From 727171cc0e699dbe252056af743752ded7e9ec85 Mon Sep 17 00:00:00 2001 From: gregfromstl Date: Sun, 10 Aug 2025 20:01:17 -0600 Subject: [PATCH 1/2] refactor: only show user balances in payment selection screens --- .changeset/warm-ways-decide.md | 5 ++ .../FiatProviderSelection.tsx | 10 ++-- .../payment-selection/PaymentSelection.tsx | 1 + .../payment-selection/TokenSelection.tsx | 47 ++++++++++++------- 4 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 .changeset/warm-ways-decide.md diff --git a/.changeset/warm-ways-decide.md b/.changeset/warm-ways-decide.md new file mode 100644 index 00000000000..a534560c8b7 --- /dev/null +++ b/.changeset/warm-ways-decide.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Hide quote value in payment widgets diff --git a/packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx b/packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx index b002c97a7db..419d3a992ca 100644 --- a/packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx +++ b/packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx @@ -164,12 +164,12 @@ export function FiatProviderSelection({ size="sm" style={{ fontWeight: 500 }} > - $ - {quote.currencyAmount.toLocaleString(undefined, { - maximumFractionDigits: 2, + {new Intl.NumberFormat(navigator.language, { + style: "currency", + currency: currency, minimumFractionDigits: 2, - })}{" "} - {quote.currency} + maximumFractionDigits: 2, + }).format(quote.currencyAmount)} {formatNumber( diff --git a/packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx b/packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx index be7940ce646..7b6d54c4492 100644 --- a/packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx +++ b/packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx @@ -292,6 +292,7 @@ export function PaymentSelection({ onPaymentMethodSelected={handlePaymentMethodSelected} paymentMethods={suitableTokenPaymentMethods} paymentMethodsLoading={paymentMethodsLoading} + currency={currency} /> )} diff --git a/packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx b/packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx index e889fed9cc5..60eef3a1b4f 100644 --- a/packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx +++ b/packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx @@ -1,6 +1,7 @@ "use client"; import type { Token } from "../../../../../bridge/types/Token.js"; import type { ThirdwebClient } from "../../../../../client/client.js"; +import type { SupportedFiatCurrency } from "../../../../../pay/convert/type.js"; import { useCustomTheme } from "../../../../core/design-system/CustomThemeProvider.js"; import { radius, spacing } from "../../../../core/design-system/index.js"; import type { PaymentMethod } from "../../../../core/machines/paymentMachine.js"; @@ -21,6 +22,7 @@ interface TokenSelectionProps { destinationToken: Token; destinationAmount: bigint; feePayer?: "sender" | "receiver"; + currency?: SupportedFiatCurrency; } // Individual payment method token row component @@ -31,12 +33,14 @@ interface PaymentMethodTokenRowProps { client: ThirdwebClient; onPaymentMethodSelected: (paymentMethod: PaymentMethod) => void; feePayer?: "sender" | "receiver"; + currency?: SupportedFiatCurrency; } function PaymentMethodTokenRow({ paymentMethod, client, onPaymentMethodSelected, + currency, }: PaymentMethodTokenRowProps) { const theme = useCustomTheme(); @@ -44,6 +48,7 @@ function PaymentMethodTokenRow({ const hasEnoughBalance = displayOriginAmount ? paymentMethod.balance >= displayOriginAmount : false; + const currencyPrice = paymentMethod.originToken.prices[currency || "USD"]; return (