@@ -8,21 +8,21 @@ import { FeeJuiceContract } from "@aztec/noir-contracts.js/FeeJuice";
88import { FPCContract } from "@aztec/noir-contracts.js/FPC" ;
99import { PodRacingContract } from "../src/artifacts/PodRacing.js"
1010import { TokenContract } from "@aztec/noir-contracts.js/Token" ;
11- import { SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee/testing'
11+ import { SponsoredFeePaymentMethod , FeeJuicePaymentMethodWithClaim , PrivateFeePaymentMethod , PublicFeePaymentMethod } from '@aztec/aztec.js/fee' ;
1212import { getSponsoredFPCInstance } from "../src/utils/sponsored_fpc.js" ;
1313import { createEthereumChain } from '@aztec/ethereum/chain' ;
1414import { createExtendedL1Client } from '@aztec/ethereum/client' ;
1515import { deploySchnorrAccount } from "../src/utils/deploy_account.js" ;
1616import { setupWallet } from "../src/utils/setup_wallet.js" ;
17- import { Logger , createLogger } from '@aztec/aztec.js /log' ;
18- import { FeeJuicePaymentMethodWithClaim , PrivateFeePaymentMethod , PublicFeePaymentMethod } from '@aztec/aztec.js/fee ' ;
19- import { Fr , GrumpkinScalar } from '@aztec/aztec.js/fields ' ;
17+ import { type Logger , createLogger } from '@aztec/foundation /log' ;
18+ import { Fr } from '@aztec/aztec.js/fields ' ;
19+ import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin ' ;
2020import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum' ;
21- import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC' ;
21+ import { SponsoredFPCContractArtifact } from '@aztec/noir-contracts.js/SponsoredFPC' ;
2222import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice' ;
2323import { createAztecNodeClient } from '@aztec/aztec.js/node' ;
24- import { AztecAddress } from '@aztec/stdlib/ aztec-address ' ;
25- import { getAztecNodeUrl } from '../config/config.js' ;
24+ import { AztecAddress } from '@aztec/aztec.js/addresses ' ;
25+ import { getAztecNodeUrl , getTimeouts } from '../config/config.js' ;
2626import { GasSettings } from '@aztec/stdlib/gas' ;
2727
2828const MNEMONIC = 'test test test test test test test test test test test junk' ;
@@ -66,23 +66,27 @@ async function main() {
6666
6767 // set up sponsored fee payments
6868 const sponsoredFPC = await getSponsoredFPCInstance ( ) ;
69- await wallet . registerContract ( sponsoredFPC , SponsoredFPCContract . artifact ) ;
69+ await wallet . registerContract ( sponsoredFPC , SponsoredFPCContractArtifact ) ;
7070 const paymentMethod = new SponsoredFeePaymentMethod ( sponsoredFPC . address ) ;
71+ const timeouts = getTimeouts ( ) ;
7172
7273 // Two arbitrary txs to make the L1 message available on L2
7374 const podRacingContract = await PodRacingContract . deploy ( wallet , account1 . address ) . send ( {
7475 from : account1 . address ,
75- fee : { paymentMethod }
76- } ) . deployed ( ) ;
76+ fee : { paymentMethod } ,
77+ wait : { timeout : timeouts . deployTimeout }
78+ } ) ;
7779 const bananaCoin = await TokenContract . deploy ( wallet , account1 . address , "bananaCoin" , "BNC" , 18 ) . send ( {
7880 from : account1 . address ,
79- fee : { paymentMethod }
80- } ) . deployed ( )
81+ fee : { paymentMethod } ,
82+ wait : { timeout : timeouts . deployTimeout }
83+ } ) ;
8184
8285 // Claim Fee Juice & Pay Fees yourself
8386
84- const claimAndPay = new FeeJuicePaymentMethodWithClaim ( account2 . address , claim )
85- await ( await account2 . getDeployMethod ( ) ) . send ( { from : AztecAddress . ZERO , fee : { paymentMethod : claimAndPay } } ) . wait ( )
87+ const claimAndPay = new FeeJuicePaymentMethodWithClaim ( account2 . address , claim ) ;
88+ const deployMethod = await account2 . getDeployMethod ( ) ;
89+ await deployMethod . send ( { from : AztecAddress . ZERO , fee : { paymentMethod : claimAndPay } , wait : { timeout : timeouts . deployTimeout } } ) ;
8690 logger . info ( `New account at ${ account2 . address } deployed using claimed funds for fees.` )
8791
8892 // Pay fees yourself
@@ -91,7 +95,8 @@ async function main() {
9195 const gameId = Fr . random ( ) ;
9296 await podRacingContract . methods . create_game ( gameId ) . send ( {
9397 from : account2 . address ,
94- } ) . wait ( )
98+ wait : { timeout : timeouts . txTimeout }
99+ } ) ;
95100 logger . info ( `Game created from new account, paying fees via newWallet.` )
96101
97102 // Private Fee Payments via FPC
@@ -102,54 +107,59 @@ async function main() {
102107 // This uses bananaCoin as the fee paying asset that will be exchanged for fee juice
103108 const fpc = await FPCContract . deploy ( wallet , bananaCoin . address , account1 . address ) . send ( {
104109 from : account1 . address ,
105- fee : { paymentMethod }
106- } ) . deployed ( )
110+ fee : { paymentMethod } ,
111+ wait : { timeout : timeouts . deployTimeout }
112+ } ) ;
107113 const fpcClaim = await feeJuicePortalManager . bridgeTokensPublic ( fpc . address , FEE_FUNDING_FOR_TESTER_ACCOUNT , true ) ;
108114 // 2 public txs to make the bridged fee juice available
109115 // Mint some bananaCoin and send to the newWallet to pay fees privately
110116 await bananaCoin . methods . mint_to_private ( account2 . address , FEE_FUNDING_FOR_TESTER_ACCOUNT ) . send ( {
111117 from : account1 . address ,
112- fee : { paymentMethod }
113- } ) . wait ( )
118+ fee : { paymentMethod } ,
119+ wait : { timeout : timeouts . txTimeout }
120+ } ) ;
114121 // mint some public bananaCoin to the newWallet to pay fees publicly
115122 await bananaCoin . methods . mint_to_public ( account2 . address , FEE_FUNDING_FOR_TESTER_ACCOUNT ) . send ( {
116123 from : account1 . address ,
117- fee : { paymentMethod }
118- } ) . wait ( )
124+ fee : { paymentMethod } ,
125+ wait : { timeout : timeouts . txTimeout }
126+ } ) ;
119127 const bananaBalance = await bananaCoin . methods . balance_of_private ( account2 . address ) . simulate ( {
120128 from : account2 . address
121- } )
129+ } ) ;
122130
123131 logger . info ( `BananaCoin balance of newWallet is ${ bananaBalance } ` )
124132
125133 const feeJuiceInstance = await getCanonicalFeeJuice ( ) ;
126- await wallet . registerContract ( feeJuiceInstance . instance , FeeJuiceContract . artifact )
127- const feeJuice = await FeeJuiceContract . at ( feeJuiceInstance . address , wallet )
134+ await wallet . registerContract ( feeJuiceInstance . instance , FeeJuiceContract . artifact ) ;
135+ const feeJuice = await FeeJuiceContract . at ( feeJuiceInstance . address , wallet ) ;
128136
129- await feeJuice . methods . claim ( fpc . address , fpcClaim . claimAmount , fpcClaim . claimSecret , fpcClaim . messageLeafIndex ) . send ( { from : account2 . address } ) . wait ( )
137+ await feeJuice . methods . claim ( fpc . address , fpcClaim . claimAmount , fpcClaim . claimSecret , fpcClaim . messageLeafIndex ) . send ( { from : account2 . address , wait : { timeout : timeouts . txTimeout } } ) ;
130138
131139 logger . info ( `Fpc fee juice balance ${ await feeJuice . methods . balance_of_public ( fpc . address ) . simulate ( {
132140 from : account2 . address
133- } ) } `)
141+ } ) } `) ;
134142
135- const maxFeesPerGas = ( await node . getCurrentBaseFees ( ) ) . mul ( 1.5 ) ;
143+ const maxFeesPerGas = ( await node . getCurrentMinFees ( ) ) . mul ( 1.5 ) ;
136144 const gasSettings = GasSettings . default ( { maxFeesPerGas } ) ;
137145
138- const privateFee = new PrivateFeePaymentMethod ( fpc . address , account2 . address , wallet , gasSettings )
146+ const privateFee = new PrivateFeePaymentMethod ( fpc . address , account2 . address , wallet , gasSettings ) ;
139147 await bananaCoin . methods . transfer_in_private ( account2 . address , account1 . address , 10 , 0 ) . send ( {
140148 from : account2 . address ,
141- fee : { paymentMethod : privateFee }
142- } ) . wait ( )
149+ fee : { paymentMethod : privateFee } ,
150+ wait : { timeout : timeouts . txTimeout }
151+ } ) ;
143152
144153 logger . info ( `Transfer paid with fees via the FPC, privately.` )
145154
146155 // Public Fee Payments via FPC
147156
148- const publicFee = new PublicFeePaymentMethod ( fpc . address , account2 . address , wallet , gasSettings )
157+ const publicFee = new PublicFeePaymentMethod ( fpc . address , account2 . address , wallet , gasSettings ) ;
149158 await bananaCoin . methods . transfer_in_private ( account2 . address , account1 . address , 10 , 0 ) . send ( {
150159 from : account2 . address ,
151- fee : { paymentMethod : publicFee }
152- } ) . wait ( )
160+ fee : { paymentMethod : publicFee } ,
161+ wait : { timeout : timeouts . txTimeout }
162+ } ) ;
153163 logger . info ( `Transfer paid with fees via the FPC, publicly.` )
154164
155165 // Sponsored Fee Payment
@@ -158,8 +168,9 @@ async function main() {
158168 const sponsoredPaymentMethod = new SponsoredFeePaymentMethod ( sponsoredFPC . address ) ;
159169 await bananaCoin . methods . transfer_in_private ( account2 . address , account1 . address , 10 , 0 ) . send ( {
160170 from : account2 . address ,
161- fee : { paymentMethod : sponsoredPaymentMethod }
162- } ) . wait ( )
171+ fee : { paymentMethod : sponsoredPaymentMethod } ,
172+ wait : { timeout : timeouts . txTimeout }
173+ } ) ;
163174 logger . info ( `Transfer paid with fees from Sponsored FPC.` )
164175}
165176
0 commit comments