-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: call multicall v3 contract, add unit test for amoy, base, polyg…
…on chain
- Loading branch information
Showing
8 changed files
with
1,464 additions
and
244 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ethers } from 'ethers'; | ||
import { assert } from 'chai'; | ||
import { Contract, Provider } from '../src'; | ||
|
||
const rpcUrl = 'https://polygon-amoy.drpc.org' | ||
const provider = new ethers.providers.JsonRpcProvider(rpcUrl); | ||
const ethcallProvider = new Provider(provider, 80002); | ||
|
||
describe('amoy network', () => { | ||
it('should retrieve totalSupply both of the tokens successfully', async () => { | ||
const abi = ['function totalSupply() public view returns (uint256)']; | ||
const addresses = [ | ||
'0x0Fd9e8d3aF1aaee056EB9e802c3A762a667b1904', | ||
'0x6EEBe75caf9c579B3FBA9030760B84050283b50a' | ||
]; | ||
|
||
const linkContract = new Contract(addresses[0], abi); | ||
const usdcContract = new Contract(addresses[1], abi); | ||
|
||
const calls = [linkContract.totalSupply(), usdcContract.totalSupply()]; | ||
const [linkSupply, usdcSupply] = await ethcallProvider.all(calls); | ||
|
||
assert.equal(linkSupply.toString(), '10001000000000000000000000'); | ||
assert.equal(usdcSupply.toString(), '100000000000000000000000000'); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ethers } from 'ethers'; | ||
import { assert } from 'chai'; | ||
import { Contract, Provider } from '../src'; | ||
|
||
const rpcUrl = 'https://base-pokt.nodies.app' | ||
const provider = new ethers.providers.JsonRpcProvider(rpcUrl); | ||
const ethcallProvider = new Provider(provider, 8453); | ||
|
||
describe('base network', () => { | ||
it('should retrieve totalSupply both of the tokens successfully', async () => { | ||
const abi = ['function totalSupply() public view returns (uint256)']; | ||
const addresses = [ | ||
'0xfA980cEd6895AC314E7dE34Ef1bFAE90a5AdD21b', | ||
'0x1C7a460413dD4e964f96D8dFC56E7223cE88CD85' | ||
]; | ||
|
||
const primeContract = new Contract(addresses[0], abi); | ||
const seamContract = new Contract(addresses[1], abi); | ||
|
||
const calls = [primeContract.totalSupply(), seamContract.totalSupply()]; | ||
const [primeSupply, seamSupply] = await ethcallProvider.all(calls); | ||
|
||
assert.equal(primeSupply.toString(), '655283967592417997806328'); | ||
assert.equal(seamSupply.toString(), '100000000000000000000000000'); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,58 @@ | ||
import {InfuraProvider} from '@ethersproject/providers'; | ||
import { InfuraProvider } from '@ethersproject/providers'; | ||
import { assert } from 'chai'; | ||
import { Contract, Provider } from '../src'; | ||
|
||
const provider = new InfuraProvider('mainnet'); | ||
const ethcallProvider = new Provider(provider, 1); | ||
|
||
it('human readable abi', async () => { | ||
const abi = ['function totalSupply() public view returns (uint256)']; | ||
const addresses = [ | ||
'0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', | ||
'0x1f9840a85d5af5bf1d1762f925bdaddc4201f984' | ||
]; | ||
describe('ethereum network', () => { | ||
it('human readable abi', async () => { | ||
const abi = ['function totalSupply() public view returns (uint256)']; | ||
const addresses = [ | ||
'0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', | ||
'0x1f9840a85d5af5bf1d1762f925bdaddc4201f984' | ||
]; | ||
|
||
const yfiContract = new Contract(addresses[0], abi); | ||
const uniContract = new Contract(addresses[1], abi); | ||
const yfiContract = new Contract(addresses[0], abi); | ||
const uniContract = new Contract(addresses[1], abi); | ||
|
||
const calls = [yfiContract.totalSupply(), uniContract.totalSupply()]; | ||
const [yfiSupply, uniSupply] = await ethcallProvider.all(calls); | ||
const calls = [yfiContract.totalSupply(), uniContract.totalSupply()]; | ||
const [yfiSupply, uniSupply] = await ethcallProvider.all(calls); | ||
|
||
assert.equal(yfiSupply.toString(), '36666000000000000000000'); | ||
assert.equal(uniSupply.toString(), '1000000000000000000000000000'); | ||
}); | ||
assert.equal(yfiSupply.toString(), '36666000000000000000000'); | ||
assert.equal(uniSupply.toString(), '1000000000000000000000000000'); | ||
}).timeout(5_000); | ||
|
||
it('json abi', async () => { | ||
const abi = [ | ||
{ | ||
it('json abi', async () => { | ||
const abi = [ | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: 'totalSupply', | ||
outputs: [ | ||
{ | ||
internalType: 'uint256', | ||
name: '', | ||
type: 'uint256' | ||
} | ||
{ | ||
internalType: 'uint256', | ||
name: '', | ||
type: 'uint256' | ||
} | ||
], | ||
payable: false, | ||
stateMutability: 'view', | ||
type: 'function' | ||
} | ||
]; | ||
const addresses = [ | ||
'0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', | ||
'0x1f9840a85d5af5bf1d1762f925bdaddc4201f984' | ||
]; | ||
|
||
const yfiContract = new Contract(addresses[0], abi); | ||
const uniContract = new Contract(addresses[1], abi); | ||
|
||
const calls = [yfiContract.totalSupply(), uniContract.totalSupply()]; | ||
const [yfiSupply, uniSupply] = await ethcallProvider.all(calls); | ||
|
||
assert.equal(yfiSupply.toString(), '36666000000000000000000'); | ||
assert.equal(uniSupply.toString(), '1000000000000000000000000000'); | ||
}); | ||
} | ||
]; | ||
const addresses = [ | ||
'0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', | ||
'0x1f9840a85d5af5bf1d1762f925bdaddc4201f984' | ||
]; | ||
|
||
const yfiContract = new Contract(addresses[0], abi); | ||
const uniContract = new Contract(addresses[1], abi); | ||
|
||
const calls = [yfiContract.totalSupply(), uniContract.totalSupply()]; | ||
const [yfiSupply, uniSupply] = await ethcallProvider.all(calls); | ||
|
||
assert.equal(yfiSupply.toString(), '36666000000000000000000'); | ||
assert.equal(uniSupply.toString(), '1000000000000000000000000000'); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ethers } from 'ethers'; | ||
import { assert } from 'chai'; | ||
import { Contract, Provider } from '../src'; | ||
|
||
const rpcUrl = 'https://polygon-pokt.nodies.app' | ||
const provider = new ethers.providers.JsonRpcProvider(rpcUrl); | ||
const ethcallProvider = new Provider(provider, 137); | ||
|
||
describe('polygon network', () => { | ||
it('should retrieve totalSupply both of the tokens successfully', async () => { | ||
const abi = ['function totalSupply() public view returns (uint256)']; | ||
const addresses = [ | ||
'0x0000000000000000000000000000000000001010', | ||
'0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619' | ||
]; | ||
|
||
const maticContract = new Contract(addresses[0], abi); | ||
const wethContract = new Contract(addresses[1], abi); | ||
|
||
const calls = [maticContract.totalSupply(), wethContract.totalSupply()]; | ||
const [maticSupply, wethSupply] = await ethcallProvider.all(calls); | ||
|
||
assert.equal(maticSupply.toString(), '10000000000000000000000000000'); | ||
assert.equal(wethSupply.toString(), '151625134652898175725399'); | ||
}) | ||
}) |
Oops, something went wrong.