@aztec/cli 0.0.0-test.1 → 0.0.1-commit.b655e406

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.
Files changed (242) hide show
  1. package/README.md +1 -427
  2. package/dest/cmds/aztec_node/block_number.d.ts +3 -0
  3. package/dest/cmds/aztec_node/block_number.d.ts.map +1 -0
  4. package/dest/cmds/aztec_node/block_number.js +10 -0
  5. package/dest/cmds/aztec_node/get_block.d.ts +3 -0
  6. package/dest/cmds/aztec_node/get_block.d.ts.map +1 -0
  7. package/dest/cmds/aztec_node/get_block.js +9 -0
  8. package/dest/cmds/aztec_node/get_current_base_fee.d.ts +3 -0
  9. package/dest/cmds/aztec_node/get_current_base_fee.d.ts.map +1 -0
  10. package/dest/cmds/aztec_node/get_current_base_fee.js +7 -0
  11. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts +5 -0
  12. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts.map +1 -0
  13. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.js +12 -0
  14. package/dest/cmds/aztec_node/get_logs.d.ts +6 -0
  15. package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -0
  16. package/dest/cmds/{pxe → aztec_node}/get_logs.js +4 -4
  17. package/dest/cmds/aztec_node/get_node_info.d.ts +3 -0
  18. package/dest/cmds/aztec_node/get_node_info.d.ts.map +1 -0
  19. package/dest/cmds/{pxe → aztec_node}/get_node_info.js +14 -15
  20. package/dest/cmds/aztec_node/index.d.ts.map +1 -0
  21. package/dest/cmds/aztec_node/index.js +28 -0
  22. package/dest/cmds/contracts/inspect_contract.d.ts.map +1 -1
  23. package/dest/cmds/contracts/inspect_contract.js +9 -5
  24. package/dest/cmds/infrastructure/index.d.ts +2 -2
  25. package/dest/cmds/infrastructure/index.d.ts.map +1 -1
  26. package/dest/cmds/infrastructure/index.js +8 -9
  27. package/dest/cmds/infrastructure/sequencers.d.ts +4 -4
  28. package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
  29. package/dest/cmds/infrastructure/sequencers.js +29 -16
  30. package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
  31. package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
  32. package/dest/cmds/infrastructure/setup_l2_contract.js +11 -24
  33. package/dest/cmds/l1/advance_epoch.d.ts +1 -1
  34. package/dest/cmds/l1/advance_epoch.d.ts.map +1 -1
  35. package/dest/cmds/l1/advance_epoch.js +8 -6
  36. package/dest/cmds/l1/assume_proven_through.d.ts +1 -1
  37. package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
  38. package/dest/cmds/l1/assume_proven_through.js +9 -8
  39. package/dest/cmds/l1/bridge_erc20.d.ts +2 -2
  40. package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
  41. package/dest/cmds/l1/bridge_erc20.js +5 -5
  42. package/dest/cmds/l1/deploy_l1_contracts.d.ts +2 -2
  43. package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +1 -1
  44. package/dest/cmds/l1/deploy_l1_contracts.js +23 -6
  45. package/dest/cmds/l1/deploy_new_rollup.d.ts +2 -1
  46. package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
  47. package/dest/cmds/l1/deploy_new_rollup.js +17 -8
  48. package/dest/cmds/l1/get_l1_addresses.d.ts +1 -1
  49. package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -1
  50. package/dest/cmds/l1/governance_utils.d.ts.map +1 -1
  51. package/dest/cmds/l1/governance_utils.js +17 -17
  52. package/dest/cmds/l1/index.d.ts +1 -0
  53. package/dest/cmds/l1/index.d.ts.map +1 -1
  54. package/dest/cmds/l1/index.js +33 -43
  55. package/dest/cmds/l1/trigger_seed_snapshot.d.ts +6 -0
  56. package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -0
  57. package/dest/cmds/l1/trigger_seed_snapshot.js +19 -0
  58. package/dest/cmds/l1/update_l1_validators.d.ts +17 -2
  59. package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
  60. package/dest/cmds/l1/update_l1_validators.js +159 -103
  61. package/dest/cmds/misc/generate_bootnode_enr.d.ts +1 -1
  62. package/dest/cmds/misc/generate_bootnode_enr.d.ts.map +1 -1
  63. package/dest/cmds/misc/generate_bootnode_enr.js +2 -2
  64. package/dest/cmds/misc/generate_secret_and_hash.d.ts +1 -1
  65. package/dest/cmds/misc/generate_secret_and_hash.d.ts.map +1 -1
  66. package/dest/cmds/misc/generate_secret_and_hash.js +3 -3
  67. package/dest/cmds/misc/generate_secret_key.d.ts +1 -1
  68. package/dest/cmds/misc/generate_secret_key.d.ts.map +1 -1
  69. package/dest/cmds/misc/generate_secret_key.js +1 -1
  70. package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts +3 -0
  71. package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts.map +1 -0
  72. package/dest/cmds/misc/get_canonical_sponsored_fpc_address.js +4 -0
  73. package/dest/cmds/misc/index.d.ts.map +1 -1
  74. package/dest/cmds/misc/index.js +7 -3
  75. package/dest/cmds/misc/update/github.d.ts +0 -1
  76. package/dest/cmds/misc/update/github.d.ts.map +1 -1
  77. package/dest/cmds/misc/update/github.js +0 -1
  78. package/dest/cmds/misc/update.d.ts.map +1 -1
  79. package/dest/cmds/misc/update.js +2 -3
  80. package/dest/cmds/validator_keys/add.d.ts +5 -0
  81. package/dest/cmds/validator_keys/add.d.ts.map +1 -0
  82. package/dest/cmds/validator_keys/add.js +70 -0
  83. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts +12 -0
  84. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -0
  85. package/dest/cmds/validator_keys/generate_bls_keypair.js +26 -0
  86. package/dest/cmds/validator_keys/index.d.ts +4 -0
  87. package/dest/cmds/validator_keys/index.d.ts.map +1 -0
  88. package/dest/cmds/validator_keys/index.js +20 -0
  89. package/dest/cmds/validator_keys/new.d.ts +26 -0
  90. package/dest/cmds/validator_keys/new.d.ts.map +1 -0
  91. package/dest/cmds/validator_keys/new.js +60 -0
  92. package/dest/cmds/validator_keys/shared.d.ts +68 -0
  93. package/dest/cmds/validator_keys/shared.d.ts.map +1 -0
  94. package/dest/cmds/validator_keys/shared.js +271 -0
  95. package/dest/config/cached_fetch.d.ts +18 -0
  96. package/dest/config/cached_fetch.d.ts.map +1 -0
  97. package/dest/config/cached_fetch.js +54 -0
  98. package/dest/config/chain_l2_config.d.ts +39 -0
  99. package/dest/config/chain_l2_config.d.ts.map +1 -0
  100. package/dest/config/chain_l2_config.js +475 -0
  101. package/dest/config/enrich_env.d.ts +4 -0
  102. package/dest/config/enrich_env.d.ts.map +1 -0
  103. package/dest/config/enrich_env.js +12 -0
  104. package/dest/config/get_l1_config.d.ts +8 -0
  105. package/dest/config/get_l1_config.d.ts.map +1 -0
  106. package/dest/config/get_l1_config.js +22 -0
  107. package/dest/config/index.d.ts +5 -0
  108. package/dest/config/index.d.ts.map +1 -0
  109. package/dest/config/index.js +4 -0
  110. package/dest/config/network_config.d.ts +19 -0
  111. package/dest/config/network_config.d.ts.map +1 -0
  112. package/dest/config/network_config.js +79 -0
  113. package/dest/utils/aztec.d.ts +12 -17
  114. package/dest/utils/aztec.d.ts.map +1 -1
  115. package/dest/utils/aztec.js +54 -49
  116. package/dest/utils/commands.d.ts +17 -9
  117. package/dest/utils/commands.d.ts.map +1 -1
  118. package/dest/utils/commands.js +40 -14
  119. package/dest/utils/encoding.js +1 -1
  120. package/dest/utils/github.d.ts +0 -1
  121. package/dest/utils/github.d.ts.map +1 -1
  122. package/dest/utils/github.js +0 -1
  123. package/dest/utils/index.d.ts +1 -0
  124. package/dest/utils/index.d.ts.map +1 -1
  125. package/dest/utils/index.js +1 -0
  126. package/dest/utils/inspect.d.ts +3 -10
  127. package/dest/utils/inspect.d.ts.map +1 -1
  128. package/dest/utils/inspect.js +19 -109
  129. package/dest/utils/setup_contracts.d.ts +3 -0
  130. package/dest/utils/setup_contracts.d.ts.map +1 -0
  131. package/dest/utils/setup_contracts.js +16 -0
  132. package/package.json +44 -33
  133. package/src/cmds/aztec_node/block_number.ts +9 -0
  134. package/src/cmds/aztec_node/get_block.ts +10 -0
  135. package/src/cmds/aztec_node/get_current_base_fee.ts +9 -0
  136. package/src/cmds/aztec_node/get_l1_to_l2_message_witness.ts +27 -0
  137. package/src/cmds/{pxe → aztec_node}/get_logs.ts +8 -7
  138. package/src/cmds/{pxe → aztec_node}/get_node_info.ts +15 -23
  139. package/src/cmds/aztec_node/index.ts +87 -0
  140. package/src/cmds/contracts/inspect_contract.ts +16 -6
  141. package/src/cmds/infrastructure/index.ts +8 -10
  142. package/src/cmds/infrastructure/sequencers.ts +36 -19
  143. package/src/cmds/infrastructure/setup_l2_contract.ts +13 -25
  144. package/src/cmds/l1/advance_epoch.ts +7 -5
  145. package/src/cmds/l1/assume_proven_through.ts +8 -7
  146. package/src/cmds/l1/bridge_erc20.ts +7 -4
  147. package/src/cmds/l1/deploy_l1_contracts.ts +32 -7
  148. package/src/cmds/l1/deploy_new_rollup.ts +23 -9
  149. package/src/cmds/l1/get_l1_addresses.ts +1 -1
  150. package/src/cmds/l1/governance_utils.ts +18 -17
  151. package/src/cmds/l1/index.ts +74 -101
  152. package/src/cmds/l1/trigger_seed_snapshot.ts +31 -0
  153. package/src/cmds/l1/update_l1_validators.ts +194 -94
  154. package/src/cmds/misc/generate_bootnode_enr.ts +3 -2
  155. package/src/cmds/misc/generate_secret_and_hash.ts +3 -3
  156. package/src/cmds/misc/generate_secret_key.ts +1 -1
  157. package/src/cmds/misc/get_canonical_sponsored_fpc_address.ts +7 -0
  158. package/src/cmds/misc/index.ts +13 -4
  159. package/src/cmds/misc/update/github.ts +0 -1
  160. package/src/cmds/misc/update.ts +1 -7
  161. package/src/cmds/validator_keys/add.ts +113 -0
  162. package/src/cmds/validator_keys/generate_bls_keypair.ts +33 -0
  163. package/src/cmds/validator_keys/index.ts +96 -0
  164. package/src/cmds/validator_keys/new.ts +120 -0
  165. package/src/cmds/validator_keys/shared.ts +321 -0
  166. package/src/config/cached_fetch.ts +67 -0
  167. package/src/config/chain_l2_config.ts +627 -0
  168. package/src/config/enrich_env.ts +15 -0
  169. package/src/config/get_l1_config.ts +28 -0
  170. package/src/config/index.ts +4 -0
  171. package/src/config/network_config.ts +102 -0
  172. package/src/utils/aztec.ts +78 -65
  173. package/src/utils/commands.ts +54 -18
  174. package/src/utils/encoding.ts +1 -1
  175. package/src/utils/github.ts +0 -1
  176. package/src/utils/index.ts +1 -0
  177. package/src/utils/inspect.ts +23 -123
  178. package/src/utils/setup_contracts.ts +19 -0
  179. package/dest/cmds/devnet/bootstrap_network.d.ts +0 -3
  180. package/dest/cmds/devnet/bootstrap_network.d.ts.map +0 -1
  181. package/dest/cmds/devnet/bootstrap_network.js +0 -196
  182. package/dest/cmds/devnet/faucet.d.ts +0 -4
  183. package/dest/cmds/devnet/faucet.d.ts.map +0 -1
  184. package/dest/cmds/devnet/faucet.js +0 -26
  185. package/dest/cmds/devnet/index.d.ts.map +0 -1
  186. package/dest/cmds/devnet/index.js +0 -14
  187. package/dest/cmds/l1/deploy_l1_verifier.d.ts +0 -5
  188. package/dest/cmds/l1/deploy_l1_verifier.d.ts.map +0 -1
  189. package/dest/cmds/l1/deploy_l1_verifier.js +0 -54
  190. package/dest/cmds/misc/setup_contracts.d.ts +0 -7
  191. package/dest/cmds/misc/setup_contracts.d.ts.map +0 -1
  192. package/dest/cmds/misc/setup_contracts.js +0 -27
  193. package/dest/cmds/pxe/add_contract.d.ts +0 -5
  194. package/dest/cmds/pxe/add_contract.d.ts.map +0 -1
  195. package/dest/cmds/pxe/add_contract.js +0 -29
  196. package/dest/cmds/pxe/block_number.d.ts +0 -3
  197. package/dest/cmds/pxe/block_number.d.ts.map +0 -1
  198. package/dest/cmds/pxe/block_number.js +0 -10
  199. package/dest/cmds/pxe/get_account.d.ts +0 -4
  200. package/dest/cmds/pxe/get_account.d.ts.map +0 -1
  201. package/dest/cmds/pxe/get_account.js +0 -10
  202. package/dest/cmds/pxe/get_accounts.d.ts +0 -3
  203. package/dest/cmds/pxe/get_accounts.d.ts.map +0 -1
  204. package/dest/cmds/pxe/get_accounts.js +0 -25
  205. package/dest/cmds/pxe/get_block.d.ts +0 -3
  206. package/dest/cmds/pxe/get_block.d.ts.map +0 -1
  207. package/dest/cmds/pxe/get_block.js +0 -9
  208. package/dest/cmds/pxe/get_contract_data.d.ts +0 -4
  209. package/dest/cmds/pxe/get_contract_data.d.ts.map +0 -1
  210. package/dest/cmds/pxe/get_contract_data.js +0 -31
  211. package/dest/cmds/pxe/get_current_base_fee.d.ts +0 -3
  212. package/dest/cmds/pxe/get_current_base_fee.d.ts.map +0 -1
  213. package/dest/cmds/pxe/get_current_base_fee.js +0 -7
  214. package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts +0 -4
  215. package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts.map +0 -1
  216. package/dest/cmds/pxe/get_l1_to_l2_message_witness.js +0 -11
  217. package/dest/cmds/pxe/get_logs.d.ts +0 -4
  218. package/dest/cmds/pxe/get_logs.d.ts.map +0 -1
  219. package/dest/cmds/pxe/get_node_info.d.ts +0 -3
  220. package/dest/cmds/pxe/get_node_info.d.ts.map +0 -1
  221. package/dest/cmds/pxe/get_pxe_info.d.ts +0 -3
  222. package/dest/cmds/pxe/get_pxe_info.d.ts.map +0 -1
  223. package/dest/cmds/pxe/get_pxe_info.js +0 -11
  224. package/dest/cmds/pxe/index.d.ts +0 -4
  225. package/dest/cmds/pxe/index.d.ts.map +0 -1
  226. package/dest/cmds/pxe/index.js +0 -55
  227. package/src/cmds/devnet/bootstrap_network.ts +0 -318
  228. package/src/cmds/devnet/faucet.ts +0 -33
  229. package/src/cmds/devnet/index.ts +0 -60
  230. package/src/cmds/l1/deploy_l1_verifier.ts +0 -105
  231. package/src/cmds/misc/setup_contracts.ts +0 -40
  232. package/src/cmds/pxe/add_contract.ts +0 -41
  233. package/src/cmds/pxe/block_number.ts +0 -9
  234. package/src/cmds/pxe/get_account.ts +0 -16
  235. package/src/cmds/pxe/get_accounts.ts +0 -35
  236. package/src/cmds/pxe/get_block.ts +0 -10
  237. package/src/cmds/pxe/get_contract_data.ts +0 -51
  238. package/src/cmds/pxe/get_current_base_fee.ts +0 -9
  239. package/src/cmds/pxe/get_l1_to_l2_message_witness.ts +0 -25
  240. package/src/cmds/pxe/get_pxe_info.ts +0 -13
  241. package/src/cmds/pxe/index.ts +0 -170
  242. /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
