Skip to content

feat(solana-wallet-snap): use shareable state management lib - #294

Merged
Julink-eth merged 6 commits into
mainfrom
feat/WPN-2057-solana-shared-state
Sep 11, 2026
Merged

feat(solana-wallet-snap): use shareable state management lib#294
Julink-eth merged 6 commits into
mainfrom
feat/WPN-2057-solana-shared-state

Conversation

@Julink-eth

Copy link
Copy Markdown
Contributor

Explanation

  • Switch Solana to the shared @metamask/snap-networks-utils state helpers (IStateManager, State, InMemoryState) from #288
  • Delete the local State / IStateManager / InMemoryState implementations and drop the now-unused async-mutex dependency.
  • Keep Solana-only state shape in stateTypes.ts (UnencryptedStateValue / DEFAULT_UNENCRYPTED_STATE).
  • Keep the legacy assets purge outside the shared class: registerStateMigration still runs on onStart / onUpdate / onInstall (old State constructor behavior). That key was replaced by assetEntities; existing installs still need the cleanup.
  • Delete-account now uses one deleteKeys() call instead of three parallel deleteKey()s.

Not client-breaking: JSON-RPC surface and persisted state format are unchanged. deleteKey now unsets the path (same as Tron/Stellar and Solana’s old test double) instead of writing serialized undefined.

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

@Julink-eth
Julink-eth requested review from a team as code owners September 9, 2026 13:25
@Julink-eth
Julink-eth deployed to default-branch September 9, 2026 13:26 — with GitHub Actions Active
@Julink-eth

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/bitcoin-wallet-snap@2.0.1-preview-d6a148d0
@metamask-previews/snap-networks-utils@1.0.0-preview-d6a148d0
@metamask-previews/solana-wallet-snap@6.0.0-preview-d6a148d0
@metamask-previews/stellar-wallet-snap@0.1.0-preview-d6a148d0
@metamask-previews/tron-wallet-snap@3.2.0-preview-d6a148d0

@Julink-eth

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/bitcoin-wallet-snap@2.0.1-preview-39366099
@metamask-previews/snap-networks-utils@1.0.0-preview-39366099
@metamask-previews/solana-wallet-snap@6.0.0-preview-39366099
@metamask-previews/stellar-wallet-snap@0.1.0-preview-39366099
@metamask-previews/tron-wallet-snap@3.2.0-preview-39366099

@Julink-eth

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@sonarqubecloud

Copy link
Copy Markdown

@taran-a taran-a left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just one comment/question

eventEmitter: EventEmitter,
state: Pick<IStateManager<UnencryptedStateValue>, 'deleteKey'>,
): void => {
const migrateState = async (): Promise<void> => state.deleteKey('assets');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if my assumption is correct but with state.deleteKey - the assets field becomes undefined, but previous omit striped this field out from the object. Probably nothing wrong with this ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good, using the newer shared deleteKey, this shared deleteKey strips the key like omit, it does not persist undefined.
The new deleteKey uses unset(state, key); which unset comes from lodash and that actually delete the property.

@Julink-eth
Julink-eth added this pull request to the merge queue Sep 11, 2026
Merged via the queue into main with commit 9eda248 Sep 11, 2026
95 checks passed
@Julink-eth
Julink-eth deleted the feat/WPN-2057-solana-shared-state branch September 11, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants