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

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
@@ -25,18 +25,30 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
25
25
  client: l1Client
26
26
  });
27
27
  // deploy l2 token
28
- const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send().deployed();
28
+ const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
29
+ from: owner
30
+ }).deployed();
29
31
  // deploy l2 token bridge and attach to the portal
30
- const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send().deployed();
31
- if (await token.methods.get_admin().simulate() !== owner.toBigInt()) {
32
+ const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
33
+ from: owner
34
+ }).deployed();
35
+ if (await token.methods.get_admin().simulate({
36
+ from: owner
37
+ }) !== owner.toBigInt()) {
32
38
  throw new Error(`Token admin is not ${owner}`);
33
39
  }
34
- if (!(await bridge.methods.get_config().simulate()).token.equals(token.address)) {
40
+ if (!(await bridge.methods.get_config().simulate({
41
+ from: owner
42
+ })).token.equals(token.address)) {
35
43
  throw new Error(`Bridge token is not ${token.address}`);
36
44
  }
37
45
  // make the bridge a minter on the token:
38
- await token.methods.set_minter(bridge.address, true).send().wait();
39
- if (await token.methods.is_minter(bridge.address).simulate() === 1n) {
46
+ await token.methods.set_minter(bridge.address, true).send({
47
+ from: owner
48
+ }).wait();
49
+ if (await token.methods.is_minter(bridge.address).simulate({
50
+ from: owner
51
+ }) === 1n) {
40
52
  throw new Error(`Bridge is not a minter`);
41
53
  }
42
54
  // initialize portal
@@ -73,19 +85,19 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
73
85
  l1Client;
74
86
  l1ContractAddresses;
75
87
  ownerWallet;
76
- static async new(aztecNode, pxeService, l1Client, wallet, logger, underlyingERC20Address) {
88
+ ownerAddress;
89
+ static async new(aztecNode, pxeService, l1Client, wallet, ownerAddress, logger, underlyingERC20Address) {
77
90
  const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
78
91
  const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;
79
92
  // Deploy and initialize all required contracts
80
93
  logger.info('Deploying and initializing token, portal and its bridge...');
81
94
  const { token, bridge, tokenPortalAddress, underlyingERC20 } = await deployAndInitializeTokenAndBridgeContracts(wallet, l1Client, l1ContractAddresses.registryAddress, wallet.getAddress(), underlyingERC20Address);
82
95
  logger.info('Deployed and initialized token, portal and its bridge.');
83
- return new CrossChainTestHarness(aztecNode, pxeService, logger, token, bridge, ethAccount, tokenPortalAddress, underlyingERC20.address, l1Client, l1ContractAddresses, wallet);
96
+ return new CrossChainTestHarness(aztecNode, pxeService, logger, token, bridge, ethAccount, tokenPortalAddress, underlyingERC20.address, l1Client, l1ContractAddresses, wallet, ownerAddress);
84
97
  }
85
98
  l1TokenManager;
86
99
  l1TokenPortalManager;
87
- ownerAddress;
88
- constructor(/** Aztec node instance. */ aztecNode, /** Private eXecution Environment (PXE). */ pxeService, /** Logger. */ logger, /** L2 Token contract. */ l2Token, /** L2 Token bridge contract. */ l2Bridge, /** Eth account to interact with. */ ethAccount, /** Portal address. */ tokenPortalAddress, /** Underlying token for portal tests. */ underlyingERC20Address, /** Viem Extended client instance. */ l1Client, /** Deployment addresses for all L1 contracts */ l1ContractAddresses, /** Wallet of the owner. */ ownerWallet){
100
+ constructor(/** Aztec node instance. */ aztecNode, /** Private eXecution Environment (PXE). */ pxeService, /** Logger. */ logger, /** L2 Token contract. */ l2Token, /** L2 Token bridge contract. */ l2Bridge, /** Eth account to interact with. */ ethAccount, /** Portal address. */ tokenPortalAddress, /** Underlying token for portal tests. */ underlyingERC20Address, /** Viem Extended client instance. */ l1Client, /** Deployment addresses for all L1 contracts */ l1ContractAddresses, /** Wallet of the owner. */ ownerWallet, /** Owner of the l2 token and bridge */ ownerAddress){
89
101
  this.aztecNode = aztecNode;
90
102
  this.pxeService = pxeService;
91
103
  this.logger = logger;
@@ -97,6 +109,7 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
97
109
  this.l1Client = l1Client;
98
110
  this.l1ContractAddresses = l1ContractAddresses;
99
111
  this.ownerWallet = ownerWallet;
112
+ this.ownerAddress = ownerAddress;
100
113
  this.l1TokenPortalManager = new L1TokenPortalManager(this.tokenPortalAddress, this.underlyingERC20Address, this.l1ContractAddresses.feeAssetHandlerAddress, this.l1ContractAddresses.outboxAddress, this.l1Client, this.logger);
101
114
  this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
102
115
  this.ownerAddress = this.ownerWallet.getAddress();
@@ -128,35 +141,46 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
128
141
  }
129
142
  async mintTokensPublicOnL2(amount) {
130
143
  this.logger.info('Minting tokens on L2 publicly');
131
- await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send().wait();
144
+ await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({
145
+ from: this.ownerAddress
146
+ }).wait();
132
147
  }
133
148
  async mintTokensPrivateOnL2(amount) {
134
- await mintTokensToPrivate(this.l2Token, this.ownerWallet, this.ownerAddress, amount);
149
+ await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerWallet, this.ownerAddress, amount);
135
150
  }
136
151
  async sendL2PublicTransfer(transferAmount, receiverAddress) {
137
152
  // send a transfer tx to force through rollup with the message included
138
- await this.l2Token.methods.transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0).send().wait();
153
+ await this.l2Token.methods.transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0).send({
154
+ from: this.ownerAddress
155
+ }).wait();
139
156
  }
140
157
  async consumeMessageOnAztecAndMintPrivately(claim) {
141
158
  this.logger.info('Consuming messages on L2 privately');
142
159
  const { recipient, claimAmount, claimSecret: secretForL2MessageConsumption, messageLeafIndex } = claim;
143
- await this.l2Bridge.methods.claim_private(recipient, claimAmount, secretForL2MessageConsumption, messageLeafIndex).send().wait();
160
+ await this.l2Bridge.methods.claim_private(recipient, claimAmount, secretForL2MessageConsumption, messageLeafIndex).send({
161
+ from: this.ownerAddress
162
+ }).wait();
144
163
  }
145
164
  async consumeMessageOnAztecAndMintPublicly(claim) {
146
165
  this.logger.info('Consuming messages on L2 Publicly');
147
166
  const { claimAmount, claimSecret, messageLeafIndex } = claim;
148
- await this.l2Bridge.methods.claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex).send().wait();
167
+ await this.l2Bridge.methods.claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex).send({
168
+ from: this.ownerAddress
169
+ }).wait();
149
170
  }
