HomePhabricator

[Cashtab] Standardize use of wallet state parameters

Description

[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.

  1. Screens are simply not rendered until an unmigrated wallet has migrated (at this point, very unlikely anyone would have an unmigrated wallet)
  2. This simplifies and standardizes validation checks across the Send.js, SendToken.js, Tokens.js, and Wallet.js screens
  3. 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

  1. Send an XEC tx, observe spinner lock and unlock with no flash of different screens
  2. Send an eToken tx, observe spinner lock and unlock with no flash of different screens
  3. Receive an XEC tx, observe received notification, observe brief UI lock as utxo set updates with no flash of different screens
  4. Receive an eToken tx, observe receivd notification, observe brief UI lock as utxo set updates with no flash of different screen
  5. 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

Details

Provenance
Joey King <joseph.roy.king@gmail.com>Authored on Aug 18 2021, 20:28
bytesofmanPushed on Aug 20 2021, 13:42
Reviewer
Restricted Project
Differential Revision
D9885: [Cashtab] Standardize use of wallet state parameters
Parents
rABC17ae0fce00b1: refactor: use structured binding instead of first/second in processor_tests
Branches
Unknown
Tags
Unknown