@aztec/cli 0.16.9 → 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 +70 -21
- 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 -18
- 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 -30
- 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 -26
- package/dest/cmds/unbox.d.ts +0 -6
- package/dest/cmds/unbox.d.ts.map +0 -1
- package/dest/cmds/unbox.js +0 -9
- 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/unbox.d.ts +0 -14
- package/dest/unbox.d.ts.map +0 -1
- package/dest/unbox.js +0 -276
- 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
package/README.md
CHANGED
|
@@ -4,19 +4,13 @@ The Aztec CLI `aztec-cli` is a command-line interface (CLI) tool for interacting
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
1. In your terminal, download the sandbox by running
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
```shell
|
|
14
|
-
npm install -g @aztec/cli
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
This will install the `aztec-cli` globally, making it accessible from any location in your terminal.
|
|
9
|
+
```
|
|
10
|
+
bash -i <(curl -s https://install.aztec.network)
|
|
11
|
+
```
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
2. Verify the installation: After the installation is complete, run the following command to verify that `aztec-cli` is installed correctly:
|
|
20
14
|
|
|
21
15
|
```shell
|
|
22
16
|
aztec-cli --version
|
|
@@ -41,10 +35,9 @@ Replace `<command>` with the actual command you want to execute and `[options]`
|
|
|
41
35
|
Some options can be set globally as environment variables to avoid having to re-enter them every time you call `aztec-cli.`
|
|
42
36
|
These options are:
|
|
43
37
|
|
|
44
|
-
- `
|
|
38
|
+
- `SECRET_KEY` -> `-sk, --secret-key` for all commands that require an Aztec secret key.
|
|
45
39
|
- `PUBLIC_KEY` -> `-k, --public-key` for all commands that require a public key.
|
|
46
40
|
- `PXE_URL` -> `-u, --rpc-url` for commands that require a PXE
|
|
47
|
-
- `API_KEY` -> `a, --api-key` for `deploy-l1-contracts`.
|
|
48
41
|
- `ETHEREUM_RPC_HOST` -> `-u, --rpc-url` for `deploy-l1-contracts`.
|
|
49
42
|
|
|
50
43
|
So if for example you are running your Private eXecution Environment (PXE) remotely you can do:
|
|
@@ -76,7 +69,7 @@ aztec-cli deploy-l1-contracts [rpcUrl] [options]
|
|
|
76
69
|
|
|
77
70
|
Options:
|
|
78
71
|
|
|
79
|
-
- `-a, --
|
|
72
|
+
- `-a, --l1-chain-id <string>`: Chain ID for the Ethereum host.
|
|
80
73
|
- `-p, --private-key <string>`: The private key to use for deployment.
|
|
81
74
|
- `-m, --mnemonic <string>`: The mnemonic to use in deployment. Default: `test test test test test test test test test test test junk`.
|
|
82
75
|
|
|
@@ -395,6 +388,7 @@ Syntax:
|
|
|
395
388
|
```shell
|
|
396
389
|
aztec-cli get-logs --fromBlock <number>
|
|
397
390
|
```
|
|
391
|
+
|
|
398
392
|
Options:
|
|
399
393
|
|
|
400
394
|
- `-u, --rpc-url <string>`: URL of PXE Service. Default: `http://localhost:8080`.
|
|
@@ -428,7 +422,7 @@ This command retrieves and displays the current Aztec L2 block number.
|
|
|
428
422
|
|
|
429
423
|
### example-contracts
|
|
430
424
|
|
|
431
|
-
Lists the contracts available in [@aztec/noir-contracts](https://github.com/AztecProtocol/aztec-packages/tree/master/
|
|
425
|
+
Lists the contracts available in [@aztec/noir-contracts](https://github.com/AztecProtocol/aztec-packages/tree/master/noir-contracts)
|
|
432
426
|
|
|
433
427
|
Syntax:
|
|
434
428
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function injectCommands(program, log, debugLogger) {
|
|
2
|
+
program.command('inspect-contract').description('Shows list of external callable functions for a contract').argument('<contractArtifactFile>', `A compiled Noir contract's artifact in JSON format or name of a contract artifact exported by @aztec/noir-contracts.js`).action(async (contractArtifactFile)=>{
|
|
3
|
+
const { inspectContract } = await import('./inspect_contract.js');
|
|
4
|
+
await inspectContract(contractArtifactFile, debugLogger, log);
|
|
5
|
+
});
|
|
6
|
+
// Helper for users to decode hex strings into structs if needed.
|
|
7
|
+
program.command('parse-parameter-struct').description("Helper for parsing an encoded string into a contract's parameter struct.").argument('<encodedString>', 'The encoded hex string').requiredOption('-c, --contract-artifact <fileLocation>', "A compiled Aztec.nr contract's ABI in JSON format or name of a contract ABI exported by @aztec/noir-contracts.js").requiredOption('-p, --parameter <parameterName>', 'The name of the struct parameter to decode into').action(async (encodedString, options)=>{
|
|
8
|
+
const { parseParameterStruct } = await import('./parse_parameter_struct.js');
|
|
9
|
+
await parseParameterStruct(encodedString, options.contractArtifact, options.parameter, log);
|
|
10
|
+
});
|
|
11
|
+
return program;
|
|
12
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getContractClassFromArtifact } from '@aztec/circuits.js';
|
|
2
|
+
import { FunctionSelector, decodeFunctionSignature, decodeFunctionSignatureWithParameterNames } from '@aztec/foundation/abi';
|
|
3
|
+
import { sha256 } from '@aztec/foundation/crypto';
|
|
4
|
+
import { getContractArtifact } from '../../utils/aztec.js';
|
|
5
|
+
export async function inspectContract(contractArtifactFile, debugLogger, log) {
|
|
6
|
+
const contractArtifact = await getContractArtifact(contractArtifactFile, log);
|
|
7
|
+
const contractFns = contractArtifact.functions.filter((f)=>f.name !== 'compute_note_hash_and_optionally_a_nullifier');
|
|
8
|
+
if (contractFns.length === 0) {
|
|
9
|
+
log(`No functions found for contract ${contractArtifact.name}`);
|
|
10
|
+
}
|
|
11
|
+
const contractClass = await getContractClassFromArtifact(contractArtifact);
|
|
12
|
+
const bytecodeLengthInFields = 1 + Math.ceil(contractClass.packedBytecode.length / 31);
|
|
13
|
+
log(`Contract class details:`);
|
|
14
|
+
log(`\tidentifier: ${contractClass.id.toString()}`);
|
|
15
|
+
log(`\tartifact hash: ${contractClass.artifactHash.toString()}`);
|
|
16
|
+
log(`\tprivate function tree root: ${contractClass.privateFunctionsRoot.toString()}`);
|
|
17
|
+
log(`\tpublic bytecode commitment: ${contractClass.publicBytecodeCommitment.toString()}`);
|
|
18
|
+
log(`\tpublic bytecode length: ${contractClass.packedBytecode.length} bytes (${bytecodeLengthInFields} fields)`);
|
|
19
|
+
const externalFunctions = contractFns.filter((f)=>!f.isInternal);
|
|
20
|
+
if (externalFunctions.length > 0) {
|
|
21
|
+
log(`\nExternal functions:`);
|
|
22
|
+
await Promise.all(externalFunctions.map((f)=>logFunction(f, log)));
|
|
23
|
+
}
|
|
24
|
+
const internalFunctions = contractFns.filter((f)=>f.isInternal);
|
|
25
|
+
if (internalFunctions.length > 0) {
|
|
26
|
+
log(`\nInternal functions:`);
|
|
27
|
+
await Promise.all(internalFunctions.map((f)=>logFunction(f, log)));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function logFunction(fn, log) {
|
|
31
|
+
const signatureWithParameterNames = decodeFunctionSignatureWithParameterNames(fn.name, fn.parameters);
|
|
32
|
+
const signature = decodeFunctionSignature(fn.name, fn.parameters);
|
|
33
|
+
const selector = await FunctionSelector.fromSignature(signature);
|
|
34
|
+
const bytecodeSize = fn.bytecode.length;
|
|
35
|
+
const bytecodeHash = sha256(fn.bytecode).toString('hex');
|
|
36
|
+
log(`${fn.functionType} ${signatureWithParameterNames} \n\tfunction signature: ${signature}\n\tselector: ${selector}\n\tbytecode: ${bytecodeSize} bytes (sha256 ${bytecodeHash})`);
|
|
37
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
2
|
+
import { getContractArtifact } from '../../utils/aztec.js';
|
|
3
|
+
import { parseStructString } from '../../utils/encoding.js';
|
|
4
|
+
export async function parseParameterStruct(encodedString, contractArtifactPath, parameterName, log) {
|
|
5
|
+
const contractArtifact = await getContractArtifact(contractArtifactPath, log);
|
|
6
|
+
const parameterAbitype = contractArtifact.functions.map(({ parameters })=>parameters).flat().find(({ name, type })=>name === parameterName && type.kind === 'struct');
|
|
7
|
+
if (!parameterAbitype) {
|
|
8
|
+
log(`No struct parameter found with name ${parameterName}`);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const data = parseStructString(encodedString, parameterAbitype.type);
|
|
12
|
+
log(`\nStruct Data: \n${jsonStringify(data, true)}\n`);
|
|
13
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { BatchCall, L1FeeJuicePortalManager, createCompatibleClient, retryUntil } from '@aztec/aztec.js';
|
|
3
|
+
import { FEE_FUNDING_FOR_TESTER_ACCOUNT, Fq, Fr } from '@aztec/circuits.js';
|
|
4
|
+
import { createEthereumChain, createL1Clients, deployL1Contract } from '@aztec/ethereum';
|
|
5
|
+
import { getContract } from 'viem';
|
|
6
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
7
|
+
const waitOpts = {
|
|
8
|
+
timeout: 120,
|
|
9
|
+
provenTimeout: 4800,
|
|
10
|
+
interval: 1
|
|
11
|
+
};
|
|
12
|
+
export async function bootstrapNetwork(pxeUrl, l1Url, l1ChainId, l1PrivateKey, l1Mnemonic, json, log, debugLog) {
|
|
13
|
+
const pxe = await createCompatibleClient(pxeUrl, debugLog);
|
|
14
|
+
// setup a one-off account contract
|
|
15
|
+
const account = await getSchnorrAccount(pxe, Fr.random(), Fq.random(), Fr.random());
|
|
16
|
+
const wallet = await account.deploy().getWallet();
|
|
17
|
+
const l1Clients = createL1Clients(l1Url, l1PrivateKey ? privateKeyToAccount(l1PrivateKey) : l1Mnemonic, createEthereumChain(l1Url, +l1ChainId).chainInfo);
|
|
18
|
+
const { erc20Address, portalAddress } = await deployERC20(l1Clients);
|
|
19
|
+
const { token, bridge } = await deployToken(wallet, portalAddress);
|
|
20
|
+
await initPortal(pxe, l1Clients, erc20Address, portalAddress, bridge.address);
|
|
21
|
+
const fpcAdmin = wallet.getAddress();
|
|
22
|
+
const fpc = await deployFPC(wallet, token.address, fpcAdmin);
|
|
23
|
+
const counter = await deployCounter(wallet);
|
|
24
|
+
// NOTE: Disabling for now in order to get devnet running
|
|
25
|
+
await fundFPC(counter.address, wallet, l1Clients, fpc.address, debugLog);
|
|
26
|
+
if (json) {
|
|
27
|
+
log(JSON.stringify({
|
|
28
|
+
devCoinL1: erc20Address.toString(),
|
|
29
|
+
devCoinPortalL1: portalAddress.toString(),
|
|
30
|
+
devCoin: {
|
|
31
|
+
address: token.address.toString(),
|
|
32
|
+
initHash: token.initHash.toString(),
|
|
33
|
+
salt: token.salt.toString()
|
|
34
|
+
},
|
|
35
|
+
devCoinBridge: {
|
|
36
|
+
address: bridge.address.toString(),
|
|
37
|
+
initHash: bridge.initHash.toString(),
|
|
38
|
+
salt: bridge.salt.toString()
|
|
39
|
+
},
|
|
40
|
+
devCoinFpc: {
|
|
41
|
+
address: fpc.address.toString(),
|
|
42
|
+
initHash: fpc.initHash.toString(),
|
|
43
|
+
salt: fpc.salt.toString()
|
|
44
|
+
},
|
|
45
|
+
counter: {
|
|
46
|
+
address: counter.address.toString(),
|
|
47
|
+
initHash: counter.initHash.toString(),
|
|
48
|
+
salt: counter.salt.toString()
|
|
49
|
+
}
|
|
50
|
+
}, null, 2));
|
|
51
|
+
} else {
|
|
52
|
+
log(`DevCoin L1: ${erc20Address}`);
|
|
53
|
+
log(`DevCoin L1 Portal: ${portalAddress}`);
|
|
54
|
+
log(`DevCoin L2: ${token.address}`);
|
|
55
|
+
log(`DevCoin L2 init hash: ${token.initHash}`);
|
|
56
|
+
log(`DevCoin L2 salt: ${token.salt}`);
|
|
57
|
+
log(`DevCoin L2 Bridge: ${bridge.address}`);
|
|
58
|
+
log(`DevCoin L2 Bridge init hash: ${bridge.initHash}`);
|
|
59
|
+
log(`DevCoin L2 Bridge salt: ${bridge.salt}`);
|
|
60
|
+
log(`DevCoin FPC: ${fpc.address}`);
|
|
61
|
+
log(`DevCoin FPC init hash: ${fpc.initHash}`);
|
|
62
|
+
log(`DevCoin FPC salt: ${fpc.salt}`);
|
|
63
|
+
log(`Counter: ${counter.address}`);
|
|
64
|
+
log(`Counter init hash: ${counter.initHash}`);
|
|
65
|
+
log(`Counter salt: ${counter.salt}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Step 1. Deploy the L1 contracts, but don't initialize
|
|
70
|
+
*/ async function deployERC20({ walletClient, publicClient }) {
|
|
71
|
+
const { TestERC20Abi, TestERC20Bytecode, TokenPortalAbi, TokenPortalBytecode } = await import('@aztec/l1-artifacts');
|
|
72
|
+
const erc20 = {
|
|
73
|
+
contractAbi: TestERC20Abi,
|
|
74
|
+
contractBytecode: TestERC20Bytecode
|
|
75
|
+
};
|
|
76
|
+
const portal = {
|
|
77
|
+
contractAbi: TokenPortalAbi,
|
|
78
|
+
contractBytecode: TokenPortalBytecode
|
|
79
|
+
};
|
|
80
|
+
const { address: erc20Address } = await deployL1Contract(walletClient, publicClient, erc20.contractAbi, erc20.contractBytecode, [
|
|
81
|
+
'DevCoin',
|
|
82
|
+
'DEV',
|
|
83
|
+
walletClient.account.address
|
|
84
|
+
]);
|
|
85
|
+
const { address: portalAddress } = await deployL1Contract(walletClient, publicClient, portal.contractAbi, portal.contractBytecode);
|
|
86
|
+
return {
|
|
87
|
+
erc20Address,
|
|
88
|
+
portalAddress
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Step 2. Deploy the L2 contracts
|
|
93
|
+
*/ async function deployToken(wallet, l1Portal) {
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
95
|
+
// @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
|
|
96
|
+
const { TokenContract } = await import('@aztec/noir-contracts.js/Token');
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
98
|
+
// @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
|
|
99
|
+
const { TokenBridgeContract } = await import('@aztec/noir-contracts.js/TokenBridge');
|
|
100
|
+
const devCoin = await TokenContract.deploy(wallet, wallet.getAddress(), 'DevCoin', 'DEV', 18).send({
|
|
101
|
+
universalDeploy: true
|
|
102
|
+
}).deployed(waitOpts);
|
|
103
|
+
const bridge = await TokenBridgeContract.deploy(wallet, devCoin.address, l1Portal).send({
|
|
104
|
+
universalDeploy: true
|
|
105
|
+
}).deployed(waitOpts);
|
|
106
|
+
await new BatchCall(wallet, [
|
|
107
|
+
await devCoin.methods.set_minter(bridge.address, true).request(),
|
|
108
|
+
await devCoin.methods.set_admin(bridge.address).request()
|
|
109
|
+
]).send().wait(waitOpts);
|
|
110
|
+
return {
|
|
111
|
+
token: {
|
|
112
|
+
address: devCoin.address,
|
|
113
|
+
initHash: devCoin.instance.initializationHash,
|
|
114
|
+
salt: devCoin.instance.salt
|
|
115
|
+
},
|
|
116
|
+
bridge: {
|
|
117
|
+
address: bridge.address,
|
|
118
|
+
initHash: bridge.instance.initializationHash,
|
|
119
|
+
salt: bridge.instance.salt
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Step 3. Initialize DevCoin's L1 portal
|
|
125
|
+
*/ async function initPortal(pxe, { walletClient, publicClient }, erc20, portal, bridge) {
|
|
126
|
+
const { TokenPortalAbi } = await import('@aztec/l1-artifacts');
|
|
127
|
+
const { l1ContractAddresses: { registryAddress } } = await pxe.getNodeInfo();
|
|
128
|
+
const contract = getContract({
|
|
129
|
+
abi: TokenPortalAbi,
|
|
130
|
+
address: portal.toString(),
|
|
131
|
+
client: walletClient
|
|
132
|
+
});
|
|
133
|
+
const hash = await contract.write.initialize([
|
|
134
|
+
registryAddress.toString(),
|
|
135
|
+
erc20.toString(),
|
|
136
|
+
bridge.toString()
|
|
137
|
+
]);
|
|
138
|
+
await publicClient.waitForTransactionReceipt({
|
|
139
|
+
hash
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async function deployFPC(wallet, tokenAddress, admin) {
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
144
|
+
// @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
|
|
145
|
+
const { FPCContract } = await import('@aztec/noir-contracts.js/FPC');
|
|
146
|
+
const fpc = await FPCContract.deploy(wallet, tokenAddress, admin).send({
|
|
147
|
+
universalDeploy: true
|
|
148
|
+
}).deployed(waitOpts);
|
|
149
|
+
const info = {
|
|
150
|
+
address: fpc.address,
|
|
151
|
+
initHash: fpc.instance.initializationHash,
|
|
152
|
+
salt: fpc.instance.salt
|
|
153
|
+
};
|
|
154
|
+
return info;
|
|
155
|
+
}
|
|
156
|
+
async function deployCounter(wallet) {
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
158
|
+
// @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
|
|
159
|
+
const { CounterContract } = await import('@aztec/noir-contracts.js/Counter');
|
|
160
|
+
const counter = await CounterContract.deploy(wallet, 1, wallet.getAddress()).send({
|
|
161
|
+
universalDeploy: true
|
|
162
|
+
}).deployed(waitOpts);
|
|
163
|
+
const info = {
|
|
164
|
+
address: counter.address,
|
|
165
|
+
initHash: counter.instance.initializationHash,
|
|
166
|
+
salt: counter.instance.salt
|
|
167
|
+
};
|
|
168
|
+
return info;
|
|
169
|
+
}
|
|
170
|
+
// NOTE: Disabling for now in order to get devnet running
|
|
171
|
+
async function fundFPC(counterAddress, wallet, l1Clients, fpcAddress, debugLog) {
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
173
|
+
// @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
|
|
174
|
+
const { FeeJuiceContract } = await import('@aztec/noir-contracts.js/FeeJuice');
|
|
175
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
176
|
+
// @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
|
|
177
|
+
const { CounterContract } = await import('@aztec/noir-contracts.js/Counter');
|
|
178
|
+
const { protocolContractAddresses: { feeJuice } } = await wallet.getPXEInfo();
|
|
179
|
+
const feeJuiceContract = await FeeJuiceContract.at(feeJuice, wallet);
|
|
180
|
+
const feeJuicePortal = await L1FeeJuicePortalManager.new(wallet, l1Clients.publicClient, l1Clients.walletClient, debugLog);
|
|
181
|
+
const amount = FEE_FUNDING_FOR_TESTER_ACCOUNT;
|
|
182
|
+
const { claimAmount, claimSecret, messageLeafIndex, messageHash } = await feeJuicePortal.bridgeTokensPublic(fpcAddress, amount, true);
|
|
183
|
+
await retryUntil(async ()=>await wallet.isL1ToL2MessageSynced(Fr.fromHexString(messageHash)), 'message sync', 600, 1);
|
|
184
|
+
const counter = await CounterContract.at(counterAddress, wallet);
|
|
185
|
+
// TODO (alexg) remove this once sequencer builds blocks continuously
|
|
186
|
+
// advance the chain
|
|
187
|
+
await counter.methods.increment(wallet.getAddress(), wallet.getAddress()).send().wait(waitOpts);
|
|
188
|
+
await counter.methods.increment(wallet.getAddress(), wallet.getAddress()).send().wait(waitOpts);
|
|
189
|
+
await feeJuiceContract.methods.claim(fpcAddress, claimAmount, claimSecret, messageLeafIndex).send().wait({
|
|
190
|
+
...waitOpts,
|
|
191
|
+
proven: true
|
|
192
|
+
});
|
|
193
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { prettyPrintJSON } from '../../utils/commands.js';
|
|
2
|
+
export async function dripFaucet(faucetUrl, asset, account, json, log) {
|
|
3
|
+
const url = new URL(`/drip/${account.toString()}`, faucetUrl);
|
|
4
|
+
url.searchParams.set('asset', asset);
|
|
5
|
+
const res = await fetch(url);
|
|
6
|
+
if (res.status === 200) {
|
|
7
|
+
if (json) {
|
|
8
|
+
log(prettyPrintJSON({
|
|
9
|
+
ok: true
|
|
10
|
+
}));
|
|
11
|
+
} else {
|
|
12
|
+
log(`Dripped ${asset} for ${account.toString()}`);
|
|
13
|
+
}
|
|
14
|
+
} else {
|
|
15
|
+
if (json) {
|
|
16
|
+
log(prettyPrintJSON({
|
|
17
|
+
ok: false
|
|
18
|
+
}));
|
|
19
|
+
} else if (res.status === 429) {
|
|
20
|
+
log(`Rate limited when dripping ${asset} for ${account.toString()}`);
|
|
21
|
+
} else {
|
|
22
|
+
log(`Failed to drip ${asset} for ${account.toString()}`);
|
|
23
|
+
}
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ETHEREUM_HOST, l1ChainIdOption, parseEthereumAddress, pxeOption } from '../../utils/commands.js';
|
|
2
|
+
export function injectCommands(program, log, debugLogger) {
|
|
3
|
+
program.command('bootstrap-network').description('Bootstrap a new network').addOption(pxeOption).addOption(l1ChainIdOption).requiredOption('--l1-rpc-url <string>', 'Url of the ethereum host. Chain identifiers localhost and testnet can be used', ETHEREUM_HOST).option('--l1-private-key <string>', 'The private key to use for deployment', process.env.PRIVATE_KEY).option('-m, --mnemonic <string>', 'The mnemonic to use in deployment', 'test test test test test test test test test test test junk').option('--json', 'Output the result as JSON').action(async (options)=>{
|
|
4
|
+
const { bootstrapNetwork } = await import('./bootstrap_network.js');
|
|
5
|
+
await bootstrapNetwork(options[pxeOption.attributeName()], options.l1RpcUrl, options[l1ChainIdOption.attributeName()], options.l1PrivateKey, options.mnemonic, options.json, log, debugLogger);
|
|
6
|
+
});
|
|
7
|
+
program.command('drip-faucet').description('Drip the faucet').requiredOption('-u, --faucet-url <string>', 'Url of the faucet', 'http://localhost:8082').requiredOption('-t, --token <string>', 'The asset to drip', 'eth').requiredOption('-a, --address <string>', 'The Ethereum address to drip to', parseEthereumAddress).option('--json', 'Output the result as JSON').action(async (options)=>{
|
|
8
|
+
const { dripFaucet } = await import('./faucet.js');
|
|
9
|
+
await dripFaucet(options.faucetUrl, options.token, options.address, options.json, log);
|
|
10
|
+
});
|
|
11
|
+
return program;
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ETHEREUM_HOST, l1ChainIdOption, parseOptionalInteger, pxeOption } from '../../utils/commands.js';
|
|
2
|
+
export function injectCommands(program, log, debugLogger) {
|
|
3
|
+
program.command('setup-protocol-contracts').description('Bootstrap the blockchain by initializing all the protocol contracts').addOption(pxeOption).addOption(l1ChainIdOption).option('--json', 'Output the contract addresses in JSON format').option('--skipProofWait', "Don't wait for proofs to land.").action(async (options)=>{
|
|
4
|
+
const { setupProtocolContracts } = await import('./setup_protocol_contract.js');
|
|
5
|
+
await setupProtocolContracts(options.rpcUrl, options.l1ChainId, options.json, options.skipProofWait, log);
|
|
6
|
+
});
|
|
7
|
+
program.command('sequencers').argument('<command>', 'Command to run: list, add, remove, who-next').argument('[who]', 'Who to add/remove').description('Manages or queries registered sequencers on the L1 rollup contract.').requiredOption('--l1-rpc-url <string>', 'Url of the ethereum host. Chain identifiers localhost and testnet can be used', ETHEREUM_HOST).option('-m, --mnemonic <string>', 'The mnemonic for the sender of the tx', 'test test test test test test test test test test test junk').option('--block-number <number>', 'Block number to query next sequencer for', parseOptionalInteger).addOption(pxeOption).addOption(l1ChainIdOption).action(async (command, who, options)=>{
|
|
8
|
+
const { sequencers } = await import('./sequencers.js');
|
|
9
|
+
await sequencers({
|
|
10
|
+
command: command,
|
|
11
|
+
who,
|
|
12
|
+
mnemonic: options.mnemonic,
|
|
13
|
+
rpcUrl: options.rpcUrl,
|
|
14
|
+
l1RpcUrl: options.l1RpcUrl,
|
|
15
|
+
chainId: options.l1ChainId,
|
|
16
|
+
blockNumber: options.blockNumber,
|
|
17
|
+
log,
|
|
18
|
+
debugLogger
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
return program;
|
|
22
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
import { createEthereumChain, getL1ContractsConfigEnvVars } from '@aztec/ethereum';
|
|
3
|
+
import { RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
|
|
4
|
+
import { createPublicClient, createWalletClient, getContract, http } from 'viem';
|
|
5
|
+
import { mnemonicToAccount } from 'viem/accounts';
|
|
6
|
+
export async function sequencers(opts) {
|
|
7
|
+
const { command, who: maybeWho, mnemonic, rpcUrl, l1RpcUrl, chainId, log, debugLogger } = opts;
|
|
8
|
+
const client = await createCompatibleClient(rpcUrl, debugLogger);
|
|
9
|
+
const { l1ContractAddresses } = await client.getNodeInfo();
|
|
10
|
+
const chain = createEthereumChain(l1RpcUrl, chainId);
|
|
11
|
+
const publicClient = createPublicClient({
|
|
12
|
+
chain: chain.chainInfo,
|
|
13
|
+
transport: http(chain.rpcUrl)
|
|
14
|
+
});
|
|
15
|
+
const walletClient = mnemonic ? createWalletClient({
|
|
16
|
+
account: mnemonicToAccount(mnemonic),
|
|
17
|
+
chain: chain.chainInfo,
|
|
18
|
+
transport: http(chain.rpcUrl)
|
|
19
|
+
}) : undefined;
|
|
20
|
+
const rollup = getContract({
|
|
21
|
+
address: l1ContractAddresses.rollupAddress.toString(),
|
|
22
|
+
abi: RollupAbi,
|
|
23
|
+
client: publicClient
|
|
24
|
+
});
|
|
25
|
+
const writeableRollup = walletClient ? getContract({
|
|
26
|
+
address: l1ContractAddresses.rollupAddress.toString(),
|
|
27
|
+
abi: RollupAbi,
|
|
28
|
+
client: walletClient
|
|
29
|
+
}) : undefined;
|
|
30
|
+
const who = maybeWho ?? walletClient?.account.address.toString();
|
|
31
|
+
if (command === 'list') {
|
|
32
|
+
const sequencers = await rollup.read.getAttesters();
|
|
33
|
+
if (sequencers.length === 0) {
|
|
34
|
+
log(`No sequencers registered on rollup`);
|
|
35
|
+
} else {
|
|
36
|
+
log(`Registered sequencers on rollup:`);
|
|
37
|
+
for (const sequencer of sequencers){
|
|
38
|
+
log(' ' + sequencer.toString());
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} else if (command === 'add') {
|
|
42
|
+
if (!who || !writeableRollup || !walletClient) {
|
|
43
|
+
throw new Error(`Missing sequencer address`);
|
|
44
|
+
}
|
|
45
|
+
log(`Adding ${who} as sequencer`);
|
|
46
|
+
const stakingAsset = getContract({
|
|
47
|
+
address: await rollup.read.getStakingAsset(),
|
|
48
|
+
abi: TestERC20Abi,
|
|
49
|
+
client: walletClient
|
|
50
|
+
});
|
|
51
|
+
const config = getL1ContractsConfigEnvVars();
|
|
52
|
+
await Promise.all([
|
|
53
|
+
await stakingAsset.write.mint([
|
|
54
|
+
walletClient.account.address,
|
|
55
|
+
config.minimumStake
|
|
56
|
+
], {}),
|
|
57
|
+
await stakingAsset.write.approve([
|
|
58
|
+
rollup.address,
|
|
59
|
+
config.minimumStake
|
|
60
|
+
], {})
|
|
61
|
+
].map((txHash)=>publicClient.waitForTransactionReceipt({
|
|
62
|
+
hash: txHash
|
|
63
|
+
})));
|
|
64
|
+
const hash = await writeableRollup.write.deposit([
|
|
65
|
+
who,
|
|
66
|
+
who,
|
|
67
|
+
who,
|
|
68
|
+
config.minimumStake
|
|
69
|
+
]);
|
|
70
|
+
await publicClient.waitForTransactionReceipt({
|
|
71
|
+
hash
|
|
72
|
+
});
|
|
73
|
+
log(`Added in tx ${hash}`);
|
|
74
|
+
} else if (command === 'remove') {
|
|
75
|
+
if (!who || !writeableRollup) {
|
|
76
|
+
throw new Error(`Missing sequencer address`);
|
|
77
|
+
}
|
|
78
|
+
log(`Removing ${who} as sequencer`);
|
|
79
|
+
const hash = await writeableRollup.write.initiateWithdraw([
|
|
80
|
+
who,
|
|
81
|
+
who
|
|
82
|
+
]);
|
|
83
|
+
await publicClient.waitForTransactionReceipt({
|
|
84
|
+
hash
|
|
85
|
+
});
|
|
86
|
+
log(`Removed in tx ${hash}`);
|
|
87
|
+
} else if (command === 'who-next') {
|
|
88
|
+
const next = await rollup.read.getCurrentProposer();
|
|
89
|
+
log(`Sequencer expected to build is ${next}`);
|
|
90
|
+
} else {
|
|
91
|
+
throw new Error(`Unknown command ${command}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SignerlessWallet, createPXEClient, makeFetch } from '@aztec/aztec.js';
|
|
2
|
+
import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint';
|
|
3
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
4
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
|
+
import { setupCanonicalL2FeeJuice } from '../misc/setup_contracts.js';
|
|
6
|
+
export async function setupProtocolContracts(rpcUrl, l1ChainId, json, skipProofWait, log) {
|
|
7
|
+
const waitOpts = {
|
|
8
|
+
timeout: 180,
|
|
9
|
+
interval: 1,
|
|
10
|
+
proven: !skipProofWait,
|
|
11
|
+
provenTimeout: 600
|
|
12
|
+
};
|
|
13
|
+
log('setupProtocolContracts: Wait options' + jsonStringify(waitOpts));
|
|
14
|
+
log('setupProtocolContracts: Creating PXE client...');
|
|
15
|
+
const pxe = createPXEClient(rpcUrl, makeFetch([
|
|
16
|
+
1,
|
|
17
|
+
1,
|
|
18
|
+
1,
|
|
19
|
+
1,
|
|
20
|
+
1
|
|
21
|
+
], false));
|
|
22
|
+
const wallet = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(l1ChainId, 1));
|
|
23
|
+
log('setupProtocolContracts: Getting fee juice portal address...');
|
|
24
|
+
// Deploy Fee Juice
|
|
25
|
+
const feeJuicePortalAddress = (await wallet.getNodeInfo()).l1ContractAddresses.feeJuicePortalAddress;
|
|
26
|
+
log('setupProtocolContracts: Setting up fee juice portal...');
|
|
27
|
+
await setupCanonicalL2FeeJuice(wallet, feeJuicePortalAddress, waitOpts, log);
|
|
28
|
+
if (json) {
|
|
29
|
+
log(JSON.stringify(ProtocolContractAddress, null, 2));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CheatCodes, createPXEClient, makeFetch } from '@aztec/aztec.js';
|
|
2
|
+
export async function advanceEpoch(l1RpcUrl, rpcUrl, log) {
|
|
3
|
+
const pxe = createPXEClient(rpcUrl, makeFetch([], true));
|
|
4
|
+
const rollupAddress = await pxe.getNodeInfo().then((i)=>i.l1ContractAddresses.rollupAddress);
|
|
5
|
+
const cheat = CheatCodes.createRollup(l1RpcUrl, {
|
|
6
|
+
rollupAddress
|
|
7
|
+
});
|
|
8
|
+
await cheat.advanceToNextEpoch();
|
|
9
|
+
log(`Warped time to advance to next epoch`);
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createPXEClient, makeFetch } from '@aztec/aztec.js';
|
|
2
|
+
import { createEthereumChain, createL1Clients } from '@aztec/ethereum';
|
|
3
|
+
import { setAssumeProvenThrough } from '../../utils/aztec.js';
|
|
4
|
+
export async function assumeProvenThrough(blockNumberOrLatest, l1RpcUrl, rpcUrl, chainId, privateKey, mnemonic, log) {
|
|
5
|
+
const chain = createEthereumChain(l1RpcUrl, chainId);
|
|
6
|
+
const { walletClient } = createL1Clients(chain.rpcUrl, privateKey ?? mnemonic, chain.chainInfo);
|
|
7
|
+
const pxe = createPXEClient(rpcUrl, makeFetch([], true));
|
|
8
|
+
const rollupAddress = await pxe.getNodeInfo().then((i)=>i.l1ContractAddresses.rollupAddress);
|
|
9
|
+
const blockNumber = blockNumberOrLatest ?? await pxe.getBlockNumber();
|
|
10
|
+
await setAssumeProvenThrough(blockNumber, rollupAddress, walletClient);
|
|
11
|
+
log(`Assumed proven through block ${blockNumber}`);
|
|
12
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { L1ToL2TokenPortalManager } from '@aztec/aztec.js';
|
|
2
|
+
import { createEthereumChain, createL1Clients } from '@aztec/ethereum';
|
|
3
|
+
import { prettyPrintJSON } from '../../utils/commands.js';
|
|
4
|
+
export async function bridgeERC20(amount, recipient, l1RpcUrl, chainId, privateKey, mnemonic, tokenAddress, portalAddress, privateTransfer, mint, json, log, debugLogger) {
|
|
5
|
+
// Prepare L1 client
|
|
6
|
+
const chain = createEthereumChain(l1RpcUrl, chainId);
|
|
7
|
+
const { publicClient, walletClient } = createL1Clients(chain.rpcUrl, privateKey ?? mnemonic, chain.chainInfo);
|
|
8
|
+
// Setup portal manager
|
|
9
|
+
const manager = new L1ToL2TokenPortalManager(portalAddress, tokenAddress, publicClient, walletClient, debugLogger);
|
|
10
|
+
let claimSecret;
|
|
11
|
+
let messageHash;
|
|
12
|
+
if (privateTransfer) {
|
|
13
|
+
({ claimSecret, messageHash } = await manager.bridgeTokensPrivate(recipient, amount, mint));
|
|
14
|
+
} else {
|
|
15
|
+
({ claimSecret, messageHash } = await manager.bridgeTokensPublic(recipient, amount, mint));
|
|
16
|
+
}
|
|
17
|
+
if (json) {
|
|
18
|
+
log(prettyPrintJSON({
|
|
19
|
+
claimAmount: amount,
|
|
20
|
+
claimSecret: claimSecret
|
|
21
|
+
}));
|
|
22
|
+
} else {
|
|
23
|
+
if (mint) {
|
|
24
|
+
log(`Minted ${amount} tokens on L1 and pushed to L2 portal`);
|
|
25
|
+
} else {
|
|
26
|
+
log(`Bridged ${amount} tokens to L2 portal`);
|
|
27
|
+
}
|
|
28
|
+
log(`claimAmount=${amount},claimSecret=${claimSecret}\n,messageHash=${messageHash}`);
|
|
29
|
+
log(`Note: You need to wait for two L2 blocks before pulling them from the L2 side`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
2
|
+
import { prettyPrintJSON } from '../../utils/commands.js';
|
|
3
|
+
export function createL1Account(json, log) {
|
|
4
|
+
const privateKey = generatePrivateKey();
|
|
5
|
+
const account = privateKeyToAccount(privateKey);
|
|
6
|
+
if (json) {
|
|
7
|
+
log(prettyPrintJSON({
|
|
8
|
+
privateKey,
|
|
9
|
+
address: account.address
|
|
10
|
+
}));
|
|
11
|
+
} else {
|
|
12
|
+
log(`Private Key: ${privateKey}`);
|
|
13
|
+
log(`Address: ${account.address}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum';
|
|
2
|
+
import { deployAztecContracts } from '../../utils/aztec.js';
|
|
3
|
+
export async function deployL1Contracts(rpcUrl, chainId, privateKey, mnemonic, mnemonicIndex, salt, json, initialValidators, log, debugLogger) {
|
|
4
|
+
const config = getL1ContractsConfigEnvVars();
|
|
5
|
+
const { l1ContractAddresses } = await deployAztecContracts(rpcUrl, chainId, privateKey, mnemonic, mnemonicIndex, salt, initialValidators, config, debugLogger);
|
|
6
|
+
if (json) {
|
|
7
|
+
log(JSON.stringify(Object.fromEntries(Object.entries(l1ContractAddresses).map(([k, v])=>[
|
|
8
|
+
k,
|
|
9
|
+
v.toString()
|
|
10
|
+
])), null, 2));
|
|
11
|
+
} else {
|
|
12
|
+
log(`Rollup Address: ${l1ContractAddresses.rollupAddress.toString()}`);
|
|
13
|
+
log(`Registry Address: ${l1ContractAddresses.registryAddress.toString()}`);
|
|
14
|
+
log(`L1 -> L2 Inbox Address: ${l1ContractAddresses.inboxAddress.toString()}`);
|
|
15
|
+
log(`L2 -> L1 Outbox Address: ${l1ContractAddresses.outboxAddress.toString()}`);
|
|
16
|
+
log(`Fee Juice Address: ${l1ContractAddresses.feeJuiceAddress.toString()}`);
|
|
17
|
+
log(`Staking Asset Address: ${l1ContractAddresses.stakingAssetAddress.toString()}`);
|
|
18
|
+
log(`Fee Juice Portal Address: ${l1ContractAddresses.feeJuicePortalAddress.toString()}`);
|
|
19
|
+
log(`CoinIssuer Address: ${l1ContractAddresses.coinIssuerAddress.toString()}`);
|
|
20
|
+
log(`RewardDistributor Address: ${l1ContractAddresses.rewardDistributorAddress.toString()}`);
|
|
21
|
+
log(`GovernanceProposer Address: ${l1ContractAddresses.governanceProposerAddress.toString()}`);
|
|
22
|
+
log(`Governance Address: ${l1ContractAddresses.governanceAddress.toString()}`);
|
|
23
|
+
log(`SlashFactory Address: ${l1ContractAddresses.slashFactoryAddress.toString()}`);
|
|
24
|
+
}
|
|
25
|
+
}
|