@alchemy/cli 0.7.2 → 0.7.4-alpha.37
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-TA3SL4BL.js → auth-D6CT363I.js} +2 -2
- package/dist/auth-R5QHPFMA.js +16 -0
- package/dist/{chunk-LQXLZLCY.js → chunk-2OUAYCVA.js} +6 -6
- package/dist/{chunk-5LCA2B6S.js → chunk-5HYOZ773.js} +610 -483
- package/dist/{chunk-MB6REYQL.js → chunk-6UHKZ5EN.js} +3 -3
- package/dist/{chunk-RE5HSYJJ.js → chunk-AUGBYMHT.js} +1 -1
- package/dist/{chunk-DGKUBK7G.js → chunk-HR2UZ6ZU.js} +1 -1
- package/dist/{chunk-KLPWJFWP.js → chunk-MYHXAACL.js} +6 -23
- package/dist/{chunk-BAZ4NGOD.js → chunk-PX2YJ7XC.js} +1 -1
- package/dist/chunk-UYZH6GSY.js +134 -0
- package/dist/{chunk-INVT5BV6.js → chunk-WCZIVY4O.js} +1 -1
- package/dist/{errors-J6HNGXVA.js → errors-UL3W4ECQ.js} +1 -1
- package/dist/index.js +1114 -279
- package/dist/{interactive-JNTFVCUJ.js → interactive-Z2YHE6ME.js} +13 -10
- package/dist/{onboarding-WN3IMTGS.js → onboarding-Q5PBXH3M.js} +6 -6
- package/dist/{resolve-ZCR3YCHJ.js → resolve-PAQKIAX3.js} +3 -3
- package/package.json +18 -24
- package/scripts/postinstall.cjs +2 -0
- package/dist/auth-7QNYRHIK.js +0 -16
- package/dist/chunk-EZ2ZD7YO.js +0 -64
|
@@ -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-PX2YJ7XC.js";
|
|
6
6
|
import {
|
|
7
7
|
esc
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-MYHXAACL.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.7.
|
|
56
|
+
return true ? "0.7.4-alpha.37" : "0.0.0";
|
|
57
57
|
}
|
|
58
58
|
function toUpdateStatus(latestVersion, checkedAt) {
|
|
59
59
|
const current = currentVersion();
|
|
@@ -91,9 +91,6 @@ function parseBaseURLOverride(envVarName, options = {}) {
|
|
|
91
91
|
return parsed;
|
|
92
92
|
}
|
|
93
93
|
var BREADCRUMB_HEADER = "alchemy-cli";
|
|
94
|
-
function escapeRegExp(input) {
|
|
95
|
-
return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
96
|
-
}
|
|
97
94
|
async function fetchWithTimeout(url, init) {
|
|
98
95
|
try {
|
|
99
96
|
return await fetch(url, {
|
|
@@ -109,22 +106,6 @@ async function fetchWithTimeout(url, init) {
|
|
|
109
106
|
throw errNetwork(`Request timed out after ${timeout}ms`);
|
|
110
107
|
}
|
|
111
108
|
const message = err.message ?? String(err);
|
|
112
|
-
const causeMessage = err.cause?.message ?? "";
|
|
113
|
-
const causeCode = err.cause?.code ?? "";
|
|
114
|
-
const fullErrorText = `${message} ${causeMessage} ${causeCode}`;
|
|
115
|
-
if (/ENOTFOUND|EAI_AGAIN|getaddrinfo/i.test(fullErrorText)) {
|
|
116
|
-
try {
|
|
117
|
-
const hostname = new URL(url).hostname;
|
|
118
|
-
const networkSlug = hostname.replace(new RegExp(`\\.g\\.${escapeRegExp(getBaseDomain())}$`), "");
|
|
119
|
-
if (networkSlug !== hostname) {
|
|
120
|
-
throw errInvalidArgs(
|
|
121
|
-
`Unknown network '${networkSlug}'. Run 'alchemy evm network list' to see available networks.`
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
} catch (innerErr) {
|
|
125
|
-
if (innerErr instanceof CLIError) throw innerErr;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
109
|
throw errNetwork(message);
|
|
129
110
|
}
|
|
130
111
|
}
|
|
@@ -323,6 +304,7 @@ var ErrorCode = {
|
|
|
323
304
|
RATE_LIMITED: "RATE_LIMITED",
|
|
324
305
|
PAYMENT_REQUIRED: "PAYMENT_REQUIRED",
|
|
325
306
|
SETUP_REQUIRED: "SETUP_REQUIRED",
|
|
307
|
+
QUOTE_FAILED: "QUOTE_FAILED",
|
|
326
308
|
INTERNAL_ERROR: "INTERNAL_ERROR"
|
|
327
309
|
};
|
|
328
310
|
var RETRYABLE_CODES = /* @__PURE__ */ new Set([
|
|
@@ -344,6 +326,7 @@ var EXIT_CODES = {
|
|
|
344
326
|
ADMIN_API_ERROR: 8,
|
|
345
327
|
PAYMENT_REQUIRED: 9,
|
|
346
328
|
SETUP_REQUIRED: 3,
|
|
329
|
+
QUOTE_FAILED: 10,
|
|
347
330
|
INTERNAL_ERROR: 1
|
|
348
331
|
};
|
|
349
332
|
var CLIError = class extends Error {
|
|
@@ -465,8 +448,8 @@ function errAppRequired() {
|
|
|
465
448
|
function errWalletKeyRequired() {
|
|
466
449
|
return new CLIError(
|
|
467
450
|
ErrorCode.AUTH_REQUIRED,
|
|
468
|
-
"Wallet key required for x402. Set ALCHEMY_WALLET_KEY, run 'alchemy wallet connect --mode local
|
|
469
|
-
"alchemy wallet connect --mode local
|
|
451
|
+
"Wallet key required for x402. Set ALCHEMY_WALLET_KEY, run 'alchemy wallet connect --mode local', or use --wallet-key-file.",
|
|
452
|
+
"alchemy wallet connect --mode local"
|
|
470
453
|
);
|
|
471
454
|
}
|
|
472
455
|
function errSessionExpired() {
|
|
@@ -486,8 +469,8 @@ function errNoActiveSession() {
|
|
|
486
469
|
function errSolanaWalletKeyRequired() {
|
|
487
470
|
return new CLIError(
|
|
488
471
|
ErrorCode.AUTH_REQUIRED,
|
|
489
|
-
"Solana wallet key required. Set ALCHEMY_SOLANA_WALLET_KEY, run 'alchemy wallet connect --mode local
|
|
490
|
-
"alchemy wallet connect --mode local
|
|
472
|
+
"Solana wallet key required. Set ALCHEMY_SOLANA_WALLET_KEY, run 'alchemy wallet connect --mode local', or use --solana-wallet-key-file.",
|
|
473
|
+
"alchemy wallet connect --mode local"
|
|
491
474
|
);
|
|
492
475
|
}
|
|
493
476
|
function errSolanaTransactionFailed(details) {
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
|
|
3
|
+
import {
|
|
4
|
+
isInteractiveAllowed
|
|
5
|
+
} from "./chunk-AUGBYMHT.js";
|
|
6
|
+
import {
|
|
7
|
+
resolveAuthToken,
|
|
8
|
+
resolveWalletSession
|
|
9
|
+
} from "./chunk-5HYOZ773.js";
|
|
10
|
+
|
|
11
|
+
// src/lib/onboarding.ts
|
|
12
|
+
var SETUP_CAPABILITY_ORDER = [
|
|
13
|
+
"rpc_data",
|
|
14
|
+
"admin_api",
|
|
15
|
+
"notify_webhooks",
|
|
16
|
+
"wallet_signing",
|
|
17
|
+
"x402"
|
|
18
|
+
];
|
|
19
|
+
var SETUP_CAPABILITY_LABELS = {
|
|
20
|
+
rpc_data: "RPC/data",
|
|
21
|
+
admin_api: "Admin API",
|
|
22
|
+
notify_webhooks: "Notify/webhooks",
|
|
23
|
+
wallet_signing: "Wallet signing",
|
|
24
|
+
x402: "x402"
|
|
25
|
+
};
|
|
26
|
+
function hasAPIKey(cfg) {
|
|
27
|
+
return Boolean(cfg.api_key?.trim());
|
|
28
|
+
}
|
|
29
|
+
function hasAccessKeyAndApp(cfg) {
|
|
30
|
+
return Boolean(cfg.access_key?.trim() && cfg.app?.id && cfg.app.apiKey);
|
|
31
|
+
}
|
|
32
|
+
function hasX402Wallet(cfg) {
|
|
33
|
+
return cfg.x402 === true && Boolean(cfg.wallet_key_file?.trim());
|
|
34
|
+
}
|
|
35
|
+
function hasAuthToken(cfg) {
|
|
36
|
+
return resolveAuthToken(cfg) !== void 0;
|
|
37
|
+
}
|
|
38
|
+
function capabilityStatus(args) {
|
|
39
|
+
return args;
|
|
40
|
+
}
|
|
41
|
+
function getSetupCapabilities(cfg) {
|
|
42
|
+
const hasConfiguredAPIKey = hasAPIKey(cfg) || Boolean(cfg.app?.apiKey?.trim());
|
|
43
|
+
const hasAdminAuth = Boolean(cfg.access_key?.trim()) || hasAuthToken(cfg);
|
|
44
|
+
const hasNotifyAuth = Boolean(
|
|
45
|
+
cfg.webhook_api_key?.trim() || cfg.app?.webhookApiKey?.trim()
|
|
46
|
+
);
|
|
47
|
+
const hasLocalWallet = Boolean(
|
|
48
|
+
cfg.wallet_key_file?.trim() || cfg.solana_wallet_key_file?.trim()
|
|
49
|
+
);
|
|
50
|
+
const hasSessionWallet = resolveWalletSession() !== null && hasAuthToken(cfg);
|
|
51
|
+
const x402Ready = hasX402Wallet(cfg);
|
|
52
|
+
return {
|
|
53
|
+
rpc_data: capabilityStatus({
|
|
54
|
+
complete: hasConfiguredAPIKey || x402Ready,
|
|
55
|
+
satisfiedBy: hasConfiguredAPIKey ? "api_key" : x402Ready ? "x402_wallet" : null,
|
|
56
|
+
missing: hasConfiguredAPIKey || x402Ready ? [] : ["api-key or x402 wallet"],
|
|
57
|
+
nextCommands: hasConfiguredAPIKey || x402Ready ? [] : ["alchemy config set app", "alchemy config set api-key <key>"]
|
|
58
|
+
}),
|
|
59
|
+
admin_api: capabilityStatus({
|
|
60
|
+
complete: hasAdminAuth,
|
|
61
|
+
satisfiedBy: cfg.access_key?.trim() ? "access_key" : hasAuthToken(cfg) ? "auth_token" : null,
|
|
62
|
+
missing: hasAdminAuth ? [] : ["access-key or auth token"],
|
|
63
|
+
nextCommands: hasAdminAuth ? [] : ["alchemy auth", "alchemy config set access-key <key>"]
|
|
64
|
+
}),
|
|
65
|
+
notify_webhooks: capabilityStatus({
|
|
66
|
+
complete: hasNotifyAuth,
|
|
67
|
+
satisfiedBy: cfg.webhook_api_key?.trim() ? "webhook-api-key" : cfg.app?.webhookApiKey?.trim() ? "configured app webhook key" : null,
|
|
68
|
+
missing: hasNotifyAuth ? [] : ["webhook API key"],
|
|
69
|
+
nextCommands: hasNotifyAuth ? [] : ["alchemy config set webhook-api-key <key>", "alchemy config set app"]
|
|
70
|
+
}),
|
|
71
|
+
wallet_signing: capabilityStatus({
|
|
72
|
+
complete: hasLocalWallet || hasSessionWallet,
|
|
73
|
+
satisfiedBy: hasSessionWallet ? "wallet_session" : hasLocalWallet ? "local_wallet" : null,
|
|
74
|
+
missing: hasLocalWallet || hasSessionWallet ? [] : ["wallet signer"],
|
|
75
|
+
nextCommands: hasLocalWallet || hasSessionWallet ? [] : [
|
|
76
|
+
"alchemy wallet connect",
|
|
77
|
+
"alchemy wallet connect --mode local"
|
|
78
|
+
]
|
|
79
|
+
}),
|
|
80
|
+
x402: capabilityStatus({
|
|
81
|
+
complete: x402Ready,
|
|
82
|
+
satisfiedBy: x402Ready ? "x402_wallet" : null,
|
|
83
|
+
missing: x402Ready ? [] : ["x402 enabled with wallet key file"],
|
|
84
|
+
nextCommands: x402Ready ? [] : ["alchemy wallet connect --mode local && alchemy config set x402 true"]
|
|
85
|
+
})
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function getSetupMethod(cfg) {
|
|
89
|
+
if (hasAPIKey(cfg)) return "api_key";
|
|
90
|
+
if (hasAccessKeyAndApp(cfg)) return "access_key_app";
|
|
91
|
+
if (hasX402Wallet(cfg)) return "x402_wallet";
|
|
92
|
+
if (hasAuthToken(cfg)) return "auth_token";
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function isSetupComplete(cfg) {
|
|
96
|
+
return getSetupMethod(cfg) !== null;
|
|
97
|
+
}
|
|
98
|
+
function getSetupStatus(cfg) {
|
|
99
|
+
const satisfiedBy = getSetupMethod(cfg);
|
|
100
|
+
const capabilities = getSetupCapabilities(cfg);
|
|
101
|
+
if (satisfiedBy) {
|
|
102
|
+
return {
|
|
103
|
+
complete: true,
|
|
104
|
+
satisfiedBy,
|
|
105
|
+
missing: [],
|
|
106
|
+
nextCommands: [],
|
|
107
|
+
capabilities
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
complete: false,
|
|
112
|
+
satisfiedBy: null,
|
|
113
|
+
missing: ["Provide one auth path: alchemy auth OR api-key OR ALCHEMY_ACCESS_KEY+app OR SIWx wallet"],
|
|
114
|
+
nextCommands: [
|
|
115
|
+
"alchemy auth",
|
|
116
|
+
"alchemy config set app",
|
|
117
|
+
"alchemy config set access-key <key> && alchemy config set app <app-id>",
|
|
118
|
+
"alchemy wallet connect --mode local && alchemy config set x402 true"
|
|
119
|
+
],
|
|
120
|
+
capabilities
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function shouldRunOnboarding(program, cfg) {
|
|
124
|
+
return isInteractiveAllowed(program) && !isSetupComplete(cfg);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export {
|
|
128
|
+
SETUP_CAPABILITY_ORDER,
|
|
129
|
+
SETUP_CAPABILITY_LABELS,
|
|
130
|
+
getSetupMethod,
|
|
131
|
+
isSetupComplete,
|
|
132
|
+
getSetupStatus,
|
|
133
|
+
shouldRunOnboarding
|
|
134
|
+
};
|