-
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.
Merge pull request #6 from c0rv0s/master
Enable human readable abis and include multicall address for goerli
- Loading branch information
Showing
5 changed files
with
73 additions
and
13 deletions.
There are no files selected for viewing
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
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,3 +1,56 @@ | ||
describe('noop', () => { | ||
// no tests :( | ||
import { assert } from 'chai'; | ||
import { ethers } from 'ethers'; | ||
import { Contract, Provider } from '../src'; | ||
|
||
const provider = new ethers.providers.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' | ||
]; | ||
|
||
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'); | ||
}); | ||
|
||
it('json abi', async () => { | ||
const abi = [ | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: 'totalSupply', | ||
outputs: [ | ||
{ | ||
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'); | ||
}); |
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