feat(wallet): add injectable logger to WalletOptions#9097
Open
grypez wants to merge 2 commits into
Open
Conversation
Add an optional `logger?: Pick<Console, 'info'>` field to `WalletOptions`.
When provided, `initialize()` emits a `[wallet] ${name}: initialized`
breadcrumb via `logger.info` immediately after each controller's `init()`
completes, in initialization order. The field is no-op by default, so
library consumers are unaffected.
This gives visibility into controller initialization order and timing —
the data needed to observe which messenger actions are called during
`init()` vs. at runtime, informing the init-messenger pattern decision.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The `changelog:check` CI gate requires entries to reference the current PR rather than the issue. Co-Authored-By: Claude Opus 4.8 <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
@metamask/walletis the shared controller-integration layer for the extension, mobile, and other clients (e.g. wallet-cli), so any value that differs between clients is an injectableWalletOptionsfield rather than something hardcoded.This PR adds an optional
logger?: Pick<Console, 'info'>field toWalletOptions. When provided, the initialization loop emits a[wallet] ${name}: initializedbreadcrumb vialogger.infoimmediately after each controller'sinit()returns, in initialization order. The field is no-op by default, so library consumers are unaffected unless they opt in.Passing
{ logger: console }during a development run then produces one timestamped log line per wired controller, in order. This gives visibility into controller initialization sequence and timing — the empirical data needed to observe which messenger actions a controller calls duringinit()versus at runtime. Any messenger action observed before a controller's init-complete breadcrumb is a candidate for an init messenger; calls after are runtime uses.Closes #8791.
Options
loggerconsole) for dev diagnosticsconsoleduring developmentThe default is no output, so the field has no effect on any client that does not pass it.
References
N/A
Checklist
🤖 Generated with Claude Code
Note
Low Risk
Optional diagnostic logging only; no change to init logic or required options when
loggeris omitted.Overview
Adds an optional
loggeronWalletOptions(Pick<Console, 'info'>) so clients can opt into initialization diagnostics without changing default behavior.During
initialize(), after each controller'sinit()finishes, the wallet callslogger?.infowith[wallet] ${name}: initializedin wiring order.Walletforwards the option unchanged; JSDoc and the changelog document the hook. Tests assert ordered breadcrumbs matchdefaultConfigurationsand that construction still works whenloggeris omitted.Reviewed by Cursor Bugbot for commit f01e8f5. Bugbot is set up for automated code reviews on this repo. Configure here.