fix(wallet): Improve default messenger, state and instance types#8436
Merged
rekmarks merged 5 commits intorekm/wallet-library-tweaksfrom Apr 13, 2026
Merged
Conversation
a652933
into
rekm/wallet-library-tweaks
318 of 347 checks passed
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
Infer messenger, instance and state types from
defaultConfigurations. Which lets us remove casting due to previous lack of messenger types.Note
Medium Risk
Mostly TypeScript typing refactors, but it also downgrades
@metamask/utils, which could introduce subtle compatibility or build/runtime differences across the wallet package.Overview
Improves type-safety for the wallet initialization flow by deriving
RootMessenger, default action/event types, instance types, andWallet.stateshape directly fromdefaultConfigurations(newinitialization/defaults.ts) and re-exporting them viainitialization/index.ts.Updates
Walletandinitializeto use these inferred types (including strictermessengertyping and typedDefaultState/DefaultInstances), removes the oldRootMessengertype fromtypes.ts, and adds a couple of targeted@ts-expect-errorannotations for calling optionaldestroy().Also adjusts
sendTransactionto rely on the typed return value frommessenger.call(removing an explicit cast) and downgrades@metamask/utilsfrom^11.11.0to^11.9.0(with lockfile update).Reviewed by Cursor Bugbot for commit e130704. Bugbot is set up for automated code reviews on this repo. Configure here.