@aztec/cli 0.17.0 → 0.77.0-testnet-ignition.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -16
- package/dest/cmds/contracts/index.d.ts +4 -0
- package/dest/cmds/contracts/index.d.ts.map +1 -0
- package/dest/cmds/contracts/index.js +12 -0
- package/dest/cmds/contracts/inspect_contract.d.ts +3 -0
- package/dest/cmds/contracts/inspect_contract.d.ts.map +1 -0
- package/dest/cmds/contracts/inspect_contract.js +37 -0
- package/dest/cmds/{parse_parameter_struct.d.ts → contracts/parse_parameter_struct.d.ts} +1 -4
- package/dest/cmds/contracts/parse_parameter_struct.d.ts.map +1 -0
- package/dest/cmds/contracts/parse_parameter_struct.js +13 -0
- package/dest/cmds/devnet/bootstrap_network.d.ts +3 -0
- package/dest/cmds/devnet/bootstrap_network.d.ts.map +1 -0
- package/dest/cmds/devnet/bootstrap_network.js +196 -0
- package/dest/cmds/devnet/faucet.d.ts +4 -0
- package/dest/cmds/devnet/faucet.d.ts.map +1 -0
- package/dest/cmds/devnet/faucet.js +26 -0
- package/dest/cmds/devnet/index.d.ts +4 -0
- package/dest/cmds/devnet/index.d.ts.map +1 -0
- package/dest/cmds/devnet/index.js +14 -0
- package/dest/cmds/infrastructure/index.d.ts +4 -0
- package/dest/cmds/infrastructure/index.d.ts.map +1 -0
- package/dest/cmds/infrastructure/index.js +24 -0
- package/dest/cmds/infrastructure/sequencers.d.ts +13 -0
- package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -0
- package/dest/cmds/infrastructure/sequencers.js +93 -0
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts +3 -0
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -0
- package/dest/cmds/infrastructure/setup_l2_contract.js +43 -0
- package/dest/cmds/l1/advance_epoch.d.ts +3 -0
- package/dest/cmds/l1/advance_epoch.d.ts.map +1 -0
- package/dest/cmds/l1/advance_epoch.js +10 -0
- package/dest/cmds/l1/assume_proven_through.d.ts +3 -0
- package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -0
- package/dest/cmds/l1/assume_proven_through.js +12 -0
- package/dest/cmds/l1/bridge_erc20.d.ts +4 -0
- package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -0
- package/dest/cmds/l1/bridge_erc20.js +31 -0
- package/dest/cmds/l1/create_l1_account.d.ts +3 -0
- package/dest/cmds/l1/create_l1_account.d.ts.map +1 -0
- package/dest/cmds/l1/create_l1_account.js +15 -0
- package/dest/cmds/l1/deploy_l1_contracts.d.ts +4 -0
- package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +1 -0
- package/dest/cmds/l1/deploy_l1_contracts.js +29 -0
- package/dest/cmds/l1/deploy_l1_verifier.d.ts +5 -0
- package/dest/cmds/l1/deploy_l1_verifier.d.ts.map +1 -0
- package/dest/cmds/l1/deploy_l1_verifier.js +54 -0
- package/dest/cmds/l1/deploy_new_rollup.d.ts +4 -0
- package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -0
- package/dest/cmds/l1/deploy_new_rollup.js +19 -0
- package/dest/cmds/l1/get_l1_addresses.d.ts +4 -0
- package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -0
- package/dest/cmds/l1/get_l1_addresses.js +18 -0
- package/dest/cmds/l1/get_l1_balance.d.ts +4 -0
- package/dest/cmds/l1/get_l1_balance.d.ts.map +1 -0
- package/dest/cmds/l1/get_l1_balance.js +33 -0
- package/dest/cmds/l1/governance_utils.d.ts +50 -0
- package/dest/cmds/l1/governance_utils.d.ts.map +1 -0
- package/dest/cmds/l1/governance_utils.js +85 -0
- package/dest/cmds/l1/index.d.ts +4 -0
- package/dest/cmds/l1/index.d.ts.map +1 -0
- package/dest/cmds/l1/index.js +208 -0
- package/dest/cmds/l1/prover_stats.d.ts +14 -0
- package/dest/cmds/l1/prover_stats.d.ts.map +1 -0
- package/dest/cmds/l1/prover_stats.js +145 -0
- package/dest/cmds/l1/update_l1_validators.d.ts +30 -0
- package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -0
- package/dest/cmds/l1/update_l1_validators.js +186 -0
- package/dest/cmds/misc/compute_selector.d.ts +3 -0
- package/dest/cmds/misc/compute_selector.d.ts.map +1 -0
- package/dest/cmds/misc/compute_selector.js +5 -0
- package/dest/cmds/misc/example_contracts.d.ts +3 -0
- package/dest/cmds/misc/example_contracts.d.ts.map +1 -0
- package/dest/cmds/misc/example_contracts.js +6 -0
- package/dest/cmds/misc/generate_bootnode_enr.d.ts +3 -0
- package/dest/cmds/misc/generate_bootnode_enr.d.ts.map +1 -0
- package/dest/cmds/misc/generate_bootnode_enr.js +5 -0
- package/dest/cmds/misc/generate_p2p_private_key.d.ts +3 -0
- package/dest/cmds/misc/generate_p2p_private_key.d.ts.map +1 -0
- package/dest/cmds/misc/generate_p2p_private_key.js +7 -0
- package/dest/cmds/misc/generate_secret_and_hash.d.ts +3 -0
- package/dest/cmds/misc/generate_secret_and_hash.d.ts.map +1 -0
- package/dest/cmds/misc/generate_secret_and_hash.js +11 -0
- package/dest/cmds/misc/generate_secret_key.d.ts +5 -0
- package/dest/cmds/misc/generate_secret_key.d.ts.map +1 -0
- package/dest/cmds/misc/generate_secret_key.js +6 -0
- package/dest/cmds/misc/index.d.ts +4 -0
- package/dest/cmds/misc/index.d.ts.map +1 -0
- package/dest/cmds/misc/index.js +44 -0
- package/dest/cmds/misc/setup_contracts.d.ts +7 -0
- package/dest/cmds/misc/setup_contracts.d.ts.map +1 -0
- package/dest/cmds/misc/setup_contracts.js +27 -0
- package/dest/cmds/misc/update/common.d.ts.map +1 -0
- package/dest/cmds/misc/update/common.js +3 -0
- package/dest/cmds/misc/update/github.d.ts.map +1 -0
- package/dest/cmds/misc/update/github.js +3 -0
- package/dest/{update → cmds/misc/update}/noir.d.ts +2 -2
- package/dest/cmds/misc/update/noir.d.ts.map +1 -0
- package/dest/cmds/misc/update/noir.js +45 -0
- package/dest/{update → cmds/misc/update}/npm.d.ts +3 -3
- package/dest/cmds/misc/update/npm.d.ts.map +1 -0
- package/dest/cmds/misc/update/npm.js +127 -0
- package/dest/cmds/misc/update/utils.d.ts +14 -0
- package/dest/cmds/misc/update/utils.d.ts.map +1 -0
- package/dest/cmds/misc/update/utils.js +38 -0
- package/dest/cmds/misc/update.d.ts +3 -0
- package/dest/cmds/misc/update.d.ts.map +1 -0
- package/dest/cmds/misc/update.js +52 -0
- package/dest/cmds/pxe/add_contract.d.ts +5 -0
- package/dest/cmds/pxe/add_contract.d.ts.map +1 -0
- package/dest/cmds/pxe/add_contract.js +29 -0
- package/dest/cmds/pxe/block_number.d.ts +3 -0
- package/dest/cmds/pxe/block_number.d.ts.map +1 -0
- package/dest/cmds/pxe/block_number.js +10 -0
- package/dest/cmds/pxe/get_account.d.ts +4 -0
- package/dest/cmds/pxe/get_account.d.ts.map +1 -0
- package/dest/cmds/pxe/get_account.js +10 -0
- package/dest/cmds/pxe/get_accounts.d.ts +3 -0
- package/dest/cmds/pxe/get_accounts.d.ts.map +1 -0
- package/dest/cmds/pxe/get_accounts.js +25 -0
- package/dest/cmds/pxe/get_block.d.ts +3 -0
- package/dest/cmds/pxe/get_block.d.ts.map +1 -0
- package/dest/cmds/pxe/get_block.js +9 -0
- package/dest/cmds/pxe/get_contract_data.d.ts +4 -0
- package/dest/cmds/pxe/get_contract_data.d.ts.map +1 -0
- package/dest/cmds/pxe/get_contract_data.js +31 -0
- package/dest/cmds/pxe/get_current_base_fee.d.ts +3 -0
- package/dest/cmds/pxe/get_current_base_fee.d.ts.map +1 -0
- package/dest/cmds/pxe/get_current_base_fee.js +7 -0
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts +4 -0
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts.map +1 -0
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.js +11 -0
- package/dest/cmds/pxe/get_logs.d.ts +4 -0
- package/dest/cmds/pxe/get_logs.d.ts.map +1 -0
- package/dest/cmds/pxe/get_logs.js +51 -0
- package/dest/cmds/pxe/get_node_info.d.ts +3 -0
- package/dest/cmds/pxe/get_node_info.d.ts.map +1 -0
- package/dest/cmds/pxe/get_node_info.js +61 -0
- package/dest/cmds/pxe/get_pxe_info.d.ts +3 -0
- package/dest/cmds/pxe/get_pxe_info.d.ts.map +1 -0
- package/dest/cmds/pxe/get_pxe_info.js +11 -0
- package/dest/cmds/pxe/index.d.ts +4 -0
- package/dest/cmds/pxe/index.d.ts.map +1 -0
- package/dest/cmds/pxe/index.js +55 -0
- package/dest/utils/aztec.d.ts +68 -0
- package/dest/utils/aztec.d.ts.map +1 -0
- package/dest/utils/aztec.js +173 -0
- package/dest/{parse_args.d.ts → utils/commands.d.ts} +50 -12
- package/dest/utils/commands.d.ts.map +1 -0
- package/dest/utils/commands.js +303 -0
- package/dest/{encoding.d.ts → utils/encoding.d.ts} +1 -1
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/utils/encoding.js +103 -0
- package/dest/utils/github.d.ts +4 -0
- package/dest/utils/github.d.ts.map +1 -0
- package/dest/utils/github.js +3 -0
- package/dest/utils/index.d.ts +5 -0
- package/dest/utils/index.d.ts.map +1 -0
- package/dest/utils/index.js +4 -0
- package/dest/utils/inspect.d.ts +17 -0
- package/dest/utils/inspect.d.ts.map +1 -0
- package/dest/utils/inspect.js +177 -0
- package/package.json +68 -22
- package/src/cmds/contracts/index.ts +34 -0
- package/src/cmds/contracts/inspect_contract.ts +51 -0
- package/src/cmds/contracts/parse_parameter_struct.ts +27 -0
- package/src/cmds/devnet/bootstrap_network.ts +318 -0
- package/src/cmds/devnet/faucet.ts +33 -0
- package/src/cmds/devnet/index.ts +60 -0
- package/src/cmds/infrastructure/index.ts +55 -0
- package/src/cmds/infrastructure/sequencers.ts +103 -0
- package/src/cmds/infrastructure/setup_l2_contract.ts +47 -0
- package/src/cmds/l1/advance_epoch.ts +12 -0
- package/src/cmds/l1/assume_proven_through.ts +19 -0
- package/src/cmds/l1/bridge_erc20.ts +52 -0
- package/src/cmds/l1/create_l1_account.ts +17 -0
- package/src/cmds/l1/deploy_l1_contracts.ts +63 -0
- package/src/cmds/l1/deploy_l1_verifier.ts +105 -0
- package/src/cmds/l1/deploy_new_rollup.ts +58 -0
- package/src/cmds/l1/get_l1_addresses.ts +30 -0
- package/src/cmds/l1/get_l1_balance.ts +44 -0
- package/src/cmds/l1/governance_utils.ts +187 -0
- package/src/cmds/l1/index.ts +556 -0
- package/src/cmds/l1/prover_stats.ts +202 -0
- package/src/cmds/l1/update_l1_validators.ts +238 -0
- package/src/cmds/misc/compute_selector.ts +7 -0
- package/src/cmds/misc/example_contracts.ts +12 -0
- package/src/cmds/misc/generate_bootnode_enr.ts +12 -0
- package/src/cmds/misc/generate_p2p_private_key.ts +10 -0
- package/src/cmds/misc/generate_secret_and_hash.ts +15 -0
- package/src/cmds/misc/generate_secret_key.ts +5 -0
- package/src/cmds/misc/index.ts +92 -0
- package/src/cmds/misc/setup_contracts.ts +40 -0
- package/src/cmds/misc/update/common.ts +16 -0
- package/src/cmds/misc/update/github.ts +3 -0
- package/src/cmds/misc/update/noir.ts +57 -0
- package/src/cmds/misc/update/npm.ts +154 -0
- package/src/cmds/misc/update/utils.ts +50 -0
- package/src/cmds/misc/update.ts +78 -0
- package/src/cmds/pxe/add_contract.ts +41 -0
- package/src/cmds/pxe/block_number.ts +9 -0
- package/src/cmds/pxe/get_account.ts +16 -0
- package/src/cmds/pxe/get_accounts.ts +35 -0
- package/src/cmds/pxe/get_block.ts +10 -0
- package/src/cmds/pxe/get_contract_data.ts +51 -0
- package/src/cmds/pxe/get_current_base_fee.ts +9 -0
- package/src/cmds/pxe/get_l1_to_l2_message_witness.ts +25 -0
- package/src/cmds/pxe/get_logs.ts +66 -0
- package/src/cmds/pxe/get_node_info.ts +71 -0
- package/src/cmds/pxe/get_pxe_info.ts +13 -0
- package/src/cmds/pxe/index.ts +170 -0
- package/src/utils/aztec.ts +248 -0
- package/src/utils/commands.ts +384 -0
- package/src/utils/encoding.ts +117 -0
- package/src/utils/github.ts +3 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/inspect.ts +208 -0
- package/dest/bin/index.d.ts +0 -3
- package/dest/bin/index.d.ts.map +0 -1
- package/dest/bin/index.js +0 -19
- package/dest/client.d.ts +0 -17
- package/dest/client.d.ts.map +0 -1
- package/dest/client.js +0 -60
- package/dest/cmds/add_contract.d.ts +0 -7
- package/dest/cmds/add_contract.d.ts.map +0 -1
- package/dest/cmds/add_contract.js +0 -15
- package/dest/cmds/add_note.d.ts +0 -8
- package/dest/cmds/add_note.d.ts.map +0 -1
- package/dest/cmds/add_note.js +0 -13
- package/dest/cmds/block_number.d.ts +0 -6
- package/dest/cmds/block_number.d.ts.map +0 -1
- package/dest/cmds/block_number.js +0 -10
- package/dest/cmds/call.d.ts +0 -7
- package/dest/cmds/call.d.ts.map +0 -1
- package/dest/cmds/call.js +0 -18
- package/dest/cmds/check_deploy.d.ts +0 -7
- package/dest/cmds/check_deploy.d.ts.map +0 -1
- package/dest/cmds/check_deploy.js +0 -16
- package/dest/cmds/compute_selector.d.ts +0 -6
- package/dest/cmds/compute_selector.d.ts.map +0 -1
- package/dest/cmds/compute_selector.js +0 -9
- package/dest/cmds/create_account.d.ts +0 -7
- package/dest/cmds/create_account.d.ts.map +0 -1
- package/dest/cmds/create_account.js +0 -31
- package/dest/cmds/deploy.d.ts +0 -7
- package/dest/cmds/deploy.d.ts.map +0 -1
- package/dest/cmds/deploy.js +0 -58
- package/dest/cmds/deploy_l1_contracts.d.ts +0 -6
- package/dest/cmds/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/cmds/deploy_l1_contracts.js +0 -15
- package/dest/cmds/example_contracts.d.ts +0 -6
- package/dest/cmds/example_contracts.d.ts.map +0 -1
- package/dest/cmds/example_contracts.js +0 -10
- package/dest/cmds/generate_p2p_private_key.d.ts +0 -6
- package/dest/cmds/generate_p2p_private_key.d.ts.map +0 -1
- package/dest/cmds/generate_p2p_private_key.js +0 -11
- package/dest/cmds/generate_private_key.d.ts +0 -6
- package/dest/cmds/generate_private_key.d.ts.map +0 -1
- package/dest/cmds/generate_private_key.js +0 -22
- package/dest/cmds/get_account.d.ts +0 -7
- package/dest/cmds/get_account.d.ts.map +0 -1
- package/dest/cmds/get_account.js +0 -15
- package/dest/cmds/get_accounts.d.ts +0 -6
- package/dest/cmds/get_accounts.d.ts.map +0 -1
- package/dest/cmds/get_accounts.js +0 -18
- package/dest/cmds/get_contract_data.d.ts +0 -7
- package/dest/cmds/get_contract_data.d.ts.map +0 -1
- package/dest/cmds/get_contract_data.js +0 -28
- package/dest/cmds/get_logs.d.ts +0 -7
- package/dest/cmds/get_logs.d.ts.map +0 -1
- package/dest/cmds/get_logs.js +0 -54
- package/dest/cmds/get_node_info.d.ts +0 -6
- package/dest/cmds/get_node_info.d.ts.map +0 -1
- package/dest/cmds/get_node_info.js +0 -15
- package/dest/cmds/get_recipient.d.ts +0 -7
- package/dest/cmds/get_recipient.d.ts.map +0 -1
- package/dest/cmds/get_recipient.js +0 -15
- package/dest/cmds/get_recipients.d.ts +0 -6
- package/dest/cmds/get_recipients.d.ts.map +0 -1
- package/dest/cmds/get_recipients.js +0 -18
- package/dest/cmds/get_tx_receipt.d.ts +0 -7
- package/dest/cmds/get_tx_receipt.d.ts.map +0 -1
- package/dest/cmds/get_tx_receipt.js +0 -16
- package/dest/cmds/inspect_contract.d.ts +0 -6
- package/dest/cmds/inspect_contract.d.ts.map +0 -1
- package/dest/cmds/inspect_contract.js +0 -19
- package/dest/cmds/parse_parameter_struct.d.ts.map +0 -1
- package/dest/cmds/parse_parameter_struct.js +0 -20
- package/dest/cmds/register_account.d.ts +0 -7
- package/dest/cmds/register_account.d.ts.map +0 -1
- package/dest/cmds/register_account.js +0 -13
- package/dest/cmds/register_recipient.d.ts +0 -7
- package/dest/cmds/register_recipient.d.ts.map +0 -1
- package/dest/cmds/register_recipient.js +0 -11
- package/dest/cmds/send.d.ts +0 -7
- package/dest/cmds/send.d.ts.map +0 -1
- package/dest/cmds/send.js +0 -27
- package/dest/cmds/unbox.d.ts +0 -7
- package/dest/cmds/unbox.d.ts.map +0 -1
- package/dest/cmds/unbox.js +0 -133
- package/dest/encoding.d.ts.map +0 -1
- package/dest/encoding.js +0 -114
- package/dest/github.d.ts.map +0 -1
- package/dest/github.js +0 -4
- package/dest/index.d.ts +0 -10
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -321
- package/dest/parse_args.d.ts.map +0 -1
- package/dest/parse_args.js +0 -233
- package/dest/test/mocks.d.ts +0 -3
- package/dest/test/mocks.d.ts.map +0 -1
- package/dest/test/mocks.js +0 -65
- package/dest/update/common.d.ts.map +0 -1
- package/dest/update/common.js +0 -2
- package/dest/update/noir.d.ts.map +0 -1
- package/dest/update/noir.js +0 -63
- package/dest/update/npm.d.ts.map +0 -1
- package/dest/update/npm.js +0 -125
- package/dest/update/update.d.ts +0 -3
- package/dest/update/update.d.ts.map +0 -1
- package/dest/update/update.js +0 -58
- package/dest/utils.d.ts +0 -70
- package/dest/utils.d.ts.map +0 -1
- package/dest/utils.js +0 -168
- /package/dest/{update → cmds/misc/update}/common.d.ts +0 -0
- /package/dest/{github.d.ts → cmds/misc/update/github.d.ts} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type AztecAddress, type EthAddress, type Fr, L1ToL2TokenPortalManager } from '@aztec/aztec.js';
|
|
2
|
+
import { createEthereumChain, createL1Clients } from '@aztec/ethereum';
|
|
3
|
+
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
4
|
+
|
|
5
|
+
import { prettyPrintJSON } from '../../utils/commands.js';
|
|
6
|
+
|
|
7
|
+
export async function bridgeERC20(
|
|
8
|
+
amount: bigint,
|
|
9
|
+
recipient: AztecAddress,
|
|
10
|
+
l1RpcUrls: string[],
|
|
11
|
+
chainId: number,
|
|
12
|
+
privateKey: string | undefined,
|
|
13
|
+
mnemonic: string,
|
|
14
|
+
tokenAddress: EthAddress,
|
|
15
|
+
portalAddress: EthAddress,
|
|
16
|
+
privateTransfer: boolean,
|
|
17
|
+
mint: boolean,
|
|
18
|
+
json: boolean,
|
|
19
|
+
log: LogFn,
|
|
20
|
+
debugLogger: Logger,
|
|
21
|
+
) {
|
|
22
|
+
// Prepare L1 client
|
|
23
|
+
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
24
|
+
const { publicClient, walletClient } = createL1Clients(chain.rpcUrls, privateKey ?? mnemonic, chain.chainInfo);
|
|
25
|
+
|
|
26
|
+
// Setup portal manager
|
|
27
|
+
const manager = new L1ToL2TokenPortalManager(portalAddress, tokenAddress, publicClient, walletClient, debugLogger);
|
|
28
|
+
let claimSecret: Fr;
|
|
29
|
+
let messageHash: `0x${string}`;
|
|
30
|
+
if (privateTransfer) {
|
|
31
|
+
({ claimSecret, messageHash } = await manager.bridgeTokensPrivate(recipient, amount, mint));
|
|
32
|
+
} else {
|
|
33
|
+
({ claimSecret, messageHash } = await manager.bridgeTokensPublic(recipient, amount, mint));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (json) {
|
|
37
|
+
log(
|
|
38
|
+
prettyPrintJSON({
|
|
39
|
+
claimAmount: amount,
|
|
40
|
+
claimSecret: claimSecret,
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
} else {
|
|
44
|
+
if (mint) {
|
|
45
|
+
log(`Minted ${amount} tokens on L1 and pushed to L2 portal`);
|
|
46
|
+
} else {
|
|
47
|
+
log(`Bridged ${amount} tokens to L2 portal`);
|
|
48
|
+
}
|
|
49
|
+
log(`claimAmount=${amount},claimSecret=${claimSecret}\n,messageHash=${messageHash}`);
|
|
50
|
+
log(`Note: You need to wait for two L2 blocks before pulling them from the L2 side`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
|
|
3
|
+
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
4
|
+
|
|
5
|
+
import { prettyPrintJSON } from '../../utils/commands.js';
|
|
6
|
+
|
|
7
|
+
export function createL1Account(json: boolean, log: LogFn) {
|
|
8
|
+
const privateKey = generatePrivateKey();
|
|
9
|
+
const account = privateKeyToAccount(privateKey);
|
|
10
|
+
|
|
11
|
+
if (json) {
|
|
12
|
+
log(prettyPrintJSON({ privateKey, address: account.address }));
|
|
13
|
+
} else {
|
|
14
|
+
log(`Private Key: ${privateKey}`);
|
|
15
|
+
log(`Address: ${account.address}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getInitialTestAccounts } from '@aztec/accounts/testing';
|
|
2
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum';
|
|
3
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
5
|
+
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
6
|
+
|
|
7
|
+
import { deployAztecContracts } from '../../utils/aztec.js';
|
|
8
|
+
|
|
9
|
+
export async function deployL1Contracts(
|
|
10
|
+
rpcUrls: string[],
|
|
11
|
+
chainId: number,
|
|
12
|
+
privateKey: string | undefined,
|
|
13
|
+
mnemonic: string,
|
|
14
|
+
mnemonicIndex: number,
|
|
15
|
+
salt: number | undefined,
|
|
16
|
+
testAccounts: boolean,
|
|
17
|
+
json: boolean,
|
|
18
|
+
initialValidators: EthAddress[],
|
|
19
|
+
log: LogFn,
|
|
20
|
+
debugLogger: Logger,
|
|
21
|
+
) {
|
|
22
|
+
const config = getL1ContractsConfigEnvVars();
|
|
23
|
+
|
|
24
|
+
const initialFundedAccounts = testAccounts ? await getInitialTestAccounts() : [];
|
|
25
|
+
const { genesisBlockHash, genesisArchiveRoot } = await getGenesisValues(initialFundedAccounts.map(a => a.address));
|
|
26
|
+
|
|
27
|
+
const { l1ContractAddresses } = await deployAztecContracts(
|
|
28
|
+
rpcUrls,
|
|
29
|
+
chainId,
|
|
30
|
+
privateKey,
|
|
31
|
+
mnemonic,
|
|
32
|
+
mnemonicIndex,
|
|
33
|
+
salt,
|
|
34
|
+
initialValidators,
|
|
35
|
+
genesisArchiveRoot,
|
|
36
|
+
genesisBlockHash,
|
|
37
|
+
config,
|
|
38
|
+
debugLogger,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (json) {
|
|
42
|
+
log(
|
|
43
|
+
JSON.stringify(
|
|
44
|
+
Object.fromEntries(Object.entries(l1ContractAddresses).map(([k, v]) => [k, v.toString()])),
|
|
45
|
+
null,
|
|
46
|
+
2,
|
|
47
|
+
),
|
|
48
|
+
);
|
|
49
|
+
} else {
|
|
50
|
+
log(`Rollup Address: ${l1ContractAddresses.rollupAddress.toString()}`);
|
|
51
|
+
log(`Registry Address: ${l1ContractAddresses.registryAddress.toString()}`);
|
|
52
|
+
log(`L1 -> L2 Inbox Address: ${l1ContractAddresses.inboxAddress.toString()}`);
|
|
53
|
+
log(`L2 -> L1 Outbox Address: ${l1ContractAddresses.outboxAddress.toString()}`);
|
|
54
|
+
log(`Fee Juice Address: ${l1ContractAddresses.feeJuiceAddress.toString()}`);
|
|
55
|
+
log(`Staking Asset Address: ${l1ContractAddresses.stakingAssetAddress.toString()}`);
|
|
56
|
+
log(`Fee Juice Portal Address: ${l1ContractAddresses.feeJuicePortalAddress.toString()}`);
|
|
57
|
+
log(`CoinIssuer Address: ${l1ContractAddresses.coinIssuerAddress.toString()}`);
|
|
58
|
+
log(`RewardDistributor Address: ${l1ContractAddresses.rewardDistributorAddress.toString()}`);
|
|
59
|
+
log(`GovernanceProposer Address: ${l1ContractAddresses.governanceProposerAddress.toString()}`);
|
|
60
|
+
log(`Governance Address: ${l1ContractAddresses.governanceAddress.toString()}`);
|
|
61
|
+
log(`SlashFactory Address: ${l1ContractAddresses.slashFactoryAddress?.toString()}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
import { createEthereumChain, createL1Clients, deployL1Contract } from '@aztec/ethereum';
|
|
3
|
+
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
4
|
+
import { HonkVerifierAbi, HonkVerifierBytecode } from '@aztec/l1-artifacts';
|
|
5
|
+
|
|
6
|
+
import { InvalidOptionArgumentError } from 'commander';
|
|
7
|
+
import { type Hex, getContract } from 'viem';
|
|
8
|
+
|
|
9
|
+
export async function deployUltraHonkVerifier(
|
|
10
|
+
rollupAddress: Hex | undefined,
|
|
11
|
+
ethRpcUrls: string[],
|
|
12
|
+
l1ChainId: string,
|
|
13
|
+
privateKey: string | undefined,
|
|
14
|
+
mnemonic: string,
|
|
15
|
+
pxeRpcUrl: string,
|
|
16
|
+
bbBinaryPath: string,
|
|
17
|
+
bbWorkingDirectory: string,
|
|
18
|
+
log: LogFn,
|
|
19
|
+
debugLogger: Logger,
|
|
20
|
+
) {
|
|
21
|
+
if (!bbBinaryPath || !bbWorkingDirectory) {
|
|
22
|
+
throw new InvalidOptionArgumentError('Missing path to bb binary and working directory');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { publicClient, walletClient } = createL1Clients(
|
|
26
|
+
ethRpcUrls,
|
|
27
|
+
privateKey ?? mnemonic,
|
|
28
|
+
createEthereumChain(ethRpcUrls, l1ChainId).chainInfo,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
if (!rollupAddress && pxeRpcUrl) {
|
|
32
|
+
const pxe = await createCompatibleClient(pxeRpcUrl, debugLogger);
|
|
33
|
+
const { l1ContractAddresses } = await pxe.getNodeInfo();
|
|
34
|
+
rollupAddress = l1ContractAddresses.rollupAddress.toString();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!rollupAddress) {
|
|
38
|
+
throw new InvalidOptionArgumentError('Missing rollup address');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { RollupAbi } = await import('@aztec/l1-artifacts');
|
|
42
|
+
|
|
43
|
+
const rollup = getContract({
|
|
44
|
+
abi: RollupAbi,
|
|
45
|
+
address: rollupAddress,
|
|
46
|
+
client: walletClient,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const { address: verifierAddress } = await deployL1Contract(
|
|
50
|
+
walletClient,
|
|
51
|
+
publicClient,
|
|
52
|
+
HonkVerifierAbi,
|
|
53
|
+
HonkVerifierBytecode,
|
|
54
|
+
);
|
|
55
|
+
log(`Deployed honk verifier at ${verifierAddress}`);
|
|
56
|
+
|
|
57
|
+
await rollup.write.setEpochVerifier([verifierAddress.toString()]);
|
|
58
|
+
|
|
59
|
+
log(`Rollup accepts only real proofs now`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function deployMockVerifier(
|
|
63
|
+
rollupAddress: Hex | undefined,
|
|
64
|
+
ethRpcUrls: string[],
|
|
65
|
+
l1ChainId: string,
|
|
66
|
+
privateKey: string | undefined,
|
|
67
|
+
mnemonic: string,
|
|
68
|
+
pxeRpcUrl: string,
|
|
69
|
+
log: LogFn,
|
|
70
|
+
debugLogger: Logger,
|
|
71
|
+
) {
|
|
72
|
+
const { publicClient, walletClient } = createL1Clients(
|
|
73
|
+
ethRpcUrls,
|
|
74
|
+
privateKey ?? mnemonic,
|
|
75
|
+
createEthereumChain(ethRpcUrls, l1ChainId).chainInfo,
|
|
76
|
+
);
|
|
77
|
+
const { MockVerifierAbi, MockVerifierBytecode, RollupAbi } = await import('@aztec/l1-artifacts');
|
|
78
|
+
|
|
79
|
+
const { address: mockVerifierAddress } = await deployL1Contract(
|
|
80
|
+
walletClient,
|
|
81
|
+
publicClient,
|
|
82
|
+
MockVerifierAbi,
|
|
83
|
+
MockVerifierBytecode,
|
|
84
|
+
);
|
|
85
|
+
log(`Deployed MockVerifier at ${mockVerifierAddress.toString()}`);
|
|
86
|
+
|
|
87
|
+
if (!rollupAddress && pxeRpcUrl) {
|
|
88
|
+
const pxe = await createCompatibleClient(pxeRpcUrl, debugLogger);
|
|
89
|
+
const { l1ContractAddresses } = await pxe.getNodeInfo();
|
|
90
|
+
rollupAddress = l1ContractAddresses.rollupAddress.toString();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!rollupAddress) {
|
|
94
|
+
throw new InvalidOptionArgumentError('Missing rollup address');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const rollup = getContract({
|
|
98
|
+
abi: RollupAbi,
|
|
99
|
+
address: rollupAddress,
|
|
100
|
+
client: walletClient,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
await rollup.write.setEpochVerifier([mockVerifierAddress.toString()]);
|
|
104
|
+
log(`Rollup accepts only fake proofs now`);
|
|
105
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { getInitialTestAccounts } from '@aztec/accounts/testing';
|
|
2
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum';
|
|
3
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
5
|
+
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
6
|
+
|
|
7
|
+
import { deployNewRollupContracts } from '../../utils/aztec.js';
|
|
8
|
+
|
|
9
|
+
export async function deployNewRollup(
|
|
10
|
+
registryAddress: EthAddress,
|
|
11
|
+
rpcUrls: string[],
|
|
12
|
+
chainId: number,
|
|
13
|
+
privateKey: string | undefined,
|
|
14
|
+
mnemonic: string,
|
|
15
|
+
mnemonicIndex: number,
|
|
16
|
+
salt: number | undefined,
|
|
17
|
+
testAccounts: boolean,
|
|
18
|
+
json: boolean,
|
|
19
|
+
initialValidators: EthAddress[],
|
|
20
|
+
log: LogFn,
|
|
21
|
+
debugLogger: Logger,
|
|
22
|
+
) {
|
|
23
|
+
const config = getL1ContractsConfigEnvVars();
|
|
24
|
+
|
|
25
|
+
const initialFundedAccounts = testAccounts ? await getInitialTestAccounts() : [];
|
|
26
|
+
const { genesisBlockHash, genesisArchiveRoot } = await getGenesisValues(initialFundedAccounts.map(a => a.address));
|
|
27
|
+
|
|
28
|
+
const { payloadAddress, rollup } = await deployNewRollupContracts(
|
|
29
|
+
registryAddress,
|
|
30
|
+
rpcUrls,
|
|
31
|
+
chainId,
|
|
32
|
+
privateKey,
|
|
33
|
+
mnemonic,
|
|
34
|
+
mnemonicIndex,
|
|
35
|
+
salt,
|
|
36
|
+
initialValidators,
|
|
37
|
+
genesisArchiveRoot,
|
|
38
|
+
genesisBlockHash,
|
|
39
|
+
config,
|
|
40
|
+
debugLogger,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (json) {
|
|
44
|
+
log(
|
|
45
|
+
JSON.stringify(
|
|
46
|
+
{
|
|
47
|
+
payloadAddress: payloadAddress.toString(),
|
|
48
|
+
rollupAddress: rollup.address,
|
|
49
|
+
},
|
|
50
|
+
null,
|
|
51
|
+
2,
|
|
52
|
+
),
|
|
53
|
+
);
|
|
54
|
+
} else {
|
|
55
|
+
log(`Payload Address: ${payloadAddress.toString()}`);
|
|
56
|
+
log(`Rollup Address: ${rollup.address}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js';
|
|
2
|
+
import { RegistryContract, type ViemPublicClient, createEthereumChain } from '@aztec/ethereum';
|
|
3
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
4
|
+
|
|
5
|
+
import { createPublicClient, fallback, http } from 'viem';
|
|
6
|
+
|
|
7
|
+
export async function getL1Addresses(
|
|
8
|
+
registryAddress: EthAddress,
|
|
9
|
+
rollupVersion: number | bigint | 'canonical',
|
|
10
|
+
rpcUrls: string[],
|
|
11
|
+
chainId: number,
|
|
12
|
+
json: boolean,
|
|
13
|
+
log: LogFn,
|
|
14
|
+
) {
|
|
15
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
16
|
+
const publicClient: ViemPublicClient = createPublicClient({
|
|
17
|
+
chain: chain.chainInfo,
|
|
18
|
+
transport: fallback(rpcUrls.map(url => http(url))),
|
|
19
|
+
pollingInterval: 100,
|
|
20
|
+
});
|
|
21
|
+
const addresses = await RegistryContract.collectAddresses(publicClient, registryAddress.toString(), rollupVersion);
|
|
22
|
+
|
|
23
|
+
if (json) {
|
|
24
|
+
log(JSON.stringify(addresses, null, 2));
|
|
25
|
+
} else {
|
|
26
|
+
for (const [key, value] of Object.entries(addresses)) {
|
|
27
|
+
log(`${key}: ${value.toString()}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createEthereumChain } from '@aztec/ethereum';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
4
|
+
import { TestERC20Abi } from '@aztec/l1-artifacts';
|
|
5
|
+
|
|
6
|
+
import { createPublicClient, fallback, getContract, http } from 'viem';
|
|
7
|
+
|
|
8
|
+
import { prettyPrintJSON } from '../../utils/commands.js';
|
|
9
|
+
|
|
10
|
+
export async function getL1Balance(
|
|
11
|
+
who: EthAddress,
|
|
12
|
+
token: EthAddress | undefined,
|
|
13
|
+
l1RpcUrls: string[],
|
|
14
|
+
chainId: number,
|
|
15
|
+
json: boolean,
|
|
16
|
+
log: LogFn,
|
|
17
|
+
) {
|
|
18
|
+
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
19
|
+
const publicClient = createPublicClient({
|
|
20
|
+
chain: chain.chainInfo,
|
|
21
|
+
transport: fallback(l1RpcUrls.map(url => http(url))),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
let balance = 0n;
|
|
25
|
+
if (token) {
|
|
26
|
+
const gasL1 = getContract({
|
|
27
|
+
address: token.toString(),
|
|
28
|
+
abi: TestERC20Abi,
|
|
29
|
+
client: publicClient,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
balance = await gasL1.read.balanceOf([who.toString()]);
|
|
33
|
+
} else {
|
|
34
|
+
balance = await publicClient.getBalance({
|
|
35
|
+
address: who.toString(),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (json) {
|
|
40
|
+
log(prettyPrintJSON({ balance }));
|
|
41
|
+
} else {
|
|
42
|
+
log(`L1 balance of ${who.toString()} is ${balance.toString()}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FeeJuiceContract,
|
|
3
|
+
GovernanceContract,
|
|
4
|
+
ProposalState,
|
|
5
|
+
RegistryContract,
|
|
6
|
+
createEthereumChain,
|
|
7
|
+
createL1Clients,
|
|
8
|
+
} from '@aztec/ethereum';
|
|
9
|
+
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
10
|
+
|
|
11
|
+
export async function depositGovernanceTokens({
|
|
12
|
+
registryAddress,
|
|
13
|
+
rpcUrls,
|
|
14
|
+
chainId,
|
|
15
|
+
privateKey,
|
|
16
|
+
mnemonic,
|
|
17
|
+
mnemonicIndex,
|
|
18
|
+
recipient,
|
|
19
|
+
amount,
|
|
20
|
+
debugLogger,
|
|
21
|
+
mint,
|
|
22
|
+
}: {
|
|
23
|
+
registryAddress: `0x${string}`;
|
|
24
|
+
rpcUrls: string[];
|
|
25
|
+
chainId: number;
|
|
26
|
+
privateKey: string | undefined;
|
|
27
|
+
mnemonic: string;
|
|
28
|
+
mnemonicIndex: number;
|
|
29
|
+
recipient: `0x${string}`;
|
|
30
|
+
amount: bigint;
|
|
31
|
+
debugLogger: Logger;
|
|
32
|
+
mint: boolean;
|
|
33
|
+
}) {
|
|
34
|
+
debugLogger.info(`Depositing ${amount} governance tokens to ${recipient}`);
|
|
35
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
36
|
+
const { publicClient, walletClient } = createL1Clients(
|
|
37
|
+
rpcUrls,
|
|
38
|
+
privateKey ?? mnemonic,
|
|
39
|
+
chain.chainInfo,
|
|
40
|
+
mnemonicIndex,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const addresses = await RegistryContract.collectAddresses(publicClient, registryAddress, 'canonical');
|
|
44
|
+
const governanceAddress = addresses.governanceAddress.toString();
|
|
45
|
+
const tokenAddress = addresses.feeJuiceAddress.toString();
|
|
46
|
+
|
|
47
|
+
const feeJuice = new FeeJuiceContract(tokenAddress, publicClient, walletClient);
|
|
48
|
+
const governance = new GovernanceContract(governanceAddress, publicClient, walletClient);
|
|
49
|
+
if (mint) {
|
|
50
|
+
await feeJuice.mint(recipient, amount);
|
|
51
|
+
debugLogger.info(`Minted ${amount} tokens to ${recipient}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
await feeJuice.approve(governanceAddress, amount);
|
|
55
|
+
debugLogger.info(`Approved ${amount} tokens for governance`);
|
|
56
|
+
|
|
57
|
+
await governance.deposit(recipient, amount);
|
|
58
|
+
debugLogger.info(`Deposited ${amount} tokens to ${recipient}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function proposeWithLock({
|
|
62
|
+
payloadAddress,
|
|
63
|
+
registryAddress,
|
|
64
|
+
rpcUrls,
|
|
65
|
+
chainId,
|
|
66
|
+
privateKey,
|
|
67
|
+
mnemonic,
|
|
68
|
+
mnemonicIndex,
|
|
69
|
+
json,
|
|
70
|
+
debugLogger,
|
|
71
|
+
log,
|
|
72
|
+
}: {
|
|
73
|
+
payloadAddress: `0x${string}`;
|
|
74
|
+
registryAddress: `0x${string}`;
|
|
75
|
+
rpcUrls: string[];
|
|
76
|
+
chainId: number;
|
|
77
|
+
privateKey: string | undefined;
|
|
78
|
+
mnemonic: string;
|
|
79
|
+
mnemonicIndex: number;
|
|
80
|
+
debugLogger: Logger;
|
|
81
|
+
log: LogFn;
|
|
82
|
+
json: boolean;
|
|
83
|
+
}) {
|
|
84
|
+
debugLogger.info(`Proposing with lock from ${payloadAddress} to ${registryAddress}`);
|
|
85
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
86
|
+
const clients = createL1Clients(rpcUrls, privateKey ?? mnemonic, chain.chainInfo, mnemonicIndex);
|
|
87
|
+
|
|
88
|
+
const addresses = await RegistryContract.collectAddresses(clients.publicClient, registryAddress, 'canonical');
|
|
89
|
+
const governanceAddress = addresses.governanceAddress.toString();
|
|
90
|
+
|
|
91
|
+
const governance = new GovernanceContract(governanceAddress, clients.publicClient, clients.walletClient);
|
|
92
|
+
|
|
93
|
+
const proposalId = await governance.proposeWithLock({
|
|
94
|
+
payloadAddress,
|
|
95
|
+
withdrawAddress: clients.walletClient.account.address,
|
|
96
|
+
});
|
|
97
|
+
if (json) {
|
|
98
|
+
log(JSON.stringify({ proposalId }, null, 2));
|
|
99
|
+
} else {
|
|
100
|
+
log(`Proposed with lock`);
|
|
101
|
+
log(`Proposal ID: ${proposalId}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function voteOnGovernanceProposal({
|
|
106
|
+
proposalId,
|
|
107
|
+
voteAmount,
|
|
108
|
+
inFavor,
|
|
109
|
+
waitTilActive,
|
|
110
|
+
registryAddress,
|
|
111
|
+
rpcUrls,
|
|
112
|
+
chainId,
|
|
113
|
+
privateKey,
|
|
114
|
+
mnemonic,
|
|
115
|
+
mnemonicIndex,
|
|
116
|
+
debugLogger,
|
|
117
|
+
}: {
|
|
118
|
+
proposalId: bigint;
|
|
119
|
+
voteAmount: bigint | undefined;
|
|
120
|
+
inFavor: boolean;
|
|
121
|
+
waitTilActive: boolean;
|
|
122
|
+
registryAddress: `0x${string}`;
|
|
123
|
+
rpcUrls: string[];
|
|
124
|
+
chainId: number;
|
|
125
|
+
privateKey: string | undefined;
|
|
126
|
+
mnemonic: string;
|
|
127
|
+
mnemonicIndex: number;
|
|
128
|
+
debugLogger: Logger;
|
|
129
|
+
}) {
|
|
130
|
+
debugLogger.info(
|
|
131
|
+
`Voting on proposal ${proposalId} with ${voteAmount ? voteAmount : 'all'} tokens in favor: ${inFavor}`,
|
|
132
|
+
);
|
|
133
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
134
|
+
const clients = createL1Clients(rpcUrls, privateKey ?? mnemonic, chain.chainInfo, mnemonicIndex);
|
|
135
|
+
|
|
136
|
+
const addresses = await RegistryContract.collectAddresses(clients.publicClient, registryAddress, 'canonical');
|
|
137
|
+
const governanceAddress = addresses.governanceAddress.toString();
|
|
138
|
+
|
|
139
|
+
const governance = new GovernanceContract(governanceAddress, clients.publicClient, clients.walletClient);
|
|
140
|
+
const state = await governance.getProposalState(proposalId);
|
|
141
|
+
if (state !== ProposalState.Active && !waitTilActive) {
|
|
142
|
+
debugLogger.warn(`Proposal is not active, but waitTilActive is false. Not voting.`);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
await governance.awaitProposalActive({ proposalId, logger: debugLogger });
|
|
147
|
+
await governance.vote({ proposalId, voteAmount, inFavor, retries: 10, logger: debugLogger });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export async function executeGovernanceProposal({
|
|
151
|
+
proposalId,
|
|
152
|
+
waitTilExecutable,
|
|
153
|
+
registryAddress,
|
|
154
|
+
rpcUrls,
|
|
155
|
+
chainId,
|
|
156
|
+
privateKey,
|
|
157
|
+
mnemonic,
|
|
158
|
+
mnemonicIndex,
|
|
159
|
+
debugLogger,
|
|
160
|
+
}: {
|
|
161
|
+
proposalId: bigint;
|
|
162
|
+
waitTilExecutable: boolean;
|
|
163
|
+
registryAddress: `0x${string}`;
|
|
164
|
+
rpcUrls: string[];
|
|
165
|
+
chainId: number;
|
|
166
|
+
privateKey: string | undefined;
|
|
167
|
+
mnemonic: string;
|
|
168
|
+
mnemonicIndex: number;
|
|
169
|
+
debugLogger: Logger;
|
|
170
|
+
}) {
|
|
171
|
+
debugLogger.info(`Executing proposal ${proposalId}`);
|
|
172
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
173
|
+
const clients = createL1Clients(rpcUrls, privateKey ?? mnemonic, chain.chainInfo, mnemonicIndex);
|
|
174
|
+
|
|
175
|
+
const addresses = await RegistryContract.collectAddresses(clients.publicClient, registryAddress, 'canonical');
|
|
176
|
+
const governanceAddress = addresses.governanceAddress.toString();
|
|
177
|
+
|
|
178
|
+
const governance = new GovernanceContract(governanceAddress, clients.publicClient, clients.walletClient);
|
|
179
|
+
const state = await governance.getProposalState(proposalId);
|
|
180
|
+
if (state !== ProposalState.Executable && !waitTilExecutable) {
|
|
181
|
+
debugLogger.warn(`Proposal is not executable, but waitTilExecutable is false. Not executing.`);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
await governance.awaitProposalExecutable({ proposalId, logger: debugLogger });
|
|
186
|
+
await governance.executeProposal({ proposalId, retries: 10, logger: debugLogger });
|
|
187
|
+
}
|