@aztec/end-to-end 1.2.1 → 2.0.0-nightly.20250813

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +2 -2
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/benchmark.js +4 -2
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  6. package/dest/bench/client_flows/client_flows_benchmark.js +33 -15
  7. package/dest/bench/utils.d.ts.map +1 -1
  8. package/dest/bench/utils.js +7 -4
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +11 -3
  10. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  11. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +59 -24
  12. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +3 -2
  13. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  14. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +13 -10
  15. package/dest/e2e_deploy_contract/deploy_test.d.ts +1 -1
  16. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  17. package/dest/e2e_deploy_contract/deploy_test.js +7 -6
  18. package/dest/e2e_epochs/epochs_test.d.ts +16 -2
  19. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  20. package/dest/e2e_epochs/epochs_test.js +65 -7
  21. package/dest/e2e_fees/bridging_race.notest.js +3 -1
  22. package/dest/e2e_fees/fees_test.d.ts +5 -4
  23. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  24. package/dest/e2e_fees/fees_test.js +44 -59
  25. package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -3
  26. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  27. package/dest/e2e_nested_contract/nested_contract_test.js +17 -12
  28. package/dest/e2e_p2p/p2p_network.d.ts +7 -4
  29. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  30. package/dest/e2e_p2p/p2p_network.js +43 -22
  31. package/dest/e2e_p2p/shared.d.ts +3 -3
  32. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  33. package/dest/e2e_p2p/shared.js +16 -12
  34. package/dest/e2e_token_contract/token_contract_test.d.ts +8 -4
  35. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  36. package/dest/e2e_token_contract/token_contract_test.js +48 -23
  37. package/dest/fixtures/e2e_prover_test.d.ts +1 -1
  38. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  39. package/dest/fixtures/e2e_prover_test.js +27 -10
  40. package/dest/fixtures/setup_p2p_test.d.ts +4 -1
  41. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  42. package/dest/fixtures/setup_p2p_test.js +39 -8
  43. package/dest/fixtures/snapshot_manager.d.ts +3 -1
  44. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  45. package/dest/fixtures/snapshot_manager.js +20 -17
  46. package/dest/fixtures/token_utils.d.ts +3 -3
  47. package/dest/fixtures/token_utils.d.ts.map +1 -1
  48. package/dest/fixtures/token_utils.js +14 -10
  49. package/dest/fixtures/utils.d.ts +23 -8
  50. package/dest/fixtures/utils.d.ts.map +1 -1
  51. package/dest/fixtures/utils.js +88 -56
  52. package/dest/integration_l1_publisher/write_json.d.ts +8 -0
  53. package/dest/integration_l1_publisher/write_json.d.ts.map +1 -0
  54. package/dest/integration_l1_publisher/write_json.js +57 -0
  55. package/dest/sample-dapp/connect.d.mts +2 -0
  56. package/dest/sample-dapp/connect.d.mts.map +1 -0
  57. package/dest/sample-dapp/connect.js +1 -1
  58. package/dest/sample-dapp/contracts.d.mts +3 -0
  59. package/dest/sample-dapp/contracts.d.mts.map +1 -0
  60. package/dest/sample-dapp/contracts.js +1 -1
  61. package/dest/sample-dapp/deploy.d.mts +3 -0
  62. package/dest/sample-dapp/deploy.d.mts.map +1 -0
  63. package/dest/sample-dapp/deploy.js +4 -1
  64. package/dest/sample-dapp/index.d.mts +2 -0
  65. package/dest/sample-dapp/index.d.mts.map +1 -0
  66. package/dest/sample-dapp/index.js +18 -8
  67. package/dest/shared/cross_chain_test_harness.d.ts +6 -3
  68. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  69. package/dest/shared/cross_chain_test_harness.js +50 -20
  70. package/dest/shared/gas_portal_test_harness.d.ts +3 -3
  71. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  72. package/dest/shared/gas_portal_test_harness.js +21 -6
  73. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  74. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  75. package/dest/shared/uniswap_l1_l2.js +45 -22
  76. package/dest/simulators/lending_simulator.d.ts +1 -1
  77. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  78. package/dest/simulators/lending_simulator.js +6 -2
  79. package/dest/simulators/token_simulator.d.ts +2 -1
  80. package/dest/simulators/token_simulator.d.ts.map +1 -1
  81. package/dest/simulators/token_simulator.js +12 -4
  82. package/dest/spartan/setup_test_wallets.d.ts +7 -0
  83. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  84. package/dest/spartan/setup_test_wallets.js +96 -11
  85. package/dest/spartan/utils.d.ts +23 -3
  86. package/dest/spartan/utils.d.ts.map +1 -1
  87. package/dest/spartan/utils.js +9 -6
  88. package/package.json +36 -36
  89. package/src/bench/client_flows/benchmark.ts +8 -3
  90. package/src/bench/client_flows/client_flows_benchmark.ts +23 -14
  91. package/src/bench/utils.ts +5 -4
  92. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +47 -26
  93. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +14 -9
  94. package/src/e2e_deploy_contract/deploy_test.ts +7 -7
  95. package/src/e2e_epochs/epochs_test.ts +97 -25
  96. package/src/e2e_fees/bridging_race.notest.ts +1 -1
  97. package/src/e2e_fees/fees_test.ts +55 -82
  98. package/src/e2e_nested_contract/nested_contract_test.ts +16 -11
  99. package/src/e2e_p2p/p2p_network.ts +51 -26
  100. package/src/e2e_p2p/shared.ts +14 -12
  101. package/src/e2e_token_contract/token_contract_test.ts +38 -36
  102. package/src/fixtures/e2e_prover_test.ts +17 -10
  103. package/src/fixtures/setup_p2p_test.ts +51 -9
  104. package/src/fixtures/snapshot_manager.ts +24 -17
  105. package/src/fixtures/token_utils.ts +14 -9
  106. package/src/fixtures/utils.ts +116 -57
  107. package/src/guides/up_quick_start.sh +1 -1
  108. package/src/integration_l1_publisher/write_json.ts +74 -0
  109. package/src/sample-dapp/connect.mjs +1 -1
  110. package/src/sample-dapp/contracts.mjs +1 -1
  111. package/src/sample-dapp/deploy.mjs +3 -3
  112. package/src/sample-dapp/index.mjs +11 -8
  113. package/src/shared/cross_chain_test_harness.ts +31 -18
  114. package/src/shared/gas_portal_test_harness.ts +17 -7
  115. package/src/shared/uniswap_l1_l2.ts +28 -24
  116. package/src/simulators/lending_simulator.ts +3 -3
  117. package/src/simulators/token_simulator.ts +12 -3
  118. package/src/spartan/setup_test_wallets.ts +130 -19
  119. package/src/spartan/utils.ts +10 -3
