@aztec/cli 3.0.0-nightly.20251118 → 3.0.0-nightly.20251120

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 (30) hide show
  1. package/dest/cmds/validator_keys/add.d.ts.map +1 -1
  2. package/dest/cmds/validator_keys/add.js +19 -3
  3. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -1
  4. package/dest/cmds/validator_keys/generate_bls_keypair.js +2 -1
  5. package/dest/cmds/validator_keys/index.d.ts.map +1 -1
  6. package/dest/cmds/validator_keys/index.js +4 -3
  7. package/dest/cmds/validator_keys/new.d.ts +2 -1
  8. package/dest/cmds/validator_keys/new.d.ts.map +1 -1
  9. package/dest/cmds/validator_keys/new.js +24 -26
  10. package/dest/cmds/validator_keys/shared.d.ts +2 -0
  11. package/dest/cmds/validator_keys/shared.d.ts.map +1 -1
  12. package/dest/cmds/validator_keys/shared.js +26 -8
  13. package/dest/cmds/validator_keys/staker.d.ts.map +1 -1
  14. package/dest/cmds/validator_keys/staker.js +12 -11
  15. package/dest/cmds/validator_keys/utils.d.ts +25 -0
  16. package/dest/cmds/validator_keys/utils.d.ts.map +1 -0
  17. package/dest/cmds/validator_keys/utils.js +52 -0
  18. package/dest/config/network_config.d.ts +1 -1
  19. package/dest/config/network_config.d.ts.map +1 -1
  20. package/dest/config/network_config.js +18 -4
  21. package/package.json +30 -29
  22. package/public_include_metric_prefixes.json +1 -0
  23. package/src/cmds/validator_keys/add.ts +20 -4
  24. package/src/cmds/validator_keys/generate_bls_keypair.ts +2 -1
  25. package/src/cmds/validator_keys/index.ts +33 -17
  26. package/src/cmds/validator_keys/new.ts +35 -34
  27. package/src/cmds/validator_keys/shared.ts +27 -8
  28. package/src/cmds/validator_keys/staker.ts +14 -12
  29. package/src/cmds/validator_keys/utils.ts +80 -0
  30. package/src/config/network_config.ts +25 -4
@@ -8,11 +8,12 @@ import { enrichEthAddressVar, enrichVar } from './enrich_env.js';
8
8
 
9
9
  const DEFAULT_CONFIG_URL =
10
10
  'https://raw.githubusercontent.com/AztecProtocol/networks/refs/heads/main/network_config.json';
11
+ const FALLBACK_CONFIG_URL = 'https://metadata.aztec.network/network_config.json';
11
12
  const NETWORK_CONFIG_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour
12
13
 
13
14
  /**
14
15
  * Fetches remote network configuration from GitHub with caching support.
15
- * Uses the reusable cachedFetch utility.
16
+ * Uses the reusable cachedFetch utility. Falls back to metadata.aztec.network if the default URL fails.
16
17
  *
17
18
  * @param networkName - The network name to fetch config for
18
19
  * @param cacheDir - Optional cache directory for storing fetched config
@@ -22,13 +23,33 @@ export async function getNetworkConfig(
22
23
  networkName: NetworkNames,
23
24
  cacheDir?: string,
24
25
  ): Promise<NetworkConfig | undefined> {
25
- let url: URL | undefined;
26
+ // Try with the primary URL (env var or default)
26
27
  const configLocation = process.env.NETWORK_CONFIG_LOCATION || DEFAULT_CONFIG_URL;
27
28
 
28
- if (!configLocation) {
29
- return undefined;
29
+ // First try the primary config location
30
+ let config = await fetchNetworkConfigFromUrl(configLocation, networkName, cacheDir);
31
+
32
+ // If primary fails and we were using the default URL, try the fallback
33
+ if (!config && configLocation === DEFAULT_CONFIG_URL) {
34
+ config = await fetchNetworkConfigFromUrl(FALLBACK_CONFIG_URL, networkName, cacheDir);
30
35
  }
31
36
 
37
+ return config;
38
+ }
39
+
40
+ /**
41
+ * Helper function to fetch network config from a specific URL.
42
+ * @param configLocation - The URL or file path to fetch from
43
+ * @param networkName - The network name to fetch config for
44
+ * @param cacheDir - Optional cache directory for storing fetched config
45
+ * @returns Remote configuration for the specified network, or undefined if not found/error
46
+ */
47
+ async function fetchNetworkConfigFromUrl(
48
+ configLocation: string,
49
+ networkName: NetworkNames,
50
+ cacheDir?: string,
51
+ ): Promise<NetworkConfig | undefined> {
52
+ let url: URL | undefined;
32
53
  try {
33
54
  if (configLocation.includes('://')) {
34
55
  url = new URL(configLocation);