150
171
  async withdrawPrivateFromAztecToL1(withdrawAmount, authwitNonce = Fr.ZERO, authWitness) {
151
172
  const withdrawReceipt = await this.l2Bridge.methods.exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce).send({
152
173
  authWitnesses: [
153
174
  authWitness
154
- ]
175
+ ],
176
+ from: this.ownerAddress
155
177
  }).wait();
156
178
  return withdrawReceipt;
157
179
  }
158
180
  async withdrawPublicFromAztecToL1(withdrawAmount, authwitNonce = Fr.ZERO) {
159
- const withdrawReceipt = await this.l2Bridge.methods.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce).send().wait();
181
+ const withdrawReceipt = await this.l2Bridge.methods.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce).send({
182
+ from: this.ownerAddress
183
+ }).wait();
160
184
  return withdrawReceipt;
161
185
  }
162
186
  async getL2PrivateBalanceOf(owner) {
@@ -170,7 +194,9 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
170
194
  expect(balance).toBe(expectedBalance);
171
195
  }
172
196
  async getL2PublicBalanceOf(owner) {
173
- return await this.l2Token.methods.balance_of_public(owner).simulate();
197
+ return await this.l2Token.methods.balance_of_public(owner).simulate({
198
+ from: this.ownerAddress
199
+ });
174
200
  }
175
201
  async expectPublicBalanceOnL2(owner, expectedBalance) {
176
202
  const balance = await this.getL2PublicBalanceOf(owner);
@@ -184,11 +210,15 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
184
210
  }
185
211
  async transferToPrivateOnL2(shieldAmount) {
186
212
  this.logger.info('Transferring to private on L2');
187
- await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send().wait();
213
+ await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send({
214
+ from: this.ownerAddress
215
+ }).wait();
188
216
  }
189
217
  async transferToPublicOnL2(amount, authwitNonce = Fr.ZERO) {
190
218
  this.logger.info('Transferring tokens to public');
191
- await this.l2Token.methods.transfer_to_public(this.ownerAddress, this.ownerAddress, amount, authwitNonce).send().wait();
219
+ await this.l2Token.methods.transfer_to_public(this.ownerAddress, this.ownerAddress, amount, authwitNonce).send({
220
+ from: this.ownerAddress
221
+ }).wait();
192
222
  }
193
223
  /**
194
224
  * Makes message available for consumption.
@@ -5,7 +5,7 @@ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
5
5
  export interface IGasBridgingTestHarness {
6
6
  getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
7
7
  prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress): Promise<L2AmountClaim>;
8
- bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress): Promise<void>;
8
+ bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress, claimer: AztecAddress): Promise<void>;
9
9
  feeJuice: FeeJuiceContract;
10
10
  l1FeeJuiceAddress: EthAddress;
11
11
  }
@@ -75,11 +75,11 @@ export declare class GasBridgingTestHarness implements IGasBridgingTestHarness {
75
75
  mintTokensOnL1(amount: bigint, to?: EthAddress): Promise<void>;
76
76
  getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
77
77
  sendTokensToPortalPublic(bridgeAmount: bigint, l2Address: AztecAddress): Promise<L2AmountClaim>;
78
- consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claim: L2AmountClaim): Promise<void>;
78
+ consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claimer: AztecAddress, claim: L2AmountClaim): Promise<void>;
79
79
  getL2PublicBalanceOf(owner: AztecAddress): Promise<any>;
80
80
  expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint): Promise<void>;
81
81
  prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress): Promise<L2AmountClaim>;
82
- bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress): Promise<void>;
82
+ bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress, claimer: AztecAddress): Promise<void>;
83
83
  private advanceL2Block;
84
84
  }
85
85
  //# sourceMappingURL=gas_portal_test_harness.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gas_portal_test_harness.d.ts","sourceRoot":"","s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;IAc/D,oBAAoB,CAAC,OAAO,EAAE,UAAU;IAI9C,wBAAwB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY;IAIhE,sCAAsC,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa;IAMvG,oBAAoB,CAAC,KAAK,EAAE,YAAY;IAIxC,uBAAuB,CAAC,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM;IAKpE,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY;IAc3D,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY;YAQzE,cAAc;CAe7B"}
@@ -75,13 +75,17 @@ export class FeeJuicePortalTestingHarnessFactory {
75
75
  sendTokensToPortalPublic(bridgeAmount, l2Address) {
76
76
  return this.feeJuicePortalManager.bridgeTokensPublic(l2Address, bridgeAmount, false);
77
77
  }
78
- async consumeMessageOnAztecAndClaimPrivately(owner, claim) {
78
+ async consumeMessageOnAztecAndClaimPrivately(owner, claimer, claim) {
79
79
  this.logger.info('Consuming messages on L2 Privately');
80
80
  const { claimAmount, claimSecret, messageLeafIndex } = claim;
81
- await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send().wait();
81
+ await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send({
82
+ from: claimer
83
+ }).wait();
82
84
  }
83
85
  async getL2PublicBalanceOf(owner) {
84
- return await this.feeJuice.methods.balance_of_public(owner).simulate();
86
+ return await this.feeJuice.methods.balance_of_public(owner).simulate({
87
+ from: owner
88
+ });
85
89
  }
86
90
  async expectPublicBalanceOnL2(owner, expectedBalance) {
87
91
  const balance = await this.getL2PublicBalanceOf(owner);
@@ -97,15 +101,26 @@ export class FeeJuicePortalTestingHarnessFactory {
97
101
  await this.advanceL2Block();
98
102
  return claim;
99
103
  }
100
- async bridgeFromL1ToL2(bridgeAmount, owner) {
104
+ async bridgeFromL1ToL2(bridgeAmount, owner, claimer) {
101
105
  // Prepare the tokens on the L1 side
102
106
  const claim = await this.prepareTokensOnL1(bridgeAmount, owner);
103
107
  // Consume L1 -> L2 message and claim tokens privately on L2
104
- await this.consumeMessageOnAztecAndClaimPrivately(owner, claim);
108
+ await this.consumeMessageOnAztecAndClaimPrivately(owner, claimer, claim);
105
109
  }
106
110
  async advanceL2Block() {
107
111
  const initialBlockNumber = await this.aztecNode.getBlockNumber();
108
- await this.aztecNodeAdmin?.flushTxs();
112
+ let minTxsPerBlock = undefined;
113
+ if (this.aztecNodeAdmin) {
114
+ ({ minTxsPerBlock } = await this.aztecNodeAdmin.getConfig());
115
+ await this.aztecNodeAdmin.setConfig({
116
+ minTxsPerBlock: 0
117
+ }); // Set to 0 to ensure we can advance the block
118
+ }
109
119
  await retryUntil(async ()=>await this.aztecNode.getBlockNumber() >= initialBlockNumber + 1);
120
+ if (this.aztecNodeAdmin && minTxsPerBlock !== undefined) {
121
+ await this.aztecNodeAdmin.setConfig({
122
+ minTxsPerBlock
123
+ });
124
+ }
110
125
  }
111
126
  } // docs:end:cross_chain_test_harness
@@ -1,5 +1,5 @@
1
1
  import { type AccountWallet, type AztecNode, type Logger, type PXE } from '@aztec/aztec.js';
2
- import { CheatCodes } from '@aztec/aztec.js/testing';
2
+ import { CheatCodes } from '@aztec/aztec/testing';
3
3
  import { type DeployL1ContractsReturnType, type ExtendedViemWalletClient } from '@aztec/ethereum';
4
4
  /** Objects to be returned by the uniswap setup function */
5
5
  export type UniswapSetupContext = {
@@ -1 +1 @@
1
- {"version":3,"file":"uniswap_l1_l2.d.ts","sourceRoot":"","sources":["../../src/shared/uniswap_l1_l2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,SAAS,EAGd,KAAK,MAAM,EACX,KAAK,GAAG,EAGT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAA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AC;IACnC,wBAAwB;IACxB,WAAW,EAAE,aAAa,CAAC;IAC3B,0BAA0B;IAC1B,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO;IACP,uBAAuB,EAAE,2BAA2B,CAAC;IACrD,4BAA4B;IAC5B,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAGF,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,OAAO,CAAC,mBAAmB,CAAC,EACzC,SAAS,MAAM,OAAO,CAAC,IAAI,CAAC,EAC5B,gCAAkC,SAg+BnC,CAAC"}
@@ -7,7 +7,7 @@ import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
7
7
  import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
8
8
  import { jest } from '@jest/globals';
9
9
  import { getContract, parseEther, toFunctionSelector } from 'viem';
10
- import { ensureAccountsPubliclyDeployed } from '../fixtures/utils.js';
10
+ import { ensureAccountContractsPublished } from '../fixtures/utils.js';
11
11
  import { CrossChainTestHarness } from './cross_chain_test_harness.js';
12
12
  // PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
13
13
  // don't need to burn through RPC requests.
@@ -33,7 +33,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
33
33
  let ownerEthAddress;
34
34
  // does transactions on behalf of owner on Aztec:
35
35
  let sponsorWallet;
36
- // let sponsorAddress: AztecAddress;
36
+ let sponsorAddress;
37
37
  let daiCrossChainHarness;
38
38
  let wethCrossChainHarness;
39
39
  let deployL1ContractsValues;
@@ -54,16 +54,16 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
54
54
  rollup = new RollupContract(deployL1ContractsValues.l1Client, deployL1ContractsValues.l1ContractAddresses.rollupAddress);
55
55
  version = Number(await rollup.getVersion());
56
56
  ownerAddress = ownerWallet.getAddress();
57
- // sponsorAddress = sponsorWallet.getAddress();
57
+ sponsorAddress = sponsorWallet.getAddress();
58
58
  ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
59
- await ensureAccountsPubliclyDeployed(ownerWallet, [
59
+ await ensureAccountContractsPublished(ownerWallet, [
60
60
  ownerWallet,
61
61
  sponsorWallet
62
62
  ]);
63
63
  logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
64
- daiCrossChainHarness = await CrossChainTestHarness.new(aztecNode, pxe, deployL1ContractsValues.l1Client, ownerWallet, logger, DAI_ADDRESS);
64
+ daiCrossChainHarness = await CrossChainTestHarness.new(aztecNode, pxe, deployL1ContractsValues.l1Client, ownerWallet, ownerAddress, logger, DAI_ADDRESS);
65
65
  logger.info('Deploying WETH Portal, initializing and deploying l2 contract...');
66
- wethCrossChainHarness = await CrossChainTestHarness.new(aztecNode, pxe, l1Client, ownerWallet, logger, WETH9_ADDRESS);
66
+ wethCrossChainHarness = await CrossChainTestHarness.new(aztecNode, pxe, l1Client, ownerWallet, ownerAddress, logger, WETH9_ADDRESS);
67
67
  logger.info('Deploy Uniswap portal on L1 and L2...');
68
68
  uniswapPortalAddress = await deployL1Contract(l1Client, UniswapPortalAbi, UniswapPortalBytecode).then(({ address })=>address);
69
69
  uniswapPortal = getContract({
@@ -72,7 +72,9 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
72
72
  client: l1Client
73
73
  });
74
74
  // deploy l2 uniswap contract and attach to portal
75
- uniswapL2Contract = await UniswapContract.deploy(ownerWallet, uniswapPortalAddress).send().deployed();
75
+ uniswapL2Contract = await UniswapContract.deploy(ownerWallet, uniswapPortalAddress).send({
76
+ from: ownerAddress
77
+ }).deployed();
76
78
  const registryAddress = (await pxe.getNodeInfo()).l1ContractAddresses.registryAddress;
77
79
  await uniswapPortal.write.initialize([
78
80
  registryAddress.toString(),
@@ -121,6 +123,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
121
123
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
122
124
  const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
123
125
  const l2UniswapInteractionReceipt = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send({
126
+ from: ownerAddress,
124
127
  authWitnesses: [
125
128
  transferToPublicAuhtwit
126
129
  ]
@@ -167,9 +170,9 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
167
170
  const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(daiCrossChainHarness.tokenPortalAddress);
168
171
  const swapResult = await computeL2ToL1MembershipWitness(aztecNode, l2UniswapInteractionReceipt.blockNumber, swapPrivateLeaf);
169
172
  const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, l2UniswapInteractionReceipt.blockNumber, withdrawLeaf);
170
- const swapPrivateL2MessageIndex = swapResult.l2MessageIndex;
173
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
171
174
  const swapPrivateSiblingPath = swapResult.siblingPath;
172
- const withdrawL2MessageIndex = withdrawResult.l2MessageIndex;
175
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
173
176
  const withdrawSiblingPath = withdrawResult.siblingPath;
174
177
  const withdrawMessageMetadata = {
175
178
  _l2BlockNumber: BigInt(l2UniswapInteractionReceipt.blockNumber),
@@ -444,7 +447,9 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
444
447
  chainId: ownerWallet.getChainId(),
445
448
  version: ownerWallet.getVersion()
446
449
  });
447
- await expect(uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, Fr.random(), ownerEthAddress).simulate()).rejects.toThrow(`Unknown auth witness for message hash ${expectedMessageHash.toString()}`);
450
+ await expect(uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, Fr.random(), ownerEthAddress).simulate({
451
+ from: ownerAddress
452
+ })).rejects.toThrow(`Unknown auth witness for message hash ${expectedMessageHash.toString()}`);
448
453
  });
449
454
  it("can't swap if user passes a token different to what the bridge tracks", async ()=>{
450
455
  // 1. give user private funds on L2:
@@ -460,6 +465,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
460
465
  // 3. Swap but send the wrong token address
461
466
  logger.info('Swap but send the wrong token address');
462
467
  await expect(uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, daiCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, Fr.random(), ownerEthAddress).prove({
468
+ from: ownerAddress,
463
469
  authWitnesses: [
464
470
  transferToPublicAuthwith
465
471
  ]
@@ -475,10 +481,14 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
475
481
  caller: uniswapL2Contract.address,
476
482
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferApproval)
477
483
  }, true);
478
- await validateActionInteraction.send().wait();
484
+ await validateActionInteraction.send({
485
+ from: ownerAddress
486
+ }).wait();
479
487
  // No approval to call `swap` but should work even without it:
480
488
  const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
481
- await uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferApproval, uniswapFeeTier, minimumOutputAmount, ownerAddress, secretHashForDepositingSwappedDai, ownerEthAddress, Fr.ZERO).send().wait();
489
+ await uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferApproval, uniswapFeeTier, minimumOutputAmount, ownerAddress, secretHashForDepositingSwappedDai, ownerEthAddress, Fr.ZERO).send({
490
+ from: ownerAddress
491
+ }).wait();
482
492
  // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
483
493
  await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
484
494
  });
@@ -493,8 +503,12 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
493
503
  caller: approvedUser,
494
504
  action
495
505
  }, true);
496
- await validateActionInteraction.send().wait();
497
- await expect(action.simulate()).rejects.toThrow(/unauthorized/);
506
+ await validateActionInteraction.send({
507
+ from: sponsorAddress
508
+ }).wait();
509
+ await expect(action.simulate({
510
+ from: sponsorAddress
511
+ })).rejects.toThrow(/unauthorized/);
498
512
  });
499
513
  it("uniswap can't pull funds without transfer approval", async ()=>{
500
514
  // swap should fail since no transfer approval to uniswap:
@@ -503,8 +517,12 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
503
517
  caller: uniswapL2Contract.address,
504
518
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferApproval)
505
519
  }, true);
506
- await validateActionInteraction.send().wait();
507
- await expect(uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, new Fr(420), uniswapFeeTier, minimumOutputAmount, ownerAddress, Fr.random(), ownerEthAddress, Fr.ZERO).simulate()).rejects.toThrow(/unauthorized/);
520
+ await validateActionInteraction.send({
521
+ from: ownerAddress
522
+ }).wait();
523
+ await expect(uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, new Fr(420), uniswapFeeTier, minimumOutputAmount, ownerAddress, Fr.random(), ownerEthAddress, Fr.ZERO).simulate({
524
+ from: ownerAddress
525
+ })).rejects.toThrow(/unauthorized/);
508
526
  });
