@aztec/end-to-end 0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2 → 0.77.0-testnet-ignition.17

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 (138) hide show
  1. package/README.md +2 -0
  2. package/dest/bench/utils.d.ts +70 -0
  3. package/dest/bench/utils.d.ts.map +1 -0
  4. package/dest/bench/utils.js +24 -8
  5. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +46 -0
  6. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -0
  7. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +17 -17
  8. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +47 -0
  9. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -0
  10. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +27 -16
  11. package/dest/e2e_deploy_contract/deploy_test.d.ts +28 -0
  12. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -0
  13. package/dest/e2e_deploy_contract/deploy_test.js +4 -7
  14. package/dest/e2e_epochs/epochs_test.d.ts +51 -0
  15. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -0
  16. package/dest/e2e_epochs/epochs_test.js +155 -0
  17. package/dest/e2e_fees/fees_test.d.ts +73 -0
  18. package/dest/e2e_fees/fees_test.d.ts.map +1 -0
  19. package/dest/e2e_fees/fees_test.js +75 -32
  20. package/dest/e2e_nested_contract/nested_contract_test.d.ts +26 -0
  21. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -0
  22. package/dest/e2e_nested_contract/nested_contract_test.js +14 -12
  23. package/dest/e2e_p2p/p2p_network.d.ts +61 -0
  24. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -0
  25. package/dest/e2e_p2p/p2p_network.js +54 -30
  26. package/dest/e2e_p2p/shared.d.ts +10 -0
  27. package/dest/e2e_p2p/shared.d.ts.map +1 -0
  28. package/dest/e2e_p2p/shared.js +7 -8
  29. package/dest/e2e_prover/e2e_prover_test.d.ts +56 -0
  30. package/dest/e2e_prover/e2e_prover_test.d.ts.map +1 -0
  31. package/dest/e2e_prover/e2e_prover_test.js +20 -24
  32. package/dest/e2e_token_contract/token_contract_test.d.ts +29 -0
  33. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -0
  34. package/dest/e2e_token_contract/token_contract_test.js +4 -7
  35. package/dest/fixtures/fixtures.d.ts +17 -0
  36. package/dest/fixtures/fixtures.d.ts.map +1 -0
  37. package/dest/fixtures/fixtures.js +2 -2
  38. package/dest/fixtures/get_acvm_config.d.ts +8 -0
  39. package/dest/fixtures/get_acvm_config.d.ts.map +1 -0
  40. package/dest/fixtures/get_acvm_config.js +10 -5
  41. package/dest/fixtures/get_bb_config.d.ts +6 -0
  42. package/dest/fixtures/get_bb_config.d.ts.map +1 -0
  43. package/dest/fixtures/get_bb_config.js +9 -4
  44. package/dest/fixtures/index.d.ts +6 -0
  45. package/dest/fixtures/index.d.ts.map +1 -0
  46. package/dest/fixtures/l1_to_l2_messaging.d.ts +13 -0
  47. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -0
  48. package/dest/fixtures/l1_to_l2_messaging.js +1 -1
  49. package/dest/fixtures/logging.d.ts +8 -0
  50. package/dest/fixtures/logging.d.ts.map +1 -0
  51. package/dest/fixtures/setup_l1_contracts.d.ts +6 -0
  52. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -0
  53. package/dest/fixtures/setup_l1_contracts.js +6 -4
  54. package/dest/fixtures/setup_p2p_test.d.ts +22 -0
  55. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -0
  56. package/dest/fixtures/setup_p2p_test.js +5 -3
  57. package/dest/fixtures/snapshot_manager.d.ts +87 -0
  58. package/dest/fixtures/snapshot_manager.d.ts.map +1 -0
  59. package/dest/fixtures/snapshot_manager.js +67 -74
  60. package/dest/fixtures/token_utils.d.ts +6 -0
  61. package/dest/fixtures/token_utils.d.ts.map +1 -0
  62. package/dest/fixtures/token_utils.js +1 -1
  63. package/dest/fixtures/utils.d.ts +155 -0
  64. package/dest/fixtures/utils.d.ts.map +1 -0
  65. package/dest/fixtures/utils.js +97 -71
  66. package/dest/fixtures/with_telemetry_utils.d.ts +3 -0
  67. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -0
  68. package/dest/index.d.ts +2 -0
  69. package/dest/index.d.ts.map +1 -0
  70. package/dest/quality_of_service/alert_checker.d.ts +41 -0
  71. package/dest/quality_of_service/alert_checker.d.ts.map +1 -0
  72. package/dest/quality_of_service/alert_checker.js +4 -1
  73. package/dest/sample-dapp/index.js +1 -1
  74. package/dest/shared/cross_chain_test_harness.d.ts +124 -0
  75. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -0
  76. package/dest/shared/cross_chain_test_harness.js +6 -17
  77. package/dest/shared/gas_portal_test_harness.d.ts +80 -0
  78. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -0
  79. package/dest/shared/gas_portal_test_harness.js +11 -4
  80. package/dest/shared/index.d.ts +2 -0
  81. package/dest/shared/index.d.ts.map +1 -0
  82. package/dest/shared/index.js +0 -1
  83. package/dest/shared/jest_setup.d.ts +2 -0
  84. package/dest/shared/jest_setup.d.ts.map +1 -0
  85. package/dest/shared/submit-transactions.d.ts +4 -0
  86. package/dest/shared/submit-transactions.d.ts.map +1 -0
  87. package/dest/shared/submit-transactions.js +9 -17
  88. package/dest/shared/uniswap_l1_l2.d.ts +25 -0
  89. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -0
  90. package/dest/shared/uniswap_l1_l2.js +5 -10
  91. package/dest/simulators/index.d.ts +3 -0
  92. package/dest/simulators/index.d.ts.map +1 -0
  93. package/dest/simulators/lending_simulator.d.ts +69 -0
  94. package/dest/simulators/lending_simulator.d.ts.map +1 -0
  95. package/dest/simulators/lending_simulator.js +1 -3
  96. package/dest/simulators/token_simulator.d.ts +29 -0
  97. package/dest/simulators/token_simulator.d.ts.map +1 -0
  98. package/dest/spartan/setup_test_wallets.d.ts +20 -0
  99. package/dest/spartan/setup_test_wallets.d.ts.map +1 -0
  100. package/dest/spartan/setup_test_wallets.js +72 -38
  101. package/dest/spartan/utils.d.ts +485 -0
  102. package/dest/spartan/utils.d.ts.map +1 -0
  103. package/dest/spartan/utils.js +110 -2
  104. package/package.json +35 -40
  105. package/src/bench/utils.ts +30 -13
  106. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +40 -30
  107. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +34 -18
  108. package/src/e2e_deploy_contract/deploy_test.ts +6 -11
  109. package/src/e2e_epochs/epochs_test.ts +217 -0
  110. package/src/e2e_fees/fees_test.ts +84 -38
  111. package/src/e2e_nested_contract/nested_contract_test.ts +14 -16
  112. package/src/e2e_p2p/p2p_network.ts +67 -47
  113. package/src/e2e_p2p/shared.ts +16 -10
  114. package/src/e2e_prover/e2e_prover_test.ts +56 -37
  115. package/src/e2e_token_contract/token_contract_test.ts +10 -11
  116. package/src/fixtures/fixtures.ts +2 -2
  117. package/src/fixtures/get_acvm_config.ts +7 -3
  118. package/src/fixtures/get_bb_config.ts +6 -2
  119. package/src/fixtures/l1_to_l2_messaging.ts +6 -13
  120. package/src/fixtures/setup_l1_contracts.ts +8 -7
  121. package/src/fixtures/setup_p2p_test.ts +8 -6
  122. package/src/fixtures/snapshot_manager.ts +72 -79
  123. package/src/fixtures/token_utils.ts +2 -2
  124. package/src/fixtures/utils.ts +135 -97
  125. package/src/guides/up_quick_start.sh +10 -5
  126. package/src/quality_of_service/alert_checker.ts +6 -2
  127. package/src/sample-dapp/index.mjs +1 -1
  128. package/src/shared/cross_chain_test_harness.ts +17 -35
  129. package/src/shared/gas_portal_test_harness.ts +21 -11
  130. package/src/shared/index.ts +0 -1
  131. package/src/shared/submit-transactions.ts +16 -20
  132. package/src/shared/uniswap_l1_l2.ts +35 -26
  133. package/src/simulators/lending_simulator.ts +5 -6
  134. package/src/simulators/token_simulator.ts +1 -1
  135. package/src/spartan/setup_test_wallets.ts +111 -37
  136. package/src/spartan/utils.ts +88 -3
  137. package/dest/shared/browser.js +0 -163
  138. package/src/shared/browser.ts +0 -272
