@alchemy/cli 0.6.3-alpha.6 → 0.7.0-alpha.13
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/README.md +74 -42
- package/dist/{auth-JGON2JU6.js → auth-FQFFNNZZ.js} +2 -2
- package/dist/auth-ZME2NTXG.js +16 -0
- package/dist/{chunk-PKAN5FKD.js → chunk-A6BWLRFV.js} +5 -3
- package/dist/{chunk-A6L3WCJN.js → chunk-AFD4Y42F.js} +1 -1
- package/dist/{chunk-HSKKIATB.js → chunk-EKBSQAEG.js} +1 -1
- package/dist/{chunk-B3R6PRAL.js → chunk-HGZTGSXO.js} +66 -3
- package/dist/{chunk-HYCRHNPX.js → chunk-JMDBEC5L.js} +1 -1
- package/dist/{chunk-NT3G6BKD.js → chunk-KJ5VM7FE.js} +6 -6
- package/dist/{chunk-NSBL7TUF.js → chunk-LTR4NPUM.js} +3 -3
- package/dist/{chunk-QEDAULQ2.js → chunk-OLVYWGY6.js} +1 -1
- package/dist/{chunk-MUT4TFQ5.js → chunk-PXPURTNF.js} +4 -4
- package/dist/{errors-3CNFGAXT.js → errors-VUVL3B2E.js} +1 -1
- package/dist/index.js +93 -46
- package/dist/{interactive-OSVYTHBP.js → interactive-HKPHBHCR.js} +7 -7
- package/dist/{onboarding-EBOY4QWF.js → onboarding-LLISVTDS.js} +6 -6
- package/dist/{resolve-X7HLVLGA.js → resolve-O64VTY3W.js} +3 -3
- package/package.json +2 -6
- package/dist/auth-I5WFLU46.js +0 -16
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Alchemy CLI is a command-line tool for querying blockchain data and managing Alchemy apps/configuration.
|
|
4
4
|
It supports both human-friendly terminal output and JSON output for automation.
|
|
5
|
-
You can use API keys, access keys, or x402 wallet auth depending on the command.
|
|
5
|
+
You can use browser login, API keys, access keys, or x402 wallet auth depending on the command.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -51,7 +51,7 @@ If you run `alchemy` with no command and no auth configured, the CLI will guide
|
|
|
51
51
|
|
|
52
52
|
If you have an auth token but haven't selected an app yet, the CLI will prompt you to pick one before running any command that requires an API key. Teams with many apps can type to search by name.
|
|
53
53
|
|
|
54
|
-
If you use Notify webhooks, add webhook auth on top via `alchemy config set webhook-api-key <key>`, `--webhook-api-key
|
|
54
|
+
If you use Notify webhooks, add webhook auth on top via `alchemy config set webhook-api-key <key>`, `--webhook-api-key` on `alchemy webhook` commands, or `ALCHEMY_WEBHOOK_API_KEY`.
|
|
55
55
|
|
|
56
56
|
### Usage By Workflow
|
|
57
57
|
|
|
@@ -79,7 +79,7 @@ Have your agent run `agent-prompt` as its first step to get a complete, machine-
|
|
|
79
79
|
|
|
80
80
|
```bash
|
|
81
81
|
# Agent runs this once to learn everything the CLI can do
|
|
82
|
-
alchemy --json agent-prompt
|
|
82
|
+
alchemy --json --no-interactive agent-prompt
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
This returns a single JSON document with execution policy, preflight instructions, auth matrix, the full command tree with all arguments and options, error codes with recovery actions, and example invocations. No external docs required.
|
|
@@ -114,24 +114,21 @@ Use `alchemy help` or `alchemy help <command>` for generated command help.
|
|
|
114
114
|
|
|
115
115
|
### Wallets
|
|
116
116
|
|
|
117
|
-
`alchemy
|
|
117
|
+
`alchemy wallet` exposes a unified onchain-actions surface. The **session wallet** (Alchemy/Privy-managed, P-256 delegated signer) is the recommended flow; a **local wallet** (private key stored on disk) is supported as an alternative.
|
|
118
118
|
|
|
119
119
|
| Command | What it does | Example |
|
|
120
120
|
|---|---|---|
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
121
|
+
| `wallet connect` | Interactive: choose a session wallet (recommended) or a local wallet. For scripts, pass `--mode <session\|local>`. | `alchemy wallet connect` |
|
|
122
|
+
| `wallet connect --mode local --chain evm` | Create a new local EVM key (non-interactive). `--chain` accepts `evm`, `solana`, or `both`. | `alchemy wallet connect --mode local --chain both` |
|
|
123
|
+
| `wallet connect --mode local --import <path>` | Import an existing EVM private key from a file. | `alchemy wallet connect --mode local --import ./key.txt` |
|
|
124
|
+
| `wallet connect --mode session --instance-name <name>` | Connect a named session wallet instance. | `alchemy wallet connect --mode session --instance-name laptop` |
|
|
125
|
+
| `wallet status [--verify]` | Reports session, local EVM, local Solana, and the active signer. `--verify` reconciles the session with the backend. | `alchemy wallet status --verify` |
|
|
126
|
+
| `wallet address` | Prints addresses for every configured signer. | `alchemy wallet address` |
|
|
127
|
+
| `wallet use <session\|local>` | Selects which signer `evm send`, `evm swap`, `evm approve`, `xchain bridge`, and `evm contract call` use for EVM transactions. | `alchemy wallet use local` |
|
|
128
|
+
| `wallet disconnect` | Revokes the current session (local + backend). Clears `active_signer` if it pointed at the session. | `alchemy wallet disconnect` |
|
|
129
|
+
| `wallet qr [--type <evm\|solana>]` | Renders a configured address as a QR code. | `alchemy wallet qr --type evm` |
|
|
129
130
|
|
|
130
131
|
Per-command override: pass `--signer <session\|local>` to `evm send`, `evm approve`, `evm swap`, `xchain bridge`, or `evm contract call` to override the active signer for a single invocation.
|
|
131
|
-
| `webhooks list` | Lists Notify webhooks | `alchemy webhooks list --webhook-api-key <key>` |
|
|
132
|
-
| `webhooks create --body <json>` | Creates Notify webhook | `alchemy webhooks create --body '{...}' --webhook-api-key <key>` |
|
|
133
|
-
| `webhooks update --body <json>` | Updates Notify webhook | `alchemy webhooks update --body '{...}' --webhook-api-key <key>` |
|
|
134
|
-
| `webhooks delete <id>` | Deletes Notify webhook | `alchemy webhooks delete <id> --webhook-api-key <key>` |
|
|
135
132
|
|
|
136
133
|
### Chains
|
|
137
134
|
|
|
@@ -140,6 +137,10 @@ Per-command override: pass `--signer <session\|local>` to `evm send`, `evm appro
|
|
|
140
137
|
| `solana rpc <method> [params...]` | Calls Solana JSON-RPC methods | `alchemy solana rpc getBalance '"<pubkey>"'` |
|
|
141
138
|
| `solana das <method> [params...]` | Calls Solana DAS methods | `alchemy solana das getAssetsByOwner '{"ownerAddress":"<pubkey>"}'` |
|
|
142
139
|
| `solana network list` | Lists networks from the Solana namespace | `alchemy solana network list --search solana` |
|
|
140
|
+
| `solana send <to> <amount>` | Sends SOL to an address | `alchemy solana send <pubkey> 0.1` |
|
|
141
|
+
| `solana program accounts/account/show` | Inspects Solana program accounts and account metadata | `alchemy solana program accounts <program-id>` |
|
|
142
|
+
| `solana delegate approve/revoke` | Approves or revokes SPL token delegates | `alchemy solana delegate approve --token-account <addr> --mint <mint> --delegate <addr> --amount 1 --decimals 6` |
|
|
143
|
+
| `solana status [id]` | Checks Solana transaction or operation status | `alchemy solana status <signature>` |
|
|
143
144
|
| `xchain bridge quote/execute` | Bridges tokens across chains | `alchemy xchain bridge quote --from 0xEeee... --to 0xEeee... --amount 0.1 --to-network base-mainnet -n eth-mainnet` |
|
|
144
145
|
|
|
145
146
|
### CLI Admin
|
|
@@ -150,26 +151,34 @@ Per-command override: pass `--signer <session\|local>` to `evm send`, `evm appro
|
|
|
150
151
|
| `auth` (`auth login`) | Log in via browser (PKCE) | `alchemy auth` |
|
|
151
152
|
| `auth status` | Show current authentication status | `alchemy auth status` |
|
|
152
153
|
| `auth logout` | Clear saved authentication token | `alchemy auth logout` |
|
|
153
|
-
| `
|
|
154
|
-
| `
|
|
155
|
-
| `
|
|
156
|
-
| `
|
|
157
|
-
| `
|
|
158
|
-
| `
|
|
159
|
-
| `
|
|
160
|
-
| `
|
|
161
|
-
| `
|
|
162
|
-
| `
|
|
154
|
+
| `app list` | Lists apps (supports pagination/filtering) | `alchemy app list --all` |
|
|
155
|
+
| `app chains` | Lists Admin API chain identifiers (e.g. `ETH_MAINNET`) | `alchemy app chains` |
|
|
156
|
+
| `app get <id>` | Gets app details | `alchemy app get <app-id>` |
|
|
157
|
+
| `app create` | Creates app | `alchemy app create --name "My App" --networks eth-mainnet` |
|
|
158
|
+
| `app update <id>` | Updates app name/description | `alchemy app update <app-id> --name "New Name"` |
|
|
159
|
+
| `app delete <id>` | Deletes app | `alchemy app delete <app-id>` |
|
|
160
|
+
| `app networks <id>` | Updates app network allowlist | `alchemy app networks <app-id> --networks eth-mainnet,polygon-mainnet` |
|
|
161
|
+
| `app address-allowlist <id>` | Updates app address allowlist | `alchemy app address-allowlist <app-id> --addresses 0xabc,0xdef` |
|
|
162
|
+
| `app origin-allowlist <id>` | Updates app origin allowlist | `alchemy app origin-allowlist <app-id> --origins https://example.com` |
|
|
163
|
+
| `app ip-allowlist <id>` | Updates app IP allowlist | `alchemy app ip-allowlist <app-id> --ips 1.2.3.4,5.6.7.8` |
|
|
164
|
+
| `app configured-networks` | Lists RPC network slugs configured for an app | `alchemy app configured-networks --app-id <app-id>` |
|
|
165
|
+
| `app select [id]` | Selects the default app interactively or by ID | `alchemy app select <app-id>` |
|
|
166
|
+
| `webhook list` | Lists Notify webhooks | `alchemy webhook list --webhook-api-key <key>` |
|
|
167
|
+
| `webhook create --body <json>` | Creates Notify webhook | `alchemy webhook create --body '{...}' --webhook-api-key <key>` |
|
|
168
|
+
| `webhook update --body <json>` | Updates Notify webhook | `alchemy webhook update --body '{...}' --webhook-api-key <key>` |
|
|
169
|
+
| `webhook delete <id>` | Deletes Notify webhook | `alchemy webhook delete <id> --webhook-api-key <key>` |
|
|
170
|
+
| `webhook addresses <id>` | Gets address activity webhook addresses | `alchemy webhook addresses <id> --webhook-api-key <key>` |
|
|
171
|
+
| `webhook nft-filters <id>` | Gets NFT activity webhook filters | `alchemy webhook nft-filters <id> --webhook-api-key <key>` |
|
|
163
172
|
| `doctor` | Runs readiness checks and suggestions | `alchemy doctor` |
|
|
164
173
|
| `install mcp` | Installs Alchemy's remote MCP server config | `alchemy install mcp --client claude --dry-run` |
|
|
165
174
|
| `install skills` | Installs bundled Alchemy skills | `alchemy install skills --client cursor --dry-run` |
|
|
166
175
|
| `update-check` | Checks whether a newer CLI version is available | `alchemy update-check --json --no-interactive` |
|
|
167
|
-
| `config set ...` | Sets config values | `alchemy config set
|
|
176
|
+
| `config set ...` | Sets config values | `alchemy config set app <app-id>` |
|
|
168
177
|
| `config get <key>` | Gets one config value | `alchemy config get network` |
|
|
169
178
|
| `config list` | Lists all config values | `alchemy config list` |
|
|
170
179
|
| `config reset [key]` | Resets one or all config values | `alchemy config reset --yes` |
|
|
171
180
|
| `completions <shell>` | Generates shell completion scripts (bash/zsh/fish) | `eval "$(alchemy completions zsh)"` |
|
|
172
|
-
| `agent-prompt` | Emits complete agent/automation usage instructions | `alchemy --json agent-prompt` |
|
|
181
|
+
| `agent-prompt` | Emits complete agent/automation usage instructions | `alchemy --json --no-interactive agent-prompt` |
|
|
173
182
|
| `version` | Prints CLI version | `alchemy version` |
|
|
174
183
|
|
|
175
184
|
## Flags
|
|
@@ -183,10 +192,10 @@ These apply to all commands.
|
|
|
183
192
|
| Flag | Env var | Description |
|
|
184
193
|
|---|---|---|
|
|
185
194
|
| `--api-key <key>` | `ALCHEMY_API_KEY` | API key for blockchain query commands |
|
|
186
|
-
| `--access-key <key>` | `ALCHEMY_ACCESS_KEY` | Access key for Admin API operations |
|
|
187
195
|
| `-n, --network <network>` | `ALCHEMY_NETWORK` | Target network (default: `eth-mainnet`) |
|
|
188
196
|
| `--x402` | — | Enable x402 wallet-based gateway auth |
|
|
189
|
-
| `--wallet-key-file <path>` | — |
|
|
197
|
+
| `--wallet-key-file <path>` | — | EVM wallet private key file for x402 auth and local signing |
|
|
198
|
+
| `--solana-wallet-key-file <path>` | — | Solana wallet private key file for local signing |
|
|
190
199
|
|
|
191
200
|
#### Output & formatting
|
|
192
201
|
|
|
@@ -211,7 +220,14 @@ Additional env vars:
|
|
|
211
220
|
| Env var | Description |
|
|
212
221
|
|---|---|
|
|
213
222
|
| `ALCHEMY_CONFIG` | Custom path to config file |
|
|
214
|
-
| `
|
|
223
|
+
| `ALCHEMY_ACCESS_KEY` | Access key for Admin API operations |
|
|
224
|
+
| `ALCHEMY_WALLET_KEY` | EVM wallet private key for x402 auth and local signing |
|
|
225
|
+
| `ALCHEMY_SOLANA_WALLET_KEY` | Solana wallet private key |
|
|
226
|
+
| `ALCHEMY_ACTIVE_SIGNER` | Active EVM signer override (`session` or `local`) |
|
|
227
|
+
| `ALCHEMY_EVM_GAS_SPONSORED` | Enable EVM gas sponsorship when set to `true` |
|
|
228
|
+
| `ALCHEMY_EVM_GAS_POLICY_ID` | EVM gas sponsorship policy ID |
|
|
229
|
+
| `ALCHEMY_SOLANA_FEE_SPONSORED` | Enable Solana fee sponsorship when set to `true` |
|
|
230
|
+
| `ALCHEMY_SOLANA_FEE_POLICY_ID` | Solana fee sponsorship policy ID |
|
|
215
231
|
| `ALCHEMY_WEBHOOK_API_KEY` | Webhook API key for Notify commands |
|
|
216
232
|
|
|
217
233
|
### Command-specific flags
|
|
@@ -228,18 +244,34 @@ Additional env vars:
|
|
|
228
244
|
| `evm data price historical` | `--body <json>` (required) |
|
|
229
245
|
| `evm data portfolio *` | `--body <json>` (required per subcommand) |
|
|
230
246
|
| `evm simulate *` | `--tx <json>` or `--txs <json>` (required) |
|
|
231
|
-
| `
|
|
232
|
-
| `
|
|
233
|
-
| `
|
|
234
|
-
| `
|
|
235
|
-
| `
|
|
236
|
-
| `
|
|
237
|
-
| `
|
|
238
|
-
| `
|
|
239
|
-
| `
|
|
247
|
+
| `evm send` | `--token <address>`, `--gas-sponsored`, `--gas-policy-id <id>`, `--signer <session\|local>` |
|
|
248
|
+
| `evm contract call` | `--args <json>`, `--abi-file <path>`, `--abi <json>`, `--value <ether>`, `--gas-sponsored`, `--gas-policy-id <id>`, `--signer <session\|local>` |
|
|
249
|
+
| `evm swap quote` | `--from <token_address>`, `--to <token_address>`, `--amount <number>`, `--slippage <percent>`, `--signer <session\|local>` |
|
|
250
|
+
| `evm swap execute` | `--from <token_address>`, `--to <token_address>`, `--amount <number>`, `--slippage <percent>`, `--gas-sponsored`, `--gas-policy-id <id>`, `--signer <session\|local>` |
|
|
251
|
+
| `evm approve` | `--token-address <token_address>`, `--amount <decimal_amount>`, `--unlimited`, `--revoke`, `--reset-first`, `-y, --yes`, `--gas-sponsored`, `--gas-policy-id <id>`, `--signer <session\|local>` |
|
|
252
|
+
| `xchain bridge quote` | `--from <token_address>`, `--to <token_address>`, `--amount <number>`, `--to-network <network>`, `--slippage <percent>`, `--signer <session\|local>` |
|
|
253
|
+
| `xchain bridge execute` | `--from <token_address>`, `--to <token_address>`, `--amount <number>`, `--to-network <network>`, `--slippage <percent>`, `--gas-sponsored`, `--gas-policy-id <id>`, `--signer <session\|local>` |
|
|
254
|
+
| `wallet connect` | `--mode <session\|local>`, `--chain <evm\|solana\|both>`, `--import <path>`, `--instance-name <name>`, `--force` |
|
|
255
|
+
| `wallet status` | `--verify` |
|
|
256
|
+
| `wallet qr` | `--type <evm\|solana>`, `--solana` |
|
|
257
|
+
| `solana send` | `--fee-sponsored`, `--fee-policy-id <id>`, `--signer <local>` (session signing is not yet supported for Solana) |
|
|
258
|
+
| `solana program accounts` | `--filters <json>`, `--encoding <encoding>`, `--limit <n>` |
|
|
259
|
+
| `solana delegate approve` | `--token-account <address>`, `--mint <address>`, `--delegate <address>`, `--amount <number>`, `--decimals <n>`, `--fee-sponsored`, `--fee-policy-id <id>` |
|
|
260
|
+
| `solana delegate revoke` | `--token-account <address>`, `--fee-sponsored`, `--fee-policy-id <id>` |
|
|
261
|
+
| `webhook *` | `--webhook-api-key <key>` (or `ALCHEMY_WEBHOOK_API_KEY`, `ALCHEMY_NOTIFY_AUTH_TOKEN`, config `webhook-api-key`, or app webhook key) |
|
|
262
|
+
| `app list` | `--cursor <cursor>`, `--limit <n>`, `--all`, `--search <query>`, `--id <appId>` |
|
|
263
|
+
| `app create` | `--name <name>` (required), `--networks <networks>` (required), `--description <desc>`, `--products <products>`, `--dry-run` |
|
|
264
|
+
| `app update` | `--name <name>`, `--description <desc>`, `--dry-run` |
|
|
265
|
+
| `app delete` | `--dry-run`, `-y, --yes` |
|
|
266
|
+
| `app networks` | `--networks <networks>` (required), `--dry-run` |
|
|
267
|
+
| `app address-allowlist` | `--addresses <addrs>` (required), `--dry-run` |
|
|
268
|
+
| `app origin-allowlist` | `--origins <origins>` (required), `--dry-run` |
|
|
269
|
+
| `app ip-allowlist` | `--ips <ips>` (required), `--dry-run` |
|
|
270
|
+
| `app configured-networks` | `--app-id <id>` |
|
|
240
271
|
| `install mcp` | `--client <claude,cursor,codex,other,all>`, `--dry-run` |
|
|
241
272
|
| `install skills` | `--client <claude,cursor,codex,all>`, `--dry-run` |
|
|
242
273
|
| `evm network list` | `--mainnet-only`, `--testnet-only`, `--search <term>` |
|
|
274
|
+
| `config set` | `webhook-api-key`, `app`, `network`, `verbose`, `wallet-key-file`, `x402`, `evm-gas-sponsored`, `evm-gas-policy-id`, `solana-fee-sponsored`, `solana-fee-policy-id` |
|
|
243
275
|
| `config reset` | `-y, --yes` |
|
|
244
276
|
|
|
245
277
|
## Authentication Reference
|
|
@@ -294,8 +326,8 @@ Errors are structured JSON in JSON mode:
|
|
|
294
326
|
{
|
|
295
327
|
"error": {
|
|
296
328
|
"code": "AUTH_REQUIRED",
|
|
297
|
-
"message": "Not authenticated.
|
|
298
|
-
"hint": "alchemy
|
|
329
|
+
"message": "Not authenticated. Run 'alchemy auth' to log in, or set ALCHEMY_API_KEY.",
|
|
330
|
+
"hint": "alchemy auth"
|
|
299
331
|
}
|
|
300
332
|
}
|
|
301
333
|
```
|
|
@@ -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-KJ5VM7FE.js";
|
|
7
|
+
import "./chunk-EKBSQAEG.js";
|
|
8
|
+
import "./chunk-JMDBEC5L.js";
|
|
9
|
+
import "./chunk-A6BWLRFV.js";
|
|
10
|
+
import "./chunk-AFD4Y42F.js";
|
|
11
|
+
import "./chunk-HGZTGSXO.js";
|
|
12
|
+
import "./chunk-OLVYWGY6.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-HGZTGSXO.js";
|
|
8
8
|
import {
|
|
9
9
|
CLIError,
|
|
10
10
|
ErrorCode,
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
parseBaseURLOverride,
|
|
30
30
|
redactSensitiveText,
|
|
31
31
|
verbose
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-OLVYWGY6.js";
|
|
33
33
|
|
|
34
34
|
// src/lib/resolve.ts
|
|
35
35
|
import { readFileSync as readFileSync2 } from "fs";
|
|
@@ -875,7 +875,9 @@ var walletSessionEnvironmentSchema = z.object({
|
|
|
875
875
|
platform: z.string().min(1),
|
|
876
876
|
arch: z.string().min(1),
|
|
877
877
|
nodeVersion: z.string().min(1),
|
|
878
|
-
interactive: z.boolean()
|
|
878
|
+
interactive: z.boolean(),
|
|
879
|
+
clientInstanceId: z.string().uuid().optional(),
|
|
880
|
+
clientInstanceName: z.string().min(1).max(64).optional()
|
|
879
881
|
}).strict();
|
|
880
882
|
var walletSessionSchema = z.object({
|
|
881
883
|
sessionId: z.string().uuid(),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
|
|
3
3
|
import {
|
|
4
4
|
isRevealMode
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-OLVYWGY6.js";
|
|
6
6
|
|
|
7
7
|
// src/lib/secrets.ts
|
|
8
8
|
function maskSecret(value) {
|
|
@@ -15,6 +15,7 @@ function maskIf(value) {
|
|
|
15
15
|
|
|
16
16
|
// src/lib/config.ts
|
|
17
17
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
18
|
+
import { createHash, randomUUID } from "crypto";
|
|
18
19
|
import { homedir } from "os";
|
|
19
20
|
import { join, dirname } from "path";
|
|
20
21
|
import { z } from "zod";
|
|
@@ -51,13 +52,18 @@ var KEY_MAP = {
|
|
|
51
52
|
"delegated-wallet": "delegated_wallet",
|
|
52
53
|
delegated_wallet: "delegated_wallet",
|
|
53
54
|
"active-signer": "active_signer",
|
|
54
|
-
active_signer: "active_signer"
|
|
55
|
+
active_signer: "active_signer",
|
|
56
|
+
"wallet-client-instance-name": "wallet_client_instance_name",
|
|
57
|
+
wallet_client_instance_name: "wallet_client_instance_name"
|
|
55
58
|
};
|
|
56
59
|
var SAFE_ID_RE = /^[A-Za-z0-9:_-]{1,128}$/;
|
|
57
60
|
var SAFE_NETWORK_RE = /^[A-Za-z0-9:_-]{1,128}$/;
|
|
61
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
58
62
|
var MAX_SECRET_LEN = 512;
|
|
59
63
|
var MAX_APP_NAME_LEN = 128;
|
|
64
|
+
var MAX_WALLET_CLIENT_INSTANCE_NAME_LEN = 64;
|
|
60
65
|
var CONTROL_CHAR_RE = /[\u0000-\u001f\u007f]/;
|
|
66
|
+
var WALLET_CLIENT_INSTANCE_ID_NAMESPACE = "alchemy-cli:wallet-client-instance-name:v1";
|
|
61
67
|
var safeTextSchema = (maxLen) => z.string().min(1).max(maxLen).refine((value) => !CONTROL_CHAR_RE.test(value));
|
|
62
68
|
var appConfigSchema = z.object({
|
|
63
69
|
id: z.string().regex(SAFE_ID_RE),
|
|
@@ -87,8 +93,13 @@ var configSchema = z.object({
|
|
|
87
93
|
solana_fee_sponsored: z.boolean().optional().catch(void 0),
|
|
88
94
|
solana_fee_policy_id: safeTextSchema(MAX_SECRET_LEN).optional().catch(void 0),
|
|
89
95
|
delegated_wallet: z.boolean().optional().catch(void 0),
|
|
90
|
-
active_signer: z.enum(["session", "local"]).optional().catch(void 0)
|
|
96
|
+
active_signer: z.enum(["session", "local"]).optional().catch(void 0),
|
|
97
|
+
wallet_client_instance_id: z.string().regex(UUID_RE).optional().catch(void 0),
|
|
98
|
+
wallet_client_instance_name: z.string().transform(normalizeWhitespace).pipe(safeTextSchema(MAX_WALLET_CLIENT_INSTANCE_NAME_LEN)).optional().catch(void 0)
|
|
91
99
|
}).strip();
|
|
100
|
+
function normalizeWhitespace(value) {
|
|
101
|
+
return value.trim().replace(/\s+/g, " ");
|
|
102
|
+
}
|
|
92
103
|
function sanitizeConfig(input) {
|
|
93
104
|
const parsed = configSchema.safeParse(input);
|
|
94
105
|
if (!parsed.success) {
|
|
@@ -134,6 +145,57 @@ function save(cfg) {
|
|
|
134
145
|
mode: 384
|
|
135
146
|
});
|
|
136
147
|
}
|
|
148
|
+
function normalizeWalletClientInstanceName(value) {
|
|
149
|
+
const normalized = normalizeWhitespace(value);
|
|
150
|
+
const parsed = safeTextSchema(MAX_WALLET_CLIENT_INSTANCE_NAME_LEN).safeParse(normalized);
|
|
151
|
+
return parsed.success ? parsed.data : void 0;
|
|
152
|
+
}
|
|
153
|
+
function deriveWalletClientInstanceIdFromName(name) {
|
|
154
|
+
const normalized = normalizeWalletClientInstanceName(name);
|
|
155
|
+
if (normalized === void 0) {
|
|
156
|
+
throw new Error("Invalid wallet client instance name.");
|
|
157
|
+
}
|
|
158
|
+
const digest = createHash("sha256").update(WALLET_CLIENT_INSTANCE_ID_NAMESPACE).update("\0").update(normalized.toLowerCase()).digest();
|
|
159
|
+
const bytes = Buffer.from(digest.subarray(0, 16));
|
|
160
|
+
bytes[6] = bytes[6] & 15 | 80;
|
|
161
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
162
|
+
const hex = bytes.toString("hex");
|
|
163
|
+
return [
|
|
164
|
+
hex.slice(0, 8),
|
|
165
|
+
hex.slice(8, 12),
|
|
166
|
+
hex.slice(12, 16),
|
|
167
|
+
hex.slice(16, 20),
|
|
168
|
+
hex.slice(20, 32)
|
|
169
|
+
].join("-");
|
|
170
|
+
}
|
|
171
|
+
function getOrCreateWalletClientInstance(input = {}) {
|
|
172
|
+
const cfg = load();
|
|
173
|
+
const instanceName = input.instanceName === void 0 ? cfg.wallet_client_instance_name : normalizeWalletClientInstanceName(input.instanceName);
|
|
174
|
+
if (input.instanceName !== void 0 && instanceName === void 0) {
|
|
175
|
+
throw new Error("Invalid wallet client instance name.");
|
|
176
|
+
}
|
|
177
|
+
if (instanceName !== void 0) {
|
|
178
|
+
const walletClientInstanceId2 = deriveWalletClientInstanceIdFromName(instanceName);
|
|
179
|
+
save({
|
|
180
|
+
...cfg,
|
|
181
|
+
wallet_client_instance_id: walletClientInstanceId2,
|
|
182
|
+
wallet_client_instance_name: instanceName
|
|
183
|
+
});
|
|
184
|
+
return {
|
|
185
|
+
id: walletClientInstanceId2,
|
|
186
|
+
name: instanceName
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
if (cfg.wallet_client_instance_id) {
|
|
190
|
+
return { id: cfg.wallet_client_instance_id };
|
|
191
|
+
}
|
|
192
|
+
const walletClientInstanceId = randomUUID();
|
|
193
|
+
save({
|
|
194
|
+
...cfg,
|
|
195
|
+
wallet_client_instance_id: walletClientInstanceId
|
|
196
|
+
});
|
|
197
|
+
return { id: walletClientInstanceId };
|
|
198
|
+
}
|
|
137
199
|
function get(cfg, key) {
|
|
138
200
|
if (key === "app") {
|
|
139
201
|
if (!cfg.app) return void 0;
|
|
@@ -192,6 +254,7 @@ export {
|
|
|
192
254
|
configDir,
|
|
193
255
|
load,
|
|
194
256
|
save,
|
|
257
|
+
getOrCreateWalletClientInstance,
|
|
195
258
|
get,
|
|
196
259
|
validKeys,
|
|
197
260
|
toMap
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
completeLogin,
|
|
5
5
|
prepareLogin,
|
|
6
6
|
revokeToken
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-EKBSQAEG.js";
|
|
8
8
|
import {
|
|
9
9
|
isInteractiveAllowed
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-JMDBEC5L.js";
|
|
11
11
|
import {
|
|
12
12
|
AdminClient,
|
|
13
13
|
resolveAuthToken
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-A6BWLRFV.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-AFD4Y42F.js";
|
|
24
24
|
import {
|
|
25
25
|
configPath,
|
|
26
26
|
load,
|
|
27
27
|
maskIf,
|
|
28
28
|
save
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-HGZTGSXO.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-OLVYWGY6.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-HGZTGSXO.js";
|
|
6
6
|
import {
|
|
7
7
|
esc
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-OLVYWGY6.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.
|
|
56
|
+
return true ? "0.7.0-alpha.13" : "0.0.0";
|
|
57
57
|
}
|
|
58
58
|
function toUpdateStatus(latestVersion, checkedAt) {
|
|
59
59
|
const current = currentVersion();
|
|
@@ -388,7 +388,7 @@ function errAuthRequired() {
|
|
|
388
388
|
function errAccessKeyRequired() {
|
|
389
389
|
return new CLIError(
|
|
390
390
|
ErrorCode.ACCESS_KEY_REQUIRED,
|
|
391
|
-
"Access key required. Set ALCHEMY_ACCESS_KEY
|
|
391
|
+
"Access key required. Set ALCHEMY_ACCESS_KEY.",
|
|
392
392
|
"Get an access key: https://www.alchemy.com/docs/reference/admin-api/overview"
|
|
393
393
|
);
|
|
394
394
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
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-JMDBEC5L.js";
|
|
6
6
|
import {
|
|
7
7
|
resolveAuthToken
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-A6BWLRFV.js";
|
|
9
9
|
|
|
10
10
|
// src/lib/onboarding.ts
|
|
11
11
|
function hasAPIKey(cfg) {
|
|
@@ -43,11 +43,11 @@ function getSetupStatus(cfg) {
|
|
|
43
43
|
return {
|
|
44
44
|
complete: false,
|
|
45
45
|
satisfiedBy: null,
|
|
46
|
-
missing: ["Provide one auth path: alchemy auth OR api-key OR
|
|
46
|
+
missing: ["Provide one auth path: alchemy auth OR api-key OR ALCHEMY_ACCESS_KEY+app OR SIWx wallet"],
|
|
47
47
|
nextCommands: [
|
|
48
48
|
"alchemy auth",
|
|
49
49
|
"alchemy config set app",
|
|
50
|
-
"
|
|
50
|
+
"ALCHEMY_ACCESS_KEY=<key> alchemy config set app <app-id>",
|
|
51
51
|
"alchemy wallet connect --mode local --chain evm && alchemy config set x402 true"
|
|
52
52
|
]
|
|
53
53
|
};
|
package/dist/index.js
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
|
|
3
3
|
import {
|
|
4
4
|
registerAuth
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-KJ5VM7FE.js";
|
|
6
6
|
import {
|
|
7
7
|
openBrowser
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-EKBSQAEG.js";
|
|
9
9
|
import {
|
|
10
10
|
getSetupStatus,
|
|
11
11
|
isSetupComplete,
|
|
12
12
|
shouldRunOnboarding
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-PXPURTNF.js";
|
|
14
14
|
import {
|
|
15
15
|
isInteractiveAllowed
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JMDBEC5L.js";
|
|
17
17
|
import {
|
|
18
18
|
adminClientFromFlags,
|
|
19
19
|
clearSession,
|
|
@@ -41,12 +41,12 @@ import {
|
|
|
41
41
|
resolveX402Client,
|
|
42
42
|
saveSession,
|
|
43
43
|
updateSession
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-A6BWLRFV.js";
|
|
45
45
|
import {
|
|
46
46
|
getAvailableUpdate,
|
|
47
47
|
getUpdateStatus,
|
|
48
48
|
printUpdateNotice
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-LTR4NPUM.js";
|
|
50
50
|
import {
|
|
51
51
|
bold,
|
|
52
52
|
brand,
|
|
@@ -70,17 +70,18 @@ import {
|
|
|
70
70
|
weiToEth,
|
|
71
71
|
withSpinner,
|
|
72
72
|
yellow
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-AFD4Y42F.js";
|
|
74
74
|
import {
|
|
75
75
|
KEY_MAP,
|
|
76
76
|
configDir,
|
|
77
77
|
get,
|
|
78
|
+
getOrCreateWalletClientInstance,
|
|
78
79
|
load,
|
|
79
80
|
maskIf,
|
|
80
81
|
save,
|
|
81
82
|
toMap,
|
|
82
83
|
validKeys
|
|
83
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-HGZTGSXO.js";
|
|
84
85
|
import {
|
|
85
86
|
CLIError,
|
|
86
87
|
EXIT_CODES,
|
|
@@ -115,7 +116,7 @@ import {
|
|
|
115
116
|
setFlags,
|
|
116
117
|
setNoColor,
|
|
117
118
|
verbose
|
|
118
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-OLVYWGY6.js";
|
|
119
120
|
|
|
120
121
|
// src/index.ts
|
|
121
122
|
import { Command, Help } from "commander";
|
|
@@ -437,16 +438,6 @@ async function selectOrCreateApp(admin) {
|
|
|
437
438
|
function registerConfig(program2) {
|
|
438
439
|
const cmd = program2.command("config").description("Manage CLI configuration");
|
|
439
440
|
const setCmd = cmd.command("set").description("Set a config value");
|
|
440
|
-
setCmd.command("api-key <key>").description("Set the Alchemy API key for RPC operations").action((key) => {
|
|
441
|
-
try {
|
|
442
|
-
const cfg = load();
|
|
443
|
-
save({ ...cfg, api_key: key });
|
|
444
|
-
printHuman(`${green("\u2713")} Set api-key
|
|
445
|
-
`, { key: "api-key", status: "set" });
|
|
446
|
-
} catch (err) {
|
|
447
|
-
exitWithError(err);
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
441
|
setCmd.command("webhook-api-key <key>").description("Set the Alchemy webhook API key for Notify operations").action((key) => {
|
|
451
442
|
try {
|
|
452
443
|
const cfg = load();
|
|
@@ -638,7 +629,7 @@ function registerConfig(program2) {
|
|
|
638
629
|
printJSON(toMap(cfg));
|
|
639
630
|
return;
|
|
640
631
|
}
|
|
641
|
-
const { resolveAuthToken: resolveAuthToken2 } = await import("./resolve-
|
|
632
|
+
const { resolveAuthToken: resolveAuthToken2 } = await import("./resolve-O64VTY3W.js");
|
|
642
633
|
const validToken = resolveAuthToken2(cfg);
|
|
643
634
|
const authStatus = cfg.auth_token ? validToken ? `${green("\u2713")} authenticated${cfg.auth_token_expires_at ? ` ${dim(`(expires ${cfg.auth_token_expires_at})`)}` : ""}` : `${yellow("\u25C6")} expired${cfg.auth_token_expires_at ? ` ${dim(`(${cfg.auth_token_expires_at})`)}` : ""}` : dim("(not set) \u2014 run 'alchemy auth' to log in");
|
|
644
635
|
const pairs = [
|
|
@@ -1486,13 +1477,49 @@ function toProviderSigningBindingInput(input) {
|
|
|
1486
1477
|
};
|
|
1487
1478
|
}
|
|
1488
1479
|
async function createRemoteWalletSession(token, input) {
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1480
|
+
let data;
|
|
1481
|
+
let requestInput = input;
|
|
1482
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
1483
|
+
try {
|
|
1484
|
+
data = await request(
|
|
1485
|
+
token,
|
|
1486
|
+
"POST",
|
|
1487
|
+
"/wallet/sessions",
|
|
1488
|
+
requestInput
|
|
1489
|
+
);
|
|
1490
|
+
return unwrapAdminData(walletSessionCreateResponseSchema, data);
|
|
1491
|
+
} catch (err) {
|
|
1492
|
+
const retryInput = getClientInstanceCompatibilityRetryInput(requestInput, err);
|
|
1493
|
+
if (retryInput === void 0) {
|
|
1494
|
+
throw err;
|
|
1495
|
+
}
|
|
1496
|
+
requestInput = retryInput;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
throw new CLIError(ErrorCode.NETWORK_ERROR, "Unable to create wallet session.");
|
|
1500
|
+
}
|
|
1501
|
+
function getClientInstanceCompatibilityRetryInput(input, err) {
|
|
1502
|
+
if (input.environment.clientInstanceName !== void 0 && isUnsupportedClientInstanceMetadataError(err, "clientInstanceName")) {
|
|
1503
|
+
const { clientInstanceName: _, ...environment } = input.environment;
|
|
1504
|
+
return {
|
|
1505
|
+
...input,
|
|
1506
|
+
environment
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1509
|
+
if (input.environment.clientInstanceId !== void 0 && isUnsupportedClientInstanceMetadataError(err, "clientInstanceId")) {
|
|
1510
|
+
const { clientInstanceId: _, clientInstanceName: __, ...environment } = input.environment;
|
|
1511
|
+
return {
|
|
1512
|
+
...input,
|
|
1513
|
+
environment
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
return void 0;
|
|
1517
|
+
}
|
|
1518
|
+
function isUnsupportedClientInstanceMetadataError(err, fieldName) {
|
|
1519
|
+
if (!(err instanceof CLIError)) {
|
|
1520
|
+
return false;
|
|
1521
|
+
}
|
|
1522
|
+
return err.code === ErrorCode.NETWORK_ERROR && err.message.includes("HTTP 400") && (err.details?.includes(fieldName) ?? true);
|
|
1496
1523
|
}
|
|
1497
1524
|
async function getRemoteWalletSession(token, sessionId) {
|
|
1498
1525
|
const data = await request(
|
|
@@ -2060,11 +2087,23 @@ async function runSessionConnect(opts) {
|
|
|
2060
2087
|
clearSession();
|
|
2061
2088
|
}
|
|
2062
2089
|
const session = createPendingSession();
|
|
2090
|
+
let clientInstance;
|
|
2091
|
+
try {
|
|
2092
|
+
clientInstance = getOrCreateWalletClientInstance({
|
|
2093
|
+
instanceName: opts.instanceName
|
|
2094
|
+
});
|
|
2095
|
+
} catch {
|
|
2096
|
+
throw errInvalidArgs(
|
|
2097
|
+
"`--instance-name` must be 1-64 characters and cannot contain control characters."
|
|
2098
|
+
);
|
|
2099
|
+
}
|
|
2063
2100
|
const sessionEnvironment = {
|
|
2064
2101
|
platform: process.platform,
|
|
2065
2102
|
arch: process.arch,
|
|
2066
2103
|
nodeVersion: process.version,
|
|
2067
|
-
interactive: isInteractiveAllowed(opts.program)
|
|
2104
|
+
interactive: isInteractiveAllowed(opts.program),
|
|
2105
|
+
clientInstanceId: clientInstance.id,
|
|
2106
|
+
...clientInstance.name === void 0 ? {} : { clientInstanceName: clientInstance.name }
|
|
2068
2107
|
};
|
|
2069
2108
|
updateSession({
|
|
2070
2109
|
chainType: "evm",
|
|
@@ -2087,13 +2126,17 @@ async function runSessionConnect(opts) {
|
|
|
2087
2126
|
expiresAt: remoteSession.expiresAt ?? session.expiresAt
|
|
2088
2127
|
});
|
|
2089
2128
|
if (!isJSONMode()) {
|
|
2090
|
-
|
|
2129
|
+
const summaryPairs = [
|
|
2091
2130
|
["Session ID", remoteSession.sessionId],
|
|
2092
2131
|
["Status", "pending"],
|
|
2093
2132
|
["Approval URL", remoteSession.approvalUrl],
|
|
2094
2133
|
["Created", session.createdAt],
|
|
2095
2134
|
["Expires", remoteSession.expiresAt ?? session.expiresAt]
|
|
2096
|
-
]
|
|
2135
|
+
];
|
|
2136
|
+
if (clientInstance.name !== void 0) {
|
|
2137
|
+
summaryPairs.splice(1, 0, ["Instance", clientInstance.name]);
|
|
2138
|
+
}
|
|
2139
|
+
printKeyValue(summaryPairs);
|
|
2097
2140
|
console.log(` ${green("\u2713")} Wallet session created`);
|
|
2098
2141
|
}
|
|
2099
2142
|
if (!isJSONMode() && isInteractiveAllowed(opts.program)) {
|
|
@@ -2246,6 +2289,12 @@ async function runConnectFlow(program2, opts) {
|
|
|
2246
2289
|
} else if (opts.mode !== void 0) {
|
|
2247
2290
|
throw errInvalidArgs("`--mode` must be 'session' or 'local'.");
|
|
2248
2291
|
}
|
|
2292
|
+
if (opts.instanceName !== void 0) {
|
|
2293
|
+
if (mode2 === "local") {
|
|
2294
|
+
throw errInvalidArgs("`--instance-name` is only valid with `--mode session`.");
|
|
2295
|
+
}
|
|
2296
|
+
mode2 = "session";
|
|
2297
|
+
}
|
|
2249
2298
|
if (importPath) {
|
|
2250
2299
|
if (mode2 === "session") {
|
|
2251
2300
|
throw errInvalidArgs("`--import` is only valid with `--mode local`.");
|
|
@@ -2282,7 +2331,7 @@ async function runConnectFlow(program2, opts) {
|
|
|
2282
2331
|
mode2 = choice;
|
|
2283
2332
|
}
|
|
2284
2333
|
if (mode2 === "session") {
|
|
2285
|
-
await runSessionConnect({ program: program2, force });
|
|
2334
|
+
await runSessionConnect({ program: program2, force, instanceName: opts.instanceName });
|
|
2286
2335
|
printCrossModeHintAfterSessionConnect();
|
|
2287
2336
|
return;
|
|
2288
2337
|
}
|
|
@@ -2343,7 +2392,7 @@ async function buildSessionSnapshot(program2, verify) {
|
|
|
2343
2392
|
}
|
|
2344
2393
|
function registerWallets(program2) {
|
|
2345
2394
|
const cmd = program2.command("wallet").description("Manage wallets");
|
|
2346
|
-
cmd.command("connect").description("Connect a wallet for onchain actions (session or local)").option("--mode <mode>", "session | local").option("--chain <chain>", "For --mode local: evm | solana | both (default: both)").option("--import <path>", "For --mode local: import EVM key from file (implies --chain evm)").option("--force", "Replace the existing signer").action(async (opts) => {
|
|
2395
|
+
cmd.command("connect").description("Connect a wallet for onchain actions (session or local)").option("--mode <mode>", "session | local").option("--chain <chain>", "For --mode local: evm | solana | both (default: both)").option("--import <path>", "For --mode local: import EVM key from file (implies --chain evm)").option("--instance-name <name>", "For --mode session: name this CLI instance").option("--force", "Replace the existing signer").action(async (opts) => {
|
|
2347
2396
|
try {
|
|
2348
2397
|
await runConnectFlow(program2, opts);
|
|
2349
2398
|
} catch (err) {
|
|
@@ -4585,7 +4634,7 @@ var ERROR_RECOVERY = {
|
|
|
4585
4634
|
INVALID_API_KEY: "Check your API key and select a valid app: alchemy config set app",
|
|
4586
4635
|
NETWORK_NOT_ENABLED: "Enable the target network for your app at dashboard.alchemy.com",
|
|
4587
4636
|
INVALID_ACCESS_KEY: "Check your access key: https://dashboard.alchemy.com/",
|
|
4588
|
-
ACCESS_KEY_REQUIRED: "Set ALCHEMY_ACCESS_KEY env var
|
|
4637
|
+
ACCESS_KEY_REQUIRED: "Set ALCHEMY_ACCESS_KEY env var",
|
|
4589
4638
|
APP_REQUIRED: "Select an app: alchemy config set app <app-id>",
|
|
4590
4639
|
ADMIN_API_ERROR: "Check the error message for details; verify access key permissions",
|
|
4591
4640
|
NETWORK_ERROR: "Check internet connection and retry",
|
|
@@ -4594,7 +4643,7 @@ var ERROR_RECOVERY = {
|
|
|
4594
4643
|
NOT_FOUND: "Verify the resource identifier (address, hash, id) is correct",
|
|
4595
4644
|
RATE_LIMITED: "Wait and retry; consider upgrading your Alchemy plan",
|
|
4596
4645
|
PAYMENT_REQUIRED: "Fund your x402 wallet or switch to API key auth",
|
|
4597
|
-
SETUP_REQUIRED: "Run preflight: alchemy --json config status, then follow nextCommands",
|
|
4646
|
+
SETUP_REQUIRED: "Run preflight: alchemy --json --no-interactive config status, then follow nextCommands",
|
|
4598
4647
|
INTERNAL_ERROR: "Unexpected error; retry or report a bug"
|
|
4599
4648
|
};
|
|
4600
4649
|
function buildCommandSchema(cmd) {
|
|
@@ -4648,7 +4697,7 @@ function buildAgentPrompt(program2) {
|
|
|
4648
4697
|
"Run alchemy --json --no-interactive update-check when you need to detect available CLI upgrades"
|
|
4649
4698
|
],
|
|
4650
4699
|
preflight: {
|
|
4651
|
-
command: "alchemy --json config status",
|
|
4700
|
+
command: "alchemy --json --no-interactive config status",
|
|
4652
4701
|
description: "Check auth readiness before first command. If complete is false, follow nextCommands in the response to configure auth."
|
|
4653
4702
|
},
|
|
4654
4703
|
auth: [
|
|
@@ -4656,7 +4705,6 @@ function buildAgentPrompt(program2) {
|
|
|
4656
4705
|
method: "API key",
|
|
4657
4706
|
envVar: "ALCHEMY_API_KEY",
|
|
4658
4707
|
flag: "--api-key <key>",
|
|
4659
|
-
configKey: "api-key",
|
|
4660
4708
|
commandFamilies: [
|
|
4661
4709
|
"evm data",
|
|
4662
4710
|
"evm tx",
|
|
@@ -4676,8 +4724,7 @@ function buildAgentPrompt(program2) {
|
|
|
4676
4724
|
{
|
|
4677
4725
|
method: "Access key",
|
|
4678
4726
|
envVar: "ALCHEMY_ACCESS_KEY",
|
|
4679
|
-
flag: "
|
|
4680
|
-
configKey: "access-key",
|
|
4727
|
+
flag: "env only",
|
|
4681
4728
|
commandFamilies: ["app", "evm network"]
|
|
4682
4729
|
},
|
|
4683
4730
|
{
|
|
@@ -4736,7 +4783,7 @@ function buildAgentPrompt(program2) {
|
|
|
4736
4783
|
"alchemy --json --no-interactive config status",
|
|
4737
4784
|
"alchemy --json --no-interactive update-check",
|
|
4738
4785
|
"alchemy --json --no-interactive evm data balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --api-key $ALCHEMY_API_KEY",
|
|
4739
|
-
"alchemy --json --no-interactive app list
|
|
4786
|
+
"ALCHEMY_ACCESS_KEY=$ALCHEMY_ACCESS_KEY alchemy --json --no-interactive app list",
|
|
4740
4787
|
"alchemy --json --no-interactive evm rpc eth_blockNumber --api-key $ALCHEMY_API_KEY",
|
|
4741
4788
|
"alchemy --json --no-interactive evm network list",
|
|
4742
4789
|
"alchemy --json --no-interactive evm send 0xRecipient 0.001 -n eth-sepolia",
|
|
@@ -4793,7 +4840,7 @@ function formatAsSystemPrompt(payload) {
|
|
|
4793
4840
|
lines.push(" For RPC method signatures, parameters, and supported networks.");
|
|
4794
4841
|
lines.push("");
|
|
4795
4842
|
lines.push(
|
|
4796
|
-
"For full command tree, run: alchemy --json agent-prompt"
|
|
4843
|
+
"For full command tree, run: alchemy --json --no-interactive agent-prompt"
|
|
4797
4844
|
);
|
|
4798
4845
|
lines.push("");
|
|
4799
4846
|
return lines.join("\n");
|
|
@@ -6549,7 +6596,7 @@ Examples:
|
|
|
6549
6596
|
signer: parseSignerOpt(opts.signer)
|
|
6550
6597
|
});
|
|
6551
6598
|
} catch (err) {
|
|
6552
|
-
const { exitWithError: exitWithError2 } = await import("./errors-
|
|
6599
|
+
const { exitWithError: exitWithError2 } = await import("./errors-VUVL3B2E.js");
|
|
6553
6600
|
exitWithError2(err);
|
|
6554
6601
|
}
|
|
6555
6602
|
});
|
|
@@ -7903,7 +7950,7 @@ function resetUpdateNoticeState() {
|
|
|
7903
7950
|
}
|
|
7904
7951
|
program.name("alchemy").description(
|
|
7905
7952
|
"The Alchemy CLI lets you query blockchain data, call JSON-RPC methods, and manage your Alchemy configuration."
|
|
7906
|
-
).version("0.
|
|
7953
|
+
).version("0.7.0-alpha.13", "-v, --version", "display CLI version").option("--api-key <key>", "Alchemy API key (env: ALCHEMY_API_KEY)").option(
|
|
7907
7954
|
"-n, --network <network>",
|
|
7908
7955
|
"Target network (default: eth-mainnet) (env: ALCHEMY_NETWORK)"
|
|
7909
7956
|
).option("--x402", "Use x402 wallet-based gateway auth").option(
|
|
@@ -8090,11 +8137,11 @@ ${styledLine}`;
|
|
|
8090
8137
|
"wallet"
|
|
8091
8138
|
];
|
|
8092
8139
|
if (!skipAppPrompt.includes(cmdName) && isInteractiveAllowed(program) && !opts.apiKey && !process.env.ALCHEMY_API_KEY) {
|
|
8093
|
-
const { resolveAuthToken: resolveAuthToken2 } = await import("./resolve-
|
|
8140
|
+
const { resolveAuthToken: resolveAuthToken2 } = await import("./resolve-O64VTY3W.js");
|
|
8094
8141
|
const authToken = resolveAuthToken2(cfg);
|
|
8095
8142
|
const hasApiKey = Boolean(cfg.api_key?.trim() || cfg.app?.apiKey);
|
|
8096
8143
|
if (authToken && !hasApiKey) {
|
|
8097
|
-
const { selectAppAfterAuth } = await import("./auth-
|
|
8144
|
+
const { selectAppAfterAuth } = await import("./auth-ZME2NTXG.js");
|
|
8098
8145
|
console.log("");
|
|
8099
8146
|
console.log(` No app selected. Please select an app to continue.`);
|
|
8100
8147
|
await selectAppAfterAuth(authToken);
|
|
@@ -8125,7 +8172,7 @@ ${styledLine}`;
|
|
|
8125
8172
|
if (isInteractiveAllowed(program)) {
|
|
8126
8173
|
let latestForInteractiveStartup = null;
|
|
8127
8174
|
if (shouldRunOnboarding(program, cfg)) {
|
|
8128
|
-
const { runOnboarding } = await import("./onboarding-
|
|
8175
|
+
const { runOnboarding } = await import("./onboarding-LLISVTDS.js");
|
|
8129
8176
|
const latest = getAvailableUpdateOnce();
|
|
8130
8177
|
const completed = await runOnboarding(program, latest);
|
|
8131
8178
|
updateShownDuringInteractiveStartup = Boolean(latest);
|
|
@@ -8139,7 +8186,7 @@ ${styledLine}`;
|
|
|
8139
8186
|
latestForInteractiveStartup
|
|
8140
8187
|
);
|
|
8141
8188
|
}
|
|
8142
|
-
const { startREPL } = await import("./interactive-
|
|
8189
|
+
const { startREPL } = await import("./interactive-HKPHBHCR.js");
|
|
8143
8190
|
program.exitOverride();
|
|
8144
8191
|
program.configureOutput({
|
|
8145
8192
|
writeErr: () => {
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
|
|
3
3
|
import {
|
|
4
4
|
getSetupMethod
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-PXPURTNF.js";
|
|
6
|
+
import "./chunk-JMDBEC5L.js";
|
|
7
7
|
import {
|
|
8
8
|
getRPCNetworkIds
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-A6BWLRFV.js";
|
|
10
10
|
import {
|
|
11
11
|
getUpdateNoticeLines
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LTR4NPUM.js";
|
|
13
13
|
import {
|
|
14
14
|
bold,
|
|
15
15
|
brand,
|
|
@@ -17,18 +17,18 @@ import {
|
|
|
17
17
|
dim,
|
|
18
18
|
green,
|
|
19
19
|
setBrandedHelpSuppressed
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-AFD4Y42F.js";
|
|
21
21
|
import {
|
|
22
22
|
configDir,
|
|
23
23
|
load
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-HGZTGSXO.js";
|
|
25
25
|
import {
|
|
26
26
|
bgRgb,
|
|
27
27
|
isJSONMode,
|
|
28
28
|
noColor,
|
|
29
29
|
rgb,
|
|
30
30
|
setReplMode
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-OLVYWGY6.js";
|
|
32
32
|
|
|
33
33
|
// src/commands/interactive.ts
|
|
34
34
|
import * as readline from "readline";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
|
|
3
3
|
import {
|
|
4
4
|
getUpdateNoticeLines
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-LTR4NPUM.js";
|
|
6
6
|
import {
|
|
7
7
|
bold,
|
|
8
8
|
brand,
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
dim,
|
|
11
11
|
green,
|
|
12
12
|
promptText
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-AFD4Y42F.js";
|
|
14
14
|
import {
|
|
15
15
|
load,
|
|
16
16
|
save
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-HGZTGSXO.js";
|
|
18
|
+
import "./chunk-OLVYWGY6.js";
|
|
19
19
|
|
|
20
20
|
// src/commands/onboarding.ts
|
|
21
21
|
async function runOnboarding(_program, latestUpdate = null) {
|
|
@@ -38,7 +38,7 @@ async function runOnboarding(_program, latestUpdate = null) {
|
|
|
38
38
|
if (answer === null) {
|
|
39
39
|
return false;
|
|
40
40
|
}
|
|
41
|
-
const { performBrowserLogin, AUTH_PORT, getLoginUrl } = await import("./auth-
|
|
41
|
+
const { performBrowserLogin, AUTH_PORT, getLoginUrl } = await import("./auth-FQFFNNZZ.js");
|
|
42
42
|
console.log(` Opening browser to log in...`);
|
|
43
43
|
console.log(` ${dim(getLoginUrl(AUTH_PORT))}`);
|
|
44
44
|
console.log(` ${dim("Waiting for authentication...")}`);
|
|
@@ -51,7 +51,7 @@ async function runOnboarding(_program, latestUpdate = null) {
|
|
|
51
51
|
auth_token_expires_at: result.expiresAt
|
|
52
52
|
});
|
|
53
53
|
console.log(` ${green("\u2713")} Logged in successfully`);
|
|
54
|
-
const { selectAppAfterAuth } = await import("./auth-
|
|
54
|
+
const { selectAppAfterAuth } = await import("./auth-ZME2NTXG.js");
|
|
55
55
|
await selectAppAfterAuth(result.token);
|
|
56
56
|
return true;
|
|
57
57
|
} catch (err) {
|
|
@@ -22,9 +22,9 @@ import {
|
|
|
22
22
|
resolveWalletSession,
|
|
23
23
|
resolveX402,
|
|
24
24
|
resolveX402Client
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
25
|
+
} from "./chunk-A6BWLRFV.js";
|
|
26
|
+
import "./chunk-HGZTGSXO.js";
|
|
27
|
+
import "./chunk-OLVYWGY6.js";
|
|
28
28
|
export {
|
|
29
29
|
adminClientFromFlags,
|
|
30
30
|
clientFromFlags,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alchemy/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-alpha.13",
|
|
4
4
|
"description": "Alchemy CLI — interact with blockchain data",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,10 +17,6 @@
|
|
|
17
17
|
"README.md",
|
|
18
18
|
"scripts/postinstall.cjs"
|
|
19
19
|
],
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "https://github.com/OMGWINNING/alchemy-cli.git"
|
|
23
|
-
},
|
|
24
20
|
"publishConfig": {
|
|
25
21
|
"access": "public"
|
|
26
22
|
},
|
|
@@ -29,7 +25,7 @@
|
|
|
29
25
|
"node": ">=22"
|
|
30
26
|
},
|
|
31
27
|
"dependencies": {
|
|
32
|
-
"@alchemy/wallet-apis": "5.0.0-beta.
|
|
28
|
+
"@alchemy/wallet-apis": "5.0.0-beta.28",
|
|
33
29
|
"@alchemy/x402": "^0.4.0",
|
|
34
30
|
"@noble/hashes": "^2.0.1",
|
|
35
31
|
"@solana-program/system": "^0.12.0",
|
package/dist/auth-I5WFLU46.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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-NT3G6BKD.js";
|
|
7
|
-
import "./chunk-HSKKIATB.js";
|
|
8
|
-
import "./chunk-HYCRHNPX.js";
|
|
9
|
-
import "./chunk-PKAN5FKD.js";
|
|
10
|
-
import "./chunk-A6L3WCJN.js";
|
|
11
|
-
import "./chunk-B3R6PRAL.js";
|
|
12
|
-
import "./chunk-QEDAULQ2.js";
|
|
13
|
-
export {
|
|
14
|
-
registerAuth,
|
|
15
|
-
selectAppAfterAuth
|
|
16
|
-
};
|