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/purple-foxes-wear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
Comment thread
gregfromstl marked this conversation as resolved.
---

Adds `country` code option to payment widgets
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
* The fiat currency (e.g., "USD"). Defaults to "USD".
*/
currency?: string;
/**
* The user's ISO 3166 alpha-2 country code. This is used to determine onramp provider support.
*/
country?: string;
};

/**
Expand Down Expand Up @@ -89,6 +93,7 @@
onramp: provider,
receiver: params.receiver,
tokenAddress: params.tokenAddress,
country: params.country,

Check warning on line 96 in packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.ts#L96

Added line #L96 was not covered by tests
});
},
queryKey: ["onramp-prepare", provider, params],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export type SendTransactionPayModalConfig =
},
) => void;
showThirdwebBranding?: boolean;
/**
* The user's ISO 3166 alpha-2 country code. This is used to determine onramp provider support.
*/
country?: string;
}
| false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
if (payModal === false) return;
setRootEl(
<TransactionModal
country={payModal?.country}

Check warning on line 140 in packages/thirdweb/src/react/web/hooks/transaction/useSendTransaction.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/hooks/transaction/useSendTransaction.tsx#L140

Added line #L140 was not covered by tests
client={data.tx.client}
localeId={payModal?.locale || "en_US"}
modalMode={data.mode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@
*/
paymentMethods?: ("crypto" | "card")[];

/**
* The user's ISO 3166 alpha-2 country code. This is used to determine onramp provider support.
*/
country: string | undefined;

/**
* Whether to show thirdweb branding in the widget.
* @default true
Expand All @@ -148,6 +153,7 @@
paymentMethods = ["crypto", "card"],
showThirdwebBranding = true,
supportedTokens,
country = "US",

Check warning on line 156 in packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx#L156

Added line #L156 was not covered by tests
}: BridgeOrchestratorProps) {
// Initialize adapters
const adapters = useMemo(
Expand Down Expand Up @@ -319,6 +325,7 @@
receiverAddress={state.context.receiverAddress}
currency={uiOptions.currency}
supportedTokens={supportedTokens}
country={country}

Check warning on line 328 in packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx#L328

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

Expand Down
6 changes: 6 additions & 0 deletions packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@
*/
currency?: SupportedFiatCurrency;

/**
* The user's ISO 3166 alpha-2 country code. This is used to determine onramp provider support.
*/
country?: string;

/**
* Custom label for the main action button.
*/
Expand Down Expand Up @@ -432,6 +437,7 @@
// Show normal bridge orchestrator
content = (
<BridgeOrchestrator
country={props.country}

Check warning on line 440 in packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx#L440

Added line #L440 was not covered by tests
supportedTokens={props.supportedTokens}
client={props.client}
connectLocale={localeQuery.data}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ export type CheckoutWidgetProps = {
*/
currency?: SupportedFiatCurrency;

/**
* The user's ISO 3166 alpha-2 country code. This is used to determine onramp provider support.
*/
country?: string;

/**
* Custom label for the main action button.
*/
Expand Down Expand Up @@ -400,6 +405,7 @@ export function CheckoutWidget(props: CheckoutWidgetProps) {
// Show normal bridge orchestrator
content = (
<BridgeOrchestrator
country={props.country}
client={props.client}
connectLocale={localeQuery.data}
connectOptions={props.connectOptions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ export type TransactionWidgetProps = {
*/
currency?: SupportedFiatCurrency;

/** The user's ISO 3166 alpha-2 country code. This is used to determine onramp provider support. */
country?: string;

/**
* Custom label for the main action button.
*/
Expand Down Expand Up @@ -442,6 +445,7 @@ export function TransactionWidget(props: TransactionWidgetProps) {
// Show normal bridge orchestrator
content = (
<BridgeOrchestrator
country={props.country}
supportedTokens={props.supportedTokens}
client={props.client}
connectLocale={localeQuery.data}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
toAddress: string;
toAmount?: string;
currency?: SupportedFiatCurrency;
country: string | undefined;
}

const PROVIDERS = [
Expand Down Expand Up @@ -59,6 +60,7 @@
toAddress,
toAmount,
currency,
country,

Check warning on line 63 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#L63

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

Expand All @@ -70,6 +72,7 @@
currency: currency || "USD",
receiver: checksumAddress(toAddress),
tokenAddress: checksumAddress(toTokenAddress),
country,

Check warning on line 75 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#L75

Added line #L75 was not covered by tests
});

const quotes = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
*/
currency?: SupportedFiatCurrency;

/**
* The user's ISO 3166 alpha-2 country code. This is used to determine onramp provider support.
*/
country: string | undefined;

supportedTokens?: SupportedTokens;
}

Expand All @@ -115,6 +120,7 @@
supportedTokens,
feePayer,
currency,
country,

Check warning on line 123 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#L123

Added line #L123 was not covered by tests
}: PaymentSelectionProps) {
const connectedWallets = useConnectedWallets();
const activeWallet = useActiveWallet();
Expand Down Expand Up @@ -298,6 +304,7 @@

{currentStep.type === "fiatProviderSelection" && (
<FiatProviderSelection
country={country}

Check warning on line 307 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#L307

Added line #L307 was not covered by tests
client={client}
onProviderSelected={handleOnrampProviderSelected}
toAddress={receiverAddress || ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
payOptions: PayUIOptions;
onTxSent: (data: WaitForReceiptOptions) => void;
modalMode: "buy" | "deposit";
country?: string;
};

export function TransactionModal(props: ModalProps) {
Expand Down Expand Up @@ -116,6 +117,7 @@

return (
<BridgeOrchestrator
country={props.country}

Check warning on line 120 in packages/thirdweb/src/react/web/ui/TransactionButton/TransactionModal.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/TransactionButton/TransactionModal.tsx#L120

Added line #L120 was not covered by tests
client={props.client}
connectLocale={localeQuery.data}
connectOptions={undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const meta = {
onError: (error) => console.error("Bridge error:", error),
theme: "dark",
uiOptions: FUND_WALLET_UI_OPTIONS.usdcDefault,
country: "US",
},
argTypes: {
onCancel: { action: "flow cancelled" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const meta = {
onError: (error) => console.error("Error:", error),
onPaymentMethodSelected: (_paymentMethod) => {},
theme: "dark",
country: "US",
},
argTypes: {
connectLocale: {
Expand Down
Loading