@aztec/cli 0.86.0-nightly.20250425 → 0.86.0-nightly.20250426

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.
@@ -1 +1 @@
1
- {"version":3,"file":"update_l1_validators.d.ts","sourceRoot":"","sources":["../../../src/cmds/l1/update_l1_validators.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAM3D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,UAAU,CAAC;IAC1B,iBAAiB,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0BAA0B,EAAE,UAAU,CAAC;CACxC;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,KAAK,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,iBAAiB;;;EAQhC;AAED,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,GAAG,EACH,WAAW,GACZ,EAAE,8BAA8B,GAAG,UAAU,GAAG;IAAE,eAAe,EAAE,UAAU,CAAC;IAAC,kBAAkB,EAAE,UAAU,CAAA;CAAE,iBAqC/G;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,GAAG;IAAE,gBAAgB,EAAE,UAAU,CAAA;CAAE,iBAcnE;AAED,wBAAsB,WAAW,CAAC,EAChC,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,aAAa,EACb,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,iBAchC;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,OAAO,EACP,aAAa,EACb,SAAS,EACT,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,iBAyBxD;AAED,wBAAsB,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,iBAAiB,GAAG,UAAU,iBAwBzG"}
1
+ {"version":3,"file":"update_l1_validators.d.ts","sourceRoot":"","sources":["../../../src/cmds/l1/update_l1_validators.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAM3D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,UAAU,CAAC;IAC1B,iBAAiB,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0BAA0B,EAAE,UAAU,CAAC;CACxC;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,KAAK,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,iBAAiB;;;EAQhC;AAED,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,GAAG,EACH,WAAW,GACZ,EAAE,8BAA8B,GAAG,UAAU,GAAG;IAAE,eAAe,EAAE,UAAU,CAAC;IAAC,kBAAkB,EAAE,UAAU,CAAA;CAAE,iBAiD/G;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,GAAG;IAAE,gBAAgB,EAAE,UAAU,CAAA;CAAE,iBAiBnE;AAED,wBAAsB,WAAW,CAAC,EAChC,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,aAAa,EACb,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,iBAgBhC;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,OAAO,EACP,aAAa,EACb,SAAS,EACT,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,iBAyBxD;AAED,wBAAsB,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,iBAAiB,GAAG,UAAU,iBAwBzG"}
@@ -1,6 +1,6 @@
1
- import { EthCheatCodes, RollupContract, createEthereumChain, getExpectedAddress, getL1ContractsConfigEnvVars, isAnvilTestChain } from '@aztec/ethereum';
1
+ import { EthCheatCodes, L1TxUtils, RollupContract, createEthereumChain, createExtendedL1Client, getExpectedAddress, getL1ContractsConfigEnvVars, getPublicClient, isAnvilTestChain } from '@aztec/ethereum';
2
2
  import { ForwarderAbi, ForwarderBytecode, RollupAbi, StakingAssetHandlerAbi } from '@aztec/l1-artifacts';
3
- import { createPublicClient, createWalletClient, fallback, formatEther, getContract, http } from 'viem';
3
+ import { encodeFunctionData, formatEther, getContract } from 'viem';
4
4
  import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
5
5
  export function generateL1Account() {
6
6
  const privateKey = generatePrivateKey();
@@ -13,32 +13,42 @@ export function generateL1Account() {
13
13
  }
14
14
  export async function addL1Validator({ rpcUrls, chainId, privateKey, mnemonic, attesterAddress, proposerEOAAddress, stakingAssetHandlerAddress, log, debugLogger }) {
15
15
  const dualLog = makeDualLog(log, debugLogger);
16
- const publicClient = getPublicClient(rpcUrls, chainId);
17
- const walletClient = getWalletClient(rpcUrls, chainId, privateKey, mnemonic);
16
+ const account = getAccount(privateKey, mnemonic);
17
+ const chain = createEthereumChain(rpcUrls, chainId);
18
+ const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
18
19
  const stakingAssetHandler = getContract({
19
20
  address: stakingAssetHandlerAddress.toString(),
20
21
  abi: StakingAssetHandlerAbi,
21
- client: walletClient
22
+ client: l1Client
22
23
  });
23
24
  const rollup = await stakingAssetHandler.read.getRollup();
24
25
  const forwarderAddress = getExpectedAddress(ForwarderAbi, ForwarderBytecode, [
25
26
  proposerEOAAddress.toString()
26
27
  ], proposerEOAAddress.toString()).address;
27
28
  dualLog(`Adding validator (${attesterAddress}, ${proposerEOAAddress} [forwarder: ${forwarderAddress}]) to rollup ${rollup.toString()}`);
28
- const txHash = await stakingAssetHandler.write.addValidator([
29
- attesterAddress.toString(),
30
- forwarderAddress
31
- ]);
32
- dualLog(`Transaction hash: ${txHash}`);
33
- await publicClient.waitForTransactionReceipt({
34
- hash: txHash
29
+ const l1TxUtils = new L1TxUtils(l1Client, debugLogger);
30
+ const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
31
+ to: stakingAssetHandlerAddress.toString(),
32
+ data: encodeFunctionData({
33
+ abi: StakingAssetHandlerAbi,
34
+ functionName: 'addValidator',
35
+ args: [
36
+ attesterAddress.toString(),
37
+ forwarderAddress
38
+ ]
39
+ }),
40
+ abi: StakingAssetHandlerAbi
41
+ });
42
+ dualLog(`Transaction hash: ${receipt.transactionHash}`);
43
+ await l1Client.waitForTransactionReceipt({
44
+ hash: receipt.transactionHash
35
45
  });
36
46
  if (isAnvilTestChain(chainId)) {
37
47
  dualLog(`Funding validator on L1`);
38
48
  const cheatCodes = new EthCheatCodes(rpcUrls, debugLogger);
39
49
  await cheatCodes.setBalance(proposerEOAAddress, 10n ** 20n);
40
50
  } else {
41
- const balance = await publicClient.getBalance({
51
+ const balance = await l1Client.getBalance({
42
52
  address: proposerEOAAddress.toString()
43
53
  });
44
54
  dualLog(`Proposer balance: ${formatEther(balance)} ETH`);
@@ -49,42 +59,46 @@ export async function addL1Validator({ rpcUrls, chainId, privateKey, mnemonic, a
49
59
  }
50
60
  export async function removeL1Validator({ rpcUrls, chainId, privateKey, mnemonic, validatorAddress, rollupAddress, log, debugLogger }) {
51
61
  const dualLog = makeDualLog(log, debugLogger);
52
- const publicClient = getPublicClient(rpcUrls, chainId);
53
- const walletClient = getWalletClient(rpcUrls, chainId, privateKey, mnemonic);
54
- const rollup = getContract({
55
- address: rollupAddress.toString(),
56
- abi: RollupAbi,
57
- client: walletClient
58
- });
62
+ const account = getAccount(privateKey, mnemonic);
63
+ const chain = createEthereumChain(rpcUrls, chainId);
64
+ const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
65
+ const l1TxUtils = new L1TxUtils(l1Client, debugLogger);
59
66
  dualLog(`Removing validator ${validatorAddress.toString()} from rollup ${rollupAddress.toString()}`);
60
- const txHash = await rollup.write.initiateWithdraw([
61
- validatorAddress.toString(),
62
- validatorAddress.toString()
63
- ]);
64
- dualLog(`Transaction hash: ${txHash}`);
65
- await publicClient.waitForTransactionReceipt({
66
- hash: txHash
67
+ const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
68
+ to: rollupAddress.toString(),
69
+ data: encodeFunctionData({
70
+ abi: RollupAbi,
71
+ functionName: 'initiateWithdraw',
72
+ args: [
73
+ validatorAddress.toString(),
74
+ validatorAddress.toString()
75
+ ]
76
+ })
67
77
  });
78
+ dualLog(`Transaction hash: ${receipt.transactionHash}`);
68
79
  }
69
80
  export async function pruneRollup({ rpcUrls, chainId, privateKey, mnemonic, rollupAddress, log, debugLogger }) {
70
81
  const dualLog = makeDualLog(log, debugLogger);
71
- const publicClient = getPublicClient(rpcUrls, chainId);
72
- const walletClient = getWalletClient(rpcUrls, chainId, privateKey, mnemonic);
73
- const rollup = getContract({
74
- address: rollupAddress.toString(),
75
- abi: RollupAbi,
76
- client: walletClient
77
- });
82
+ const account = getAccount(privateKey, mnemonic);
83
+ const chain = createEthereumChain(rpcUrls, chainId);
84
+ const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
85
+ const l1TxUtils = new L1TxUtils(l1Client, debugLogger);
78
86
  dualLog(`Trying prune`);
79
- const txHash = await rollup.write.prune();
80
- dualLog(`Transaction hash: ${txHash}`);
81
- await publicClient.waitForTransactionReceipt({
82
- hash: txHash
87
+ const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
88
+ to: rollupAddress.toString(),
89
+ data: encodeFunctionData({
90
+ abi: RollupAbi,
91
+ functionName: 'prune'
92
+ })
83
93
  });
94
+ dualLog(`Transaction hash: ${receipt.transactionHash}`);
84
95
  }
85
96
  export async function fastForwardEpochs({ rpcUrls, chainId, rollupAddress, numEpochs, log, debugLogger }) {
86
97
  const dualLog = makeDualLog(log, debugLogger);
87
- const publicClient = getPublicClient(rpcUrls, chainId);
98
+ const publicClient = getPublicClient({
99
+ l1RpcUrls: rpcUrls,
100
+ l1ChainId: chainId
101
+ });
88
102
  const rollup = getContract({
89
103
  address: rollupAddress.toString(),
90
104
  abi: RollupAbi,
@@ -111,7 +125,10 @@ export async function fastForwardEpochs({ rpcUrls, chainId, rollupAddress, numEp
111
125
  }
112
126
  export async function debugRollup({ rpcUrls, chainId, rollupAddress, log }) {
113
127
  const config = getL1ContractsConfigEnvVars();
114
- const publicClient = getPublicClient(rpcUrls, chainId);
128
+ const publicClient = getPublicClient({
129
+ l1RpcUrls: rpcUrls,
130
+ l1ChainId: chainId
131
+ });
115
132
  const rollup = new RollupContract(publicClient, rollupAddress);
116
133
  const pendingNum = await rollup.getBlockNumber();
117
134
  log(`Pending block num: ${pendingNum}`);
@@ -139,22 +156,10 @@ function makeDualLog(log, debugLogger) {
139
156
  debugLogger.info(msg);
140
157
  };
141
158
  }
142
- function getPublicClient(rpcUrls, chainId) {
143
- const chain = createEthereumChain(rpcUrls, chainId);
144
- return createPublicClient({
145
- chain: chain.chainInfo,
146
- transport: fallback(rpcUrls.map((url)=>http(url)))
147
- });
148
- }
149
- function getWalletClient(rpcUrls, chainId, privateKey, mnemonic) {
159
+ function getAccount(privateKey, mnemonic) {
150
160
  if (!privateKey && !mnemonic) {
151
161
  throw new Error('Either privateKey or mnemonic must be provided to create a wallet client');
152
162
  }
153
- const chain = createEthereumChain(rpcUrls, chainId);
154
163
  const account = !privateKey ? mnemonicToAccount(mnemonic) : privateKeyToAccount(`${privateKey.startsWith('0x') ? '' : '0x'}${privateKey}`);
155
- return createWalletClient({
156
- account,
157
- chain: chain.chainInfo,
158
- transport: fallback(rpcUrls.map((url)=>http(url)))
159
- });
164
+ return account;
160
165
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli",
3
- "version": "0.86.0-nightly.20250425",
3
+ "version": "0.86.0-nightly.20250426",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./contracts": "./dest/cmds/contracts/index.js",
@@ -65,15 +65,15 @@
65
65
  ]
66
66
  },
67
67
  "dependencies": {
68
- "@aztec/archiver": "0.86.0-nightly.20250425",
69
- "@aztec/aztec.js": "0.86.0-nightly.20250425",
70
- "@aztec/constants": "0.86.0-nightly.20250425",
71
- "@aztec/entrypoints": "0.86.0-nightly.20250425",
72
- "@aztec/foundation": "0.86.0-nightly.20250425",
73
- "@aztec/l1-artifacts": "0.86.0-nightly.20250425",
74
- "@aztec/p2p": "0.86.0-nightly.20250425",
75
- "@aztec/stdlib": "0.86.0-nightly.20250425",
76
- "@aztec/world-state": "0.86.0-nightly.20250425",
68
+ "@aztec/archiver": "0.86.0-nightly.20250426",
69
+ "@aztec/aztec.js": "0.86.0-nightly.20250426",
70
+ "@aztec/constants": "0.86.0-nightly.20250426",
71
+ "@aztec/entrypoints": "0.86.0-nightly.20250426",
72
+ "@aztec/foundation": "0.86.0-nightly.20250426",
73
+ "@aztec/l1-artifacts": "0.86.0-nightly.20250426",
74
+ "@aztec/p2p": "0.86.0-nightly.20250426",
75
+ "@aztec/stdlib": "0.86.0-nightly.20250426",
76
+ "@aztec/world-state": "0.86.0-nightly.20250426",
77
77
  "@iarna/toml": "^2.2.5",
78
78
  "@libp2p/peer-id-factory": "^3.0.4",
79
79
  "commander": "^12.1.0",
@@ -85,9 +85,9 @@
85
85
  "viem": "2.23.7"
86
86
  },
87
87
  "devDependencies": {
88
- "@aztec/accounts": "0.86.0-nightly.20250425",
89
- "@aztec/ethereum": "0.86.0-nightly.20250425",
90
- "@aztec/protocol-contracts": "0.86.0-nightly.20250425",
88
+ "@aztec/accounts": "0.86.0-nightly.20250426",
89
+ "@aztec/ethereum": "0.86.0-nightly.20250426",
90
+ "@aztec/protocol-contracts": "0.86.0-nightly.20250426",
91
91
  "@jest/globals": "^29.5.0",
92
92
  "@types/jest": "^29.5.0",
93
93
  "@types/lodash.chunk": "^4.2.9",
@@ -103,14 +103,14 @@
103
103
  "typescript": "^5.0.4"
104
104
  },
105
105
  "peerDependencies": {
106
- "@aztec/accounts": "0.86.0-nightly.20250425",
107
- "@aztec/bb-prover": "0.86.0-nightly.20250425",
108
- "@aztec/ethereum": "0.86.0-nightly.20250425",
109
- "@aztec/l1-artifacts": "0.86.0-nightly.20250425",
110
- "@aztec/noir-contracts.js": "0.86.0-nightly.20250425",
111
- "@aztec/noir-protocol-circuits-types": "0.86.0-nightly.20250425",
112
- "@aztec/protocol-contracts": "0.86.0-nightly.20250425",
113
- "@aztec/stdlib": "0.86.0-nightly.20250425"
106
+ "@aztec/accounts": "0.86.0-nightly.20250426",
107
+ "@aztec/bb-prover": "0.86.0-nightly.20250426",
108
+ "@aztec/ethereum": "0.86.0-nightly.20250426",
109
+ "@aztec/l1-artifacts": "0.86.0-nightly.20250426",
110
+ "@aztec/noir-contracts.js": "0.86.0-nightly.20250426",
111
+ "@aztec/noir-protocol-circuits-types": "0.86.0-nightly.20250426",
112
+ "@aztec/protocol-contracts": "0.86.0-nightly.20250426",
113
+ "@aztec/stdlib": "0.86.0-nightly.20250426"
114
114
  },
115
115
  "files": [
116
116
  "dest",
@@ -1,16 +1,19 @@
1
1
  import {
2
2
  EthCheatCodes,
3
+ L1TxUtils,
3
4
  RollupContract,
4
5
  createEthereumChain,
6
+ createExtendedL1Client,
5
7
  getExpectedAddress,
6
8
  getL1ContractsConfigEnvVars,
9
+ getPublicClient,
7
10
  isAnvilTestChain,
8
11
  } from '@aztec/ethereum';
9
12
  import type { EthAddress } from '@aztec/foundation/eth-address';
10
13
  import type { LogFn, Logger } from '@aztec/foundation/log';
11
14
  import { ForwarderAbi, ForwarderBytecode, RollupAbi, StakingAssetHandlerAbi } from '@aztec/l1-artifacts';
12
15
 
13
- import { createPublicClient, createWalletClient, fallback, formatEther, getContract, http } from 'viem';
16
+ import { encodeFunctionData, formatEther, getContract } from 'viem';
14
17
  import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
15
18
 
16
19
  export interface RollupCommandArgs {
@@ -57,13 +60,14 @@ export async function addL1Validator({
57
60
  debugLogger,
58
61
  }: StakingAssetHandlerCommandArgs & LoggerArgs & { attesterAddress: EthAddress; proposerEOAAddress: EthAddress }) {
59
62
  const dualLog = makeDualLog(log, debugLogger);
60
- const publicClient = getPublicClient(rpcUrls, chainId);
61
- const walletClient = getWalletClient(rpcUrls, chainId, privateKey, mnemonic);
63
+ const account = getAccount(privateKey, mnemonic);
64
+ const chain = createEthereumChain(rpcUrls, chainId);
65
+ const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
62
66
 
63
67
  const stakingAssetHandler = getContract({
64
68
  address: stakingAssetHandlerAddress.toString(),
65
69
  abi: StakingAssetHandlerAbi,
66
- client: walletClient,
70
+ client: l1Client,
67
71
  });
68
72
 
69
73
  const rollup = await stakingAssetHandler.read.getRollup();
@@ -78,15 +82,26 @@ export async function addL1Validator({
78
82
  dualLog(
79
83
  `Adding validator (${attesterAddress}, ${proposerEOAAddress} [forwarder: ${forwarderAddress}]) to rollup ${rollup.toString()}`,
80
84
  );
81
- const txHash = await stakingAssetHandler.write.addValidator([attesterAddress.toString(), forwarderAddress]);
82
- dualLog(`Transaction hash: ${txHash}`);
83
- await publicClient.waitForTransactionReceipt({ hash: txHash });
85
+
86
+ const l1TxUtils = new L1TxUtils(l1Client, debugLogger);
87
+
88
+ const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
89
+ to: stakingAssetHandlerAddress.toString(),
90
+ data: encodeFunctionData({
91
+ abi: StakingAssetHandlerAbi,
92
+ functionName: 'addValidator',
93
+ args: [attesterAddress.toString(), forwarderAddress],
94
+ }),
95
+ abi: StakingAssetHandlerAbi,
96
+ });
97
+ dualLog(`Transaction hash: ${receipt.transactionHash}`);
98
+ await l1Client.waitForTransactionReceipt({ hash: receipt.transactionHash });
84
99
  if (isAnvilTestChain(chainId)) {
85
100
  dualLog(`Funding validator on L1`);
86
101
  const cheatCodes = new EthCheatCodes(rpcUrls, debugLogger);
87
102
  await cheatCodes.setBalance(proposerEOAAddress, 10n ** 20n);
88
103
  } else {
89
- const balance = await publicClient.getBalance({ address: proposerEOAAddress.toString() });
104
+ const balance = await l1Client.getBalance({ address: proposerEOAAddress.toString() });
90
105
  dualLog(`Proposer balance: ${formatEther(balance)} ETH`);
91
106
  if (balance === 0n) {
92
107
  dualLog(`WARNING: Proposer has no balance. Remember to fund it!`);
@@ -105,18 +120,21 @@ export async function removeL1Validator({
105
120
  debugLogger,
106
121
  }: RollupCommandArgs & LoggerArgs & { validatorAddress: EthAddress }) {
107
122
  const dualLog = makeDualLog(log, debugLogger);
108
- const publicClient = getPublicClient(rpcUrls, chainId);
109
- const walletClient = getWalletClient(rpcUrls, chainId, privateKey, mnemonic);
110
- const rollup = getContract({
111
- address: rollupAddress.toString(),
112
- abi: RollupAbi,
113
- client: walletClient,
114
- });
123
+ const account = getAccount(privateKey, mnemonic);
124
+ const chain = createEthereumChain(rpcUrls, chainId);
125
+ const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
126
+ const l1TxUtils = new L1TxUtils(l1Client, debugLogger);
115
127
 
116
128
  dualLog(`Removing validator ${validatorAddress.toString()} from rollup ${rollupAddress.toString()}`);
117
- const txHash = await rollup.write.initiateWithdraw([validatorAddress.toString(), validatorAddress.toString()]);
118
- dualLog(`Transaction hash: ${txHash}`);
119
- await publicClient.waitForTransactionReceipt({ hash: txHash });
129
+ const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
130
+ to: rollupAddress.toString(),
131
+ data: encodeFunctionData({
132
+ abi: RollupAbi,
133
+ functionName: 'initiateWithdraw',
134
+ args: [validatorAddress.toString(), validatorAddress.toString()],
135
+ }),
136
+ });
137
+ dualLog(`Transaction hash: ${receipt.transactionHash}`);
120
138
  }
121
139
 
122
140
  export async function pruneRollup({
@@ -129,18 +147,20 @@ export async function pruneRollup({
129
147
  debugLogger,
130
148
  }: RollupCommandArgs & LoggerArgs) {
131
149
  const dualLog = makeDualLog(log, debugLogger);
132
- const publicClient = getPublicClient(rpcUrls, chainId);
133
- const walletClient = getWalletClient(rpcUrls, chainId, privateKey, mnemonic);
134
- const rollup = getContract({
135
- address: rollupAddress.toString(),
136
- abi: RollupAbi,
137
- client: walletClient,
138
- });
150
+ const account = getAccount(privateKey, mnemonic);
151
+ const chain = createEthereumChain(rpcUrls, chainId);
152
+ const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
153
+ const l1TxUtils = new L1TxUtils(l1Client, debugLogger);
139
154
 
140
155
  dualLog(`Trying prune`);
141
- const txHash = await rollup.write.prune();
142
- dualLog(`Transaction hash: ${txHash}`);
143
- await publicClient.waitForTransactionReceipt({ hash: txHash });
156
+ const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
157
+ to: rollupAddress.toString(),
158
+ data: encodeFunctionData({
159
+ abi: RollupAbi,
160
+ functionName: 'prune',
161
+ }),
162
+ });
163
+ dualLog(`Transaction hash: ${receipt.transactionHash}`);
144
164
  }
145
165
 
146
166
  export async function fastForwardEpochs({
@@ -152,7 +172,7 @@ export async function fastForwardEpochs({
152
172
  debugLogger,
153
173
  }: RollupCommandArgs & LoggerArgs & { numEpochs: bigint }) {
154
174
  const dualLog = makeDualLog(log, debugLogger);
155
- const publicClient = getPublicClient(rpcUrls, chainId);
175
+ const publicClient = getPublicClient({ l1RpcUrls: rpcUrls, l1ChainId: chainId });
156
176
  const rollup = getContract({
157
177
  address: rollupAddress.toString(),
158
178
  abi: RollupAbi,
@@ -179,7 +199,7 @@ export async function fastForwardEpochs({
179
199
 
180
200
  export async function debugRollup({ rpcUrls, chainId, rollupAddress, log }: RollupCommandArgs & LoggerArgs) {
181
201
  const config = getL1ContractsConfigEnvVars();
182
- const publicClient = getPublicClient(rpcUrls, chainId);
202
+ const publicClient = getPublicClient({ l1RpcUrls: rpcUrls, l1ChainId: chainId });
183
203
  const rollup = new RollupContract(publicClient, rollupAddress);
184
204
 
185
205
  const pendingNum = await rollup.getBlockNumber();
@@ -210,24 +230,12 @@ function makeDualLog(log: LogFn, debugLogger: Logger) {
210
230
  };
211
231
  }
212
232
 
213
- function getPublicClient(rpcUrls: string[], chainId: number) {
214
- const chain = createEthereumChain(rpcUrls, chainId);
215
- return createPublicClient({ chain: chain.chainInfo, transport: fallback(rpcUrls.map(url => http(url))) });
216
- }
217
-
218
- function getWalletClient(
219
- rpcUrls: string[],
220
- chainId: number,
221
- privateKey: string | undefined,
222
- mnemonic: string | undefined,
223
- ) {
233
+ function getAccount(privateKey: string | undefined, mnemonic: string | undefined) {
224
234
  if (!privateKey && !mnemonic) {
225
235
  throw new Error('Either privateKey or mnemonic must be provided to create a wallet client');
226
236
  }
227
-
228
- const chain = createEthereumChain(rpcUrls, chainId);
229
237
  const account = !privateKey
230
238
  ? mnemonicToAccount(mnemonic!)
231
239
  : privateKeyToAccount(`${privateKey.startsWith('0x') ? '' : '0x'}${privateKey}` as `0x${string}`);
232
- return createWalletClient({ account, chain: chain.chainInfo, transport: fallback(rpcUrls.map(url => http(url))) });
240
+ return account;
233
241
  }