11import { fp , OpType , randomEvmAddress } from '@mimicprotocol/sdk'
22import { Context , ContractCallMock , GetPriceMock , runTask , Transfer } from '@mimicprotocol/test-ts'
33import { expect } from 'chai'
4+ import { Interface } from 'ethers'
5+
6+ import ERC20Abi from '../abis/ERC20.json'
7+
8+ const ERC20Interface = new Interface ( ERC20Abi )
49
510describe ( 'Task' , ( ) => {
611 const taskDir = './build'
@@ -22,10 +27,7 @@ describe('Task', () => {
2227
2328 const prices : GetPriceMock [ ] = [
2429 {
25- request : {
26- token : inputs . token ,
27- chainId : inputs . chainId ,
28- } ,
30+ request : { token : inputs . token , chainId : inputs . chainId } ,
2931 response : [ '1000000000000000000' ] , // 1 token = 1 USD
3032 } ,
3133 ]
@@ -35,29 +37,18 @@ describe('Task', () => {
3537 request : {
3638 to : inputs . token ,
3739 chainId : inputs . chainId ,
38- fnSelector : '0x70a08231' , // `balanceOf`,
39- params : [
40- {
41- value : inputs . recipient ,
42- abiType : 'address' ,
43- } ,
44- ] ,
45- } ,
46- response : {
47- value : balance ,
48- abiType : 'uint256' ,
40+ fnSelector : ERC20Interface . getFunction ( 'balanceOf' ) ! . selector ,
41+ params : [ { value : inputs . recipient , abiType : 'address' } ] ,
4942 } ,
43+ response : { value : balance , abiType : 'uint256' } ,
5044 } ,
5145 {
5246 request : {
5347 to : inputs . token ,
5448 chainId : inputs . chainId ,
55- fnSelector : '0x313ce567' , // `decimals`
56- } ,
57- response : {
58- value : '6' ,
59- abiType : 'uint8' ,
49+ fnSelector : ERC20Interface . getFunction ( 'decimals' ) ! . selector ,
6050 } ,
51+ response : { value : '6' , abiType : 'uint8' } ,
6152 } ,
6253 ]
6354
0 commit comments