diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.tsx
index af6605aec7c..685f1340f8e 100644
--- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.tsx
+++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.tsx
@@ -1,519 +1,15 @@
-import {
- Cross1Icon,
- ExternalLinkIcon,
- TriangleDownIcon,
-} from "@radix-ui/react-icons";
-import { useMemo } from "react";
-import { getCachedChain } from "../../../../../../../chains/utils.js";
-import type { ThirdwebClient } from "../../../../../../../client/client.js";
-import { NATIVE_TOKEN_ADDRESS } from "../../../../../../../constants/addresses.js";
-import type { BuyWithFiatStatus } from "../../../../../../../pay/buyWithFiat/getStatus.js";
-import { formatNumber } from "../../../../../../../utils/formatNumber.js";
-import { formatExplorerTxUrl } from "../../../../../../../utils/url.js";
+import { Cross1Icon } from "@radix-ui/react-icons";
import {
type Theme,
- fontSize,
iconSize,
radius,
spacing,
} from "../../../../../../core/design-system/index.js";
-import {
- useChainExplorers,
- useChainName,
-} from "../../../../../../core/hooks/others/useChainQuery.js";
-import type { TokenInfo } from "../../../../../../core/utils/defaultTokens.js";
-import { Spacer } from "../../../../components/Spacer.js";
import { Spinner } from "../../../../components/Spinner.js";
-import { Container, Line, ModalHeader } from "../../../../components/basic.js";
-import { Button, ButtonLink } from "../../../../components/buttons.js";
+import { Container } from "../../../../components/basic.js";
import { Text } from "../../../../components/text.js";
-import { TokenSymbol } from "../../../../components/token/TokenSymbol.js";
-import { type ERC20OrNativeToken, NATIVE_TOKEN } from "../../nativeToken.js";
-import { PayTokenIcon } from "../PayTokenIcon.js";
import { StepIcon } from "../Stepper.js";
-import {
- type FiatStatusMeta,
- getBuyWithFiatStatusMeta,
-} from "../pay-transactions/statusMeta.js";
-import { getCurrencyMeta, getFiatIcon } from "./currencies.js";
-
-export type BuyWithFiatPartialQuote = {
- fromCurrencySymbol: string;
- fromCurrencyAmount: string;
- onRampTokenAmount: string;
- toTokenAmount: string;
- onRampToken: {
- tokenAddress: string;
- name?: string;
- symbol?: string;
- chainId: number;
- };
-
- toToken: {
- tokenAddress: string;
- name?: string;
- symbol?: string;
- chainId: number;
- };
-};
-
-export function FiatSteps(props: {
- title: string;
- partialQuote: BuyWithFiatPartialQuote;
- status?: BuyWithFiatStatus;
- onBack: () => void;
- client: ThirdwebClient;
- step: number;
- onContinue: () => void;
-}) {
- const statusMeta = props.status
- ? getBuyWithFiatStatusMeta(props.status)
- : undefined;
-
- const {
- toToken: toTokenMeta,
- onRampToken: onRampTokenMeta,
- onRampTokenAmount,
- fromCurrencySymbol,
- fromCurrencyAmount,
- toTokenAmount,
- } = props.partialQuote;
-
- const currency = getCurrencyMeta(fromCurrencySymbol);
- const isPartialSuccess = statusMeta?.progressStatus === "partialSuccess";
-
- const toChain = useMemo(
- () => getCachedChain(toTokenMeta.chainId),
- [toTokenMeta.chainId],
- );
-
- const destinationChain = useMemo(() => {
- if (props.status?.status !== "NOT_FOUND" && props.status?.destination) {
- return getCachedChain(props.status?.destination.token.chainId);
- }
-
- return undefined;
- }, [props.status]);
-
- const toToken: ERC20OrNativeToken = useMemo(() => {
- if (toTokenMeta.tokenAddress === NATIVE_TOKEN_ADDRESS) {
- return NATIVE_TOKEN;
- }
-
- const tokenInfo: TokenInfo = {
- address: toTokenMeta.tokenAddress,
- name: toTokenMeta.name || "",
- symbol: toTokenMeta.symbol || "",
- // TODO: when icon is available in endpoint
- // icon: toTokenMeta.icon
- };
- return tokenInfo;
- }, [toTokenMeta]);
-
- const onRampChain = useMemo(
- () => getCachedChain(onRampTokenMeta.chainId),
- [onRampTokenMeta.chainId],
- );
-
- const onRampToken: ERC20OrNativeToken = useMemo(() => {
- if (onRampTokenMeta.tokenAddress === NATIVE_TOKEN_ADDRESS) {
- return NATIVE_TOKEN;
- }
-
- const tokenInfo: TokenInfo = {
- address: onRampTokenMeta.tokenAddress,
- name: onRampTokenMeta.name || "",
- symbol: onRampTokenMeta.symbol || "",
- // TODO: when icon is available in endpoint
- // icon: onRampTokenMeta.icon,
- };
- return tokenInfo;
- }, [onRampTokenMeta]);
-
- const onRampName = useChainName(onRampChain);
- const onRampExplorers = useChainExplorers(onRampChain);
- const toChainName = useChainName(toChain);
- const toChainExplorers = useChainExplorers(toChain);
- const destinationName = useChainName(destinationChain);
-
- const onRampTokenInfo = (
-
-
- {formatNumber(Number(onRampTokenAmount), 6)}{" "}
-
-
-
- );
-
- const fiatIcon = getFiatIcon(currency, "sm");
-
- const onRampTokenIcon = (
-
- );
-
- const toTokenIcon = (
-
- );
-
- const onRampChainInfo = {onRampName.name};
-
- const partialSuccessToTokenInfo =
- props.status?.status === "CRYPTO_SWAP_FALLBACK" &&
- props.status.destination ? (
-
-
- {formatNumber(Number(toTokenAmount), 6)}{" "}
-
- {" "}
-
- {formatNumber(Number(props.status.destination.amount), 6)}{" "}
-
-
-
- ) : null;
-
- const toTokenInfo = partialSuccessToTokenInfo || (
-
- {formatNumber(Number(toTokenAmount), 6)}{" "}
-
-
- );
-
- const partialSuccessToChainInfo =
- props.status?.status === "CRYPTO_SWAP_FALLBACK" &&
- props.status.destination &&
- props.status.destination.token.chainId !==
- props.status.quote.toToken.chainId ? (
-
-
- {toChainName.name}
- {" "}
-
- {destinationName.name}
-
-
- ) : null;
-
- const toTokehChainInfo = partialSuccessToChainInfo || (
- {toChainName.name}
- );
-
- const onRampTxHash =
- props.status?.status !== "NOT_FOUND"
- ? props.status?.source?.transactionHash
- : undefined;
-
- const toTokenTxHash =
- props.status?.status !== "NOT_FOUND"
- ? props.status?.destination?.transactionHash
- : undefined;
-
- const showContinueBtn =
- !props.status ||
- props.status.status === "CRYPTO_SWAP_REQUIRED" ||
- props.status.status === "CRYPTO_SWAP_FAILED";
-
- function getStep1State(): FiatStatusMeta["progressStatus"] {
- if (!statusMeta) {
- if (props.step === 2) {
- return "completed";
- }
- return "actionRequired";
- }
-
- if (statusMeta.step === 2) {
- return "completed";
- }
-
- return statusMeta.progressStatus;
- }
-
- function getStep2State(): FiatStatusMeta["progressStatus"] | undefined {
- if (!statusMeta) {
- if (props.step === 2) {
- return "actionRequired";
- }
- return undefined;
- }
-
- if (statusMeta.step === 2) {
- return statusMeta.progressStatus;
- }
-
- return undefined;
- }
-
- return (
-
-
-
-
- {/* Step 1 */}
-
- Get{" "}
- {" "}
- with {props.partialQuote.fromCurrencySymbol}
-
- }
- step={1}
- from={{
- icon: fiatIcon,
- primaryText: (
-
- {formatNumber(Number(fromCurrencyAmount), 6)} {fromCurrencySymbol}
-
- ),
- }}
- to={{
- icon: onRampTokenIcon,
- primaryText: onRampTokenInfo,
- secondaryText: onRampChainInfo,
- }}
- state={getStep1State()}
- explorer={
- onRampExplorers.explorers[0]?.url && onRampTxHash
- ? {
- label: "View on Explorer",
- url: formatExplorerTxUrl(
- onRampExplorers.explorers[0]?.url,
- onRampTxHash,
- ),
- }
- : undefined
- }
- />
-
-
-
-
- Convert{" "}
- {" "}
- to
-
- }
- step={2}
- from={{
- icon: onRampTokenIcon,
- primaryText: onRampTokenInfo,
- secondaryText: onRampChainInfo,
- }}
- to={{
- icon: toTokenIcon,
- primaryText: toTokenInfo,
- secondaryText: toTokehChainInfo,
- }}
- state={getStep2State()}
- explorer={
- toChainExplorers.explorers[0]?.url && toTokenTxHash
- ? {
- label: "View on Explorer",
- url: formatExplorerTxUrl(
- toChainExplorers.explorers[0]?.url,
- toTokenTxHash,
- ),
- }
- : undefined
- }
- />
-
- {isPartialSuccess &&
- props.status &&
- props.status.status !== "NOT_FOUND" &&
- props.status.source &&
- props.status.destination && (
- <>
-
-
- Expected {props.status.source?.token.symbol}, Got{" "}
- {props.status.destination?.token.symbol} instead
-
-
- >
- )}
-
- {showContinueBtn && (
- <>
-
-
- >
- )}
-
- );
-}
-
-function PaymentStep(props: {
- step: number;
- title: React.ReactNode;
- state?: FiatStatusMeta["progressStatus"];
- from: {
- icon: React.ReactNode;
- primaryText: React.ReactNode;
- secondaryText?: React.ReactNode;
- };
- to: {
- icon: React.ReactNode;
- primaryText: React.ReactNode;
- secondaryText?: React.ReactNode;
- };
- iconText?: string;
- explorer?: {
- label: string;
- url: string;
- };
-}) {
- return (
-
- Step {props.step}
-
- {props.title}
-
-
-
-
-
-
-
- {/* TODO - replace this with SVG */}
-
-
-
-
-
-
- {props.explorer && (
- <>
-
-
- {props.explorer.label}
-
-
- >
- )}
-
- );
-}
-
-function PaymentSubStep(props: {
- icon: React.ReactNode;
- primaryText: React.ReactNode;
- secondaryText?: React.ReactNode;
-}) {
- return (
-
- {/* icon */}
-
- {props.icon}
-
-
- {props.primaryText} {props.secondaryText}
-
-
- );
-}
+import type { FiatStatusMeta } from "../pay-transactions/statusMeta.js";
export function StepContainer(props: {
state?: FiatStatusMeta["progressStatus"];
@@ -535,9 +31,6 @@ export function StepContainer(props: {
} else if (props.state === "failed") {
color = "danger";
text = "Failed";
- } else if (props.state === "partialSuccess") {
- color = "danger";
- text = "Incomplete";
}
return (
diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.tsx
deleted file mode 100644
index 218c9d26210..00000000000
--- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.tsx
+++ /dev/null
@@ -1,142 +0,0 @@
-import { ExternalLinkIcon } from "@radix-ui/react-icons";
-import { getCachedChain } from "../../../../../../../chains/utils.js";
-import type { ThirdwebClient } from "../../../../../../../client/client.js";
-import { formatNumber } from "../../../../../../../utils/formatNumber.js";
-import { formatExplorerTxUrl } from "../../../../../../../utils/url.js";
-import {
- fontSize,
- iconSize,
-} from "../../../../../../core/design-system/index.js";
-import { useChainExplorers } from "../../../../../../core/hooks/others/useChainQuery.js";
-import { Spacer } from "../../../../components/Spacer.js";
-import { Container, Line } from "../../../../components/basic.js";
-import { ButtonLink } from "../../../../components/buttons.js";
-import { Text } from "../../../../components/text.js";
-import { TokenInfoRow } from "../pay-transactions/TokenInfoRow.js";
-import type { FiatStatusMeta } from "../pay-transactions/statusMeta.js";
-import { getCurrencyMeta, getFiatIcon } from "./currencies.js";
-
-/**
- * Show a table with the details of a "OnRamp" transaction step in the "Buy with Fiat" flow.
- * - Show OnRamp token as "Receive"
- * - Show fiat amount as "Pay"
- */
-export function OnRampTxDetailsTable(props: {
- client: ThirdwebClient;
- token: {
- chainId: number;
- address: string;
- symbol: string;
- amount: string;
- };
- fiat: {
- currencySymbol: string;
- amount: string;
- };
- statusMeta?: {
- color: FiatStatusMeta["color"];
- text: FiatStatusMeta["status"];
- txHash?: string;
- };
-}) {
- const onRampExplorers = useChainExplorers(
- getCachedChain(props.token.chainId),
- );
- const onrampTxHash = props.statusMeta?.txHash;
- const currencyMeta = getCurrencyMeta(props.fiat.currencySymbol);
-
- const lineSpacer = (
- <>
-
-
-
- >
- );
-
- return (
-
- {/* Pay */}
-
- Pay
-
-
- {getFiatIcon(currencyMeta, "sm")}
-
- {formatNumber(Number(props.fiat.amount), 2)}{" "}
- {props.fiat.currencySymbol}
-
-
-
-
-
- {lineSpacer}
-
- {/* Receive */}
-
-
- {/* Status */}
- {props.statusMeta && (
- <>
- {lineSpacer}
-
- Status
-
-
- {props.statusMeta.text}
-
-
-
- >
- )}
-
- {lineSpacer}
-
- {/* Transaction Hash link */}
- {onrampTxHash && onRampExplorers.explorers?.[0]?.url && (
- <>
-
-
- View on Explorer
-
-
- >
- )}
-
- );
-}
diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx
index 971651d215b..7f69f31f824 100644
--- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx
+++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx
@@ -496,19 +496,12 @@ function useOnRampStatus(props: {
switch (statusQuery.data?.status) {
case "ON_RAMP_TRANSFER_COMPLETED":
- case "CRYPTO_SWAP_COMPLETED":
- case "CRYPTO_SWAP_REQUIRED":
uiStatus = "completed";
break;
- case "CRYPTO_SWAP_FALLBACK":
- uiStatus = "partialSuccess";
- break;
- case "ON_RAMP_TRANSFER_FAILED":
case "PAYMENT_FAILED":
uiStatus = "failed";
break;
case "PENDING_PAYMENT":
- case "ON_RAMP_TRANSFER_IN_PROGRESS":
uiStatus = "pending";
break;
default:
@@ -522,10 +515,7 @@ function useOnRampStatus(props: {
return;
}
- if (
- statusQuery.data &&
- (uiStatus === "completed" || uiStatus === "partialSuccess")
- ) {
+ if (statusQuery.data && uiStatus === "completed") {
purchaseCbCalled.current = true;
props.onSuccess(statusQuery.data);
}
@@ -537,7 +527,7 @@ function useOnRampStatus(props: {
return;
}
- if (uiStatus === "completed" || uiStatus === "partialSuccess") {
+ if (uiStatus === "completed") {
try {
if (props.openedWindow && !props.openedWindow.closed) {
props.openedWindow.close();
diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.tsx
deleted file mode 100644
index 200820251b3..00000000000
--- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.tsx
+++ /dev/null
@@ -1,170 +0,0 @@
-import { useQuery } from "@tanstack/react-query";
-import { useEffect, useState } from "react";
-import { getCachedChain } from "../../../../../../../chains/utils.js";
-import type { ThirdwebClient } from "../../../../../../../client/client.js";
-import { getContract } from "../../../../../../../contract/contract.js";
-import { allowance } from "../../../../../../../extensions/erc20/__generated__/IERC20/read/allowance.js";
-import type { BuyWithCryptoQuote } from "../../../../../../../pay/buyWithCrypto/getQuote.js";
-import type { BuyWithCryptoStatus } from "../../../../../../../pay/buyWithCrypto/getStatus.js";
-import { getPostOnRampQuote } from "../../../../../../../pay/buyWithFiat/getPostOnRampQuote.js";
-import type { BuyWithFiatStatus } from "../../../../../../../pay/buyWithFiat/getStatus.js";
-import { iconSize } from "../../../../../../core/design-system/index.js";
-import { Spacer } from "../../../../components/Spacer.js";
-import { Spinner } from "../../../../components/Spinner.js";
-import { Container, ModalHeader } from "../../../../components/basic.js";
-import { Button } from "../../../../components/buttons.js";
-import { Text } from "../../../../components/text.js";
-import { AccentFailIcon } from "../../../icons/AccentFailIcon.js";
-import { SwapFlow } from "../swap/SwapFlow.js";
-import type { PayerInfo } from "../types.js";
-
-export function PostOnRampSwap(props: {
- title: string;
- client: ThirdwebClient;
- buyWithFiatStatus: BuyWithFiatStatus;
- onBack?: () => void;
- onDone: () => void;
- transactionMode: boolean;
- isEmbed: boolean;
- payer: PayerInfo;
- onSuccess: ((status: BuyWithCryptoStatus) => void) | undefined;
-}) {
- const [lockedOnRampQuote, setLockedOnRampQuote] = useState<
- BuyWithCryptoQuote | undefined
- >(undefined);
-
- const postOnRampQuoteQuery = useQuery({
- queryKey: ["getPostOnRampQuote", props.buyWithFiatStatus],
- queryFn: async () => {
- return await getPostOnRampQuote({
- client: props.client,
- buyWithFiatStatus: props.buyWithFiatStatus,
- });
- },
- // stop fetching if a quote is already locked
- enabled: !lockedOnRampQuote,
- refetchOnWindowFocus: false,
- });
-
- const allowanceQuery = useQuery({
- queryKey: [
- "allowance",
- props.payer.account.address,
- postOnRampQuoteQuery.data?.approvalData,
- ],
- queryFn: () => {
- if (!postOnRampQuoteQuery.data?.approvalData) {
- return null;
- }
- return allowance({
- contract: getContract({
- client: props.client,
- address: postOnRampQuoteQuery.data.swapDetails.fromToken.tokenAddress,
- chain: getCachedChain(
- postOnRampQuoteQuery.data.swapDetails.fromToken.chainId,
- ),
- }),
- spender: postOnRampQuoteQuery.data.approvalData.spenderAddress,
- owner: props.payer.account.address,
- });
- },
- enabled: !!postOnRampQuoteQuery.data?.approvalData,
- refetchOnMount: true,
- });
-
- useEffect(() => {
- if (
- postOnRampQuoteQuery.data &&
- !lockedOnRampQuote &&
- !postOnRampQuoteQuery.isRefetching &&
- !allowanceQuery.isLoading
- ) {
- setLockedOnRampQuote(postOnRampQuoteQuery.data);
- }
- }, [
- postOnRampQuoteQuery.data,
- lockedOnRampQuote,
- postOnRampQuoteQuery.isRefetching,
- allowanceQuery.isLoading,
- ]);
-
- if (postOnRampQuoteQuery.isError) {
- return (
-
-
-
-
-
-
-
-
- Failed to get a price quote
-
-
-
-
-
-
-
- );
- }
-
- if (!lockedOnRampQuote) {
- return (
-
-
-
-
-
-
-
-
- Getting price quote
-
-
-
-
- );
- }
-
- return (
- {
- setLockedOnRampQuote(undefined);
- postOnRampQuoteQuery.refetch();
- }}
- transactionMode={props.transactionMode}
- isEmbed={props.isEmbed}
- onSuccess={props.onSuccess}
- approvalAmount={allowanceQuery.data ?? undefined}
- />
- );
-}
diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.tsx
deleted file mode 100644
index 1bde4e8c767..00000000000
--- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-import { useState } from "react";
-import type { ThirdwebClient } from "../../../../../../../client/client.js";
-import type { BuyWithCryptoStatus } from "../../../../../../../pay/buyWithCrypto/getStatus.js";
-import type { BuyWithFiatStatus } from "../../../../../../../pay/buyWithFiat/getStatus.js";
-import type { PayerInfo } from "../types.js";
-import { type BuyWithFiatPartialQuote, FiatSteps } from "./FiatSteps.js";
-import { PostOnRampSwap } from "./PostOnRampSwap.js";
-
-// Note: It is necessary to lock in the fiat-status in state and only pass that to so it does not suddenly change during the swap process.
-
-/**
- * - Show 2 steps UI with step 2 highlighted, on continue button click:
- * - Show swap flow
- */
-export function PostOnRampSwapFlow(props: {
- title: string;
- status: BuyWithFiatStatus;
- quote: BuyWithFiatPartialQuote;
- client: ThirdwebClient;
- onBack: () => void;
- onDone: () => void;
- onSwapFlowStarted: () => void;
- transactionMode: boolean;
- isEmbed: boolean;
- payer: PayerInfo;
- onSuccess: ((status: BuyWithCryptoStatus) => void) | undefined;
-}) {
- const [statusForSwap, setStatusForSwap] = useState<
- BuyWithFiatStatus | undefined
- >();
-
- // step 2 flow
- if (statusForSwap) {
- return (
-
- );
- }
-
- // show step 1 and step 2 details
- return (
- {
- props.onSwapFlowStarted();
- setStatusForSwap(props.status);
- }}
- status={props.status}
- />
- );
-}
diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.tsx
deleted file mode 100644
index 3d2c8e7ed65..00000000000
--- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.tsx
+++ /dev/null
@@ -1,138 +0,0 @@
-import { useState } from "react";
-import type { ThirdwebClient } from "../../../../../../../client/client.js";
-import type {
- BuyWithFiatStatus,
- ValidBuyWithFiatStatus,
-} from "../../../../../../../pay/buyWithFiat/getStatus.js";
-import { useBuyWithFiatStatus } from "../../../../../../core/hooks/pay/useBuyWithFiatStatus.js";
-import { Container, Line, ModalHeader } from "../../../../components/basic.js";
-import { OnRampTxDetailsTable } from "../fiat/FiatTxDetailsTable.js";
-import { PostOnRampSwapFlow } from "../fiat/PostOnRampSwapFlow.js";
-import type { PayerInfo } from "../types.js";
-import { getBuyWithFiatStatusMeta } from "./statusMeta.js";
-
-export function FiatDetailsScreen(props: {
- title: string;
- status: ValidBuyWithFiatStatus;
- onBack: () => void;
- client: ThirdwebClient;
- onDone: () => void;
- transactionMode: boolean;
- isEmbed: boolean;
- payer: PayerInfo;
-}) {
- const initialStatus = props.status;
- const [stopPolling, setStopPolling] = useState(false);
-
- const statusQuery = useBuyWithFiatStatus(
- stopPolling
- ? undefined
- : {
- client: props.client,
- intentId: initialStatus.intentId,
- },
- );
-
- const status: ValidBuyWithFiatStatus =
- (statusQuery.data?.status === "NOT_FOUND" ? undefined : statusQuery.data) ||
- initialStatus;
-
- const hasTwoSteps = isSwapRequiredAfterOnRamp(status);
- const statusMeta = getBuyWithFiatStatusMeta(status);
-
- if (hasTwoSteps) {
- const fiatQuote = status.quote;
- return (
- {
- setStopPolling(true);
- }}
- payer={props.payer}
- // viewing history - ignore onSuccess
- onSuccess={undefined}
- />
- );
- }
-
- return (
-
-
-
-
-
-
-
-
-
-
-
- );
-}
-
-// if the toToken is the same as the onRampToken, no swap is required
-function isSwapRequiredAfterOnRamp(buyWithFiatStatus: BuyWithFiatStatus) {
- if (buyWithFiatStatus.status === "NOT_FOUND") {
- return false;
- }
-
- const sameChain =
- buyWithFiatStatus.quote.toToken.chainId ===
- buyWithFiatStatus.quote.onRampToken.chainId;
-
- const sameToken =
- buyWithFiatStatus.quote.toToken.tokenAddress ===
- buyWithFiatStatus.quote.onRampToken.tokenAddress;
-
- return !(sameChain && sameToken);
-}
diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx
index 2280b771d64..90cfebaf9bc 100644
--- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx
+++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx
@@ -13,50 +13,14 @@ import {
useChainExplorers,
useChainName,
} from "../../../../../../core/hooks/others/useChainQuery.js";
-import { useBuyWithCryptoStatus } from "../../../../../../core/hooks/pay/useBuyWithCryptoStatus.js";
import { Spacer } from "../../../../components/Spacer.js";
-import { Container, Line, ModalHeader } from "../../../../components/basic.js";
+import { Container, Line } from "../../../../components/basic.js";
import { ButtonLink } from "../../../../components/buttons.js";
import { Text } from "../../../../components/text.js";
import { WalletRow } from "../swap/WalletRow.js";
import { TokenInfoRow } from "./TokenInfoRow.js";
import { type StatusMeta, getBuyWithCryptoStatusMeta } from "./statusMeta.js";
-export function SwapDetailsScreen(props: {
- status: ValidBuyWithCryptoStatus;
- onBack: () => void;
- client: ThirdwebClient;
-}) {
- const { status: initialStatus, client } = props;
- const statusQuery = useBuyWithCryptoStatus(
- initialStatus.source?.transactionHash
- ? {
- client: client,
- transactionHash: initialStatus.source.transactionHash,
- chainId: initialStatus.source.token.chainId,
- }
- : undefined,
- );
-
- const status: ValidBuyWithCryptoStatus =
- (statusQuery.data?.status !== "NOT_FOUND" ? statusQuery.data : undefined) ||
- initialStatus;
-
- return (
-
-
-
-
-
-
-
-
-
-
-
- );
-}
-
type SwapTxDetailsData = {
fromToken: {
chainId: number;
diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.tsx
deleted file mode 100644
index 4ab8deee3bc..00000000000
--- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import type { ThirdwebClient } from "../../../../../../../client/client.js";
-import type { PayerInfo } from "../types.js";
-import { FiatDetailsScreen } from "./FiatDetailsScreen.js";
-import { SwapDetailsScreen } from "./SwapDetailsScreen.js";
-import type { TxStatusInfo } from "./useBuyTransactionsToShow.js";
-
-export function TxDetailsScreen(props: {
- title: string;
- client: ThirdwebClient;
- statusInfo: TxStatusInfo;
- onBack: () => void;
- onDone: () => void;
- transactionMode: boolean;
- isEmbed: boolean;
- payer: PayerInfo;
-}) {
- const { statusInfo } = props;
-
- if (statusInfo.type === "swap") {
- return (
-
- );
- }
-
- if (statusInfo.type === "fiat") {
- return (
-
- );
- }
-
- return null;
-}
diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.test.ts b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.test.ts
index bf681b6e55e..a4eebbfabf8 100644
--- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.test.ts
+++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.test.ts
@@ -1,10 +1,6 @@
import { describe, expect, it } from "vitest";
import type { BuyWithCryptoStatus } from "../../../../../../../pay/buyWithCrypto/getStatus.js";
-import type { BuyWithFiatStatus } from "../../../../../../../pay/buyWithFiat/getStatus.js";
-import {
- getBuyWithCryptoStatusMeta,
- getBuyWithFiatStatusMeta,
-} from "./statusMeta.js";
+import { getBuyWithCryptoStatusMeta } from "./statusMeta.js";
describe("getBuyWithCryptoStatusMeta", () => {
it('returns "Unknown" for NOT_FOUND status', () => {
@@ -82,93 +78,3 @@ describe("getBuyWithCryptoStatusMeta", () => {
});
});
});
-
-describe("getBuyWithFiatStatusMeta", () => {
- it('returns "Incomplete" for CRYPTO_SWAP_FALLBACK status', () => {
- const result = getBuyWithFiatStatusMeta({
- status: "CRYPTO_SWAP_FALLBACK",
- } as BuyWithFiatStatus);
- expect(result).toEqual({
- status: "Incomplete",
- color: "danger",
- step: 2,
- progressStatus: "partialSuccess",
- });
- });
-
- it('returns "Pending" for CRYPTO_SWAP_IN_PROGRESS status', () => {
- const result = getBuyWithFiatStatusMeta({
- status: "CRYPTO_SWAP_IN_PROGRESS",
- } as BuyWithFiatStatus);
- expect(result).toEqual({
- status: "Pending",
- color: "accentText",
- loading: true,
- step: 2,
- progressStatus: "pending",
- });
- });
-
- it('returns "Pending" for PENDING_ON_RAMP_TRANSFER status', () => {
- const result = getBuyWithFiatStatusMeta({
- status: "PENDING_ON_RAMP_TRANSFER",
- } as BuyWithFiatStatus);
- expect(result).toEqual({
- status: "Pending",
- color: "accentText",
- loading: true,
- step: 1,
- progressStatus: "pending",
- });
- });
-
- it('returns "Completed" for ON_RAMP_TRANSFER_COMPLETED status', () => {
- const result = getBuyWithFiatStatusMeta({
- status: "ON_RAMP_TRANSFER_COMPLETED",
- } as BuyWithFiatStatus);
- expect(result).toEqual({
- status: "Completed",
- color: "success",
- loading: true,
- step: 1,
- progressStatus: "completed",
- });
- });
-
- it('returns "Action Required" for CRYPTO_SWAP_REQUIRED status', () => {
- const result = getBuyWithFiatStatusMeta({
- status: "CRYPTO_SWAP_REQUIRED",
- } as BuyWithFiatStatus);
- expect(result).toEqual({
- status: "Action Required",
- color: "accentText",
- step: 2,
- progressStatus: "actionRequired",
- });
- });
-
- it('returns "Failed" for PAYMENT_FAILED status', () => {
- const result = getBuyWithFiatStatusMeta({
- status: "PAYMENT_FAILED",
- } as BuyWithFiatStatus);
- expect(result).toEqual({
- status: "Failed",
- color: "danger",
- step: 1,
- progressStatus: "failed",
- });
- });
-
- it('returns "Unknown" for unhandled status', () => {
- const result = getBuyWithFiatStatusMeta({
- // @ts-ignore
- status: "UNKNOWN_STATUS",
- });
- expect(result).toEqual({
- status: "Unknown",
- color: "secondaryText",
- step: 1,
- progressStatus: "unknown",
- });
- });
-});
diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.ts b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.ts
index 5ce3ed5524c..3238d9112a5 100644
--- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.ts
+++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.ts
@@ -1,5 +1,4 @@
import type { BuyWithCryptoStatus } from "../../../../../../../pay/buyWithCrypto/getStatus.js";
-import type { BuyWithFiatStatus } from "../../../../../../../pay/buyWithFiat/getStatus.js";
import type { Theme } from "../../../../../../core/design-system/index.js";
export type StatusMeta = {
@@ -74,73 +73,5 @@ export type FiatStatusMeta = {
| "completed"
| "failed"
| "actionRequired"
- | "partialSuccess"
| "unknown";
};
-export function getBuyWithFiatStatusMeta(
- fiatStatus: BuyWithFiatStatus,
-): FiatStatusMeta {
- const status = fiatStatus.status;
-
- switch (status) {
- case "CRYPTO_SWAP_FALLBACK": {
- return {
- status: "Incomplete",
- color: "danger",
- step: 2,
- progressStatus: "partialSuccess",
- };
- }
-
- case "CRYPTO_SWAP_IN_PROGRESS":
- case "PENDING_ON_RAMP_TRANSFER":
- case "ON_RAMP_TRANSFER_IN_PROGRESS":
- case "PENDING_PAYMENT": {
- return {
- status: "Pending",
- color: "accentText",
- loading: true,
- step: status === "CRYPTO_SWAP_IN_PROGRESS" ? 2 : 1,
- progressStatus: "pending",
- };
- }
-
- case "ON_RAMP_TRANSFER_COMPLETED":
- case "CRYPTO_SWAP_COMPLETED": {
- return {
- status: "Completed", // Is this actually completed though?
- color: "success",
- loading: true,
- step: status === "CRYPTO_SWAP_COMPLETED" ? 2 : 1,
- progressStatus: "completed",
- };
- }
-
- case "CRYPTO_SWAP_FAILED":
- case "CRYPTO_SWAP_REQUIRED": {
- return {
- status: "Action Required",
- color: "accentText",
- step: 2,
- progressStatus: "actionRequired",
- };
- }
-
- case "PAYMENT_FAILED":
- case "ON_RAMP_TRANSFER_FAILED": {
- return {
- status: "Failed",
- color: "danger",
- step: 1,
- progressStatus: "failed",
- };
- }
- }
-
- return {
- status: "Unknown",
- color: "secondaryText",
- step: 1,
- progressStatus: "unknown",
- };
-}
diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.ts b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.ts
deleted file mode 100644
index 79ecf8e2d1e..00000000000
--- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import type { ValidBuyWithCryptoStatus } from "../../../../../../../pay/buyWithCrypto/getStatus.js";
-import type { ValidBuyWithFiatStatus } from "../../../../../../../pay/buyWithFiat/getStatus.js";
-
-export type TxStatusInfo =
- | {
- type: "swap";
- status: ValidBuyWithCryptoStatus;
- }
- | {
- type: "fiat";
- status: ValidBuyWithFiatStatus;
- };