@aztec/end-to-end 0.0.0-test.1 → 0.0.1-fake-ceab37513c

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 (156) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +60 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +261 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +69 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.js +315 -0
  7. package/dest/bench/client_flows/config.d.ts +14 -0
  8. package/dest/bench/client_flows/config.d.ts.map +1 -0
  9. package/dest/bench/client_flows/config.js +106 -0
  10. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  12. package/dest/bench/client_flows/data_extractor.js +99 -0
  13. package/dest/bench/utils.d.ts +10 -27
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +27 -43
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +15 -7
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +66 -38
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -18
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +34 -53
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -2
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +9 -6
  25. package/dest/e2e_epochs/epochs_test.d.ts +56 -17
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +222 -42
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +60 -0
  31. package/dest/e2e_fees/fees_test.d.ts +16 -5
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +87 -88
  34. package/dest/e2e_l1_publisher/write_json.d.ts +8 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +57 -0
  37. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  38. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  39. package/dest/e2e_multi_validator/utils.js +214 -0
  40. package/dest/e2e_nested_contract/nested_contract_test.d.ts +5 -5
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +19 -14
  43. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.js +132 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +56 -21
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +154 -125
  49. package/dest/e2e_p2p/shared.d.ts +41 -3
  50. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  51. package/dest/e2e_p2p/shared.js +146 -6
  52. package/dest/e2e_token_contract/token_contract_test.d.ts +10 -5
  53. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  54. package/dest/e2e_token_contract/token_contract_test.js +51 -24
  55. package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +7 -4
  56. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  57. package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +67 -62
  58. package/dest/fixtures/fixtures.d.ts +5 -6
  59. package/dest/fixtures/fixtures.d.ts.map +1 -1
  60. package/dest/fixtures/fixtures.js +4 -3
  61. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  62. package/dest/fixtures/get_acvm_config.js +2 -14
  63. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  64. package/dest/fixtures/get_bb_config.js +8 -15
  65. package/dest/fixtures/l1_to_l2_messaging.d.ts +8 -5
  66. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  67. package/dest/fixtures/l1_to_l2_messaging.js +44 -18
  68. package/dest/fixtures/setup_l1_contracts.d.ts +3 -3
  69. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  70. package/dest/fixtures/setup_l1_contracts.js +3 -3
  71. package/dest/fixtures/setup_p2p_test.d.ts +14 -6
  72. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  73. package/dest/fixtures/setup_p2p_test.js +73 -21
  74. package/dest/fixtures/snapshot_manager.d.ts +8 -3
  75. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  76. package/dest/fixtures/snapshot_manager.js +120 -104
  77. package/dest/fixtures/token_utils.d.ts +4 -3
  78. package/dest/fixtures/token_utils.d.ts.map +1 -1
  79. package/dest/fixtures/token_utils.js +24 -7
  80. package/dest/fixtures/utils.d.ts +65 -22
  81. package/dest/fixtures/utils.d.ts.map +1 -1
  82. package/dest/fixtures/utils.js +439 -318
  83. package/dest/fixtures/web3signer.d.ts +5 -0
  84. package/dest/fixtures/web3signer.d.ts.map +1 -0
  85. package/dest/fixtures/web3signer.js +42 -0
  86. package/dest/shared/cross_chain_test_harness.d.ts +28 -18
  87. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  88. package/dest/shared/cross_chain_test_harness.js +97 -41
  89. package/dest/shared/gas_portal_test_harness.d.ts +23 -18
  90. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  91. package/dest/shared/gas_portal_test_harness.js +43 -25
  92. package/dest/shared/submit-transactions.d.ts.map +1 -1
  93. package/dest/shared/uniswap_l1_l2.d.ts +5 -6
  94. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  95. package/dest/shared/uniswap_l1_l2.js +136 -90
  96. package/dest/simulators/lending_simulator.d.ts +5 -6
  97. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  98. package/dest/simulators/lending_simulator.js +11 -15
  99. package/dest/simulators/token_simulator.d.ts +2 -1
  100. package/dest/simulators/token_simulator.d.ts.map +1 -1
  101. package/dest/simulators/token_simulator.js +16 -13
  102. package/dest/spartan/setup_test_wallets.d.ts +8 -1
  103. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  104. package/dest/spartan/setup_test_wallets.js +108 -22
  105. package/dest/spartan/utils.d.ts +60 -307
  106. package/dest/spartan/utils.d.ts.map +1 -1
  107. package/dest/spartan/utils.js +200 -115
  108. package/package.json +60 -56
  109. package/src/bench/client_flows/benchmark.ts +341 -0
  110. package/src/bench/client_flows/client_flows_benchmark.ts +422 -0
  111. package/src/bench/client_flows/config.ts +61 -0
  112. package/src/bench/client_flows/data_extractor.ts +111 -0
  113. package/src/bench/utils.ts +26 -52
  114. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +60 -40
  115. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +47 -75
  116. package/src/e2e_deploy_contract/deploy_test.ts +11 -8
  117. package/src/e2e_epochs/epochs_test.ts +276 -54
  118. package/src/e2e_fees/bridging_race.notest.ts +75 -0
  119. package/src/e2e_fees/fees_test.ts +121 -108
  120. package/src/e2e_l1_publisher/write_json.ts +74 -0
  121. package/src/e2e_multi_validator/utils.ts +258 -0
  122. package/src/e2e_nested_contract/nested_contract_test.ts +22 -14
  123. package/src/e2e_p2p/inactivity_slash_test.ts +174 -0
  124. package/src/e2e_p2p/p2p_network.ts +212 -144
  125. package/src/e2e_p2p/shared.ts +234 -14
  126. package/src/e2e_token_contract/token_contract_test.ts +42 -38
  127. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  128. package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +62 -69
  129. package/src/fixtures/fixtures.ts +4 -3
  130. package/src/fixtures/get_acvm_config.ts +2 -10
  131. package/src/fixtures/get_bb_config.ts +15 -11
  132. package/src/fixtures/l1_to_l2_messaging.ts +53 -23
  133. package/src/fixtures/setup_l1_contracts.ts +5 -6
  134. package/src/fixtures/setup_p2p_test.ts +112 -30
  135. package/src/fixtures/snapshot_manager.ts +150 -102
  136. package/src/fixtures/token_utils.ts +33 -8
  137. package/src/fixtures/utils.ts +530 -352
  138. package/src/fixtures/web3signer.ts +46 -0
  139. package/src/guides/up_quick_start.sh +4 -4
  140. package/src/shared/cross_chain_test_harness.ts +92 -52
  141. package/src/shared/gas_portal_test_harness.ts +47 -31
  142. package/src/shared/uniswap_l1_l2.ts +127 -124
  143. package/src/simulators/lending_simulator.ts +11 -15
  144. package/src/simulators/token_simulator.ts +17 -12
  145. package/src/spartan/DEVELOP.md +116 -0
  146. package/src/spartan/setup_test_wallets.ts +144 -29
  147. package/src/spartan/utils.ts +194 -116
  148. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  149. package/dest/sample-dapp/connect.js +0 -12
  150. package/dest/sample-dapp/contracts.js +0 -10
  151. package/dest/sample-dapp/deploy.js +0 -35
  152. package/dest/sample-dapp/index.js +0 -98
  153. package/src/sample-dapp/connect.mjs +0 -16
  154. package/src/sample-dapp/contracts.mjs +0 -14
  155. package/src/sample-dapp/deploy.mjs +0 -40
  156. package/src/sample-dapp/index.mjs +0 -128