@@ -75,22 +75,26 @@ export async function deployAndInitializeTokenAndBridgeContracts(
75
75
  });
76
76
 
77
77
  // deploy l2 token
78
- const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send().deployed();
78
+ const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18)
79
+ .send({ from: owner })
80
+ .deployed();
79
81
 
80
82
  // deploy l2 token bridge and attach to the portal
81
- const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send().deployed();
83
+ const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress)
84
+ .send({ from: owner })
85
+ .deployed();
82
86
 
83
- if ((await token.methods.get_admin().simulate()) !== owner.toBigInt()) {
87
+ if ((await token.methods.get_admin().simulate({ from: owner })) !== owner.toBigInt()) {
84
88
  throw new Error(`Token admin is not ${owner}`);
85
89
  }
86
90
 
87
- if (!(await bridge.methods.get_config().simulate()).token.equals(token.address)) {
91
+ if (!(await bridge.methods.get_config().simulate({ from: owner })).token.equals(token.address)) {
88
92
  throw new Error(`Bridge token is not ${token.address}`);
89
93
  }
90
94
 
91
95
  // make the bridge a minter on the token:
92
- await token.methods.set_minter(bridge.address, true).send().wait();
93
- if ((await token.methods.is_minter(bridge.address).simulate()) === 1n) {
96
+ await token.methods.set_minter(bridge.address, true).send({ from: owner }).wait();
97
+ if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })) === 1n) {
94
98
  throw new Error(`Bridge is not a minter`);
95
99
  }
96
100
 
@@ -131,6 +135,7 @@ export class CrossChainTestHarness {
131
135
  pxeService: PXE,
132
136
  l1Client: ExtendedViemWalletClient,
133
137
  wallet: AccountWallet,
138
+ ownerAddress: AztecAddress,
134
139
  logger: Logger,
135
140
  underlyingERC20Address: EthAddress,
136
141
  ): Promise<CrossChainTestHarness> {
@@ -160,14 +165,13 @@ export class CrossChainTestHarness {
160
165
  l1Client,
161
166
  l1ContractAddresses,
162
167
  wallet,
168
+ ownerAddress,
163
169
  );
164
170
  }
