@aztec/end-to-end 1.0.0-nightly.20250810 → 1.0.0-nightly.20250812
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 +1 -1
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +30 -12
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +6 -2
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +3 -0
- 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 +47 -15
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -1
- 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 +12 -9
- package/dest/e2e_deploy_contract/deploy_test.d.ts +1 -1
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +5 -4
- package/dest/e2e_fees/bridging_race.notest.js +3 -1
- package/dest/e2e_fees/fees_test.d.ts +2 -2
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +29 -33
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -3
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +17 -12
- package/dest/e2e_p2p/p2p_network.d.ts +2 -1
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +5 -1
- package/dest/e2e_p2p/shared.d.ts +2 -2
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +7 -3
- package/dest/e2e_token_contract/token_contract_test.d.ts +8 -4
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +48 -23
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +22 -8
- package/dest/fixtures/snapshot_manager.js +3 -1
- package/dest/fixtures/token_utils.d.ts +3 -3
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +13 -7
- package/dest/fixtures/utils.d.ts +4 -3
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +14 -6
- package/dest/sample-dapp/connect.d.mts +2 -0
- package/dest/sample-dapp/connect.d.mts.map +1 -0
- package/dest/sample-dapp/connect.js +1 -1
- package/dest/sample-dapp/contracts.d.mts +3 -0
- package/dest/sample-dapp/contracts.d.mts.map +1 -0
- package/dest/sample-dapp/contracts.js +1 -1
- package/dest/sample-dapp/deploy.d.mts +3 -0
- package/dest/sample-dapp/deploy.d.mts.map +1 -0
- package/dest/sample-dapp/deploy.js +4 -1
- package/dest/sample-dapp/index.d.mts +2 -0
- package/dest/sample-dapp/index.d.mts.map +1 -0
- package/dest/sample-dapp/index.js +18 -7
- package/dest/shared/cross_chain_test_harness.d.ts +6 -3
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +50 -20
- package/dest/shared/gas_portal_test_harness.d.ts +3 -3
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +9 -5
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +37 -14
- package/dest/simulators/lending_simulator.js +6 -2
- package/dest/simulators/token_simulator.d.ts +2 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +12 -4
- package/dest/spartan/setup_test_wallets.d.ts +2 -0
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +15 -5
- package/package.json +35 -35
- package/src/bench/client_flows/benchmark.ts +1 -1
- package/src/bench/client_flows/client_flows_benchmark.ts +20 -11
- package/src/bench/utils.ts +4 -2
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +28 -17
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +13 -8
- package/src/e2e_deploy_contract/deploy_test.ts +5 -5
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +37 -46
- package/src/e2e_nested_contract/nested_contract_test.ts +16 -11
- package/src/e2e_p2p/p2p_network.ts +6 -2
- package/src/e2e_p2p/shared.ts +4 -2
- package/src/e2e_token_contract/token_contract_test.ts +38 -36
- package/src/fixtures/e2e_prover_test.ts +13 -7
- package/src/fixtures/snapshot_manager.ts +1 -1
- package/src/fixtures/token_utils.ts +13 -6
- package/src/fixtures/utils.ts +14 -7
- package/src/sample-dapp/connect.mjs +1 -1
- package/src/sample-dapp/contracts.mjs +1 -1
- package/src/sample-dapp/deploy.mjs +3 -3
- package/src/sample-dapp/index.mjs +11 -7
- package/src/shared/cross_chain_test_harness.ts +31 -18
- package/src/shared/gas_portal_test_harness.ts +6 -6
- package/src/shared/uniswap_l1_l2.ts +19 -15
- package/src/simulators/lending_simulator.ts +2 -2
- package/src/simulators/token_simulator.ts +12 -3
- package/src/spartan/setup_test_wallets.ts +40 -16
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getSchnorrWallet } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { type AccountWallet,
|
|
2
|
+
import { type AccountWallet, AztecAddress, type AztecNode, type Logger, createLogger } from '@aztec/aztec.js';
|
|
3
3
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
4
|
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
5
5
|
|
|
@@ -23,13 +23,18 @@ export class TokenContractTest {
|
|
|
23
23
|
static TOKEN_DECIMALS = 18n;
|
|
24
24
|
private snapshotManager: ISnapshotManager;
|
|
25
25
|
logger: Logger;
|
|
26
|
-
wallets: AccountWallet[] = [];
|
|
27
|
-
accounts: CompleteAddress[] = [];
|
|
28
26
|
asset!: TokenContract;
|
|
29
27
|
tokenSim!: TokenSimulator;
|
|
30
|
-
badAccount!: InvalidAccountContract;
|
|
31
28
|
node!: AztecNode;
|
|
32
29
|
|
|
30
|
+
badAccount!: InvalidAccountContract;
|
|
31
|
+
admin!: AccountWallet;
|
|
32
|
+
adminAddress!: AztecAddress;
|
|
33
|
+
account1!: AccountWallet;
|
|
34
|
+
account1Address!: AztecAddress;
|
|
35
|
+
account2!: AccountWallet;
|
|
36
|
+
account2Address!: AztecAddress;
|
|
37
|
+
|
|
33
38
|
constructor(testName: string) {
|
|
34
39
|
this.logger = createLogger(`e2e:e2e_token_contract:${testName}`);
|
|
35
40
|
this.snapshotManager = createSnapshotManager(`e2e_token_contract/${testName}`, dataPath, {
|
|
@@ -51,8 +56,9 @@ export class TokenContractTest {
|
|
|
51
56
|
deployAccounts(3, this.logger),
|
|
52
57
|
async ({ deployedAccounts }, { pxe, aztecNode }) => {
|
|
53
58
|
this.node = aztecNode;
|
|
54
|
-
|
|
55
|
-
this.
|
|
59
|
+
const wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
|
|
60
|
+
[this.admin, this.account1, this.account2] = wallets;
|
|
61
|
+
[this.adminAddress, this.account1Address, this.account2Address] = wallets.map(w => w.getAddress());
|
|
56
62
|
},
|
|
57
63
|
);
|
|
58
64
|
|
|
@@ -62,42 +68,42 @@ export class TokenContractTest {
|
|
|
62
68
|
// Create the token contract state.
|
|
63
69
|
// Move this account thing to addAccounts above?
|
|
64
70
|
this.logger.verbose(`Public deploy accounts...`);
|
|
65
|
-
await publicDeployAccounts(this.
|
|
71
|
+
await publicDeployAccounts(this.admin, [this.adminAddress, this.account1Address]);
|
|
66
72
|
|
|
67
73
|
this.logger.verbose(`Deploying TokenContract...`);
|
|
68
74
|
const asset = await TokenContract.deploy(
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
75
|
+
this.admin,
|
|
76
|
+
this.adminAddress,
|
|
71
77
|
TokenContractTest.TOKEN_NAME,
|
|
72
78
|
TokenContractTest.TOKEN_SYMBOL,
|
|
73
79
|
TokenContractTest.TOKEN_DECIMALS,
|
|
74
80
|
)
|
|
75
|
-
.send()
|
|
81
|
+
.send({ from: this.adminAddress })
|
|
76
82
|
.deployed();
|
|
77
83
|
this.logger.verbose(`Token deployed to ${asset.address}`);
|
|
78
84
|
|
|
79
85
|
this.logger.verbose(`Deploying bad account...`);
|
|
80
|
-
this.badAccount = await InvalidAccountContract.deploy(this.
|
|
86
|
+
this.badAccount = await InvalidAccountContract.deploy(this.admin).send({ from: this.adminAddress }).deployed();
|
|
81
87
|
this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
|
|
82
88
|
|
|
83
89
|
return { tokenContractAddress: asset.address, badAccountAddress: this.badAccount.address };
|
|
84
90
|
},
|
|
85
91
|
async ({ tokenContractAddress, badAccountAddress }) => {
|
|
86
92
|
// Restore the token contract state.
|
|
87
|
-
this.asset = await TokenContract.at(tokenContractAddress, this.
|
|
93
|
+
this.asset = await TokenContract.at(tokenContractAddress, this.admin);
|
|
88
94
|
this.logger.verbose(`Token contract address: ${this.asset.address}`);
|
|
89
95
|
|
|
90
|
-
this.tokenSim = new TokenSimulator(
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
this.accounts.map(a => a.address),
|
|
95
|
-
);
|
|
96
|
+
this.tokenSim = new TokenSimulator(this.asset, this.admin, this.adminAddress, this.logger, [
|
|
97
|
+
this.adminAddress,
|
|
98
|
+
this.account1Address,
|
|
99
|
+
]);
|
|
96
100
|
|
|
97
|
-
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.
|
|
101
|
+
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.admin);
|
|
98
102
|
this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
|
|
99
103
|
|
|
100
|
-
expect(await this.asset.methods.get_admin().simulate()).toBe(
|
|
104
|
+
expect(await this.asset.methods.get_admin().simulate({ from: this.adminAddress })).toBe(
|
|
105
|
+
this.adminAddress.toBigInt(),
|
|
106
|
+
);
|
|
101
107
|
},
|
|
102
108
|
);
|
|
103
109
|
|
|
@@ -125,36 +131,32 @@ export class TokenContractTest {
|
|
|
125
131
|
await this.snapshotManager.snapshot(
|
|
126
132
|
'mint',
|
|
127
133
|
async () => {
|
|
128
|
-
const { asset,
|
|
134
|
+
const { asset, admin, adminAddress } = this;
|
|
129
135
|
const amount = 10000n;
|
|
130
136
|
|
|
131
137
|
this.logger.verbose(`Minting ${amount} publicly...`);
|
|
132
|
-
await asset.methods.mint_to_public(
|
|
138
|
+
await asset.methods.mint_to_public(adminAddress, amount).send({ from: adminAddress }).wait();
|
|
133
139
|
|
|
134
140
|
this.logger.verbose(`Minting ${amount} privately...`);
|
|
135
|
-
await mintTokensToPrivate(asset,
|
|
141
|
+
await mintTokensToPrivate(asset, adminAddress, admin, adminAddress, amount);
|
|
136
142
|
this.logger.verbose(`Minting complete.`);
|
|
137
143
|
|
|
138
144
|
return { amount };
|
|
139
145
|
},
|
|
140
146
|
async ({ amount }) => {
|
|
141
|
-
const {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
} = this;
|
|
146
|
-
tokenSim.mintPublic(address, amount);
|
|
147
|
-
|
|
148
|
-
const publicBalance = await asset.methods.balance_of_public(address).simulate();
|
|
147
|
+
const { asset, adminAddress, tokenSim } = this;
|
|
148
|
+
tokenSim.mintPublic(adminAddress, amount);
|
|
149
|
+
|
|
150
|
+
const publicBalance = await asset.methods.balance_of_public(adminAddress).simulate({ from: adminAddress });
|
|
149
151
|
this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
|
|
150
|
-
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(
|
|
152
|
+
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(adminAddress));
|
|
151
153
|
|
|
152
|
-
tokenSim.mintPrivate(
|
|
153
|
-
const privateBalance = await asset.methods.balance_of_private(
|
|
154
|
+
tokenSim.mintPrivate(adminAddress, amount);
|
|
155
|
+
const privateBalance = await asset.methods.balance_of_private(adminAddress).simulate({ from: adminAddress });
|
|
154
156
|
this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
|
|
155
|
-
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(
|
|
157
|
+
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(adminAddress));
|
|
156
158
|
|
|
157
|
-
const totalSupply = await asset.methods.total_supply().simulate();
|
|
159
|
+
const totalSupply = await asset.methods.total_supply().simulate({ from: adminAddress });
|
|
158
160
|
this.logger.verbose(`Total supply: ${totalSupply}`);
|
|
159
161
|
expect(totalSupply).toEqual(tokenSim.totalSupply);
|
|
160
162
|
|
|
@@ -141,7 +141,7 @@ export class FullProverTest {
|
|
|
141
141
|
FullProverTest.TOKEN_SYMBOL,
|
|
142
142
|
FullProverTest.TOKEN_DECIMALS,
|
|
143
143
|
)
|
|
144
|
-
.send()
|
|
144
|
+
.send({ from: this.wallets[0].getAddress() })
|
|
145
145
|
.deployed();
|
|
146
146
|
this.logger.verbose(`Token deployed to ${asset.address}`);
|
|
147
147
|
|
|
@@ -155,11 +155,14 @@ export class FullProverTest {
|
|
|
155
155
|
this.tokenSim = new TokenSimulator(
|
|
156
156
|
this.fakeProofsAsset,
|
|
157
157
|
this.wallets[0],
|
|
158
|
+
this.wallets[0].getAddress(),
|
|
158
159
|
this.logger,
|
|
159
160
|
this.accounts.map(a => a.address),
|
|
160
161
|
);
|
|
161
162
|
|
|
162
|
-
expect(await this.fakeProofsAsset.methods.get_admin().simulate(
|
|
163
|
+
expect(await this.fakeProofsAsset.methods.get_admin().simulate({ from: this.accounts[0].address })).toBe(
|
|
164
|
+
this.accounts[0].address.toBigInt(),
|
|
165
|
+
);
|
|
163
166
|
},
|
|
164
167
|
);
|
|
165
168
|
}
|
|
@@ -365,11 +368,14 @@ export class FullProverTest {
|
|
|
365
368
|
this.logger.verbose(`Minting ${privateAmount + publicAmount} publicly...`);
|
|
366
369
|
await asset.methods
|
|
367
370
|
.mint_to_public(accounts[0].address, privateAmount + publicAmount)
|
|
368
|
-
.send()
|
|
371
|
+
.send({ from: accounts[0].address })
|
|
369
372
|
.wait();
|
|
370
373
|
|
|
371
374
|
this.logger.verbose(`Transferring ${privateAmount} to private...`);
|
|
372
|
-
await asset.methods
|
|
375
|
+
await asset.methods
|
|
376
|
+
.transfer_to_private(accounts[0].address, privateAmount)
|
|
377
|
+
.send({ from: accounts[0].address })
|
|
378
|
+
.wait();
|
|
373
379
|
|
|
374
380
|
this.logger.verbose(`Minting complete.`);
|
|
375
381
|
|
|
@@ -383,16 +389,16 @@ export class FullProverTest {
|
|
|
383
389
|
} = this;
|
|
384
390
|
tokenSim.mintPublic(address, amount);
|
|
385
391
|
|
|
386
|
-
const publicBalance = await asset.methods.balance_of_public(address).simulate();
|
|
392
|
+
const publicBalance = await asset.methods.balance_of_public(address).simulate({ from: address });
|
|
387
393
|
this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
|
|
388
394
|
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address));
|
|
389
395
|
|
|
390
396
|
tokenSim.mintPrivate(address, amount);
|
|
391
|
-
const privateBalance = await asset.methods.balance_of_private(address).simulate();
|
|
397
|
+
const privateBalance = await asset.methods.balance_of_private(address).simulate({ from: address });
|
|
392
398
|
this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
|
|
393
399
|
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address));
|
|
394
400
|
|
|
395
|
-
const totalSupply = await asset.methods.total_supply().simulate();
|
|
401
|
+
const totalSupply = await asset.methods.total_supply().simulate({ from: address });
|
|
396
402
|
this.logger.verbose(`Total supply: ${totalSupply}`);
|
|
397
403
|
expect(totalSupply).toEqual(tokenSim.totalSupply);
|
|
398
404
|
|
|
@@ -666,7 +666,7 @@ export async function publicDeployAccounts(
|
|
|
666
666
|
|
|
667
667
|
const batch = new BatchCall(sender, calls);
|
|
668
668
|
|
|
669
|
-
const txReceipt = await batch.send().wait();
|
|
669
|
+
const txReceipt = await batch.send({ from: accountAddressesToDeploy[0] }).wait();
|
|
670
670
|
if (waitUntilProven) {
|
|
671
671
|
if (!pxeOrNode) {
|
|
672
672
|
throw new Error('Need to provide a PXE or AztecNode to wait for proven.');
|
|
@@ -3,15 +3,20 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
|
3
3
|
|
|
4
4
|
// docs:start:token_utils
|
|
5
5
|
|
|
6
|
-
export async function deployToken(
|
|
6
|
+
export async function deployToken(
|
|
7
|
+
adminWallet: Wallet,
|
|
8
|
+
deployerAddress: AztecAddress,
|
|
9
|
+
initialAdminBalance: bigint,
|
|
10
|
+
logger: Logger,
|
|
11
|
+
) {
|
|
7
12
|
logger.info(`Deploying Token contract...`);
|
|
8
|
-
const contract = await TokenContract.deploy(adminWallet,
|
|
9
|
-
.send()
|
|
13
|
+
const contract = await TokenContract.deploy(adminWallet, deployerAddress, 'TokenName', 'TokenSymbol', 18)
|
|
14
|
+
.send({ from: deployerAddress })
|
|
10
15
|
.deployed();
|
|
11
16
|
|
|
12
17
|
if (initialAdminBalance > 0n) {
|
|
13
18
|
// Minter is minting to herself so contract as minter is the same as contract as recipient
|
|
14
|
-
await mintTokensToPrivate(contract,
|
|
19
|
+
await mintTokensToPrivate(contract, deployerAddress, adminWallet, deployerAddress, initialAdminBalance);
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
logger.info('L2 contract deployed');
|
|
@@ -21,12 +26,13 @@ export async function deployToken(adminWallet: Wallet, initialAdminBalance: bigi
|
|
|
21
26
|
|
|
22
27
|
export async function mintTokensToPrivate(
|
|
23
28
|
token: TokenContract,
|
|
29
|
+
minter: AztecAddress,
|
|
24
30
|
minterWallet: Wallet,
|
|
25
31
|
recipient: AztecAddress,
|
|
26
32
|
amount: bigint,
|
|
27
33
|
) {
|
|
28
34
|
const tokenAsMinter = await TokenContract.at(token.address, minterWallet);
|
|
29
|
-
await tokenAsMinter.methods.mint_to_private(recipient, amount).send().wait();
|
|
35
|
+
await tokenAsMinter.methods.mint_to_private(recipient, amount).send({ from: minter }).wait();
|
|
30
36
|
}
|
|
31
37
|
// docs:end:token_utils
|
|
32
38
|
|
|
@@ -46,6 +52,7 @@ export async function expectTokenBalance(
|
|
|
46
52
|
|
|
47
53
|
export async function mintNotes(
|
|
48
54
|
sender: Wallet,
|
|
55
|
+
minter: AztecAddress,
|
|
49
56
|
recipient: AztecAddress,
|
|
50
57
|
asset: TokenContract,
|
|
51
58
|
noteAmounts: bigint[],
|
|
@@ -56,7 +63,7 @@ export async function mintNotes(
|
|
|
56
63
|
for (let mintedNotes = 0; mintedNotes < noteAmounts.length; mintedNotes += notesPerIteration) {
|
|
57
64
|
const toMint = noteAmounts.slice(mintedNotes, mintedNotes + notesPerIteration);
|
|
58
65
|
const actions = toMint.map(amt => asset.methods.mint_to_private(recipient, amt));
|
|
59
|
-
await new BatchCall(sender, actions).send().wait();
|
|
66
|
+
await new BatchCall(sender, actions).send({ from: minter }).wait();
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
return noteAmounts.reduce((prev, curr) => prev + curr, 0n);
|
package/src/fixtures/utils.ts
CHANGED
|
@@ -257,8 +257,9 @@ async function setupWithRemoteEnvironment(
|
|
|
257
257
|
deployL1ContractsValues,
|
|
258
258
|
config,
|
|
259
259
|
initialFundedAccounts,
|
|
260
|
+
wallets,
|
|
260
261
|
wallet: wallets[0],
|
|
261
|
-
|
|
262
|
+
accounts: wallets.slice(0, numberOfAccounts).map(w => w.getAddress()),
|
|
262
263
|
logger,
|
|
263
264
|
cheatCodes,
|
|
264
265
|
prefilledPublicData: undefined,
|
|
@@ -335,10 +336,12 @@ export type EndToEndContext = {
|
|
|
335
336
|
config: AztecNodeConfig;
|
|
336
337
|
/** The data for the initial funded accounts. */
|
|
337
338
|
initialFundedAccounts: InitialAccountData[];
|
|
339
|
+
/* Wallets created for the initial funded accounts, with secret keys. */
|
|
340
|
+
wallets: AccountWalletWithSecretKey[];
|
|
338
341
|
/** The first wallet to be used. */
|
|
339
342
|
wallet: AccountWalletWithSecretKey;
|
|
340
|
-
/** The
|
|
341
|
-
|
|
343
|
+
/** The accounts to be used. */
|
|
344
|
+
accounts: AztecAddress[];
|
|
342
345
|
/** Logger instance named as the current test. */
|
|
343
346
|
logger: Logger;
|
|
344
347
|
/** The cheat codes. */
|
|
@@ -710,8 +713,9 @@ export async function setup(
|
|
|
710
713
|
sequencer: sequencerClient,
|
|
711
714
|
teardown,
|
|
712
715
|
telemetryClient: telemetry,
|
|
713
|
-
wallet: wallets[0],
|
|
714
716
|
wallets,
|
|
717
|
+
wallet: wallets[0],
|
|
718
|
+
accounts: wallets.map(w => w.getAddress()),
|
|
715
719
|
watcher,
|
|
716
720
|
};
|
|
717
721
|
} catch (err) {
|
|
@@ -750,11 +754,13 @@ export async function ensureAccountContractsPublished(sender: Wallet, accountsTo
|
|
|
750
754
|
).map(contractMetadata => contractMetadata.contractInstance);
|
|
751
755
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
752
756
|
if (!(await sender.getContractClassMetadata(contractClass.id, true)).isContractClassPubliclyRegistered) {
|
|
753
|
-
await (await publishContractClass(sender, SchnorrAccountContractArtifact))
|
|
757
|
+
await (await publishContractClass(sender, SchnorrAccountContractArtifact))
|
|
758
|
+
.send({ from: accountsToDeploy[0].getAddress() })
|
|
759
|
+
.wait();
|
|
754
760
|
}
|
|
755
761
|
const requests = await Promise.all(instances.map(async instance => await publishInstance(sender, instance!)));
|
|
756
762
|
const batch = new BatchCall(sender, requests);
|
|
757
|
-
await batch.send().wait();
|
|
763
|
+
await batch.send({ from: accountsToDeploy[0].getAddress() }).wait();
|
|
758
764
|
}
|
|
759
765
|
// docs:end:public_deploy_accounts
|
|
760
766
|
|
|
@@ -794,11 +800,12 @@ export type BalancesFn = ReturnType<typeof getBalancesFn>;
|
|
|
794
800
|
export function getBalancesFn(
|
|
795
801
|
symbol: string,
|
|
796
802
|
method: ContractMethod,
|
|
803
|
+
from: AztecAddress,
|
|
797
804
|
logger: any,
|
|
798
805
|
): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
|
|
799
806
|
const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
|
|
800
807
|
const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
|
|
801
|
-
const b = await Promise.all(addresses.map(address => method(address).simulate()));
|
|
808
|
+
const b = await Promise.all(addresses.map(address => method(address).simulate({ from })));
|
|
802
809
|
const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
|
|
803
810
|
logger.verbose(debugString);
|
|
804
811
|
return b;
|
|
@@ -4,7 +4,7 @@ import { createPXEClient } from '@aztec/aztec.js';
|
|
|
4
4
|
const { PXE_URL = 'http://localhost:8080' } = process.env;
|
|
5
5
|
|
|
6
6
|
async function main() {
|
|
7
|
-
const pxe =
|
|
7
|
+
const pxe = createPXEClient(PXE_URL);
|
|
8
8
|
const { l1ChainId } = await pxe.getNodeInfo();
|
|
9
9
|
console.log(`Connected to chain ${l1ChainId}`);
|
|
10
10
|
}
|
|
@@ -7,7 +7,7 @@ import { readFileSync } from 'fs';
|
|
|
7
7
|
const TokenContractArtifact = TokenContract.artifact;
|
|
8
8
|
|
|
9
9
|
// docs:start:get-tokens
|
|
10
|
-
export
|
|
10
|
+
export function getToken(wallet) {
|
|
11
11
|
const addresses = JSON.parse(readFileSync('addresses.json'));
|
|
12
12
|
return Contract.at(AztecAddress.fromString(addresses.token), TokenContractArtifact, wallet);
|
|
13
13
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// docs:start:deploy-imports
|
|
2
2
|
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';
|
|
3
|
-
import { Contract, createPXEClient,
|
|
3
|
+
import { Contract, createPXEClient, waitForPXE } from '@aztec/aztec.js';
|
|
4
4
|
// docs:end:deploy-imports
|
|
5
5
|
// docs:start:import_artifact
|
|
6
6
|
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
7
|
+
|
|
7
8
|
// docs:end:import_artifact
|
|
8
|
-
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
9
9
|
|
|
10
10
|
import { writeFileSync } from 'fs';
|
|
11
11
|
import { fileURLToPath } from 'url';
|
|
@@ -21,7 +21,7 @@ async function main() {
|
|
|
21
21
|
const ownerAddress = ownerWallet.getAddress();
|
|
22
22
|
|
|
23
23
|
const token = await Contract.deploy(ownerWallet, TokenContractArtifact, [ownerAddress, 'TokenName', 'TKN', 18])
|
|
24
|
-
.send()
|
|
24
|
+
.send({ from: ownerAddress })
|
|
25
25
|
.deployed();
|
|
26
26
|
|
|
27
27
|
console.log(`Token deployed at ${token.address.toString()}`);
|
|
@@ -25,7 +25,7 @@ async function showPrivateBalances(pxe) {
|
|
|
25
25
|
|
|
26
26
|
for (const account of accounts) {
|
|
27
27
|
// highlight-next-line:showPrivateBalances
|
|
28
|
-
const balance = await token.methods.balance_of_private(account.address).simulate();
|
|
28
|
+
const balance = await token.methods.balance_of_private(account.address).simulate({ from: account.address });
|
|
29
29
|
console.log(`Balance of ${account.address}: ${balance}`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -40,7 +40,10 @@ async function mintPrivateFunds(pxe) {
|
|
|
40
40
|
|
|
41
41
|
// We mint tokens to the owner
|
|
42
42
|
const mintAmount = 20n;
|
|
43
|
-
await token.methods
|
|
43
|
+
await token.methods
|
|
44
|
+
.mint_to_private(ownerWallet.getAddress(), mintAmount)
|
|
45
|
+
.send({ from: ownerWallet.getAddress() })
|
|
46
|
+
.wait();
|
|
44
47
|
|
|
45
48
|
await showPrivateBalances(pxe);
|
|
46
49
|
}
|
|
@@ -53,7 +56,7 @@ async function transferPrivateFunds(pxe) {
|
|
|
53
56
|
|
|
54
57
|
await showPrivateBalances(pxe);
|
|
55
58
|
console.log(`Sending transaction, awaiting transaction to be mined`);
|
|
56
|
-
const receipt = await token.methods.transfer(recipient.getAddress(), 1).send().wait();
|
|
59
|
+
const receipt = await token.methods.transfer(recipient.getAddress(), 1).send({ from: owner.getAddress() }).wait();
|
|
57
60
|
|
|
58
61
|
console.log(`Transaction ${receipt.txHash} has been mined on block ${receipt.blockNumber}`);
|
|
59
62
|
await showPrivateBalances(pxe);
|
|
@@ -69,7 +72,7 @@ async function showPublicBalances(pxe) {
|
|
|
69
72
|
|
|
70
73
|
for (const account of accounts) {
|
|
71
74
|
// highlight-next-line:showPublicBalances
|
|
72
|
-
const balance = await token.methods.balance_of_public(account.address).simulate();
|
|
75
|
+
const balance = await token.methods.balance_of_public(account.address).simulate({ from: account.address });
|
|
73
76
|
console.log(`Balance of ${account.address}: ${balance}`);
|
|
74
77
|
}
|
|
75
78
|
}
|
|
@@ -83,7 +86,7 @@ async function mintPublicFunds(pxe) {
|
|
|
83
86
|
await showPublicBalances(pxe);
|
|
84
87
|
|
|
85
88
|
console.log(`Sending transaction, awaiting transaction to be mined`);
|
|
86
|
-
const receipt = await token.methods.mint_to_public(owner.getAddress(), 100).send().wait();
|
|
89
|
+
const receipt = await token.methods.mint_to_public(owner.getAddress(), 100).send({ from: owner.getAddress() }).wait();
|
|
87
90
|
console.log(`Transaction ${receipt.txHash} has been mined on block ${receipt.blockNumber}`);
|
|
88
91
|
|
|
89
92
|
await showPublicBalances(pxe);
|
|
@@ -92,7 +95,9 @@ async function mintPublicFunds(pxe) {
|
|
|
92
95
|
const blockNumber = await pxe.getBlockNumber();
|
|
93
96
|
const logs = (await pxe.getPublicLogs({ fromBlock: blockNumber - 1 })).logs;
|
|
94
97
|
const textLogs = logs.map(extendedLog => extendedLog.toHumanReadable().slice(0, 200));
|
|
95
|
-
for (const log of textLogs)
|
|
98
|
+
for (const log of textLogs) {
|
|
99
|
+
console.log(`Log emitted: ${log}`);
|
|
100
|
+
}
|
|
96
101
|
// docs:end:showLogs
|
|
97
102
|
}
|
|
98
103
|
// docs:end:mintPublicFunds
|
|
@@ -115,7 +120,6 @@ async function main() {
|
|
|
115
120
|
|
|
116
121
|
// Execute main only if run directly
|
|
117
122
|
if (process.argv[1].replace(/\/index\.m?js$/, '') === fileURLToPath(import.meta.url).replace(/\/index\.m?js$/, '')) {
|
|
118
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
119
123
|
main()
|
|
120
124
|
.then(() => process.exit(0))
|
|
121
125
|
.catch(err => {
|
|
@@ -75,22 +75,26 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
// deploy l2 token
|
|
78
|
-
const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18)
|
|
78
|
+
const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18)
|
|
79
|
+
.send({ from: owner })
|
|
80
|
+
.deployed();
|
|
79
81
|
|
|
80
82
|
// deploy l2 token bridge and attach to the portal
|
|
81
|
-
const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress)
|
|
83
|
+
const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress)
|
|
84
|
+
.send({ from: owner })
|
|
85
|
+
.deployed();
|
|
82
86
|
|
|
83
|
-
if ((await token.methods.get_admin().simulate()) !== owner.toBigInt()) {
|
|
87
|
+
if ((await token.methods.get_admin().simulate({ from: owner })) !== owner.toBigInt()) {
|
|
84
88
|
throw new Error(`Token admin is not ${owner}`);
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
if (!(await bridge.methods.get_config().simulate()).token.equals(token.address)) {
|
|
91
|
+
if (!(await bridge.methods.get_config().simulate({ from: owner })).token.equals(token.address)) {
|
|
88
92
|
throw new Error(`Bridge token is not ${token.address}`);
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
// make the bridge a minter on the token:
|
|
92
|
-
await token.methods.set_minter(bridge.address, true).send().wait();
|
|
93
|
-
if ((await token.methods.is_minter(bridge.address).simulate()) === 1n) {
|
|
96
|
+
await token.methods.set_minter(bridge.address, true).send({ from: owner }).wait();
|
|
97
|
+
if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })) === 1n) {
|
|
94
98
|
throw new Error(`Bridge is not a minter`);
|
|
95
99
|
}
|
|
96
100
|
|
|
@@ -131,6 +135,7 @@ export class CrossChainTestHarness {
|
|
|
131
135
|
pxeService: PXE,
|
|
132
136
|
l1Client: ExtendedViemWalletClient,
|
|
133
137
|
wallet: AccountWallet,
|
|
138
|
+
ownerAddress: AztecAddress,
|
|
134
139
|
logger: Logger,
|
|
135
140
|
underlyingERC20Address: EthAddress,
|
|
136
141
|
): Promise<CrossChainTestHarness> {
|
|
@@ -160,14 +165,13 @@ export class CrossChainTestHarness {
|
|
|
160
165
|
l1Client,
|
|
161
166
|
l1ContractAddresses,
|
|
162
167
|
wallet,
|
|
168
|
+
ownerAddress,
|
|
163
169
|
);
|
|
164
170
|
}
|
|
165
171
|
|
|
166
172
|
private readonly l1TokenManager: L1TokenManager;
|
|
167
173
|
private readonly l1TokenPortalManager: L1TokenPortalManager;
|
|
168
174
|
|
|
169
|
-
public readonly ownerAddress: AztecAddress;
|
|
170
|
-
|
|
171
175
|
constructor(
|
|
172
176
|
/** Aztec node instance. */
|
|
173
177
|
public aztecNode: AztecNode,
|
|
@@ -196,6 +200,9 @@ export class CrossChainTestHarness {
|
|
|
196
200
|
|
|
197
201
|
/** Wallet of the owner. */
|
|
198
202
|
public readonly ownerWallet: AccountWallet,
|
|
203
|
+
|
|
204
|
+
/** Owner of the l2 token and bridge */
|
|
205
|
+
public readonly ownerAddress: AztecAddress,
|
|
199
206
|
) {
|
|
200
207
|
this.l1TokenPortalManager = new L1TokenPortalManager(
|
|
201
208
|
this.tokenPortalAddress,
|
|
@@ -235,16 +242,19 @@ export class CrossChainTestHarness {
|
|
|
235
242
|
|
|
236
243
|
async mintTokensPublicOnL2(amount: bigint) {
|
|
237
244
|
this.logger.info('Minting tokens on L2 publicly');
|
|
238
|
-
await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send().wait();
|
|
245
|
+
await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress }).wait();
|
|
239
246
|
}
|
|
240
247
|
|
|
241
248
|
async mintTokensPrivateOnL2(amount: bigint) {
|
|
242
|
-
await mintTokensToPrivate(this.l2Token, this.ownerWallet, this.ownerAddress, amount);
|
|
249
|
+
await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerWallet, this.ownerAddress, amount);
|
|
243
250
|
}
|
|
244
251
|
|
|
245
252
|
async sendL2PublicTransfer(transferAmount: bigint, receiverAddress: AztecAddress) {
|
|
246
253
|
// send a transfer tx to force through rollup with the message included
|
|
247
|
-
await this.l2Token.methods
|
|
254
|
+
await this.l2Token.methods
|
|
255
|
+
.transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0)
|
|
256
|
+
.send({ from: this.ownerAddress })
|
|
257
|
+
.wait();
|
|
248
258
|
}
|
|
249
259
|
|
|
250
260
|
async consumeMessageOnAztecAndMintPrivately(
|
|
@@ -254,7 +264,7 @@ export class CrossChainTestHarness {
|
|
|
254
264
|
const { recipient, claimAmount, claimSecret: secretForL2MessageConsumption, messageLeafIndex } = claim;
|
|
255
265
|
await this.l2Bridge.methods
|
|
256
266
|
.claim_private(recipient, claimAmount, secretForL2MessageConsumption, messageLeafIndex)
|
|
257
|
-
.send()
|
|
267
|
+
.send({ from: this.ownerAddress })
|
|
258
268
|
.wait();
|
|
259
269
|
}
|
|
260
270
|
|
|
@@ -265,7 +275,7 @@ export class CrossChainTestHarness {
|
|
|
265
275
|
const { claimAmount, claimSecret, messageLeafIndex } = claim;
|
|
266
276
|
await this.l2Bridge.methods
|
|
267
277
|
.claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex)
|
|
268
|
-
.send()
|
|
278
|
+
.send({ from: this.ownerAddress })
|
|
269
279
|
.wait();
|
|
270
280
|
}
|
|
271
281
|
|
|
@@ -276,7 +286,7 @@ export class CrossChainTestHarness {
|
|
|
276
286
|
): Promise<FieldsOf<TxReceipt>> {
|
|
277
287
|
const withdrawReceipt = await this.l2Bridge.methods
|
|
278
288
|
.exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
279
|
-
.send({ authWitnesses: [authWitness] })
|
|
289
|
+
.send({ authWitnesses: [authWitness], from: this.ownerAddress })
|
|
280
290
|
.wait();
|
|
281
291
|
|
|
282
292
|
return withdrawReceipt;
|
|
@@ -285,7 +295,7 @@ export class CrossChainTestHarness {
|
|
|
285
295
|
async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<FieldsOf<TxReceipt>> {
|
|
286
296
|
const withdrawReceipt = await this.l2Bridge.methods
|
|
287
297
|
.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
288
|
-
.send()
|
|
298
|
+
.send({ from: this.ownerAddress })
|
|
289
299
|
.wait();
|
|
290
300
|
|
|
291
301
|
return withdrawReceipt;
|
|
@@ -302,7 +312,7 @@ export class CrossChainTestHarness {
|
|
|
302
312
|
}
|
|
303
313
|
|
|
304
314
|
async getL2PublicBalanceOf(owner: AztecAddress) {
|
|
305
|
-
return await this.l2Token.methods.balance_of_public(owner).simulate();
|
|
315
|
+
return await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress });
|
|
306
316
|
}
|
|
307
317
|
|
|
308
318
|
async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -336,14 +346,17 @@ export class CrossChainTestHarness {
|
|
|
336
346
|
|
|
337
347
|
async transferToPrivateOnL2(shieldAmount: bigint) {
|
|
338
348
|
this.logger.info('Transferring to private on L2');
|
|
339
|
-
await this.l2Token.methods
|
|
349
|
+
await this.l2Token.methods
|
|
350
|
+
.transfer_to_private(this.ownerAddress, shieldAmount)
|
|
351
|
+
.send({ from: this.ownerAddress })
|
|
352
|
+
.wait();
|
|
340
353
|
}
|
|
341
354
|
|
|
342
355
|
async transferToPublicOnL2(amount: bigint, authwitNonce = Fr.ZERO) {
|
|
343
356
|
this.logger.info('Transferring tokens to public');
|
|
344
357
|
await this.l2Token.methods
|
|
345
358
|
.transfer_to_public(this.ownerAddress, this.ownerAddress, amount, authwitNonce)
|
|
346
|
-
.send()
|
|
359
|
+
.send({ from: this.ownerAddress })
|
|
347
360
|
.wait();
|
|
348
361
|
}
|
|
349
362
|
|
|
@@ -22,7 +22,7 @@ import { getContract } from 'viem';
|
|
|
22
22
|
export interface IGasBridgingTestHarness {
|
|
23
23
|
getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
|
|
24
24
|
prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress): Promise<L2AmountClaim>;
|
|
25
|
-
bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress): Promise<void>;
|
|
25
|
+
bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress, claimer: AztecAddress): Promise<void>;
|
|
26
26
|
feeJuice: FeeJuiceContract;
|
|
27
27
|
l1FeeJuiceAddress: EthAddress;
|
|
28
28
|
}
|
|
@@ -141,14 +141,14 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
141
141
|
return this.feeJuicePortalManager.bridgeTokensPublic(l2Address, bridgeAmount, false);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
async consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claim: L2AmountClaim) {
|
|
144
|
+
async consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claimer: AztecAddress, claim: L2AmountClaim) {
|
|
145
145
|
this.logger.info('Consuming messages on L2 Privately');
|
|
146
146
|
const { claimAmount, claimSecret, messageLeafIndex } = claim;
|
|
147
|
-
await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send().wait();
|
|
147
|
+
await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send({ from: claimer }).wait();
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
async getL2PublicBalanceOf(owner: AztecAddress) {
|
|
151
|
-
return await this.feeJuice.methods.balance_of_public(owner).simulate();
|
|
151
|
+
return await this.feeJuice.methods.balance_of_public(owner).simulate({ from: owner });
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -170,12 +170,12 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
170
170
|
return claim;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
async bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress) {
|
|
173
|
+
async bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress, claimer: AztecAddress) {
|
|
174
174
|
// Prepare the tokens on the L1 side
|
|
175
175
|
const claim = await this.prepareTokensOnL1(bridgeAmount, owner);
|
|
176
176
|
|
|
177
177
|
// Consume L1 -> L2 message and claim tokens privately on L2
|
|
178
|
-
await this.consumeMessageOnAztecAndClaimPrivately(owner, claim);
|
|
178
|
+
await this.consumeMessageOnAztecAndClaimPrivately(owner, claimer, claim);
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
private async advanceL2Block() {
|