@aztec/cli 0.0.0-test.1 → 0.0.1-fake-c83136db25
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 +1 -427
- package/dest/cmds/aztec_node/block_number.d.ts +3 -0
- package/dest/cmds/aztec_node/block_number.d.ts.map +1 -0
- package/dest/cmds/aztec_node/block_number.js +10 -0
- package/dest/cmds/aztec_node/get_block.d.ts +3 -0
- package/dest/cmds/aztec_node/get_block.d.ts.map +1 -0
- package/dest/cmds/aztec_node/get_block.js +9 -0
- package/dest/cmds/aztec_node/get_current_base_fee.d.ts +3 -0
- package/dest/cmds/aztec_node/get_current_base_fee.d.ts.map +1 -0
- package/dest/cmds/aztec_node/get_current_base_fee.js +7 -0
- package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts +5 -0
- package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts.map +1 -0
- package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.js +12 -0
- package/dest/cmds/aztec_node/get_logs.d.ts +6 -0
- package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -0
- package/dest/cmds/{pxe → aztec_node}/get_logs.js +4 -4
- package/dest/cmds/aztec_node/get_node_info.d.ts +3 -0
- package/dest/cmds/aztec_node/get_node_info.d.ts.map +1 -0
- package/dest/cmds/{pxe → aztec_node}/get_node_info.js +14 -15
- package/dest/cmds/aztec_node/index.d.ts.map +1 -0
- package/dest/cmds/aztec_node/index.js +28 -0
- package/dest/cmds/contracts/inspect_contract.d.ts.map +1 -1
- package/dest/cmds/contracts/inspect_contract.js +9 -5
- package/dest/cmds/infrastructure/index.d.ts +2 -2
- package/dest/cmds/infrastructure/index.d.ts.map +1 -1
- package/dest/cmds/infrastructure/index.js +8 -9
- package/dest/cmds/infrastructure/sequencers.d.ts +4 -4
- package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
- package/dest/cmds/infrastructure/sequencers.js +29 -16
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.js +11 -24
- package/dest/cmds/l1/advance_epoch.d.ts +1 -1
- package/dest/cmds/l1/advance_epoch.d.ts.map +1 -1
- package/dest/cmds/l1/advance_epoch.js +8 -6
- package/dest/cmds/l1/assume_proven_through.d.ts +1 -1
- package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
- package/dest/cmds/l1/assume_proven_through.js +9 -8
- package/dest/cmds/l1/bridge_erc20.d.ts +2 -2
- package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
- package/dest/cmds/l1/bridge_erc20.js +5 -5
- package/dest/cmds/l1/deploy_l1_contracts.d.ts +2 -2
- package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_l1_contracts.js +23 -6
- package/dest/cmds/l1/deploy_new_rollup.d.ts +2 -1
- package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_new_rollup.js +17 -8
- package/dest/cmds/l1/get_l1_addresses.d.ts +1 -1
- package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -1
- package/dest/cmds/l1/governance_utils.d.ts.map +1 -1
- package/dest/cmds/l1/governance_utils.js +17 -17
- package/dest/cmds/l1/index.d.ts +1 -0
- package/dest/cmds/l1/index.d.ts.map +1 -1
- package/dest/cmds/l1/index.js +33 -43
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts +6 -0
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -0
- package/dest/cmds/l1/trigger_seed_snapshot.js +19 -0
- package/dest/cmds/l1/update_l1_validators.d.ts +17 -2
- package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
- package/dest/cmds/l1/update_l1_validators.js +159 -103
- package/dest/cmds/misc/generate_bootnode_enr.d.ts +1 -1
- package/dest/cmds/misc/generate_bootnode_enr.d.ts.map +1 -1
- package/dest/cmds/misc/generate_bootnode_enr.js +2 -2
- package/dest/cmds/misc/generate_secret_and_hash.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.d.ts.map +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.js +3 -3
- package/dest/cmds/misc/generate_secret_key.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_key.d.ts.map +1 -1
- package/dest/cmds/misc/generate_secret_key.js +1 -1
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts +3 -0
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts.map +1 -0
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.js +4 -0
- package/dest/cmds/misc/index.d.ts.map +1 -1
- package/dest/cmds/misc/index.js +7 -3
- package/dest/cmds/misc/update/github.d.ts +0 -1
- package/dest/cmds/misc/update/github.d.ts.map +1 -1
- package/dest/cmds/misc/update/github.js +0 -1
- package/dest/cmds/misc/update.d.ts.map +1 -1
- package/dest/cmds/misc/update.js +2 -3
- package/dest/config/cached_fetch.d.ts +18 -0
- package/dest/config/cached_fetch.d.ts.map +1 -0
- package/dest/config/cached_fetch.js +54 -0
- package/dest/config/chain_l2_config.d.ts +39 -0
- package/dest/config/chain_l2_config.d.ts.map +1 -0
- package/dest/config/chain_l2_config.js +452 -0
- package/dest/config/enrich_env.d.ts +4 -0
- package/dest/config/enrich_env.d.ts.map +1 -0
- package/dest/config/enrich_env.js +12 -0
- package/dest/config/get_l1_config.d.ts +8 -0
- package/dest/config/get_l1_config.d.ts.map +1 -0
- package/dest/config/get_l1_config.js +22 -0
- package/dest/config/index.d.ts +5 -0
- package/dest/config/index.d.ts.map +1 -0
- package/dest/config/index.js +4 -0
- package/dest/config/network_config.d.ts +19 -0
- package/dest/config/network_config.d.ts.map +1 -0
- package/dest/config/network_config.js +79 -0
- package/dest/utils/aztec.d.ts +12 -17
- package/dest/utils/aztec.d.ts.map +1 -1
- package/dest/utils/aztec.js +54 -49
- package/dest/utils/commands.d.ts +7 -8
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +10 -11
- package/dest/utils/encoding.js +1 -1
- package/dest/utils/github.d.ts +0 -1
- package/dest/utils/github.d.ts.map +1 -1
- package/dest/utils/github.js +0 -1
- package/dest/utils/index.d.ts +1 -0
- package/dest/utils/index.d.ts.map +1 -1
- package/dest/utils/index.js +1 -0
- package/dest/utils/inspect.d.ts +3 -10
- package/dest/utils/inspect.d.ts.map +1 -1
- package/dest/utils/inspect.js +19 -109
- package/dest/utils/setup_contracts.d.ts +3 -0
- package/dest/utils/setup_contracts.d.ts.map +1 -0
- package/dest/utils/setup_contracts.js +16 -0
- package/package.json +40 -33
- package/src/cmds/aztec_node/block_number.ts +9 -0
- package/src/cmds/aztec_node/get_block.ts +10 -0
- package/src/cmds/aztec_node/get_current_base_fee.ts +9 -0
- package/src/cmds/aztec_node/get_l1_to_l2_message_witness.ts +27 -0
- package/src/cmds/{pxe → aztec_node}/get_logs.ts +8 -7
- package/src/cmds/{pxe → aztec_node}/get_node_info.ts +15 -23
- package/src/cmds/aztec_node/index.ts +87 -0
- package/src/cmds/contracts/inspect_contract.ts +16 -6
- package/src/cmds/infrastructure/index.ts +8 -10
- package/src/cmds/infrastructure/sequencers.ts +36 -19
- package/src/cmds/infrastructure/setup_l2_contract.ts +13 -25
- package/src/cmds/l1/advance_epoch.ts +7 -5
- package/src/cmds/l1/assume_proven_through.ts +8 -7
- package/src/cmds/l1/bridge_erc20.ts +7 -4
- package/src/cmds/l1/deploy_l1_contracts.ts +32 -7
- package/src/cmds/l1/deploy_new_rollup.ts +23 -9
- package/src/cmds/l1/get_l1_addresses.ts +1 -1
- package/src/cmds/l1/governance_utils.ts +18 -17
- package/src/cmds/l1/index.ts +74 -101
- package/src/cmds/l1/trigger_seed_snapshot.ts +31 -0
- package/src/cmds/l1/update_l1_validators.ts +194 -94
- package/src/cmds/misc/generate_bootnode_enr.ts +3 -2
- package/src/cmds/misc/generate_secret_and_hash.ts +3 -3
- package/src/cmds/misc/generate_secret_key.ts +1 -1
- package/src/cmds/misc/get_canonical_sponsored_fpc_address.ts +7 -0
- package/src/cmds/misc/index.ts +13 -4
- package/src/cmds/misc/update/github.ts +0 -1
- package/src/cmds/misc/update.ts +1 -7
- package/src/config/cached_fetch.ts +67 -0
- package/src/config/chain_l2_config.ts +597 -0
- package/src/config/enrich_env.ts +15 -0
- package/src/config/get_l1_config.ts +28 -0
- package/src/config/index.ts +4 -0
- package/src/config/network_config.ts +102 -0
- package/src/utils/aztec.ts +78 -65
- package/src/utils/commands.ts +13 -15
- package/src/utils/encoding.ts +1 -1
- package/src/utils/github.ts +0 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/inspect.ts +23 -123
- package/src/utils/setup_contracts.ts +19 -0
- package/dest/cmds/devnet/bootstrap_network.d.ts +0 -3
- package/dest/cmds/devnet/bootstrap_network.d.ts.map +0 -1
- package/dest/cmds/devnet/bootstrap_network.js +0 -196
- package/dest/cmds/devnet/faucet.d.ts +0 -4
- package/dest/cmds/devnet/faucet.d.ts.map +0 -1
- package/dest/cmds/devnet/faucet.js +0 -26
- package/dest/cmds/devnet/index.d.ts.map +0 -1
- package/dest/cmds/devnet/index.js +0 -14
- package/dest/cmds/l1/deploy_l1_verifier.d.ts +0 -5
- package/dest/cmds/l1/deploy_l1_verifier.d.ts.map +0 -1
- package/dest/cmds/l1/deploy_l1_verifier.js +0 -54
- package/dest/cmds/misc/setup_contracts.d.ts +0 -7
- package/dest/cmds/misc/setup_contracts.d.ts.map +0 -1
- package/dest/cmds/misc/setup_contracts.js +0 -27
- package/dest/cmds/pxe/add_contract.d.ts +0 -5
- package/dest/cmds/pxe/add_contract.d.ts.map +0 -1
- package/dest/cmds/pxe/add_contract.js +0 -29
- package/dest/cmds/pxe/block_number.d.ts +0 -3
- package/dest/cmds/pxe/block_number.d.ts.map +0 -1
- package/dest/cmds/pxe/block_number.js +0 -10
- package/dest/cmds/pxe/get_account.d.ts +0 -4
- package/dest/cmds/pxe/get_account.d.ts.map +0 -1
- package/dest/cmds/pxe/get_account.js +0 -10
- package/dest/cmds/pxe/get_accounts.d.ts +0 -3
- package/dest/cmds/pxe/get_accounts.d.ts.map +0 -1
- package/dest/cmds/pxe/get_accounts.js +0 -25
- package/dest/cmds/pxe/get_block.d.ts +0 -3
- package/dest/cmds/pxe/get_block.d.ts.map +0 -1
- package/dest/cmds/pxe/get_block.js +0 -9
- package/dest/cmds/pxe/get_contract_data.d.ts +0 -4
- package/dest/cmds/pxe/get_contract_data.d.ts.map +0 -1
- package/dest/cmds/pxe/get_contract_data.js +0 -31
- package/dest/cmds/pxe/get_current_base_fee.d.ts +0 -3
- package/dest/cmds/pxe/get_current_base_fee.d.ts.map +0 -1
- package/dest/cmds/pxe/get_current_base_fee.js +0 -7
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts +0 -4
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts.map +0 -1
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.js +0 -11
- package/dest/cmds/pxe/get_logs.d.ts +0 -4
- package/dest/cmds/pxe/get_logs.d.ts.map +0 -1
- package/dest/cmds/pxe/get_node_info.d.ts +0 -3
- package/dest/cmds/pxe/get_node_info.d.ts.map +0 -1
- package/dest/cmds/pxe/get_pxe_info.d.ts +0 -3
- package/dest/cmds/pxe/get_pxe_info.d.ts.map +0 -1
- package/dest/cmds/pxe/get_pxe_info.js +0 -11
- package/dest/cmds/pxe/index.d.ts +0 -4
- package/dest/cmds/pxe/index.d.ts.map +0 -1
- package/dest/cmds/pxe/index.js +0 -55
- package/src/cmds/devnet/bootstrap_network.ts +0 -318
- package/src/cmds/devnet/faucet.ts +0 -33
- package/src/cmds/devnet/index.ts +0 -60
- package/src/cmds/l1/deploy_l1_verifier.ts +0 -105
- package/src/cmds/misc/setup_contracts.ts +0 -40
- package/src/cmds/pxe/add_contract.ts +0 -41
- package/src/cmds/pxe/block_number.ts +0 -9
- package/src/cmds/pxe/get_account.ts +0 -16
- package/src/cmds/pxe/get_accounts.ts +0 -35
- package/src/cmds/pxe/get_block.ts +0 -10
- package/src/cmds/pxe/get_contract_data.ts +0 -51
- package/src/cmds/pxe/get_current_base_fee.ts +0 -9
- package/src/cmds/pxe/get_l1_to_l2_message_witness.ts +0 -25
- package/src/cmds/pxe/get_pxe_info.ts +0 -13
- package/src/cmds/pxe/index.ts +0 -170
- /package/dest/cmds/{devnet → aztec_node}/index.d.ts +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type NetworkConfig, NetworkConfigMapSchema, type NetworkNames } from '@aztec/foundation/config';
|
|
2
|
+
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
import { cachedFetch } from './cached_fetch.js';
|
|
7
|
+
import { enrichEthAddressVar, enrichVar } from './enrich_env.js';
|
|
8
|
+
|
|
9
|
+
const DEFAULT_CONFIG_URL =
|
|
10
|
+
'https://raw.githubusercontent.com/AztecProtocol/networks/refs/heads/main/network_config.json';
|
|
11
|
+
const NETWORK_CONFIG_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Fetches remote network configuration from GitHub with caching support.
|
|
15
|
+
* Uses the reusable cachedFetch utility.
|
|
16
|
+
*
|
|
17
|
+
* @param networkName - The network name to fetch config for
|
|
18
|
+
* @param cacheDir - Optional cache directory for storing fetched config
|
|
19
|
+
* @returns Remote configuration for the specified network, or undefined if not found/error
|
|
20
|
+
*/
|
|
21
|
+
export async function getNetworkConfig(
|
|
22
|
+
networkName: NetworkNames,
|
|
23
|
+
cacheDir?: string,
|
|
24
|
+
): Promise<NetworkConfig | undefined> {
|
|
25
|
+
let url: URL | undefined;
|
|
26
|
+
const configLocation = process.env.NETWORK_CONFIG_LOCATION || DEFAULT_CONFIG_URL;
|
|
27
|
+
|
|
28
|
+
if (!configLocation) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
if (configLocation.includes('://')) {
|
|
34
|
+
url = new URL(configLocation);
|
|
35
|
+
} else {
|
|
36
|
+
url = new URL(`file://${configLocation}`);
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
/* no-op */
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!url) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
let rawConfig: any;
|
|
48
|
+
|
|
49
|
+
if (url.protocol === 'http:' || url.protocol === 'https:') {
|
|
50
|
+
rawConfig = await cachedFetch(url.href, {
|
|
51
|
+
cacheDurationMs: NETWORK_CONFIG_CACHE_DURATION_MS,
|
|
52
|
+
cacheFile: cacheDir ? join(cacheDir, networkName, 'network_config.json') : undefined,
|
|
53
|
+
});
|
|
54
|
+
} else if (url.protocol === 'file:') {
|
|
55
|
+
rawConfig = JSON.parse(await readFile(url.pathname, 'utf-8'));
|
|
56
|
+
} else {
|
|
57
|
+
throw new Error('Unsupported Aztec network config protocol: ' + url.href);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!rawConfig) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const networkConfigMap = NetworkConfigMapSchema.parse(rawConfig);
|
|
65
|
+
if (networkName in networkConfigMap) {
|
|
66
|
+
return networkConfigMap[networkName];
|
|
67
|
+
} else {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Enriches environment variables with remote network configuration.
|
|
77
|
+
* This function is called before node config initialization to set env vars
|
|
78
|
+
* from the remote config, following the same pattern as enrichEnvironmentWithChainConfig().
|
|
79
|
+
*
|
|
80
|
+
* @param networkName - The network name to fetch remote config for
|
|
81
|
+
*/
|
|
82
|
+
export async function enrichEnvironmentWithNetworkConfig(networkName: NetworkNames) {
|
|
83
|
+
if (networkName === 'local') {
|
|
84
|
+
return; // No remote config for local development
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const cacheDir = process.env.DATA_DIRECTORY ? join(process.env.DATA_DIRECTORY, 'cache') : undefined;
|
|
88
|
+
const networkConfig = await getNetworkConfig(networkName, cacheDir);
|
|
89
|
+
|
|
90
|
+
if (!networkConfig) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
enrichVar('BOOTSTRAP_NODES', networkConfig.bootnodes.join(','));
|
|
95
|
+
enrichVar('L1_CHAIN_ID', String(networkConfig.l1ChainId));
|
|
96
|
+
enrichVar('SYNC_SNAPSHOTS_URLS', networkConfig.snapshots.join(','));
|
|
97
|
+
|
|
98
|
+
enrichEthAddressVar('REGISTRY_CONTRACT_ADDRESS', networkConfig.registryAddress.toString());
|
|
99
|
+
if (networkConfig.feeAssetHandlerAddress) {
|
|
100
|
+
enrichEthAddressVar('FEE_ASSET_HANDLER_CONTRACT_ADDRESS', networkConfig.feeAssetHandlerAddress.toString());
|
|
101
|
+
}
|
|
102
|
+
}
|
package/src/utils/aztec.ts
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
type ContractArtifact,
|
|
3
|
+
type FunctionAbi,
|
|
4
|
+
FunctionType,
|
|
5
|
+
getAllFunctionAbis,
|
|
6
|
+
loadContractArtifact,
|
|
7
|
+
} from '@aztec/aztec.js/abi';
|
|
8
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
9
|
+
import {
|
|
10
|
+
type DeployL1ContractsReturnType,
|
|
11
|
+
type L1ContractsConfig,
|
|
12
|
+
type Operator,
|
|
13
|
+
RollupContract,
|
|
14
|
+
} from '@aztec/ethereum';
|
|
15
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
16
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
5
17
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
6
18
|
import type { NoirPackageConfig } from '@aztec/foundation/noir';
|
|
7
|
-
import {
|
|
8
|
-
import { FunctionType } from '@aztec/stdlib/abi';
|
|
19
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
9
20
|
|
|
10
21
|
import TOML from '@iarna/toml';
|
|
11
22
|
import { readFile } from 'fs/promises';
|
|
12
|
-
import { gtr, ltr, satisfies, valid } from 'semver';
|
|
13
23
|
|
|
14
24
|
import { encodeArgs } from './encoding.js';
|
|
15
25
|
|
|
@@ -19,8 +29,8 @@ import { encodeArgs } from './encoding.js';
|
|
|
19
29
|
* @param fnName - Function name to be found.
|
|
20
30
|
* @returns The function's ABI.
|
|
21
31
|
*/
|
|
22
|
-
export function
|
|
23
|
-
const fn = artifact.
|
|
32
|
+
export function getFunctionAbi(artifact: ContractArtifact, fnName: string): FunctionAbi {
|
|
33
|
+
const fn = getAllFunctionAbis(artifact).find(({ name }) => name === fnName);
|
|
24
34
|
if (!fn) {
|
|
25
35
|
throw Error(`Function ${fnName} not found in contract ABI.`);
|
|
26
36
|
}
|
|
@@ -41,11 +51,14 @@ export async function deployAztecContracts(
|
|
|
41
51
|
mnemonic: string,
|
|
42
52
|
mnemonicIndex: number,
|
|
43
53
|
salt: number | undefined,
|
|
44
|
-
initialValidators:
|
|
54
|
+
initialValidators: Operator[],
|
|
45
55
|
genesisArchiveRoot: Fr,
|
|
46
|
-
|
|
56
|
+
feeJuicePortalInitialBalance: bigint,
|
|
47
57
|
acceleratedTestDeployments: boolean,
|
|
48
58
|
config: L1ContractsConfig,
|
|
59
|
+
existingToken: EthAddress | undefined,
|
|
60
|
+
realVerifier: boolean,
|
|
61
|
+
createVerificationJson: string | false,
|
|
49
62
|
debugLogger: Logger,
|
|
50
63
|
): Promise<DeployL1ContractsReturnType> {
|
|
51
64
|
const { createEthereumChain, deployL1Contracts } = await import('@aztec/ethereum');
|
|
@@ -53,29 +66,33 @@ export async function deployAztecContracts(
|
|
|
53
66
|
|
|
54
67
|
const account = !privateKey
|
|
55
68
|
? mnemonicToAccount(mnemonic!, { addressIndex: mnemonicIndex })
|
|
56
|
-
: privateKeyToAccount(
|
|
69
|
+
: privateKeyToAccount(addLeadingHex(privateKey));
|
|
57
70
|
const chain = createEthereumChain(rpcUrls, chainId);
|
|
58
71
|
|
|
59
72
|
const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types/vk-tree');
|
|
60
73
|
|
|
61
|
-
|
|
74
|
+
const result = await deployL1Contracts(
|
|
62
75
|
chain.rpcUrls,
|
|
63
76
|
account,
|
|
64
77
|
chain.chainInfo,
|
|
65
78
|
debugLogger,
|
|
66
79
|
{
|
|
67
|
-
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
|
|
68
80
|
vkTreeRoot: getVKTreeRoot(),
|
|
69
|
-
|
|
81
|
+
protocolContractsHash,
|
|
70
82
|
genesisArchiveRoot,
|
|
71
|
-
genesisBlockHash,
|
|
72
83
|
salt,
|
|
73
84
|
initialValidators,
|
|
74
85
|
acceleratedTestDeployments,
|
|
86
|
+
feeJuicePortalInitialBalance,
|
|
87
|
+
realVerifier,
|
|
88
|
+
existingTokenAddress: existingToken,
|
|
75
89
|
...config,
|
|
76
90
|
},
|
|
77
91
|
config,
|
|
92
|
+
createVerificationJson,
|
|
78
93
|
);
|
|
94
|
+
|
|
95
|
+
return result;
|
|
79
96
|
}
|
|
80
97
|
|
|
81
98
|
export async function deployNewRollupContracts(
|
|
@@ -86,40 +103,59 @@ export async function deployNewRollupContracts(
|
|
|
86
103
|
mnemonic: string,
|
|
87
104
|
mnemonicIndex: number,
|
|
88
105
|
salt: number | undefined,
|
|
89
|
-
initialValidators:
|
|
106
|
+
initialValidators: Operator[],
|
|
90
107
|
genesisArchiveRoot: Fr,
|
|
91
|
-
|
|
108
|
+
feeJuicePortalInitialBalance: bigint,
|
|
92
109
|
config: L1ContractsConfig,
|
|
110
|
+
realVerifier: boolean,
|
|
111
|
+
createVerificationJson: string | false,
|
|
93
112
|
logger: Logger,
|
|
94
|
-
): Promise<{
|
|
95
|
-
const { createEthereumChain,
|
|
113
|
+
): Promise<{ rollup: RollupContract; slashFactoryAddress: EthAddress }> {
|
|
114
|
+
const { createEthereumChain, deployRollupForUpgrade, createExtendedL1Client } = await import('@aztec/ethereum');
|
|
96
115
|
const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts');
|
|
97
116
|
const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types/vk-tree');
|
|
98
117
|
|
|
99
118
|
const account = !privateKey
|
|
100
119
|
? mnemonicToAccount(mnemonic!, { addressIndex: mnemonicIndex })
|
|
101
|
-
: privateKeyToAccount(
|
|
120
|
+
: privateKeyToAccount(addLeadingHex(privateKey));
|
|
102
121
|
const chain = createEthereumChain(rpcUrls, chainId);
|
|
103
|
-
const
|
|
122
|
+
const client = createExtendedL1Client(rpcUrls, account, chain.chainInfo, undefined, mnemonicIndex);
|
|
123
|
+
|
|
124
|
+
if (!initialValidators || initialValidators.length === 0) {
|
|
125
|
+
// initialize the new rollup with Amin's validator address.
|
|
126
|
+
const aminAddressString = '0x3b218d0F26d15B36C715cB06c949210a0d630637';
|
|
127
|
+
const amin = EthAddress.fromString(aminAddressString);
|
|
104
128
|
|
|
105
|
-
|
|
106
|
-
|
|
129
|
+
initialValidators = [
|
|
130
|
+
{
|
|
131
|
+
attester: amin,
|
|
132
|
+
withdrawer: amin,
|
|
133
|
+
// No secrets here. The actual keys are not currently used.
|
|
134
|
+
bn254SecretKey: new SecretValue(Fr.fromHexString(aminAddressString).toBigInt()),
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
logger.info('Initializing new rollup with old attesters', { initialValidators });
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const { rollup, slashFactoryAddress } = await deployRollupForUpgrade(
|
|
141
|
+
client,
|
|
107
142
|
{
|
|
108
143
|
salt,
|
|
109
144
|
vkTreeRoot: getVKTreeRoot(),
|
|
110
|
-
|
|
111
|
-
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
|
|
145
|
+
protocolContractsHash,
|
|
112
146
|
genesisArchiveRoot,
|
|
113
|
-
genesisBlockHash,
|
|
114
147
|
initialValidators,
|
|
148
|
+
feeJuicePortalInitialBalance,
|
|
149
|
+
realVerifier,
|
|
115
150
|
...config,
|
|
116
151
|
},
|
|
117
152
|
registryAddress,
|
|
118
153
|
logger,
|
|
119
154
|
config,
|
|
155
|
+
createVerificationJson,
|
|
120
156
|
);
|
|
121
157
|
|
|
122
|
-
return {
|
|
158
|
+
return { rollup, slashFactoryAddress };
|
|
123
159
|
}
|
|
124
160
|
|
|
125
161
|
/**
|
|
@@ -178,7 +214,7 @@ export async function getContractArtifact(fileDir: string, log: LogFn) {
|
|
|
178
214
|
*/
|
|
179
215
|
export async function prepTx(contractFile: string, functionName: string, _functionArgs: string[], log: LogFn) {
|
|
180
216
|
const contractArtifact = await getContractArtifact(contractFile, log);
|
|
181
|
-
const functionArtifact =
|
|
217
|
+
const functionArtifact = getFunctionAbi(contractArtifact, functionName);
|
|
182
218
|
const functionArgs = encodeArgs(_functionArgs, functionArtifact.parameters);
|
|
183
219
|
const isPrivate = functionArtifact.functionType === FunctionType.PRIVATE;
|
|
184
220
|
|
|
@@ -190,7 +226,7 @@ export async function prepTx(contractFile: string, functionName: string, _functi
|
|
|
190
226
|
* @param hex - A hex string
|
|
191
227
|
* @returns A new string with leading 0x removed
|
|
192
228
|
*/
|
|
193
|
-
export const stripLeadingHex = (hex: string) => {
|
|
229
|
+
export const stripLeadingHex = (hex: string): string => {
|
|
194
230
|
if (hex.length > 2 && hex.startsWith('0x')) {
|
|
195
231
|
return hex.substring(2);
|
|
196
232
|
}
|
|
@@ -198,6 +234,18 @@ export const stripLeadingHex = (hex: string) => {
|
|
|
198
234
|
};
|
|
199
235
|
|
|
200
236
|
/**
|
|
237
|
+
* Adds a leading 0x to a hex string. If a leading 0x is already present the string is returned unchanged.
|
|
238
|
+
* @param hex - A hex string
|
|
239
|
+
* @returns A new string with leading 0x added
|
|
240
|
+
*/
|
|
241
|
+
export const addLeadingHex = (hex: string): `0x${string}` => {
|
|
242
|
+
if (hex.length > 2 && hex.startsWith('0x')) {
|
|
243
|
+
return hex as `0x${string}`;
|
|
244
|
+
}
|
|
245
|
+
return `0x${hex}`;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/*
|
|
201
249
|
* Pretty prints Nargo.toml contents to a string
|
|
202
250
|
* @param config - Nargo.toml contents
|
|
203
251
|
* @returns The Nargo.toml contents as a string
|
|
@@ -213,38 +261,3 @@ export function prettyPrintNargoToml(config: NoirPackageConfig): string {
|
|
|
213
261
|
|
|
214
262
|
return partialToml + '\n[dependencies]\n' + dependenciesToml.join('\n') + '\n';
|
|
215
263
|
}
|
|
216
|
-
|
|
217
|
-
/** Mismatch between server and client versions. */
|
|
218
|
-
class VersionMismatchError extends Error {}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Checks that Private eXecution Environment (PXE) version matches the expected one by this CLI. Throws if not.
|
|
222
|
-
* @param pxe - PXE client.
|
|
223
|
-
* @param expectedVersionRange - Expected version by CLI.
|
|
224
|
-
*/
|
|
225
|
-
export async function checkServerVersion(pxe: PXE, expectedVersionRange: string) {
|
|
226
|
-
const serverName = 'Aztec Node';
|
|
227
|
-
const { nodeVersion } = await pxe.getNodeInfo();
|
|
228
|
-
if (!nodeVersion) {
|
|
229
|
-
throw new VersionMismatchError(`Couldn't determine ${serverName} version. You may run into issues.`);
|
|
230
|
-
}
|
|
231
|
-
if (!nodeVersion || !valid(nodeVersion)) {
|
|
232
|
-
throw new VersionMismatchError(
|
|
233
|
-
`Missing or invalid version identifier for ${serverName} (${nodeVersion ?? 'empty'}).`,
|
|
234
|
-
);
|
|
235
|
-
} else if (!satisfies(nodeVersion, expectedVersionRange)) {
|
|
236
|
-
if (gtr(nodeVersion, expectedVersionRange)) {
|
|
237
|
-
throw new VersionMismatchError(
|
|
238
|
-
`${serverName} is running version ${nodeVersion} which is newer than the expected by this CLI (${expectedVersionRange}). Consider upgrading your CLI to a newer version.`,
|
|
239
|
-
);
|
|
240
|
-
} else if (ltr(nodeVersion, expectedVersionRange)) {
|
|
241
|
-
throw new VersionMismatchError(
|
|
242
|
-
`${serverName} is running version ${nodeVersion} which is older than the expected by this CLI (${expectedVersionRange}). Consider upgrading your ${serverName} to a newer version.`,
|
|
243
|
-
);
|
|
244
|
-
} else {
|
|
245
|
-
throw new VersionMismatchError(
|
|
246
|
-
`${serverName} is running version ${nodeVersion} which does not match the expected by this CLI (${expectedVersionRange}).`,
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
package/src/utils/commands.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
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';
|
|
2
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
4
3
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
-
import { LogId } from '@aztec/aztec.js/
|
|
6
|
-
import { TxHash } from '@aztec/aztec.js/
|
|
4
|
+
import { LogId } from '@aztec/aztec.js/log';
|
|
5
|
+
import { TxHash } from '@aztec/aztec.js/tx';
|
|
7
6
|
import type { LogFn } from '@aztec/foundation/log';
|
|
8
|
-
import type { PXE } from '@aztec/
|
|
7
|
+
import type { PXE } from '@aztec/pxe/server';
|
|
9
8
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
10
9
|
|
|
11
10
|
import { type Command, CommanderError, InvalidArgumentError, Option } from 'commander';
|
|
@@ -22,21 +21,20 @@ export const getLocalhost = () =>
|
|
|
22
21
|
.catch(() => 'localhost');
|
|
23
22
|
|
|
24
23
|
export const LOCALHOST = await getLocalhost();
|
|
25
|
-
export const { ETHEREUM_HOSTS = `http://${LOCALHOST}:8545`, PRIVATE_KEY, API_KEY, CLI_VERSION } = process.env;
|
|
24
|
+
export const { ETHEREUM_HOSTS = `http://${LOCALHOST}:8545`, PRIVATE_KEY, MNEMONIC, API_KEY, CLI_VERSION } = process.env;
|
|
26
25
|
|
|
27
26
|
export function addOptions(program: Command, options: Option[]) {
|
|
28
27
|
options.forEach(option => program.addOption(option));
|
|
29
28
|
return program;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
export const
|
|
33
|
-
new Option('-
|
|
34
|
-
.env('
|
|
31
|
+
export const makeNodeOption = (mandatory: boolean) =>
|
|
32
|
+
new Option('-n, --node-url <string>', 'URL of the Aztec node')
|
|
33
|
+
.env('AZTEC_NODE_URL')
|
|
35
34
|
.default(`http://${LOCALHOST}:8080`)
|
|
36
|
-
.conflicts('remote-pxe')
|
|
37
35
|
.makeOptionMandatory(mandatory);
|
|
38
36
|
|
|
39
|
-
export const
|
|
37
|
+
export const nodeOption = makeNodeOption(true);
|
|
40
38
|
|
|
41
39
|
export const l1ChainIdOption = new Option('-c, --l1-chain-id <number>', 'Chain ID of the ethereum host')
|
|
42
40
|
.env('L1_CHAIN_ID')
|
|
@@ -287,7 +285,7 @@ export function parsePublicKey(publicKey: string): PublicKeys | undefined {
|
|
|
287
285
|
}
|
|
288
286
|
try {
|
|
289
287
|
return PublicKeys.fromString(publicKey);
|
|
290
|
-
} catch
|
|
288
|
+
} catch {
|
|
291
289
|
throw new InvalidArgumentError(`Invalid public key: ${publicKey}`);
|
|
292
290
|
}
|
|
293
291
|
}
|
|
@@ -301,7 +299,7 @@ export function parsePublicKey(publicKey: string): PublicKeys | undefined {
|
|
|
301
299
|
export function parsePartialAddress(address: string): Fr {
|
|
302
300
|
try {
|
|
303
301
|
return Fr.fromHexString(address);
|
|
304
|
-
} catch
|
|
302
|
+
} catch {
|
|
305
303
|
throw new InvalidArgumentError(`Invalid partial address: ${address}`);
|
|
306
304
|
}
|
|
307
305
|
}
|
|
@@ -315,7 +313,7 @@ export function parsePartialAddress(address: string): Fr {
|
|
|
315
313
|
export function parseSecretKey(secretKey: string): Fr {
|
|
316
314
|
try {
|
|
317
315
|
return Fr.fromHexString(secretKey);
|
|
318
|
-
} catch
|
|
316
|
+
} catch {
|
|
319
317
|
throw new InvalidArgumentError(`Invalid encryption secret key: ${secretKey}`);
|
|
320
318
|
}
|
|
321
319
|
}
|
|
@@ -348,7 +346,7 @@ export function parseField(field: string): Fr {
|
|
|
348
346
|
}
|
|
349
347
|
|
|
350
348
|
return new Fr(BigInt(field));
|
|
351
|
-
} catch
|
|
349
|
+
} catch {
|
|
352
350
|
throw new InvalidArgumentError(`Invalid field: ${field}`);
|
|
353
351
|
}
|
|
354
352
|
}
|
package/src/utils/encoding.ts
CHANGED
|
@@ -35,7 +35,7 @@ function encodeArg(arg: string, abiType: AbiType, name: string): any {
|
|
|
35
35
|
let res: bigint;
|
|
36
36
|
try {
|
|
37
37
|
res = BigInt(arg);
|
|
38
|
-
} catch
|
|
38
|
+
} catch {
|
|
39
39
|
throw new Error(
|
|
40
40
|
`Invalid value passed for ${name}. Could not parse ${arg} as a${kind === 'integer' ? 'n' : ''} ${kind}.`,
|
|
41
41
|
);
|
package/src/utils/github.ts
CHANGED
package/src/utils/index.ts
CHANGED
package/src/utils/inspect.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import type { AztecAddress, ContractArtifact, Fr } from '@aztec/aztec.js';
|
|
2
1
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
import {
|
|
4
|
-
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
5
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
6
|
-
import { type ExtendedNote, NoteStatus } from '@aztec/stdlib/note';
|
|
2
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
7
3
|
import type { TxHash } from '@aztec/stdlib/tx';
|
|
8
4
|
|
|
9
|
-
export async function inspectBlock(
|
|
10
|
-
|
|
5
|
+
export async function inspectBlock(
|
|
6
|
+
aztecNode: AztecNode,
|
|
7
|
+
blockNumber: number,
|
|
8
|
+
log: LogFn,
|
|
9
|
+
opts: { showTxs?: boolean } = {},
|
|
10
|
+
) {
|
|
11
|
+
const block = await aztecNode.getBlock(blockNumber);
|
|
11
12
|
if (!block) {
|
|
12
13
|
log(`No block found for block number ${blockNumber}`);
|
|
13
14
|
return;
|
|
@@ -18,16 +19,15 @@ export async function inspectBlock(pxe: PXE, blockNumber: number, log: LogFn, op
|
|
|
18
19
|
log(` Total fees: ${block.header.totalFees.toBigInt()}`);
|
|
19
20
|
log(` Total mana used: ${block.header.totalManaUsed.toBigInt()}`);
|
|
20
21
|
log(
|
|
21
|
-
` Fee per gas unit: DA=${block.header.globalVariables.gasFees.feePerDaGas
|
|
22
|
+
` Fee per gas unit: DA=${block.header.globalVariables.gasFees.feePerDaGas} L2=${block.header.globalVariables.gasFees.feePerL2Gas}`,
|
|
22
23
|
);
|
|
23
24
|
log(` Coinbase: ${block.header.globalVariables.coinbase}`);
|
|
24
25
|
log(` Fee recipient: ${block.header.globalVariables.feeRecipient}`);
|
|
25
|
-
log(` Timestamp: ${new Date(block.header.globalVariables.timestamp
|
|
26
|
+
log(` Timestamp: ${new Date(Number(block.header.globalVariables.timestamp) * 500)}`);
|
|
26
27
|
if (opts.showTxs) {
|
|
27
28
|
log(``);
|
|
28
|
-
const artifactMap = await getKnownArtifacts(pxe);
|
|
29
29
|
for (const txHash of block.body.txEffects.map(tx => tx.txHash)) {
|
|
30
|
-
await inspectTx(
|
|
30
|
+
await inspectTx(aztecNode, txHash, log, { includeBlockInfo: false });
|
|
31
31
|
}
|
|
32
32
|
} else {
|
|
33
33
|
log(` Transactions: ${block.body.txEffects.length}`);
|
|
@@ -35,16 +35,12 @@ export async function inspectBlock(pxe: PXE, blockNumber: number, log: LogFn, op
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export async function inspectTx(
|
|
38
|
-
|
|
38
|
+
aztecNode: AztecNode,
|
|
39
39
|
txHash: TxHash,
|
|
40
40
|
log: LogFn,
|
|
41
|
-
opts: { includeBlockInfo?: boolean
|
|
41
|
+
opts: { includeBlockInfo?: boolean } = {},
|
|
42
42
|
) {
|
|
43
|
-
const [receipt, effectsInBlock
|
|
44
|
-
pxe.getTxReceipt(txHash),
|
|
45
|
-
pxe.getTxEffect(txHash),
|
|
46
|
-
pxe.getNotes({ txHash, status: NoteStatus.ACTIVE_OR_NULLIFIED }),
|
|
47
|
-
]);
|
|
43
|
+
const [receipt, effectsInBlock] = await Promise.all([aztecNode.getTxReceipt(txHash), aztecNode.getTxEffect(txHash)]);
|
|
48
44
|
// Base tx data
|
|
49
45
|
log(`Tx ${txHash.toString()}`);
|
|
50
46
|
log(` Status: ${receipt.status} ${effectsInBlock ? `(${effectsInBlock.data.revertCode.getDescription()})` : ''}`);
|
|
@@ -57,7 +53,6 @@ export async function inspectTx(
|
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
const effects = effectsInBlock.data;
|
|
60
|
-
const artifactMap = opts?.artifactMap ?? (await getKnownArtifacts(pxe));
|
|
61
56
|
|
|
62
57
|
if (opts.includeBlockInfo) {
|
|
63
58
|
log(` Block: ${receipt.blockNumber} (${receipt.blockHash?.toString()})`);
|
|
@@ -88,45 +83,18 @@ export async function inspectTx(
|
|
|
88
83
|
const notes = effects.noteHashes;
|
|
89
84
|
if (notes.length > 0) {
|
|
90
85
|
log(' Created notes:');
|
|
91
|
-
log(` Total: ${notes.length}
|
|
92
|
-
|
|
93
|
-
log(
|
|
94
|
-
for (const note of getNotes) {
|
|
95
|
-
inspectNote(note, artifactMap, log);
|
|
96
|
-
}
|
|
86
|
+
log(` Total: ${notes.length}`);
|
|
87
|
+
for (const note of notes) {
|
|
88
|
+
log(` Note hash: ${note.toShortString()}`);
|
|
97
89
|
}
|
|
98
90
|
}
|
|
99
91
|
|
|
100
|
-
//
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const [note] = await pxe.getNotes({ siloedNullifier: nullifier });
|
|
107
|
-
const deployed = deployNullifiers[nullifier.toString()];
|
|
108
|
-
const initialized = initNullifiers[nullifier.toString()];
|
|
109
|
-
const registered = classNullifiers[nullifier.toString()];
|
|
110
|
-
if (nullifier.toBuffer().equals(txHash.toBuffer())) {
|
|
111
|
-
log(` Transaction hash nullifier ${nullifier.toShortString()}`);
|
|
112
|
-
} else if (note) {
|
|
113
|
-
inspectNote(note, artifactMap, log, `Nullifier ${nullifier.toShortString()} for note`);
|
|
114
|
-
} else if (deployed) {
|
|
115
|
-
log(
|
|
116
|
-
` Contract ${toFriendlyAddress(deployed, artifactMap)} deployed via nullifier ${nullifier.toShortString()}`,
|
|
117
|
-
);
|
|
118
|
-
} else if (initialized) {
|
|
119
|
-
log(
|
|
120
|
-
` Contract ${toFriendlyAddress(
|
|
121
|
-
initialized,
|
|
122
|
-
artifactMap,
|
|
123
|
-
)} initialized via nullifier ${nullifier.toShortString()}`,
|
|
124
|
-
);
|
|
125
|
-
} else if (registered) {
|
|
126
|
-
log(` Class ${registered} registered via nullifier ${nullifier.toShortString()}`);
|
|
127
|
-
} else {
|
|
128
|
-
log(` Unknown nullifier ${nullifier.toString()}`);
|
|
129
|
-
}
|
|
92
|
+
// Created nullifiers
|
|
93
|
+
const nullifiers = effects.nullifiers;
|
|
94
|
+
if (nullifiers.length > 0) {
|
|
95
|
+
log(' Created nullifiers:');
|
|
96
|
+
for (const nullifier of nullifiers) {
|
|
97
|
+
log(` Nullifier: ${nullifier.toShortString()}`);
|
|
130
98
|
}
|
|
131
99
|
}
|
|
132
100
|
|
|
@@ -138,71 +106,3 @@ export async function inspectTx(
|
|
|
138
106
|
}
|
|
139
107
|
}
|
|
140
108
|
}
|
|
141
|
-
|
|
142
|
-
function inspectNote(note: ExtendedNote, artifactMap: ArtifactMap, log: LogFn, text = 'Note') {
|
|
143
|
-
const artifact = artifactMap[note.contractAddress.toString()];
|
|
144
|
-
const contract = artifact?.name ?? note.contractAddress.toString();
|
|
145
|
-
const type = artifact?.notes[note.noteTypeId.toString()]?.typ ?? note.noteTypeId.toField().toShortString();
|
|
146
|
-
log(` ${text} type ${type} at ${contract}`);
|
|
147
|
-
log(` Owner: ${toFriendlyAddress(note.owner, artifactMap)}`);
|
|
148
|
-
for (const field of note.note.items) {
|
|
149
|
-
log(` ${field.toString()}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function toFriendlyAddress(address: AztecAddress, artifactMap: ArtifactMap) {
|
|
154
|
-
const artifact = artifactMap[address.toString()];
|
|
155
|
-
if (!artifact) {
|
|
156
|
-
return address.toString();
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return `${artifact.name}<${address.toString()}>`;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async function getKnownNullifiers(pxe: PXE, artifactMap: ArtifactMap) {
|
|
163
|
-
const knownContracts = await pxe.getContracts();
|
|
164
|
-
const deployerAddress = ProtocolContractAddress.ContractInstanceDeployer;
|
|
165
|
-
const registererAddress = ProtocolContractAddress.ContractClassRegisterer;
|
|
166
|
-
const initNullifiers: Record<string, AztecAddress> = {};
|
|
167
|
-
const deployNullifiers: Record<string, AztecAddress> = {};
|
|
168
|
-
const classNullifiers: Record<string, string> = {};
|
|
169
|
-
for (const contract of knownContracts) {
|
|
170
|
-
initNullifiers[siloNullifier(contract, contract.toField()).toString()] = contract;
|
|
171
|
-
deployNullifiers[siloNullifier(deployerAddress, contract.toField()).toString()] = contract;
|
|
172
|
-
}
|
|
173
|
-
for (const artifact of Object.values(artifactMap)) {
|
|
174
|
-
classNullifiers[
|
|
175
|
-
siloNullifier(registererAddress, artifact.classId).toString()
|
|
176
|
-
] = `${artifact.name}Class<${artifact.classId}>`;
|
|
177
|
-
}
|
|
178
|
-
return { initNullifiers, deployNullifiers, classNullifiers };
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
type ArtifactMap = Record<string, ContractArtifactWithClassId>;
|
|
182
|
-
type ContractArtifactWithClassId = ContractArtifact & { classId: Fr };
|
|
183
|
-
async function getKnownArtifacts(pxe: PXE): Promise<ArtifactMap> {
|
|
184
|
-
const knownContractAddresses = await pxe.getContracts();
|
|
185
|
-
const knownContracts = (
|
|
186
|
-
await Promise.all(knownContractAddresses.map(contractAddress => pxe.getContractMetadata(contractAddress)))
|
|
187
|
-
).map(contractMetadata => contractMetadata.contractInstance);
|
|
188
|
-
const classIds = [...new Set(knownContracts.map(contract => contract?.currentContractClassId))];
|
|
189
|
-
const knownArtifacts = (
|
|
190
|
-
await Promise.all(classIds.map(classId => (classId ? pxe.getContractClassMetadata(classId) : undefined)))
|
|
191
|
-
).map(contractClassMetadata =>
|
|
192
|
-
contractClassMetadata
|
|
193
|
-
? { ...contractClassMetadata.artifact, classId: contractClassMetadata.contractClass?.id }
|
|
194
|
-
: undefined,
|
|
195
|
-
);
|
|
196
|
-
const map: Record<string, ContractArtifactWithClassId> = {};
|
|
197
|
-
for (const instance of knownContracts) {
|
|
198
|
-
if (instance) {
|
|
199
|
-
const artifact = knownArtifacts.find(a =>
|
|
200
|
-
a?.classId?.equals(instance.currentContractClassId),
|
|
201
|
-
) as ContractArtifactWithClassId;
|
|
202
|
-
if (artifact) {
|
|
203
|
-
map[instance.address.toString()] = artifact;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return map;
|
|
208
|
-
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
+
import { SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
5
|
+
|
|
6
|
+
async function getSponsoredFPCContract() {
|
|
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 { SponsoredFPCContract } = await import('@aztec/noir-contracts.js/SponsoredFPC');
|
|
10
|
+
return SponsoredFPCContract;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function getSponsoredFPCAddress(): Promise<AztecAddress> {
|
|
14
|
+
const SponsoredFPCContract = await getSponsoredFPCContract();
|
|
15
|
+
const sponsoredFPCInstance = await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
16
|
+
salt: new Fr(SPONSORED_FPC_SALT),
|
|
17
|
+
});
|
|
18
|
+
return sponsoredFPCInstance.address;
|
|
19
|
+
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
2
|
-
export declare function bootstrapNetwork(pxeUrl: string, l1Urls: string[], l1ChainId: string, l1PrivateKey: `0x${string}` | undefined, l1Mnemonic: string, addressIndex: number, json: boolean, log: LogFn, debugLog: Logger): Promise<void>;
|
|
3
|
-
//# sourceMappingURL=bootstrap_network.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap_network.d.ts","sourceRoot":"","sources":["../../../src/cmds/devnet/bootstrap_network.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAiB3D,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EAAE,EAChB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,KAAK,MAAM,EAAE,GAAG,SAAS,EACvC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,KAAK,EACV,QAAQ,EAAE,MAAM,iBA4EjB"}
|