Skip to content

refactor(keyring-sdk)!: remove envelope from the migration framework - #619

Merged
ccharly merged 18 commits into
mainfrom
cc/refactor/flat-migrations
Aug 10, 2026
Merged

refactor(keyring-sdk)!: remove envelope from the migration framework#619
ccharly merged 18 commits into
mainfrom
cc/refactor/flat-migrations

Conversation

@ccharly

@ccharly ccharly commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Remove the use of the envelope for the migration's states. This allows more flexibility for systems/data that already uses a version field with a flat shape, making it more natural too.


Note

High Risk
Breaking API and on-disk/vault serialization shape for any consumer of createMigrations; integrators must migrate deserialize/serialize and stored state from envelope to flat form.

Overview
Breaking change: The keyring migration framework no longer wraps state in { version, data }. Serialized state is flatversion sits next to keyring fields—and apply() returns { version, state, migrated } instead of putting payload on data.

Migration steps still receive and return inner data without version; the framework strips version before running steps and sets state.version to the chain version after (overriding any version a step returns). isVersionedState now means any plain object with an integer version, not an envelope with required data.

State must be a plain JSON object (JsonObject): unversioned null or arrays throw, and default step validation uses JsonObjectStruct rather than generic JSON. Typed chains and tests were updated for the new shapes.

Reviewed by Cursor Bugbot for commit 00307a3. Bugbot is set up for automated code reviews on this repo. Configure here.

@ccharly
ccharly marked this pull request as ready for review August 7, 2026 15:38
@ccharly
ccharly requested a review from a team as a code owner August 7, 2026 15:38

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ff1538c. Configure here.

Comment thread packages/keyring-sdk/src/migration.ts
@ccharly

ccharly commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown

Preview builds have been published. See these instructions (from the core monorepo) for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/account-api": "2.0.0-00307a3",
  "@metamask-previews/hw-wallet-sdk": "1.0.0-00307a3",
  "@metamask-previews/keyring-api": "24.1.0-00307a3",
  "@metamask-previews/eth-hd-keyring": "15.0.0-00307a3",
  "@metamask-previews/eth-ledger-bridge-keyring": "13.0.2-00307a3",
  "@metamask-previews/eth-money-keyring": "4.0.0-00307a3",
  "@metamask-previews/eth-qr-keyring": "3.0.0-00307a3",
  "@metamask-previews/eth-simple-keyring": "13.0.0-00307a3",
  "@metamask-previews/eth-trezor-keyring": "11.0.0-00307a3",
  "@metamask-previews/keyring-internal-api": "12.1.0-00307a3",
  "@metamask-previews/keyring-internal-snap-client": "11.1.0-00307a3",
  "@metamask-previews/keyring-sdk": "3.1.0-00307a3",
  "@metamask-previews/eth-snap-keyring": "24.1.0-00307a3",
  "@metamask-previews/keyring-snap-client": "10.0.0-00307a3",
  "@metamask-previews/keyring-snap-sdk": "10.0.0-00307a3",
  "@metamask-previews/keyring-utils": "5.0.0-00307a3"
}

@ccharly
ccharly added this pull request to the merge queue Aug 10, 2026
Merged via the queue into main with commit 893dbbf Aug 10, 2026
23 checks passed
@ccharly
ccharly deleted the cc/refactor/flat-migrations branch August 10, 2026 10:09
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