[Cashtab] Move cashtabCache to cashtabState
Summary:
The existing cashtabCache is poorly tested and, based on observing debug logs in prod Cashtab, it is possibly not of predictable shape.
The shape of the existing cashtabCache, an object with tokenId for keys, is bad for its use case and also difficult to migrate and test. Since there are possibly bugs in the existing cache, do not migrate -- instead start with a new cache.
Since we are starting with a new one, do it the right way. Token cache should be a map storing genesisInfo by tokenId.
We can't store a map in localforage, so add helper functions to convert cashtabCache to and from JSON.
Update existing mocks for new shape.
Add new tests to confirm migration and expected behavior.
There is a lot going on in this diff but I do not think it can be split into steps. Perhaps we could migrate to the map before we move cashtabCache to cashtabState -- but it is the consistent organization of this value in cashtabState with standardized getters and setters that makes this migration practical. Perhaps we could move to cashtabState and then migrate -- but the existing validation functions and implementation are not functioning properly, and this could raise unrelated errors.
Big diff. But ,
- It's tested
- We get a lot of improvement
- This will make it easier to migrate to in-node chronik-client
Test Plan: npm test
Reviewers: #bitcoin_abc, emack
Reviewed By: #bitcoin_abc, emack
Subscribers: emack
Differential Revision: https://reviews.bitcoinabc.org/D15566