Skip to content

Commit

Permalink
add official tokens address and contract wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjah committed Oct 18, 2024
1 parent fa5345d commit 548f418
Show file tree
Hide file tree
Showing 15 changed files with 437 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/contracts-wrappers/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './token'
export * from './tokens'
112 changes: 112 additions & 0 deletions src/contracts-wrappers/tokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { Provider } from '../provider'
import { CHAIN_ID, Network } from '../utils'
import { MRC20 } from './token'

export const MAINNET_TOKENS = {
USDCe: 'AS1hCJXjndR4c9vekLWsXGnrdigp4AaZ7uYG3UKFzzKnWVsrNLPJ',
USDTb: 'AS12LKs9txoSSy8JgFJgV96m8k5z9pgzjYMYSshwN67mFVuj3bdUV',
DAIe: 'AS1ZGF1upwp9kPRvDKLxFAKRebgg7b3RWDnhgV7VvdZkZsUL7Nuv',
WETHe: 'AS124vf3YfAJCSCQVYKczzuWWpXrximFpbTmX4rheLs5uNSftiiRY',
WETHb: 'AS125oPLYRTtfVjpWisPZVTLjBhCFfQ1jDsi75XNtRm1NZux54eCj',
PUR: 'AS133eqPPaPttJ6hJnk3sfoG5cjFFqBDi1VGxdo2wzWkq8AfZnan',
}

export const BUILDNET_TOKENS = {
DAIs: 'AS12LpYyAjYRJfYhyu7fkrS224gMdvFHVEeVWoeHZzMdhis7UZ3Eb',
WETHs: 'AS1gt69gqYD92dqPyE6DBRJ7KjpnQHqFzFs2YCkBcSnuxX5bGhBC',
USDCs: 'AS12k8viVmqPtRuXzCm6rKXjLgpQWqbuMjc37YHhB452KSUUb9FgL',
USDTbt: 'AS12ix1Qfpue7BB8q6mWVtjNdNE9UV3x4MaUo7WhdUubov8sJ3CuP',
WETHbt: 'AS12RmCXTA9NZaTBUBnRJuH66AGNmtEfEoqXKxLdmrTybS6GFJPFs',
}

