@@ -3,6 +3,9 @@ const { encodeFunctionData } = require('viem')
33const { privateKeyToAccount } = require ( 'viem/accounts' )
44const { relay, walletClient, publicClient } = require ( './viem/config' )
55const { abi, bytecode } = require ( './viem/contract' )
6+ const conf = require ( './config' )
7+ const helpers = require ( './helpers' )
8+ const web3 = conf . web3
69
710// eoa is 0xfe847d8bebe46799FCE83eB52f38Ef4b907996A6
811const eoa = privateKeyToAccount ( '0x3a0901a19a40f2041727fe1a973137ad917fc925ce716983e1376e927658b12e' )
@@ -46,6 +49,33 @@ it('should send transactions with relay account', async () => {
4649 contractAddress,
4750 } )
4851
52+ let txArgs = {
53+ from : relay . address ,
54+ to : eoa . address ,
55+ data : encodeFunctionData ( {
56+ abi,
57+ functionName : 'initialize' ,
58+ } ) ,
59+ authorizationList : [
60+ {
61+ address : authorization . address ,
62+ chainId : web3 . utils . numberToHex ( authorization . chainId ) ,
63+ nonce : web3 . utils . numberToHex ( authorization . nonce ) ,
64+ r : authorization . r ,
65+ s : authorization . s ,
66+ yParity : web3 . utils . numberToHex ( authorization . yParity )
67+ }
68+ ]
69+ }
70+
71+ let response = await helpers . callRPCMethod (
72+ 'eth_estimateGas' ,
73+ [ txArgs , 'latest' ]
74+ )
75+ assert . equal ( response . status , 200 )
76+ assert . isDefined ( response . body )
77+ assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 63779n )
78+
4979 // 2. Designate the Contract on the EOA, and invoke the `initialize` function.
5080 let hash = await walletClient . sendTransaction ( {
5181 authorizationList : [ authorization ] , // 3. Pass the Authorization as a parameter.
@@ -54,6 +84,7 @@ it('should send transactions with relay account', async () => {
5484 functionName : 'initialize' ,
5585 } ) ,
5686 to : eoa . address ,
87+ gas : web3 . utils . hexToNumber ( response . body . result )
5788 } )
5889
5990 await new Promise ( ( res ) => setTimeout ( ( ) => res ( ) , 1500 ) )
@@ -108,14 +139,42 @@ it('should send self-executing transactions', async () => {
108139 executor : 'self' ,
109140 } )
110141
142+ let txArgs = {
143+ from : relay . address ,
144+ to : relay . address ,
145+ data : encodeFunctionData ( {
146+ abi,
147+ functionName : 'initialize' ,
148+ } ) ,
149+ authorizationList : [
150+ {
151+ address : authorization . address ,
152+ chainId : web3 . utils . numberToHex ( authorization . chainId ) ,
153+ nonce : web3 . utils . numberToHex ( authorization . nonce ) ,
154+ r : authorization . r ,
155+ s : authorization . s ,
156+ yParity : web3 . utils . numberToHex ( authorization . yParity )
157+ }
158+ ]
159+ }
160+
161+ let response = await helpers . callRPCMethod (
162+ 'eth_estimateGas' ,
163+ [ txArgs , 'latest' ]
164+ )
165+ assert . equal ( response . status , 200 )
166+ assert . isDefined ( response . body )
167+ assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 63779n )
168+
111169 // 2. Designate the Contract on the EOA, and invoke the `initialize` function.
112170 let hash = await walletClient . sendTransaction ( {
113171 authorizationList : [ authorization ] , // 3. Pass the Authorization as a parameter.
114172 data : encodeFunctionData ( {
115173 abi,
116174 functionName : 'initialize' ,
117175 } ) ,
118- to : walletClient . account . address ,
176+ to : relay . address ,
177+ gas : web3 . utils . hexToNumber ( response . body . result ) ,
119178 } )
120179
121180 await new Promise ( ( res ) => setTimeout ( ( ) => res ( ) , 1500 ) )
@@ -150,7 +209,7 @@ it('should send self-executing transactions', async () => {
150209 abi,
151210 functionName : 'ping' ,
152211 } ) ,
153- to : walletClient . account . address ,
212+ to : relay . address ,
154213 } )
155214
156215 await new Promise ( ( res ) => setTimeout ( ( ) => res ( ) , 1500 ) )
0 commit comments