@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
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DefaultWaitOpts, NoFeePaymentMethod } from '@aztec/aztec.js';
|
|
2
|
+
import { FEE_JUICE_INITIAL_MINT, Gas } from '@aztec/circuits.js';
|
|
3
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
4
|
+
/**
|
|
5
|
+
* Deploys the contract to pay for gas on L2.
|
|
6
|
+
*/ export async function setupCanonicalL2FeeJuice(deployer, feeJuicePortalAddress, waitOpts = DefaultWaitOpts, log) {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
|
+
// @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
|
|
9
|
+
const { FeeJuiceContract } = await import('@aztec/noir-contracts.js/FeeJuice');
|
|
10
|
+
const feeJuiceContract = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, deployer);
|
|
11
|
+
const portalAddress = await deployer.getPublicStorageAt(feeJuiceContract.address, feeJuiceContract.artifact.storageLayout.portal_address.slot);
|
|
12
|
+
if (portalAddress.isZero()) {
|
|
13
|
+
log('setupCanonicalL2FeeJuice: Calling initialize on fee juice contract...');
|
|
14
|
+
await feeJuiceContract.methods.initialize(feeJuicePortalAddress, FEE_JUICE_INITIAL_MINT).send({
|
|
15
|
+
fee: {
|
|
16
|
+
paymentMethod: new NoFeePaymentMethod(),
|
|
17
|
+
gasSettings: {
|
|
18
|
+
teardownGasLimits: Gas.empty()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}).wait(waitOpts);
|
|
22
|
+
} else {
|
|
23
|
+
log('setupCanonicalL2FeeJuice: Fee juice contract already initialized. Fee Juice Portal address: ' + portalAddress.toString());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { parseNoirPackageConfig } from '@aztec/foundation/noir';
|
|
2
|
+
import TOML from '@iarna/toml';
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import { join, relative, resolve } from 'path';
|
|
5
|
+
import { atomicUpdateFile, prettyPrintNargoToml } from './utils.js';
|
|
6
|
+
/**
|
|
7
|
+
* Updates Aztec.nr dependencies
|
|
8
|
+
* @param contractPath - Path to the contract to be updated
|
|
9
|
+
* @param tag - The tag to update to
|
|
10
|
+
* @param log - Logging function
|
|
11
|
+
*/ export async function updateAztecNr(contractPath, tag, log) {
|
|
12
|
+
const configFilepath = resolve(join(contractPath, 'Nargo.toml'));
|
|
13
|
+
const packageConfig = parseNoirPackageConfig(TOML.parse(await readFile(configFilepath, 'utf-8')));
|
|
14
|
+
const changes = {
|
|
15
|
+
dependencies: [],
|
|
16
|
+
file: configFilepath
|
|
17
|
+
};
|
|
18
|
+
log(`Updating Aztec.nr libraries to ${tag} in ${relative(process.cwd(), changes.file)}`);
|
|
19
|
+
for (const dep of Object.values(packageConfig.dependencies)){
|
|
20
|
+
if (!('git' in dep)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
// remove trailing slash
|
|
24
|
+
const gitUrl = dep.git.toLowerCase().replace(/\/$/, '');
|
|
25
|
+
if (gitUrl !== 'https://github.com/aztecprotocol/aztec-packages') {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (dep.tag !== tag) {
|
|
29
|
+
// show the Aztec.nr package name rather than the lib name
|
|
30
|
+
const dirParts = dep.directory?.split('/') ?? [];
|
|
31
|
+
changes.dependencies.push({
|
|
32
|
+
name: dirParts.slice(-2).join('/'),
|
|
33
|
+
from: dep.tag,
|
|
34
|
+
to: tag
|
|
35
|
+
});
|
|
36
|
+
dep.tag = tag;
|
|
37
|
+
dep.directory = dep.directory?.replace('yarn-project/', 'noir-projects/');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (changes.dependencies.length > 0) {
|
|
41
|
+
const contents = prettyPrintNargoToml(packageConfig);
|
|
42
|
+
await atomicUpdateFile(configFilepath, contents);
|
|
43
|
+
}
|
|
44
|
+
return changes;
|
|
45
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import { join, relative, resolve } from 'path';
|
|
5
|
+
import { parse } from 'semver';
|
|
6
|
+
import { atomicUpdateFile } from './utils.js';
|
|
7
|
+
const deprecatedNpmPackages = new Set([
|
|
8
|
+
'@aztec/cli',
|
|
9
|
+
'@aztec/aztec-sandbox'
|
|
10
|
+
]);
|
|
11
|
+
const npmDeprecationMessage = `
|
|
12
|
+
The following packages have been deprecated and will no longer be updated on the npm registry:
|
|
13
|
+
${Array.from(deprecatedNpmPackages).map((pkg)=>` - ${pkg}`).join('\n')}
|
|
14
|
+
Remove them from package.json
|
|
15
|
+
`;
|
|
16
|
+
/**
|
|
17
|
+
* Looks up a package.json file and returns its contents
|
|
18
|
+
* @param projectPath - Path to Nodejs project
|
|
19
|
+
* @returns The parsed package.json
|
|
20
|
+
*/ export async function readPackageJson(projectPath) {
|
|
21
|
+
const configFilepath = resolve(join(projectPath, 'package.json'));
|
|
22
|
+
const pkg = JSON.parse(await readFile(configFilepath, 'utf-8'));
|
|
23
|
+
return pkg;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Queries the npm registry for the latest version of a package
|
|
27
|
+
* @param packageName - The package to query
|
|
28
|
+
* @param distTag - The distribution tag
|
|
29
|
+
* @returns The latest version of the package on that distribution tag
|
|
30
|
+
*/ export async function getNewestVersion(packageName, distTag = 'latest') {
|
|
31
|
+
const url = new URL(packageName, 'https://registry.npmjs.org/');
|
|
32
|
+
const response = await fetch(url);
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
throw new Error(`Failed to fetch ${url}`);
|
|
35
|
+
}
|
|
36
|
+
const body = await response.json();
|
|
37
|
+
const latestVersion = parse(body['dist-tags'][distTag]);
|
|
38
|
+
if (!latestVersion) {
|
|
39
|
+
throw new Error(`Failed to get latest version from registry`);
|
|
40
|
+
}
|
|
41
|
+
return latestVersion;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Updates a project's \@aztec/* dependencies to the specific version
|
|
45
|
+
* @param projectPath - Path to Nodejs project
|
|
46
|
+
* @param aztecVersion - The version to update to
|
|
47
|
+
* @returns True if the project was updated
|
|
48
|
+
*/ export async function updateAztecDeps(projectPath, aztecVersion, log) {
|
|
49
|
+
const pkg = await readPackageJson(projectPath);
|
|
50
|
+
const changes = {
|
|
51
|
+
file: resolve(join(projectPath, 'package.json')),
|
|
52
|
+
dependencies: []
|
|
53
|
+
};
|
|
54
|
+
log(`Updating @aztec packages to ${aztecVersion} in ${relative(process.cwd(), changes.file)}`);
|
|
55
|
+
const version = aztecVersion.version;
|
|
56
|
+
let detectedDeprecatedPackages = false;
|
|
57
|
+
for (const depType of [
|
|
58
|
+
'dependencies',
|
|
59
|
+
'devDependencies'
|
|
60
|
+
]){
|
|
61
|
+
const dependencies = pkg[depType];
|
|
62
|
+
if (!dependencies) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
for (const name of Object.keys(dependencies)){
|
|
66
|
+
if (!name.startsWith('@aztec/')) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
// different release schedule
|
|
70
|
+
if (name === '@aztec/aztec-ui') {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (deprecatedNpmPackages.has(name)) {
|
|
74
|
+
detectedDeprecatedPackages = true;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (dependencies[name] !== version) {
|
|
78
|
+
changes.dependencies.push({
|
|
79
|
+
name,
|
|
80
|
+
from: dependencies[name],
|
|
81
|
+
to: version
|
|
82
|
+
});
|
|
83
|
+
dependencies[name] = version;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (detectedDeprecatedPackages) {
|
|
88
|
+
log(npmDeprecationMessage);
|
|
89
|
+
}
|
|
90
|
+
if (changes.dependencies.length > 0) {
|
|
91
|
+
const contents = JSON.stringify(pkg, null, 2) + '\n';
|
|
92
|
+
await atomicUpdateFile(resolve(join(projectPath, 'package.json')), contents);
|
|
93
|
+
}
|
|
94
|
+
return changes;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Updates a project's yarn.lock or package-lock.json
|
|
98
|
+
* @param projectPath - Path to Nodejs project
|
|
99
|
+
*/ export function updateLockfile(projectPath, log) {
|
|
100
|
+
const isNpm = existsSync(resolve(join(projectPath, 'package-lock.json')));
|
|
101
|
+
const isYarn = existsSync(resolve(join(projectPath, 'yarn.lock')));
|
|
102
|
+
const isPnpm = existsSync(resolve(join(projectPath, 'pnpm-lock.yaml')));
|
|
103
|
+
if (isPnpm) {
|
|
104
|
+
spawnSync('pnpm', [
|
|
105
|
+
'install'
|
|
106
|
+
], {
|
|
107
|
+
cwd: projectPath,
|
|
108
|
+
stdio: 'inherit'
|
|
109
|
+
});
|
|
110
|
+
} else if (isYarn) {
|
|
111
|
+
spawnSync('yarn', [
|
|
112
|
+
'install'
|
|
113
|
+
], {
|
|
114
|
+
cwd: projectPath,
|
|
115
|
+
stdio: 'inherit'
|
|
116
|
+
});
|
|
117
|
+
} else if (isNpm) {
|
|
118
|
+
spawnSync('npm', [
|
|
119
|
+
'install'
|
|
120
|
+
], {
|
|
121
|
+
cwd: projectPath,
|
|
122
|
+
stdio: 'inherit'
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
log(`No lockfile found in ${projectPath}. Skipping lockfile update...`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import TOML from '@iarna/toml';
|
|
2
|
+
import { CommanderError } from 'commander';
|
|
3
|
+
import { rename, writeFile } from 'fs/promises';
|
|
4
|
+
/**
|
|
5
|
+
* Updates a file in place atomically.
|
|
6
|
+
* @param filePath - Path to file
|
|
7
|
+
* @param contents - New contents to write
|
|
8
|
+
*/ export async function atomicUpdateFile(filePath, contents) {
|
|
9
|
+
const tmpFilepath = filePath + '.tmp';
|
|
10
|
+
try {
|
|
11
|
+
await writeFile(tmpFilepath, contents, {
|
|
12
|
+
// let's crash if the tmp file already exists
|
|
13
|
+
flag: 'wx'
|
|
14
|
+
});
|
|
15
|
+
await rename(tmpFilepath, filePath);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
if (e instanceof Error && 'code' in e && e.code === 'EEXIST') {
|
|
18
|
+
const commanderError = new CommanderError(1, e.code, `Temporary file already exists: ${tmpFilepath}. Delete this file and try again.`);
|
|
19
|
+
commanderError.nestedError = e.message;
|
|
20
|
+
throw commanderError;
|
|
21
|
+
} else {
|
|
22
|
+
throw e;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Pretty prints Nargo.toml contents to a string
|
|
28
|
+
* @param config - Nargo.toml contents
|
|
29
|
+
* @returns The Nargo.toml contents as a string
|
|
30
|
+
*/ export function prettyPrintNargoToml(config) {
|
|
31
|
+
const withoutDependencies = Object.fromEntries(Object.entries(config).filter(([key])=>key !== 'dependencies'));
|
|
32
|
+
const partialToml = TOML.stringify(withoutDependencies);
|
|
33
|
+
const dependenciesToml = Object.entries(config.dependencies).map(([name, dep])=>{
|
|
34
|
+
const depToml = TOML.stringify.value(dep);
|
|
35
|
+
return `${name} = ${depToml}`;
|
|
36
|
+
});
|
|
37
|
+
return partialToml + '\n[dependencies]\n' + dependenciesToml.join('\n') + '\n';
|
|
38
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* eslint-disable jsdoc/require-jsdoc */ import { relative, resolve } from 'path';
|
|
2
|
+
import { parse } from 'semver';
|
|
3
|
+
import { GITHUB_TAG_PREFIX } from './update/github.js';
|
|
4
|
+
import { updateAztecNr } from './update/noir.js';
|
|
5
|
+
import { getNewestVersion, updateAztecDeps, updateLockfile } from './update/npm.js';
|
|
6
|
+
const AZTECJS_PACKAGE = '@aztec/aztec.js';
|
|
7
|
+
const UPDATE_DOCS_URL = 'https://docs.aztec.network/developers/guides/local_env/versions-updating';
|
|
8
|
+
export async function updateProject(projectPath, contracts, aztecVersion, log) {
|
|
9
|
+
const targetAztecVersion = aztecVersion === 'latest' ? await getNewestVersion(AZTECJS_PACKAGE, 'latest') : parse(aztecVersion);
|
|
10
|
+
if (!targetAztecVersion) {
|
|
11
|
+
throw new Error(`Invalid aztec version ${aztecVersion}`);
|
|
12
|
+
}
|
|
13
|
+
const projectDependencyChanges = [];
|
|
14
|
+
try {
|
|
15
|
+
const npmChanges = await updateAztecDeps(resolve(process.cwd(), projectPath), targetAztecVersion, log);
|
|
16
|
+
if (npmChanges.dependencies.length > 0) {
|
|
17
|
+
updateLockfile(projectPath, log);
|
|
18
|
+
}
|
|
19
|
+
projectDependencyChanges.push(npmChanges);
|
|
20
|
+
} catch (err) {
|
|
21
|
+
if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
|
|
22
|
+
log(`No package.json found in ${projectPath}. Skipping npm update...`);
|
|
23
|
+
} else {
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
for (const contract of contracts){
|
|
28
|
+
try {
|
|
29
|
+
projectDependencyChanges.push(await updateAztecNr(resolve(process.cwd(), projectPath, contract), `${GITHUB_TAG_PREFIX}-v${targetAztecVersion.version}`, log));
|
|
30
|
+
} catch (err) {
|
|
31
|
+
if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
|
|
32
|
+
log(`No Nargo.toml found in ${relative(process.cwd(), contract)}. Skipping...`);
|
|
33
|
+
} else {
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
log(`To update Docker containers follow instructions at ${UPDATE_DOCS_URL}`);
|
|
39
|
+
projectDependencyChanges.forEach((changes)=>{
|
|
40
|
+
printChanges(changes, log);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function printChanges(changes, log) {
|
|
44
|
+
log(`\nIn ${relative(process.cwd(), changes.file)}:`);
|
|
45
|
+
if (changes.dependencies.length === 0) {
|
|
46
|
+
log(' No changes');
|
|
47
|
+
} else {
|
|
48
|
+
changes.dependencies.forEach(({ name, from, to })=>{
|
|
49
|
+
log(` Updated ${name} from ${from} to ${to}`);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AztecAddress, getContractClassFromArtifact } from '@aztec/aztec.js';
|
|
2
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
3
|
+
import { PublicKeys } from '@aztec/circuits.js';
|
|
4
|
+
import { computeContractAddressFromInstance } from '@aztec/circuits.js/contract';
|
|
5
|
+
import { getContractArtifact } from '../../utils/aztec.js';
|
|
6
|
+
export async function addContract(rpcUrl, contractArtifactPath, address, initializationHash, salt, publicKeys, deployer, debugLogger, log) {
|
|
7
|
+
const artifact = await getContractArtifact(contractArtifactPath, log);
|
|
8
|
+
const instance = {
|
|
9
|
+
version: 1,
|
|
10
|
+
salt,
|
|
11
|
+
initializationHash,
|
|
12
|
+
contractClassId: (await getContractClassFromArtifact(artifact)).id,
|
|
13
|
+
publicKeys: publicKeys ?? PublicKeys.default(),
|
|
14
|
+
address,
|
|
15
|
+
deployer: deployer ?? AztecAddress.ZERO
|
|
16
|
+
};
|
|
17
|
+
const computed = await computeContractAddressFromInstance(instance);
|
|
18
|
+
if (!computed.equals(address)) {
|
|
19
|
+
throw new Error(`Contract address ${address.toString()} does not match computed address ${computed.toString()}`);
|
|
20
|
+
}
|
|
21
|
+
const client = await createCompatibleClient(rpcUrl, debugLogger);
|
|
22
|
+
await client.registerContract({
|
|
23
|
+
artifact,
|
|
24
|
+
instance
|
|
25
|
+
});
|
|
26
|
+
log(`\nContract added to PXE at ${address.toString()} with class ${instance.contractClassId.toString()}\n`);
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
export async function blockNumber(rpcUrl, debugLogger, log) {
|
|
3
|
+
const client = await createCompatibleClient(rpcUrl, debugLogger);
|
|
4
|
+
const [latestNum, provenNum] = await Promise.all([
|
|
5
|
+
client.getBlockNumber(),
|
|
6
|
+
client.getProvenBlockNumber()
|
|
7
|
+
]);
|
|
8
|
+
log(`Latest block: ${latestNum}`);
|
|
9
|
+
log(`Proven block: ${provenNum}`);
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
export async function getAccount(aztecAddress, rpcUrl, debugLogger, log) {
|
|
3
|
+
const client = await createCompatibleClient(rpcUrl, debugLogger);
|
|
4
|
+
const account = (await client.getRegisteredAccounts()).find((completeAddress)=>completeAddress.address.equals(aztecAddress));
|
|
5
|
+
if (!account) {
|
|
6
|
+
log(`Unknown account ${aztecAddress.toString()}`);
|
|
7
|
+
} else {
|
|
8
|
+
log(account.toReadableString());
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
export async function getAccounts(rpcUrl, json, debugLogger, log, logJson) {
|
|
3
|
+
const client = await createCompatibleClient(rpcUrl, debugLogger);
|
|
4
|
+
const accounts = await client.getRegisteredAccounts();
|
|
5
|
+
if (!accounts.length) {
|
|
6
|
+
if (json) {
|
|
7
|
+
logJson([]);
|
|
8
|
+
} else {
|
|
9
|
+
log('No accounts found.');
|
|
10
|
+
}
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (json) {
|
|
14
|
+
logJson(accounts.map((a)=>({
|
|
15
|
+
address: a.address.toString(),
|
|
16
|
+
publicKeys: a.publicKeys.toString(),
|
|
17
|
+
partialAddress: a.partialAddress.toString()
|
|
18
|
+
})));
|
|
19
|
+
} else {
|
|
20
|
+
log(`Accounts found: \n`);
|
|
21
|
+
for (const account of accounts){
|
|
22
|
+
log(account.toReadableString());
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
import { inspectBlock } from '../../utils/inspect.js';
|
|
3
|
+
export async function getBlock(rpcUrl, maybeBlockNumber, debugLogger, log) {
|
|
4
|
+
const client = await createCompatibleClient(rpcUrl, debugLogger);
|
|
5
|
+
const blockNumber = maybeBlockNumber ?? await client.getBlockNumber();
|
|
6
|
+
await inspectBlock(client, blockNumber, log, {
|
|
7
|
+
showTxs: true
|
|
8
|
+
});
|
|
9
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
export async function getContractData(rpcUrl, contractAddress, includeBytecode, debugLogger, log) {
|
|
3
|
+
const client = await createCompatibleClient(rpcUrl, debugLogger);
|
|
4
|
+
const { contractInstance: instance, isContractInitialized: isInitialized, isContractPubliclyDeployed: isPubliclyDeployed } = await client.getContractMetadata(contractAddress);
|
|
5
|
+
const contractClass = includeBytecode && instance && (await client.getContractClassMetadata(instance?.contractClassId)).contractClass;
|
|
6
|
+
const isPrivatelyDeployed = !!instance;
|
|
7
|
+
const initStr = isInitialized ? 'initialized' : 'not initialized';
|
|
8
|
+
const addrStr = contractAddress.toString();
|
|
9
|
+
if (isPubliclyDeployed && isPrivatelyDeployed) {
|
|
10
|
+
log(`Contract is ${initStr} and publicly deployed at ${addrStr}`);
|
|
11
|
+
} else if (isPrivatelyDeployed) {
|
|
12
|
+
log(`Contract is ${initStr} and registered in the local pxe at ${addrStr} but not publicly deployed`);
|
|
13
|
+
} else if (isPubliclyDeployed) {
|
|
14
|
+
log(`Contract is ${initStr} and publicly deployed at ${addrStr} but not registered in the local pxe`);
|
|
15
|
+
} else if (isInitialized) {
|
|
16
|
+
log(`Contract is initialized but not publicly deployed nor registered in the local pxe at ${addrStr}`);
|
|
17
|
+
} else {
|
|
18
|
+
log(`No contract found at ${addrStr}`);
|
|
19
|
+
}
|
|
20
|
+
if (instance) {
|
|
21
|
+
log(``);
|
|
22
|
+
Object.entries(instance).forEach(([key, value])=>{
|
|
23
|
+
const capitalized = key.charAt(0).toUpperCase() + key.slice(1);
|
|
24
|
+
log(`${capitalized}: ${value.toString()}`);
|
|
25
|
+
});
|
|
26
|
+
if (contractClass) {
|
|
27
|
+
log(`\nBytecode: ${contractClass.packedBytecode.toString('base64')}`);
|
|
28
|
+
}
|
|
29
|
+
log('');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
|
+
export async function getCurrentBaseFee(rpcUrl, debugLogger, log) {
|
|
4
|
+
const client = await createCompatibleClient(rpcUrl, debugLogger);
|
|
5
|
+
const fees = await client.getCurrentBaseFees();
|
|
6
|
+
log(`Current fees: ${jsonStringify(fees)}`);
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
export async function getL1ToL2MessageWitness(rpcUrl, contractAddress, messageHash, secret, debugLogger, log) {
|
|
3
|
+
const client = await createCompatibleClient(rpcUrl, debugLogger);
|
|
4
|
+
const messageWitness = await client.getL1ToL2MembershipWitness(contractAddress, messageHash, secret);
|
|
5
|
+
log(messageWitness === undefined ? `
|
|
6
|
+
L1 to L2 Message not found.
|
|
7
|
+
` : `
|
|
8
|
+
L1 to L2 message index: ${messageWitness[0]}
|
|
9
|
+
L1 to L2 message sibling path: ${messageWitness[1]}
|
|
10
|
+
`);
|
|
11
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createCompatibleClient } from '@aztec/aztec.js';
|
|
2
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
3
|
+
export async function getLogs(txHash, fromBlock, toBlock, afterLog, contractAddress, rpcUrl, follow, debugLogger, log) {
|
|
4
|
+
const pxe = await createCompatibleClient(rpcUrl, debugLogger);
|
|
5
|
+
if (follow) {
|
|
6
|
+
if (txHash) {
|
|
7
|
+
throw Error('Cannot use --follow with --tx-hash');
|
|
8
|
+
}
|
|
9
|
+
if (toBlock) {
|
|
10
|
+
throw Error('Cannot use --follow with --to-block');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const filter = {
|
|
14
|
+
txHash,
|
|
15
|
+
fromBlock,
|
|
16
|
+
toBlock,
|
|
17
|
+
afterLog,
|
|
18
|
+
contractAddress
|
|
19
|
+
};
|
|
20
|
+
const fetchLogs = async ()=>{
|
|
21
|
+
const response = await pxe.getPublicLogs(filter);
|
|
22
|
+
const logs = response.logs;
|
|
23
|
+
if (!logs.length) {
|
|
24
|
+
const filterOptions = Object.entries(filter).filter(([, value])=>value !== undefined).map(([key, value])=>`${key}: ${value}`).join(', ');
|
|
25
|
+
if (!follow) {
|
|
26
|
+
log(`No logs found for filter: {${filterOptions}}`);
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
if (!follow && !filter.afterLog) {
|
|
30
|
+
log('Logs found: \n');
|
|
31
|
+
}
|
|
32
|
+
logs.forEach((publicLog)=>log(publicLog.toHumanReadable()));
|
|
33
|
+
// Set the continuation parameter for the following requests
|
|
34
|
+
filter.afterLog = logs[logs.length - 1].id;
|
|
35
|
+
}
|
|
36
|
+
return response.maxLogsHit;
|
|
37
|
+
};
|
|
38
|
+
if (follow) {
|
|
39
|
+
log('Fetching logs...');
|
|
40
|
+
while(true){
|
|
41
|
+
const maxLogsHit = await fetchLogs();
|
|
42
|
+
if (!maxLogsHit) {
|
|
43
|
+
await sleep(1000);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
while(await fetchLogs()){
|
|
48
|
+
// Keep fetching logs until we reach the end.
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -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,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,55 @@
|
|
|
1
|
+
import { Fr } from '@aztec/circuits.js';
|
|
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
|
+
}
|