Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warm-ways-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Hide quote value in payment widgets
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
spacing,
} from "../../../../core/design-system/index.js";
import { useBuyWithFiatQuotesForProviders } from "../../../../core/hooks/pay/useBuyWithFiatQuotesForProviders.js";
import { formatCurrencyAmount } from "../../ConnectWallet/screens/formatTokenBalance.js";
import { Container } from "../../components/basic.js";
import { Button } from "../../components/buttons.js";
import { Img } from "../../components/Img.js";
Expand Down Expand Up @@ -164,12 +165,10 @@
size="sm"
style={{ fontWeight: 500 }}
>
$
{quote.currencyAmount.toLocaleString(undefined, {
maximumFractionDigits: 2,
minimumFractionDigits: 2,
})}{" "}
{quote.currency}
{formatCurrencyAmount(
currency || "US",
quote.currencyAmount,
)}

Check warning on line 171 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx#L168-L171

Added lines #L168 - L171 were not covered by tests
</Text>
<Text color="secondaryText" size="xs">
{formatNumber(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@
onPaymentMethodSelected={handlePaymentMethodSelected}
paymentMethods={suitableTokenPaymentMethods}
paymentMethodsLoading={paymentMethodsLoading}
currency={currency}

Check warning on line 295 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx#L295

Added line #L295 was not covered by tests
/>
)}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
"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";
import { formatTokenAmount } from "../../ConnectWallet/screens/formatTokenBalance.js";
import {
formatCurrencyAmount,
formatTokenAmount,
} from "../../ConnectWallet/screens/formatTokenBalance.js";
import { Container } from "../../components/basic.js";
import { Button } from "../../components/buttons.js";
import { Skeleton } from "../../components/Skeleton.js";
Expand All @@ -21,6 +25,7 @@
destinationToken: Token;
destinationAmount: bigint;
feePayer?: "sender" | "receiver";
currency?: SupportedFiatCurrency;
}

// Individual payment method token row component
Expand All @@ -31,19 +36,22 @@
client: ThirdwebClient;
onPaymentMethodSelected: (paymentMethod: PaymentMethod) => void;
feePayer?: "sender" | "receiver";
currency?: SupportedFiatCurrency;
}

function PaymentMethodTokenRow({
paymentMethod,
client,
onPaymentMethodSelected,
currency,

Check warning on line 46 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx#L46

Added line #L46 was not covered by tests
}: PaymentMethodTokenRowProps) {
const theme = useCustomTheme();

const displayOriginAmount = paymentMethod.quote.originAmount;
const hasEnoughBalance = displayOriginAmount
? paymentMethod.balance >= displayOriginAmount
: false;
const currencyPrice = paymentMethod.originToken.prices[currency || "USD"];

Check warning on line 54 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx#L54

Added line #L54 was not covered by tests

return (
<Button
Expand Down Expand Up @@ -79,26 +87,30 @@
gap="3xs"
style={{ alignItems: "flex-end", flex: 1 }}
>
<Text
color="primaryText"
size="sm"
style={{ fontWeight: 600, textWrap: "nowrap" }}
>
{formatTokenAmount(
displayOriginAmount,
paymentMethod.originToken.decimals,
)}{" "}
{paymentMethod.originToken.symbol}
</Text>
<Container flex="row" gap="3xs">
<Text color="secondaryText" size="xs">
Balance:{" "}
{currencyPrice && (
<Text
color="primaryText"
size="sm"
style={{ fontWeight: 600, textWrap: "nowrap" }}

Check warning on line 94 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx#L90-L94

Added lines #L90 - L94 were not covered by tests
>
{formatCurrencyAmount(
currency || "USD",
Number(
formatTokenAmount(
paymentMethod.balance,
paymentMethod.originToken.decimals,
),
) * currencyPrice,
)}

Check warning on line 104 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx#L96-L104

Added lines #L96 - L104 were not covered by tests
</Text>
)}
<Container flex="row" gap="3xs">

Check warning on line 107 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx#L107

Added line #L107 was not covered by tests
<Text color={hasEnoughBalance ? "success" : "danger"} size="xs">
{formatTokenAmount(
paymentMethod.balance,
paymentMethod.originToken.decimals,
)}
)}{" "}
{paymentMethod.originToken.symbol}

Check warning on line 113 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx#L112-L113

Added lines #L112 - L113 were not covered by tests
</Text>
</Container>
</Container>
Expand All @@ -116,6 +128,7 @@
destinationToken,
destinationAmount,
feePayer,
currency,

Check warning on line 131 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx#L131

Added line #L131 was not covered by tests
}: TokenSelectionProps) {
const theme = useCustomTheme();

Expand Down Expand Up @@ -210,7 +223,7 @@
return (
<>
<Text color="primaryText" size="md">
Select payment token
Your token balances
</Text>
<Spacer y="sm" />
<Container
Expand All @@ -233,6 +246,7 @@
key={`${method.originToken.address}-${method.originToken.chainId}`}
onPaymentMethodSelected={onPaymentMethodSelected}
paymentMethod={method}
currency={currency}

Check warning on line 249 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx#L249

Added line #L249 was not covered by tests
/>
))}
</Container>
Expand Down
Loading