function checkNetwork(provider: Provider, isMainnet: boolean): void {

Check warning on line 23 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
provider.networkInfos().then((network: Network) => {

Check warning on line 24 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
if (isMainnet && network.chainId !== CHAIN_ID.Mainnet) {

Check warning on line 25 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 25 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
console.warn('This contract is only available on mainnet')

Check warning on line 26 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
} else if (!isMainnet && network.chainId === CHAIN_ID.Mainnet) {

Check warning on line 27 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 27 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
console.warn('This contract is only available on buildnet')

Check warning on line 28 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 29 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 29 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 29 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 29 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 29 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
})

Check warning on line 30 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

///////////////// MAINNET TOKENS //////////////////////

export class USDCe extends MRC20 {
constructor(public provider: Provider) {

Check warning on line 36 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 36 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
checkNetwork(provider, true)

Check warning on line 37 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
super(provider, MAINNET_TOKENS.USDCe)

Check warning on line 38 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}

export class USDTb extends MRC20 {
constructor(public provider: Provider) {

Check warning on line 43 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 43 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
checkNetwork(provider, true)

Check warning on line 44 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
super(provider, MAINNET_TOKENS.USDTb)

Check warning on line 45 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}

export class DAIe extends MRC20 {
constructor(public provider: Provider) {

Check warning on line 50 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
checkNetwork(provider, true)

Check warning on line 51 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
super(provider, MAINNET_TOKENS.DAIe)

Check warning on line 52 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}

export class WETHe extends MRC20 {
constructor(public provider: Provider) {

Check warning on line 57 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
checkNetwork(provider, true)

Check warning on line 58 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
super(provider, MAINNET_TOKENS.WETHe)

Check warning on line 59 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}

export class WETHb extends MRC20 {
constructor(public provider: Provider) {

Check warning on line 64 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
checkNetwork(provider, true)

Check warning on line 65 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
super(provider, MAINNET_TOKENS.WETHb)

Check warning on line 66 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}

export class PUR extends MRC20 {
constructor(public provider: Provider) {

Check warning on line 71 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
checkNetwork(provider, true)

Check warning on line 72 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
super(provider, MAINNET_TOKENS.PUR)

Check warning on line 73 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}

///////////////// BUILDNET TOKENS //////////////////////

export class DAIs extends MRC20 {
constructor(public provider: Provider) {

Check warning on line 80 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
checkNetwork(provider, false)

Check warning on line 81 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
super(provider, BUILDNET_TOKENS.DAIs)

Check warning on line 82 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}

export class WETHs extends MRC20 {
constructor(public provider: Provider) {

Check warning on line 87 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
checkNetwork(provider, false)

Check warning on line 88 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
super(provider, BUILDNET_TOKENS.WETHs)

Check warning on line 89 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}

export class USDCs extends MRC20 {
constructor(public provider: Provider) {

Check warning on line 94 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
checkNetwork(provider, false)

Check warning on line 95 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
super(provider, BUILDNET_TOKENS.USDCs)

Check warning on line 96 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}

export class USDTbt extends MRC20 {
constructor(public provider: Provider) {

Check warning on line 101 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
checkNetwork(provider, false)

Check warning on line 102 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
super(provider, BUILDNET_TOKENS.USDTbt)

Check warning on line 103 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}

export class WETHbt extends MRC20 {
constructor(public provider: Provider) {

Check warning on line 108 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
checkNetwork(provider, false)

Check warning on line 109 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
super(provider, BUILDNET_TOKENS.WETHbt)

Check warning on line 110 in src/contracts-wrappers/tokens.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}
7 changes: 3 additions & 4 deletions test/integration/MRC20.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { MRC20 } from '../../src/contracts-wrappers'
import { provider } from './setup'

const USDC = 'AS12k8viVmqPtRuXzCm6rKXjLgpQWqbuMjc37YHhB452KSUUb9FgL'
describe('Generic token wrapper tests', () => {
let usdcContract: MRC20
const USDC = 'AS12k8viVmqPtRuXzCm6rKXjLgpQWqbuMjc37YHhB452KSUUb9FgL'

let usdcContract: MRC20

describe('Token wrapper tests', () => {
beforeAll(async () => {
usdcContract = new MRC20(provider, USDC)
})
Expand Down
2 changes: 2 additions & 0 deletions test/integration/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { Web3Provider } from '../../src/provider'

export let account: Account
export let provider: Web3Provider
export let mainnetProvider: Web3Provider

jest.setTimeout(120_000)

beforeAll(async () => {
account = await Account.fromEnv()
provider = Web3Provider.buildnet(account)
mainnetProvider = Web3Provider.mainnet(account)

// eslint-disable-next-line no-console
console.log(
Expand Down
29 changes: 29 additions & 0 deletions test/integration/tokens/DAIe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { DAIe } from '../../../src/contracts-wrappers'
import { mainnetProvider } from './../setup'

describe('DAIe wrapper tests', () => {
let contract: DAIe
beforeAll(async () => {
contract = new DAIe(mainnetProvider)
})

test('version', async () => {
const version = await contract.version()
expect(version).toBe('0.0.1')
})

test('name', async () => {
const name = await contract.name()
expect(name).toBe('Dai Stablecoin')
})

test('symbol', async () => {
const symbol = await contract.symbol()
expect(symbol).toBe('DAI.e')
})

test('decimals', async () => {
const decimals = await contract.decimals()
expect(decimals).toBe(18)
})
})
29 changes: 29 additions & 0 deletions test/integration/tokens/DAIs.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { DAIs } from '../../../src/contracts-wrappers'
import { provider } from './../setup'

describe('DAIs wrapper tests', () => {
let contract: DAIs
beforeAll(async () => {
contract = new DAIs(provider)
})

test('version', async () => {
const version = await contract.version()
expect(version).toBe('0.0.1')
})

test('name', async () => {
const name = await contract.name()
expect(name).toBe('Sepolia tDAI')
})

test('symbol', async () => {
const symbol = await contract.symbol()
expect(symbol).toBe('tDAI.s')
})

test('decimals', async () => {
const decimals = await contract.decimals()
expect(decimals).toBe(18)
})
})
29 changes: 29 additions & 0 deletions test/integration/tokens/PUR.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { PUR } from '../../../src/contracts-wrappers'
import { mainnetProvider } from './../setup'

describe('PUR wrapper tests', () => {
let contract: PUR
beforeAll(async () => {
contract = new PUR(mainnetProvider)
})

test('version', async () => {
const version = await contract.version()
expect(version).toBe('0.0.1')
})

test('name', async () => {
const name = await contract.name()
expect(name).toBe('Purrfect Universe')
})

test('symbol', async () => {
const symbol = await contract.symbol()
expect(symbol).toBe('PUR')
})

test('decimals', async () => {
const decimals = await contract.decimals()
expect(decimals).toBe(18)
})
})
29 changes: 29 additions & 0 deletions test/integration/tokens/USDCe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { USDCe } from '../../../src/contracts-wrappers'
import { mainnetProvider } from './../setup'

describe('USDCe wrapper tests', () => {
let contract: USDCe
beforeAll(async () => {
contract = new USDCe(mainnetProvider)
})

test('version', async () => {
const version = await contract.version()
expect(version).toBe('0.0.1')
})

test('name', async () => {
const name = await contract.name()
expect(name).toBe('USD Coin')
})

test('symbol', async () => {
const symbol = await contract.symbol()
expect(symbol).toBe('USDC.e')
})

test('decimals', async () => {
const decimals = await contract.decimals()
expect(decimals).toBe(6)
})
})
29 changes: 29 additions & 0 deletions test/integration/tokens/USDCs.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { USDCs } from '../../../src/contracts-wrappers'
import { provider } from './../setup'

describe('USDCs wrapper tests', () => {
let contract: USDCs
beforeAll(async () => {
contract = new USDCs(provider)
})

test('version', async () => {
const version = await contract.version()
expect(version).toBe('0.0.1')
})

test('name', async () => {
const name = await contract.name()
expect(name).toBe('Sepolia USDC')
})

test('symbol', async () => {
const symbol = await contract.symbol()
expect(symbol).toBe('USDC.s')
})

test('decimals', async () => {
const decimals = await contract.decimals()
expect(decimals).toBe(6)
})
})
29 changes: 29 additions & 0 deletions test/integration/tokens/USDTb.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { USDTb } from '../../../src/contracts-wrappers'
import { mainnetProvider } from './../setup'

describe('USDTb wrapper tests', () => {
let contract: USDTb
beforeAll(async () => {
contract = new USDTb(mainnetProvider)
})

test('version', async () => {
const version = await contract.version()
expect(version).toBe('0.0.1')
})

test('name', async () => {
const name = await contract.name()
expect(name).toBe('Bsc USDT')
})

test('symbol', async () => {
const symbol = await contract.symbol()
expect(symbol).toBe('USDT.b')
})

test('decimals', async () => {
const decimals = await contract.decimals()
expect(decimals).toBe(18)
})
})
29 changes: 29 additions & 0 deletions test/integration/tokens/USDTbt.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { USDTbt } from '../../../src/contracts-wrappers'
import { provider } from './../setup'

describe('USDTbt wrapper tests', () => {
let contract: USDTbt
beforeAll(async () => {
contract = new USDTbt(provider)
})

test('version', async () => {
const version = await contract.version()
expect(version).toBe('0.0.1')
})

test('name', async () => {
const name = await contract.name()
expect(name).toBe('Binance-peg USD')
})

test('symbol', async () => {
const symbol = await contract.symbol()
expect(symbol).toBe('USDT.bt')
})

test('decimals', async () => {
const decimals = await contract.decimals()
expect(decimals).toBe(18)
})
})
29 changes: 29 additions & 0 deletions test/integration/tokens/WETHb.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { WETHb } from '../../../src/contracts-wrappers'
import { mainnetProvider } from './../setup'

describe('WETH.b wrapper tests', () => {
let contract: WETHb
beforeAll(async () => {
contract = new WETHb(mainnetProvider)
})

test('version', async () => {
const version = await contract.version()
expect(version).toBe('0.0.1')
})

test('name', async () => {
const name = await contract.name()
expect(name).toBe('Bsc ETH')
})

test('symbol', async () => {
const symbol = await contract.symbol()
expect(symbol).toBe('WETH.b')
})

test('decimals', async () => {
const decimals = await contract.decimals()
expect(decimals).toBe(18)
})
})
Loading

0 comments on commit 548f418

Please sign in to comment.