Page MenuHomePhabricator

[Cashtab] load wallet from storage before calling API
ClosedPublic

Authored by bytesofman on Apr 23 2021, 15:29.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCb612be7f9aec: [Cashtab] load wallet from storage before calling API
Summary

Reconfigure wallet loading and activation functions to pull directly from local storage (if present) before any API call

Includes unit test to make sure wallet page still loads correctly for users who have not yet opened Cashtab in recent enough version to save wallet.state to local storage. The wallet.state object retains some artefacts to support this edge case legacy user.

Note: some other features I considered adding in this diff but should have their own diff: disable notifications for incoming txs when user switches wallet, make user wallet selection a dropdown from the Wallet page

Test Plan

npm test to confirm new unit tests

npm start and observe wallet loads faster and does not flash incorrect balance before loading
Navigate to settings page and activate a different wallet. Observe activation is almost instant.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
load-before-any-API
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 15572
Build 31063: Build Diffcashtab-tests
Build 31062: arc lint + arc unit

Event Timeline

Removing comments used in development, marking mock as generated

Removing obsolete dev comment

Handle case of cashtab user loading with unmigrated wallets, ensure that wallet object state is kept current

Allow useEffect call to update savedWallets list in Configure.js; do not call it twice with the previous wallet

This revision is now accepted and ready to land.Apr 27 2021, 15:30