165
171
 
166
172
  private readonly l1TokenManager: L1TokenManager;
167
173
  private readonly l1TokenPortalManager: L1TokenPortalManager;
168
174
 
169
- public readonly ownerAddress: AztecAddress;
170
-
171
175
  constructor(
172
176
  /** Aztec node instance. */
173
177
  public aztecNode: AztecNode,
@@ -196,6 +200,9 @@ export class CrossChainTestHarness {
196
200
 
197
201
  /** Wallet of the owner. */
198
202
  public readonly ownerWallet: AccountWallet,
203
+
204
+ /** Owner of the l2 token and bridge */
205
+ public readonly ownerAddress: AztecAddress,
199
206
  ) {
200
207
  this.l1TokenPortalManager = new L1TokenPortalManager(
201
208
  this.tokenPortalAddress,
@@ -235,16 +242,19 @@ export class CrossChainTestHarness {
235
242
 
236
243
  async mintTokensPublicOnL2(amount: bigint) {
237
244
  this.logger.info('Minting tokens on L2 publicly');
238
- await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send().wait();
245
+ await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress }).wait();
239
246
  }
240
247
 
241
248
  async mintTokensPrivateOnL2(amount: bigint) {
242
- await mintTokensToPrivate(this.l2Token, this.ownerWallet, this.ownerAddress, amount);
249
+ await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerWallet, this.ownerAddress, amount);
243
250
  }
244
251
 
245
252
  async sendL2PublicTransfer(transferAmount: bigint, receiverAddress: AztecAddress) {
246
253
  // send a transfer tx to force through rollup with the message included
247
- await this.l2Token.methods.transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0).send().wait();
254
+ await this.l2Token.methods
255
+ .transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0)
256
+ .send({ from: this.ownerAddress })
257
+ .wait();
248
258
  }
249
259
 
250
260
  async consumeMessageOnAztecAndMintPrivately(
@@ -254,7 +264,7 @@ export class CrossChainTestHarness {
254
264
  const { recipient, claimAmount, claimSecret: secretForL2MessageConsumption, messageLeafIndex } = claim;
255
265
  await this.l2Bridge.methods
256
266
  .claim_private(recipient, claimAmount, secretForL2MessageConsumption, messageLeafIndex)
257
- .send()
267
+ .send({ from: this.ownerAddress })
258
268
  .wait();
259
269
  }
260
270
 
@@ -265,7 +275,7 @@ export class CrossChainTestHarness {
265
275
  const { claimAmount, claimSecret, messageLeafIndex } = claim;
266
276
  await this.l2Bridge.methods
267
277
  .claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex)
268
- .send()
278
+ .send({ from: this.ownerAddress })
269
279
  .wait();
270
280
  }
271
281
 
@@ -276,7 +286,7 @@ export class CrossChainTestHarness {
276
286
  ): Promise<FieldsOf<TxReceipt>> {
277
287
  const withdrawReceipt = await this.l2Bridge.methods
278
288
  .exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
279
- .send({ authWitnesses: [authWitness] })
289
+ .send({ authWitnesses: [authWitness], from: this.ownerAddress })
280
290
  .wait();
281
291
 
282
292
  return withdrawReceipt;
@@ -285,7 +295,7 @@ export class CrossChainTestHarness {
285
295
  async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<FieldsOf<TxReceipt>> {
286
296
  const withdrawReceipt = await this.l2Bridge.methods
287
297
  .exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
288
- .send()
298
+ .send({ from: this.ownerAddress })
289
299
  .wait();
290
300
 
291
301
  return withdrawReceipt;
@@ -302,7 +312,7 @@ export class CrossChainTestHarness {
302
312
  }
303
313
 
304
314
  async getL2PublicBalanceOf(owner: AztecAddress) {
305
- return await this.l2Token.methods.balance_of_public(owner).simulate();
315
+ return await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress });
306
316
  }
307
317
 
308
318
  async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
@@ -336,14 +346,17 @@ export class CrossChainTestHarness {
336
346
 
337
347
  async transferToPrivateOnL2(shieldAmount: bigint) {
338
348
  this.logger.info('Transferring to private on L2');
339
- await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send().wait();
349
+ await this.l2Token.methods
350
+ .transfer_to_private(this.ownerAddress, shieldAmount)
351
+ .send({ from: this.ownerAddress })
352
+ .wait();
340
353
  }
341
354
 
342
355
  async transferToPublicOnL2(amount: bigint, authwitNonce = Fr.ZERO) {
343
356
  this.logger.info('Transferring tokens to public');
344
357
  await this.l2Token.methods
345
358
  .transfer_to_public(this.ownerAddress, this.ownerAddress, amount, authwitNonce)
346
- .send()
359
+ .send({ from: this.ownerAddress })
347
360
  .wait();
348
361
  }
349
362
 
@@ -22,7 +22,7 @@ import { getContract } from 'viem';
22
22
  export interface IGasBridgingTestHarness {
23
23
  getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
24
24
  prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress): Promise<L2AmountClaim>;
25
- bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress): Promise<void>;
25
+ bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress, claimer: AztecAddress): Promise<void>;
26
26
  feeJuice: FeeJuiceContract;
