MetaMask / MetaMask/metamask-extension
UI <=> Background - Allow reading non-persistent state from local storage
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
**Epic: Allow the UI to read state from the storage system**
https://github.com/MetaMask/metamask-extension/issues/18054
Only a subsection of state is persisted at present, the rest is initialized on bootup of the background/service worker. We are going to need to be able to read the non-persistent state from local storage as well, which means we are going to need to redefine our memstore such that it stores but does not rehydrate.
Question? Meaning on boot the state is wiped out for a clean state tree.**
```
/**
* All controllers in Memstore but not in store. They are not persisted.
* On chrome profile re-start, they will be re-initialized.
*/
const resetOnRestartStore = {
AccountTracker: this.accountTracker.store,
TxController: this.txController.memStore,
TokenRatesController: this.tokenRatesController,
MessageManager: this.messageManager.memStore,
PersonalMessageManager: this.personalMessageManager.memStore,
DecryptMessageManager: this.decryptMessageManager.memStore,
EncryptionPublicKeyManager: this.encryptionPublicKeyManager.memStore,
TypesMessageManager: this.typedMessageManager.memStore,
SwapsController: this.swapsController.store,
EnsController: this.ensController.store,
ApprovalController: this.approvalController,
};
```
Contributor guide
Research direction
Read the linked epic first, then trace the background/service worker initialization and the memstore represented by resetOnRestartStore. Determine how non-persistent state should remain available to the UI without rehydrating on restart; done means the UI can read that state and boot still produces a clean state tree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100