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

[Experiment] USD balance for AccountBalance #5533

Open
wants to merge 1 commit into
base: kien/pay-convert-endpoints
Choose a base branch
from

Conversation

kien-ngo
Copy link
Contributor

@kien-ngo kien-ngo commented Nov 27, 2024

CNCT-2494


PR-Codex overview

This PR focuses on enhancing the AccountBalance component by introducing new formatting functions for displaying balances, adding support for fiat values, and updating the props to accommodate these changes.

Detailed summary

  • Added AccountBalanceFormatParams type for balance formatting.
  • Updated formatFn prop to accept an object instead of a number.
  • Introduced formatAccountBalanceForButton and formatAccountBalanceForModal functions.
  • Added showFiatValue prop to display fiat currency.
  • Updated getWalletBalance call to include fiat conversion.
  • Adjusted rendering logic in AccountBalance to handle new formats.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

changeset-bot bot commented Nov 27, 2024

⚠️ No Changeset found

Latest commit: 4b66fbd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

graphite-app bot commented Nov 27, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge-queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

Copy link

vercel bot commented Nov 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2024 5:53pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2024 5:53pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2024 5:53pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2024 5:53pm

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Nov 27, 2024
Copy link
Contributor Author

kien-ngo commented Nov 27, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@kien-ngo kien-ngo changed the title update [Experiment] USD balance for AccountBalance Nov 27, 2024
@kien-ngo kien-ngo marked this pull request as ready for review November 27, 2024 18:13
Copy link
Contributor

github-actions bot commented Nov 27, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 47.92 KB (0%) 959 ms (0%) 4.1 s (+30.45% 🔺) 5.1 s
thirdweb (cjs) 107.43 KB (0%) 2.2 s (0%) 6.3 s (-0.5% 🔽) 8.5 s
thirdweb (minimal + tree-shaking) 5.58 KB (0%) 112 ms (0%) 310 ms (+8.7% 🔺) 422 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 71 ms (-28.63% 🔽) 81 ms
thirdweb/react (minimal + tree-shaking) 18.28 KB (0%) 366 ms (0%) 972 ms (+141.37% 🔺) 1.4 s

@gregfromstl
Copy link
Member

Don't forget a changeset but lgtm

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 7.47664% with 99 lines in your changes missing coverage. Please review.

Project coverage is 46.16%. Comparing base (07afcee) to head (5b02ff0).

Files with missing lines Patch % Lines
...hirdweb/src/react/web/ui/ConnectWallet/Details.tsx 1.88% 52 Missing ⚠️
...dweb/src/react/web/ui/prebuilt/Account/balance.tsx 12.96% 47 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                       @@
##           kien/pay-convert-endpoints    #5533      +/-   ##
==============================================================
- Coverage                       46.30%   46.16%   -0.15%     
==============================================================
  Files                            1082     1085       +3     
  Lines                           58690    58871     +181     
  Branches                         3954     3949       -5     
==============================================================
+ Hits                            27179    27180       +1     
- Misses                          30828    31007     +179     
- Partials                          683      684       +1     
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from 07afcee
packages 41.74% <7.47%> (-0.16%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...dweb/src/react/web/ui/prebuilt/Account/balance.tsx 33.33% <12.96%> (-47.80%) ⬇️
...hirdweb/src/react/web/ui/ConnectWallet/Details.tsx 7.17% <1.88%> (-0.35%) ⬇️

... and 5 files with indirect coverage changes

Comment on lines +215 to +225
fiatBalance: fiatData?.result,
fiatSymbol: fiatData?.result
? new Intl.NumberFormat("en", {
style: "currency",
currency: showFiatValue,
minimumFractionDigits: 0,
maximumFractionDigits: 0,
})
.formatToParts(0)
.find((p) => p.type === "currency")?.value ||
showFiatValue.toUpperCase()
Copy link

Choose a reason for hiding this comment

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

Simplify currency symbol formatting by using a simple mapping object instead of Intl.NumberFormat. Could replace with: const currencySymbols = { USD: '$' }; const fiatSymbol = currencySymbols[showFiatValue] || showFiatValue.toUpperCase();

Spotted by Graphite Reviewer (based on CI logs)

Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants