Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multichain account list item #25437

Merged
merged 32 commits into from
Jun 26, 2024
Merged

Conversation

montelaidev
Copy link
Contributor

@montelaidev montelaidev commented Jun 20, 2024

Description

This PR updates the account list item to support displaying multichain balances.

Related issues

Fixes https://github.com/MetaMask/accounts-planning/issues/425

Manual testing steps

This does not affect evm accounts, their balances and behaviour should be the same as before.

  1. Add a BTC account
  2. Click on the account picker
  3. See that there are balances for BTC now.

Screenshots/Recordings

Before

After

Screenshot 2024-06-26 at 23 14 18

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@montelaidev montelaidev marked this pull request as ready for review June 25, 2024 17:15
@montelaidev montelaidev requested review from a team as code owners June 25, 2024 17:15
ui/hooks/useMultichainAccountTotalFiatBalance.test.tsx Outdated Show resolved Hide resolved
ui/pages/confirmations/hooks/test-utils.js Outdated Show resolved Hide resolved
ui/hooks/useAccountTotalFiatBalanceWrapper.ts Outdated Show resolved Hide resolved
shared/constants/multichain/networks.ts Outdated Show resolved Hide resolved
ui/hooks/useMultichainAccountTotalFiatBalance.ts Outdated Show resolved Hide resolved
ui/hooks/useMultichainAccountTotalFiatBalance.ts Outdated Show resolved Hide resolved
Comment on lines +59 to +76
const balances = useSelector(getMultichainBalances);
// TODO: find dynamic way to ensure balance is the highest denomination.
const asset =
MULTICHAIN_NATIVE_CURRENCY_TO_CAIP19[
ticker as keyof typeof MULTICHAIN_NATIVE_CURRENCY_TO_CAIP19
];

if (!balances[account.id]?.[asset]) {
// FIXME: We might try to get the balance for a created account, but the
// BalancesController might not have updated it yet!
return EMPTY_VALUES;
}
const { amount } =
balances[account.id][
MULTICHAIN_NATIVE_CURRENCY_TO_CAIP19[
ticker as keyof typeof MULTICHAIN_NATIVE_CURRENCY_TO_CAIP19
]
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe introduce a new useMultichainAccountBalance that uses the same logic than here: getBtcCachedBalance so we would use it there too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed with @ccharly, this would be changed in the overview pr

ui/hooks/useMultichainAccountTotalFiatBalance.ts Outdated Show resolved Hide resolved
@ccharly
Copy link
Contributor

ccharly commented Jun 26, 2024

I was also able to test it, and this matches our design:

Screenshot 2024-06-26 at 16 43 28

Copy link

codecov bot commented Jun 26, 2024

Codecov Report

Attention: Patch coverage is 93.93939% with 4 lines in your changes missing coverage. Please review.

Project coverage is 69.69%. Comparing base (9844d1a) to head (38b767b).
Report is 2 commits behind head on develop.

Files Patch % Lines
ui/hooks/useMultichainAccountTotalFiatBalance.ts 90.48% 2 Missing ⚠️
...app/transaction-list/transaction-list.component.js 50.00% 1 Missing ⚠️
ui/selectors/multichain.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #25437      +/-   ##
===========================================
+ Coverage    69.65%   69.69%   +0.04%     
===========================================
  Files         1347     1349       +2     
  Lines        47808    47851      +43     
  Branches     13187    13200      +13     
===========================================
+ Hits         33299    33349      +50     
+ Misses       14509    14502       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@metamaskbot
Copy link
Collaborator

Builds ready [38b767b]
Page Load Metrics (46 ± 4 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint649778105
domContentLoaded8131010
load38704674
domInteractive8131010
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 4.76 KiB (0.07%)
  • common: 0 Bytes (0.00%)

@montelaidev montelaidev merged commit 4e2596f into develop Jun 26, 2024
76 checks passed
@montelaidev montelaidev deleted the fix/multichain-account-list-item branch June 26, 2024 15:36
@github-actions github-actions bot locked and limited conversation to collaborators Jun 26, 2024
@metamaskbot metamaskbot added the release-12.1.0 Issue or pull request that will be included in release 12.1.0 label Jun 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.1.0 Issue or pull request that will be included in release 12.1.0 team-accounts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants