Closed nuo-xu closed 7 months ago
[puLL-Merge] - brave/brave-ios@8726
This pull request introduces several major changes to the Brave iOS wallet related to adding and editing custom assets, managing asset visibility, updating the assets list, and improving security and robustness through codebase reorganization and refining how balances are handled.
Sources/BraveWallet/Crypto/Stores/CryptoStore.swift: The introduction of the new balance management and asset update logic increases the complexity of state management, which could lead to inconsistent UI states or data discrepancies if not properly handled.
Sources/BraveWallet/WalletUserAssetManager.swift: Extensive changes in asset management and balance updates introduce potential risks around asynchronous data handling and observer notification logic, which if improperly managed, could result in race conditions or data integrity issues.
Data Modeling (Sources/Data/models/Model.xcdatamodeld/): Any modifications to the data model that are not backward compatible could potentially lead to data migration issues or loss of user data. Proper migration strategies and thorough testing are essential.
Overall, this pull request significantly refactors how assets are managed within the Brave iOS wallet, with a particular focus on streamlining the addition and editing process, improving balance handling, and ensuring the UI accurately reflects the current state. Proper testing, especially around data integrity and UI consistency, is crucial.
Close since we have migrated to brave-core
. A duplicate PR is created https://github.com/brave/brave-core/pull/22029
Summary of Changes
We are now caching asset's balance. They can be easily fetch from CD via token info or account info or both. Cached balance will be refreshed under certain scenarios. they will be listed in the test plan.
This pull request fixes brave/brave-browser#35986
Submitter Checklist:
NSLocalizableString()
Test Plan:
Upgrade (current target 1.63.x)
New Wallet Set up
Restore A Wallet Note: Currently, we have known issues https://github.com/brave/brave-browser/issues/35696 and https://github.com/brave/brave-browser/issues/35697 these two cause auto-discovery assets are not discovered right after restoring. We will use a workaround to verify auto-discovery assets can be discovered and their balances are being fetched correctly. But this issue helps us to verify another scenario I will explain later in other test steps.
WETH
onPolygon Mainnet
WETH
WETH
to mark it as visible assetWETH
now appears and its balance is fetched.NFTs
tab, enable NFT auto-discovery in the promptAssets
also shows up if you navigate toAssets
Assets
that this Wallet A owns with some balance. Please check if their balances were fetched correctly.Add a primary or secondary account to wallet
Account
in PortfolioAdd/Remove a new network
Group
Add/Remove custom token
Check balance after a transaction is confirmed/error/dropped
Confirmed
In summary, balances in Portfolio (Assets) will be refreshed when
Note: Transactions that are submitted by Dapps via signing request through wallet, since there is no access from Wallet to know the transaction status that is not created by Brave Wallet, it is not possible to determine when to refresh the balance based this transaction's status until we can observe all on-chain activity for an address. In this case, to refresh balance, user has to lock and unlock the wallet.
Reviewer Checklist:
QA/(Yes|No)
bug
/enhancement