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

[SDK] USD balance for AccountBalance #5533

Merged
merged 1 commit into from
Dec 7, 2024
Merged

Conversation

kien-ngo
Copy link
Contributor

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

CNCT-2494


PR-Codex overview

This PR introduces significant enhancements to the AccountBalance and ConnectButton components, allowing them to display balances in fiat (USD) and improving formatting options. It also expands utility functions and adds test coverage for these features.

Detailed summary

  • Added showBalanceInFiat prop to AccountBalance and ConnectButton.
  • Updated formatFn in AccountBalance to accept AccountBalanceInfo.
  • Introduced utility functions: formatNumber and shortenLargeNumber.
  • Expanded test coverage for connected components.
  • Improved styling and structure in various UI components.

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

Copy link

changeset-bot bot commented Nov 27, 2024

🦋 Changeset detected

Latest commit: 43fbcac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
thirdweb Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another 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 Dec 7, 2024 2:38am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 7, 2024 2:38am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 7, 2024 2:38am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 7, 2024 2:38am

@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

@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) 41.13 KB (0%) 823 ms (0%) 116 ms (+26.06% 🔺) 939 ms
thirdweb (cjs) 104.48 KB (0%) 2.1 s (0%) 269 ms (-1.93% 🔽) 2.4 s
thirdweb (minimal + tree-shaking) 4.37 KB (0%) 88 ms (0%) 41 ms (+379.58% 🔺) 128 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 18 ms (+155.79% 🔺) 28 ms
thirdweb/react (minimal + tree-shaking) 16.99 KB (0%) 340 ms (0%) 57 ms (+7.17% 🔺) 397 ms

@kien-ngo kien-ngo force-pushed the kien/account-balance-in-usd branch from 1bf3114 to c2329af Compare November 27, 2024 18:16
@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 81.14754% with 46 lines in your changes missing coverage. Please review.

Project coverage is 50.62%. Comparing base (37aa163) to head (43fbcac).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...hirdweb/src/react/web/ui/ConnectWallet/Details.tsx 72.72% 28 Missing and 2 partials ⚠️
...dweb/src/react/web/ui/prebuilt/Account/balance.tsx 85.41% 13 Missing and 1 partial ⚠️
.../thirdweb/src/react/web/ui/components/CopyIcon.tsx 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5533      +/-   ##
==========================================
+ Coverage   48.97%   50.62%   +1.65%     
==========================================
  Files        1089     1091       +2     
  Lines       56891    57100     +209     
  Branches     4440     4590     +150     
==========================================
+ Hits        27861    28908    +1047     
+ Misses      28325    27478     -847     
- Partials      705      714       +9     
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from 37aa163
packages 47.08% <81.14%> (+2.06%) ⬆️

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

Files with missing lines Coverage Δ
packages/thirdweb/src/pay/convert/cryptoToFiat.ts 100.00% <ø> (+8.51%) ⬆️
packages/thirdweb/src/pay/convert/fiatToCrypto.ts 100.00% <100.00%> (+8.88%) ⬆️
...eact/web/ui/ConnectWallet/screens/ReceiveFunds.tsx 89.06% <100.00%> (+84.06%) ⬆️
...c/react/web/ui/ConnectWallet/screens/SendFunds.tsx 41.03% <100.00%> (+37.83%) ⬆️
.../thirdweb/src/react/web/ui/components/Skeleton.tsx 96.15% <100.00%> (+0.15%) ⬆️
packages/thirdweb/src/utils/formatNumber.ts 100.00% <ø> (ø)
packages/thirdweb/src/utils/shortenLargeNumber.ts 100.00% <100.00%> (ø)
.../thirdweb/src/react/web/ui/components/CopyIcon.tsx 78.12% <33.33%> (+68.12%) ⬆️
...dweb/src/react/web/ui/prebuilt/Account/balance.tsx 83.84% <85.41%> (+3.45%) ⬆️
...hirdweb/src/react/web/ui/ConnectWallet/Details.tsx 53.86% <72.72%> (+22.67%) ⬆️

... and 29 files with indirect coverage changes


const client = TEST_CLIENT;

describe("SendFunds screen", () => {
Copy link
Member

Choose a reason for hiding this comment

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

thank you for the tests! 76% coverage really nice 👌

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yesser, just trying to push to 80% so we can get this PR merged!

Copy link
Contributor Author

kien-ngo commented Dec 7, 2024

Merge activity

  • Dec 6, 8:34 PM EST: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..
  • Dec 6, 9:28 PM EST: A user added this pull request to the Graphite merge queue.
  • Dec 6, 9:40 PM EST: A user merged this pull request with the Graphite merge queue.

CNCT-2494

<!-- start pr-codex -->

---

## PR-Codex overview
This PR enhances the `AccountBalance` and `ConnectButton` components to support displaying balances in fiat currency (currently only USD). It also introduces new utility functions and improves test coverage across various components.

### Detailed summary
- Added `showBalanceInFiat` prop to `AccountBalance` and `ConnectButton`.
- Updated `formatFn` in `AccountBalance` to accept an object of type `AccountBalanceInfo`.
- Introduced `shortenLargeNumber` and `formatNumber` utility functions.
- Improved tests for `ConnectButton`, `AccountBalance`, and related components.
- Enhanced rendering logic for displaying balances in both token and fiat.

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

<!-- end pr-codex -->
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.

3 participants