509
527
  // tests when trying to mix private and public flows:
510
528
  it("can't call swap_public on L1 if called swap_private on L2", async ()=>{
@@ -523,6 +541,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
523
541
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
524
542
  const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
525
543
  const withdrawReceipt = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send({
544
+ from: ownerAddress,
526
545
  authWitnesses: [
527
546
  transferToPublicAuhtwit
528
547
  ]
@@ -559,9 +578,9 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
559
578
  });
560
579
  const swapResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawReceipt.blockNumber, swapPrivateLeaf);
561
580
  const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawReceipt.blockNumber, withdrawLeaf);
562
- const swapPrivateL2MessageIndex = swapResult.l2MessageIndex;
581
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
563
582
  const swapPrivateSiblingPath = swapResult.siblingPath;
564
- const withdrawL2MessageIndex = withdrawResult.l2MessageIndex;
583
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
565
584
  const withdrawSiblingPath = withdrawResult.siblingPath;
566
585
  const withdrawMessageMetadata = {
567
586
  _l2BlockNumber: BigInt(withdrawReceipt.blockNumber),
@@ -606,10 +625,14 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
606
625
  caller: uniswapL2Contract.address,
607
626
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferApproval)
608
627
  }, true);
609
- await validateActionInteraction.send().wait();
628
+ await validateActionInteraction.send({
629
+ from: ownerAddress
630
+ }).wait();
610
631
  // Call swap_public on L2
611
632
  const secretHashForDepositingSwappedDai = Fr.random();
612
- const withdrawReceipt = await uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferApproval, uniswapFeeTier, minimumOutputAmount, ownerAddress, secretHashForDepositingSwappedDai, ownerEthAddress, Fr.ZERO).send().wait();
633
+ const withdrawReceipt = await uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferApproval, uniswapFeeTier, minimumOutputAmount, ownerAddress, secretHashForDepositingSwappedDai, ownerEthAddress, Fr.ZERO).send({
634
+ from: ownerAddress
635
+ }).wait();
613
636
  const swapPublicContent = sha256ToField([
614
637
  Buffer.from(toFunctionSelector('swap_public(address,uint256,uint24,address,uint256,bytes32,bytes32,address)').substring(2), 'hex'),
615
638
  wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
@@ -643,9 +666,9 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
643
666
  });
644
667
  const swapResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawReceipt.blockNumber, swapPublicLeaf);
645
668
  const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawReceipt.blockNumber, withdrawLeaf);
646
- const swapPublicL2MessageIndex = swapResult.l2MessageIndex;
669
+ const swapPublicL2MessageIndex = swapResult.leafIndex;
647
670
  const swapPublicSiblingPath = swapResult.siblingPath;
648
- const withdrawL2MessageIndex = withdrawResult.l2MessageIndex;
671
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
649
672
  const withdrawSiblingPath = withdrawResult.siblingPath;
