@alchemy/cli 0.9.2 → 0.9.3
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/dist/auth-23OYLRWN.js +16 -0
- package/dist/{auth-IAM4AMBK.js → auth-KS6VPHHU.js} +2 -2
- package/dist/{chunk-75ICFV5K.js → chunk-3GBDYROJ.js} +1 -1
- package/dist/{chunk-RGVM5SNE.js → chunk-AMGGO36F.js} +1 -1
- package/dist/{chunk-SIIZGMK5.js → chunk-ANONMDDZ.js} +327 -72
- package/dist/{chunk-OVLQH6KL.js → chunk-CTTW4PA4.js} +1 -0
- package/dist/{chunk-TTWOBNJP.js → chunk-D2RUM2DD.js} +4 -4
- package/dist/{chunk-GDLPBPG3.js → chunk-GLKB4JM7.js} +1 -1
- package/dist/{chunk-L2WODD2D.js → chunk-L5E7GEUU.js} +6 -6
- package/dist/{chunk-HGFU4JCS.js → chunk-NUSUQI7X.js} +3 -3
- package/dist/{chunk-MV7O3XBG.js → chunk-PMNRIXJI.js} +1 -1
- package/dist/{chunk-P56HOTPV.js → chunk-VN5JUWHO.js} +2 -2
- package/dist/{errors-T6XE2I2L.js → errors-YPNK3AVF.js} +1 -1
- package/dist/index.js +584 -83
- package/dist/{interactive-IBR6RN74.js → interactive-KLVEYTQM.js} +7 -7
- package/dist/{onboarding-CW7XGRE4.js → onboarding-IJQ72DK7.js} +6 -6
- package/dist/{policy-prompt-4BV5AWVV.js → policy-prompt-V6W7CPAO.js} +5 -5
- package/dist/{resolve-FQ66OWT7.js → resolve-REZCFZZ7.js} +3 -3
- package/package.json +5 -8
- package/dist/auth-6BBITIOZ.js +0 -16
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
|
|
3
|
+
import {
|
|
4
|
+
registerAuth,
|
|
5
|
+
selectAppAfterAuth
|
|
6
|
+
} from "./chunk-L5E7GEUU.js";
|
|
7
|
+
import "./chunk-AMGGO36F.js";
|
|
8
|
+
import "./chunk-3GBDYROJ.js";
|
|
9
|
+
import "./chunk-ANONMDDZ.js";
|
|
10
|
+
import "./chunk-PMNRIXJI.js";
|
|
11
|
+
import "./chunk-GLKB4JM7.js";
|
|
12
|
+
import "./chunk-CTTW4PA4.js";
|
|
13
|
+
export {
|
|
14
|
+
registerAuth,
|
|
15
|
+
selectAppAfterAuth
|
|
16
|
+
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
configDir,
|
|
5
5
|
load,
|
|
6
6
|
save
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GLKB4JM7.js";
|
|
8
8
|
import {
|
|
9
9
|
CLIError,
|
|
10
10
|
ErrorCode,
|
|
@@ -29,14 +29,214 @@ import {
|
|
|
29
29
|
isLocalhost,
|
|
30
30
|
parseBaseURLOverride,
|
|
31
31
|
redactSensitiveText,
|
|
32
|
+
timeout,
|
|
32
33
|
verbose
|
|
33
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-CTTW4PA4.js";
|
|
34
35
|
|
|
35
36
|
// src/lib/resolve.ts
|
|
36
37
|
import { readFileSync as readFileSync2 } from "fs";
|
|
37
38
|
|
|
38
|
-
//
|
|
39
|
-
|
|
39
|
+
// ../../packages/sdk/dist/evm/rpc.js
|
|
40
|
+
import { createClient, http } from "viem";
|
|
41
|
+
|
|
42
|
+
// ../../packages/sdk/dist/config/index.js
|
|
43
|
+
var DEFAULT_ALCHEMY_BASE_DOMAIN = "alchemy.com";
|
|
44
|
+
function readEnv(name) {
|
|
45
|
+
if (typeof process === "undefined")
|
|
46
|
+
return void 0;
|
|
47
|
+
return process.env[name];
|
|
48
|
+
}
|
|
49
|
+
function getAlchemyBaseDomain(config = {}) {
|
|
50
|
+
return config.baseDomain ?? readEnv("ALCHEMY_BASE_DOMAIN") ?? DEFAULT_ALCHEMY_BASE_DOMAIN;
|
|
51
|
+
}
|
|
52
|
+
function getGatewayDomain(config = {}) {
|
|
53
|
+
return `g.${getAlchemyBaseDomain(config)}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ../../packages/sdk/dist/utils/network.js
|
|
57
|
+
var NETWORK_RE = /^[a-z0-9-]+$/;
|
|
58
|
+
function isSafeNetworkIdentifier(network) {
|
|
59
|
+
return NETWORK_RE.test(network);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ../../packages/sdk/dist/evm/rpc.js
|
|
63
|
+
var DEFAULT_RPC_TIMEOUT_MS = 3e4;
|
|
64
|
+
var DEFAULT_BREADCRUMB_HEADER = "alchemy-sdk";
|
|
65
|
+
var ALCHEMY_RPC_SECRET_PATTERN = /(https?:\/\/[^\s"'<>]+\/v2\/)[^\s"'<>/)]+/g;
|
|
66
|
+
var RpcApiError = class extends Error {
|
|
67
|
+
code;
|
|
68
|
+
status;
|
|
69
|
+
constructor(code, message, status) {
|
|
70
|
+
super(message);
|
|
71
|
+
this.code = code;
|
|
72
|
+
this.status = status;
|
|
73
|
+
this.name = "RpcApiError";
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
function validateNetwork(network) {
|
|
77
|
+
if (!isSafeNetworkIdentifier(network)) {
|
|
78
|
+
throw new RpcApiError(-32602, `Invalid network identifier: ${network}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function networkRpcUrl(network, apiKey, options = {}) {
|
|
82
|
+
validateNetwork(network);
|
|
83
|
+
return `https://${network}.${getGatewayDomain(options)}/v2/${apiKey}`;
|
|
84
|
+
}
|
|
85
|
+
function globalRpcUrl(apiKey, options = {}) {
|
|
86
|
+
return `https://api.${getGatewayDomain(options)}/v2/${apiKey}`;
|
|
87
|
+
}
|
|
88
|
+
async function networkRpcCall(network, apiKey, method, params, options = {}) {
|
|
89
|
+
return jsonRpcRequest(options.endpointUrl ?? networkRpcUrl(network, apiKey, options), method, params, options);
|
|
90
|
+
}
|
|
91
|
+
async function globalRpcCall(apiKey, method, params, options = {}) {
|
|
92
|
+
return jsonRpcRequest(globalRpcUrl(apiKey, options), method, params, options);
|
|
93
|
+
}
|
|
94
|
+
async function jsonRpcRequest(url, method, params, options = {}) {
|
|
95
|
+
const client = createClient({
|
|
96
|
+
name: "Alchemy JSON-RPC",
|
|
97
|
+
transport: http(url, {
|
|
98
|
+
fetchFn: createRpcFetch(options.fetchFn),
|
|
99
|
+
fetchOptions: {
|
|
100
|
+
headers: {
|
|
101
|
+
"x-alchemy-client-breadcrumb": options.breadcrumb ?? DEFAULT_BREADCRUMB_HEADER
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
retryCount: 0,
|
|
105
|
+
timeout: options.timeoutMs ?? DEFAULT_RPC_TIMEOUT_MS
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
try {
|
|
109
|
+
return await client.request({
|
|
110
|
+
method,
|
|
111
|
+
params
|
|
112
|
+
});
|
|
113
|
+
} catch (err) {
|
|
114
|
+
throw toRpcApiError(err);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function toRpcApiError(err) {
|
|
118
|
+
if (err instanceof RpcApiError)
|
|
119
|
+
return err;
|
|
120
|
+
const candidate = err;
|
|
121
|
+
const httpError = parseHttpErrorDetails(candidate.details);
|
|
122
|
+
if (httpError)
|
|
123
|
+
return httpError;
|
|
124
|
+
const parsedRpcError = parseRpcErrorDetails(candidate.details);
|
|
125
|
+
if (parsedRpcError)
|
|
126
|
+
return parsedRpcError;
|
|
127
|
+
const message = cleanDetail(candidate.details) ?? safeStringValue(candidate.shortMessage) ?? safeStringValue(candidate.message) ?? "JSON-RPC request failed";
|
|
128
|
+
if (typeof candidate.status === "number") {
|
|
129
|
+
return new RpcApiError(candidate.status, message, candidate.status);
|
|
130
|
+
}
|
|
131
|
+
if (typeof candidate.code === "number") {
|
|
132
|
+
return new RpcApiError(candidate.code, message);
|
|
133
|
+
}
|
|
134
|
+
return new RpcApiError(-32e3, message);
|
|
135
|
+
}
|
|
136
|
+
function createRpcFetch(fetchFn = fetch) {
|
|
137
|
+
return async (input, init) => {
|
|
138
|
+
const resp = await fetchFn(input, init);
|
|
139
|
+
if (resp.ok)
|
|
140
|
+
return resp;
|
|
141
|
+
const text = await resp.text().catch(() => "");
|
|
142
|
+
throw new Error(`Alchemy HTTP ${resp.status}: ${text || `HTTP ${resp.status}`}`);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function parseHttpErrorDetails(details) {
|
|
146
|
+
const text = cleanDetail(details);
|
|
147
|
+
const match = text?.match(/^Alchemy HTTP (\d+):\s*([\s\S]*)$/);
|
|
148
|
+
if (!match)
|
|
149
|
+
return null;
|
|
150
|
+
const status = Number(match[1]);
|
|
151
|
+
const body = match[2] || `HTTP ${status}`;
|
|
152
|
+
if (status !== 401 && status !== 403) {
|
|
153
|
+
const rpcError = parseRpcErrorDetails(body);
|
|
154
|
+
if (rpcError)
|
|
155
|
+
return rpcError;
|
|
156
|
+
}
|
|
157
|
+
return new RpcApiError(status, body, status);
|
|
158
|
+
}
|
|
159
|
+
function parseRpcErrorDetails(details) {
|
|
160
|
+
const text = cleanDetail(details);
|
|
161
|
+
if (!text)
|
|
162
|
+
return null;
|
|
163
|
+
try {
|
|
164
|
+
const parsed = JSON.parse(text);
|
|
165
|
+
const error = parsed.error ?? parsed;
|
|
166
|
+
if (typeof error.code === "number" && typeof error.message === "string") {
|
|
167
|
+
return new RpcApiError(error.code, error.message);
|
|
168
|
+
}
|
|
169
|
+
} catch {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
function cleanDetail(value) {
|
|
175
|
+
const text = safeStringValue(value);
|
|
176
|
+
if (!text)
|
|
177
|
+
return void 0;
|
|
178
|
+
try {
|
|
179
|
+
const parsed = JSON.parse(text);
|
|
180
|
+
if (typeof parsed === "string")
|
|
181
|
+
return redactRpcSecrets(parsed);
|
|
182
|
+
} catch {
|
|
183
|
+
return text;
|
|
184
|
+
}
|
|
185
|
+
return text;
|
|
186
|
+
}
|
|
187
|
+
function stringValue(value) {
|
|
188
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
189
|
+
}
|
|
190
|
+
function safeStringValue(value) {
|
|
191
|
+
const text = stringValue(value);
|
|
192
|
+
return text ? redactRpcSecrets(text) : void 0;
|
|
193
|
+
}
|
|
194
|
+
function redactRpcSecrets(value) {
|
|
195
|
+
return value.replace(ALCHEMY_RPC_SECRET_PATTERN, "$1[REDACTED]");
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// ../../packages/sdk/dist/networks/index.js
|
|
199
|
+
import * as viemChains from "viem/chains";
|
|
200
|
+
var TESTNET_SUFFIXES = [
|
|
201
|
+
"testnet",
|
|
202
|
+
"sepolia",
|
|
203
|
+
"holesky",
|
|
204
|
+
"hoodi",
|
|
205
|
+
"devnet",
|
|
206
|
+
"minato",
|
|
207
|
+
"amoy",
|
|
208
|
+
"fuji",
|
|
209
|
+
"saigon",
|
|
210
|
+
"cardona",
|
|
211
|
+
"aeneid",
|
|
212
|
+
"curtis",
|
|
213
|
+
"chiado",
|
|
214
|
+
"cassiopeia",
|
|
215
|
+
"blaze",
|
|
216
|
+
"ropsten",
|
|
217
|
+
"signet",
|
|
218
|
+
"mocha",
|
|
219
|
+
"fam",
|
|
220
|
+
"bepolia"
|
|
221
|
+
];
|
|
222
|
+
var NATIVE_SYMBOL_NETWORK_SUFFIXES = [
|
|
223
|
+
"mainnet",
|
|
224
|
+
"testnet",
|
|
225
|
+
"sepolia",
|
|
226
|
+
"holesky",
|
|
227
|
+
"hoodi",
|
|
228
|
+
"devnet",
|
|
229
|
+
"amoy",
|
|
230
|
+
"fuji",
|
|
231
|
+
"cardona",
|
|
232
|
+
"saigon",
|
|
233
|
+
"chiado",
|
|
234
|
+
"signet",
|
|
235
|
+
"mocha",
|
|
236
|
+
"blaze",
|
|
237
|
+
"curtis",
|
|
238
|
+
"bepolia"
|
|
239
|
+
];
|
|
40
240
|
var FAMILY_ALIASES = {
|
|
41
241
|
arb: "Arbitrum",
|
|
42
242
|
arbnova: "Arbitrum Nova",
|
|
@@ -225,40 +425,48 @@ var RPC_NETWORK_IDS = [
|
|
|
225
425
|
"zora-mainnet",
|
|
226
426
|
"zora-sepolia"
|
|
227
427
|
];
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
428
|
+
var WALLET_NETWORK_TO_CHAIN = {
|
|
429
|
+
"eth-mainnet": viemChains.mainnet,
|
|
430
|
+
"eth-sepolia": viemChains.sepolia,
|
|
431
|
+
"eth-holesky": viemChains.holesky,
|
|
432
|
+
"base-mainnet": viemChains.base,
|
|
433
|
+
"base-sepolia": viemChains.baseSepolia,
|
|
434
|
+
"arb-mainnet": viemChains.arbitrum,
|
|
435
|
+
"arb-sepolia": viemChains.arbitrumSepolia,
|
|
436
|
+
"opt-mainnet": viemChains.optimism,
|
|
437
|
+
"opt-sepolia": viemChains.optimismSepolia,
|
|
438
|
+
"polygon-mainnet": viemChains.polygon,
|
|
439
|
+
"polygon-amoy": viemChains.polygonAmoy,
|
|
440
|
+
"zksync-mainnet": viemChains.zksync,
|
|
441
|
+
"zksync-sepolia": viemChains.zksyncSepoliaTestnet,
|
|
442
|
+
"avax-mainnet": viemChains.avalanche,
|
|
443
|
+
"avax-fuji": viemChains.avalancheFuji,
|
|
444
|
+
"bnb-mainnet": viemChains.bsc,
|
|
445
|
+
"bnb-testnet": viemChains.bscTestnet,
|
|
446
|
+
"linea-mainnet": viemChains.linea,
|
|
447
|
+
"linea-sepolia": viemChains.lineaSepolia,
|
|
448
|
+
"scroll-mainnet": viemChains.scroll,
|
|
449
|
+
"scroll-sepolia": viemChains.scrollSepolia,
|
|
450
|
+
"blast-mainnet": viemChains.blast,
|
|
451
|
+
"blast-sepolia": viemChains.blastSepolia,
|
|
452
|
+
"zora-mainnet": viemChains.zora,
|
|
453
|
+
"zora-sepolia": viemChains.zoraSepolia,
|
|
454
|
+
"celo-mainnet": viemChains.celo,
|
|
455
|
+
"gnosis-mainnet": viemChains.gnosis,
|
|
456
|
+
"mantle-mainnet": viemChains.mantle,
|
|
457
|
+
"worldchain-mainnet": viemChains.worldchain,
|
|
458
|
+
"shape-mainnet": viemChains.shape,
|
|
459
|
+
"unichain-mainnet": viemChains.unichain,
|
|
460
|
+
"unichain-sepolia": viemChains.unichainSepolia,
|
|
461
|
+
"ink-mainnet": viemChains.ink,
|
|
462
|
+
"ink-sepolia": viemChains.inkSepolia,
|
|
463
|
+
"soneium-mainnet": viemChains.soneium,
|
|
464
|
+
"frax-mainnet": viemChains.fraxtal,
|
|
465
|
+
"mode-mainnet": viemChains.mode,
|
|
466
|
+
"monad-mainnet": viemChains.monad,
|
|
467
|
+
"monad-testnet": viemChains.monadTestnet,
|
|
468
|
+
"berachain-mainnet": viemChains.berachain
|
|
469
|
+
};
|
|
262
470
|
var NATIVE_TOKEN_SYMBOLS = {
|
|
263
471
|
eth: "ETH",
|
|
264
472
|
arb: "ETH",
|
|
@@ -286,11 +494,48 @@ var NATIVE_TOKEN_SYMBOLS = {
|
|
|
286
494
|
frax: "frxETH",
|
|
287
495
|
worldchain: "ETH",
|
|
288
496
|
berachain: "BERA",
|
|
497
|
+
monad: "MON",
|
|
289
498
|
flow: "FLOW",
|
|
290
499
|
rootstock: "RBTC",
|
|
291
500
|
zetachain: "ZETA",
|
|
292
501
|
sui: "SUI"
|
|
293
502
|
};
|
|
503
|
+
function isTestnetNetwork(id) {
|
|
504
|
+
const normalized = id.toLowerCase();
|
|
505
|
+
return TESTNET_SUFFIXES.some((suffix) => normalized.endsWith(suffix));
|
|
506
|
+
}
|
|
507
|
+
function tokenToName(token) {
|
|
508
|
+
const alias = NAME_ALIASES[token];
|
|
509
|
+
if (alias)
|
|
510
|
+
return alias;
|
|
511
|
+
return token.charAt(0).toUpperCase() + token.slice(1);
|
|
512
|
+
}
|
|
513
|
+
function toFamily(id) {
|
|
514
|
+
const [head] = id.split("-");
|
|
515
|
+
return FAMILY_ALIASES[head] ?? tokenToName(head);
|
|
516
|
+
}
|
|
517
|
+
function toDisplayName(id) {
|
|
518
|
+
return id.split("-").map((part) => tokenToName(part)).join(" ");
|
|
519
|
+
}
|
|
520
|
+
function toHttpsUrlTemplate(id, options = {}) {
|
|
521
|
+
const domain = getAlchemyBaseDomain(options);
|
|
522
|
+
if (id === "starknet-mainnet" || id === "starknet-sepolia") {
|
|
523
|
+
return `https://${id}.g.${domain}/starknet/version/rpc/v0_10/{apiKey}`;
|
|
524
|
+
}
|
|
525
|
+
return `https://${id}.g.${domain}/v2/{apiKey}`;
|
|
526
|
+
}
|
|
527
|
+
function getRPCNetworks(options = {}) {
|
|
528
|
+
return RPC_NETWORK_IDS.map((id) => ({
|
|
529
|
+
id,
|
|
530
|
+
name: toDisplayName(id),
|
|
531
|
+
family: toFamily(id),
|
|
532
|
+
isTestnet: isTestnetNetwork(id),
|
|
533
|
+
httpsUrlTemplate: toHttpsUrlTemplate(id, options)
|
|
534
|
+
}));
|
|
535
|
+
}
|
|
536
|
+
function getRPCNetworkIds() {
|
|
537
|
+
return [...RPC_NETWORK_IDS];
|
|
538
|
+
}
|
|
294
539
|
function isSolanaNetwork(networkId) {
|
|
295
540
|
return networkId.startsWith("solana-");
|
|
296
541
|
}
|
|
@@ -301,9 +546,22 @@ function fromAdminNetworkId(id) {
|
|
|
301
546
|
return id.trim().toLowerCase().replace(/_/g, "-");
|
|
302
547
|
}
|
|
303
548
|
function nativeTokenSymbol(networkId) {
|
|
304
|
-
const
|
|
549
|
+
const parts = networkId.split("-");
|
|
550
|
+
const suffixIndex = parts.findIndex((part, index) => {
|
|
551
|
+
if (index === 0)
|
|
552
|
+
return false;
|
|
553
|
+
const normalized = part.toLowerCase();
|
|
554
|
+
return NATIVE_SYMBOL_NETWORK_SUFFIXES.some((suffix) => normalized.startsWith(suffix));
|
|
555
|
+
});
|
|
556
|
+
const prefix = suffixIndex === -1 ? networkId : parts.slice(0, suffixIndex).join("-");
|
|
305
557
|
return NATIVE_TOKEN_SYMBOLS[prefix] ?? "ETH";
|
|
306
558
|
}
|
|
559
|
+
function walletNetworkToChain(network) {
|
|
560
|
+
return WALLET_NETWORK_TO_CHAIN[network];
|
|
561
|
+
}
|
|
562
|
+
function supportedWalletNetworks() {
|
|
563
|
+
return Object.keys(WALLET_NETWORK_TO_CHAIN).sort();
|
|
564
|
+
}
|
|
307
565
|
|
|
308
566
|
// src/lib/client.ts
|
|
309
567
|
var Client = class _Client {
|
|
@@ -387,12 +645,6 @@ var Client = class _Client {
|
|
|
387
645
|
return fetchWithTimeout(url, init);
|
|
388
646
|
}
|
|
389
647
|
async call(method, params = []) {
|
|
390
|
-
const body = {
|
|
391
|
-
jsonrpc: "2.0",
|
|
392
|
-
method,
|
|
393
|
-
params,
|
|
394
|
-
id: 1
|
|
395
|
-
};
|
|
396
648
|
const redactedURL = redactSensitiveText(this.rpcURL());
|
|
397
649
|
this.verboseLog(`\u2192 POST ${redactedURL}`);
|
|
398
650
|
this.verboseLog(` method: ${method}`);
|
|
@@ -401,31 +653,28 @@ var Client = class _Client {
|
|
|
401
653
|
this.verboseLog(` params: ${JSON.stringify(params)}`);
|
|
402
654
|
}
|
|
403
655
|
const startTime = Date.now();
|
|
404
|
-
|
|
405
|
-
method
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
if (rpcResp.error) {
|
|
426
|
-
throw errRPC(rpcResp.error.code, rpcResp.error.message);
|
|
656
|
+
try {
|
|
657
|
+
const result = await networkRpcCall(this.network, this.apiKey, method, params, {
|
|
658
|
+
breadcrumb: "alchemy-cli",
|
|
659
|
+
endpointUrl: this.rpcURL(),
|
|
660
|
+
...timeout && { timeoutMs: timeout }
|
|
661
|
+
});
|
|
662
|
+
this.verboseLog(`\u2190 ok (${Date.now() - startTime}ms)`);
|
|
663
|
+
return result;
|
|
664
|
+
} catch (err) {
|
|
665
|
+
this.verboseLog(`\u2190 error (${Date.now() - startTime}ms)`);
|
|
666
|
+
if (err instanceof RpcApiError) {
|
|
667
|
+
if (err.status === 429) throw errRateLimited();
|
|
668
|
+
if (err.status === 401 || err.status === 403) {
|
|
669
|
+
throw this.authErrorFromResponseBody(err.message);
|
|
670
|
+
}
|
|
671
|
+
if (err.status !== void 0) {
|
|
672
|
+
throw errNetwork(`HTTP ${err.status}: ${err.message}`);
|
|
673
|
+
}
|
|
674
|
+
throw errRPC(err.code, err.message);
|
|
675
|
+
}
|
|
676
|
+
throw err;
|
|
427
677
|
}
|
|
428
|
-
return rpcResp.result;
|
|
429
678
|
}
|
|
430
679
|
async callEnhanced(path, params) {
|
|
431
680
|
const url = new URL(`${this.enhancedURL()}/${path}`);
|
|
@@ -589,13 +838,13 @@ var X402Client = class _X402Client {
|
|
|
589
838
|
return resp.json();
|
|
590
839
|
}
|
|
591
840
|
async callRest(path, options = {}) {
|
|
592
|
-
const
|
|
841
|
+
const base2 = new URL(`/${path.replace(/^\//, "")}`, this.baseURL());
|
|
593
842
|
if (options.query) {
|
|
594
843
|
for (const [k, v] of Object.entries(options.query)) {
|
|
595
|
-
if (v !== void 0 && v !== "")
|
|
844
|
+
if (v !== void 0 && v !== "") base2.searchParams.set(k, v);
|
|
596
845
|
}
|
|
597
846
|
}
|
|
598
|
-
const urlStr =
|
|
847
|
+
const urlStr = base2.toString();
|
|
599
848
|
const method = options.method ?? "GET";
|
|
600
849
|
const buildInit = (extra) => ({
|
|
601
850
|
method,
|
|
@@ -1536,12 +1785,18 @@ function resolveWalletSession() {
|
|
|
1536
1785
|
var resolveDelegatedSession = resolveWalletSession;
|
|
1537
1786
|
|
|
1538
1787
|
export {
|
|
1788
|
+
getGatewayDomain,
|
|
1789
|
+
RpcApiError,
|
|
1790
|
+
validateNetwork,
|
|
1791
|
+
globalRpcCall,
|
|
1539
1792
|
getRPCNetworks,
|
|
1540
1793
|
getRPCNetworkIds,
|
|
1541
1794
|
isSolanaNetwork,
|
|
1542
1795
|
toAdminNetworkId,
|
|
1543
1796
|
fromAdminNetworkId,
|
|
1544
1797
|
nativeTokenSymbol,
|
|
1798
|
+
walletNetworkToChain,
|
|
1799
|
+
supportedWalletNetworks,
|
|
1545
1800
|
AdminClient,
|
|
1546
1801
|
createPendingSession,
|
|
1547
1802
|
loadSession,
|
|
@@ -3,7 +3,7 @@ if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
|
|
|
3
3
|
import {
|
|
4
4
|
gasManagerClientFromFlags,
|
|
5
5
|
toAdminNetworkId
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ANONMDDZ.js";
|
|
7
7
|
import {
|
|
8
8
|
dim,
|
|
9
9
|
green,
|
|
@@ -11,16 +11,16 @@ import {
|
|
|
11
11
|
promptConfirm,
|
|
12
12
|
promptText,
|
|
13
13
|
withSpinner
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-PMNRIXJI.js";
|
|
15
15
|
import {
|
|
16
16
|
load,
|
|
17
17
|
save
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-GLKB4JM7.js";
|
|
19
19
|
import {
|
|
20
20
|
errAppRequired,
|
|
21
21
|
errInvalidArgs,
|
|
22
22
|
errLoginRequired
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-CTTW4PA4.js";
|
|
24
24
|
|
|
25
25
|
// src/lib/policy-prompt.ts
|
|
26
26
|
var CREATE_NEW_SENTINEL = "__create_new__";
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
completeLogin,
|
|
5
5
|
prepareLogin,
|
|
6
6
|
revokeToken
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-AMGGO36F.js";
|
|
8
8
|
import {
|
|
9
9
|
isInteractiveAllowed
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3GBDYROJ.js";
|
|
11
11
|
import {
|
|
12
12
|
AdminClient,
|
|
13
13
|
resolveAuthToken
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ANONMDDZ.js";
|
|
15
15
|
import {
|
|
16
16
|
bold,
|
|
17
17
|
brand,
|
|
@@ -20,13 +20,13 @@ import {
|
|
|
20
20
|
promptAutocomplete,
|
|
21
21
|
promptText,
|
|
22
22
|
withSpinner
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-PMNRIXJI.js";
|
|
24
24
|
import {
|
|
25
25
|
configPath,
|
|
26
26
|
load,
|
|
27
27
|
maskIf,
|
|
28
28
|
save
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-GLKB4JM7.js";
|
|
30
30
|
import {
|
|
31
31
|
CLIError,
|
|
32
32
|
ErrorCode,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
exitWithError,
|
|
35
35
|
isJSONMode,
|
|
36
36
|
printHuman
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-CTTW4PA4.js";
|
|
38
38
|
|
|
39
39
|
// src/commands/auth.ts
|
|
40
40
|
function registerAuth(program) {
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
|
|
3
3
|
import {
|
|
4
4
|
configPath
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GLKB4JM7.js";
|
|
6
6
|
import {
|
|
7
7
|
esc
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CTTW4PA4.js";
|
|
9
9
|
|
|
10
10
|
// src/lib/update-check.ts
|
|
11
11
|
import { execFileSync } from "child_process";
|
|
@@ -53,7 +53,7 @@ function semverLT(a, b) {
|
|
|
53
53
|
return false;
|
|
54
54
|
}
|
|
55
55
|
function currentVersion() {
|
|
56
|
-
return true ? "0.9.
|
|
56
|
+
return true ? "0.9.3" : "0.0.0";
|
|
57
57
|
}
|
|
58
58
|
function toUpdateStatus(latestVersion, checkedAt) {
|
|
59
59
|
const current = currentVersion();
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
|
|
3
3
|
import {
|
|
4
4
|
isInteractiveAllowed
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-3GBDYROJ.js";
|
|
6
6
|
import {
|
|
7
7
|
resolveAuthToken,
|
|
8
8
|
resolveWalletSession
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ANONMDDZ.js";
|
|
10
10
|
|
|
11
11
|
// src/lib/onboarding.ts
|
|
12
12
|
var SETUP_CAPABILITY_ORDER = [
|