Function: storageAdapterFromChromeStorage
storageAdapterFromChromeStorage(
area):StorageAdapter
A StorageAdapter over a chrome.storage area, the shape the wallet stores pending swaps
in: the value lands under the key as the structured value it is (the browser clones it; nothing
is serialized here). A missing key resolves undefined; a rejection of the area reaches the
store, which treats it as "storage unavailable".
Pass a FUNCTION that returns the area to look it up at each call instead of when the adapter is
built: a module that is imported where chrome does not exist yet (a test, a closing extension
context) then fails only when the store touches storage, and that failure (a throw inside the
function) is the same "storage unavailable" rejection.
storage adapter
Parameters
| Parameter | Type |
|---|---|
area | ChromeStorageAreaLike | (() => ChromeStorageAreaLike) |
chrome storage area like
Returns
storage adapter
Example
const store = new PendingSwapStore(storageAdapterFromChromeStorage(chrome.storage.local));
const lazy = new PendingSwapStore(storageAdapterFromChromeStorage(() => chrome.storage.local));