@@ -0,0 +1,124 @@
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';
3
+ import { TokenContract } from '@aztec/noir-contracts.js/Token';
4
+ import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
5
+ import { type Hex } from 'viem';
6
+ /**
7
+ * Deploy L1 token and portal, initialize portal, deploy a non native l2 token contract, its L2 bridge contract and attach is to the portal.
8
+ * @param wallet - the wallet instance
9
+ * @param walletClient - A viem WalletClient.
10
+ * @param publicClient - A viem PublicClient.
11
+ * @param rollupRegistryAddress - address of rollup registry to pass to initialize the token portal
12
+ * @param owner - owner of the L2 contract
13
+ * @param underlyingERC20Address - address of the underlying ERC20 contract to use (if none supplied, it deploys one)
14
+ * @returns l2 contract instance, bridge contract instance, token portal instance, token portal address and the underlying ERC20 instance
15
+ */
16
+ export declare function deployAndInitializeTokenAndBridgeContracts(wallet: Wallet, walletClient: ViemWalletClient, publicClient: ViemPublicClient, rollupRegistryAddress: EthAddress, owner: AztecAddress, underlyingERC20Address: EthAddress): Promise<{
17
+ /**
18
+ * The L2 token contract instance.
19
+ */
20
+ token: TokenContract;
21
+ /**
22
+ * The L2 bridge contract instance.
23
+ */
24
+ bridge: TokenBridgeContract;
25
+ /**
26
+ * The token portal contract address.
27
+ */
28
+ tokenPortalAddress: EthAddress;
29
+ /**
30
+ * The token portal contract instance
31
+ */
32
+ tokenPortal: any;
33
+ /**
34
+ * The underlying ERC20 contract instance.
35
+ */
36
+ underlyingERC20: any;
37
+ }>;
38
+ /**
39
+ * A Class for testing cross chain interactions, contains common interactions
40
+ * shared between cross chain tests.
41
+ */
42
+ export declare class CrossChainTestHarness {
43
+ /** Aztec node instance. */
44
+ aztecNode: AztecNode;
45
+ /** Private eXecution Environment (PXE). */
46
+ pxeService: PXE;
47
+ /** Logger. */
48
+ logger: Logger;
49
+ /** L2 Token contract. */
50
+ l2Token: TokenContract;
51
+ /** L2 Token bridge contract. */
52
+ l2Bridge: TokenBridgeContract;
53
+ /** Eth account to interact with. */
54
+ ethAccount: EthAddress;
55
+ /** Portal address. */
56
+ tokenPortalAddress: EthAddress;
57
+ /** Underlying token for portal tests. */
58
+ underlyingERC20Address: EthAddress;
59
+ /** Viem Public client instance. */
60
+ publicClient: ViemPublicClient;
61
+ /** Viem Wallet Client instance. */
62
+ walletClient: ViemWalletClient;
63
+ /** Deployment addresses for all L1 contracts */
64
+ readonly l1ContractAddresses: L1ContractAddresses;
65
+ /** Wallet of the owner. */
66
+ readonly ownerWallet: AccountWallet;
67
+ static new(aztecNode: AztecNode, pxeService: PXE, publicClient: ViemPublicClient, walletClient: ViemWalletClient, wallet: AccountWallet, logger: Logger, underlyingERC20Address: EthAddress): Promise<CrossChainTestHarness>;
68
+ private readonly l1TokenManager;
69
+ private readonly l1TokenPortalManager;
70
+ readonly ownerAddress: AztecAddress;
71
+ constructor(
72
+ /** Aztec node instance. */
73
+ aztecNode: AztecNode,
74
+ /** Private eXecution Environment (PXE). */
75
+ pxeService: PXE,
76
+ /** Logger. */
77
+ logger: Logger,
78
+ /** L2 Token contract. */
79
+ l2Token: TokenContract,
80
+ /** L2 Token bridge contract. */
81
+ l2Bridge: TokenBridgeContract,
82
+ /** Eth account to interact with. */
83
+ ethAccount: EthAddress,
84
+ /** Portal address. */
85
+ tokenPortalAddress: EthAddress,
86
+ /** Underlying token for portal tests. */
87
+ underlyingERC20Address: EthAddress,
88
+ /** Viem Public client instance. */
89
+ publicClient: ViemPublicClient,
90
+ /** Viem Wallet Client instance. */
91
+ walletClient: ViemWalletClient,
92
+ /** Deployment addresses for all L1 contracts */
93
+ l1ContractAddresses: L1ContractAddresses,
94
+ /** Wallet of the owner. */
95
+ ownerWallet: AccountWallet);
96
+ mintTokensOnL1(amount: bigint): Promise<void>;
97
+ getL1BalanceOf(address: EthAddress): Promise<bigint>;
98
+ sendTokensToPortalPublic(bridgeAmount: bigint, mint?: boolean): Promise<L2AmountClaim>;
99
+ sendTokensToPortalPrivate(bridgeAmount: bigint, mint?: boolean): Promise<L2AmountClaimWithRecipient>;
100
+ mintTokensPublicOnL2(amount: bigint): Promise<void>;
101
+ mintTokensPrivateOnL2(amount: bigint): Promise<void>;
102
+ sendL2PublicTransfer(transferAmount: bigint, receiverAddress: AztecAddress): Promise<void>;
103
+ consumeMessageOnAztecAndMintPrivately(claim: Pick<L2AmountClaimWithRecipient, 'claimAmount' | 'claimSecret' | 'messageLeafIndex' | 'recipient'>): Promise<void>;
104
+ 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>>;
107
+ getL2PrivateBalanceOf(owner: AztecAddress): Promise<any>;
108
+ expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint): Promise<void>;
109
+ getL2PublicBalanceOf(owner: AztecAddress): Promise<any>;
110
+ expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint): Promise<void>;
111
+ getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1?: EthAddress): Fr;
112
+ withdrawFundsFromBridgeOnL1(amount: bigint, blockNumber: number | bigint, messageIndex: bigint, siblingPath: SiblingPath<number>): Promise<void>;
113
+ transferToPrivateOnL2(shieldAmount: bigint): Promise<void>;
114
+ transferToPublicOnL2(amount: bigint, nonce?: Fr): Promise<void>;
115
+ /**
116
+ * Makes message available for consumption.
117
+ * @dev Does that by performing 2 unrelated transactions on L2 to progress the rollup by 2 blocks and then waits for
118
+ * message to be processed by archiver. We need to progress by 2 because there is a 1 block lag between when
119
+ * the message is sent to Inbox and when the subtree containing the message is included in the block and then when
120
+ * it's included it becomes available for consumption in the next block because the l1 to l2 message tree.
121
+ */
122
+ makeMessageConsumable(msgHash: Fr | Hex): Promise<void>;
123
+ }
124
+ //# sourceMappingURL=cross_chain_test_harness.d.ts.map
@@ -0,0 +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,gBAAgB,EAC9B,qBAAqB,EAAE,UAAU,EACjC,KAAK,EAAE,YAAY,EACnB,sBAAsB,EAAE,UAAU,GACjC,OAAO,CAAC;IACT;;OAEG;IACH,KAAK,EAAE,aAAa,CAAC;IACrB;;OAEG;I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C,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM;IAK1E,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,GAAE,UAA4B,GAAG,EAAE;IAS1F,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;IAK1C,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,KAAU;IAK1D;;;;;;OAMG;IACG,qBAAqB,CAAC,OAAO,EAAE,EAAE,GAAG,GAAG;CAQ9C"}
@@ -1,6 +1,6 @@
1
1
  // docs:start:cross_chain_test_harness