27
27
  l1FeeJuiceAddress: EthAddress;
28
28
  }
@@ -141,14 +141,14 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
141
141
  return this.feeJuicePortalManager.bridgeTokensPublic(l2Address, bridgeAmount, false);
142
142
  }
143
143
 
144
- async consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claim: L2AmountClaim) {
144
+ async consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claimer: AztecAddress, claim: L2AmountClaim) {
145
145
  this.logger.info('Consuming messages on L2 Privately');
146
146
  const { claimAmount, claimSecret, messageLeafIndex } = claim;
147
- await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send().wait();
147
+ await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send({ from: claimer }).wait();
148
148
  }
149
149
 
150
150
  async getL2PublicBalanceOf(owner: AztecAddress) {
151
- return await this.feeJuice.methods.balance_of_public(owner).simulate();
151
+ return await this.feeJuice.methods.balance_of_public(owner).simulate({ from: owner });
152
152
  }
153
153
 
154
154
  async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
@@ -170,18 +170,28 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
170
170
  return claim;
171
171
  }
172
172
 
173
- async bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress) {
173
+ async bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress, claimer: AztecAddress) {
174
174
  // Prepare the tokens on the L1 side
175
175
  const claim = await this.prepareTokensOnL1(bridgeAmount, owner);
176
176
 
177
177
  // Consume L1 -> L2 message and claim tokens privately on L2
178
- await this.consumeMessageOnAztecAndClaimPrivately(owner, claim);
178
+ await this.consumeMessageOnAztecAndClaimPrivately(owner, claimer, claim);
179
179
  }
180
180
 
181
181
  private async advanceL2Block() {
182
182
  const initialBlockNumber = await this.aztecNode.getBlockNumber();
183
- await this.aztecNodeAdmin?.flushTxs();
183
+
184
+ let minTxsPerBlock = undefined;
185
+ if (this.aztecNodeAdmin) {
186
+ ({ minTxsPerBlock } = await this.aztecNodeAdmin.getConfig());
187
+ await this.aztecNodeAdmin.setConfig({ minTxsPerBlock: 0 }); // Set to 0 to ensure we can advance the block
188
+ }
189
+
184
190
  await retryUntil(async () => (await this.aztecNode.getBlockNumber()) >= initialBlockNumber + 1);
191
+
192
+ if (this.aztecNodeAdmin && minTxsPerBlock !== undefined) {
193
+ await this.aztecNodeAdmin.setConfig({ minTxsPerBlock });
194
+ }
185
195
  }
186
196
  }
187
197
  // docs:end:cross_chain_test_harness
@@ -9,7 +9,7 @@ import {
9
9
  computeAuthWitMessageHash,
10
10
  generateClaimSecret,
11
11
  } from '@aztec/aztec.js';
