@aztec/cli 0.17.0 → 0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2
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 +9 -15
- package/dest/cmds/contracts/index.js +12 -0
- package/dest/cmds/contracts/inspect_contract.js +37 -0
- package/dest/cmds/contracts/parse_parameter_struct.js +13 -0
- package/dest/cmds/devnet/bootstrap_network.js +193 -0
- package/dest/cmds/devnet/faucet.js +26 -0
- package/dest/cmds/devnet/index.js +12 -0
- package/dest/cmds/infrastructure/index.js +22 -0
- package/dest/cmds/infrastructure/sequencers.js +93 -0
- package/dest/cmds/infrastructure/setup_protocol_contract.js +31 -0
- package/dest/cmds/l1/advance_epoch.js +10 -0
- package/dest/cmds/l1/assume_proven_through.js +12 -0
- package/dest/cmds/l1/bridge_erc20.js +31 -0
- package/dest/cmds/l1/create_l1_account.js +15 -0
- package/dest/cmds/l1/deploy_l1_contracts.js +25 -0
- package/dest/cmds/l1/deploy_l1_verifier.js +54 -0
- package/dest/cmds/l1/get_l1_balance.js +33 -0
- package/dest/cmds/l1/index.js +127 -0
- package/dest/cmds/l1/prover_stats.js +145 -0
- package/dest/cmds/l1/update_l1_validators.js +186 -0
- package/dest/cmds/misc/compute_selector.js +5 -0
- package/dest/cmds/misc/example_contracts.js +6 -0
- package/dest/cmds/misc/generate_p2p_private_key.js +7 -0
- package/dest/cmds/misc/generate_secret_and_hash.js +11 -0
- package/dest/cmds/misc/generate_secret_key.js +6 -0
- package/dest/cmds/misc/index.js +36 -0
- package/dest/cmds/misc/setup_contracts.js +25 -0
- package/dest/cmds/misc/update/common.js +3 -0
- package/dest/cmds/misc/update/github.js +3 -0
- package/dest/cmds/misc/update/noir.js +45 -0
- package/dest/cmds/misc/update/npm.js +127 -0
- package/dest/cmds/misc/update/utils.js +38 -0
- package/dest/cmds/misc/update.js +52 -0
- package/dest/cmds/pxe/add_contract.js +27 -0
- package/dest/cmds/pxe/block_number.js +10 -0
- package/dest/cmds/pxe/get_account.js +10 -0
- package/dest/cmds/pxe/get_accounts.js +25 -0
- package/dest/cmds/pxe/get_block.js +9 -0
- package/dest/cmds/pxe/get_contract_data.js +31 -0
- package/dest/cmds/pxe/get_current_base_fee.js +7 -0
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.js +11 -0
- package/dest/cmds/pxe/get_logs.js +51 -0
- package/dest/cmds/pxe/get_node_info.js +61 -0
- package/dest/cmds/pxe/get_pxe_info.js +11 -0
- package/dest/cmds/pxe/index.js +55 -0
- package/dest/utils/aztec.js +162 -0
- package/dest/utils/commands.js +303 -0
- package/dest/utils/encoding.js +110 -0
- package/dest/utils/github.js +3 -0
- package/dest/utils/index.js +4 -0
- package/dest/utils/inspect.js +177 -0
- package/package.json +67 -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 +306 -0
- package/src/cmds/devnet/faucet.ts +33 -0
- package/src/cmds/devnet/index.ts +52 -0
- package/src/cmds/infrastructure/index.ts +54 -0
- package/src/cmds/infrastructure/sequencers.ts +100 -0
- package/src/cmds/infrastructure/setup_protocol_contract.ts +36 -0
- package/src/cmds/l1/advance_epoch.ts +12 -0
- package/src/cmds/l1/assume_proven_through.ts +25 -0
- package/src/cmds/l1/bridge_erc20.ts +53 -0
- package/src/cmds/l1/create_l1_account.ts +17 -0
- package/src/cmds/l1/deploy_l1_contracts.ts +55 -0
- package/src/cmds/l1/deploy_l1_verifier.ts +105 -0
- package/src/cmds/l1/get_l1_balance.ts +41 -0
- package/src/cmds/l1/index.ts +415 -0
- package/src/cmds/l1/prover_stats.ts +192 -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_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 +70 -0
- package/src/cmds/misc/setup_contracts.ts +38 -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 +39 -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 +49 -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 +218 -0
- package/src/utils/commands.ts +384 -0
- package/src/utils/encoding.ts +123 -0
- package/src/utils/github.ts +3 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/inspect.ts +207 -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 +0 -6
- 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 +0 -15
- package/dest/encoding.d.ts.map +0 -1
- package/dest/encoding.js +0 -114
- package/dest/github.d.ts +0 -4
- 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 +0 -105
- 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 +0 -17
- package/dest/update/common.d.ts.map +0 -1
- package/dest/update/common.js +0 -2
- package/dest/update/noir.d.ts +0 -10
- package/dest/update/noir.d.ts.map +0 -1
- package/dest/update/noir.js +0 -63
- package/dest/update/npm.d.ts +0 -34
- 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
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
2
|
+
import {
|
|
3
|
+
BatchCall,
|
|
4
|
+
L1FeeJuicePortalManager,
|
|
5
|
+
type PXE,
|
|
6
|
+
type WaitOpts,
|
|
7
|
+
type Wallet,
|
|
8
|
+
createCompatibleClient,
|
|
9
|
+
retryUntil,
|
|
10
|
+
} from '@aztec/aztec.js';
|
|
11
|
+
import { type AztecAddress, type EthAddress, FEE_FUNDING_FOR_TESTER_ACCOUNT, Fq, Fr } from '@aztec/circuits.js';
|
|
12
|
+
import {
|
|
13
|
+
type ContractArtifacts,
|
|
14
|
+
type L1Clients,
|
|
15
|
+
createEthereumChain,
|
|
16
|
+
createL1Clients,
|
|
17
|
+
deployL1Contract,
|
|
18
|
+
} from '@aztec/ethereum';
|
|
19
|
+
import { type LogFn, type Logger } from '@aztec/foundation/log';
|
|
20
|
+
|
|
21
|
+
import { getContract } from 'viem';
|
|
22
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
23
|
+
|
|
24
|
+
type ContractDeploymentInfo = {
|
|
25
|
+
address: AztecAddress;
|
|
26
|
+
initHash: Fr;
|
|
27
|
+
salt: Fr;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const waitOpts: WaitOpts = {
|
|
31
|
+
timeout: 120,
|
|
32
|
+
provenTimeout: 4800,
|
|
33
|
+
interval: 1,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export async function bootstrapNetwork(
|
|
37
|
+
pxeUrl: string,
|
|
38
|
+
l1Url: string,
|
|
39
|
+
l1ChainId: string,
|
|
40
|
+
l1PrivateKey: `0x${string}` | undefined,
|
|
41
|
+
l1Mnemonic: string,
|
|
42
|
+
json: boolean,
|
|
43
|
+
log: LogFn,
|
|
44
|
+
debugLog: Logger,
|
|
45
|
+
) {
|
|
46
|
+
const pxe = await createCompatibleClient(pxeUrl, debugLog);
|
|
47
|
+
|
|
48
|
+
// setup a one-off account contract
|
|
49
|
+
const account = await getSchnorrAccount(pxe, Fr.random(), Fq.random(), Fr.random());
|
|
50
|
+
const wallet = await account.deploy().getWallet();
|
|
51
|
+
|
|
52
|
+
const l1Clients = createL1Clients(
|
|
53
|
+
l1Url,
|
|
54
|
+
l1PrivateKey ? privateKeyToAccount(l1PrivateKey) : l1Mnemonic,
|
|
55
|
+
createEthereumChain(l1Url, +l1ChainId).chainInfo,
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const { erc20Address, portalAddress } = await deployERC20(l1Clients);
|
|
59
|
+
|
|
60
|
+
const { token, bridge } = await deployToken(wallet, portalAddress);
|
|
61
|
+
|
|
62
|
+
await initPortal(pxe, l1Clients, erc20Address, portalAddress, bridge.address);
|
|
63
|
+
|
|
64
|
+
const fpcAdmin = wallet.getAddress();
|
|
65
|
+
const fpc = await deployFPC(wallet, token.address, fpcAdmin);
|
|
66
|
+
|
|
67
|
+
const counter = await deployCounter(wallet);
|
|
68
|
+
// NOTE: Disabling for now in order to get devnet running
|
|
69
|
+
await fundFPC(counter.address, wallet, l1Clients, fpc.address, debugLog);
|
|
70
|
+
|
|
71
|
+
if (json) {
|
|
72
|
+
log(
|
|
73
|
+
JSON.stringify(
|
|
74
|
+
{
|
|
75
|
+
devCoinL1: erc20Address.toString(),
|
|
76
|
+
devCoinPortalL1: portalAddress.toString(),
|
|
77
|
+
devCoin: {
|
|
78
|
+
address: token.address.toString(),
|
|
79
|
+
initHash: token.initHash.toString(),
|
|
80
|
+
salt: token.salt.toString(),
|
|
81
|
+
},
|
|
82
|
+
devCoinBridge: {
|
|
83
|
+
address: bridge.address.toString(),
|
|
84
|
+
initHash: bridge.initHash.toString(),
|
|
85
|
+
salt: bridge.salt.toString(),
|
|
86
|
+
},
|
|
87
|
+
devCoinFpc: {
|
|
88
|
+
address: fpc.address.toString(),
|
|
89
|
+
initHash: fpc.initHash.toString(),
|
|
90
|
+
salt: fpc.salt.toString(),
|
|
91
|
+
},
|
|
92
|
+
counter: {
|
|
93
|
+
address: counter.address.toString(),
|
|
94
|
+
initHash: counter.initHash.toString(),
|
|
95
|
+
salt: counter.salt.toString(),
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
null,
|
|
99
|
+
2,
|
|
100
|
+
),
|
|
101
|
+
);
|
|
102
|
+
} else {
|
|
103
|
+
log(`DevCoin L1: ${erc20Address}`);
|
|
104
|
+
log(`DevCoin L1 Portal: ${portalAddress}`);
|
|
105
|
+
log(`DevCoin L2: ${token.address}`);
|
|
106
|
+
log(`DevCoin L2 init hash: ${token.initHash}`);
|
|
107
|
+
log(`DevCoin L2 salt: ${token.salt}`);
|
|
108
|
+
log(`DevCoin L2 Bridge: ${bridge.address}`);
|
|
109
|
+
log(`DevCoin L2 Bridge init hash: ${bridge.initHash}`);
|
|
110
|
+
log(`DevCoin L2 Bridge salt: ${bridge.salt}`);
|
|
111
|
+
log(`DevCoin FPC: ${fpc.address}`);
|
|
112
|
+
log(`DevCoin FPC init hash: ${fpc.initHash}`);
|
|
113
|
+
log(`DevCoin FPC salt: ${fpc.salt}`);
|
|
114
|
+
log(`Counter: ${counter.address}`);
|
|
115
|
+
log(`Counter init hash: ${counter.initHash}`);
|
|
116
|
+
log(`Counter salt: ${counter.salt}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Step 1. Deploy the L1 contracts, but don't initialize
|
|
122
|
+
*/
|
|
123
|
+
async function deployERC20({ walletClient, publicClient }: L1Clients) {
|
|
124
|
+
const { TestERC20Abi, TestERC20Bytecode, TokenPortalAbi, TokenPortalBytecode } = await import('@aztec/l1-artifacts');
|
|
125
|
+
|
|
126
|
+
const erc20: ContractArtifacts = {
|
|
127
|
+
contractAbi: TestERC20Abi,
|
|
128
|
+
contractBytecode: TestERC20Bytecode,
|
|
129
|
+
};
|
|
130
|
+
const portal: ContractArtifacts = {
|
|
131
|
+
contractAbi: TokenPortalAbi,
|
|
132
|
+
contractBytecode: TokenPortalBytecode,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const { address: erc20Address } = await deployL1Contract(
|
|
136
|
+
walletClient,
|
|
137
|
+
publicClient,
|
|
138
|
+
erc20.contractAbi,
|
|
139
|
+
erc20.contractBytecode,
|
|
140
|
+
['DevCoin', 'DEV', walletClient.account.address],
|
|
141
|
+
);
|
|
142
|
+
const { address: portalAddress } = await deployL1Contract(
|
|
143
|
+
walletClient,
|
|
144
|
+
publicClient,
|
|
145
|
+
portal.contractAbi,
|
|
146
|
+
portal.contractBytecode,
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
erc20Address,
|
|
151
|
+
portalAddress,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Step 2. Deploy the L2 contracts
|
|
157
|
+
*/
|
|
158
|
+
async function deployToken(
|
|
159
|
+
wallet: Wallet,
|
|
160
|
+
l1Portal: EthAddress,
|
|
161
|
+
): Promise<{ token: ContractDeploymentInfo; bridge: ContractDeploymentInfo }> {
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
163
|
+
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
164
|
+
const { TokenContract } = await import('@aztec/noir-contracts.js/Token');
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
166
|
+
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
167
|
+
const { TokenBridgeContract } = await import('@aztec/noir-contracts.js/TokenBridge');
|
|
168
|
+
const devCoin = await TokenContract.deploy(wallet, wallet.getAddress(), 'DevCoin', 'DEV', 18)
|
|
169
|
+
.send({ universalDeploy: true })
|
|
170
|
+
.deployed(waitOpts);
|
|
171
|
+
const bridge = await TokenBridgeContract.deploy(wallet, devCoin.address, l1Portal)
|
|
172
|
+
.send({ universalDeploy: true })
|
|
173
|
+
.deployed(waitOpts);
|
|
174
|
+
|
|
175
|
+
await new BatchCall(wallet, [
|
|
176
|
+
await devCoin.methods.set_minter(bridge.address, true).request(),
|
|
177
|
+
await devCoin.methods.set_admin(bridge.address).request(),
|
|
178
|
+
])
|
|
179
|
+
.send()
|
|
180
|
+
.wait(waitOpts);
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
token: {
|
|
184
|
+
address: devCoin.address,
|
|
185
|
+
initHash: devCoin.instance.initializationHash,
|
|
186
|
+
salt: devCoin.instance.salt,
|
|
187
|
+
},
|
|
188
|
+
bridge: {
|
|
189
|
+
address: bridge.address,
|
|
190
|
+
initHash: bridge.instance.initializationHash,
|
|
191
|
+
salt: bridge.instance.salt,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Step 3. Initialize DevCoin's L1 portal
|
|
198
|
+
*/
|
|
199
|
+
async function initPortal(
|
|
200
|
+
pxe: PXE,
|
|
201
|
+
{ walletClient, publicClient }: L1Clients,
|
|
202
|
+
erc20: EthAddress,
|
|
203
|
+
portal: EthAddress,
|
|
204
|
+
bridge: AztecAddress,
|
|
205
|
+
) {
|
|
206
|
+
const { TokenPortalAbi } = await import('@aztec/l1-artifacts');
|
|
207
|
+
const {
|
|
208
|
+
l1ContractAddresses: { registryAddress },
|
|
209
|
+
} = await pxe.getNodeInfo();
|
|
210
|
+
|
|
211
|
+
const contract = getContract({
|
|
212
|
+
abi: TokenPortalAbi,
|
|
213
|
+
address: portal.toString(),
|
|
214
|
+
client: walletClient,
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
const hash = await contract.write.initialize([registryAddress.toString(), erc20.toString(), bridge.toString()]);
|
|
218
|
+
|
|
219
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function deployFPC(
|
|
223
|
+
wallet: Wallet,
|
|
224
|
+
tokenAddress: AztecAddress,
|
|
225
|
+
admin: AztecAddress,
|
|
226
|
+
): Promise<ContractDeploymentInfo> {
|
|
227
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
228
|
+
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
229
|
+
const { FPCContract } = await import('@aztec/noir-contracts.js/FPC');
|
|
230
|
+
const fpc = await FPCContract.deploy(wallet, tokenAddress, admin).send({ universalDeploy: true }).deployed(waitOpts);
|
|
231
|
+
const info: ContractDeploymentInfo = {
|
|
232
|
+
address: fpc.address,
|
|
233
|
+
initHash: fpc.instance.initializationHash,
|
|
234
|
+
salt: fpc.instance.salt,
|
|
235
|
+
};
|
|
236
|
+
return info;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async function deployCounter(wallet: Wallet): Promise<ContractDeploymentInfo> {
|
|
240
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
241
|
+
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
242
|
+
const { CounterContract } = await import('@aztec/noir-contracts.js/Counter');
|
|
243
|
+
const counter = await CounterContract.deploy(wallet, 1, wallet.getAddress())
|
|
244
|
+
.send({ universalDeploy: true })
|
|
245
|
+
.deployed(waitOpts);
|
|
246
|
+
const info: ContractDeploymentInfo = {
|
|
247
|
+
address: counter.address,
|
|
248
|
+
initHash: counter.instance.initializationHash,
|
|
249
|
+
salt: counter.instance.salt,
|
|
250
|
+
};
|
|
251
|
+
return info;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// NOTE: Disabling for now in order to get devnet running
|
|
255
|
+
async function fundFPC(
|
|
256
|
+
counterAddress: AztecAddress,
|
|
257
|
+
wallet: Wallet,
|
|
258
|
+
l1Clients: L1Clients,
|
|
259
|
+
fpcAddress: AztecAddress,
|
|
260
|
+
debugLog: Logger,
|
|
261
|
+
) {
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
263
|
+
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
264
|
+
const { FeeJuiceContract } = await import('@aztec/noir-contracts.js/FeeJuice');
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
266
|
+
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
267
|
+
const { CounterContract } = await import('@aztec/noir-contracts.js/Counter');
|
|
268
|
+
const {
|
|
269
|
+
protocolContractAddresses: { feeJuice },
|
|
270
|
+
} = await wallet.getPXEInfo();
|
|
271
|
+
|
|
272
|
+
const feeJuiceContract = await FeeJuiceContract.at(feeJuice, wallet);
|
|
273
|
+
|
|
274
|
+
const feeJuicePortal = await L1FeeJuicePortalManager.new(
|
|
275
|
+
wallet,
|
|
276
|
+
l1Clients.publicClient,
|
|
277
|
+
l1Clients.walletClient,
|
|
278
|
+
debugLog,
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
const amount = FEE_FUNDING_FOR_TESTER_ACCOUNT;
|
|
282
|
+
const { claimAmount, claimSecret, messageLeafIndex, messageHash } = await feeJuicePortal.bridgeTokensPublic(
|
|
283
|
+
fpcAddress,
|
|
284
|
+
amount,
|
|
285
|
+
true,
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
await retryUntil(
|
|
289
|
+
async () => await wallet.isL1ToL2MessageSynced(Fr.fromHexString(messageHash)),
|
|
290
|
+
'message sync',
|
|
291
|
+
600,
|
|
292
|
+
1,
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
const counter = await CounterContract.at(counterAddress, wallet);
|
|
296
|
+
|
|
297
|
+
// TODO (alexg) remove this once sequencer builds blocks continuously
|
|
298
|
+
// advance the chain
|
|
299
|
+
await counter.methods.increment(wallet.getAddress(), wallet.getAddress()).send().wait(waitOpts);
|
|
300
|
+
await counter.methods.increment(wallet.getAddress(), wallet.getAddress()).send().wait(waitOpts);
|
|
301
|
+
|
|
302
|
+
await feeJuiceContract.methods
|
|
303
|
+
.claim(fpcAddress, claimAmount, claimSecret, messageLeafIndex)
|
|
304
|
+
.send()
|
|
305
|
+
.wait({ ...waitOpts, proven: true });
|
|
306
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type EthAddress } from '@aztec/circuits.js';
|
|
2
|
+
import { type LogFn } from '@aztec/foundation/log';
|
|
3
|
+
|
|
4
|
+
import { prettyPrintJSON } from '../../utils/commands.js';
|
|
5
|
+
|
|
6
|
+
export async function dripFaucet(
|
|
7
|
+
faucetUrl: string,
|
|
8
|
+
asset: string,
|
|
9
|
+
account: EthAddress,
|
|
10
|
+
json: boolean,
|
|
11
|
+
log: LogFn,
|
|
12
|
+
): Promise<void> {
|
|
13
|
+
const url = new URL(`/drip/${account.toString()}`, faucetUrl);
|
|
14
|
+
url.searchParams.set('asset', asset);
|
|
15
|
+
const res = await fetch(url);
|
|
16
|
+
if (res.status === 200) {
|
|
17
|
+
if (json) {
|
|
18
|
+
log(prettyPrintJSON({ ok: true }));
|
|
19
|
+
} else {
|
|
20
|
+
log(`Dripped ${asset} for ${account.toString()}`);
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
if (json) {
|
|
24
|
+
log(prettyPrintJSON({ ok: false }));
|
|
25
|
+
} else if (res.status === 429) {
|
|
26
|
+
log(`Rate limited when dripping ${asset} for ${account.toString()}`);
|
|
27
|
+
} else {
|
|
28
|
+
log(`Failed to drip ${asset} for ${account.toString()}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type LogFn, type Logger } from '@aztec/foundation/log';
|
|
2
|
+
|
|
3
|
+
import { type Command } from 'commander';
|
|
4
|
+
|
|
5
|
+
import { ETHEREUM_HOST, l1ChainIdOption, parseEthereumAddress, pxeOption } from '../../utils/commands.js';
|
|
6
|
+
|
|
7
|
+
export function injectCommands(program: Command, log: LogFn, debugLogger: Logger) {
|
|
8
|
+
program
|
|
9
|
+
.command('bootstrap-network')
|
|
10
|
+
.description('Bootstrap a new network')
|
|
11
|
+
.addOption(pxeOption)
|
|
12
|
+
.addOption(l1ChainIdOption)
|
|
13
|
+
.requiredOption(
|
|
14
|
+
'--l1-rpc-url <string>',
|
|
15
|
+
'Url of the ethereum host. Chain identifiers localhost and testnet can be used',
|
|
16
|
+
ETHEREUM_HOST,
|
|
17
|
+
)
|
|
18
|
+
.option('--l1-private-key <string>', 'The private key to use for deployment', process.env.PRIVATE_KEY)
|
|
19
|
+
.option(
|
|
20
|
+
'-m, --mnemonic <string>',
|
|
21
|
+
'The mnemonic to use in deployment',
|
|
22
|
+
'test test test test test test test test test test test junk',
|
|
23
|
+
)
|
|
24
|
+
.option('--json', 'Output the result as JSON')
|
|
25
|
+
.action(async options => {
|
|
26
|
+
const { bootstrapNetwork } = await import('./bootstrap_network.js');
|
|
27
|
+
await bootstrapNetwork(
|
|
28
|
+
options[pxeOption.attributeName()],
|
|
29
|
+
options.l1RpcUrl,
|
|
30
|
+
options[l1ChainIdOption.attributeName()],
|
|
31
|
+
options.l1PrivateKey,
|
|
32
|
+
options.mnemonic,
|
|
33
|
+
options.json,
|
|
34
|
+
log,
|
|
35
|
+
debugLogger,
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
program
|
|
40
|
+
.command('drip-faucet')
|
|
41
|
+
.description('Drip the faucet')
|
|
42
|
+
.requiredOption('-u, --faucet-url <string>', 'Url of the faucet', 'http://localhost:8082')
|
|
43
|
+
.requiredOption('-t, --token <string>', 'The asset to drip', 'eth')
|
|
44
|
+
.requiredOption('-a, --address <string>', 'The Ethereum address to drip to', parseEthereumAddress)
|
|
45
|
+
.option('--json', 'Output the result as JSON')
|
|
46
|
+
.action(async options => {
|
|
47
|
+
const { dripFaucet } = await import('./faucet.js');
|
|
48
|
+
await dripFaucet(options.faucetUrl, options.token, options.address, options.json, log);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return program;
|
|
52
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type LogFn, type Logger } from '@aztec/foundation/log';
|
|
2
|
+
|
|
3
|
+
import { type Command } from 'commander';
|
|
4
|
+
|
|
5
|
+
import { ETHEREUM_HOST, l1ChainIdOption, parseOptionalInteger, pxeOption } from '../../utils/commands.js';
|
|
6
|
+
|
|
7
|
+
export function injectCommands(program: Command, log: LogFn, debugLogger: Logger) {
|
|
8
|
+
program
|
|
9
|
+
.command('setup-protocol-contracts')
|
|
10
|
+
.description('Bootstrap the blockchain by initializing all the protocol contracts')
|
|
11
|
+
.addOption(pxeOption)
|
|
12
|
+
.addOption(l1ChainIdOption)
|
|
13
|
+
.option('--json', 'Output the contract addresses in JSON format')
|
|
14
|
+
.option('--skipProofWait', "Don't wait for proofs to land.")
|
|
15
|
+
.action(async options => {
|
|
16
|
+
const { setupProtocolContracts } = await import('./setup_protocol_contract.js');
|
|
17
|
+
await setupProtocolContracts(options.rpcUrl, options.l1ChainId, options.json, options.skipProofWait, log);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
program
|
|
21
|
+
.command('sequencers')
|
|
22
|
+
.argument('<command>', 'Command to run: list, add, remove, who-next')
|
|
23
|
+
.argument('[who]', 'Who to add/remove')
|
|
24
|
+
.description('Manages or queries registered sequencers on the L1 rollup contract.')
|
|
25
|
+
.requiredOption(
|
|
26
|
+
'--l1-rpc-url <string>',
|
|
27
|
+
'Url of the ethereum host. Chain identifiers localhost and testnet can be used',
|
|
28
|
+
ETHEREUM_HOST,
|
|
29
|
+
)
|
|
30
|
+
.option(
|
|
31
|
+
'-m, --mnemonic <string>',
|
|
32
|
+
'The mnemonic for the sender of the tx',
|
|
33
|
+
'test test test test test test test test test test test junk',
|
|
34
|
+
)
|
|
35
|
+
.option('--block-number <number>', 'Block number to query next sequencer for', parseOptionalInteger)
|
|
36
|
+
.addOption(pxeOption)
|
|
37
|
+
.addOption(l1ChainIdOption)
|
|
38
|
+
.action(async (command, who, options) => {
|
|
39
|
+
const { sequencers } = await import('./sequencers.js');
|
|
40
|
+
await sequencers({
|
|
41
|
+
command: command,
|
|
42
|
+
who,
|
|
43
|
+
mnemonic: options.mnemonic,
|
|
44
|
+
rpcUrl: options.rpcUrl,
|
|
45
|
+
l1RpcUrl: options.l1RpcUrl,
|
|
46
|
+
chainId: options.l1ChainId,
|
|
47
|
+
blockNumber: options.blockNumber,
|
|
48
|
+
log,
|
|
49
|
+
debugLogger,
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return program;
|
|
54
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
import { createEthereumChain, getL1ContractsConfigEnvVars } from '@aztec/ethereum';
|
|
3
|
+
import { type LogFn, type Logger } from '@aztec/foundation/log';
|
|
4
|
+
import { RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
|
|
5
|
+
|
|
6
|
+
import { createPublicClient, createWalletClient, getContract, http } from 'viem';
|
|
7
|
+
import { mnemonicToAccount } from 'viem/accounts';
|
|
8
|
+
|
|
9
|
+
export async function sequencers(opts: {
|
|
10
|
+
command: 'list' | 'add' | 'remove' | 'who-next';
|
|
11
|
+
who?: string;
|
|
12
|
+
mnemonic?: string;
|
|
13
|
+
rpcUrl: string;
|
|
14
|
+
l1RpcUrl: string;
|
|
15
|
+
chainId: number;
|
|
16
|
+
blockNumber?: number;
|
|
17
|
+
log: LogFn;
|
|
18
|
+
debugLogger: Logger;
|
|
19
|
+
}) {
|
|
20
|
+
const { command, who: maybeWho, mnemonic, rpcUrl, l1RpcUrl, chainId, log, debugLogger } = opts;
|
|
21
|
+
const client = await createCompatibleClient(rpcUrl, debugLogger);
|
|
22
|
+
const { l1ContractAddresses } = await client.getNodeInfo();
|
|
23
|
+
|
|
24
|
+
const chain = createEthereumChain(l1RpcUrl, chainId);
|
|
25
|
+
const publicClient = createPublicClient({ chain: chain.chainInfo, transport: http(chain.rpcUrl) });
|
|
26
|
+
|
|
27
|
+
const walletClient = mnemonic
|
|
28
|
+
? createWalletClient({
|
|
29
|
+
account: mnemonicToAccount(mnemonic),
|
|
30
|
+
chain: chain.chainInfo,
|
|
31
|
+
transport: http(chain.rpcUrl),
|
|
32
|
+
})
|
|
33
|
+
: undefined;
|
|
34
|
+
|
|
35
|
+
const rollup = getContract({
|
|
36
|
+
address: l1ContractAddresses.rollupAddress.toString(),
|
|
37
|
+
abi: RollupAbi,
|
|
38
|
+
client: publicClient,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const writeableRollup = walletClient
|
|
42
|
+
? getContract({
|
|
43
|
+
address: l1ContractAddresses.rollupAddress.toString(),
|
|
44
|
+
abi: RollupAbi,
|
|
45
|
+
client: walletClient,
|
|
46
|
+
})
|
|
47
|
+
: undefined;
|
|
48
|
+
|
|
49
|
+
const who = (maybeWho as `0x{string}`) ?? walletClient?.account.address.toString();
|
|
50
|
+
|
|
51
|
+
if (command === 'list') {
|
|
52
|
+
const sequencers = await rollup.read.getAttesters();
|
|
53
|
+
if (sequencers.length === 0) {
|
|
54
|
+
log(`No sequencers registered on rollup`);
|
|
55
|
+
} else {
|
|
56
|
+
log(`Registered sequencers on rollup:`);
|
|
57
|
+
for (const sequencer of sequencers) {
|
|
58
|
+
log(' ' + sequencer.toString());
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} else if (command === 'add') {
|
|
62
|
+
if (!who || !writeableRollup || !walletClient) {
|
|
63
|
+
throw new Error(`Missing sequencer address`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
log(`Adding ${who} as sequencer`);
|
|
67
|
+
|
|
68
|
+
const stakingAsset = getContract({
|
|
69
|
+
address: await rollup.read.getStakingAsset(),
|
|
70
|
+
abi: TestERC20Abi,
|
|
71
|
+
client: walletClient,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const config = getL1ContractsConfigEnvVars();
|
|
75
|
+
|
|
76
|
+
await Promise.all(
|
|
77
|
+
[
|
|
78
|
+
await stakingAsset.write.mint([walletClient.account.address, config.minimumStake], {} as any),
|
|
79
|
+
await stakingAsset.write.approve([rollup.address, config.minimumStake], {} as any),
|
|
80
|
+
].map(txHash => publicClient.waitForTransactionReceipt({ hash: txHash })),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const hash = await writeableRollup.write.deposit([who, who, who, config.minimumStake]);
|
|
84
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
85
|
+
log(`Added in tx ${hash}`);
|
|
86
|
+
} else if (command === 'remove') {
|
|
87
|
+
if (!who || !writeableRollup) {
|
|
88
|
+
throw new Error(`Missing sequencer address`);
|
|
89
|
+
}
|
|
90
|
+
log(`Removing ${who} as sequencer`);
|
|
91
|
+
const hash = await writeableRollup.write.initiateWithdraw([who, who]);
|
|
92
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
93
|
+
log(`Removed in tx ${hash}`);
|
|
94
|
+
} else if (command === 'who-next') {
|
|
95
|
+
const next = await rollup.read.getCurrentProposer();
|
|
96
|
+
log(`Sequencer expected to build is ${next}`);
|
|
97
|
+
} else {
|
|
98
|
+
throw new Error(`Unknown command ${command}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SignerlessWallet, type WaitOpts, createPXEClient, makeFetch } from '@aztec/aztec.js';
|
|
2
|
+
import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint';
|
|
3
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
4
|
+
import { type LogFn } from '@aztec/foundation/log';
|
|
5
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
6
|
+
|
|
7
|
+
import { setupCanonicalL2FeeJuice } from '../misc/setup_contracts.js';
|
|
8
|
+
|
|
9
|
+
export async function setupProtocolContracts(
|
|
10
|
+
rpcUrl: string,
|
|
11
|
+
l1ChainId: number,
|
|
12
|
+
json: boolean,
|
|
13
|
+
skipProofWait: boolean,
|
|
14
|
+
log: LogFn,
|
|
15
|
+
) {
|
|
16
|
+
const waitOpts: WaitOpts = {
|
|
17
|
+
timeout: 180,
|
|
18
|
+
interval: 1,
|
|
19
|
+
proven: !skipProofWait,
|
|
20
|
+
provenTimeout: 600,
|
|
21
|
+
};
|
|
22
|
+
log('setupProtocolContracts: Wait options' + jsonStringify(waitOpts));
|
|
23
|
+
log('setupProtocolContracts: Creating PXE client...');
|
|
24
|
+
const pxe = createPXEClient(rpcUrl, makeFetch([1, 1, 1, 1, 1], false));
|
|
25
|
+
const wallet = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(l1ChainId, 1));
|
|
26
|
+
|
|
27
|
+
log('setupProtocolContracts: Getting fee juice portal address...');
|
|
28
|
+
// Deploy Fee Juice
|
|
29
|
+
const feeJuicePortalAddress = (await wallet.getNodeInfo()).l1ContractAddresses.feeJuicePortalAddress;
|
|
30
|
+
log('setupProtocolContracts: Setting up fee juice portal...');
|
|
31
|
+
await setupCanonicalL2FeeJuice(wallet, feeJuicePortalAddress, waitOpts, log);
|
|
32
|
+
|
|
33
|
+
if (json) {
|
|
34
|
+
log(JSON.stringify(ProtocolContractAddress, null, 2));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CheatCodes, createPXEClient, makeFetch } from '@aztec/aztec.js';
|
|
2
|
+
import { type LogFn } from '@aztec/foundation/log';
|
|
3
|
+
|
|
4
|
+
export async function advanceEpoch(l1RpcUrl: string, rpcUrl: string, log: LogFn) {
|
|
5
|
+
const pxe = createPXEClient(rpcUrl, makeFetch([], true));
|
|
6
|
+
const rollupAddress = await pxe.getNodeInfo().then(i => i.l1ContractAddresses.rollupAddress);
|
|
7
|
+
|
|
8
|
+
const cheat = CheatCodes.createRollup(l1RpcUrl, { rollupAddress });
|
|
9
|
+
|
|
10
|
+
await cheat.advanceToNextEpoch();
|
|
11
|
+
log(`Warped time to advance to next epoch`);
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createPXEClient, makeFetch } from '@aztec/aztec.js';
|
|
2
|
+
import { createEthereumChain, createL1Clients } from '@aztec/ethereum';
|
|
3
|
+
import { type LogFn } from '@aztec/foundation/log';
|
|
4
|
+
|
|
5
|
+
import { setAssumeProvenThrough } from '../../utils/aztec.js';
|
|
6
|
+
|
|
7
|
+
export async function assumeProvenThrough(
|
|
8
|
+
blockNumberOrLatest: number | undefined,
|
|
9
|
+
l1RpcUrl: string,
|
|
10
|
+
rpcUrl: string,
|
|
11
|
+
chainId: number,
|
|
12
|
+
privateKey: string | undefined,
|
|
13
|
+
mnemonic: string,
|
|
14
|
+
log: LogFn,
|
|
15
|
+
) {
|
|
16
|
+
const chain = createEthereumChain(l1RpcUrl, chainId);
|
|
17
|
+
const { walletClient } = createL1Clients(chain.rpcUrl, privateKey ?? mnemonic, chain.chainInfo);
|
|
18
|
+
|
|
19
|
+
const pxe = createPXEClient(rpcUrl, makeFetch([], true));
|
|
20
|
+
const rollupAddress = await pxe.getNodeInfo().then(i => i.l1ContractAddresses.rollupAddress);
|
|
21
|
+
const blockNumber = blockNumberOrLatest ?? (await pxe.getBlockNumber());
|
|
22
|
+
|
|
23
|
+
await setAssumeProvenThrough(blockNumber, rollupAddress, walletClient);
|
|
24
|
+
log(`Assumed proven through block ${blockNumber}`);
|
|
25
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { L1ToL2TokenPortalManager } from '@aztec/aztec.js';
|
|
2
|
+
import { type AztecAddress, type EthAddress, type Fr } from '@aztec/circuits.js';
|
|
3
|
+
import { createEthereumChain, createL1Clients } from '@aztec/ethereum';
|
|
4
|
+
import { type LogFn, type Logger } from '@aztec/foundation/log';
|
|
5
|
+
|
|
6
|
+
import { prettyPrintJSON } from '../../utils/commands.js';
|
|
7
|
+
|
|
8
|
+
export async function bridgeERC20(
|
|
9
|
+
amount: bigint,
|
|
10
|
+
recipient: AztecAddress,
|
|
11
|
+
l1RpcUrl: string,
|
|
12
|
+
chainId: number,
|
|
13
|
+
privateKey: string | undefined,
|
|
14
|
+
mnemonic: string,
|
|
15
|
+
tokenAddress: EthAddress,
|
|
16
|
+
portalAddress: EthAddress,
|
|
17
|
+
privateTransfer: boolean,
|
|
18
|
+
mint: boolean,
|
|
19
|
+
json: boolean,
|
|
20
|
+
log: LogFn,
|
|
21
|
+
debugLogger: Logger,
|
|
22
|
+
) {
|
|
23
|
+
// Prepare L1 client
|
|
24
|
+
const chain = createEthereumChain(l1RpcUrl, chainId);
|
|
25
|
+
const { publicClient, walletClient } = createL1Clients(chain.rpcUrl, privateKey ?? mnemonic, chain.chainInfo);
|
|
26
|
+
|
|
27
|
+
// Setup portal manager
|
|
28
|
+
const manager = new L1ToL2TokenPortalManager(portalAddress, tokenAddress, publicClient, walletClient, debugLogger);
|
|
29
|
+
let claimSecret: Fr;
|
|
30
|
+
let messageHash: `0x${string}`;
|
|
31
|
+
if (privateTransfer) {
|
|
32
|
+
({ claimSecret, messageHash } = await manager.bridgeTokensPrivate(recipient, amount, mint));
|
|
33
|
+
} else {
|
|
34
|
+
({ claimSecret, messageHash } = await manager.bridgeTokensPublic(recipient, amount, mint));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (json) {
|
|
38
|
+
log(
|
|
39
|
+
prettyPrintJSON({
|
|
40
|
+
claimAmount: amount,
|
|
41
|
+
claimSecret: claimSecret,
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
} else {
|
|
45
|
+
if (mint) {
|
|
46
|
+
log(`Minted ${amount} tokens on L1 and pushed to L2 portal`);
|
|
47
|
+
} else {
|
|
48
|
+
log(`Bridged ${amount} tokens to L2 portal`);
|
|
49
|
+
}
|
|
50
|
+
log(`claimAmount=${amount},claimSecret=${claimSecret}\n,messageHash=${messageHash}`);
|
|
51
|
+
log(`Note: You need to wait for two L2 blocks before pulling them from the L2 side`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -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
|
+
}
|