Add a local storage state sync function for use in SelectedWalletAccountContextProvider
- Dominant language
- TypeScript
- Stars
- 695
- Forks
- 210
- Avg merge
- 21h 33m
- Merged PRs (30d)
- 90
Description
The provider added in #1154 uses an object with the following functions to sync the selected wallet/account:
```ts
{
storeSelectedWallet: (walletId: string) => void,
getSelectedWallet: () => string | null,
deleteSelectedWallet: () => void,
}
```
We could add a function to create this for a given localstorage key:
```ts
storeSelectedWallet(walletId) {
localStorage.setItem(STORAGE_KEY, walletId);
},
getSelectedWallet() {
return localStorage.getItem(STORAGE_KEY);
},
deleteSelectedWallet() {
return localStorage.removeItem(STORAGE_KEY);
}
```
Then the provider would be very easy to use with a sensible storage default, while allowing this to be customised if necessary.
Contributor guide
Assessment
This issue has not been assessed yet.