2
2
  import { EthAddress, Fr, L1TokenPortalManager, deployL1Contract, retryUntil } from '@aztec/aztec.js';
3
- import { TestERC20Abi, TestERC20Bytecode, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
3
+ import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
4
4
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
5
5
  import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
6
6
  import { getContract } from 'viem';
@@ -16,22 +16,6 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
16
16
  * @param underlyingERC20Address - address of the underlying ERC20 contract to use (if none supplied, it deploys one)
17
17
  * @returns l2 contract instance, bridge contract instance, token portal instance, token portal address and the underlying ERC20 instance
18
18
  */ export async function deployAndInitializeTokenAndBridgeContracts(wallet, walletClient, publicClient, rollupRegistryAddress, owner, underlyingERC20Address) {
19
- if (!underlyingERC20Address) {
20
- underlyingERC20Address = await deployL1Contract(walletClient, publicClient, TestERC20Abi, TestERC20Bytecode, [
21
- 'Underlying',
22
- 'UND',
23
- walletClient.account.address
24
- ]).then(({ address })=>address);
25
- }
26
- const underlyingERC20 = getContract({
27
- address: underlyingERC20Address.toString(),
28
- abi: TestERC20Abi,
29
- client: walletClient
30
- });
31
- // allow anyone to mint
32
- await underlyingERC20.write.setFreeForAll([
33
- true
34
- ], {});
35
19
  // deploy the token portal
36
20
  const { address: tokenPortalAddress } = await deployL1Contract(walletClient, publicClient, TokenPortalAbi, TokenPortalBytecode);
37
21
  const tokenPortal = getContract({
@@ -60,6 +44,11 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
60
44
  underlyingERC20Address.toString(),
61
45
  bridge.address.toString()
62
46
  ], {});
47
+ const underlyingERC20 = getContract({
48
+ address: underlyingERC20Address.toString(),
49
+ abi: TestERC20Abi,
50
+ client: walletClient
51
+ });
63
52
  return {
64
53
  token,
65
54
  bridge,
@@ -0,0 +1,80 @@
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';
3
+ import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
4
+ export interface IGasBridgingTestHarness {
5
+ getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
6
+ prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress): Promise<L2AmountClaim>;
7
+ bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress): Promise<void>;
8
+ feeJuice: FeeJuiceContract;
9
+ l1FeeJuiceAddress: EthAddress;
10
+ }
11
+ export interface FeeJuicePortalTestingHarnessFactoryConfig {
12
+ aztecNode: AztecNode;
13
+ pxeService: PXE;
14
+ publicClient: ViemPublicClient;
15
+ walletClient: ViemWalletClient;
16
+ wallet: Wallet;
17
+ logger: Logger;
18
+ mockL1?: boolean;
19
+ }
20
+ export declare class FeeJuicePortalTestingHarnessFactory {
21
+ private config;
22
+ private constructor();
23
+ private createReal;
24
+ static create(config: FeeJuicePortalTestingHarnessFactoryConfig): Promise<GasBridgingTestHarness>;
25
+ }
26
+ /**
27
+ * A Class for testing cross chain interactions, contains common interactions
28
+ * shared between cross chain tests.
29
+ */
30
+ export declare class GasBridgingTestHarness implements IGasBridgingTestHarness {
31
+ /** Aztec node */
32
+ aztecNode: AztecNode;
33
+ /** Private eXecution Environment (PXE). */
34
+ pxeService: PXE;
35
+ /** Logger. */
36
+ logger: Logger;
37
+ /** L2 Token/Bridge contract. */
38
+ feeJuice: FeeJuiceContract;
39
+ /** Eth account to interact with. */
40
+ ethAccount: EthAddress;
41
+ /** Portal address. */
42
+ feeJuicePortalAddress: EthAddress;
43
+ /** Underlying token for portal tests. */
44
+ l1FeeJuiceAddress: EthAddress;
45
+ /** Viem Public client instance. */
46
+ publicClient: ViemPublicClient;
47
+ /** Viem Wallet Client instance. */
48
+ walletClient: ViemWalletClient;
49
+ readonly l1TokenManager: L1TokenManager;
50
+ readonly feeJuicePortalManager: L1FeeJuicePortalManager;
51
+ constructor(
52
+ /** Aztec node */
53
+ aztecNode: AztecNode,
54
+ /** Private eXecution Environment (PXE). */
55
+ pxeService: PXE,
56
+ /** Logger. */
57
+ logger: Logger,
58
+ /** L2 Token/Bridge contract. */
59
+ feeJuice: FeeJuiceContract,
60
+ /** Eth account to interact with. */
61
+ ethAccount: EthAddress,
62
+ /** Portal address. */
63
+ feeJuicePortalAddress: EthAddress,
64
+ /** Underlying token for portal tests. */
65
+ 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
+ getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
72
+ sendTokensToPortalPublic(bridgeAmount: bigint, l2Address: AztecAddress, mint?: boolean): Promise<L2AmountClaim>;
73
+ consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claim: L2AmountClaim): Promise<void>;
74
+ getL2PublicBalanceOf(owner: AztecAddress): Promise<any>;
75
+ expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint): Promise<void>;
76
+ prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress): Promise<L2AmountClaim>;
77
+ bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress): Promise<void>;
78
+ private advanceL2Block;
79
+ }
80
+ //# sourceMappingURL=gas_portal_test_harness.d.ts.map
@@ -0,0 +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,MAAM,EAAE,MAAM,CAAC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EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,UAAQ;IAI9E,sCAAsC,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa;IAMhF,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;IAa3D,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY;YASlD,cAAc;CAK7B"}
@@ -1,4 +1,4 @@
1
- import { EthAddress, L1FeeJuicePortalManager } from '@aztec/aztec.js';
1
+ import { EthAddress, Fr, L1FeeJuicePortalManager, retryUntil } from '@aztec/aztec.js';
2
2
  import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
