wallet: Document the state-injection contract in README
- Dominant language
- TypeScript
- Stars
- 413
- Forks
- 308
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 253
Description
### 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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.