refactor(wallet-cli): Replace { wallet, store } with { wallet, dispose }#8847
Draft
sirtimid wants to merge 1 commit into
Draft
refactor(wallet-cli): Replace { wallet, store } with { wallet, dispose }#8847sirtimid wants to merge 1 commit into
sirtimid wants to merge 1 commit into
Conversation
`createWallet` now returns a `dispose` callback that owns the `wallet.destroy()` → `store.close()` ordering and reports per-step failures through the supplied logger. Both daemon-entry cleanup ladders (startup-failure catch and SIGTERM/SIGINT shutdown) call `dispose` instead of inlining the order, so a future third call site or extra teardown step (e.g. SQLite WAL flush) can't drift. The disposer is idempotent across concurrent and sequential calls, closes the store even when destroy rejects, and falls back to `console.error` if no logger (or a throwing one) is supplied. The pre-resolution catch block in `createWallet` was also tightened to route through the same reporter so a `store.close()` throw can't mask the original failure (e.g. bad SRP). Closes #8779 Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
createWalletindaemon/wallet-factorynow returns{ wallet, dispose }instead of{ wallet, store }.disposeis the single owner of teardown — it runsawait wallet.destroy()thenstore.close(), with per-step failures forwarded to the supplied logger (orconsole.errorif none).daemon-entry.ts(startup-failurecatchblock + SIGTERM/SIGINTshutdownclosure) now both calldisposeinstead of inlining the order, so a future third call site or extra teardown step can't drift.wallet.destroy()rejects, and survives a throwing user-supplied logger.createWalletwas tightened to route through the same reporter, so astore.close()throw during first-run cleanup can no longer mask the original failure (e.g. bad SRP).Closes #8779. Builds on #8446 (the deferred refactor was tracked there).
Test plan
yarn workspace @metamask/wallet-cli run test— 250 passing, 100% statements/branches/funcs/lines onwallet-factory.tsanddaemon-entry.ts.yarn workspace @metamask/wallet-cli run build— clean.yarn eslint packages/wallet-cli/src— clean.yarn workspace @metamask/wallet-cli run changelog:validate— clean (no entry; the package is unreleased and this is internal).🤖 Generated with Claude Code