@@ -0,0 +1,5 @@
1
+ export declare function createWeb3SignerKeystore(dir: string, ...privateKeys: string[]): Promise<void>;
2
+ export declare function refreshWeb3Signer(url: string): Promise<void>;
3
+ export declare function getWeb3SignerTestKeystoreDir(): string;
4
+ export declare function getWeb3SignerUrl(): string;
5
+ //# sourceMappingURL=web3signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web3signer.d.ts","sourceRoot":"","sources":["../../src/fixtures/web3signer.ts"],"names":[],"mappings":"AAOA,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,iBAcnF;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,iBAKlD;AAED,wBAAgB,4BAA4B,IAAI,MAAM,CAOrD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC"}
@@ -0,0 +1,42 @@
1
+ import { sleep } from '@aztec/aztec.js';
2
+ import { randomBytes } from '@aztec/foundation/crypto';
3
+ import { mkdirSync } from 'node:fs';
4
+ import { writeFile } from 'node:fs/promises';
5
+ import { join } from 'node:path';
6
+ export async function createWeb3SignerKeystore(dir, ...privateKeys) {
7
+ const yaml = privateKeys.map((pk)=>`\
8
+ type: file-raw
9
+ keyType: SECP256K1
10
+ privateKey: ${pk}`).join('\n---\n');
11
+ // NOTE: nodejs stdlib can only create temp directories, not temp files!
12
+ // this write uses wx (write-exclusive) so it'll throw if the file already exists
13
+ const path = join(dir, `keystore-${randomBytes(4).toString('hex')}.yaml`);
14
+ await writeFile(path, yaml, {
15
+ flag: 'wx'
16
+ });
17
+ }
18
+ export async function refreshWeb3Signer(url) {
19
+ await fetch(new URL('reload', url), {
20
+ method: 'POST'
21
+ });
22
+ // give the service a chance to load up the new files
23
+ // 1s might not be enough if there are a lot of files to scan
24
+ await sleep(1000);
25
+ }
26
+ export function getWeb3SignerTestKeystoreDir() {
27
+ if (process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR) {
28
+ mkdirSync(process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR, {
29
+ recursive: true
30
+ });
31
+ return process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR;
32
+ } else {
33
+ throw new Error('Web3signer not running');
34
+ }
35
+ }
36
+ export function getWeb3SignerUrl() {
37
+ if (process.env.WEB3_SIGNER_URL) {
38
+ return process.env.WEB3_SIGNER_URL;
39
+ } else {
40
+ throw new Error('Web3signer not running');
41
+ }
42
+ }
@@ -1,5 +1,5 @@
1
- import { type AccountWallet, type AztecAddress, type AztecNode, EthAddress, type FieldsOf, Fr, type L2AmountClaim, type L2AmountClaimWithRecipient, type Logger, type PXE, type SiblingPath, type TxReceipt, type Wallet } from '@aztec/aztec.js';
2
- import type { L1ContractAddresses, ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
1
+ import { type AccountWallet, AuthWitness, type AztecAddress, type AztecNode, EthAddress, type FieldsOf, Fr, type L2AmountClaim, type L2AmountClaimWithRecipient, type Logger, type PXE, type SiblingPath, type TxReceipt, type Wallet } from '@aztec/aztec.js';
2
+ import { type ExtendedViemWalletClient, type L1ContractAddresses } from '@aztec/ethereum';
3
3
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
4
4
  import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
5
5
  import { type Hex } from 'viem';
@@ -13,7 +13,7 @@ import { type Hex } from 'viem';
13
13
  * @param underlyingERC20Address - address of the underlying ERC20 contract to use (if none supplied, it deploys one)
14
14
  * @returns l2 contract instance, bridge contract instance, token portal instance, token portal address and the underlying ERC20 instance
15
15
  */
16
- export declare function deployAndInitializeTokenAndBridgeContracts(wallet: Wallet, walletClient: ViemWalletClient, publicClient: ViemPublicClient, rollupRegistryAddress: EthAddress, owner: AztecAddress, underlyingERC20Address: EthAddress): Promise<{
16
+ export declare function deployAndInitializeTokenAndBridgeContracts(wallet: Wallet, l1Client: ExtendedViemWalletClient, rollupRegistryAddress: EthAddress, owner: AztecAddress, underlyingERC20Address: EthAddress): Promise<{
17
17
  /**
18
18
  * The L2 token contract instance.
19
19
  */
@@ -35,6 +35,16 @@ export declare function deployAndInitializeTokenAndBridgeContracts(wallet: Walle
35
35
  */
36
36
  underlyingERC20: any;
37
37
  }>;
38
+ export type CrossChainContext = {
39
+ l2Token: AztecAddress;
40
+ l2Bridge: AztecAddress;
41
+ tokenPortal: EthAddress;
42
+ underlying: EthAddress;
43
+ ethAccount: EthAddress;
44
+ ownerAddress: AztecAddress;
45
+ inbox: EthAddress;
46
+ outbox: EthAddress;
47
+ };
38
48
  /**
39
49
  * A Class for testing cross chain interactions, contains common interactions
40
50
  * shared between cross chain tests.
@@ -56,18 +66,17 @@ export declare class CrossChainTestHarness {
56
66
  tokenPortalAddress: EthAddress;
57
67
  /** Underlying token for portal tests. */
58
68
  underlyingERC20Address: EthAddress;
59
- /** Viem Public client instance. */
60
- publicClient: ViemPublicClient;
61
- /** Viem Wallet Client instance. */
62
- walletClient: ViemWalletClient;
69
+ /** Viem Extended client instance. */
70
+ l1Client: ExtendedViemWalletClient;
63
71
  /** Deployment addresses for all L1 contracts */
64
72
  readonly l1ContractAddresses: L1ContractAddresses;
65
73
  /** Wallet of the owner. */
66
74
  readonly ownerWallet: AccountWallet;
67
- static new(aztecNode: AztecNode, pxeService: PXE, publicClient: ViemPublicClient, walletClient: ViemWalletClient, wallet: AccountWallet, logger: Logger, underlyingERC20Address: EthAddress): Promise<CrossChainTestHarness>;
75
+ /** Owner of the l2 token and bridge */
76
+ readonly ownerAddress: AztecAddress;
77
+ static new(aztecNode: AztecNode, pxeService: PXE, l1Client: ExtendedViemWalletClient, wallet: AccountWallet, ownerAddress: AztecAddress, logger: Logger, underlyingERC20Address: EthAddress): Promise<CrossChainTestHarness>;
68
78
  private readonly l1TokenManager;
69
79
  private readonly l1TokenPortalManager;
70
- readonly ownerAddress: AztecAddress;
71
80
  constructor(
72
81
  /** Aztec node instance. */
73
82
  aztecNode: AztecNode,
@@ -85,14 +94,14 @@ export declare class CrossChainTestHarness {
85
94
  tokenPortalAddress: EthAddress,
86
95
  /** Underlying token for portal tests. */
87
96
  underlyingERC20Address: EthAddress,
88
- /** Viem Public client instance. */
89
- publicClient: ViemPublicClient,
90
- /** Viem Wallet Client instance. */
91
- walletClient: ViemWalletClient,
97
+ /** Viem Extended client instance. */
98
+ l1Client: ExtendedViemWalletClient,
92
99
  /** Deployment addresses for all L1 contracts */
93
100
  l1ContractAddresses: L1ContractAddresses,
94
101
  /** Wallet of the owner. */
95
- ownerWallet: AccountWallet);
102
+ ownerWallet: AccountWallet,
103
+ /** Owner of the l2 token and bridge */
104
+ ownerAddress: AztecAddress);
96
105
  mintTokensOnL1(amount: bigint): Promise<void>;
97
106
  getL1BalanceOf(address: EthAddress): Promise<bigint>;
98
107
  sendTokensToPortalPublic(bridgeAmount: bigint, mint?: boolean): Promise<L2AmountClaim>;
@@ -102,16 +111,16 @@ export declare class CrossChainTestHarness {
102
111
  sendL2PublicTransfer(transferAmount: bigint, receiverAddress: AztecAddress): Promise<void>;
103
112
  consumeMessageOnAztecAndMintPrivately(claim: Pick<L2AmountClaimWithRecipient, 'claimAmount' | 'claimSecret' | 'messageLeafIndex' | 'recipient'>): Promise<void>;
104
113
  consumeMessageOnAztecAndMintPublicly(claim: Pick<L2AmountClaim, 'claimAmount' | 'claimSecret' | 'messageLeafIndex'>): Promise<void>;
105
- withdrawPrivateFromAztecToL1(withdrawAmount: bigint, nonce?: Fr): Promise<FieldsOf<TxReceipt>>;
106
- withdrawPublicFromAztecToL1(withdrawAmount: bigint, nonce?: Fr): Promise<FieldsOf<TxReceipt>>;
114
+ withdrawPrivateFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr | undefined, authWitness: AuthWitness): Promise<FieldsOf<TxReceipt>>;
115
+ withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce?: Fr): Promise<FieldsOf<TxReceipt>>;
107
116
  getL2PrivateBalanceOf(owner: AztecAddress): Promise<any>;
108
117
  expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint): Promise<void>;
109
118
  getL2PublicBalanceOf(owner: AztecAddress): Promise<any>;
110
119
  expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint): Promise<void>;
