anza-xyz / anza-xyz/kit

Add a local storage state sync function for use in SelectedWalletAccountContextProvider

Open
#1,184 5 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.