feat(wallet-cli): headless auto-approval + document the gas-fee slot#9612
Open
sirtimid wants to merge 6 commits into
Open
feat(wallet-cli): headless auto-approval + document the gas-fee slot#9612sirtimid wants to merge 6 commits into
sirtimid wants to merge 6 commits into
Conversation
sirtimid
added a commit
that referenced
this pull request
Jul 22, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Complete the two consumer-side pieces a wired `TransactionController` needs to process a transaction end-to-end in the daemon: - Headless auto-approval: subscribe to `ApprovalController:stateChanged` and accept every pending request via `ApprovalController:acceptRequest`, so an awaited `addRequest` (raised by a transaction/signature flow) resolves instead of hanging on the headless daemon's no-op `showApprovalRequest`. The subscription is torn down in the `createWallet` `dispose` path. - Gas-fee slot: the `gasFeeController` slot (`clientId: 'cli'`) is already wired; document it in `buildInstanceOptions` and rely on the wallet package's production-default EIP-1559 endpoint rather than re-specifying it. The auto-approval trust model is documented in `subscribeToAutoApproval` and the README: the daemon accepts every approval without a per-request prompt, so the trust boundary is its `0600` same-user Unix socket. Closes #9512 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Import `Logger` type alias in `auto-approval.ts` instead of redeclaring the inline shape, making compatibility with `wallet-factory.ts` explicit - Fix misleading catch-block comment that implied a rethrow; the error is intentionally suppressed - Clarify `subscribeToApprovalStateChanged` docstring: root cause is the missing `ControllerStateChangedEvent` in `ApprovalControllerEvents`, not dynamic string widening as in the persistence layer; add TODO pointing at the upstream fix - Add dropped-Patch[]-parameter note to `ApprovalStateChangeHandler` - Extend `runUnsubscribe` failure log to note the subscription may remain live - Replace fragile 5x Promise.resolve() flush with setImmediate pattern - Add missing startup-failure test: subscribeToAutoApproval throws means persistence listener is still cleaned up, wallet destroyed, store closed - Extend auto-approval unsubscribe test to also assert wallet.destroy ran - Add 5 s per-test timeout to the auto-approval integration test - Split dense CHANGELOG entry into lead sentence + nested security note Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sirtimid
force-pushed
the
sirtimid/wallet-cli-daemon-transaction-capable
branch
from
July 23, 2026 08:49
3bd65df to
09b4bb2
Compare
sirtimid
marked this pull request as ready for review
July 23, 2026 08:50
The feat commit dropped the TODO when it replaced the old comment, but the future work (exposing approval requests over the daemon transport for proper user confirmation) is still planned. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Keep only the ordering rationale; the rest is already in the function name and its JSDoc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Drop inline TODO that duplicated the JSDoc TODO in subscribeToApprovalStateChanged - Remove four in-test comments that restate their it() descriptions - Trim integration test comment block to only the non-obvious shouldShowRequest note Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Explanation
Makes the
@metamask/wallet-clidaemon able to process a transaction end-to-end by completing the two consumer-side pieces a wiredTransactionControllerneeds at runtime. This makes the daemon transaction-capable; the user-facingmm sendcommand is a separate follow-on.TransactionControlleris wired into@metamask/walletand its messenger delegates toGasFeeControllerandApprovalController. A send flow currently dead-ends in the daemon in two ways, both fixed here.Piece 1 — consume
GasFeeControllerThe
gasFeeControllerslot (clientId: 'cli') already exists inbuildInstanceOptions— it was added whenGasFeeControllerwas wired upstream (#9527) becauseclientIdis required. This PR finishes the consumer side:buildInstanceOptionsJSDoc slot list.EIP1559APIEndpoint(the default is already the prod URL) rather than re-specifying the string in the CLI, so the endpoint stays centrally owned.With
GasFeeControllerwired and released, a daemon-hostedWalletnow resolvesGasFeeController:fetchGasFeeEstimatesinstead of throwingA handler for ... has not been registered.Piece 2 — headless auto-approval
ApprovalController:addRequestis awaited by transaction/signature flows. The daemon'sshowApprovalRequestis a no-op (it only signals "a request needs attention"; it does not resolve anything), so with no UI the awaiting call hangs forever.subscribeToAutoApprovalsubscribes toApprovalController:stateChangedand immediately accepts every pending request viaApprovalController:acceptRequest. TheshowApprovalRequesthook stays a no-op (there is no UI); the id isn't available to that hook, so acceptance goes through the messenger instead. AninFlightguard keeps accepting idempotent across the re-entrant/rapid state changes a single flow emits, and both sync throws and async rejections from an accept are logged and swallowed so one bad request can't crash the daemon or wedge the subscription. The subscription is installed increateWalletand torn down in itsdisposepath.Security consideration — auto-approval is a conscious trust decision
Auto-approval means the daemon accepts every approval request without confirmation — transactions and signatures included. For a headless daemon this is the intended model: it is driven only by its owner's local CLI over a
0600, same-user Unix socket, so the trust boundary is the socket, not a per-request prompt. This is documented as the daemon's explicit trust model insubscribeToAutoApprovaland the README, and flagged as not "safe by default" — a scoped/opt-in policy (config flag, or accepting only specific approval types) is deferred until the user-facing send command exists.References
packages/wallet-cli/src/daemon/auto-approval.ts— the auto-approval subscription + trust model.packages/wallet-cli/src/daemon/wallet-factory.ts—buildInstanceOptionsslot docs;createWallet/teardownwiring.Related
wallet-cli: make the daemon transaction-capable — consumeGasFeeController+ headless auto-approval #9512GasFeeControllerinto default initialization #9527 (wireGasFeeControllerinto@metamask/wallet)wallet-cli: add themmsend-transaction command #9513 (themmsend command), which is additionally gated onwallet-cli: makesendCommandretry idempotency-safe before mutating RPC ships #9511Checklist
Walletintegration); 100% coverage maintained.build, packagetest,yarn lint:fix,yarn lint,changelog:validatepass.dispose) unsubscribes the auto-approval listener.🤖 Generated with Claude Code
Note
High Risk
Auto-approving every transaction and signature without user confirmation is a deliberate but security-sensitive behavior; compromise of the local Unix socket can move funds.
Overview
Adds
subscribeToAutoApproval, which listens forApprovalController:stateChangedand immediately callsApprovalController:acceptRequestfor every pending id so headless transaction/signature flows no longer hang on the no-opshowApprovalRequesthook. AninFlightguard avoids duplicate accepts across re-entrant state updates; accept failures are logged and swallowed.createWalletregisters this subscription beforewallet.init()and tears it down indispose(via sharedrunUnsubscribe), including error paths when subscribe/unsubscribe throws.Documents the daemon trust model (socket access implies fund movement; no per-request prompt) in README, CHANGELOG, and module JSDoc, and expands
buildInstanceOptionsJSDoc for the existinggasFeeControllerslot (clientId: 'cli', default gas API URL).Unit tests cover the subscription behavior; integration tests assert a real wallet resolves
addRequestwithout hanging.Reviewed by Cursor Bugbot for commit 01ac4a7. Bugbot is set up for automated code reviews on this repo. Configure here.