Feat wallet cli integration#20
Open
roger-gan wants to merge 14 commits into
Open
Conversation
Add wallet-cli as a new external signing backend alongside Privy, following the same client/adapter/provider layering: - clients/wallet-cli.ts: subprocess transport with JSON envelope parsing, stdin password passing, SIGTERM→SIGKILL timeout escalation, stdin error handling - adapters/wallet-cli.ts: WalletCliSigner implementing Wallet + Eip712Capable - providers/wallet-cli-config.ts + external-signer-config.ts: shared config resolver base for external signers - integrations/wallet-cli/: optional build/broadcast/query chain-ops and signAndBroadcast orchestrator with mainnet safety guard - wallet-builder.ts: registry-based external signer registration - errors.ts: ExternalSignerError hierarchy, Privy retrofitted for backward-compatible instanceof checks Also removes the deprecated packages/python implementation and unused SecureKVStore credential storage (loadCredential/saveCredential). Fixes: - blockNumber now sourced from tx status (not broadcast) in confirmed result of signAndBroadcast - checkNodeVersion throws ExecutionError (unsupported_runtime) instead of NotFoundError for correct semantics
Wire the wallet_cli wallet type through the delivery layer so it is first-class alongside local_secure, raw_secret, and privy: - address-resolution: resolve wallet_cli address via WalletCliSigner - cli: selectWalletType, cmdStart, cmdAdd, cmdInspect now handle wallet_cli; --account / --cli-password options wired into main() - help text: start/add subcommand help + top-level listing - tests: 9 new tests covering start/add/inspect wallet_cli paths (explicit flags, password prompting, --password rejection, inspect redaction, help output)
User documentation: - Add wallet_cli to README, getting-started, and TS package README - New doc/how-to-add-wallet-cli-wallet.md guide BSC pre-wiring (TRON now, BSC planned): - WalletCliSigner accepts network?, getAddress() dispatches by family - WalletCliCurrentAccountData.addresses reserves evm? - wallet-builder passes ctx.network to WalletCliSigner - CLI descriptions updated to "TRON; BSC planned" Review fixes: - Issue 4: document argv trade-off in client (single-stdin consumer) - Issue 5: sign methods throw SigningError instead of plain Error - Issue 6: address-resolution reuses createAdapter (dedup privy+wallet_cli) - Issue 7: export integrations/wallet-cli subpath (tsup + package.json) - Issue 8: checkNodeVersion message clarifies it checks host runtime - Issue 10: remove stale Python cross-language comment in config.ts - Issue 11: remove deleted loadCredential/saveCredential from architecture.md - Issue 12: prettier --write across all changed files - Issue 13: add timeout + SIGKILL escalation test - Issue 14: warn on duplicate registerExternalSigner overwrite
- Extract normalizeValue/requireFields as exported pure functions - Base class delegates to them via protected field aliases - PrivyConfigResolver now extends the shared base, removing ~30 lines of duplicated normalizeValue/normalizeSource/requiredMissing helpers - Public API unchanged (resolve/isEnabled/constructor signature)
Align naming with PrivyAdapter — both implement Wallet + Eip712Capable and delegate to an external signing source. Renamed across source, tests, and docs.
…tion
Remove the encrypted local key store (SecureKVStore, local_secure wallet
type, master password, runtime_secrets.json) and replace it with a
secret-resolver that fetches external signer credentials via exec scripts
(e.g. 1Password CLI). Credentials may now be plaintext strings or
{ exec: "/path/to/script" } references resolved at adapter construction.
- Remove WalletType.LOCAL_SECURE, SecureKVStore, local-secure adapter,
secret-loader, RUNTIME_SECRETS_FILENAME, cmdInit/cmdChangePassword/
cmdSignMsg and related CLI flags (--password, --save-runtime-secrets)
- Simplify Wallet interface: drop signRaw and signMessage, keep
signTransaction (+ signTypedData via Eip712Capable)
- Make createAdapter and ExternalSignerConfigResolver.resolve async to
support exec script resolution
- Add SecretValue/SecretRef schemas to privy and wallet_cli config params
- Add --app-secret-exec / --cli-password-exec CLI flags
- Update docs, examples, and tests to match the new API
- Catch WalletError at top level in main() to print clean one-line messages instead of raw stack traces - Remove redundant "Error: " prefixes from start/add/sign catch blocks - Probe wallet-cli binary after start/add wallet_cli: in interactive mode prompt to install via npm i -g; in non-interactive mode print a warning with install instructions. Non-blocking — wallet config is saved regardless of probe result.
Move the wallet-cli availability probe to the start of the wallet_cli branch in cmdStart and cmdAdd, before prompting for wallet ID, account, or password. Previously the probe ran after the wallet was already created, so the user had already entered all credentials before learning the binary was missing. Also switch the probe from currentAccount (which needs keystore unlock) to `wallet-cli list` (no auth required), since credentials are not yet available at probe time.
If the wallet-cli binary is not found, print a concise install hint and exit before collecting credentials. A keystore password without a wallet-cli keystore is meaningless, so the flow must stop early. Removes the previous interactive auto-install flow and spawn dependency.
If the wallet-cli binary is not found, print a concise hint and exit before collecting credentials. A keystore password without a wallet-cli keystore is meaningless, so the flow must stop early. Removes the previous interactive auto-install flow and spawn dependency.
The local_secure wallet type and init command were removed in the secret-resolver refactor. Update the CI smoke test to use the equivalent raw_secret flow: start a wallet with a private key, sign typed data, and verify wallets_config.json exists.
Add shell: process.platform === 'win32' to spawn calls in WalletCliClient.run() and secret-resolver execSecret(). On Windows, spawn cannot execute .cmd shims (npm global bins) or batch scripts without a shell, causing spawn UNKNOWN errors. Unix behavior is unchanged. Also make secret-resolver tests cross-platform: generate .cmd batch files on Windows and sh scripts on Unix instead of bash-only scripts.
Windows has no executable bit — accessSync with X_OK fails for .cmd batch files, causing spawn UNKNOWN errors before the shell even runs. Use F_OK (existence check only) on Windows; keep X_OK on POSIX.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.