3
3
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
4
4
  export class FeeJuicePortalTestingHarnessFactory {
@@ -76,9 +76,11 @@ export class FeeJuicePortalTestingHarnessFactory {
76
76
  }
77
77
  async prepareTokensOnL1(bridgeAmount, owner) {
78
78
  const claim = await this.sendTokensToPortalPublic(bridgeAmount, owner, true);
79
- // Perform an unrelated transactions on L2 to progress the rollup by 2 blocks.
80
- await this.feeJuice.methods.check_balance(0).send().wait();
81
- await this.feeJuice.methods.check_balance(0).send().wait();
79
+ const isSynced = async ()=>await this.aztecNode.isL1ToL2MessageSynced(Fr.fromHexString(claim.messageHash));
80
+ await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 1);
81
+ // Progress by 2 L2 blocks so that the l1ToL2Message added above will be available to use on L2.
82
+ await this.advanceL2Block();
83
+ await this.advanceL2Block();
82
84
  return claim;
83
85
  }
84
86
  async bridgeFromL1ToL2(bridgeAmount, owner) {
@@ -88,4 +90,9 @@ export class FeeJuicePortalTestingHarnessFactory {
88
90
  await this.consumeMessageOnAztecAndClaimPrivately(owner, claim);
89
91
  await this.expectPublicBalanceOnL2(owner, bridgeAmount);
90
92
  }
93
+ async advanceL2Block() {
94
+ const initialBlockNumber = await this.aztecNode.getBlockNumber();
95
+ await this.aztecNode.flushTxs();
96
+ await retryUntil(async ()=>await this.aztecNode.getBlockNumber() >= initialBlockNumber + 1);
97
+ }
91
98
  } // docs:end:cross_chain_test_harness