12
- import { CheatCodes } from '@aztec/aztec.js/testing';
12
+ import { CheatCodes } from '@aztec/aztec/testing';
13
13
  import {
14
14
  type DeployL1ContractsReturnType,
15
15
  type ExtendedViemWalletClient,
@@ -26,7 +26,7 @@ import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
26
26
  import { jest } from '@jest/globals';
27
27
  import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
28
28
 
29
- import { ensureAccountsPubliclyDeployed } from '../fixtures/utils.js';
29
+ import { ensureAccountContractsPublished } from '../fixtures/utils.js';
30
30
  import { CrossChainTestHarness } from './cross_chain_test_harness.js';
31
31
 
32
32
  // PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
@@ -83,7 +83,7 @@ export const uniswapL1L2TestSuite = (
83
83
  let ownerEthAddress: EthAddress;
84
84
  // does transactions on behalf of owner on Aztec:
85
85
  let sponsorWallet: AccountWallet;
86
- // let sponsorAddress: AztecAddress;
86
+ let sponsorAddress: AztecAddress;
87
87
 
88
88
  let daiCrossChainHarness: CrossChainTestHarness;
89
89
  let wethCrossChainHarness: CrossChainTestHarness;
@@ -114,10 +114,10 @@ export const uniswapL1L2TestSuite = (
114
114
  );
115
115
  version = Number(await rollup.getVersion());
116
116
  ownerAddress = ownerWallet.getAddress();
117
- // sponsorAddress = sponsorWallet.getAddress();
117
+ sponsorAddress = sponsorWallet.getAddress();
118
118
  ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
119
119
 
120
- await ensureAccountsPubliclyDeployed(ownerWallet, [ownerWallet, sponsorWallet]);
120
+ await ensureAccountContractsPublished(ownerWallet, [ownerWallet, sponsorWallet]);
121
121
 
122
122
  logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
123
123
  daiCrossChainHarness = await CrossChainTestHarness.new(
@@ -125,6 +125,7 @@ export const uniswapL1L2TestSuite = (
125
125
  pxe,
126
126
  deployL1ContractsValues.l1Client,
127
127
  ownerWallet,
128
+ ownerAddress,
128
129
  logger,
129
130
  DAI_ADDRESS,
130
131
  );
@@ -135,6 +136,7 @@ export const uniswapL1L2TestSuite = (
135
136
  pxe,
136
137
  l1Client,
137
138
  ownerWallet,
139
+ ownerAddress,
138
140
  logger,
139
141
  WETH9_ADDRESS,
140
142
  );
@@ -150,7 +152,9 @@ export const uniswapL1L2TestSuite = (
150
152
  client: l1Client,
151
153
  });
152
154
  // deploy l2 uniswap contract and attach to portal
153
- uniswapL2Contract = await UniswapContract.deploy(ownerWallet, uniswapPortalAddress).send().deployed();
155
+ uniswapL2Contract = await UniswapContract.deploy(ownerWallet, uniswapPortalAddress)
156
+ .send({ from: ownerAddress })
157
+ .deployed();
154
158
 
155
159
  const registryAddress = (await pxe.getNodeInfo()).l1ContractAddresses.registryAddress;
156
160
 
@@ -228,7 +232,7 @@ export const uniswapL1L2TestSuite = (
228
232
  secretHashForDepositingSwappedDai,
229
233
  ownerEthAddress,
230
234
  )
231
- .send({ authWitnesses: [transferToPublicAuhtwit] })
235
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] })
232
236
  .wait();
233
237
 
234
238
  const swapPrivateFunction = 'swap_private(address,uint256,uint24,address,uint256,bytes32,address)';
@@ -290,10 +294,10 @@ export const uniswapL1L2TestSuite = (
290
294
  withdrawLeaf,
291
295
  );
292
296
 
293
- const swapPrivateL2MessageIndex = swapResult!.l2MessageIndex;
297
+ const swapPrivateL2MessageIndex = swapResult!.leafIndex;
294
298
  const swapPrivateSiblingPath = swapResult!.siblingPath;
295
299
 
296
- const withdrawL2MessageIndex = withdrawResult!.l2MessageIndex;
300
+ const withdrawL2MessageIndex = withdrawResult!.leafIndex;
297
301
  const withdrawSiblingPath = withdrawResult!.siblingPath;
298
302
 
299
303
  const withdrawMessageMetadata = {
@@ -634,7 +638,7 @@ export const uniswapL1L2TestSuite = (
634
638
  Fr.random(),
635
639
  ownerEthAddress,
636
640
  )
637
- .simulate(),
641
+ .simulate({ from: ownerAddress }),
638
642
  ).rejects.toThrow(`Unknown auth witness for message hash ${expectedMessageHash.toString()}`);
639
643
  });
