1+ const fs = require ( 'fs' )
2+ const utils = require ( 'web3-utils' )
13const { assert } = require ( 'chai' )
24const conf = require ( './config' )
35const helpers = require ( './helpers' )
46const web3 = conf . web3
57
6- it ( 'deploy contract and interact ' , async ( ) => {
7- let deployed = await helpers . deployContract ( " storage" )
8+ it ( 'deploys mutlicall3 contract and interacts ' , async ( ) => {
9+ let deployed = await helpers . deployContract ( ' storage' )
810 let contractAddress = deployed . receipt . contractAddress
911
1012 // get the default deployed value on contract
1113 const initValue = 1337
12- let callRetrieve = await deployed . contract . methods . retrieve ( ) . encodeABI ( )
13- result = await web3 . eth . call ( { to : contractAddress , data : callRetrieve } , " latest" )
14+ let callRetrieve = deployed . contract . methods . retrieve ( ) . encodeABI ( )
15+ result = await web3 . eth . call ( { to : contractAddress , data : callRetrieve } , ' latest' )
1416 assert . equal ( result , initValue )
1517
16- let multicall3 = await helpers . deployContract ( "multicall3" )
17- let multicall3Address = multicall3 . receipt . contractAddress
18+ let transfer = await helpers . signAndSend ( {
19+ from : conf . eoa . address ,
20+ to : '0x05f32b3cc3888453ff71b01135b34ff8e41263f2' ,
21+ value : utils . toWei ( '1.0' , 'ether' ) ,
22+ gasPrice : conf . minGasPrice ,
23+ gasLimit : 55_000 ,
24+ } )
25+ assert . equal ( transfer . receipt . status , conf . successStatus )
26+
27+ let multicall3DeploymentTx = await fs . promises . readFile ( `${ __dirname } /../fixtures/multicall3.byte` , 'utf8' )
28+ let response = await helpers . callRPCMethod (
29+ 'eth_sendRawTransaction' ,
30+ [ multicall3DeploymentTx ]
31+ )
32+ assert . equal ( 200 , response . status )
33+
34+ let txHash = response . body . result
35+ let receipt = await web3 . eth . getTransactionReceipt ( txHash )
36+ let multicall3Address = receipt . contractAddress
1837
1938 // make sure deploy results are correct
20- assert . equal ( multicall3 . receipt . status , conf . successStatus )
21- assert . isString ( multicall3 . receipt . transactionHash )
39+ assert . equal ( receipt . status , conf . successStatus )
40+ assert . equal ( receipt . from , '0x05f32B3cC3888453ff71B01135B34FF8e41263F2' )
41+ assert . isString ( receipt . transactionHash )
2242 assert . isString ( multicall3Address )
2343
24- let callSum20 = await deployed . contract . methods . sum ( 10 , 10 ) . encodeABI ( )
25- let callSum50 = await deployed . contract . methods . sum ( 10 , 40 ) . encodeABI ( )
26- let callAggregate3 = await multicall3 . contract . methods . aggregate3 (
44+ let tx = await web3 . eth . getTransaction ( txHash )
45+ assert . equal ( tx . from , '0x05f32B3cC3888453ff71B01135B34FF8e41263F2' )
46+ assert . isUndefined ( tx . chainId )
47+
48+ let block = await web3 . eth . getBlock ( receipt . blockNumber , true )
49+ assert . equal ( block . transactions [ 0 ] . from , '0x05f32B3cC3888453ff71B01135B34FF8e41263F2' )
50+ assert . isUndefined ( block . transactions [ 0 ] . chainId )
51+
52+ let multicall3ABI = require ( '../fixtures/multicall3ABI.json' )
53+ let multicall3 = new web3 . eth . Contract ( multicall3ABI , multicall3Address , { handleReverted : true } )
54+
55+ let callSum20 = deployed . contract . methods . sum ( 10 , 10 ) . encodeABI ( )
56+ let callSum50 = deployed . contract . methods . sum ( 10 , 40 ) . encodeABI ( )
57+ let callAggregate3 = multicall3 . methods . aggregate3 (
2758 [
2859 {
2960 target : contractAddress ,
@@ -43,7 +74,7 @@ it('deploy contract and interact', async () => {
4374 to : multicall3Address ,
4475 data : callAggregate3
4576 } ,
46- " latest"
77+ ' latest'
4778 )
4879 let decodedResult = web3 . eth . abi . decodeParameter (
4980 {
0 commit comments