[Cashtab] Standardize use of wallet state parameters
Summary:
T1737
Cashtab switched from keeping distinct state parameters in state to keeping all state parameters in an object called wallet.state. This was done to dramatically speed up loading times by loading cached wallet state from local storage instead of polling the API every time the app opened.
Because this was done with active users with wallets that did not have this state parameter, some kind of migration system had to be devised. This was rolled out incrementally as some screens did not exist until after the migration (Tokens.js).
This diff standardizes how the newer wallet.state parameters are used.
- Screens are simply not rendered until an unmigrated wallet has migrated (at this point, very unlikely anyone would have an unmigrated wallet)
- This simplifies and standardizes validation checks across the Send.js, SendToken.js, Tokens.js, and Wallet.js screens
- Bug fix in update function that made wallet temporarily invalid every time its state was updated
Some unit tests were removed because this diff changes how an invalid wallet is handled. Previously, rendering for invalid wallets was handled on a screen by screen basis. Now, the app will lock with a spinner until a valid wallet is loaded.
This refactor is necessary to prevent 2 sources of truth for wallet state. Another diff is still necessary to completely remove use of legacy wallet state parameters (they are still used for incoming transaction notifications).
Test Plan:
npm start
- Send an XEC tx, observe spinner lock and unlock with no flash of different screens
- Send an eToken tx, observe spinner lock and unlock with no flash of different screens
- Receive an XEC tx, observe received notification, observe brief UI lock as utxo set updates with no flash of different screens
- Receive an eToken tx, observe receivd notification, observe brief UI lock as utxo set updates with no flash of different screen
- Switch wallets and send a tx, send a few txs, try to break it
Reviewers: #bitcoin_abc, deadalnix, majcosta
Reviewed By: #bitcoin_abc, deadalnix, majcosta
Subscribers: majcosta
Differential Revision: https://reviews.bitcoinabc.org/D9885