@aztec/cli 0.0.0-test.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +449 -0
- 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/contracts/parse_parameter_struct.d.ts +3 -0
- 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 +17 -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 +4 -0
- package/dest/cmds/misc/update/github.d.ts.map +1 -0
- package/dest/cmds/misc/update/github.js +3 -0
- package/dest/cmds/misc/update/noir.d.ts +10 -0
- package/dest/cmds/misc/update/noir.d.ts.map +1 -0
- package/dest/cmds/misc/update/noir.js +45 -0
- package/dest/cmds/misc/update/npm.d.ts +34 -0
- 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 +174 -0
- package/dest/utils/commands.d.ts +143 -0
- package/dest/utils/commands.d.ts.map +1 -0
- package/dest/utils/commands.js +303 -0
- package/dest/utils/encoding.d.ts +15 -0
- 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 +125 -0
- 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 +65 -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 +558 -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 +250 -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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createAztecNodeClient, createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
export async function getNodeInfo(rpcUrl, pxeRequest, debugLogger, json, log, logJson) {
|
|
3
|
+
let client;
|
|
4
|
+
if (pxeRequest) {
|
|
5
|
+
client = await createCompatibleClient(rpcUrl, debugLogger);
|
|
6
|
+
} else {
|
|
7
|
+
client = createAztecNodeClient(rpcUrl);
|
|
8
|
+
}
|
|
9
|
+
const info = await client.getNodeInfo();
|
|
10
|
+
if (json) {
|
|
11
|
+
logJson({
|
|
12
|
+
nodeVersion: info.nodeVersion,
|
|
13
|
+
l1ChainId: info.l1ChainId,
|
|
14
|
+
protocolVersion: info.protocolVersion,
|
|
15
|
+
enr: info.enr,
|
|
16
|
+
l1ContractAddresses: {
|
|
17
|
+
rollup: info.l1ContractAddresses.rollupAddress.toString(),
|
|
18
|
+
registry: info.l1ContractAddresses.registryAddress.toString(),
|
|
19
|
+
inbox: info.l1ContractAddresses.inboxAddress.toString(),
|
|
20
|
+
outbox: info.l1ContractAddresses.outboxAddress.toString(),
|
|
21
|
+
feeJuice: info.l1ContractAddresses.feeJuiceAddress.toString(),
|
|
22
|
+
stakingAsset: info.l1ContractAddresses.stakingAssetAddress.toString(),
|
|
23
|
+
feeJuicePortal: info.l1ContractAddresses.feeJuicePortalAddress.toString(),
|
|
24
|
+
coinIssuer: info.l1ContractAddresses.coinIssuerAddress.toString(),
|
|
25
|
+
rewardDistributor: info.l1ContractAddresses.rewardDistributorAddress.toString(),
|
|
26
|
+
governanceProposer: info.l1ContractAddresses.governanceProposerAddress.toString(),
|
|
27
|
+
governance: info.l1ContractAddresses.governanceAddress.toString(),
|
|
28
|
+
slashFactory: info.l1ContractAddresses.slashFactoryAddress?.toString()
|
|
29
|
+
},
|
|
30
|
+
protocolContractAddresses: {
|
|
31
|
+
classRegisterer: info.protocolContractAddresses.classRegisterer.toString(),
|
|
32
|
+
feeJuice: info.protocolContractAddresses.feeJuice.toString(),
|
|
33
|
+
instanceDeployer: info.protocolContractAddresses.instanceDeployer.toString(),
|
|
34
|
+
multiCallEntrypoint: info.protocolContractAddresses.multiCallEntrypoint.toString()
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
log(`Node Version: ${info.nodeVersion}`);
|
|
39
|
+
log(`Chain Id: ${info.l1ChainId}`);
|
|
40
|
+
log(`Protocol Version: ${info.protocolVersion}`);
|
|
41
|
+
log(`Node ENR: ${info.enr}`);
|
|
42
|
+
log(`L1 Contract Addresses:`);
|
|
43
|
+
log(` Rollup Address: ${info.l1ContractAddresses.rollupAddress.toString()}`);
|
|
44
|
+
log(` Registry Address: ${info.l1ContractAddresses.registryAddress.toString()}`);
|
|
45
|
+
log(` L1 -> L2 Inbox Address: ${info.l1ContractAddresses.inboxAddress.toString()}`);
|
|
46
|
+
log(` L2 -> L1 Outbox Address: ${info.l1ContractAddresses.outboxAddress.toString()}`);
|
|
47
|
+
log(` Fee Juice Address: ${info.l1ContractAddresses.feeJuiceAddress.toString()}`);
|
|
48
|
+
log(` Staking Asset Address: ${info.l1ContractAddresses.stakingAssetAddress.toString()}`);
|
|
49
|
+
log(` Fee Juice Portal Address: ${info.l1ContractAddresses.feeJuicePortalAddress.toString()}`);
|
|
50
|
+
log(` CoinIssuer Address: ${info.l1ContractAddresses.coinIssuerAddress.toString()}`);
|
|
51
|
+
log(` RewardDistributor Address: ${info.l1ContractAddresses.rewardDistributorAddress.toString()}`);
|
|
52
|
+
log(` GovernanceProposer Address: ${info.l1ContractAddresses.governanceProposerAddress.toString()}`);
|
|
53
|
+
log(` Governance Address: ${info.l1ContractAddresses.governanceAddress.toString()}`);
|
|
54
|
+
log(` SlashFactory Address: ${info.l1ContractAddresses.slashFactoryAddress?.toString()}`);
|
|
55
|
+
log(`L2 Contract Addresses:`);
|
|
56
|
+
log(` Class Registerer: ${info.protocolContractAddresses.classRegisterer.toString()}`);
|
|
57
|
+
log(` Fee Juice: ${info.protocolContractAddresses.feeJuice.toString()}`);
|
|
58
|
+
log(` Instance Deployer: ${info.protocolContractAddresses.instanceDeployer.toString()}`);
|
|
59
|
+
log(` MultiCall: ${info.protocolContractAddresses.multiCallEntrypoint.toString()}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_pxe_info.d.ts","sourceRoot":"","sources":["../../../src/cmds/pxe/get_pxe_info.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,iBAS/E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
export async function getPXEInfo(rpcUrl, debugLogger, log) {
|
|
3
|
+
const client = await createCompatibleClient(rpcUrl, debugLogger);
|
|
4
|
+
const info = await client.getPXEInfo();
|
|
5
|
+
log(`PXE Version: ${info.pxeVersion}`);
|
|
6
|
+
log(`Protocol Contract Addresses:`);
|
|
7
|
+
log(` Class Registerer: ${info.protocolContractAddresses.classRegisterer.toString()}`);
|
|
8
|
+
log(` Fee Juice: ${info.protocolContractAddresses.feeJuice.toString()}`);
|
|
9
|
+
log(` Instance Deployer: ${info.protocolContractAddresses.instanceDeployer.toString()}`);
|
|
10
|
+
log(` Multi Call Entrypoint: ${info.protocolContractAddresses.multiCallEntrypoint.toString()}`);
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/pxe/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBzC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAqJ/E"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { logJson, makePxeOption, parseAztecAddress, parseEthereumAddress, parseField, parseFieldFromHexString, parseOptionalAztecAddress, parseOptionalInteger, parseOptionalLogId, parseOptionalTxHash, parsePublicKey, pxeOption } from '../../utils/commands.js';
|
|
3
|
+
export function injectCommands(program, log, debugLogger) {
|
|
4
|
+
program.command('add-contract').description('Adds an existing contract to the PXE. This is useful if you have deployed a contract outside of the PXE and want to use it with the PXE.').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('-ca, --contract-address <address>', 'Aztec address of the contract.', parseAztecAddress).requiredOption('--init-hash <init hash>', 'Initialization hash', parseFieldFromHexString).option('--salt <salt>', 'Optional deployment salt', parseFieldFromHexString).option('-p, --public-key <public key>', 'Optional public key for this contract', parsePublicKey).option('--portal-address <address>', 'Optional address to a portal contract on L1', parseEthereumAddress).option('--deployer-address <address>', 'Optional address of the contract deployer', parseAztecAddress).addOption(pxeOption).action(async (options)=>{
|
|
5
|
+
const { addContract } = await import('./add_contract.js');
|
|
6
|
+
await addContract(options.rpcUrl, options.contractArtifact, options.contractAddress, options.initHash, options.salt ?? Fr.ZERO, options.publicKey, options.deployerAddress, debugLogger, log);
|
|
7
|
+
});
|
|
8
|
+
program.command('get-block').description('Gets info for a given block or latest.').argument('[blockNumber]', 'Block height', parseOptionalInteger).addOption(pxeOption).action(async (blockNumber, options)=>{
|
|
9
|
+
const { getBlock } = await import('./get_block.js');
|
|
10
|
+
await getBlock(options.rpcUrl, blockNumber, debugLogger, log);
|
|
11
|
+
});
|
|
12
|
+
program.command('get-current-base-fee').description('Gets the current base fee.').addOption(pxeOption).action(async (options)=>{
|
|
13
|
+
const { getCurrentBaseFee } = await import('./get_current_base_fee.js');
|
|
14
|
+
await getCurrentBaseFee(options.rpcUrl, debugLogger, log);
|
|
15
|
+
});
|
|
16
|
+
program.command('get-contract-data').description('Gets information about the Aztec contract deployed at the specified address.').argument('<contractAddress>', 'Aztec address of the contract.', parseAztecAddress).addOption(pxeOption).option('-b, --include-bytecode <boolean>', "Include the contract's public function bytecode, if any.", false).action(async (contractAddress, options)=>{
|
|
17
|
+
const { getContractData } = await import('./get_contract_data.js');
|
|
18
|
+
await getContractData(options.rpcUrl, contractAddress, options.includeBytecode, debugLogger, log);
|
|
19
|
+
});
|
|
20
|
+
program.command('get-logs').description('Gets all the public logs from an intersection of all the filter params.').option('-tx, --tx-hash <txHash>', 'A transaction hash to get the receipt for.', parseOptionalTxHash).option('-fb, --from-block <blockNum>', 'Initial block number for getting logs (defaults to 1).', parseOptionalInteger).option('-tb, --to-block <blockNum>', 'Up to which block to fetch logs (defaults to latest).', parseOptionalInteger).option('-al --after-log <logId>', 'ID of a log after which to fetch the logs.', parseOptionalLogId).option('-ca, --contract-address <address>', 'Contract address to filter logs by.', parseOptionalAztecAddress).addOption(pxeOption).option('--follow', 'If set, will keep polling for new logs until interrupted.').action(async ({ txHash, fromBlock, toBlock, afterLog, contractAddress, rpcUrl, follow })=>{
|
|
21
|
+
const { getLogs } = await import('./get_logs.js');
|
|
22
|
+
await getLogs(txHash, fromBlock, toBlock, afterLog, contractAddress, rpcUrl, follow, debugLogger, log);
|
|
23
|
+
});
|
|
24
|
+
program.command('get-accounts').description('Gets all the Aztec accounts stored in the PXE.').addOption(pxeOption).option('--json', 'Emit output as json').action(async (options)=>{
|
|
25
|
+
const { getAccounts } = await import('./get_accounts.js');
|
|
26
|
+
await getAccounts(options.rpcUrl, options.json, debugLogger, log, logJson(log));
|
|
27
|
+
});
|
|
28
|
+
program.command('get-account').description('Gets an account given its Aztec address.').argument('<address>', 'The Aztec address to get account for', parseAztecAddress).addOption(pxeOption).action(async (address, options)=>{
|
|
29
|
+
const { getAccount } = await import('./get_account.js');
|
|
30
|
+
await getAccount(address, options.rpcUrl, debugLogger, log);
|
|
31
|
+
});
|
|
32
|
+
program.command('block-number').description('Gets the current Aztec L2 block number.').addOption(pxeOption).action(async (options)=>{
|
|
33
|
+
const { blockNumber } = await import('./block_number.js');
|
|
34
|
+
await blockNumber(options.rpcUrl, debugLogger, log);
|
|
35
|
+
});
|
|
36
|
+
program.command('get-l1-to-l2-message-witness').description('Gets a L1 to L2 message witness.').requiredOption('-ca, --contract-address <address>', 'Aztec address of the contract.', parseAztecAddress).requiredOption('--message-hash <messageHash>', 'The L1 to L2 message hash.', parseField).requiredOption('--secret <secret>', 'The secret used to claim the L1 to L2 message', parseField).addOption(pxeOption).action(async ({ contractAddress, messageHash, secret, rpcUrl })=>{
|
|
37
|
+
const { getL1ToL2MessageWitness } = await import('./get_l1_to_l2_message_witness.js');
|
|
38
|
+
await getL1ToL2MessageWitness(rpcUrl, contractAddress, messageHash, secret, debugLogger, log);
|
|
39
|
+
});
|
|
40
|
+
program.command('get-node-info').description('Gets the information of an Aztec node from a PXE or directly from an Aztec node.').option('--node-url <string>', 'URL of the node.').option('--json', 'Emit output as json').addOption(makePxeOption(false)).action(async (options)=>{
|
|
41
|
+
const { getNodeInfo } = await import('./get_node_info.js');
|
|
42
|
+
let url;
|
|
43
|
+
if (options.nodeUrl) {
|
|
44
|
+
url = options.nodeUrl;
|
|
45
|
+
} else {
|
|
46
|
+
url = options.rpcUrl;
|
|
47
|
+
}
|
|
48
|
+
await getNodeInfo(url, !options.nodeUrl, debugLogger, options.json, log, logJson(log));
|
|
49
|
+
});
|
|
50
|
+
program.command('get-pxe-info').description('Gets the information of a PXE at a URL.').addOption(pxeOption).action(async (options)=>{
|
|
51
|
+
const { getPXEInfo } = await import('./get_pxe_info.js');
|
|
52
|
+
await getPXEInfo(options.rpcUrl, debugLogger, log);
|
|
53
|
+
});
|
|
54
|
+
return program;
|
|
55
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { EthAddress, PXE } from '@aztec/aztec.js';
|
|
2
|
+
import { type ContractArtifact, type FunctionArtifact } from '@aztec/aztec.js/abi';
|
|
3
|
+
import type { DeployL1ContractsReturnType, L1ContractsConfig, RollupContract } from '@aztec/ethereum';
|
|
4
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
5
|
+
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
6
|
+
import type { NoirPackageConfig } from '@aztec/foundation/noir';
|
|
7
|
+
/**
|
|
8
|
+
* Helper to get an ABI function or throw error if it doesn't exist.
|
|
9
|
+
* @param artifact - Contract's build artifact in JSON format.
|
|
10
|
+
* @param fnName - Function name to be found.
|
|
11
|
+
* @returns The function's ABI.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getFunctionArtifact(artifact: ContractArtifact, fnName: string): FunctionArtifact;
|
|
14
|
+
/**
|
|
15
|
+
* Function to execute the 'deployRollupContracts' command.
|
|
16
|
+
* @param rpcUrls - The RPC URL of the ethereum node.
|
|
17
|
+
* @param chainId - The chain ID of the L1 host.
|
|
18
|
+
* @param privateKey - The private key to be used in contract deployment.
|
|
19
|
+
* @param mnemonic - The mnemonic to be used in contract deployment.
|
|
20
|
+
*/
|
|
21
|
+
export declare function deployAztecContracts(rpcUrls: string[], chainId: number, privateKey: string | undefined, mnemonic: string, mnemonicIndex: number, salt: number | undefined, initialValidators: EthAddress[], genesisArchiveRoot: Fr, genesisBlockHash: Fr, acceleratedTestDeployments: boolean, config: L1ContractsConfig, debugLogger: Logger): Promise<DeployL1ContractsReturnType>;
|
|
22
|
+
export declare function deployNewRollupContracts(registryAddress: EthAddress, rpcUrls: string[], chainId: number, privateKey: string | undefined, mnemonic: string, mnemonicIndex: number, salt: number | undefined, initialValidators: EthAddress[], genesisArchiveRoot: Fr, genesisBlockHash: Fr, config: L1ContractsConfig, logger: Logger): Promise<{
|
|
23
|
+
payloadAddress: EthAddress;
|
|
24
|
+
rollup: RollupContract;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Gets all contracts available in \@aztec/noir-contracts.js.
|
|
28
|
+
* @returns The contract names.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getExampleContractNames(): Promise<string[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Reads a file and converts it to an Aztec Contract ABI.
|
|
33
|
+
* @param fileDir - The directory of the compiled contract ABI.
|
|
34
|
+
* @returns The parsed contract artifact.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getContractArtifact(fileDir: string, log: LogFn): Promise<ContractArtifact>;
|
|
37
|
+
/**
|
|
38
|
+
* Performs necessary checks, conversions & operations to call a contract fn from the CLI.
|
|
39
|
+
* @param contractFile - Directory of the compiled contract ABI.
|
|
40
|
+
* @param functionName - Name of the function to be called.
|
|
41
|
+
* @param _functionArgs - Arguments to call the function with.
|
|
42
|
+
* @param log - Logger instance that will output to the CLI
|
|
43
|
+
* @returns Formatted contract address, function arguments and caller's aztec address.
|
|
44
|
+
*/
|
|
45
|
+
export declare function prepTx(contractFile: string, functionName: string, _functionArgs: string[], log: LogFn): Promise<{
|
|
46
|
+
functionArgs: any[];
|
|
47
|
+
contractArtifact: ContractArtifact;
|
|
48
|
+
isPrivate: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Removes the leading 0x from a hex string. If no leading 0x is found the string is returned unchanged.
|
|
52
|
+
* @param hex - A hex string
|
|
53
|
+
* @returns A new string with leading 0x removed
|
|
54
|
+
*/
|
|
55
|
+
export declare const stripLeadingHex: (hex: string) => string;
|
|
56
|
+
/**
|
|
57
|
+
* Pretty prints Nargo.toml contents to a string
|
|
58
|
+
* @param config - Nargo.toml contents
|
|
59
|
+
* @returns The Nargo.toml contents as a string
|
|
60
|
+
*/
|
|
61
|
+
export declare function prettyPrintNargoToml(config: NoirPackageConfig): string;
|
|
62
|
+
/**
|
|
63
|
+
* Checks that Private eXecution Environment (PXE) version matches the expected one by this CLI. Throws if not.
|
|
64
|
+
* @param pxe - PXE client.
|
|
65
|
+
* @param expectedVersionRange - Expected version by CLI.
|
|
66
|
+
*/
|
|
67
|
+
export declare function checkServerVersion(pxe: PXE, expectedVersionRange: string): Promise<void>;
|
|
68
|
+
//# sourceMappingURL=aztec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aztec.d.ts","sourceRoot":"","sources":["../../src/utils/aztec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAwB,MAAM,qBAAqB,CAAC;AACzG,OAAO,KAAK,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtG,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAUhE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAMhG;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,iBAAiB,EAAE,UAAU,EAAE,EAC/B,kBAAkB,EAAE,EAAE,EACtB,gBAAgB,EAAE,EAAE,EACpB,0BAA0B,EAAE,OAAO,EACnC,MAAM,EAAE,iBAAiB,EACzB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,2BAA2B,CAAC,CA6BtC;AAED,wBAAsB,wBAAwB,CAC5C,eAAe,EAAE,UAAU,EAC3B,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,iBAAiB,EAAE,UAAU,EAAE,EAC/B,kBAAkB,EAAE,EAAE,EACtB,gBAAgB,EAAE,EAAE,EACpB,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,cAAc,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,CAAC,CA6BjE;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAKjE;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,6BA4BpE;AAED;;;;;;;GAOG;AACH,wBAAsB,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,KAAK;;;;GAO3G;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAS,MAAM,WAK1C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAUtE;AAKD;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,iBAyB9E"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { loadContractArtifact } from '@aztec/aztec.js/abi';
|
|
2
|
+
import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
3
|
+
import { FunctionType } from '@aztec/stdlib/abi';
|
|
4
|
+
import TOML from '@iarna/toml';
|
|
5
|
+
import { readFile } from 'fs/promises';
|
|
6
|
+
import { gtr, ltr, satisfies, valid } from 'semver';
|
|
7
|
+
import { encodeArgs } from './encoding.js';
|
|
8
|
+
/**
|
|
9
|
+
* Helper to get an ABI function or throw error if it doesn't exist.
|
|
10
|
+
* @param artifact - Contract's build artifact in JSON format.
|
|
11
|
+
* @param fnName - Function name to be found.
|
|
12
|
+
* @returns The function's ABI.
|
|
13
|
+
*/ export function getFunctionArtifact(artifact, fnName) {
|
|
14
|
+
const fn = artifact.functions.find(({ name })=>name === fnName);
|
|
15
|
+
if (!fn) {
|
|
16
|
+
throw Error(`Function ${fnName} not found in contract ABI.`);
|
|
17
|
+
}
|
|
18
|
+
return fn;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Function to execute the 'deployRollupContracts' command.
|
|
22
|
+
* @param rpcUrls - The RPC URL of the ethereum node.
|
|
23
|
+
* @param chainId - The chain ID of the L1 host.
|
|
24
|
+
* @param privateKey - The private key to be used in contract deployment.
|
|
25
|
+
* @param mnemonic - The mnemonic to be used in contract deployment.
|
|
26
|
+
*/ export async function deployAztecContracts(rpcUrls, chainId, privateKey, mnemonic, mnemonicIndex, salt, initialValidators, genesisArchiveRoot, genesisBlockHash, acceleratedTestDeployments, config, debugLogger) {
|
|
27
|
+
const { createEthereumChain, deployL1Contracts } = await import('@aztec/ethereum');
|
|
28
|
+
const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts');
|
|
29
|
+
const account = !privateKey ? mnemonicToAccount(mnemonic, {
|
|
30
|
+
addressIndex: mnemonicIndex
|
|
31
|
+
}) : privateKeyToAccount(`${privateKey.startsWith('0x') ? '' : '0x'}${privateKey}`);
|
|
32
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
33
|
+
const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types/vk-tree');
|
|
34
|
+
return await deployL1Contracts(chain.rpcUrls, account, chain.chainInfo, debugLogger, {
|
|
35
|
+
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
|
|
36
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
37
|
+
protocolContractTreeRoot,
|
|
38
|
+
genesisArchiveRoot,
|
|
39
|
+
genesisBlockHash,
|
|
40
|
+
salt,
|
|
41
|
+
initialValidators,
|
|
42
|
+
acceleratedTestDeployments,
|
|
43
|
+
...config
|
|
44
|
+
}, config);
|
|
45
|
+
}
|
|
46
|
+
export async function deployNewRollupContracts(registryAddress, rpcUrls, chainId, privateKey, mnemonic, mnemonicIndex, salt, initialValidators, genesisArchiveRoot, genesisBlockHash, config, logger) {
|
|
47
|
+
const { createEthereumChain, deployRollupAndPeriphery, createL1Clients } = await import('@aztec/ethereum');
|
|
48
|
+
const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts');
|
|
49
|
+
const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types/vk-tree');
|
|
50
|
+
const account = !privateKey ? mnemonicToAccount(mnemonic, {
|
|
51
|
+
addressIndex: mnemonicIndex
|
|
52
|
+
}) : privateKeyToAccount(`${privateKey.startsWith('0x') ? '' : '0x'}${privateKey}`);
|
|
53
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
54
|
+
const clients = createL1Clients(rpcUrls, account, chain.chainInfo, mnemonicIndex);
|
|
55
|
+
const { payloadAddress, rollup } = await deployRollupAndPeriphery(clients, {
|
|
56
|
+
salt,
|
|
57
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
58
|
+
protocolContractTreeRoot,
|
|
59
|
+
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
|
|
60
|
+
genesisArchiveRoot,
|
|
61
|
+
genesisBlockHash,
|
|
62
|
+
initialValidators,
|
|
63
|
+
...config
|
|
64
|
+
}, registryAddress, logger, config);
|
|
65
|
+
return {
|
|
66
|
+
payloadAddress,
|
|
67
|
+
rollup
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets all contracts available in \@aztec/noir-contracts.js.
|
|
72
|
+
* @returns The contract names.
|
|
73
|
+
*/ export async function getExampleContractNames() {
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
75
|
+
// @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
|
|
76
|
+
const { ContractNames } = await import('@aztec/noir-contracts.js');
|
|
77
|
+
return ContractNames;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Reads a file and converts it to an Aztec Contract ABI.
|
|
81
|
+
* @param fileDir - The directory of the compiled contract ABI.
|
|
82
|
+
* @returns The parsed contract artifact.
|
|
83
|
+
*/ export async function getContractArtifact(fileDir, log) {
|
|
84
|
+
// first check if it's a noir-contracts example
|
|
85
|
+
const allNames = await getExampleContractNames();
|
|
86
|
+
const contractName = fileDir.replace(/Contract(Artifact)?$/, '');
|
|
87
|
+
if (allNames.includes(contractName)) {
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
89
|
+
// @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
|
|
90
|
+
const imported = await import(`@aztec/noir-contracts.js/${contractName}`);
|
|
91
|
+
const artifact = imported[`${contractName}ContractArtifact`];
|
|
92
|
+
if (!artifact) {
|
|
93
|
+
throw Error(`Could not import ${contractName}ContractArtifact from @aztec/noir-contracts.js/${contractName}`);
|
|
94
|
+
}
|
|
95
|
+
return artifact;
|
|
96
|
+
}
|
|
97
|
+
let contents;
|
|
98
|
+
try {
|
|
99
|
+
contents = await readFile(fileDir, 'utf8');
|
|
100
|
+
} catch {
|
|
101
|
+
throw Error(`Contract ${fileDir} not found`);
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
return loadContractArtifact(JSON.parse(contents));
|
|
105
|
+
} catch (err) {
|
|
106
|
+
log('Invalid file used. Please try again.');
|
|
107
|
+
throw err;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Performs necessary checks, conversions & operations to call a contract fn from the CLI.
|
|
112
|
+
* @param contractFile - Directory of the compiled contract ABI.
|
|
113
|
+
* @param functionName - Name of the function to be called.
|
|
114
|
+
* @param _functionArgs - Arguments to call the function with.
|
|
115
|
+
* @param log - Logger instance that will output to the CLI
|
|
116
|
+
* @returns Formatted contract address, function arguments and caller's aztec address.
|
|
117
|
+
*/ export async function prepTx(contractFile, functionName, _functionArgs, log) {
|
|
118
|
+
const contractArtifact = await getContractArtifact(contractFile, log);
|
|
119
|
+
const functionArtifact = getFunctionArtifact(contractArtifact, functionName);
|
|
120
|
+
const functionArgs = encodeArgs(_functionArgs, functionArtifact.parameters);
|
|
121
|
+
const isPrivate = functionArtifact.functionType === FunctionType.PRIVATE;
|
|
122
|
+
return {
|
|
123
|
+
functionArgs,
|
|
124
|
+
contractArtifact,
|
|
125
|
+
isPrivate
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Removes the leading 0x from a hex string. If no leading 0x is found the string is returned unchanged.
|
|
130
|
+
* @param hex - A hex string
|
|
131
|
+
* @returns A new string with leading 0x removed
|
|
132
|
+
*/ export const stripLeadingHex = (hex)=>{
|
|
133
|
+
if (hex.length > 2 && hex.startsWith('0x')) {
|
|
134
|
+
return hex.substring(2);
|
|
135
|
+
}
|
|
136
|
+
return hex;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Pretty prints Nargo.toml contents to a string
|
|
140
|
+
* @param config - Nargo.toml contents
|
|
141
|
+
* @returns The Nargo.toml contents as a string
|
|
142
|
+
*/ export function prettyPrintNargoToml(config) {
|
|
143
|
+
const withoutDependencies = Object.fromEntries(Object.entries(config).filter(([key])=>key !== 'dependencies'));
|
|
144
|
+
const partialToml = TOML.stringify(withoutDependencies);
|
|
145
|
+
const dependenciesToml = Object.entries(config.dependencies).map(([name, dep])=>{
|
|
146
|
+
const depToml = TOML.stringify.value(dep);
|
|
147
|
+
return `${name} = ${depToml}`;
|
|
148
|
+
});
|
|
149
|
+
return partialToml + '\n[dependencies]\n' + dependenciesToml.join('\n') + '\n';
|
|
150
|
+
}
|
|
151
|
+
/** Mismatch between server and client versions. */ class VersionMismatchError extends Error {
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Checks that Private eXecution Environment (PXE) version matches the expected one by this CLI. Throws if not.
|
|
155
|
+
* @param pxe - PXE client.
|
|
156
|
+
* @param expectedVersionRange - Expected version by CLI.
|
|
157
|
+
*/ export async function checkServerVersion(pxe, expectedVersionRange) {
|
|
158
|
+
const serverName = 'Aztec Node';
|
|
159
|
+
const { nodeVersion } = await pxe.getNodeInfo();
|
|
160
|
+
if (!nodeVersion) {
|
|
161
|
+
throw new VersionMismatchError(`Couldn't determine ${serverName} version. You may run into issues.`);
|
|
162
|
+
}
|
|
163
|
+
if (!nodeVersion || !valid(nodeVersion)) {
|
|
164
|
+
throw new VersionMismatchError(`Missing or invalid version identifier for ${serverName} (${nodeVersion ?? 'empty'}).`);
|
|
165
|
+
} else if (!satisfies(nodeVersion, expectedVersionRange)) {
|
|
166
|
+
if (gtr(nodeVersion, expectedVersionRange)) {
|
|
167
|
+
throw new VersionMismatchError(`${serverName} is running version ${nodeVersion} which is newer than the expected by this CLI (${expectedVersionRange}). Consider upgrading your CLI to a newer version.`);
|
|
168
|
+
} else if (ltr(nodeVersion, expectedVersionRange)) {
|
|
169
|
+
throw new VersionMismatchError(`${serverName} is running version ${nodeVersion} which is older than the expected by this CLI (${expectedVersionRange}). Consider upgrading your ${serverName} to a newer version.`);
|
|
170
|
+
} else {
|
|
171
|
+
throw new VersionMismatchError(`${serverName} is running version ${nodeVersion} which does not match the expected by this CLI (${expectedVersionRange}).`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { FunctionSelector } from '@aztec/aztec.js/abi';
|
|
2
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { EthAddress } from '@aztec/aztec.js/eth_address';
|
|
4
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
+
import { LogId } from '@aztec/aztec.js/log_id';
|
|
6
|
+
import { TxHash } from '@aztec/aztec.js/tx_hash';
|
|
7
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
8
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
9
|
+
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
10
|
+
import { type Command, Option } from 'commander';
|
|
11
|
+
/**
|
|
12
|
+
* If we can successfully resolve 'host.docker.internal', then we are running in a container, and we should treat
|
|
13
|
+
* localhost as being host.docker.internal.
|
|
14
|
+
*/
|
|
15
|
+
export declare const getLocalhost: () => Promise<string>;
|
|
16
|
+
export declare const LOCALHOST: string;
|
|
17
|
+
export declare const ETHEREUM_HOSTS: string, PRIVATE_KEY: string | undefined, API_KEY: string | undefined, CLI_VERSION: string | undefined;
|
|
18
|
+
export declare function addOptions(program: Command, options: Option[]): Command;
|
|
19
|
+
export declare const makePxeOption: (mandatory: boolean) => Option;
|
|
20
|
+
export declare const pxeOption: Option;
|
|
21
|
+
export declare const l1ChainIdOption: Option;
|
|
22
|
+
export declare const createSecretKeyOption: (description: string, mandatory: boolean, argsParser?: (value: string, previous: Fr) => Fr) => Option;
|
|
23
|
+
export declare const logJson: (log: LogFn) => (obj: object) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Updates a file in place atomically.
|
|
26
|
+
* @param filePath - Path to file
|
|
27
|
+
* @param contents - New contents to write
|
|
28
|
+
*/
|
|
29
|
+
export declare function atomicUpdateFile(filePath: string, contents: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Utility to select a TX sender either from user input
|
|
32
|
+
* or from the first account that is found in a PXE instance.
|
|
33
|
+
* @param pxe - The PXE instance that will be checked for an account.
|
|
34
|
+
* @param _from - The user input.
|
|
35
|
+
* @returns An Aztec address. Will throw if one can't be found in either options.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getTxSender(pxe: PXE, _from?: string): Promise<AztecAddress>;
|
|
38
|
+
export declare function parseBigint(bigint: string): bigint | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Parses a hex encoded string to an Fr integer
|
|
41
|
+
* @param str - Hex encoded string
|
|
42
|
+
* @returns A integer
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseFieldFromHexString(str: string): Fr;
|
|
45
|
+
/**
|
|
46
|
+
* Parses an AztecAddress from a string.
|
|
47
|
+
* @param address - A serialized Aztec address
|
|
48
|
+
* @returns An Aztec address
|
|
49
|
+
* @throws InvalidArgumentError if the input string is not valid.
|
|
50
|
+
*/
|
|
51
|
+
export declare function parseAztecAddress(address: string): AztecAddress;
|
|
52
|
+
/**
|
|
53
|
+
* Parses an Ethereum address from a string.
|
|
54
|
+
* @param address - A serialized Ethereum address
|
|
55
|
+
* @returns An Ethereum address
|
|
56
|
+
* @throws InvalidArgumentError if the input string is not valid.
|
|
57
|
+
*/
|
|
58
|
+
export declare function parseEthereumAddress(address: string): EthAddress;
|
|
59
|
+
/**
|
|
60
|
+
* Parses an AztecAddress from a string.
|
|
61
|
+
* @param address - A serialized Aztec address
|
|
62
|
+
* @returns An Aztec address
|
|
63
|
+
* @throws InvalidArgumentError if the input string is not valid.
|
|
64
|
+
*/
|
|
65
|
+
export declare function parseOptionalAztecAddress(address: string): AztecAddress | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Parses an optional log ID string into a LogId object.
|
|
68
|
+
*
|
|
69
|
+
* @param logId - The log ID string to parse.
|
|
70
|
+
* @returns The parsed LogId object, or undefined if the log ID is missing or empty.
|
|
71
|
+
*/
|
|
72
|
+
export declare function parseOptionalLogId(logId: string): LogId | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Parses a selector from a string.
|
|
75
|
+
* @param selector - A serialized selector.
|
|
76
|
+
* @returns A selector.
|
|
77
|
+
* @throws InvalidArgumentError if the input string is not valid.
|
|
78
|
+
*/
|
|
79
|
+
export declare function parseOptionalSelector(selector: string): FunctionSelector | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Parses a string into an integer or returns undefined if the input is falsy.
|
|
82
|
+
*
|
|
83
|
+
* @param value - The string to parse into an integer.
|
|
84
|
+
* @returns The parsed integer, or undefined if the input string is falsy.
|
|
85
|
+
* @throws If the input is not a valid integer.
|
|
86
|
+
*/
|
|
87
|
+
export declare function parseOptionalInteger(value: string): number | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Parses a TxHash from a string.
|
|
90
|
+
* @param txHash - A transaction hash
|
|
91
|
+
* @returns A TxHash instance
|
|
92
|
+
* @throws InvalidArgumentError if the input string is not valid.
|
|
93
|
+
*/
|
|
94
|
+
export declare function parseTxHash(txHash: string): TxHash;
|
|
95
|
+
/**
|
|
96
|
+
* Parses an optional TxHash from a string.
|
|
97
|
+
* Calls parseTxHash internally.
|
|
98
|
+
* @param txHash - A transaction hash
|
|
99
|
+
* @returns A TxHash instance, or undefined if the input string is falsy.
|
|
100
|
+
* @throws InvalidArgumentError if the input string is not valid.
|
|
101
|
+
*/
|
|
102
|
+
export declare function parseOptionalTxHash(txHash: string): TxHash | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Parses a public key from a string.
|
|
105
|
+
* @param publicKey - A public keys object serialised as a string
|
|
106
|
+
* @returns A PublicKeys instance
|
|
107
|
+
* @throws InvalidArgumentError if the input string is not valid.
|
|
108
|
+
*/
|
|
109
|
+
export declare function parsePublicKey(publicKey: string): PublicKeys | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Parses a partial address from a string.
|
|
112
|
+
* @param address - A partial address
|
|
113
|
+
* @returns A Fr instance
|
|
114
|
+
* @throws InvalidArgumentError if the input string is not valid.
|
|
115
|
+
*/
|
|
116
|
+
export declare function parsePartialAddress(address: string): Fr;
|
|
117
|
+
/**
|
|
118
|
+
* Parses a secret key from a string.
|
|
119
|
+
* @param privateKey - A string
|
|
120
|
+
* @returns A secret key
|
|
121
|
+
* @throws InvalidArgumentError if the input string is not valid.
|
|
122
|
+
*/
|
|
123
|
+
export declare function parseSecretKey(secretKey: string): Fr;
|
|
124
|
+
/**
|
|
125
|
+
* Parses a field from a string.
|
|
126
|
+
* @param field - A string representing the field.
|
|
127
|
+
* @returns A field.
|
|
128
|
+
* @throws InvalidArgumentError if the input string is not valid.
|
|
129
|
+
*/
|
|
130
|
+
export declare function parseField(field: string): Fr;
|
|
131
|
+
/**
|
|
132
|
+
* Parses an array of strings to Frs.
|
|
133
|
+
* @param fields - An array of strings representing the fields.
|
|
134
|
+
* @returns An array of Frs.
|
|
135
|
+
*/
|
|
136
|
+
export declare function parseFields(fields: string[]): Fr[];
|
|
137
|
+
/**
|
|
138
|
+
* Pretty prints an object as JSON
|
|
139
|
+
* @param data - The object to stringify
|
|
140
|
+
* @returns A JSON string
|
|
141
|
+
*/
|
|
142
|
+
export declare function prettyPrintJSON(data: Record<string, any>): string;
|
|
143
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/utils/commands.ts"],"names":[],"mappings":"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"}
|