@aztec/end-to-end 3.0.0-canary.a9708bd → 3.0.0-devnet.2
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.
- package/dest/bench/client_flows/benchmark.d.ts +3 -2
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +16 -12
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +54 -58
- package/dest/bench/utils.d.ts +2 -11
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +10 -34
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +7 -7
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +42 -42
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -8
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +31 -33
- package/dest/e2e_deploy_contract/deploy_test.d.ts +10 -4
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +9 -18
- package/dest/e2e_epochs/epochs_test.d.ts +9 -3
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +19 -13
- package/dest/e2e_fees/bridging_race.notest.js +12 -9
- package/dest/e2e_fees/fees_test.d.ts +5 -5
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +26 -33
- package/dest/e2e_l1_publisher/write_json.d.ts +3 -1
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +5 -5
- package/dest/e2e_multi_validator/utils.d.ts +1 -1
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
- package/dest/e2e_multi_validator/utils.js +3 -9
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -3
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +7 -9
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +135 -0
- package/dest/e2e_p2p/p2p_network.d.ts +22 -8
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +36 -15
- package/dest/e2e_p2p/shared.d.ts +12 -13
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +54 -54
- package/dest/e2e_token_contract/token_contract_test.d.ts +5 -4
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +14 -17
- package/dest/fixtures/e2e_prover_test.d.ts +8 -6
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +42 -51
- package/dest/fixtures/get_acvm_config.d.ts +1 -1
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +2 -2
- package/dest/fixtures/setup_l1_contracts.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +2 -2
- package/dest/fixtures/setup_p2p_test.d.ts +10 -9
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +38 -20
- package/dest/fixtures/snapshot_manager.d.ts +10 -7
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +60 -47
- package/dest/fixtures/token_utils.d.ts +6 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +11 -15
- package/dest/fixtures/utils.d.ts +26 -28
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +83 -109
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/quality_of_service/alert_checker.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +16 -10
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +13 -15
- package/dest/shared/gas_portal_test_harness.d.ts +9 -6
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +10 -7
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +5 -3
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +8 -7
- package/dest/shared/uniswap_l1_l2.d.ts +9 -6
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +29 -45
- package/dest/simulators/lending_simulator.d.ts +2 -1
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +3 -2
- package/dest/simulators/token_simulator.d.ts +3 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -2
- package/dest/spartan/setup_test_wallets.d.ts +19 -13
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +108 -85
- package/dest/spartan/utils.d.ts +68 -3
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +312 -49
- package/package.json +39 -38
- package/src/bench/client_flows/benchmark.ts +6 -6
- package/src/bench/client_flows/client_flows_benchmark.ts +62 -82
- package/src/bench/client_flows/data_extractor.ts +1 -1
- package/src/bench/utils.ts +9 -37
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +46 -63
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +33 -47
- package/src/e2e_deploy_contract/deploy_test.ts +17 -35
- package/src/e2e_epochs/epochs_test.ts +22 -19
- package/src/e2e_fees/bridging_race.notest.ts +14 -9
- package/src/e2e_fees/fees_test.ts +29 -40
- package/src/e2e_l1_publisher/write_json.ts +8 -6
- package/src/e2e_multi_validator/utils.ts +4 -10
- package/src/e2e_nested_contract/nested_contract_test.ts +11 -10
- package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
- package/src/e2e_p2p/p2p_network.ts +110 -71
- package/src/e2e_p2p/shared.ts +57 -56
- package/src/e2e_token_contract/token_contract_test.ts +17 -17
- package/src/fixtures/e2e_prover_test.ts +52 -88
- package/src/fixtures/get_acvm_config.ts +1 -1
- package/src/fixtures/get_bb_config.ts +3 -2
- package/src/fixtures/setup_l1_contracts.ts +3 -3
- package/src/fixtures/setup_p2p_test.ts +60 -27
- package/src/fixtures/snapshot_manager.ts +80 -72
- package/src/fixtures/token_utils.ts +13 -21
- package/src/fixtures/utils.ts +95 -145
- package/src/fixtures/web3signer.ts +63 -0
- package/src/guides/up_quick_start.sh +2 -10
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +18 -29
- package/src/shared/gas_portal_test_harness.ts +12 -19
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +61 -67
- package/src/simulators/lending_simulator.ts +3 -2
- package/src/simulators/token_simulator.ts +5 -2
- package/src/spartan/DEVELOP.md +8 -3
- package/src/spartan/setup_test_wallets.ts +133 -126
- package/src/spartan/utils.ts +373 -48
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { L1TokenPortalManager } from '@aztec/aztec.js/ethereum';
|
|
3
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
4
|
import { deployL1Contract } from '@aztec/ethereum';
|
|
5
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
4
6
|
import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
|
|
5
7
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
6
8
|
import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
7
9
|
import { getContract } from 'viem';
|
|
8
10
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
9
|
-
// docs:start:deployAndInitializeTokenAndBridgeContracts
|
|
10
11
|
/**
|
|
11
12
|
* Deploy L1 token and portal, initialize portal, deploy a non native l2 token contract, its L2 bridge contract and attach is to the portal.
|
|
12
13
|
* @param wallet - the wallet instance
|
|
@@ -75,7 +76,6 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
75
76
|
* shared between cross chain tests.
|
|
76
77
|
*/ export class CrossChainTestHarness {
|
|
77
78
|
aztecNode;
|
|
78
|
-
pxeService;
|
|
79
79
|
logger;
|
|
80
80
|
l2Token;
|
|
81
81
|
l2Bridge;
|
|
@@ -84,22 +84,21 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
84
84
|
underlyingERC20Address;
|
|
85
85
|
l1Client;
|
|
86
86
|
l1ContractAddresses;
|
|
87
|
-
|
|
87
|
+
wallet;
|
|
88
88
|
ownerAddress;
|
|
89
|
-
static async new(aztecNode,
|
|
89
|
+
static async new(aztecNode, l1Client, wallet, ownerAddress, logger, underlyingERC20Address) {
|
|
90
90
|
const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
91
|
-
const l1ContractAddresses = (await
|
|
91
|
+
const l1ContractAddresses = (await aztecNode.getNodeInfo()).l1ContractAddresses;
|
|
92
92
|
// Deploy and initialize all required contracts
|
|
93
93
|
logger.info('Deploying and initializing token, portal and its bridge...');
|
|
94
|
-
const { token, bridge, tokenPortalAddress, underlyingERC20 } = await deployAndInitializeTokenAndBridgeContracts(wallet, l1Client, l1ContractAddresses.registryAddress,
|
|
94
|
+
const { token, bridge, tokenPortalAddress, underlyingERC20 } = await deployAndInitializeTokenAndBridgeContracts(wallet, l1Client, l1ContractAddresses.registryAddress, ownerAddress, underlyingERC20Address);
|
|
95
95
|
logger.info('Deployed and initialized token, portal and its bridge.');
|
|
96
|
-
return new CrossChainTestHarness(aztecNode,
|
|
96
|
+
return new CrossChainTestHarness(aztecNode, logger, token, bridge, ethAccount, tokenPortalAddress, underlyingERC20.address, l1Client, l1ContractAddresses, wallet, ownerAddress);
|
|
97
97
|
}
|
|
98
98
|
l1TokenManager;
|
|
99
99
|
l1TokenPortalManager;
|
|
100
|
-
constructor(/** Aztec node instance. */ aztecNode, /**
|
|
100
|
+
constructor(/** Aztec node instance. */ aztecNode, /** 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 to simulate and send txs from. */ wallet, /** Owner of the l2 token and bridge */ ownerAddress){
|
|
101
101
|
this.aztecNode = aztecNode;
|
|
102
|
-
this.pxeService = pxeService;
|
|
103
102
|
this.logger = logger;
|
|
104
103
|
this.l2Token = l2Token;
|
|
105
104
|
this.l2Bridge = l2Bridge;
|
|
@@ -108,11 +107,10 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
108
107
|
this.underlyingERC20Address = underlyingERC20Address;
|
|
109
108
|
this.l1Client = l1Client;
|
|
110
109
|
this.l1ContractAddresses = l1ContractAddresses;
|
|
111
|
-
this.
|
|
110
|
+
this.wallet = wallet;
|
|
112
111
|
this.ownerAddress = ownerAddress;
|
|
113
112
|
this.l1TokenPortalManager = new L1TokenPortalManager(this.tokenPortalAddress, this.underlyingERC20Address, this.l1ContractAddresses.feeAssetHandlerAddress, this.l1ContractAddresses.outboxAddress, this.l1Client, this.logger);
|
|
114
113
|
this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
|
|
115
|
-
this.ownerAddress = this.ownerWallet.getAddress();
|
|
116
114
|
}
|
|
117
115
|
async mintTokensOnL1(amount) {
|
|
118
116
|
const contract = getContract({
|
|
@@ -146,7 +144,7 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
146
144
|
}).wait();
|
|
147
145
|
}
|
|
148
146
|
async mintTokensPrivateOnL2(amount) {
|
|
149
|
-
await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.
|
|
147
|
+
await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerAddress, amount);
|
|
150
148
|
}
|
|
151
149
|
async sendL2PublicTransfer(transferAmount, receiverAddress) {
|
|
152
150
|
// send a transfer tx to force through rollup with the message included
|
|
@@ -245,4 +243,4 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
245
243
|
outbox: this.l1ContractAddresses.outboxAddress
|
|
246
244
|
};
|
|
247
245
|
}
|
|
248
|
-
}
|
|
246
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { L1FeeJuicePortalManager, type L1TokenManager, type L2AmountClaim } from '@aztec/aztec.js/ethereum';
|
|
3
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
4
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
5
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
2
6
|
import type { ExtendedViemWalletClient } from '@aztec/ethereum';
|
|
3
7
|
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
4
8
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
@@ -12,7 +16,6 @@ export interface IGasBridgingTestHarness {
|
|
|
12
16
|
export interface FeeJuicePortalTestingHarnessFactoryConfig {
|
|
13
17
|
aztecNode: AztecNode;
|
|
14
18
|
aztecNodeAdmin?: AztecNodeAdmin;
|
|
15
|
-
pxeService: PXE;
|
|
16
19
|
l1Client: ExtendedViemWalletClient;
|
|
17
20
|
wallet: Wallet;
|
|
18
21
|
logger: Logger;
|
|
@@ -33,8 +36,8 @@ export declare class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
33
36
|
aztecNode: AztecNode;
|
|
34
37
|
/** Aztec node admin interface */
|
|
35
38
|
aztecNodeAdmin: AztecNodeAdmin | undefined;
|
|
36
|
-
/**
|
|
37
|
-
|
|
39
|
+
/** Wallet. */
|
|
40
|
+
wallet: Wallet;
|
|
38
41
|
/** Logger. */
|
|
39
42
|
logger: Logger;
|
|
40
43
|
/** L2 Token/Bridge contract. */
|
|
@@ -56,8 +59,8 @@ export declare class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
56
59
|
aztecNode: AztecNode,
|
|
57
60
|
/** Aztec node admin interface */
|
|
58
61
|
aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
59
|
-
/**
|
|
60
|
-
|
|
62
|
+
/** Wallet. */
|
|
63
|
+
wallet: Wallet,
|
|
61
64
|
/** Logger. */
|
|
62
65
|
logger: Logger,
|
|
63
66
|
/** L2 Token/Bridge contract. */
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"gas_portal_test_harness.d.ts","sourceRoot":"","sources":["../../src/shared/gas_portal_test_harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,KAAK,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C,gBAAgB,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY;YAQnD,cAAc;CAe7B"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { EthAddress
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
3
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
2
5
|
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
3
6
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
4
7
|
export class FeeJuicePortalTestingHarnessFactory {
|
|
@@ -7,16 +10,16 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
7
10
|
this.config = config;
|
|
8
11
|
}
|
|
9
12
|
async createReal() {
|
|
10
|
-
const { aztecNode, aztecNodeAdmin,
|
|
13
|
+
const { aztecNode, aztecNodeAdmin, l1Client, wallet, logger } = this.config;
|
|
11
14
|
const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
12
|
-
const l1ContractAddresses = (await
|
|
15
|
+
const l1ContractAddresses = (await aztecNode.getNodeInfo()).l1ContractAddresses;
|
|
13
16
|
const feeJuiceAddress = l1ContractAddresses.feeJuiceAddress;
|
|
14
17
|
const feeJuicePortalAddress = l1ContractAddresses.feeJuicePortalAddress;
|
|
15
18
|
if (feeJuiceAddress.isZero() || feeJuicePortalAddress.isZero()) {
|
|
16
19
|
throw new Error('Fee Juice portal not deployed on L1');
|
|
17
20
|
}
|
|
18
21
|
const gasL2 = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
|
|
19
|
-
return new GasBridgingTestHarness(aztecNode, aztecNodeAdmin,
|
|
22
|
+
return new GasBridgingTestHarness(aztecNode, aztecNodeAdmin, wallet, logger, gasL2, ethAccount, feeJuicePortalAddress, feeJuiceAddress, l1ContractAddresses.feeAssetHandlerAddress, l1Client);
|
|
20
23
|
}
|
|
21
24
|
static create(config) {
|
|
22
25
|
const factory = new FeeJuicePortalTestingHarnessFactory(config);
|
|
@@ -29,7 +32,7 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
29
32
|
*/ export class GasBridgingTestHarness {
|
|
30
33
|
aztecNode;
|
|
31
34
|
aztecNodeAdmin;
|
|
32
|
-
|
|
35
|
+
wallet;
|
|
33
36
|
logger;
|
|
34
37
|
feeJuice;
|
|
35
38
|
ethAccount;
|
|
@@ -39,10 +42,10 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
39
42
|
l1Client;
|
|
40
43
|
l1TokenManager;
|
|
41
44
|
feeJuicePortalManager;
|
|
42
|
-
constructor(/** Aztec node */ aztecNode, /** Aztec node admin interface */ aztecNodeAdmin, /**
|
|
45
|
+
constructor(/** Aztec node */ aztecNode, /** Aztec node admin interface */ aztecNodeAdmin, /** Wallet. */ wallet, /** Logger. */ logger, /** L2 Token/Bridge contract. */ feeJuice, /** Eth account to interact with. */ ethAccount, /** Portal address. */ feeJuicePortalAddress, /** Underlying token for portal tests. */ l1FeeJuiceAddress, /** Fee asset handler address. */ feeAssetHandlerAddress, /** Viem Extended client instance. */ l1Client){
|
|
43
46
|
this.aztecNode = aztecNode;
|
|
44
47
|
this.aztecNodeAdmin = aztecNodeAdmin;
|
|
45
|
-
this.
|
|
48
|
+
this.wallet = wallet;
|
|
46
49
|
this.logger = logger;
|
|
47
50
|
this.feeJuice = feeJuice;
|
|
48
51
|
this.ethAccount = ethAccount;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { SentTx } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
4
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
5
|
+
export declare const submitTxsTo: (wallet: TestWallet, submitter: AztecAddress, numTxs: number, logger: Logger) => Promise<SentTx[]>;
|
|
4
6
|
//# sourceMappingURL=submit-transactions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit-transactions.d.ts","sourceRoot":"","sources":["../../src/shared/submit-transactions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"submit-transactions.d.ts","sourceRoot":"","sources":["../../src/shared/submit-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,eAAO,MAAM,WAAW,GACtB,QAAQ,UAAU,EAClB,WAAW,YAAY,EACvB,QAAQ,MAAM,EACd,QAAQ,MAAM,KACb,OAAO,CAAC,MAAM,EAAE,CAsBlB,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Fr, GrumpkinScalar } from '@aztec/aztec.js/fields';
|
|
2
|
+
import { TxStatus } from '@aztec/aztec.js/tx';
|
|
3
3
|
import { times } from '@aztec/foundation/collection';
|
|
4
|
-
// submits a set of transactions to the provided
|
|
5
|
-
export const submitTxsTo = async (
|
|
4
|
+
// submits a set of transactions to the provided Wallet
|
|
5
|
+
export const submitTxsTo = async (wallet, submitter, numTxs, logger)=>{
|
|
6
6
|
const txs = [];
|
|
7
7
|
await Promise.all(times(numTxs, async ()=>{
|
|
8
|
-
const accountManager = await
|
|
9
|
-
const
|
|
10
|
-
|
|
8
|
+
const accountManager = await wallet.createSchnorrAccount(Fr.random(), Fr.random(), GrumpkinScalar.random());
|
|
9
|
+
const deployMethod = await accountManager.getDeployMethod();
|
|
10
|
+
const tx = deployMethod.send({
|
|
11
|
+
from: submitter
|
|
11
12
|
});
|
|
12
13
|
const txHash = await tx.getTxHash();
|
|
13
14
|
logger.info(`Tx sent with hash ${txHash}`);
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
3
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
4
|
import { CheatCodes } from '@aztec/aztec/testing';
|
|
3
5
|
import { type DeployL1ContractsReturnType, type ExtendedViemWalletClient } from '@aztec/ethereum';
|
|
6
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
4
7
|
/** Objects to be returned by the uniswap setup function */
|
|
5
8
|
export type UniswapSetupContext = {
|
|
6
9
|
/** Aztec Node instance */
|
|
7
10
|
aztecNode: AztecNode;
|
|
8
|
-
/** The Private eXecution Environment (PXE). */
|
|
9
|
-
pxe: PXE;
|
|
10
11
|
/** Logger instance named as the current test. */
|
|
11
12
|
logger: Logger;
|
|
12
13
|
/** The L1 wallet client, extended with public actions. */
|
|
13
14
|
l1Client: ExtendedViemWalletClient;
|
|
14
|
-
/** The
|
|
15
|
-
|
|
15
|
+
/** The wallet. */
|
|
16
|
+
wallet: TestWallet;
|
|
17
|
+
/** The owner address. */
|
|
18
|
+
ownerAddress: AztecAddress;
|
|
16
19
|
/** The sponsor wallet. */
|
|
17
|
-
|
|
20
|
+
sponsorAddress: AztecAddress;
|
|
18
21
|
/** */
|
|
19
22
|
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
20
23
|
/** Cheat codes instance. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniswap_l1_l2.d.ts","sourceRoot":"","sources":["../../src/shared/uniswap_l1_l2.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"uniswap_l1_l2.d.ts","sourceRoot":"","sources":["../../src/shared/uniswap_l1_l2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAc,MAAM,2BAA2B,CAAC;AAIrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAI9B,MAAM,iBAAiB,CAAC;AAMzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAiB5D,2DAA2D;AAC3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,0BAA0B;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,QAAQ,EAAE,wBAAwB,CAAC;IACnC,kBAAkB;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,yBAAyB;IACzB,YAAY,EAAE,YAAY,CAAC;IAC3B,0BAA0B;IAC1B,cAAc,EAAE,YAAY,CAAC;IAC7B,OAAO;IACP,uBAAuB,EAAE,2BAA2B,CAAC;IACrD,4BAA4B;IAC5B,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,OAAO,CAAC,mBAAmB,CAAC,EACzC,SAAS,MAAM,OAAO,CAAC,IAAI,CAAC,EAC5B,gCAAkC,SAg+BnC,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { AztecAddress, EthAddress
|
|
1
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { computeAuthWitMessageHash } from '@aztec/aztec.js/authorization';
|
|
3
|
+
import { generateClaimSecret } from '@aztec/aztec.js/ethereum';
|
|
4
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
2
5
|
import { RollupContract, deployL1Contract, extractEvent } from '@aztec/ethereum';
|
|
3
6
|
import { sha256ToField } from '@aztec/foundation/crypto';
|
|
4
7
|
import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
|
|
@@ -15,24 +18,19 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
|
|
|
15
18
|
// To start an actual fork, use the command:
|
|
16
19
|
// anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337
|
|
17
20
|
// For CI, this is configured in `run_tests.sh` and `docker-compose-images.yml`
|
|
18
|
-
// docs:start:uniswap_l1_l2_test_setup_const
|
|
19
21
|
const TIMEOUT = 360_000;
|
|
20
|
-
// docs:end:uniswap_l1_l2_test_setup_const
|
|
21
22
|
export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 17514288)=>{
|
|
22
|
-
// docs:start:uniswap_l1_l2_test_beforeAll
|
|
23
23
|
describe('uniswap_trade_on_l1_from_l2', ()=>{
|
|
24
24
|
jest.setTimeout(TIMEOUT);
|
|
25
25
|
const WETH9_ADDRESS = EthAddress.fromString('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2');
|
|
26
26
|
const DAI_ADDRESS = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC495271d0F');
|
|
27
27
|
let aztecNode;
|
|
28
|
-
let pxe;
|
|
29
28
|
let logger;
|
|
30
29
|
let l1Client;
|
|
31
|
-
let
|
|
30
|
+
let wallet;
|
|
32
31
|
let ownerAddress;
|
|
33
32
|
let ownerEthAddress;
|
|
34
33
|
// does transactions on behalf of owner on Aztec:
|
|
35
|
-
let sponsorWallet;
|
|
36
34
|
let sponsorAddress;
|
|
37
35
|
let daiCrossChainHarness;
|
|
38
36
|
let wethCrossChainHarness;
|
|
@@ -47,23 +45,21 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
47
45
|
let cheatCodes;
|
|
48
46
|
let version;
|
|
49
47
|
beforeAll(async ()=>{
|
|
50
|
-
({ aztecNode,
|
|
48
|
+
({ aztecNode, logger, l1Client, wallet, ownerAddress, sponsorAddress, deployL1ContractsValues, cheatCodes } = await setup());
|
|
51
49
|
if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
|
|
52
50
|
throw new Error('This test must be run on a fork of mainnet with the expected fork block');
|
|
53
51
|
}
|
|
54
52
|
rollup = new RollupContract(deployL1ContractsValues.l1Client, deployL1ContractsValues.l1ContractAddresses.rollupAddress);
|
|
55
53
|
version = Number(await rollup.getVersion());
|
|
56
|
-
ownerAddress = ownerWallet.getAddress();
|
|
57
|
-
sponsorAddress = sponsorWallet.getAddress();
|
|
58
54
|
ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
59
|
-
await ensureAccountContractsPublished(
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
await ensureAccountContractsPublished(wallet, [
|
|
56
|
+
ownerAddress,
|
|
57
|
+
sponsorAddress
|
|
62
58
|
]);
|
|
63
59
|
logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
|
|
64
|
-
daiCrossChainHarness = await CrossChainTestHarness.new(aztecNode,
|
|
60
|
+
daiCrossChainHarness = await CrossChainTestHarness.new(aztecNode, deployL1ContractsValues.l1Client, wallet, ownerAddress, logger, DAI_ADDRESS);
|
|
65
61
|
logger.info('Deploying WETH Portal, initializing and deploying l2 contract...');
|
|
66
|
-
wethCrossChainHarness = await CrossChainTestHarness.new(aztecNode,
|
|
62
|
+
wethCrossChainHarness = await CrossChainTestHarness.new(aztecNode, l1Client, wallet, ownerAddress, logger, WETH9_ADDRESS);
|
|
67
63
|
logger.info('Deploy Uniswap portal on L1 and L2...');
|
|
68
64
|
uniswapPortalAddress = await deployL1Contract(l1Client, UniswapPortalAbi, UniswapPortalBytecode).then(({ address })=>address);
|
|
69
65
|
uniswapPortal = getContract({
|
|
@@ -72,10 +68,10 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
72
68
|
client: l1Client
|
|
73
69
|
});
|
|
74
70
|
// deploy l2 uniswap contract and attach to portal
|
|
75
|
-
uniswapL2Contract = await UniswapContract.deploy(
|
|
71
|
+
uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
|
|
76
72
|
from: ownerAddress
|
|
77
73
|
}).deployed();
|
|
78
|
-
const registryAddress = (await
|
|
74
|
+
const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
|
|
79
75
|
await uniswapPortal.write.initialize([
|
|
80
76
|
registryAddress.toString(),
|
|
81
77
|
uniswapL2Contract.address.toString()
|
|
@@ -92,7 +88,6 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
92
88
|
const wethBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
|
|
93
89
|
expect(wethBalance).toBe(parseEther('1000'));
|
|
94
90
|
});
|
|
95
|
-
// docs:end:uniswap_l1_l2_test_beforeAll
|
|
96
91
|
afterAll(async ()=>{
|
|
97
92
|
await cleanup();
|
|
98
93
|
});
|
|
@@ -115,7 +110,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
115
110
|
// 3. Owner gives uniswap approval to transfer the funds to public to self on its behalf
|
|
116
111
|
logger.info('Approving uniswap to transfer funds to public to self on my behalf');
|
|
117
112
|
const nonceForWETHTransferToPublicApproval = new Fr(1n);
|
|
118
|
-
const transferToPublicAuhtwit = await
|
|
113
|
+
const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
|
|
119
114
|
caller: uniswapL2Contract.address,
|
|
120
115
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferToPublicApproval)
|
|
121
116
|
});
|
|
@@ -442,11 +437,8 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
442
437
|
const nonceForWETHTransferToPublicApproval = new Fr(2n);
|
|
443
438
|
const expectedMessageHash = await computeAuthWitMessageHash({
|
|
444
439
|
caller: uniswapL2Contract.address,
|
|
445
|
-
|
|
446
|
-
},
|
|
447
|
-
chainId: ownerWallet.getChainId(),
|
|
448
|
-
version: ownerWallet.getVersion()
|
|
449
|
-
});
|
|
440
|
+
call: await wethCrossChainHarness.l2Token.methods.transfer_to_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferToPublicApproval).getFunctionCall()
|
|
441
|
+
}, await wallet.getChainInfo());
|
|
450
442
|
await expect(uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, Fr.random(), ownerEthAddress).simulate({
|
|
451
443
|
from: ownerAddress
|
|
452
444
|
})).rejects.toThrow(`Unknown auth witness for message hash ${expectedMessageHash.toString()}`);
|
|
@@ -458,18 +450,18 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
458
450
|
// 2. owner gives uniswap approval to transfer the funds to public:
|
|
459
451
|
logger.info('Approving uniswap to transfer funds to public to self on my behalf');
|
|
460
452
|
const nonceForWETHTransferToPublicApproval = new Fr(3n);
|
|
461
|
-
const transferToPublicAuthwith = await
|
|
453
|
+
const transferToPublicAuthwith = await wallet.createAuthWit(ownerAddress, {
|
|
462
454
|
caller: uniswapL2Contract.address,
|
|
463
455
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferToPublicApproval)
|
|
464
456
|
});
|
|
465
457
|
// 3. Swap but send the wrong token address
|
|
466
458
|
logger.info('Swap but send the wrong token address');
|
|
467
|
-
await expect(uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, daiCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, Fr.random(), ownerEthAddress).
|
|
459
|
+
await expect(uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, daiCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, Fr.random(), ownerEthAddress).send({
|
|
468
460
|
from: ownerAddress,
|
|
469
461
|
authWitnesses: [
|
|
470
462
|
transferToPublicAuthwith
|
|
471
463
|
]
|
|
472
|
-
})).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
|
|
464
|
+
}).wait()).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
|
|
473
465
|
});
|
|
474
466
|
// edge cases for public flow:
|
|
475
467
|
it("I don't need approval to call swap_public if I'm swapping on my own behalf", async ()=>{
|
|
@@ -477,13 +469,11 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
477
469
|
await wethCrossChainHarness.mintTokensPublicOnL2(wethAmountToBridge);
|
|
478
470
|
// 2. Give approval to uniswap to transfer funds to itself
|
|
479
471
|
const nonceForWETHTransferApproval = new Fr(2n);
|
|
480
|
-
const validateActionInteraction = await
|
|
472
|
+
const validateActionInteraction = await wallet.setPublicAuthWit(ownerAddress, {
|
|
481
473
|
caller: uniswapL2Contract.address,
|
|
482
474
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferApproval)
|
|
483
475
|
}, true);
|
|
484
|
-
await validateActionInteraction.send(
|
|
485
|
-
from: ownerAddress
|
|
486
|
-
}).wait();
|
|
476
|
+
await validateActionInteraction.send().wait();
|
|
487
477
|
// No approval to call `swap` but should work even without it:
|
|
488
478
|
const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
489
479
|
await uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferApproval, uniswapFeeTier, minimumOutputAmount, ownerAddress, secretHashForDepositingSwappedDai, ownerEthAddress, Fr.ZERO).send({
|
|
@@ -498,14 +488,12 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
498
488
|
const nonceForWETHTransferApproval = new Fr(3n);
|
|
499
489
|
const nonceForSwap = new Fr(3n);
|
|
500
490
|
const secretHashForDepositingSwappedDai = new Fr(4n);
|
|
501
|
-
const action = uniswapL2Contract.
|
|
502
|
-
const validateActionInteraction = await
|
|
491
|
+
const action = uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferApproval, uniswapFeeTier, minimumOutputAmount, ownerAddress, secretHashForDepositingSwappedDai, ownerEthAddress, nonceForSwap);
|
|
492
|
+
const validateActionInteraction = await wallet.setPublicAuthWit(ownerAddress, {
|
|
503
493
|
caller: approvedUser,
|
|
504
494
|
action
|
|
505
495
|
}, true);
|
|
506
|
-
await validateActionInteraction.send(
|
|
507
|
-
from: ownerAddress
|
|
508
|
-
}).wait();
|
|
496
|
+
await validateActionInteraction.send().wait();
|
|
509
497
|
await expect(action.simulate({
|
|
510
498
|
from: sponsorAddress
|
|
511
499
|
})).rejects.toThrow(/unauthorized/);
|
|
@@ -513,13 +501,11 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
513
501
|
it("uniswap can't pull funds without transfer approval", async ()=>{
|
|
514
502
|
// swap should fail since no transfer approval to uniswap:
|
|
515
503
|
const nonceForWETHTransferApproval = new Fr(4n);
|
|
516
|
-
const validateActionInteraction = await
|
|
504
|
+
const validateActionInteraction = await wallet.setPublicAuthWit(ownerAddress, {
|
|
517
505
|
caller: uniswapL2Contract.address,
|
|
518
506
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferApproval)
|
|
519
507
|
}, true);
|
|
520
|
-
await validateActionInteraction.send(
|
|
521
|
-
from: ownerAddress
|
|
522
|
-
}).wait();
|
|
508
|
+
await validateActionInteraction.send().wait();
|
|
523
509
|
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
510
|
from: ownerAddress
|
|
525
511
|
})).rejects.toThrow(/unauthorized/);
|
|
@@ -532,7 +518,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
532
518
|
// Owner gives uniswap approval to transfer the funds to public to self on its behalf
|
|
533
519
|
logger.info('Approving uniswap to transfer the funds to public to self on my behalf');
|
|
534
520
|
const nonceForWETHTransferToPublicApproval = new Fr(4n);
|
|
535
|
-
const transferToPublicAuhtwit = await
|
|
521
|
+
const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
|
|
536
522
|
caller: uniswapL2Contract.address,
|
|
537
523
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferToPublicApproval)
|
|
538
524
|
});
|
|
@@ -621,13 +607,11 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
621
607
|
await wethCrossChainHarness.mintTokensPublicOnL2(wethAmountToBridge);
|
|
622
608
|
// Owner gives uniswap approval to transfer funds on its behalf
|
|
623
609
|
const nonceForWETHTransferApproval = new Fr(5n);
|
|
624
|
-
const validateActionInteraction = await
|
|
610
|
+
const validateActionInteraction = await wallet.setPublicAuthWit(ownerAddress, {
|
|
625
611
|
caller: uniswapL2Contract.address,
|
|
626
612
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferApproval)
|
|
627
613
|
}, true);
|
|
628
|
-
await validateActionInteraction.send(
|
|
629
|
-
from: ownerAddress
|
|
630
|
-
}).wait();
|
|
614
|
+
await validateActionInteraction.send().wait();
|
|
631
615
|
// Call swap_public on L2
|
|
632
616
|
const secretHashForDepositingSwappedDai = Fr.random();
|
|
633
617
|
const withdrawReceipt = await uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferApproval, uniswapFeeTier, minimumOutputAmount, ownerAddress, secretHashForDepositingSwappedDai, ownerEthAddress, Fr.ZERO).send({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AztecAddress
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
2
3
|
import { CheatCodes } from '@aztec/aztec/testing';
|
|
3
4
|
import type { RollupContract } from '@aztec/ethereum';
|
|
4
5
|
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"lending_simulator.d.ts","sourceRoot":"","sources":["../../src/simulators/lending_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK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c,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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Convenience struct to hold an account's address and secret that can easily be passed around.
|
|
2
|
-
import { AztecAddress
|
|
2
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
4
|
import { pedersenHash } from '@aztec/foundation/crypto';
|
|
4
5
|
/**
|
|
5
6
|
* Contains utilities to compute the "key" for private holdings in the public state.
|
|
@@ -160,7 +161,7 @@ const computeMultiplier = (rate, dt)=>{
|
|
|
160
161
|
AztecAddress.fromField(await this.account.key())
|
|
161
162
|
]){
|
|
162
163
|
const privatePos = await this.lendingContract.methods.get_position(key).simulate({
|
|
163
|
-
from:
|
|
164
|
+
from: this.account.address
|
|
164
165
|
});
|
|
165
166
|
expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
|
|
166
167
|
expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
3
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
2
4
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
3
5
|
export declare class TokenSimulator {
|
|
4
6
|
protected token: TokenContract;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token_simulator.d.ts","sourceRoot":"","sources":["../../src/simulators/token_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"token_simulator.d.ts","sourceRoot":"","sources":["../../src/simulators/token_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,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,cAAc,EAAE,YAAY;IACtC,SAAS,CAAC,MAAM,EAAE,MAAM;IACxB,SAAS,CAAC,QAAQ,EAAE,YAAY,EAAE;IAXpC,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,cAAc,EAAE,YAAY,EAC5B,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;IAoBX,YAAY;IAsCL,KAAK;CAInB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BatchCall } from '@aztec/aztec.js';
|
|
1
|
+
import { BatchCall } from '@aztec/aztec.js/contracts';
|
|
2
2
|
import chunk from 'lodash.chunk';
|
|
3
3
|
export class TokenSimulator {
|
|
4
4
|
token;
|
|
@@ -88,7 +88,7 @@ export class TokenSimulator {
|
|
|
88
88
|
this.token.methods.total_supply(),
|
|
89
89
|
...this.accounts.map((address)=>this.token.methods.balance_of_public(address))
|
|
90
90
|
];
|
|
91
|
-
const results = (await Promise.all(chunk(calls,
|
|
91
|
+
const results = (await Promise.all(chunk(calls, 5).map((batch)=>new BatchCall(this.defaultWallet, batch).simulate({
|
|
92
92
|
from: this.defaultAddress
|
|
93
93
|
})))).flat();
|
|
94
94
|
expect(results[0]).toEqual(this.totalSupply);
|
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { type FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
3
|
+
import { type AztecNode } from '@aztec/aztec.js/node';
|
|
2
4
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
5
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
7
|
+
export interface TestAccounts {
|
|
8
|
+
aztecNode: AztecNode;
|
|
9
|
+
wallet: TestWallet;
|
|
10
|
+
accounts: AztecAddress[];
|
|
11
|
+
tokenContract: TokenContract;
|
|
8
12
|
tokenAdminAddress: AztecAddress;
|
|
9
13
|
tokenName: string;
|
|
10
|
-
recipientWallet: AccountWalletWithSecretKey;
|
|
11
14
|
recipientAddress: AztecAddress;
|
|
12
15
|
tokenAddress: AztecAddress;
|
|
13
16
|
}
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function performTransfers({
|
|
18
|
-
|
|
17
|
+
export declare function setupTestAccountsWithTokens(nodeUrl: string, mintAmount: bigint, logger: Logger): Promise<TestAccounts>;
|
|
18
|
+
export declare function deploySponsoredTestAccounts(wallet: TestWallet, aztecNode: AztecNode, mintAmount: bigint, logger: Logger, numberOfFundedWallets?: number): Promise<TestAccounts>;
|
|
19
|
+
export declare function deployTestAccountsWithTokens(nodeUrl: string, l1RpcUrls: string[], mnemonicOrPrivateKey: string, mintAmount: bigint, logger: Logger, numberOfFundedWallets?: number): Promise<TestAccounts>;
|
|
20
|
+
export declare function performTransfers({ wallet, testAccounts, rounds, transferAmount, logger, feePaymentMethod, }: {
|
|
21
|
+
wallet: TestWallet;
|
|
22
|
+
testAccounts: TestAccounts;
|
|
19
23
|
rounds: number;
|
|
20
24
|
transferAmount: bigint;
|
|
21
25
|
logger: Logger;
|
|
26
|
+
feePaymentMethod?: FeePaymentMethod;
|
|
22
27
|
}): Promise<void>;
|
|
23
|
-
export declare function
|
|
24
|
-
|
|
28
|
+
export declare function createWalletAndAztecNodeClient(nodeUrl: string, proverEnabled: boolean, logger: Logger): Promise<{
|
|
29
|
+
wallet: TestWallet;
|
|
30
|
+
aztecNode: AztecNode;
|
|
25
31
|
cleanup: () => Promise<void>;
|
|
26
32
|
}>;
|
|
27
33
|
//# sourceMappingURL=setup_test_wallets.d.ts.map
|