+ }
@@ -1,15 +1,25 @@
1
- import type { EthAddress, PXE } from '@aztec/aztec.js';
2
- import { type ContractArtifact, type FunctionArtifact, loadContractArtifact } from '@aztec/aztec.js/abi';
3
- import type { DeployL1ContractsReturnType, L1ContractsConfig, RollupContract } from '@aztec/ethereum';
4
- import type { Fr } from '@aztec/foundation/fields';
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 { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
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 getFunctionArtifact(artifact: ContractArtifact, fnName: string): FunctionArtifact {
23
- const fn = artifact.functions.find(({ name }) => name === fnName);
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: EthAddress[],
54
+ initialValidators: Operator[],
45
55
  genesisArchiveRoot: Fr,
46
- genesisBlockHash: Fr,
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(`${privateKey.startsWith('0x') ? '' : '0x'}${privateKey}` as `0x${string}`);
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
- return await deployL1Contracts(
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
- protocolContractTreeRoot,
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: EthAddress[],
106
+ initialValidators: Operator[],
90
107
  genesisArchiveRoot: Fr,
91
- genesisBlockHash: Fr,
108
+ feeJuicePortalInitialBalance: bigint,
92
109
  config: L1ContractsConfig,
110
+ realVerifier: boolean,
111
+ createVerificationJson: string | false,
93
112
  logger: Logger,
94
- ): Promise<{ payloadAddress: EthAddress; rollup: RollupContract }> {
95
- const { createEthereumChain, deployRollupAndPeriphery, createL1Clients } = await import('@aztec/ethereum');
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(`${privateKey.startsWith('0x') ? '' : '0x'}${privateKey}` as `0x${string}`);
120
+ : privateKeyToAccount(addLeadingHex(privateKey));
102
121
  const chain = createEthereumChain(rpcUrls, chainId);
103
- const clients = createL1Clients(rpcUrls, account, chain.chainInfo, mnemonicIndex);
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
- const { payloadAddress, rollup } = await deployRollupAndPeriphery(
106
- clients,
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
- protocolContractTreeRoot,
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 { payloadAddress, rollup };
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 = getFunctionArtifact(contractArtifact, functionName);
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
- }
@@ -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/log_id';
6
- import { TxHash } from '@aztec/aztec.js/tx_hash';
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/stdlib/interfaces/client';
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 makePxeOption = (mandatory: boolean) =>
33
- new Option('-u, --rpc-url <string>', 'URL of the PXE')
34
- .env('PXE_URL')
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 pxeOption = makePxeOption(true);
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')
@@ -114,6 +112,34 @@ export async function getTxSender(pxe: PXE, _from?: string) {
114
112
  return from;
115
113
  }
116
114
 
115
+ /**
116
+ * Parses and validates a hex string. Removes leading 0x if present, checks for hex validity,
117
+ * and enforces an optional minimum length.
118
+ * @param hex - The hex string to validate.
119
+ * @param minLen - Optional minimum length (in hex characters, after stripping '0x').
120
+ * @returns The normalized hex string (without leading 0x).
121
+ * @throws InvalidArgumentError if the string is not valid hex or does not meet the minimum length.
122
+ */
123
+ // minLen is now interpreted as the minimum number of bytes (2 hex characters per byte)
124
+ export function parseHex(hex: string, minLen?: number): `0x${string}` {
125
+ const normalized = hex.startsWith('0x') ? hex.slice(2) : hex;
126
+
127
+ if (!/^[0-9a-fA-F]*$/.test(normalized)) {
128
+ throw new InvalidArgumentError('Invalid hex string');
129
+ }
130
+
131
+ if (minLen !== undefined) {
132
+ const minHexLen = minLen * 2;
133
+ if (normalized.length < minHexLen) {
134
+ throw new InvalidArgumentError(
135
+ `Hex string is too short (length ${normalized.length}), minimum byte length is ${minLen} (hex chars: ${minHexLen})`,
136
+ );
137
+ }
138
+ }
139
+
140
+ return `0x${normalized}`;
141
+ }
142
+
117
143
  /**
118
144
  * Removes the leading 0x from a hex string. If no leading 0x is found the string is returned unchanged.
119
145
  * @param hex - A hex string
@@ -168,7 +194,7 @@ export function parseAztecAddress(address: string): AztecAddress {
168
194
  try {
169
195
  return AztecAddress.fromString(address);
170
196
  } catch {
171
- throw new InvalidArgumentError(`Invalid address: ${address}`);
197
+ throw new InvalidArgumentError(`Invalid Aztec address: ${address}`);
172
198
  }
173
199
  }
174
200
 
@@ -182,7 +208,7 @@ export function parseEthereumAddress(address: string): EthAddress {
182
208
  try {
183
209
  return EthAddress.fromString(address);
184
210
  } catch {
185
- throw new InvalidArgumentError(`Invalid address: ${address}`);
211
+ throw new InvalidArgumentError(`Invalid Ethereumaddress: ${address}`);
186
212
  }
187
213
  }
188
214
 
@@ -236,7 +262,11 @@ export function parseOptionalSelector(selector: string): FunctionSelector | unde
236
262
  * @returns The parsed integer, or undefined if the input string is falsy.
237
263
  * @throws If the input is not a valid integer.
238
264
  */
239
- export function parseOptionalInteger(value: string): number | undefined {
265
+ export function parseOptionalInteger(
266
+ value: string,
267
+ min: number = Number.MIN_SAFE_INTEGER,
268
+ max: number = Number.MAX_SAFE_INTEGER,
269
+ ): number | undefined {
240
270
  if (!value) {
241
271
  return undefined;
242
272
  }
@@ -244,6 +274,12 @@ export function parseOptionalInteger(value: string): number | undefined {
244
274
  if (!Number.isInteger(parsed)) {
245
275
  throw new InvalidArgumentError('Invalid integer.');
246
276
  }
277
+ if (parsed < min) {
278
+ throw new InvalidArgumentError(`Value must be greater than ${min}.`);
279
+ }
280
+ if (parsed > max) {
281
+ throw new InvalidArgumentError(`Value must be less than ${max}.`);
282
+ }
247
283
  return parsed;
248
284
  }
249
285
 
@@ -287,7 +323,7 @@ export function parsePublicKey(publicKey: string): PublicKeys | undefined {
287
323
  }
288
324
  try {
289
325
  return PublicKeys.fromString(publicKey);
290
- } catch (err) {
326
+ } catch {
291
327
  throw new InvalidArgumentError(`Invalid public key: ${publicKey}`);
292
328
  }
293
329
  }
@@ -301,7 +337,7 @@ export function parsePublicKey(publicKey: string): PublicKeys | undefined {
301
337
  export function parsePartialAddress(address: string): Fr {
302
338
  try {
303
339
  return Fr.fromHexString(address);
304
- } catch (err) {
340
+ } catch {
305
341
  throw new InvalidArgumentError(`Invalid partial address: ${address}`);
306
342
  }
307
343
  }
@@ -315,7 +351,7 @@ export function parsePartialAddress(address: string): Fr {
315
351
  export function parseSecretKey(secretKey: string): Fr {
316
352
  try {
317
353
  return Fr.fromHexString(secretKey);
318
- } catch (err) {
354
+ } catch {
319
355
  throw new InvalidArgumentError(`Invalid encryption secret key: ${secretKey}`);
320
356
  }
321
357
  }
@@ -348,7 +384,7 @@ export function parseField(field: string): Fr {
348
384
  }
349
385
 
350
386
  return new Fr(BigInt(field));
351
- } catch (err) {
387
+ } catch {
352
388
  throw new InvalidArgumentError(`Invalid field: ${field}`);
353
389
  }
354
390
  }
@@ -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 (err) {
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
  );
@@ -1,3 +1,2 @@
1
1
  export const GITHUB_OWNER = 'AztecProtocol';
2
2
  export const GITHUB_REPO = 'aztec-packages';
3
- export const GITHUB_TAG_PREFIX = 'aztec-packages';
@@ -2,3 +2,4 @@ export * from './commands.js';
2
2
  export * from './aztec.js';
3
3
  export * from './encoding.js';
4
4
  export * from './github.js';
5
+ export * from './setup_contracts.js';