@@ -0,0 +1,2 @@
1
+ export { uniswapL1L2TestSuite, type UniswapSetupContext } from './uniswap_l1_l2.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,2 +1 @@
1
- export { browserTestSuite } from './browser.js';
2
1
  export { uniswapL1L2TestSuite } from './uniswap_l1_l2.js';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jest_setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest_setup.d.ts","sourceRoot":"","sources":["../../src/shared/jest_setup.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { type Logger, type SentTx, type Wallet } from '@aztec/aztec.js';
2
+ import type { PXEService } from '@aztec/pxe';
3
+ export declare const submitTxsTo: (pxe: PXEService, numTxs: number, wallet: Wallet, logger: Logger) => Promise<SentTx[]>;
4
+ //# sourceMappingURL=submit-transactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submit-transactions.d.ts","sourceRoot":"","sources":["../../src/shared/submit-transactions.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,MAAM,EAAE,KAAK,MAAM,EAAY,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEtG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,eAAO,MAAM,WAAW,QACjB,UAAU,UACP,MAAM,UACN,MAAM,UACN,MAAM,KACb,QAAQ,MAAM,EAAE,CAqBlB,CAAC"}
@@ -1,22 +1,14 @@
1
1
  import { getSchnorrAccount } from '@aztec/accounts/schnorr';
2
- import { TxStatus } from '@aztec/aztec.js';
3
- import { Fr, GrumpkinScalar } from '@aztec/pxe';
2
+ import { Fr, GrumpkinScalar, TxStatus } from '@aztec/aztec.js';
3
+ import { times } from '@aztec/foundation/collection';
4
4
  // submits a set of transactions to the provided Private eXecution Environment (PXE)