111
- getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1?: EthAddress): Fr;
120
+ getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1?: EthAddress): Promise<Fr>;
112
121
  withdrawFundsFromBridgeOnL1(amount: bigint, blockNumber: number | bigint, messageIndex: bigint, siblingPath: SiblingPath<number>): Promise<void>;
113
122
  transferToPrivateOnL2(shieldAmount: bigint): Promise<void>;
114
- transferToPublicOnL2(amount: bigint, nonce?: Fr): Promise<void>;
123
+ transferToPublicOnL2(amount: bigint, authwitNonce?: Fr): Promise<void>;
115
124
  /**
116
125
  * Makes message available for consumption.
117
126
  * @dev Does that by performing 2 unrelated transactions on L2 to progress the rollup by 2 blocks and then waits for
@@ -120,5 +129,6 @@ export declare class CrossChainTestHarness {
120
129
  * it's included it becomes available for consumption in the next block because the l1 to l2 message tree.
121
130
  */
122
131
  makeMessageConsumable(msgHash: Fr | Hex): Promise<void>;
132
+ toCrossChainContext(): CrossChainContext;
123
133
  }
124
134
  //# sourceMappingURL=cross_chain_test_harness.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cross_chain_test_harness.d.ts","sourceRoot":"","sources":["../../src/shared/cross_chain_test_harness.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,UAAU,EACV,KAAK,QAAQ,EACb,EAAE,EAGF,KAAK,aAAa,EAClB,KAAK,0BAA0B,EAC/B,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,MAAM,EAGZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAE/F,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE,KAAK,GAAG,EAAe,MAAM,MAAM,CAAC;AAK7C;;;;;;;;;GASG;AACH,wBAAsB,0CAA0C,CAC9D,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,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xC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAU1E,4BAA4B,CAChC,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,EAAE,YAAU,EAC1B,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IASzB,2BAA2B,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,GAAE,EAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAS7G,qBAAqB,CAAC,KAAK,EAAE,YAAY;IAIzC,wBAAwB,CAAC,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM;IAMrE,oBAAoB,CAAC,KAAK,EAAE,YAAY;IAIxC,uBAAuB,CAAC,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM;IAKpE,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,GAAE,UAA4B,GAAG,OAAO,CAAC,EAAE,CAAC;IASzG,2BAA2B,CACzB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC;IAW5B,qBAAqB,CAAC,YAAY,EAAE,MAAM;IAQ1C,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,KAAU;IAQjE;;;;;;OAMG;IACG,qBAAqB,CAAC,OAAO,EAAE,EAAE,GAAG,GAAG;IAS7C,mBAAmB,IAAI,iBAAiB;CAYzC"}