640
644
 
@@ -671,7 +675,7 @@ export const uniswapL1L2TestSuite = (
671
675
  Fr.random(),
672
676
  ownerEthAddress,
673
677
  )
674
- .prove({ authWitnesses: [transferToPublicAuthwith] }),
678
+ .prove({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] }),
675
679
  ).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
676
680
  });
677
681
 
@@ -695,7 +699,7 @@ export const uniswapL1L2TestSuite = (
695
699
  },
696
700
  true,
697
701
  );
698
- await validateActionInteraction.send().wait();
702
+ await validateActionInteraction.send({ from: ownerAddress }).wait();
699
703
 
700
704
  // No approval to call `swap` but should work even without it:
701
705
  const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
@@ -714,7 +718,7 @@ export const uniswapL1L2TestSuite = (
714
718
  ownerEthAddress,
715
719
  Fr.ZERO, // nonce for swap -> doesn't matter
716
720
  )
717
- .send()
721
+ .send({ from: ownerAddress })
718
722
  .wait();
719
723
  // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
720
724
  await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
@@ -743,9 +747,9 @@ export const uniswapL1L2TestSuite = (
743
747
  nonceForSwap,
744
748
  );
745
749
  const validateActionInteraction = await ownerWallet.setPublicAuthWit({ caller: approvedUser, action }, true);
746
- await validateActionInteraction.send().wait();
750
+ await validateActionInteraction.send({ from: sponsorAddress }).wait();
747
751
 
748
- await expect(action.simulate()).rejects.toThrow(/unauthorized/);
752
+ await expect(action.simulate({ from: sponsorAddress })).rejects.toThrow(/unauthorized/);
749
753
  });
750
754
 
751
755
  it("uniswap can't pull funds without transfer approval", async () => {
@@ -764,7 +768,7 @@ export const uniswapL1L2TestSuite = (
764
768
  },
765
769
  true,
766
770
  );
767
- await validateActionInteraction.send().wait();
771
+ await validateActionInteraction.send({ from: ownerAddress }).wait();
768
772
 
769
773
  await expect(
770
774
  uniswapL2Contract.methods
@@ -781,7 +785,7 @@ export const uniswapL1L2TestSuite = (
781
785
  ownerEthAddress,
782
786
  Fr.ZERO,
783
787
  )
784
- .simulate(),
788
+ .simulate({ from: ownerAddress }),
785
789
  ).rejects.toThrow(/unauthorized/);
786
790
  });
787
791
 
@@ -821,7 +825,7 @@ export const uniswapL1L2TestSuite = (
821
825
  secretHashForDepositingSwappedDai,
822
826
  ownerEthAddress,
823
827
  )
824
- .send({ authWitnesses: [transferToPublicAuhtwit] })
828
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] })
825
829
  .wait();
826
830
 
