@aztec/cli 0.0.1-commit.5476d83 → 0.0.1-commit.9b94fc1
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.
|
@@ -5,8 +5,7 @@ import { type NetworkConfig, type NetworkNames } from '@aztec/foundation/config'
|
|
|
5
5
|
*
|
|
6
6
|
* @param networkName - The network name to fetch config for
|
|
7
7
|
* @param cacheDir - Optional cache directory for storing fetched config
|
|
8
|
-
* @returns Remote configuration for the specified network, or undefined if
|
|
9
|
-
* @throws Error if both primary and fallback URLs fail to fetch
|
|
8
|
+
* @returns Remote configuration for the specified network, or undefined if not found/error
|
|
10
9
|
*/
|
|
11
10
|
export declare function getNetworkConfig(networkName: NetworkNames, cacheDir?: string): Promise<NetworkConfig | undefined>;
|
|
12
11
|
/**
|
|
@@ -15,8 +14,6 @@ export declare function getNetworkConfig(networkName: NetworkNames, cacheDir?: s
|
|
|
15
14
|
* from the remote config, following the same pattern as enrichEnvironmentWithChainConfig().
|
|
16
15
|
*
|
|
17
16
|
* @param networkName - The network name to fetch remote config for
|
|
18
|
-
* @throws Error if network config fetch fails (network errors, parse errors, etc.)
|
|
19
|
-
* Does not throw if the network simply doesn't exist in the config - just returns without enriching
|
|
20
17
|
*/
|
|
21
18
|
export declare function enrichEnvironmentWithNetworkConfig(networkName: NetworkNames): Promise<void>;
|
|
22
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV0d29ya19jb25maWcuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb25maWcvbmV0d29ya19jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssYUFBYSxFQUEwQixLQUFLLFlBQVksRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBYXpHOzs7Ozs7O0dBT0c7QUFDSCx3QkFBc0IsZ0JBQWdCLENBQ3BDLFdBQVcsRUFBRSxZQUFZLEVBQ3pCLFFBQVEsQ0FBQyxFQUFFLE1BQU0sR0FDaEIsT0FBTyxDQUFDLGFBQWEsR0FBRyxTQUFTLENBQUMsQ0FhcEM7QUEwREQ7Ozs7OztHQU1HO0FBQ0gsd0JBQXNCLGtDQUFrQyxDQUFDLFdBQVcsRUFBRSxZQUFZLGlCQW9CakYifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network_config.d.ts","sourceRoot":"","sources":["../../src/config/network_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAA0B,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAazG
|
|
1
|
+
{"version":3,"file":"network_config.d.ts","sourceRoot":"","sources":["../../src/config/network_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAA0B,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAazG;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,YAAY,EACzB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAapC;AA0DD;;;;;;GAMG;AACH,wBAAsB,kCAAkC,CAAC,WAAW,EAAE,YAAY,iBAoBjF"}
|
|
@@ -12,32 +12,15 @@ const NETWORK_CONFIG_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour
|
|
|
12
12
|
*
|
|
13
13
|
* @param networkName - The network name to fetch config for
|
|
14
14
|
* @param cacheDir - Optional cache directory for storing fetched config
|
|
15
|
-
* @returns Remote configuration for the specified network, or undefined if
|
|
16
|
-
* @throws Error if both primary and fallback URLs fail to fetch
|
|
15
|
+
* @returns Remote configuration for the specified network, or undefined if not found/error
|
|
17
16
|
*/ export async function getNetworkConfig(networkName, cacheDir) {
|
|
18
17
|
// Try with the primary URL (env var or default)
|
|
19
18
|
const configLocation = process.env.NETWORK_CONFIG_LOCATION || DEFAULT_CONFIG_URL;
|
|
20
|
-
let primaryError;
|
|
21
|
-
let config;
|
|
22
19
|
// First try the primary config location
|
|
23
|
-
|
|
24
|
-
config = await fetchNetworkConfigFromUrl(configLocation, networkName, cacheDir);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
primaryError = error;
|
|
27
|
-
}
|
|
20
|
+
let config = await fetchNetworkConfigFromUrl(configLocation, networkName, cacheDir);
|
|
28
21
|
// If primary fails and we were using the default URL, try the fallback
|
|
29
22
|
if (!config && configLocation === DEFAULT_CONFIG_URL) {
|
|
30
|
-
|
|
31
|
-
config = await fetchNetworkConfigFromUrl(FALLBACK_CONFIG_URL, networkName, cacheDir);
|
|
32
|
-
} catch {
|
|
33
|
-
// Both failed - throw the primary error
|
|
34
|
-
if (primaryError) {
|
|
35
|
-
throw primaryError;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
} else if (primaryError) {
|
|
39
|
-
// Primary failed and no fallback to try
|
|
40
|
-
throw primaryError;
|
|
23
|
+
config = await fetchNetworkConfigFromUrl(FALLBACK_CONFIG_URL, networkName, cacheDir);
|
|
41
24
|
}
|
|
42
25
|
return config;
|
|
43
26
|
}
|
|
@@ -46,8 +29,7 @@ const NETWORK_CONFIG_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour
|
|
|
46
29
|
* @param configLocation - The URL or file path to fetch from
|
|
47
30
|
* @param networkName - The network name to fetch config for
|
|
48
31
|
* @param cacheDir - Optional cache directory for storing fetched config
|
|
49
|
-
* @returns Remote configuration for the specified network, or undefined if
|
|
50
|
-
* @throws Error if fetch/parse fails
|
|
32
|
+
* @returns Remote configuration for the specified network, or undefined if not found/error
|
|
51
33
|
*/ async function fetchNetworkConfigFromUrl(configLocation, networkName, cacheDir) {
|
|
52
34
|
let url;
|
|
53
35
|
try {
|
|
@@ -61,24 +43,28 @@ const NETWORK_CONFIG_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour
|
|
|
61
43
|
if (!url) {
|
|
62
44
|
return undefined;
|
|
63
45
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
46
|
+
try {
|
|
47
|
+
let rawConfig;
|
|
48
|
+
if (url.protocol === 'http:' || url.protocol === 'https:') {
|
|
49
|
+
rawConfig = await cachedFetch(url.href, {
|
|
50
|
+
cacheDurationMs: NETWORK_CONFIG_CACHE_DURATION_MS,
|
|
51
|
+
cacheFile: cacheDir ? join(cacheDir, networkName, 'network_config.json') : undefined
|
|
52
|
+
});
|
|
53
|
+
} else if (url.protocol === 'file:') {
|
|
54
|
+
rawConfig = JSON.parse(await readFile(url.pathname, 'utf-8'));
|
|
55
|
+
} else {
|
|
56
|
+
throw new Error('Unsupported Aztec network config protocol: ' + url.href);
|
|
57
|
+
}
|
|
58
|
+
if (!rawConfig) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const networkConfigMap = NetworkConfigMapSchema.parse(rawConfig);
|
|
62
|
+
if (networkName in networkConfigMap) {
|
|
63
|
+
return networkConfigMap[networkName];
|
|
64
|
+
} else {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
82
68
|
return undefined;
|
|
83
69
|
}
|
|
84
70
|
}
|
|
@@ -88,8 +74,6 @@ const NETWORK_CONFIG_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour
|
|
|
88
74
|
* from the remote config, following the same pattern as enrichEnvironmentWithChainConfig().
|
|
89
75
|
*
|
|
90
76
|
* @param networkName - The network name to fetch remote config for
|
|
91
|
-
* @throws Error if network config fetch fails (network errors, parse errors, etc.)
|
|
92
|
-
* Does not throw if the network simply doesn't exist in the config - just returns without enriching
|
|
93
77
|
*/ export async function enrichEnvironmentWithNetworkConfig(networkName) {
|
|
94
78
|
if (networkName === 'local') {
|
|
95
79
|
return; // No remote config for local development
|
|
@@ -97,7 +81,7 @@ const NETWORK_CONFIG_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour
|
|
|
97
81
|
const cacheDir = process.env.DATA_DIRECTORY ? join(process.env.DATA_DIRECTORY, 'cache') : undefined;
|
|
98
82
|
const networkConfig = await getNetworkConfig(networkName, cacheDir);
|
|
99
83
|
if (!networkConfig) {
|
|
100
|
-
|
|
84
|
+
throw new Error(`Failed to fetch network config for network: ${networkName}`);
|
|
101
85
|
}
|
|
102
86
|
enrichVar('BOOTSTRAP_NODES', networkConfig.bootnodes.join(','));
|
|
103
87
|
enrichVar('L1_CHAIN_ID', String(networkConfig.l1ChainId));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/cli",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.9b94fc1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./contracts": "./dest/cmds/contracts/index.js",
|
|
@@ -71,21 +71,21 @@
|
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
75
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
76
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
77
|
-
"@aztec/constants": "0.0.1-commit.
|
|
78
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
79
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
80
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
81
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
82
|
-
"@aztec/node-keystore": "0.0.1-commit.
|
|
83
|
-
"@aztec/node-lib": "0.0.1-commit.
|
|
84
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
85
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
86
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
87
|
-
"@aztec/test-wallet": "0.0.1-commit.
|
|
88
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
74
|
+
"@aztec/accounts": "0.0.1-commit.9b94fc1",
|
|
75
|
+
"@aztec/archiver": "0.0.1-commit.9b94fc1",
|
|
76
|
+
"@aztec/aztec.js": "0.0.1-commit.9b94fc1",
|
|
77
|
+
"@aztec/constants": "0.0.1-commit.9b94fc1",
|
|
78
|
+
"@aztec/entrypoints": "0.0.1-commit.9b94fc1",
|
|
79
|
+
"@aztec/ethereum": "0.0.1-commit.9b94fc1",
|
|
80
|
+
"@aztec/foundation": "0.0.1-commit.9b94fc1",
|
|
81
|
+
"@aztec/l1-artifacts": "0.0.1-commit.9b94fc1",
|
|
82
|
+
"@aztec/node-keystore": "0.0.1-commit.9b94fc1",
|
|
83
|
+
"@aztec/node-lib": "0.0.1-commit.9b94fc1",
|
|
84
|
+
"@aztec/p2p": "0.0.1-commit.9b94fc1",
|
|
85
|
+
"@aztec/protocol-contracts": "0.0.1-commit.9b94fc1",
|
|
86
|
+
"@aztec/stdlib": "0.0.1-commit.9b94fc1",
|
|
87
|
+
"@aztec/test-wallet": "0.0.1-commit.9b94fc1",
|
|
88
|
+
"@aztec/world-state": "0.0.1-commit.9b94fc1",
|
|
89
89
|
"@ethersproject/wallet": "^5.8.0",
|
|
90
90
|
"@iarna/toml": "^2.2.5",
|
|
91
91
|
"@libp2p/peer-id-factory": "^3.0.4",
|
|
@@ -99,9 +99,9 @@
|
|
|
99
99
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
|
-
"@aztec/aztec-node": "0.0.1-commit.
|
|
103
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
104
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
102
|
+
"@aztec/aztec-node": "0.0.1-commit.9b94fc1",
|
|
103
|
+
"@aztec/kv-store": "0.0.1-commit.9b94fc1",
|
|
104
|
+
"@aztec/telemetry-client": "0.0.1-commit.9b94fc1",
|
|
105
105
|
"@jest/globals": "^30.0.0",
|
|
106
106
|
"@types/jest": "^30.0.0",
|
|
107
107
|
"@types/lodash.chunk": "^4.2.9",
|
|
@@ -118,15 +118,15 @@
|
|
|
118
118
|
"typescript": "^5.3.3"
|
|
119
119
|
},
|
|
120
120
|
"peerDependencies": {
|
|
121
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
122
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
123
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
124
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
125
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
126
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
127
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.
|
|
128
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
129
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
121
|
+
"@aztec/accounts": "0.0.1-commit.9b94fc1",
|
|
122
|
+
"@aztec/bb-prover": "0.0.1-commit.9b94fc1",
|
|
123
|
+
"@aztec/ethereum": "0.0.1-commit.9b94fc1",
|
|
124
|
+
"@aztec/l1-artifacts": "0.0.1-commit.9b94fc1",
|
|
125
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.9b94fc1",
|
|
126
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.9b94fc1",
|
|
127
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.9b94fc1",
|
|
128
|
+
"@aztec/protocol-contracts": "0.0.1-commit.9b94fc1",
|
|
129
|
+
"@aztec/stdlib": "0.0.1-commit.9b94fc1"
|
|
130
130
|
},
|
|
131
131
|
"files": [
|
|
132
132
|
"dest",
|
|
@@ -17,8 +17,7 @@ const NETWORK_CONFIG_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour
|
|
|
17
17
|
*
|
|
18
18
|
* @param networkName - The network name to fetch config for
|
|
19
19
|
* @param cacheDir - Optional cache directory for storing fetched config
|
|
20
|
-
* @returns Remote configuration for the specified network, or undefined if
|
|
21
|
-
* @throws Error if both primary and fallback URLs fail to fetch
|
|
20
|
+
* @returns Remote configuration for the specified network, or undefined if not found/error
|
|
22
21
|
*/
|
|
23
22
|
export async function getNetworkConfig(
|
|
24
23
|
networkName: NetworkNames,
|
|
@@ -27,29 +26,12 @@ export async function getNetworkConfig(
|
|
|
27
26
|
// Try with the primary URL (env var or default)
|
|
28
27
|
const configLocation = process.env.NETWORK_CONFIG_LOCATION || DEFAULT_CONFIG_URL;
|
|
29
28
|
|
|
30
|
-
let primaryError: Error | undefined;
|
|
31
|
-
let config: NetworkConfig | undefined;
|
|
32
|
-
|
|
33
29
|
// First try the primary config location
|
|
34
|
-
|
|
35
|
-
config = await fetchNetworkConfigFromUrl(configLocation, networkName, cacheDir);
|
|
36
|
-
} catch (error) {
|
|
37
|
-
primaryError = error as Error;
|
|
38
|
-
}
|
|
30
|
+
let config = await fetchNetworkConfigFromUrl(configLocation, networkName, cacheDir);
|
|
39
31
|
|
|
40
32
|
// If primary fails and we were using the default URL, try the fallback
|
|
41
33
|
if (!config && configLocation === DEFAULT_CONFIG_URL) {
|
|
42
|
-
|
|
43
|
-
config = await fetchNetworkConfigFromUrl(FALLBACK_CONFIG_URL, networkName, cacheDir);
|
|
44
|
-
} catch {
|
|
45
|
-
// Both failed - throw the primary error
|
|
46
|
-
if (primaryError) {
|
|
47
|
-
throw primaryError;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
} else if (primaryError) {
|
|
51
|
-
// Primary failed and no fallback to try
|
|
52
|
-
throw primaryError;
|
|
34
|
+
config = await fetchNetworkConfigFromUrl(FALLBACK_CONFIG_URL, networkName, cacheDir);
|
|
53
35
|
}
|
|
54
36
|
|
|
55
37
|
return config;
|
|
@@ -60,8 +42,7 @@ export async function getNetworkConfig(
|
|
|
60
42
|
* @param configLocation - The URL or file path to fetch from
|
|
61
43
|
* @param networkName - The network name to fetch config for
|
|
62
44
|
* @param cacheDir - Optional cache directory for storing fetched config
|
|
63
|
-
* @returns Remote configuration for the specified network, or undefined if
|
|
64
|
-
* @throws Error if fetch/parse fails
|
|
45
|
+
* @returns Remote configuration for the specified network, or undefined if not found/error
|
|
65
46
|
*/
|
|
66
47
|
async function fetchNetworkConfigFromUrl(
|
|
67
48
|
configLocation: string,
|
|
@@ -83,27 +64,31 @@ async function fetchNetworkConfigFromUrl(
|
|
|
83
64
|
return undefined;
|
|
84
65
|
}
|
|
85
66
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
67
|
+
try {
|
|
68
|
+
let rawConfig: any;
|
|
69
|
+
|
|
70
|
+
if (url.protocol === 'http:' || url.protocol === 'https:') {
|
|
71
|
+
rawConfig = await cachedFetch(url.href, {
|
|
72
|
+
cacheDurationMs: NETWORK_CONFIG_CACHE_DURATION_MS,
|
|
73
|
+
cacheFile: cacheDir ? join(cacheDir, networkName, 'network_config.json') : undefined,
|
|
74
|
+
});
|
|
75
|
+
} else if (url.protocol === 'file:') {
|
|
76
|
+
rawConfig = JSON.parse(await readFile(url.pathname, 'utf-8'));
|
|
77
|
+
} else {
|
|
78
|
+
throw new Error('Unsupported Aztec network config protocol: ' + url.href);
|
|
79
|
+
}
|
|
98
80
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
81
|
+
if (!rawConfig) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
102
84
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
85
|
+
const networkConfigMap = NetworkConfigMapSchema.parse(rawConfig);
|
|
86
|
+
if (networkName in networkConfigMap) {
|
|
87
|
+
return networkConfigMap[networkName];
|
|
88
|
+
} else {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
} catch {
|
|
107
92
|
return undefined;
|
|
108
93
|
}
|
|
109
94
|
}
|
|
@@ -114,8 +99,6 @@ async function fetchNetworkConfigFromUrl(
|
|
|
114
99
|
* from the remote config, following the same pattern as enrichEnvironmentWithChainConfig().
|
|
115
100
|
*
|
|
116
101
|
* @param networkName - The network name to fetch remote config for
|
|
117
|
-
* @throws Error if network config fetch fails (network errors, parse errors, etc.)
|
|
118
|
-
* Does not throw if the network simply doesn't exist in the config - just returns without enriching
|
|
119
102
|
*/
|
|
120
103
|
export async function enrichEnvironmentWithNetworkConfig(networkName: NetworkNames) {
|
|
121
104
|
if (networkName === 'local') {
|
|
@@ -126,7 +109,7 @@ export async function enrichEnvironmentWithNetworkConfig(networkName: NetworkNam
|
|
|
126
109
|
const networkConfig = await getNetworkConfig(networkName, cacheDir);
|
|
127
110
|
|
|
128
111
|
if (!networkConfig) {
|
|
129
|
-
|
|
112
|
+
throw new Error(`Failed to fetch network config for network: ${networkName}`);
|
|
130
113
|
}
|
|
131
114
|
|
|
132
115
|
enrichVar('BOOTSTRAP_NODES', networkConfig.bootnodes.join(','));
|