@@ -1,5 +1,6 @@
1
1
  // docs:start:cross_chain_test_harness
2
- import { EthAddress, Fr, L1TokenPortalManager, deployL1Contract, retryUntil } from '@aztec/aztec.js';
2
+ import { EthAddress, Fr, L1TokenPortalManager, retryUntil } from '@aztec/aztec.js';
3
+ import { deployL1Contract } from '@aztec/ethereum';
3
4
  import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
4
5
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
5
6
  import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
@@ -15,27 +16,39 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
15
16
  * @param owner - owner of the L2 contract
16
17
  * @param underlyingERC20Address - address of the underlying ERC20 contract to use (if none supplied, it deploys one)
17
18
  * @returns l2 contract instance, bridge contract instance, token portal instance, token portal address and the underlying ERC20 instance
18
- */ export async function deployAndInitializeTokenAndBridgeContracts(wallet, walletClient, publicClient, rollupRegistryAddress, owner, underlyingERC20Address) {
19
+ */ export async function deployAndInitializeTokenAndBridgeContracts(wallet, l1Client, rollupRegistryAddress, owner, underlyingERC20Address) {
19
20
  // deploy the token portal
20
- const { address: tokenPortalAddress } = await deployL1Contract(walletClient, publicClient, TokenPortalAbi, TokenPortalBytecode);
21
+ const { address: tokenPortalAddress } = await deployL1Contract(l1Client, TokenPortalAbi, TokenPortalBytecode);
21
22
  const tokenPortal = getContract({
22
23
  address: tokenPortalAddress.toString(),
23
24
  abi: TokenPortalAbi,
24
- client: walletClient
25
+ client: l1Client
25
26
  });
26
27
  // deploy l2 token
27
- 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();
28
31
  // deploy l2 token bridge and attach to the portal
29
- const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send().deployed();
30
- 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()) {
31
38
  throw new Error(`Token admin is not ${owner}`);
32
39
  }
33
- 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)) {
34
43
  throw new Error(`Bridge token is not ${token.address}`);
35
44
  }
