[Cashtab] Init storage abstraction layer to support cross-platform app
Summary:
We would like Cashtab to be available as a mobile app. Currently, it is available as a webapp and a browser extension.
Both the extension and the webapp are using indexedDb, i.e. web storage. This is the best we can do with a web browser for a web app. However, we want to support native mobile storage for mobile apps, and we also want to support the chrome storage API for the extension (which is persistent).
In this diff, we init an abstraction layer for Cashtab's storage. For now we only support the extension. We migrate web storage to extension storage API.
After this, we will add support for iOS and Android native storage for capacitor.
Test Plan:
npm test
npm run extension
navigate to brave://extensions and update
cd modules/cashtab-connect/demo npm start
navigate to localhost:3000, check logs for extension, confirm migration, check that you can just see your wallets as before, confirm address sharing still works
Migration risk is mitigated here by not wiping localforage. It's not practical to test migration in unit tests / integration tests as we end up mocking all of the storage APIs and then ... "hey look the mock was called"
I did a few migrations including settings, contacts, multiple wallets by building old extension, setting it up, then installing the new one and opening it, checking the logs.
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D18468