827
831
  const swapPrivateContent = sha256ToField([
@@ -868,10 +872,10 @@ export const uniswapL1L2TestSuite = (
868
872
  withdrawLeaf,
869
873
  );
870
874
 
871
- const swapPrivateL2MessageIndex = swapResult!.l2MessageIndex;
875
+ const swapPrivateL2MessageIndex = swapResult!.leafIndex;
872
876
  const swapPrivateSiblingPath = swapResult!.siblingPath;
873
877
 
874
- const withdrawL2MessageIndex = withdrawResult!.l2MessageIndex;
878
+ const withdrawL2MessageIndex = withdrawResult!.leafIndex;
875
879
  const withdrawSiblingPath = withdrawResult!.siblingPath;
876
880
 
877
881
  const withdrawMessageMetadata = {
@@ -934,7 +938,7 @@ export const uniswapL1L2TestSuite = (
934
938
  },
935
939
  true,
936
940
  );
937
- await validateActionInteraction.send().wait();
941
+ await validateActionInteraction.send({ from: ownerAddress }).wait();
938
942
 
939
943
  // Call swap_public on L2
940
944
  const secretHashForDepositingSwappedDai = Fr.random();
@@ -952,7 +956,7 @@ export const uniswapL1L2TestSuite = (
952
956
  ownerEthAddress,
953
957
  Fr.ZERO,
954
958
  )
955
- .send()
959
+ .send({ from: ownerAddress })
956
960
  .wait();
957
961
 
958
962
  const swapPublicContent = sha256ToField([
@@ -1002,10 +1006,10 @@ export const uniswapL1L2TestSuite = (
1002
1006
  withdrawLeaf,
1003
1007
  );
1004
1008
 
1005
- const swapPublicL2MessageIndex = swapResult!.l2MessageIndex;
1009
+ const swapPublicL2MessageIndex = swapResult!.leafIndex;
1006
1010
  const swapPublicSiblingPath = swapResult!.siblingPath;
1007
1011
 
1008
- const withdrawL2MessageIndex = withdrawResult!.l2MessageIndex;
1012
+ const withdrawL2MessageIndex = withdrawResult!.leafIndex;
1009
1013
  const withdrawSiblingPath = withdrawResult!.siblingPath;
1010
1014
 
1011
1015
  const withdrawMessageMetadata = {
@@ -1,6 +1,6 @@
1
1
  // Convenience struct to hold an account's address and secret that can easily be passed around.
2
2
  import { AztecAddress, Fr } from '@aztec/aztec.js';
3
- import { CheatCodes } from '@aztec/aztec.js/testing';
3
+ import { CheatCodes } from '@aztec/aztec/testing';
4
4
  import type { RollupContract } from '@aztec/ethereum';
5
5
  import { pedersenHash } from '@aztec/foundation/crypto';
6
6
  import type { TestDateProvider } from '@aztec/foundation/timer';
@@ -183,14 +183,14 @@ export class LendingSimulator {
183
183
 
184
184
  expect(this.borrowed).toEqual(this.stableCoin.totalSupply - this.mintedOutside);
185
185
 
186
- const asset = await this.lendingContract.methods.get_asset(0).simulate();
186
+ const asset = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
187
187
 
188
188
  const interestAccumulator = asset['interest_accumulator'];
189
189
  expect(interestAccumulator).toEqual(this.accumulator);
190
190
  expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
191
191
 
192
192
  for (const key of [this.account.address, AztecAddress.fromField(await this.account.key())]) {
193
- const privatePos = await this.lendingContract.methods.get_position(key).simulate();
193
+ const privatePos = await this.lendingContract.methods.get_position(key).simulate({ from: key });
194
194
  expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
195
195
  expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
196
196
  expect(privatePos['debt']).toEqual(
@@ -13,6 +13,7 @@ export class TokenSimulator {
13
13
  constructor(
14
14
  protected token: TokenContract,
15
15
  protected defaultWallet: Wallet,
16
+ protected defaultAddress: AztecAddress,
16
17
  protected logger: Logger,
17
18
  protected accounts: AztecAddress[],
18
19
  ) {}
@@ -102,7 +103,9 @@ export class TokenSimulator {
102
103
  ];
103
104
 
104
105
  const results = (
105
- await Promise.all(chunk(calls, 4).map(batch => new BatchCall(this.defaultWallet, batch).simulate()))
106
+ await Promise.all(
107
+ chunk(calls, 4).map(batch => new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress })),
108
+ )
106
109
  ).flat();
107
110
  expect(results[0]).toEqual(this.totalSupply);
108
111
 
@@ -127,7 +130,11 @@ export class TokenSimulator {
127
130
 
128
131
  const defaultCalls = defaultLookups.map(address => this.token.methods.balance_of_private(address));
129
132
  const results = (
130
- await Promise.all(chunk(defaultCalls, 4).map(batch => new BatchCall(this.defaultWallet, batch).simulate()))
133
+ await Promise.all(
134
+ chunk(defaultCalls, 4).map(batch =>
135
+ new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress }),
136
+ ),
137
+ )
131
138
  ).flat();
132
139
  for (let i = 0; i < defaultLookups.length; i++) {
133
140
  expect(results[i]).toEqual(this.balanceOfPrivate(defaultLookups[i]));
@@ -139,7 +146,9 @@ export class TokenSimulator {
139
146
  const wallet = this.lookupProvider.get(address.toString());
140
147
  const asset = wallet ? this.token.withWallet(wallet) : this.token;
141
148
 
142
- const actualPrivateBalance = await asset.methods.balance_of_private({ address }).simulate();
149
+ const actualPrivateBalance = await asset.methods
150
+ .balance_of_private({ address })
151
+ .simulate({ from: this.defaultAddress });
143
152
  expect(actualPrivateBalance).toEqual(this.balanceOfPrivate(address));
144
153
  }
145
154
  }