36
45
  // make the bridge a minter on the token:
37
- await token.methods.set_minter(bridge.address, true).send().wait();
38
- 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) {
39
52
  throw new Error(`Bridge is not a minter`);
40
53
  }
41
54
  // initialize portal
@@ -47,7 +60,7 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
47
60
  const underlyingERC20 = getContract({
48
61
  address: underlyingERC20Address.toString(),
49
62
  abi: TestERC20Abi,
50
- client: walletClient
63
+ client: l1Client
51
64
  });
52
65
  return {
53
66
  token,
@@ -57,7 +70,6 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
57
70
  underlyingERC20
58
71
  };
59
72
  }
60
- // docs:end:deployAndInitializeTokenAndBridgeContracts
61
73
  /**
62
74
  * A Class for testing cross chain interactions, contains common interactions
63
75
  * shared between cross chain tests.
@@ -70,23 +82,22 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
70
82
  ethAccount;
71
83
  tokenPortalAddress;
72
84
  underlyingERC20Address;
73
- publicClient;
74
- walletClient;
85
+ l1Client;
75
86
  l1ContractAddresses;
76
87
  ownerWallet;
77
- static async new(aztecNode, pxeService, publicClient, walletClient, wallet, logger, underlyingERC20Address) {
78
- const ethAccount = EthAddress.fromString((await walletClient.getAddresses())[0]);
88
+ ownerAddress;
89
+ static async new(aztecNode, pxeService, l1Client, wallet, ownerAddress, logger, underlyingERC20Address) {
90
+ const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
79
91
  const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;
80
92
  // Deploy and initialize all required contracts
81
93
  logger.info('Deploying and initializing token, portal and its bridge...');
82
- const { token, bridge, tokenPortalAddress, underlyingERC20 } = await deployAndInitializeTokenAndBridgeContracts(wallet, walletClient, publicClient, l1ContractAddresses.registryAddress, wallet.getAddress(), underlyingERC20Address);
94
+ const { token, bridge, tokenPortalAddress, underlyingERC20 } = await deployAndInitializeTokenAndBridgeContracts(wallet, l1Client, l1ContractAddresses.registryAddress, wallet.getAddress(), underlyingERC20Address);
83
95
  logger.info('Deployed and initialized token, portal and its bridge.');
84
- return new CrossChainTestHarness(aztecNode, pxeService, logger, token, bridge, ethAccount, tokenPortalAddress, underlyingERC20.address, publicClient, walletClient, l1ContractAddresses, wallet);
96
+ return new CrossChainTestHarness(aztecNode, pxeService, logger, token, bridge, ethAccount, tokenPortalAddress, underlyingERC20.address, l1Client, l1ContractAddresses, wallet, ownerAddress);
85
97
  }
86
98
  l1TokenManager;
87
99
  l1TokenPortalManager;
88
- ownerAddress;
89
- 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 Public client instance. */ publicClient, /** Viem Wallet Client instance. */ walletClient, /** 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){
90
101
  this.aztecNode = aztecNode;
91
102
  this.pxeService = pxeService;
92
103
  this.logger = logger;
@@ -95,17 +106,29 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
95
106
  this.ethAccount = ethAccount;
96
107
  this.tokenPortalAddress = tokenPortalAddress;
97
108
  this.underlyingERC20Address = underlyingERC20Address;
98
- this.publicClient = publicClient;
99
- this.walletClient = walletClient;
109
+ this.l1Client = l1Client;
100
110
  this.l1ContractAddresses = l1ContractAddresses;
101
111
  this.ownerWallet = ownerWallet;
102
- this.l1TokenPortalManager = new L1TokenPortalManager(this.tokenPortalAddress, this.underlyingERC20Address, this.l1ContractAddresses.outboxAddress, this.publicClient, this.walletClient, this.logger);
112
+ this.ownerAddress = ownerAddress;
113
+ this.l1TokenPortalManager = new L1TokenPortalManager(this.tokenPortalAddress, this.underlyingERC20Address, this.l1ContractAddresses.feeAssetHandlerAddress, this.l1ContractAddresses.outboxAddress, this.l1Client, this.logger);
103
114
  this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
104
115
  this.ownerAddress = this.ownerWallet.getAddress();
105
116
  }
106
117
  async mintTokensOnL1(amount) {
107
- await this.l1TokenManager.mint(amount, this.ethAccount.toString());
108
- expect(await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString())).toEqual(amount);
118
+ const contract = getContract({
119
+ abi: TestERC20Abi,
120
+ address: this.l1TokenManager.tokenAddress.toString(),
121
+ client: this.l1Client
122
+ });
123
+ const balanceBefore = await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString());
124
+ const hash = await contract.write.mint([
125
+ this.ethAccount.toString(),
126
+ amount
127
+ ]);
128
+ await this.l1Client.waitForTransactionReceipt({
129
+ hash
130
+ });
131
+ expect(await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString())).toEqual(balanceBefore + amount);
109
132
  }
110
133
  getL1BalanceOf(address) {
111
134
  return this.l1TokenManager.getL1TokenBalance(address.toString());
@@ -118,31 +141,46 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
118
141
  }
119
142
  async mintTokensPublicOnL2(amount) {
120
143
  this.logger.info('Minting tokens on L2 publicly');
121
- 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();
122
147
  }
123
148
  async mintTokensPrivateOnL2(amount) {
124
- await mintTokensToPrivate(this.l2Token, this.ownerWallet, this.ownerAddress, amount);
149
+ await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerWallet, this.ownerAddress, amount);
125
150
  }
126
151
  async sendL2PublicTransfer(transferAmount, receiverAddress) {
127
152
  // send a transfer tx to force through rollup with the message included
128
- 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();
129
156
  }
130
157
  async consumeMessageOnAztecAndMintPrivately(claim) {
131
158
  this.logger.info('Consuming messages on L2 privately');
132
159
  const { recipient, claimAmount, claimSecret: secretForL2MessageConsumption, messageLeafIndex } = claim;
133
- 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();
134
163
  }
135
164
  async consumeMessageOnAztecAndMintPublicly(claim) {
136
165
  this.logger.info('Consuming messages on L2 Publicly');
137
166
  const { claimAmount, claimSecret, messageLeafIndex } = claim;
138
- await this.l2Bridge.methods.claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex).send().wait();
139
- }
140
- async withdrawPrivateFromAztecToL1(withdrawAmount, nonce = Fr.ZERO) {
141
- const withdrawReceipt = await this.l2Bridge.methods.exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, nonce).send().wait();
167
+ await this.l2Bridge.methods.claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex).send({
168
+ from: this.ownerAddress
169
+ }).wait();
170
+ }
171
+ async withdrawPrivateFromAztecToL1(withdrawAmount, authwitNonce = Fr.ZERO, authWitness) {
172
+ const withdrawReceipt = await this.l2Bridge.methods.exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce).send({
173
+ authWitnesses: [
174
+ authWitness
175
+ ],
176
+ from: this.ownerAddress
177
+ }).wait();
142
178
  return withdrawReceipt;
143
179
  }
144
- async withdrawPublicFromAztecToL1(withdrawAmount, nonce = Fr.ZERO) {
145
- const withdrawReceipt = await this.l2Bridge.methods.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, nonce).send().wait();
180
+ async withdrawPublicFromAztecToL1(withdrawAmount, authwitNonce = Fr.ZERO) {
181
+ const withdrawReceipt = await this.l2Bridge.methods.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce).send({
182
+ from: this.ownerAddress
183
+ }).wait();
146
184
  return withdrawReceipt;
147
185
  }
148
186
  async getL2PrivateBalanceOf(owner) {
@@ -156,25 +194,31 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
156
194
  expect(balance).toBe(expectedBalance);
157
195
  }
158
196
  async getL2PublicBalanceOf(owner) {
159
- 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
+ });
160
200
  }
161
201
  async expectPublicBalanceOnL2(owner, expectedBalance) {
162
202
  const balance = await this.getL2PublicBalanceOf(owner);
163
203
  expect(balance).toBe(expectedBalance);
164
204
  }
165
- getL2ToL1MessageLeaf(withdrawAmount, callerOnL1 = EthAddress.ZERO) {
166
- return this.l1TokenPortalManager.getL2ToL1MessageLeaf(withdrawAmount, this.ethAccount, this.l2Bridge.address, callerOnL1);
205
+ async getL2ToL1MessageLeaf(withdrawAmount, callerOnL1 = EthAddress.ZERO) {
206
+ return await this.l1TokenPortalManager.getL2ToL1MessageLeaf(withdrawAmount, this.ethAccount, this.l2Bridge.address, callerOnL1);
167
207
  }
168
208
  withdrawFundsFromBridgeOnL1(amount, blockNumber, messageIndex, siblingPath) {
169
209
  return this.l1TokenPortalManager.withdrawFunds(amount, this.ethAccount, BigInt(blockNumber), messageIndex, siblingPath);
170
210
  }
171
211
  async transferToPrivateOnL2(shieldAmount) {
172
212
  this.logger.info('Transferring to private on L2');
173
- 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();
174
216
  }
175
- async transferToPublicOnL2(amount, nonce = Fr.ZERO) {
217
+ async transferToPublicOnL2(amount, authwitNonce = Fr.ZERO) {
176
218
  this.logger.info('Transferring tokens to public');
177
- await this.l2Token.methods.transfer_to_public(this.ownerAddress, this.ownerAddress, amount, nonce).send().wait();
219
+ await this.l2Token.methods.transfer_to_public(this.ownerAddress, this.ownerAddress, amount, authwitNonce).send({
220
+ from: this.ownerAddress
221
+ }).wait();
178
222
  }
179
223
  /**
180
224
  * Makes message available for consumption.
@@ -189,4 +233,16 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
189
233
  await this.mintTokensPublicOnL2(0n);
190
234
  await this.mintTokensPublicOnL2(0n);
191
235
  }
236
+ toCrossChainContext() {
237
+ return {
238
+ l2Token: this.l2Token.address,
239
+ l2Bridge: this.l2Bridge.address,
240
+ tokenPortal: this.tokenPortalAddress,
241
+ underlying: this.underlyingERC20Address,
242
+ ethAccount: this.ethAccount,
243
+ ownerAddress: this.ownerAddress,
244
+ inbox: this.l1ContractAddresses.inboxAddress,
245
+ outbox: this.l1ContractAddresses.outboxAddress
246
+ };
247
+ }
192
248
  } // docs:end:cross_chain_test_harness
@@ -1,18 +1,19 @@
1
1
  import { type AztecAddress, type AztecNode, EthAddress, L1FeeJuicePortalManager, type L1TokenManager, type L2AmountClaim, type Logger, type PXE, type Wallet } from '@aztec/aztec.js';
2
- import type { ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
2
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum';
3
3
  import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
4
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
4
5
  export interface IGasBridgingTestHarness {
5
6
  getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
6
- prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress): Promise<L2AmountClaim>;
7
- bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress): Promise<void>;
7
+ prepareTokensOnL1(owner: AztecAddress): Promise<L2AmountClaim>;
8
+ bridgeFromL1ToL2(owner: AztecAddress, claimer: AztecAddress): Promise<void>;
8
9
  feeJuice: FeeJuiceContract;
9
10
  l1FeeJuiceAddress: EthAddress;
10
11
  }
11
12
  export interface FeeJuicePortalTestingHarnessFactoryConfig {
12
13
  aztecNode: AztecNode;
14
+ aztecNodeAdmin?: AztecNodeAdmin;
13
15
  pxeService: PXE;
14
- publicClient: ViemPublicClient;
15
- walletClient: ViemWalletClient;
16
+ l1Client: ExtendedViemWalletClient;
16
17
  wallet: Wallet;
17
18
  logger: Logger;
18
19
  mockL1?: boolean;
@@ -30,6 +31,8 @@ export declare class FeeJuicePortalTestingHarnessFactory {
30
31
  export declare class GasBridgingTestHarness implements IGasBridgingTestHarness {
31
32
  /** Aztec node */
