Skip to content

[SDK] USD balance for AccountBalance#5533

Merged
graphite-app[bot] merged 1 commit into
mainfrom
kien/account-balance-in-usd
Dec 7, 2024
Merged

[SDK] USD balance for AccountBalance#5533
graphite-app[bot] merged 1 commit into
mainfrom
kien/account-balance-in-usd

Conversation

@kien-ngo

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

Copy link
Copy Markdown
Contributor

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}

@changeset-bot

changeset-bot Bot commented Nov 27, 2024

Copy link
Copy Markdown

🦋 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

@graphite-app

graphite-app Bot commented Nov 27, 2024

Copy link
Copy Markdown
Contributor

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.

@vercel

vercel Bot commented Nov 27, 2024

Copy link
Copy Markdown

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

kien-ngo commented Nov 27, 2024

Copy link
Copy Markdown
Contributor Author

@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
Comment thread packages/thirdweb/src/react/web/ui/prebuilt/Account/balance.tsx Outdated
@github-actions

github-actions Bot commented Nov 27, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

Don't forget a changeset but lgtm

@codecov

codecov Bot commented Nov 27, 2024

Copy link
Copy Markdown

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

Comment thread packages/thirdweb/src/exports/react.ts Outdated
Comment thread packages/thirdweb/src/react/web/ui/prebuilt/Account/balance.tsx Outdated
@kien-ngo kien-ngo force-pushed the kien/account-balance-in-usd branch from b31951c to ebfc761 Compare December 2, 2024 10:33
@kien-ngo kien-ngo changed the base branch from graphite-base/5533 to main December 2, 2024 10:33
@kien-ngo kien-ngo force-pushed the kien/account-balance-in-usd branch from ebfc761 to 7beaa25 Compare December 2, 2024 10:33
@kien-ngo kien-ngo force-pushed the kien/account-balance-in-usd branch 2 times, most recently from ace4abb to e05ac7a Compare December 4, 2024 02:33
@kien-ngo kien-ngo force-pushed the kien/account-balance-in-usd branch from e05ac7a to 7d8d36b Compare December 4, 2024 03:27
Comment thread packages/thirdweb/src/pay/convert/type.ts Outdated
Comment thread packages/thirdweb/src/exports/utils.ts
Comment thread packages/thirdweb/src/utils/shortenLargeNumber.ts
Comment thread packages/thirdweb/src/react/web/ui/ConnectWallet/Details.tsx Outdated

@joaquim-verges joaquim-verges left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just to remove the fiat fetching on connect button by default


const client = TEST_CLIENT;

describe("SendFunds screen", () => {

Copy link
Copy Markdown
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
Copy Markdown
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!

kien-ngo commented Dec 7, 2024

Copy link
Copy Markdown
Contributor Author

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 -->
@jnsdls jnsdls mentioned this pull request Dec 7, 2024
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