650
673
  const withdrawMessageMetadata = {
651
674
  _l2BlockNumber: BigInt(withdrawReceipt.blockNumber),
@@ -1,5 +1,5 @@
1
1
  import { AztecAddress, Fr } from '@aztec/aztec.js';
2
- import { CheatCodes } from '@aztec/aztec.js/testing';
2
+ import { CheatCodes } from '@aztec/aztec/testing';
3
3
  import type { RollupContract } from '@aztec/ethereum';
4
4
  import type { TestDateProvider } from '@aztec/foundation/timer';
5
5
  import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
@@ -1 +1 @@
1
- {"version":3,"file":"lending_simulator.d.ts","sourceRoot":"","sources":["../../src/simulators/lending_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;GAEG;AACH,qBAAa,cAAc;IACzB,yCAAyC;IACzC,SAAgB,OAAO,EAAE,YAAY,CAAC;IACtC,2CAA2C;IAC3C,SAAgB,MAAM,EAAE,EAAE,CAAC;gBAEf,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE;IAK7C;;;OAGG;IACI,GAAG;CAGX;AAgCD;;GAEG;AACH,qBAAa,gBAAgB;IAYzB,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,oBAAoB;IAC5B,0BAA0B;IACnB,MAAM,EA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,CAAc;IAC9B,OAAO,CAAC,aAAa,CAAc;gBAGzB,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,EACZ,oBAAoB,EAAE,MAAM;IACpC,0BAA0B;IACnB,MAAM,EAAE,cAAc;IAC7B,2BAA2B;IACpB,eAAe,EAAE,eAAe;IACvC,wDAAwD;IACjD,eAAe,EAAE,cAAc;IACtC,uDAAuD;IAChD,UAAU,EAAE,cAAc;IAG7B,OAAO;IAMP,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,gBAAgB;IAmBjE,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM;IAKjE,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM;IAKhE,OAAO,CAAC,OAAO;IAKf,QAAQ,CAAC,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IAM3D,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IASzD,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM;IAK/D,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM;IAK9D,OAAO,CAAC,KAAK;IAQb,yBAAyB,CAAC,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,UAAQ;IASzE,KAAK;CA0BZ"}
@@ -149,7 +149,9 @@ const computeMultiplier = (rate, dt)=>{
149
149
  const totalCollateral = Object.values(this.collateral).reduce((a, b)=>new Fr(a.value + b.value), Fr.ZERO);
150
150
  expect(totalCollateral).toEqual(new Fr(this.collateralAsset.balanceOfPublic(this.lendingContract.address)));
151
151
  expect(this.borrowed).toEqual(this.stableCoin.totalSupply - this.mintedOutside);
152
- const asset = await this.lendingContract.methods.get_asset(0).simulate();
152
+ const asset = await this.lendingContract.methods.get_asset(0).simulate({
153
+ from: this.account.address
154
+ });
153
155
  const interestAccumulator = asset['interest_accumulator'];
154
156
  expect(interestAccumulator).toEqual(this.accumulator);
155
157
  expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
@@ -157,7 +159,9 @@ const computeMultiplier = (rate, dt)=>{
157
159
  this.account.address,
158
160
  AztecAddress.fromField(await this.account.key())
159
161
  ]){
160
- const privatePos = await this.lendingContract.methods.get_position(key).simulate();
162
+ const privatePos = await this.lendingContract.methods.get_position(key).simulate({
163
+ from: key
164
+ });
161
165
  expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
162
166
  expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
163
167
  expect(privatePos['debt']).toEqual(muldivUp((this.staticDebt[key.toString()] ?? Fr.ZERO).value, this.accumulator, BASE));
@@ -3,13 +3,14 @@ import type { TokenContract } from '@aztec/noir-contracts.js/Token';
3
3
  export declare class TokenSimulator {
4
4
  protected token: TokenContract;
5
5
  protected defaultWallet: Wallet;
6
+ protected defaultAddress: AztecAddress;
6
7
  protected logger: Logger;
7
8
  protected accounts: AztecAddress[];
8
9
  private balancesPrivate;
9
10
  private balancePublic;
10
11
  totalSupply: bigint;
11
12
  private lookupProvider;
12
- constructor(token: TokenContract, defaultWallet: Wallet, logger: Logger, accounts: AztecAddress[]);
13
+ constructor(token: TokenContract, defaultWallet: Wallet, defaultAddress: AztecAddress, logger: Logger, accounts: AztecAddress[]);
13
14
  addAccount(account: AztecAddress): void;
14
15
  setLookupProvider(account: AztecAddress, wallet: Wallet): void;
15
16
  mintPrivate(to: AztecAddress, amount: bigint): void;
@@ -1 +1 @@
1
- {"version":3,"file":"token_simulator.d.ts","sourceRoot":"","sources":["../../src/simulators/token_simulator.ts"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AM,EAAE,MAAM;IASpE,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IAQtE,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IAQrE,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IAQ9C,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IAQ7C,eAAe,CAAC,OAAO,EAAE,YAAY;IAIrC,gBAAgB,CAAC,OAAO,EAAE,YAAY;IAIvC,WAAW;IAoBX,YAAY;IAsCL,KAAK;CAInB"}
@@ -3,15 +3,17 @@ import chunk from 'lodash.chunk';
3
3
  export class TokenSimulator {
4
4
  token;
5
5
  defaultWallet;
6
+ defaultAddress;
6
7
  logger;
7
8
  accounts;
8
9
  balancesPrivate;
9
10
  balancePublic;
10
11
  totalSupply;
11
12
  lookupProvider;
12
- constructor(token, defaultWallet, logger, accounts){
13
+ constructor(token, defaultWallet, defaultAddress, logger, accounts){
13
14
  this.token = token;
14
15
  this.defaultWallet = defaultWallet;
16
+ this.defaultAddress = defaultAddress;
15
17
  this.logger = logger;
16
18
  this.accounts = accounts;
17
19
  this.balancesPrivate = new Map();
@@ -86,7 +88,9 @@ export class TokenSimulator {
86
88
  this.token.methods.total_supply(),
87
89
  ...this.accounts.map((address)=>this.token.methods.balance_of_public(address))
88
90
  ];
89
- const results = (await Promise.all(chunk(calls, 4).map((batch)=>new BatchCall(this.defaultWallet, batch).simulate()))).flat();
91
+ const results = (await Promise.all(chunk(calls, 4).map((batch)=>new BatchCall(this.defaultWallet, batch).simulate({
92
+ from: this.defaultAddress
93
+ })))).flat();
90
94
  expect(results[0]).toEqual(this.totalSupply);
91
95
  // Check that all our balances match
92
96
  for(let i = 0; i < this.accounts.length; i++){
@@ -105,7 +109,9 @@ export class TokenSimulator {
105
109
  }
106
110
  }
107
111
  const defaultCalls = defaultLookups.map((address)=>this.token.methods.balance_of_private(address));
108
- const results = (await Promise.all(chunk(defaultCalls, 4).map((batch)=>new BatchCall(this.defaultWallet, batch).simulate()))).flat();
112
+ const results = (await Promise.all(chunk(defaultCalls, 4).map((batch)=>new BatchCall(this.defaultWallet, batch).simulate({
113
+ from: this.defaultAddress
114
+ })))).flat();
109
115
  for(let i = 0; i < defaultLookups.length; i++){
110
116
  expect(results[i]).toEqual(this.balanceOfPrivate(defaultLookups[i]));
111
117
  }
@@ -116,7 +122,9 @@ export class TokenSimulator {
116
122
  const asset = wallet ? this.token.withWallet(wallet) : this.token;
117
123
  const actualPrivateBalance = await asset.methods.balance_of_private({
118
124
  address
119
- }).simulate();
125
+ }).simulate({
126
+ from: this.defaultAddress
127
+ });
120
128
  expect(actualPrivateBalance).toEqual(this.balanceOfPrivate(address));
121
129
  }
122
130
  }
@@ -5,11 +5,14 @@ export interface TestWallets {
5
5
  pxe: PXE;
6
6
  wallets: AccountWalletWithSecretKey[];
7
7
  tokenAdminWallet: TokenContract;
8
+ tokenAdminAddress: AztecAddress;
8
9
  tokenName: string;
9
10
  recipientWallet: AccountWalletWithSecretKey;
11
+ recipientAddress: AztecAddress;
10
12
  tokenAddress: AztecAddress;
11
13
  }
12
14
  export declare function setupTestWalletsWithTokens(pxeUrl: string, mintAmount: bigint, logger: Logger): Promise<TestWallets>;
15
+ export declare function deploySponsoredTestWallets(pxe: PXE, mintAmount: bigint, logger: Logger, numberOfFundedWallets?: number): Promise<TestWallets>;
13
16
  export declare function deployTestWalletWithTokens(pxeUrl: string, nodeUrl: string, l1RpcUrls: string[], mnemonicOrPrivateKey: string, mintAmount: bigint, logger: Logger, numberOfFundedWallets?: number): Promise<TestWallets>;
14
17
  export declare function performTransfers({ testWallets, rounds, transferAmount, logger, }: {
15
18
  testWallets: TestWallets;
@@ -17,4 +20,8 @@ export declare function performTransfers({ testWallets, rounds, transferAmount,
17
20
  transferAmount: bigint;
18
21
  logger: Logger;
19
22
  }): Promise<void>;
23
+ export declare function startCompatiblePXE(nodeUrl: string, proverEnabled: boolean, logger: Logger): Promise<{
24
+ pxe: PXE;
25
+ cleanup: () => Promise<void>;
26
+ }>;
20
27
  //# sourceMappingURL=setup_test_wallets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup_test_wallets.d.ts","sourceRoot":"","sources":["../../src/spartan/setup_test_wallets.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EAKjB,KAAK,GAAG,EAIT,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,GAAG,CAAC;IACT,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,gBAAgB,EAAE,aAAa,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,0BAA0B,CAAC;IAC5C,YAAY,EAAE,YAAY,CAAC;CAC5B;AAMD,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,CAAC,CAYtB;AAED,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EAAE,EACnB,oBAAoB,EAAE,MAAM,EAC5B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,qBAAqB,SAAI,GACxB,OAAO,CAAC,WAAW,CAAC,CAqCtB;AA6DD,wBAAsB,gBAAgB,CAAC,EACrC,WAAW,EACX,MAAM,EACN,cAAc,EACd,MAAM,GACP,EAAE;IACD,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAA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