wallet: Document the state-injection contract in README

Open
#8,792 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@grypez is already working on this.

Since May 26, 2026.

Assessment

This issue has not been assessed yet.

Description

team-ocap-kernel
Problem

@metamask/wallet has no usage documentation. The persistence contract — how consumers supply initial state and subscribe to controller state changes — is entirely implicit. Callers must read the source to understand how to wire persistence, and there is no canonical reference for the expected data shapes or event subscription pattern.

Proposed direction

Add a Usage section to packages/wallet/README.md covering:

  • Hydration: pass an initial state object keyed by controller name to the Wallet constructor. Missing keys fall back to each controller's default state.
  • Writes: subscribe to ${ControllerName}:stateChanged events on wallet.messenger; use wallet.controllerMetadata to identify which fields carry persist: true.
  • Include short code examples for both.
Acceptance
  • README.md has a Usage section with working code examples for both hydration and the stateChanged subscription pattern.
  • The role of wallet.controllerMetadata (identifying persist-flagged fields) is explained.
  • Changelog entry added.
Dominant language
TypeScript
Stars
422
Forks
313
Avg merge
1d 8h
Merged PRs (30d)
414

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MetaMask/core

All issues in MetaMask/core

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.