@@ -20,9 +20,6 @@ import { TxStatus } from "@aztec/stdlib/tx";
2020import { AccountManager } from "@aztec/aztec.js/wallet" ;
2121import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice' ;
2222import { FeeJuicePaymentMethodWithClaim , PrivateFeePaymentMethod , PublicFeePaymentMethod } from "@aztec/aztec.js/fee" ;
23- import { GasFees , GasSettings } from "@aztec/stdlib/gas" ;
24-
25- const sleep = ( ms : number ) => new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
2623
2724describe ( "Accounts" , ( ) => {
2825 let wallet : TestWallet ;
@@ -70,8 +67,7 @@ describe("Accounts", () => {
7067 let signingKey = GrumpkinScalar . random ( ) ;
7168 let salt = Fr . random ( ) ;
7269 ownerAccount = await wallet . createSchnorrAccount ( secretKey , salt , signingKey ) ;
73- ( await ownerAccount . getDeployMethod ( ) ) . send ( { from : AztecAddress . ZERO , fee : { paymentMethod : sponsoredPaymentMethod } } ) . wait ( { timeout : getTimeouts ( ) . deployTimeout } ) ;
74- await wallet . registerSender ( ownerAccount . address ) ;
70+ await ( await ownerAccount . getDeployMethod ( ) ) . send ( { from : AztecAddress . ZERO , fee : { paymentMethod : sponsoredPaymentMethod } } ) . wait ( { timeout : getTimeouts ( ) . deployTimeout } ) ;
7571
7672 // Set up fee juice contract
7773 const feeJuiceInstance = await getCanonicalFeeJuice ( ) ;
@@ -92,78 +88,51 @@ describe("Accounts", () => {
9288 it ( "Creates accounts with fee juice" , async ( ) => {
9389 if ( getEnv ( ) === 'devnet' ) return ;
9490
95- // TODO: fix
96-
97- // console.log('Starting "Creates accounts with fee juice" test');
98- // console.log(`Random addresses: ${randomAddresses.map(a => a.toString()).join(', ')}`);
91+ console . log ( 'Starting "Creates accounts with fee juice" test' ) ;
92+ console . log ( `Random addresses: ${ randomAddresses . map ( a => a . toString ( ) ) . join ( ', ' ) } ` ) ;
9993
10094 // balance of each random account is 0 before bridge
101- // console.log('Checking initial balances...');
102- // let balances = await Promise.all(randomAddresses.map(async a =>
103- // await feeJuiceContract.methods.balance_of_public(a).simulate({ from: ownerAccount.address })
104- // ));
105- // console.log(`Initial balances: ${balances.join(', ')}`);
106- // balances.forEach(b => expect(b).toBe(0n));
95+ console . log ( 'Checking initial balances...' ) ;
96+ let balances = await Promise . all ( randomAddresses . map ( async a =>
97+ await feeJuiceContract . methods . balance_of_public ( a ) . simulate ( { from : ownerAccount . address } )
98+ ) ) ;
99+ console . log ( `Initial balances: ${ balances . join ( ', ' ) } ` ) ;
100+ balances . forEach ( b => expect ( b ) . toBe ( 0n ) ) ;
107101
108102 // bridge funds to unfunded random addresses
109- // const claimAmount = await l1PortalManager.getTokenManager().getMintAmount();
110- // console.log(`Claim amount: ${claimAmount}`);
111- // let claims: L2AmountClaim[] = [];
112- // bridge sequentially to avoid l1 txs (nonces) being processed out of order
113- // for (let i = 0; i < randomAddresses.length; i++) {
114- // console.log(`Bridging tokens for address ${i}: ${randomAddresses[i].toString()}`);
115- // const claim = await l1PortalManager.bridgeTokensPublic(randomAddresses[i], claimAmount, true);
116- // claims.push(claim);
117- // console.log(`Bridge complete for address ${i}`);
118- // console.log(` - claimAmount: ${claim.claimAmount.toString()}`);
119- // console.log(` - claimSecret: ${claim.claimSecret.toString()}`);
120- // console.log(` - messageLeafIndex: ${claim.messageLeafIndex.toString()}`);
121- // }
122- // console.log(`Total claims created: ${claims.length}`);
103+ const claimAmount = await l1PortalManager . getTokenManager ( ) . getMintAmount ( ) ;
104+ console . log ( `Claim amount: ${ claimAmount } ` ) ;
105+ let claims : L2AmountClaim [ ] = [ ] ;
106+ // bridge sequentially to avoid l1 txs(nonces) being processed out of order
107+ for ( let i = 0 ; i < randomAddresses . length ; i ++ ) {
108+ console . log ( `Bridging tokens for address ${ i } : ${ randomAddresses [ i ] . toString ( ) } ` ) ;
109+ const claim = await l1PortalManager . bridgeTokensPublic ( randomAddresses [ i ] , claimAmount , true ) ;
110+ claims . push ( claim ) ;
111+ }
112+ console . log ( `Total claims created: ${ claims . length } ` ) ;
123113
124114 // arbitrary transactions to progress 2 blocks, and have fee juice on Aztec ready to claim
125- // console.log('Deploying first PrivateVotingContract to progress blocks...');
126- // await PrivateVotingContract.deploy(wallet, ownerAccount.address).send({
127- // from: ownerAccount.address,
128- // fee: { paymentMethod: sponsoredPaymentMethod }
129- // }).deployed({ timeout: getTimeouts().deployTimeout }); // deploy contract with first funded wallet
130- // console.log('First PrivateVotingContract deployed');
131-
132- // console.log('Deploying second PrivateVotingContract to progress blocks...');
133- // await PrivateVotingContract.deploy(wallet, ownerAccount.address).send({
134- // from: ownerAccount.address,
135- // fee: { paymentMethod: sponsoredPaymentMethod }
136- // }).deployed({ timeout: getTimeouts().deployTimeout }); // deploy contract with first funded wallet
137- // console.log('Second PrivateVotingContract deployed');
138-
139- // Manually claim fee juice for each random account first
140- // logger.info('Starting fee juice claims...');
141- // for (let i = 0; i < randomAccountManagers.length; i++) {
142- // logger.info(`Claiming fee juice for address ${i}: ${randomAddresses[i].toString()}`);
143- // await feeJuiceContract.methods.claim(
144- // randomAddresses[i],
145- // claims[i].claimAmount,
146- // claims[i].claimSecret,
147- // claims[i].messageLeafIndex
148- // ).send({ from: ownerAccount.address, fee: { paymentMethod: sponsoredPaymentMethod } }).wait({ timeout: getTimeouts().txTimeout });
149- // logger.info(`Claim successful for address ${i}`);
150- // }
151- // logger.info('All fee juice claims completed');
115+ console . log ( 'Deploying first PrivateVotingContract to progress blocks...' ) ;
116+ await PrivateVotingContract . deploy ( wallet , ownerAccount . address ) . send ( {
117+ from : ownerAccount . address ,
118+ fee : { paymentMethod : sponsoredPaymentMethod }
119+ } ) . deployed ( { timeout : getTimeouts ( ) . deployTimeout } ) ; // deploy contract with first funded wallet
120+ console . log ( 'First PrivateVotingContract deployed' ) ;
121+
122+ console . log ( 'Deploying second PrivateVotingContract to progress blocks...' ) ;
123+ await PrivateVotingContract . deploy ( wallet , ownerAccount . address ) . send ( {
124+ from : ownerAccount . address ,
125+ fee : { paymentMethod : sponsoredPaymentMethod }
126+ } ) . deployed ( { timeout : getTimeouts ( ) . deployTimeout } ) ; // deploy contract with first funded wallet
127+ console . log ( 'Second PrivateVotingContract deployed' ) ;
152128
153129 // Now deploy random accounts using FeeJuicePaymentMethodWithClaim (which claims and pays in one tx)
154- // console.log('Starting account deployments with FeeJuicePaymentMethodWithClaim...');
155- // for (let i = 0; i < randomAccountManagers.length; i++) {
156- // const paymentMethod = new FeeJuicePaymentMethodWithClaim(randomAddresses[i], claims[i]);
157- // const deployTx = (await randomAccountManagers[i].getDeployMethod()).send({ from: AztecAddress.ZERO, fee: { paymentMethod } });
158- // const receipt = await deployTx.wait({ timeout: getTimeouts().deployTimeout });
159- // }
160-
161- // balance after deploy should still have full claimed amount (since we used sponsored payment)
162- // balances = await Promise.all(randomAddresses.map(async a =>
163- // await feeJuiceContract.methods.balance_of_public(a).simulate({ from: ownerAccount.address })
164- // ));
165- // balances.forEach(b => expect(b).toBe(claimAmount));
166-
130+ console . log ( 'Starting account deployments with FeeJuicePaymentMethodWithClaim...' ) ;
131+ for ( let i = 0 ; i < randomAccountManagers . length ; i ++ ) {
132+ const paymentMethod = new FeeJuicePaymentMethodWithClaim ( randomAddresses [ i ] , claims [ i ] ) ;
133+ const deployTx = ( await randomAccountManagers [ i ] . getDeployMethod ( ) ) . send ( { from : AztecAddress . ZERO , fee : { paymentMethod } } ) ;
134+ const receipt = await deployTx . wait ( { timeout : getTimeouts ( ) . deployTimeout } ) ;
135+ }
167136 } ) ;
168137
169138 it ( "Deploys first unfunded account from first funded account" , async ( ) => {
0 commit comments