5
- export const submitTxsTo = async (pxe, numTxs, logger)=>{
6
- const provenTxs = [];
7
- for(let i = 0; i < numTxs; i++){
5
+ export const submitTxsTo = async (pxe, numTxs, wallet, logger)=>{
6
+ const txs = [];
7
+ await Promise.all(times(numTxs, async ()=>{
8
8
  const accountManager = await getSchnorrAccount(pxe, Fr.random(), GrumpkinScalar.random(), Fr.random());
9
- const deployMethod = await accountManager.getDeployMethod();
10
- const tx = await deployMethod.prove({
11
- contractAddressSalt: new Fr(accountManager.salt),
12
- skipClassRegistration: true,
13
- skipPublicDeployment: true,
14
- universalDeploy: true
9
+ const tx = accountManager.deploy({
10
+ deployWallet: wallet
15
11
  });
16
- provenTxs.push(tx);
17
- }
18
- const sentTxs = await Promise.all(provenTxs.map(async (provenTx)=>{
19
- const tx = provenTx.send();
20
12
  const txHash = await tx.getTxHash();
21
13
  logger.info(`Tx sent with hash ${txHash}`);
22
14
  const receipt = await tx.getReceipt();
@@ -25,7 +17,7 @@ export const submitTxsTo = async (pxe, numTxs, logger)=>{
25
17
  error: ''
26
18
  }));
27
19
  logger.info(`Receipt received for ${txHash}`);
28
- return tx;
20
+ txs.push(tx);
29
21
  }));
30
- return sentTxs;
22
+ return txs;
31
23
  };
@@ -0,0 +1,25 @@
1
+ import { type AccountWallet, type AztecNode, type CheatCodes, type Logger, type PXE } from '@aztec/aztec.js';
2
+ import { type DeployL1ContractsReturnType, type ViemPublicClient, type ViemWalletClient } from '@aztec/ethereum';
3
+ /** Objects to be returned by the uniswap setup function */
4
+ export type UniswapSetupContext = {
5
+ /** Aztec Node instance */
6
+ aztecNode: AztecNode;
7
+ /** The Private eXecution Environment (PXE). */
8
+ pxe: PXE;
9
+ /** Logger instance named as the current test. */
10
+ logger: Logger;
11
+ /** Viem Public client instance. */
12
+ publicClient: ViemPublicClient;
13
+ /** Viem Wallet Client instance. */
14
+ walletClient: ViemWalletClient;
15
+ /** The owner wallet. */
16
+ ownerWallet: AccountWallet;
17
+ /** The sponsor wallet. */
18
+ sponsorWallet: AccountWallet;
19
+ /** */
20
+ deployL1ContractsValues: DeployL1ContractsReturnType;
21
+ /** Cheat codes instance. */
22
+ cheatCodes: CheatCodes;
23
+ };
24
+ export declare const uniswapL1L2TestSuite: (setup: () => Promise<UniswapSetupContext>, cleanup: () => Promise<void>, expectedForkBlockNumber?: number) => void;
25
+ //# sourceMappingURL=uniswap_l1_l2.d.ts.map
@@ -0,0 +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,EACd,KAAK,UAAU,EAGf,KAAK,MAAM,EACX,KAAK,GAAG,EAGT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAGtB,MAAM,iBAAiB,CAAC;AAqBzB,2DAA2D;AAC3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,0BAA0B;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,+CAA+C;IAC/C,GAAG,EAAE,GAAG,CAAC;IACT,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,YAAY,EAAE,gBAAgB,CAAC;IAC/B,mCAAmC;IACnC,YAAY,EAAE,gBAAgB,CAAC;IAC/B,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,UACxB,MAAM,QAAQ,mBAAmB,CAAC,WAChC,MAAM,QAAQ,IAAI,CAAC,2CA89B7B,CAAC"}
@@ -43,8 +43,9 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
43
43
  const wethAmountToBridge = parseEther('1');
44
44
  const uniswapFeeTier = 3000n;
45
45
  const minimumOutputAmount = 0n;
46
+ let cheatCodes;
46
47
  beforeAll(async ()=>{
47
- ({ aztecNode, pxe, logger, publicClient, walletClient, ownerWallet, sponsorWallet, deployL1ContractsValues } = await setup());
48
+ ({ aztecNode, pxe, logger, publicClient, walletClient, ownerWallet, sponsorWallet, deployL1ContractsValues, cheatCodes } = await setup());
48
49
  if (Number(await publicClient.getBlockNumber()) < expectedForkBlockNumber) {
49
50
  throw new Error('This test must be run on a fork of mainnet with the expected fork block');
50
51
  }
@@ -157,9 +158,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
157
158
  // ensure that uniswap contract didn't eat the funds.
158
159
  await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
159
160
  // Since the outbox is only consumable when the block is proven, we need to set the block to be proven
160
- await rollup.write.setAssumeProvenThroughBlockNumber([
161
- await rollup.read.getPendingBlockNumber()
162
- ]);
161
+ await cheatCodes.rollup.markAsProven(await rollup.read.getPendingBlockNumber());
163
162
  // 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
164
163
  logger.info('Execute withdraw and swap on the uniswapPortal!');
165
164
  const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(daiCrossChainHarness.tokenPortalAddress);
@@ -558,9 +557,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
558
557
  // ensure that user's funds were burnt
559
558
  await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
560
559
  // Since the outbox is only consumable when the block is proven, we need to set the block to be proven
561
- await rollup.write.setAssumeProvenThroughBlockNumber([
562
- await rollup.read.getPendingBlockNumber()
563
- ]);
560
+ await cheatCodes.rollup.markAsProven(await rollup.read.getPendingBlockNumber());
564
561
  // On L1 call swap_public!
565
562
  logger.info('call swap_public on L1');
566
563
  const swapArgs = [
@@ -640,9 +637,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
640
637
  // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
641
638
  await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
642
639
  // Since the outbox is only consumable when the block is proven, we need to set the block to be proven
643
- await rollup.write.setAssumeProvenThroughBlockNumber([
644
- await rollup.read.getPendingBlockNumber()
645
- ]);
640
+ await cheatCodes.rollup.markAsProven(await rollup.read.getPendingBlockNumber());
646
641
  // Call swap_private on L1
647
642
  logger.info('Execute withdraw and swap on the uniswapPortal!');
648
643
  const swapArgs = [
@@ -0,0 +1,3 @@
1
+ export * from './lending_simulator.js';
2
+ export * from './token_simulator.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/simulators/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { AztecAddress, type CheatCodes, Fr } from '@aztec/aztec.js';
2
+ import type { TestDateProvider } from '@aztec/foundation/timer';
3
+ import type { RollupAbi } from '@aztec/l1-artifacts';
4
+ import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
5
+ import type { Account, GetContractReturnType, HttpTransport, WalletClient } from 'viem';
6
+ import type * as chains from 'viem/chains';
7
+ import type { TokenSimulator } from './token_simulator.js';
8
+ /**
9
+ * Contains utilities to compute the "key" for private holdings in the public state.
10
+ */
11
+ export declare class LendingAccount {
12
+ /** The address that owns this account */
13
+ readonly address: AztecAddress;
14
+ /** The secret used for private deposits */
15
+ readonly secret: Fr;
16
+ constructor(address: AztecAddress, secret: Fr);
17
+ /**
18
+ * Computes the key for the private holdings of this account.
19
+ * @returns Key in public space
20
+ */
21
+ key(): Promise<Fr>;
22
+ }
23
+ /**
24
+ * Helper class that emulates the logic of the lending contract. Used to have a "twin" to check values against.
25
+ */
26
+ export declare class LendingSimulator {
27
+ private cc;
28
+ private account;
29
+ private rate;
30
+ private ethereumSlotDuration;
31
+ /** the rollup contract */
32
+ rollup: GetContractReturnType<typeof RollupAbi, WalletClient<HttpTransport, chains.Chain, Account>>;
33
+ /** the lending contract */
34
+ lendingContract: LendingContract;
35
+ /** the collateral asset used in the lending contract */
36
+ collateralAsset: TokenSimulator;
37
+ /** the stable-coin borrowed in the lending contract */
38
+ stableCoin: TokenSimulator;
39
+ /** interest rate accumulator */
40
+ accumulator: bigint;
41
+ /** the timestamp of the simulator*/
42
+ time: number;
43
+ private collateral;
44
+ private staticDebt;
45
+ private borrowed;
46
+ private mintedOutside;
47
+ constructor(cc: CheatCodes, account: LendingAccount, rate: bigint, ethereumSlotDuration: number,
48
+ /** the rollup contract */
49
+ rollup: GetContractReturnType<typeof RollupAbi, WalletClient<HttpTransport, chains.Chain, Account>>,
50
+ /** the lending contract */
51
+ lendingContract: LendingContract,
52
+ /** the collateral asset used in the lending contract */
53
+ collateralAsset: TokenSimulator,
54
+ /** the stable-coin borrowed in the lending contract */
55
+ stableCoin: TokenSimulator);
56
+ prepare(): Promise<void>;
57
+ progressSlots(diff: number, dateProvider?: TestDateProvider): Promise<void>;
58
+ depositPrivate(from: AztecAddress, onBehalfOf: Fr, amount: bigint): void;
59
+ depositPublic(from: AztecAddress, onBehalfOf: Fr, amount: bigint): void;
60
+ private deposit;
61
+ withdraw(owner: Fr, recipient: AztecAddress, amount: bigint): void;
62
+ borrow(owner: Fr, recipient: AztecAddress, amount: bigint): void;
63
+ repayPrivate(from: AztecAddress, onBehalfOf: Fr, amount: bigint): void;
64
+ repayPublic(from: AztecAddress, onBehalfOf: Fr, amount: bigint): void;
65
+ private repay;
66
+ mintStableCoinOutsideLoan(recipient: AztecAddress, amount: bigint, priv?: boolean): void;
67
+ check(): Promise<void>;
68
+ }
69
+ //# sourceMappingURL=lending_simulator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lending_simulator.d.ts","sourceRoot":"","sources":["../../src/simulators/lending_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,KAAK,EAAE,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACxF,OAAO,KAAK,KAAK,MAAM,MAAM,aAAa,CAAC;AAE3C,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,EAAE,qBAAqB,CAAC,OAA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,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"}
@@ -100,9 +100,7 @@ const computeMultiplier = (rate, dt)=>{
100
100
  if (dateProvider) {
101
101
  dateProvider.setTime(this.time * 1000);
102
102
  }
103
- await this.rollup.write.setAssumeProvenThroughBlockNumber([
104
- await this.rollup.read.getPendingBlockNumber() + 1n
105
- ]);
103
+ await this.cc.rollup.markAsProven(await this.rollup.read.getPendingBlockNumber());
106
104
  this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(timeDiff)), BASE);
107
105
  }
108
106
  depositPrivate(from, onBehalfOf, amount) {
@@ -0,0 +1,29 @@
1
+ import { type AztecAddress, type Logger, type Wallet } from '@aztec/aztec.js';
2
+ import type { TokenContract } from '@aztec/noir-contracts.js/Token';
3
+ export declare class TokenSimulator {
4
+ protected token: TokenContract;
5
+ protected defaultWallet: Wallet;
6
+ protected logger: Logger;
7
+ protected accounts: AztecAddress[];
8
+ private balancesPrivate;
9
+ private balancePublic;
10
+ totalSupply: bigint;
11
+ private lookupProvider;
12
+ constructor(token: TokenContract, defaultWallet: Wallet, logger: Logger, accounts: AztecAddress[]);
13
+ addAccount(account: AztecAddress): void;
14
+ setLookupProvider(account: AztecAddress, wallet: Wallet): void;
15
+ mintPrivate(to: AztecAddress, amount: bigint): void;
16
+ mintPublic(to: AztecAddress, amount: bigint): void;
17
+ transferPublic(from: AztecAddress, to: AztecAddress, amount: bigint): void;
18
+ transferPrivate(from: AztecAddress, to: AztecAddress, amount: bigint): void;
19
+ transferToPrivate(from: AztecAddress, to: AztecAddress, amount: bigint): void;
20
+ transferToPublic(from: AztecAddress, to: AztecAddress, amount: bigint): void;
21
+ burnPrivate(from: AztecAddress, amount: bigint): void;
22
+ burnPublic(from: AztecAddress, amount: bigint): void;
23
+ balanceOfPublic(address: AztecAddress): bigint;
24
+ balanceOfPrivate(address: AztecAddress): bigint;
25
+ checkPublic(): Promise<void>;
26
+ checkPrivate(): Promise<void>;
27
+ check(): Promise<void>;
28
+ }
29
+ //# sourceMappingURL=token_simulator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token_simulator.d.ts","sourceRoot":"","sources":["../../src/simulators/token_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAa,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAIpE,qBAAa,cAAc;IAQvB,SAAS,CAAC,KAAK,EAAE,aAAa;IAC9B,SAAS,CAAC,aAAa,EAAE,MAAM;IAC/B,SAAS,CAAC,MAAM,EAAE,MAAM;IACxB,SAAS,CAAC,QAAQ,EAAE,YAAY,EAAE;IAVpC,OAAO,CAAC,eAAe,CAAkC;IACzD,OAAO,CAAC,aAAa,CAAkC;IAChD,WAAW,EAAE,MAAM,CAAM;IAEhC,OAAO,CAAC,cAAc,CAAkC;gBAG5C,KAAK,EAAE,aAAa,EACpB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,YAAY,EAAE;IAG7B,UAAU,CAAC,OAAO,EAAE,YAAY;IAIhC,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IAIvD,WAAW,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IAK5C,UAAU,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IAM3C,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IASnE,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,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;IAkBX,YAAY;IAmCL,KAAK;CAInB"}
@@ -0,0 +1,20 @@
1
+ import { type AccountWalletWithSecretKey, type AztecAddress, type PXE } from '@aztec/aztec.js';
2
+ import type { Logger } from '@aztec/foundation/log';
3
+ import { TokenContract } from '@aztec/noir-contracts.js/Token';
4
+ export interface TestWallets {
5
+ pxe: PXE;
6
+ wallets: AccountWalletWithSecretKey[];
7
+ tokenAdminWallet: TokenContract;
8
+ tokenName: string;
9
+ recipientWallet: AccountWalletWithSecretKey;
10
+ tokenAddress: AztecAddress;
11
+ }
12
+ export declare function setupTestWalletsWithTokens(pxeUrl: string, mintAmount: bigint, logger: Logger): Promise<TestWallets>;
13
+ export declare function deployTestWalletWithTokens(pxeUrl: string, nodeUrl: string, l1RpcUrl: string, mnemonicOrPrivateKey: string, mintAmount: bigint, logger: Logger, numberOfFundedWallets?: number, initialFeeJuice?: bigint): Promise<TestWallets>;
14
+ export declare function performTransfers({ testWallets, rounds, transferAmount, logger, }: {
15
+ testWallets: TestWallets;
16
+ rounds: number;
17
+ transferAmount: bigint;
18
+ logger: Logger;
19
+ }): Promise<void>;
20
+ //# sourceMappingURL=setup_test_wallets.d.ts.map
@@ -0,0 +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;AAE/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,QAAQ,EAAE,MAAM,EAChB,oBAAoB,EAAE,MAAM,EAC5B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,qBAAqB,SAAI,EACzB,eAAe,SAAa,GAC3B,OAAO,CAAC,WAAW,CAAC,CAsCtB;AA2DD,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,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB,iBAkBA"}