[Cashtab] Cache wallet state in indexedDb
Summary:
This is the first step toward caching bcha utxos, slpa utxos, and tx history in local storage.
Currently the largest bottleneck on the server is that the web wallet must poll the server for full utxo history on startup. If state is saved to local storage, then Cashtab can instead only poll for utxo changes, and then only poll changed utxos for SLPA status.
This change does not add utxos or txhistory to state. It only adds what is already stored in state to the cache. Future diffs will add info required for caching, check for state in storage before polling the server, and reduce server calls from all utxos on every startup to only required calls for uncached utxo data.
Test Plan:
- npm start
- Observe in dev console that state is saved to the wallet object.
- Confirm in dev console under Application --> IndexedDb that the wallet object has been saved with new state parameter.
- Activate a different wallet.
- Confirm that your previously active wallet was written to savedWallets in IndexedDb with state parameter.
There are no unit tests for this diff because the app is designed to work whether or not state has been saved. A unit test mocking localForage does not add anything; equivalent to saying "expect true to be true."
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D9400