32
33
  aztecNode: AztecNode;
34
+ /** Aztec node admin interface */
35
+ aztecNodeAdmin: AztecNodeAdmin | undefined;
33
36
  /** Private eXecution Environment (PXE). */
34
37
  pxeService: PXE;
35
38
  /** Logger. */
@@ -42,15 +45,17 @@ export declare class GasBridgingTestHarness implements IGasBridgingTestHarness {
42
45
  feeJuicePortalAddress: EthAddress;
43
46
  /** Underlying token for portal tests. */
44
47
  l1FeeJuiceAddress: EthAddress;
45
- /** Viem Public client instance. */
46
- publicClient: ViemPublicClient;
47
- /** Viem Wallet Client instance. */
48
- walletClient: ViemWalletClient;
48
+ /** Fee asset handler address. */
49
+ feeAssetHandlerAddress: EthAddress;
50
+ /** Viem Extended client instance. */
51
+ l1Client: ExtendedViemWalletClient;
49
52
  readonly l1TokenManager: L1TokenManager;
50
53
  readonly feeJuicePortalManager: L1FeeJuicePortalManager;
51
54
  constructor(
52
55
  /** Aztec node */
53
56
  aztecNode: AztecNode,
57
+ /** Aztec node admin interface */
58
+ aztecNodeAdmin: AztecNodeAdmin | undefined,
54
59
  /** Private eXecution Environment (PXE). */
55
60
  pxeService: PXE,
56
61
  /** Logger. */
@@ -63,18 +68,18 @@ export declare class GasBridgingTestHarness implements IGasBridgingTestHarness {
63
68
  feeJuicePortalAddress: EthAddress,
64
69
  /** Underlying token for portal tests. */
65
70
  l1FeeJuiceAddress: EthAddress,
66
- /** Viem Public client instance. */
67
- publicClient: ViemPublicClient,
68
- /** Viem Wallet Client instance. */
69
- walletClient: ViemWalletClient);
70
- mintTokensOnL1(amount: bigint, to?: EthAddress): Promise<void>;
71
+ /** Fee asset handler address. */
72
+ feeAssetHandlerAddress: EthAddress,
73
+ /** Viem Extended client instance. */
74
+ l1Client: ExtendedViemWalletClient);
75
+ mintTokensOnL1(to?: EthAddress): Promise<void>;
71
76
  getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
72
- sendTokensToPortalPublic(bridgeAmount: bigint, l2Address: AztecAddress, mint?: boolean): Promise<L2AmountClaim>;
73
- consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claim: L2AmountClaim): Promise<void>;
77
+ sendTokensToPortalPublic(bridgeAmount: bigint, l2Address: AztecAddress): Promise<L2AmountClaim>;
78
+ consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claimer: AztecAddress, claim: L2AmountClaim): Promise<void>;
74
79
  getL2PublicBalanceOf(owner: AztecAddress): Promise<any>;
75
80
  expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint): Promise<void>;
76
- prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress): Promise<L2AmountClaim>;
77
- bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress): Promise<void>;
81
+ prepareTokensOnL1(owner: AztecAddress): Promise<L2AmountClaim>;
82
+ bridgeFromL1ToL2(owner: AztecAddress, claimer: AztecAddress): Promise<void>;
78
83
  private advanceL2Block;
79
84
  }
80
85
  //# sourceMappingURL=gas_portal_test_harness.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gas_portal_test_harness.d.ts","sourceRoot":"","sources":["../../src/shared/gas_portal_test_harness.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,UAAU,EAEV,uBAAuB,EACvB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,MAAM,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAGrE,MAAM,WAAW,uBAAuB;IACtC,oBAAoB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3D,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACrF,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,iBAAiB,EAAE,UAAU,CAAC;CAC/B;AAED,MAAM,WAAW,yCAAyC;IACxD,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,GAAG,CAAC;IAChB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,YAAY,EAAE,gBAAgB,CAAC;IAC/B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