@aztec/aztec.js 0.85.0 → 0.86.0
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/ethereum/portal_manager.d.ts +12 -16
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +32 -39
- package/dest/test/anvil_test_watcher.d.ts +2 -2
- package/dest/test/anvil_test_watcher.d.ts.map +1 -1
- package/dest/test/anvil_test_watcher.js +2 -2
- package/dest/test/rollup_cheat_codes.d.ts +5 -1
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +20 -0
- package/package.json +9 -11
- package/src/ethereum/portal_manager.ts +34 -39
- package/src/test/anvil_test_watcher.ts +4 -4
- package/src/test/rollup_cheat_codes.ts +23 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExtendedViemWalletClient, ViemContract } from '@aztec/ethereum';
|
|
2
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import type { Logger } from '@aztec/foundation/log';
|
|
@@ -6,7 +6,7 @@ import type { SiblingPath } from '@aztec/foundation/trees';
|
|
|
6
6
|
import { TokenPortalAbi } from '@aztec/l1-artifacts/TokenPortalAbi';
|
|
7
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
8
|
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
9
|
-
import { type
|
|
9
|
+
import { type Hex } from 'viem';
|
|
10
10
|
import type { Wallet } from '../index.js';
|
|
11
11
|
/** L1 to L2 message info to claim it on L2. */
|
|
12
12
|
export type L2Claim = {
|
|
@@ -35,8 +35,7 @@ export declare class L1TokenManager {
|
|
|
35
35
|
readonly tokenAddress: EthAddress;
|
|
36
36
|
/** Address of the handler/faucet contract. */
|
|
37
37
|
readonly handlerAddress: EthAddress | undefined;
|
|
38
|
-
private
|
|
39
|
-
private walletClient;
|
|
38
|
+
private readonly extendedClient;
|
|
40
39
|
private logger;
|
|
41
40
|
private contract;
|
|
42
41
|
private handler;
|
|
@@ -44,7 +43,7 @@ export declare class L1TokenManager {
|
|
|
44
43
|
/** Address of the ERC20 contract. */
|
|
45
44
|
tokenAddress: EthAddress,
|
|
46
45
|
/** Address of the handler/faucet contract. */
|
|
47
|
-
handlerAddress: EthAddress | undefined,
|
|
46
|
+
handlerAddress: EthAddress | undefined, extendedClient: ExtendedViemWalletClient, logger: Logger);
|
|
48
47
|
/** Returns the amount of tokens available to mint via the handler.
|
|
49
48
|
* @throws if the handler is not provided.
|
|
50
49
|
*/
|
|
@@ -70,12 +69,11 @@ export declare class L1TokenManager {
|
|
|
70
69
|
}
|
|
71
70
|
/** Helper for interacting with the FeeJuicePortal on L1. */
|
|
72
71
|
export declare class L1FeeJuicePortalManager {
|
|
73
|
-
private readonly
|
|
74
|
-
private readonly walletClient;
|
|
72
|
+
private readonly extendedClient;
|
|
75
73
|
private readonly logger;
|
|
76
74
|
private readonly tokenManager;
|
|
77
75
|
private readonly contract;
|
|
78
|
-
constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress,
|
|
76
|
+
constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress, extendedClient: ExtendedViemWalletClient, logger: Logger);
|
|
79
77
|
/** Returns the associated token manager for the L1 ERC20. */
|
|
80
78
|
getTokenManager(): L1TokenManager;
|
|
81
79
|
/**
|
|
@@ -88,20 +86,18 @@ export declare class L1FeeJuicePortalManager {
|
|
|
88
86
|
/**
|
|
89
87
|
* Creates a new instance
|
|
90
88
|
* @param walletOrPxe - Wallet or PXE client used for retrieving the L1 contract addresses.
|
|
91
|
-
* @param
|
|
92
|
-
* @param walletClient - L1 wallet client.
|
|
89
|
+
* @param extendedClient - Wallet client, extended with public actions.
|
|
93
90
|
* @param logger - Logger.
|
|
94
91
|
*/
|
|
95
|
-
static new(walletOrPxe: Wallet | PXE,
|
|
92
|
+
static new(walletOrPxe: Wallet | PXE, extendedClient: ExtendedViemWalletClient, logger: Logger): Promise<L1FeeJuicePortalManager>;
|
|
96
93
|
}
|
|
97
94
|
/** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */
|
|
98
95
|
export declare class L1ToL2TokenPortalManager {
|
|
99
|
-
protected
|
|
100
|
-
protected walletClient: ViemWalletClient;
|
|
96
|
+
protected extendedClient: ExtendedViemWalletClient;
|
|
101
97
|
protected logger: Logger;
|
|
102
|
-
protected readonly portal:
|
|
98
|
+
protected readonly portal: ViemContract<typeof TokenPortalAbi>;
|
|
103
99
|
protected readonly tokenManager: L1TokenManager;
|
|
104
|
-
constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress | undefined,
|
|
100
|
+
constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress | undefined, extendedClient: ExtendedViemWalletClient, logger: Logger);
|
|
105
101
|
/** Returns the token manager for the underlying L1 token. */
|
|
106
102
|
getTokenManager(): L1TokenManager;
|
|
107
103
|
/**
|
|
@@ -123,7 +119,7 @@ export declare class L1ToL2TokenPortalManager {
|
|
|
123
119
|
/** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */
|
|
124
120
|
export declare class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
125
121
|
private readonly outbox;
|
|
126
|
-
constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress | undefined, outboxAddress: EthAddress,
|
|
122
|
+
constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress | undefined, outboxAddress: EthAddress, extendedClient: ExtendedViemWalletClient, logger: Logger);
|
|
127
123
|
/**
|
|
128
124
|
* Withdraws funds from the portal by consuming an L2 to L1 message. Returns once the tx is mined on L1.
|
|
129
125
|
* @param amount - Amount to withdraw.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal_manager.d.ts","sourceRoot":"","sources":["../../src/ethereum/portal_manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"portal_manager.d.ts","sourceRoot":"","sources":["../../src/ethereum/portal_manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG9E,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAK3D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,KAAK,GAAG,EAAmC,MAAM,MAAM,CAAC;AAEjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAI1C,+CAA+C;AAC/C,MAAM,MAAM,OAAO,GAAG;IACpB,2BAA2B;IAC3B,WAAW,EAAE,EAAE,CAAC;IAChB,uCAAuC;IACvC,eAAe,EAAE,EAAE,CAAC;IACpB,2BAA2B;IAC3B,WAAW,EAAE,GAAG,CAAC;IACjB,+CAA+C;IAC/C,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAGF,oEAAoE;AACpE,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG;IAAyB,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAGrF,8FAA8F;AAC9F,MAAM,MAAM,0BAA0B,GAAG,aAAa,GAAG;IACvD,wDAAwD,CAAC,SAAS,EAAE,YAAY,CAAC;CAClF,CAAC;AAOF,8CAA8C;AAC9C,wBAAsB,mBAAmB,C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Y,EAAE,MAAM,EACpB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC;IA+BlC;;;;;;OAMG;IACU,oBAAoB,CAC/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,YAAY,EACtB,UAAU,GAAE,UAA4B,GACvC,OAAO,CAAC,EAAE,CAAC;CAmBf"}
|
|
@@ -24,27 +24,25 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
24
24
|
/** Helper for managing an ERC20 on L1. */ export class L1TokenManager {
|
|
25
25
|
tokenAddress;
|
|
26
26
|
handlerAddress;
|
|
27
|
-
|
|
28
|
-
walletClient;
|
|
27
|
+
extendedClient;
|
|
29
28
|
logger;
|
|
30
29
|
contract;
|
|
31
30
|
handler;
|
|
32
|
-
constructor(/** Address of the ERC20 contract. */ tokenAddress, /** Address of the handler/faucet contract. */ handlerAddress,
|
|
31
|
+
constructor(/** Address of the ERC20 contract. */ tokenAddress, /** Address of the handler/faucet contract. */ handlerAddress, extendedClient, logger){
|
|
33
32
|
this.tokenAddress = tokenAddress;
|
|
34
33
|
this.handlerAddress = handlerAddress;
|
|
35
|
-
this.
|
|
36
|
-
this.walletClient = walletClient;
|
|
34
|
+
this.extendedClient = extendedClient;
|
|
37
35
|
this.logger = logger;
|
|
38
36
|
this.contract = getContract({
|
|
39
37
|
address: this.tokenAddress.toString(),
|
|
40
38
|
abi: TestERC20Abi,
|
|
41
|
-
client: this.
|
|
39
|
+
client: this.extendedClient
|
|
42
40
|
});
|
|
43
41
|
if (this.handlerAddress) {
|
|
44
42
|
this.handler = getContract({
|
|
45
43
|
address: this.handlerAddress.toString(),
|
|
46
44
|
abi: FeeAssetHandlerAbi,
|
|
47
|
-
client: this.
|
|
45
|
+
client: this.extendedClient
|
|
48
46
|
});
|
|
49
47
|
}
|
|
50
48
|
}
|
|
@@ -86,7 +84,7 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
86
84
|
* @param addressName - Optional name of the address for logging.
|
|
87
85
|
*/ async approve(amount, address, addressName = '') {
|
|
88
86
|
this.logger.info(`Approving ${amount} tokens for ${stringifyEthAddress(address, addressName)}`);
|
|
89
|
-
await this.
|
|
87
|
+
await this.extendedClient.waitForTransactionReceipt({
|
|
90
88
|
hash: await this.contract.write.approve([
|
|
91
89
|
address,
|
|
92
90
|
amount
|
|
@@ -95,20 +93,18 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
95
|
/** Helper for interacting with the FeeJuicePortal on L1. */ export class L1FeeJuicePortalManager {
|
|
98
|
-
|
|
99
|
-
walletClient;
|
|
96
|
+
extendedClient;
|
|
100
97
|
logger;
|
|
101
98
|
tokenManager;
|
|
102
99
|
contract;
|
|
103
|
-
constructor(portalAddress, tokenAddress, handlerAddress,
|
|
104
|
-
this.
|
|
105
|
-
this.walletClient = walletClient;
|
|
100
|
+
constructor(portalAddress, tokenAddress, handlerAddress, extendedClient, logger){
|
|
101
|
+
this.extendedClient = extendedClient;
|
|
106
102
|
this.logger = logger;
|
|
107
|
-
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress,
|
|
103
|
+
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, extendedClient, logger);
|
|
108
104
|
this.contract = getContract({
|
|
109
105
|
address: portalAddress.toString(),
|
|
110
106
|
abi: FeeJuicePortalAbi,
|
|
111
|
-
client:
|
|
107
|
+
client: extendedClient
|
|
112
108
|
});
|
|
113
109
|
}
|
|
114
110
|
/** Returns the associated token manager for the L1 ERC20. */ getTokenManager() {
|
|
@@ -127,7 +123,7 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
127
123
|
if (amountToBridge !== mintableAmount) {
|
|
128
124
|
throw new Error(`Minting amount must be ${mintableAmount}`);
|
|
129
125
|
}
|
|
130
|
-
await this.tokenManager.mint(this.
|
|
126
|
+
await this.tokenManager.mint(this.extendedClient.account.address);
|
|
131
127
|
}
|
|
132
128
|
await this.tokenManager.approve(amountToBridge, this.contract.address, 'FeeJuice Portal');
|
|
133
129
|
this.logger.info('Sending L1 Fee Juice to L2 to be claimed publicly');
|
|
@@ -137,7 +133,7 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
137
133
|
claimSecretHash.toString()
|
|
138
134
|
];
|
|
139
135
|
await this.contract.simulate.depositToAztecPublic(args);
|
|
140
|
-
const txReceipt = await this.
|
|
136
|
+
const txReceipt = await this.extendedClient.waitForTransactionReceipt({
|
|
141
137
|
hash: await this.contract.write.depositToAztecPublic(args)
|
|
142
138
|
});
|
|
143
139
|
this.logger.info('Deposited to Aztec public successfully');
|
|
@@ -153,10 +149,9 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
153
149
|
/**
|
|
154
150
|
* Creates a new instance
|
|
155
151
|
* @param walletOrPxe - Wallet or PXE client used for retrieving the L1 contract addresses.
|
|
156
|
-
* @param
|
|
157
|
-
* @param walletClient - L1 wallet client.
|
|
152
|
+
* @param extendedClient - Wallet client, extended with public actions.
|
|
158
153
|
* @param logger - Logger.
|
|
159
|
-
*/ static async new(walletOrPxe,
|
|
154
|
+
*/ static async new(walletOrPxe, extendedClient, logger) {
|
|
160
155
|
const { l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress, feeAssetHandlerAddress } } = await walletOrPxe.getNodeInfo();
|
|
161
156
|
if (feeJuiceAddress.isZero() || feeJuicePortalAddress.isZero()) {
|
|
162
157
|
throw new Error('Portal or token not deployed on L1');
|
|
@@ -164,24 +159,22 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
164
159
|
if (!feeAssetHandlerAddress || feeAssetHandlerAddress.isZero()) {
|
|
165
160
|
throw new Error('Handler not deployed on L1, or handler address is zero');
|
|
166
161
|
}
|
|
167
|
-
return new L1FeeJuicePortalManager(feeJuicePortalAddress, feeJuiceAddress, feeAssetHandlerAddress,
|
|
162
|
+
return new L1FeeJuicePortalManager(feeJuicePortalAddress, feeJuiceAddress, feeAssetHandlerAddress, extendedClient, logger);
|
|
168
163
|
}
|
|
169
164
|
}
|
|
170
165
|
/** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */ export class L1ToL2TokenPortalManager {
|
|
171
|
-
|
|
172
|
-
walletClient;
|
|
166
|
+
extendedClient;
|
|
173
167
|
logger;
|
|
174
168
|
portal;
|
|
175
169
|
tokenManager;
|
|
176
|
-
constructor(portalAddress, tokenAddress, handlerAddress,
|
|
177
|
-
this.
|
|
178
|
-
this.walletClient = walletClient;
|
|
170
|
+
constructor(portalAddress, tokenAddress, handlerAddress, extendedClient, logger){
|
|
171
|
+
this.extendedClient = extendedClient;
|
|
179
172
|
this.logger = logger;
|
|
180
|
-
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress,
|
|
173
|
+
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, extendedClient, logger);
|
|
181
174
|
this.portal = getContract({
|
|
182
175
|
address: portalAddress.toString(),
|
|
183
176
|
abi: TokenPortalAbi,
|
|
184
|
-
client:
|
|
177
|
+
client: extendedClient
|
|
185
178
|
});
|
|
186
179
|
}
|
|
187
180
|
/** Returns the token manager for the underlying L1 token. */ getTokenManager() {
|
|
@@ -200,8 +193,8 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
200
193
|
amount,
|
|
201
194
|
claimSecretHash.toString()
|
|
202
195
|
]);
|
|
203
|
-
const txReceipt = await this.
|
|
204
|
-
hash: await this.
|
|
196
|
+
const txReceipt = await this.extendedClient.waitForTransactionReceipt({
|
|
197
|
+
hash: await this.extendedClient.writeContract(request)
|
|
205
198
|
});
|
|
206
199
|
const log = extractEvent(txReceipt.logs, this.portal.address, this.portal.abi, 'DepositToAztecPublic', (log)=>log.args.secretHash === claimSecretHash.toString() && log.args.amount === amount && log.args.to === to.toString(), this.logger);
|
|
207
200
|
return {
|
|
@@ -226,8 +219,8 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
226
219
|
amount,
|
|
227
220
|
claimSecretHash.toString()
|
|
228
221
|
]);
|
|
229
|
-
const txReceipt = await this.
|
|
230
|
-
hash: await this.
|
|
222
|
+
const txReceipt = await this.extendedClient.waitForTransactionReceipt({
|
|
223
|
+
hash: await this.extendedClient.writeContract(request)
|
|
231
224
|
});
|
|
232
225
|
const log = extractEvent(txReceipt.logs, this.portal.address, this.portal.abi, 'DepositToAztecPrivate', (log)=>log.args.amount === amount && log.args.secretHashForL2MessageConsumption === claimSecretHash.toString(), this.logger);
|
|
233
226
|
this.logger.info(`Claim message secret: ${claimSecret.toString()}, claim message secret hash: ${claimSecretHash.toString()}`);
|
|
@@ -246,7 +239,7 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
246
239
|
if (amount !== mintableAmount) {
|
|
247
240
|
throw new Error(`Minting amount must be ${mintableAmount} for testing`);
|
|
248
241
|
}
|
|
249
|
-
await this.tokenManager.mint(this.
|
|
242
|
+
await this.tokenManager.mint(this.extendedClient.account.address);
|
|
250
243
|
}
|
|
251
244
|
await this.tokenManager.approve(amount, this.portal.address, 'TokenPortal');
|
|
252
245
|
return generateClaimSecret();
|
|
@@ -254,12 +247,12 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
254
247
|
}
|
|
255
248
|
/** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
256
249
|
outbox;
|
|
257
|
-
constructor(portalAddress, tokenAddress, handlerAddress, outboxAddress,
|
|
258
|
-
super(portalAddress, tokenAddress, handlerAddress,
|
|
250
|
+
constructor(portalAddress, tokenAddress, handlerAddress, outboxAddress, extendedClient, logger){
|
|
251
|
+
super(portalAddress, tokenAddress, handlerAddress, extendedClient, logger);
|
|
259
252
|
this.outbox = getContract({
|
|
260
253
|
address: outboxAddress.toString(),
|
|
261
254
|
abi: OutboxAbi,
|
|
262
|
-
client:
|
|
255
|
+
client: extendedClient
|
|
263
256
|
});
|
|
264
257
|
}
|
|
265
258
|
/**
|
|
@@ -287,8 +280,8 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
287
280
|
messageIndex,
|
|
288
281
|
siblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
|
|
289
282
|
]);
|
|
290
|
-
await this.
|
|
291
|
-
hash: await this.
|
|
283
|
+
await this.extendedClient.waitForTransactionReceipt({
|
|
284
|
+
hash: await this.extendedClient.writeContract(withdrawRequest)
|
|
292
285
|
});
|
|
293
286
|
const isConsumedAfter = await this.outbox.read.hasMessageBeenConsumedAtBlockAndIndex([
|
|
294
287
|
blockNumber,
|
|
@@ -316,7 +309,7 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
316
309
|
l2Bridge.toBuffer(),
|
|
317
310
|
new Fr(version).toBuffer(),
|
|
318
311
|
EthAddress.fromString(this.portal.address).toBuffer32() ?? Buffer.alloc(32, 0),
|
|
319
|
-
new Fr(this.
|
|
312
|
+
new Fr(this.extendedClient.chain.id).toBuffer(),
|
|
320
313
|
content.toBuffer()
|
|
321
314
|
]);
|
|
322
315
|
return leaf;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ViemClient } from '@aztec/ethereum';
|
|
2
2
|
import type { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
3
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
@@ -20,7 +20,7 @@ export declare class AnvilTestWatcher {
|
|
|
20
20
|
private markingAsProvenRunningPromise?;
|
|
21
21
|
private logger;
|
|
22
22
|
private isMarkingAsProven;
|
|
23
|
-
constructor(cheatcodes: EthCheatCodes, rollupAddress: EthAddress,
|
|
23
|
+
constructor(cheatcodes: EthCheatCodes, rollupAddress: EthAddress, l1Client: ViemClient, dateProvider?: TestDateProvider | undefined);
|
|
24
24
|
setIsMarkingAsProven(isMarkingAsProven: boolean): void;
|
|
25
25
|
setIsSandbox(isSandbox: boolean): void;
|
|
26
26
|
start(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anvil_test_watcher.d.ts","sourceRoot":"","sources":["../../src/test/anvil_test_watcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"anvil_test_watcher.d.ts","sourceRoot":"","sources":["../../src/test/anvil_test_watcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAOhE;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAezB,OAAO,CAAC,UAAU;IAGlB,OAAO,CAAC,YAAY,CAAC;IAjBvB,OAAO,CAAC,SAAS,CAAkB;IAEnC,OAAO,CAAC,MAAM,CAAsD;IACpE,OAAO,CAAC,gBAAgB,CAAmB;IAE3C,OAAO,CAAC,oBAAoB,CAAC,CAAiB;IAC9C,OAAO,CAAC,qBAAqB,CAAC,CAAiB;IAC/C,OAAO,CAAC,6BAA6B,CAAC,CAAiB;IAEvD,OAAO,CAAC,MAAM,CAAiD;IAE/D,OAAO,CAAC,iBAAiB,CAAQ;gBAGvB,UAAU,EAAE,aAAa,EACjC,aAAa,EAAE,UAAU,EACzB,QAAQ,EAAE,UAAU,EACZ,YAAY,CAAC,8BAAkB;IAezC,oBAAoB,CAAC,iBAAiB,EAAE,OAAO;IAI/C,YAAY,CAAC,SAAS,EAAE,OAAO;IAIzB,KAAK;IAwBL,IAAI;IAMJ,OAAO;IAMP,YAAY;IAOZ,cAAc;IAoBd,gBAAgB;CAwCvB"}
|
|
@@ -20,7 +20,7 @@ import { RollupCheatCodes } from './rollup_cheat_codes.js';
|
|
|
20
20
|
markingAsProvenRunningPromise;
|
|
21
21
|
logger;
|
|
22
22
|
isMarkingAsProven;
|
|
23
|
-
constructor(cheatcodes, rollupAddress,
|
|
23
|
+
constructor(cheatcodes, rollupAddress, l1Client, dateProvider){
|
|
24
24
|
this.cheatcodes = cheatcodes;
|
|
25
25
|
this.dateProvider = dateProvider;
|
|
26
26
|
this.isSandbox = false;
|
|
@@ -29,7 +29,7 @@ import { RollupCheatCodes } from './rollup_cheat_codes.js';
|
|
|
29
29
|
this.rollup = getContract({
|
|
30
30
|
address: getAddress(rollupAddress.toString()),
|
|
31
31
|
abi: RollupAbi,
|
|
32
|
-
client:
|
|
32
|
+
client: l1Client
|
|
33
33
|
});
|
|
34
34
|
this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
|
|
35
35
|
rollupAddress
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ViemPublicClient } from '@aztec/ethereum';
|
|
2
2
|
import { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
3
3
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
4
4
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
@@ -22,6 +22,10 @@ export declare class RollupCheatCodes {
|
|
|
22
22
|
/** The pending chain tip */ pending: bigint;
|
|
23
23
|
/** The proven chain tip */ proven: bigint;
|
|
24
24
|
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Logs the current state of the rollup contract.
|
|
27
|
+
*/
|
|
28
|
+
debugRollup(): Promise<void>;
|
|
25
29
|
/** Fetches the epoch and slot duration config from the rollup contract */
|
|
26
30
|
getConfig(): Promise<{
|
|
27
31
|
/** Epoch duration */ epochDuration: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_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,SAAS,EAAE,gBAAgB,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC;IAQ1G,4CAA4C;IAC/B,oBAAoB;IAQjC;;;OAGG;IACU,sBAAsB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM;IAMtE;;;OAGG;IACU,qBAAqB,CAAC,QAAQ,EAAE,MAAM;CAOpD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RollupContract } from '@aztec/ethereum';
|
|
1
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
@@ -43,6 +44,25 @@ import { foundry } from 'viem/chains';
|
|
|
43
44
|
proven: res.provenBlockNumber
|
|
44
45
|
};
|
|
45
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Logs the current state of the rollup contract.
|
|
49
|
+
*/ async debugRollup() {
|
|
50
|
+
const rollup = new RollupContract(this.client, this.rollup.address);
|
|
51
|
+
const pendingNum = await rollup.getBlockNumber();
|
|
52
|
+
const provenNum = await rollup.getProvenBlockNumber();
|
|
53
|
+
const validators = await rollup.getAttesters();
|
|
54
|
+
const committee = await rollup.getCurrentEpochCommittee();
|
|
55
|
+
const archive = await rollup.archive();
|
|
56
|
+
const epochNum = await rollup.getEpochNumber();
|
|
57
|
+
const slot = await this.getSlot();
|
|
58
|
+
this.logger.info(`Pending block num: ${pendingNum}`);
|
|
59
|
+
this.logger.info(`Proven block num: ${provenNum}`);
|
|
60
|
+
this.logger.info(`Validators: ${validators.map((v)=>v.toString()).join(', ')}`);
|
|
61
|
+
this.logger.info(`Committee: ${committee.map((v)=>v.toString()).join(', ')}`);
|
|
62
|
+
this.logger.info(`Archive: ${archive}`);
|
|
63
|
+
this.logger.info(`Epoch num: ${epochNum}`);
|
|
64
|
+
this.logger.info(`Slot: ${slot}`);
|
|
65
|
+
}
|
|
46
66
|
/** Fetches the epoch and slot duration config from the rollup contract */ async getConfig() {
|
|
47
67
|
const [epochDuration, slotDuration] = await Promise.all([
|
|
48
68
|
this.rollup.read.getEpochDuration(),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec.js",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.86.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dest/index.js",
|
|
@@ -38,8 +38,6 @@
|
|
|
38
38
|
"build:dev": "tsc -b --watch",
|
|
39
39
|
"build:ts": "tsc -b",
|
|
40
40
|
"clean": "rm -rf ./dest .tsbuildinfo ./src/account_contract/artifacts",
|
|
41
|
-
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
42
|
-
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
43
41
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
44
42
|
},
|
|
45
43
|
"inherits": [
|
|
@@ -80,14 +78,14 @@
|
|
|
80
78
|
]
|
|
81
79
|
},
|
|
82
80
|
"dependencies": {
|
|
83
|
-
"@aztec/constants": "0.
|
|
84
|
-
"@aztec/entrypoints": "0.
|
|
85
|
-
"@aztec/ethereum": "0.
|
|
86
|
-
"@aztec/foundation": "0.
|
|
87
|
-
"@aztec/l1-artifacts": "0.
|
|
88
|
-
"@aztec/protocol-contracts": "0.
|
|
89
|
-
"@aztec/stdlib": "0.
|
|
90
|
-
"axios": "^1.
|
|
81
|
+
"@aztec/constants": "0.86.0",
|
|
82
|
+
"@aztec/entrypoints": "0.86.0",
|
|
83
|
+
"@aztec/ethereum": "0.86.0",
|
|
84
|
+
"@aztec/foundation": "0.86.0",
|
|
85
|
+
"@aztec/l1-artifacts": "0.86.0",
|
|
86
|
+
"@aztec/protocol-contracts": "0.86.0",
|
|
87
|
+
"@aztec/stdlib": "0.86.0",
|
|
88
|
+
"axios": "^1.8.2",
|
|
91
89
|
"tslib": "^2.4.0",
|
|
92
90
|
"viem": "2.23.7"
|
|
93
91
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExtendedViemWalletClient, ViemContract } from '@aztec/ethereum';
|
|
2
2
|
import { extractEvent } from '@aztec/ethereum/utils';
|
|
3
3
|
import { sha256ToField } from '@aztec/foundation/crypto';
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -14,7 +14,7 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
14
14
|
import { computeSecretHash } from '@aztec/stdlib/hash';
|
|
15
15
|
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
16
16
|
|
|
17
|
-
import { type
|
|
17
|
+
import { type Hex, getContract, toFunctionSelector } from 'viem';
|
|
18
18
|
|
|
19
19
|
import type { Wallet } from '../index.js';
|
|
20
20
|
|
|
@@ -57,28 +57,27 @@ export async function generateClaimSecret(logger?: Logger): Promise<[Fr, Fr]> {
|
|
|
57
57
|
|
|
58
58
|
/** Helper for managing an ERC20 on L1. */
|
|
59
59
|
export class L1TokenManager {
|
|
60
|
-
private contract:
|
|
61
|
-
private handler:
|
|
60
|
+
private contract: ViemContract<typeof TestERC20Abi>;
|
|
61
|
+
private handler: ViemContract<typeof FeeAssetHandlerAbi> | undefined;
|
|
62
62
|
|
|
63
63
|
public constructor(
|
|
64
64
|
/** Address of the ERC20 contract. */
|
|
65
65
|
public readonly tokenAddress: EthAddress,
|
|
66
66
|
/** Address of the handler/faucet contract. */
|
|
67
67
|
public readonly handlerAddress: EthAddress | undefined,
|
|
68
|
-
private
|
|
69
|
-
private walletClient: ViemWalletClient,
|
|
68
|
+
private readonly extendedClient: ExtendedViemWalletClient,
|
|
70
69
|
private logger: Logger,
|
|
71
70
|
) {
|
|
72
71
|
this.contract = getContract({
|
|
73
72
|
address: this.tokenAddress.toString(),
|
|
74
73
|
abi: TestERC20Abi,
|
|
75
|
-
client: this.
|
|
74
|
+
client: this.extendedClient,
|
|
76
75
|
});
|
|
77
76
|
if (this.handlerAddress) {
|
|
78
77
|
this.handler = getContract({
|
|
79
78
|
address: this.handlerAddress.toString(),
|
|
80
79
|
abi: FeeAssetHandlerAbi,
|
|
81
|
-
client: this.
|
|
80
|
+
client: this.extendedClient,
|
|
82
81
|
});
|
|
83
82
|
}
|
|
84
83
|
}
|
|
@@ -124,7 +123,7 @@ export class L1TokenManager {
|
|
|
124
123
|
*/
|
|
125
124
|
public async approve(amount: bigint, address: Hex, addressName = '') {
|
|
126
125
|
this.logger.info(`Approving ${amount} tokens for ${stringifyEthAddress(address, addressName)}`);
|
|
127
|
-
await this.
|
|
126
|
+
await this.extendedClient.waitForTransactionReceipt({
|
|
128
127
|
hash: await this.contract.write.approve([address, amount]),
|
|
129
128
|
});
|
|
130
129
|
}
|
|
@@ -133,21 +132,20 @@ export class L1TokenManager {
|
|
|
133
132
|
/** Helper for interacting with the FeeJuicePortal on L1. */
|
|
134
133
|
export class L1FeeJuicePortalManager {
|
|
135
134
|
private readonly tokenManager: L1TokenManager;
|
|
136
|
-
private readonly contract:
|
|
135
|
+
private readonly contract: ViemContract<typeof FeeJuicePortalAbi>;
|
|
137
136
|
|
|
138
137
|
constructor(
|
|
139
138
|
portalAddress: EthAddress,
|
|
140
139
|
tokenAddress: EthAddress,
|
|
141
140
|
handlerAddress: EthAddress,
|
|
142
|
-
private readonly
|
|
143
|
-
private readonly walletClient: ViemWalletClient,
|
|
141
|
+
private readonly extendedClient: ExtendedViemWalletClient,
|
|
144
142
|
private readonly logger: Logger,
|
|
145
143
|
) {
|
|
146
|
-
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress,
|
|
144
|
+
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, extendedClient, logger);
|
|
147
145
|
this.contract = getContract({
|
|
148
146
|
address: portalAddress.toString(),
|
|
149
147
|
abi: FeeJuicePortalAbi,
|
|
150
|
-
client:
|
|
148
|
+
client: extendedClient,
|
|
151
149
|
});
|
|
152
150
|
}
|
|
153
151
|
|
|
@@ -170,7 +168,7 @@ export class L1FeeJuicePortalManager {
|
|
|
170
168
|
if (amountToBridge !== mintableAmount) {
|
|
171
169
|
throw new Error(`Minting amount must be ${mintableAmount}`);
|
|
172
170
|
}
|
|
173
|
-
await this.tokenManager.mint(this.
|
|
171
|
+
await this.tokenManager.mint(this.extendedClient.account.address);
|
|
174
172
|
}
|
|
175
173
|
|
|
176
174
|
await this.tokenManager.approve(amountToBridge, this.contract.address, 'FeeJuice Portal');
|
|
@@ -180,7 +178,7 @@ export class L1FeeJuicePortalManager {
|
|
|
180
178
|
|
|
181
179
|
await this.contract.simulate.depositToAztecPublic(args);
|
|
182
180
|
|
|
183
|
-
const txReceipt = await this.
|
|
181
|
+
const txReceipt = await this.extendedClient.waitForTransactionReceipt({
|
|
184
182
|
hash: await this.contract.write.depositToAztecPublic(args),
|
|
185
183
|
});
|
|
186
184
|
|
|
@@ -210,14 +208,12 @@ export class L1FeeJuicePortalManager {
|
|
|
210
208
|
/**
|
|
211
209
|
* Creates a new instance
|
|
212
210
|
* @param walletOrPxe - Wallet or PXE client used for retrieving the L1 contract addresses.
|
|
213
|
-
* @param
|
|
214
|
-
* @param walletClient - L1 wallet client.
|
|
211
|
+
* @param extendedClient - Wallet client, extended with public actions.
|
|
215
212
|
* @param logger - Logger.
|
|
216
213
|
*/
|
|
217
214
|
public static async new(
|
|
218
215
|
walletOrPxe: Wallet | PXE,
|
|
219
|
-
|
|
220
|
-
walletClient: ViemWalletClient,
|
|
216
|
+
extendedClient: ExtendedViemWalletClient,
|
|
221
217
|
logger: Logger,
|
|
222
218
|
): Promise<L1FeeJuicePortalManager> {
|
|
223
219
|
const {
|
|
@@ -235,8 +231,7 @@ export class L1FeeJuicePortalManager {
|
|
|
235
231
|
feeJuicePortalAddress,
|
|
236
232
|
feeJuiceAddress,
|
|
237
233
|
feeAssetHandlerAddress,
|
|
238
|
-
|
|
239
|
-
walletClient,
|
|
234
|
+
extendedClient,
|
|
240
235
|
logger,
|
|
241
236
|
);
|
|
242
237
|
}
|
|
@@ -244,22 +239,21 @@ export class L1FeeJuicePortalManager {
|
|
|
244
239
|
|
|
245
240
|
/** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */
|
|
246
241
|
export class L1ToL2TokenPortalManager {
|
|
247
|
-
protected readonly portal:
|
|
242
|
+
protected readonly portal: ViemContract<typeof TokenPortalAbi>;
|
|
248
243
|
protected readonly tokenManager: L1TokenManager;
|
|
249
244
|
|
|
250
245
|
constructor(
|
|
251
246
|
portalAddress: EthAddress,
|
|
252
247
|
tokenAddress: EthAddress,
|
|
253
248
|
handlerAddress: EthAddress | undefined,
|
|
254
|
-
protected
|
|
255
|
-
protected walletClient: ViemWalletClient,
|
|
249
|
+
protected extendedClient: ExtendedViemWalletClient,
|
|
256
250
|
protected logger: Logger,
|
|
257
251
|
) {
|
|
258
|
-
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress,
|
|
252
|
+
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, extendedClient, logger);
|
|
259
253
|
this.portal = getContract({
|
|
260
254
|
address: portalAddress.toString(),
|
|
261
255
|
abi: TokenPortalAbi,
|
|
262
|
-
client:
|
|
256
|
+
client: extendedClient,
|
|
263
257
|
});
|
|
264
258
|
}
|
|
265
259
|
|
|
@@ -284,8 +278,8 @@ export class L1ToL2TokenPortalManager {
|
|
|
284
278
|
claimSecretHash.toString(),
|
|
285
279
|
]);
|
|
286
280
|
|
|
287
|
-
const txReceipt = await this.
|
|
288
|
-
hash: await this.
|
|
281
|
+
const txReceipt = await this.extendedClient.waitForTransactionReceipt({
|
|
282
|
+
hash: await this.extendedClient.writeContract(request),
|
|
289
283
|
});
|
|
290
284
|
|
|
291
285
|
const log = extractEvent(
|
|
@@ -327,8 +321,8 @@ export class L1ToL2TokenPortalManager {
|
|
|
327
321
|
this.logger.info('Sending L1 tokens to L2 to be claimed privately');
|
|
328
322
|
const { request } = await this.portal.simulate.depositToAztecPrivate([amount, claimSecretHash.toString()]);
|
|
329
323
|
|
|
330
|
-
const txReceipt = await this.
|
|
331
|
-
hash: await this.
|
|
324
|
+
const txReceipt = await this.extendedClient.waitForTransactionReceipt({
|
|
325
|
+
hash: await this.extendedClient.writeContract(request),
|
|
332
326
|
});
|
|
333
327
|
|
|
334
328
|
const log = extractEvent(
|
|
@@ -360,7 +354,7 @@ export class L1ToL2TokenPortalManager {
|
|
|
360
354
|
if (amount !== mintableAmount) {
|
|
361
355
|
throw new Error(`Minting amount must be ${mintableAmount} for testing`);
|
|
362
356
|
}
|
|
363
|
-
await this.tokenManager.mint(this.
|
|
357
|
+
await this.tokenManager.mint(this.extendedClient.account.address);
|
|
364
358
|
}
|
|
365
359
|
await this.tokenManager.approve(amount, this.portal.address, 'TokenPortal');
|
|
366
360
|
return generateClaimSecret();
|
|
@@ -369,22 +363,21 @@ export class L1ToL2TokenPortalManager {
|
|
|
369
363
|
|
|
370
364
|
/** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */
|
|
371
365
|
export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
372
|
-
private readonly outbox:
|
|
366
|
+
private readonly outbox: ViemContract<typeof OutboxAbi>;
|
|
373
367
|
|
|
374
368
|
constructor(
|
|
375
369
|
portalAddress: EthAddress,
|
|
376
370
|
tokenAddress: EthAddress,
|
|
377
371
|
handlerAddress: EthAddress | undefined,
|
|
378
372
|
outboxAddress: EthAddress,
|
|
379
|
-
|
|
380
|
-
walletClient: ViemWalletClient,
|
|
373
|
+
extendedClient: ExtendedViemWalletClient,
|
|
381
374
|
logger: Logger,
|
|
382
375
|
) {
|
|
383
|
-
super(portalAddress, tokenAddress, handlerAddress,
|
|
376
|
+
super(portalAddress, tokenAddress, handlerAddress, extendedClient, logger);
|
|
384
377
|
this.outbox = getContract({
|
|
385
378
|
address: outboxAddress.toString(),
|
|
386
379
|
abi: OutboxAbi,
|
|
387
|
-
client:
|
|
380
|
+
client: extendedClient,
|
|
388
381
|
});
|
|
389
382
|
}
|
|
390
383
|
|
|
@@ -422,7 +415,9 @@ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
|
422
415
|
siblingPath.toBufferArray().map((buf: Buffer): Hex => `0x${buf.toString('hex')}`),
|
|
423
416
|
]);
|
|
424
417
|
|
|
425
|
-
await this.
|
|
418
|
+
await this.extendedClient.waitForTransactionReceipt({
|
|
419
|
+
hash: await this.extendedClient.writeContract(withdrawRequest),
|
|
420
|
+
});
|
|
426
421
|
|
|
427
422
|
const isConsumedAfter = await this.outbox.read.hasMessageBeenConsumedAtBlockAndIndex([blockNumber, messageIndex]);
|
|
428
423
|
if (!isConsumedAfter) {
|
|
@@ -455,7 +450,7 @@ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
|
455
450
|
l2Bridge.toBuffer(),
|
|
456
451
|
new Fr(version).toBuffer(), // aztec version
|
|
457
452
|
EthAddress.fromString(this.portal.address).toBuffer32() ?? Buffer.alloc(32, 0),
|
|
458
|
-
new Fr(this.
|
|
453
|
+
new Fr(this.extendedClient.chain.id).toBuffer(), // chain id
|
|
459
454
|
content.toBuffer(),
|
|
460
455
|
]);
|
|
461
456
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ViemClient } from '@aztec/ethereum';
|
|
2
2
|
import type { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
3
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
@@ -20,7 +20,7 @@ import { RollupCheatCodes } from './rollup_cheat_codes.js';
|
|
|
20
20
|
export class AnvilTestWatcher {
|
|
21
21
|
private isSandbox: boolean = false;
|
|
22
22
|
|
|
23
|
-
private rollup: GetContractReturnType<typeof RollupAbi,
|
|
23
|
+
private rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
|
|
24
24
|
private rollupCheatCodes: RollupCheatCodes;
|
|
25
25
|
|
|
26
26
|
private filledRunningPromise?: RunningPromise;
|
|
@@ -34,13 +34,13 @@ export class AnvilTestWatcher {
|
|
|
34
34
|
constructor(
|
|
35
35
|
private cheatcodes: EthCheatCodes,
|
|
36
36
|
rollupAddress: EthAddress,
|
|
37
|
-
|
|
37
|
+
l1Client: ViemClient,
|
|
38
38
|
private dateProvider?: TestDateProvider,
|
|
39
39
|
) {
|
|
40
40
|
this.rollup = getContract({
|
|
41
41
|
address: getAddress(rollupAddress.toString()),
|
|
42
42
|
abi: RollupAbi,
|
|
43
|
-
client:
|
|
43
|
+
client: l1Client,
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { RollupContract, type ViemPublicClient } from '@aztec/ethereum';
|
|
2
2
|
import { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
3
3
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -54,6 +54,28 @@ export class RollupCheatCodes {
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Logs the current state of the rollup contract.
|
|
59
|
+
*/
|
|
60
|
+
public async debugRollup() {
|
|
61
|
+
const rollup = new RollupContract(this.client, this.rollup.address);
|
|
62
|
+
const pendingNum = await rollup.getBlockNumber();
|
|
63
|
+
const provenNum = await rollup.getProvenBlockNumber();
|
|
64
|
+
const validators = await rollup.getAttesters();
|
|
65
|
+
const committee = await rollup.getCurrentEpochCommittee();
|
|
66
|
+
const archive = await rollup.archive();
|
|
67
|
+
const epochNum = await rollup.getEpochNumber();
|
|
68
|
+
const slot = await this.getSlot();
|
|
69
|
+
|
|
70
|
+
this.logger.info(`Pending block num: ${pendingNum}`);
|
|
71
|
+
this.logger.info(`Proven block num: ${provenNum}`);
|
|
72
|
+
this.logger.info(`Validators: ${validators.map(v => v.toString()).join(', ')}`);
|
|
73
|
+
this.logger.info(`Committee: ${committee.map(v => v.toString()).join(', ')}`);
|
|
74
|
+
this.logger.info(`Archive: ${archive}`);
|
|
75
|
+
this.logger.info(`Epoch num: ${epochNum}`);
|
|
76
|
+
this.logger.info(`Slot: ${slot}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
57
79
|
/** Fetches the epoch and slot duration config from the rollup contract */
|
|
58
80
|
public async getConfig(): Promise<{
|
|
59
81
|
/** Epoch duration */ epochDuration: bigint;
|