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.
Problem
@metamask/wallethas 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.mdcovering:stateobject keyed by controller name to theWalletconstructor. Missing keys fall back to each controller's default state.${ControllerName}:stateChangedevents onwallet.messenger; usewallet.controllerMetadatato identify which fields carrypersist: true.Acceptance
README.mdhas a Usage section with working code examples for both hydration and the stateChanged subscription pattern.wallet.controllerMetadata(identifying persist-flagged fields) is explained.