Skip to content

fix: type Core messenger as AsyncMessenger without provider casts - #138

Closed
ulissesferreira wants to merge 2 commits into
mainfrom
ulissesferreira/fix-core-messenger-types-252b
Closed

fix: type Core messenger as AsyncMessenger without provider casts#138
ulissesferreira wants to merge 2 commits into
mainfrom
ulissesferreira/fix-core-messenger-types-252b

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Explanation

On main, Core messenger plumbing from #95 has two related type problems that should land before Release/7.0.0 (#137):

  1. CoreMessenger vs runtime type mismatchgetMessenger() returns AsyncMessenger<...>, but SnapExecutionContext.coreMessenger was typed as the sync Messenger constraint (TS2740).
  2. Unsafe provider castscoreMessenger as AssetsProviderMessenger / as RemoteFeatureFlagsProviderMessenger were required because provider messenger types were namespace-bound AsyncMessengers ('AssetsProvider' / 'RemoteFeatureFlagsProvider'). A Snap Core endowment uses the Snap namespace and often exposes an action superset, so those types are not assignable (especially for RemoteFeatureFlagController:getState).

Fix

  • Add namespace-agnostic MessengerCaller / CanCall in @metamask/snap-networks-utils (distributes per-action call overloads over an action union).
  • Retype AssetsProviderMessenger and RemoteFeatureFlagsProviderMessenger as MessengerCallers.
  • In tron-wallet-snap: introduce CoreMessengerConstraint for getMessenger, type CoreMessenger as AsyncMessenger<...>, and remove the casts.

This unblocks Solana Core plumbing (#122) from copying the same cast pattern.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them
Open in Web Open in Cursor 

cursoragent and others added 2 commits August 7, 2026 14:09
Snap getMessenger returns AsyncMessenger, but SnapExecutionContext typed
coreMessenger as the sync Messenger constraint and cast into
namespace-bound provider messengers. Introduce MessengerCaller so providers
accept a Snap Core endowment (own namespace + action superset) safely, and
type tron CoreMessenger as the async runtime value.

Co-authored-by: Ulisses Ferreira <ulisses.ferreira@consensys.net>
Co-authored-by: Ulisses Ferreira <ulisses.ferreira@consensys.net>
@ulissesferreira

Copy link
Copy Markdown
Contributor Author

Superseded by #139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants