diff --git a/.changeset/hungry-lions-boil.md b/.changeset/hungry-lions-boil.md new file mode 100644 index 00000000000..e4fd074b338 --- /dev/null +++ b/.changeset/hungry-lions-boil.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Allow forcing onramp chain in buyWithFiat options diff --git a/packages/thirdweb/src/pay/buyWithFiat/getQuote.ts b/packages/thirdweb/src/pay/buyWithFiat/getQuote.ts index 97cfdcdc6b9..2ce99e691be 100644 --- a/packages/thirdweb/src/pay/buyWithFiat/getQuote.ts +++ b/packages/thirdweb/src/pay/buyWithFiat/getQuote.ts @@ -100,6 +100,9 @@ export type GetBuyWithFiatQuoteParams = { * @hidden */ paymentLinkId?: string; + + onrampChainId?: number; + onrampTokenAddress?: string; }; /** @@ -326,7 +329,8 @@ export async function getBuyWithFiatQuote( purchaseData: params.purchaseData, currency: params.fromCurrencySymbol, maxSteps: 2, - onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // force onramp to native token to avoid missing gas issues + onrampTokenAddress: params.onrampTokenAddress ?? NATIVE_TOKEN_ADDRESS, // force onramp to native token to avoid missing gas issues + onrampChainId: params.onrampChainId, paymentLinkId: params.paymentLinkId, }); diff --git a/packages/thirdweb/src/react/core/hooks/connection/ConnectButtonProps.ts b/packages/thirdweb/src/react/core/hooks/connection/ConnectButtonProps.ts index 82a5ee57bac..aa2b40bef3e 100644 --- a/packages/thirdweb/src/react/core/hooks/connection/ConnectButtonProps.ts +++ b/packages/thirdweb/src/react/core/hooks/connection/ConnectButtonProps.ts @@ -99,6 +99,8 @@ export type PayUIOptions = Prettify< }; preferredProvider?: FiatProvider; supportedProviders?: FiatProvider[]; + onrampChainId?: number; + onrampTokenAddress?: string; } | false; diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.tsx index 9ccc4a29a31..9fd9659b030 100644 --- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.tsx +++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.tsx @@ -112,6 +112,8 @@ export function FiatScreenContent(props: { fromAddress: payer.account.address, paymentLinkId: paymentLinkId, preferredProvider: preferredProvider ?? supportedProviders[0], + onrampChainId: buyWithFiatOptions?.onrampChainId, + onrampTokenAddress: buyWithFiatOptions?.onrampTokenAddress, } : undefined, );