@b3dotfun/sdk 0.0.40-alpha.2 → 0.0.40-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +10 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +8 -4
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +26 -10
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +6 -3
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +0 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +5 -3
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +8 -8
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/cjs/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsBadge.js +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +14 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +1 -0
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/providers/index.js +3 -0
- package/dist/cjs/anyspend/types/api.d.ts +11 -1
- package/dist/cjs/anyspend/utils/orderPayload.js +1 -0
- package/dist/cjs/bondkit/bondkitToken.d.ts +37 -2
- package/dist/cjs/bondkit/bondkitToken.js +268 -2
- package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/cjs/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/cjs/bondkit/config.d.ts +1 -1
- package/dist/cjs/bondkit/config.js +5 -2
- package/dist/cjs/bondkit/constants.d.ts +4 -0
- package/dist/cjs/bondkit/constants.js +6 -1
- package/dist/cjs/bondkit/index.d.ts +1 -0
- package/dist/cjs/bondkit/index.js +4 -1
- package/dist/cjs/bondkit/swapService.d.ts +43 -0
- package/dist/cjs/bondkit/swapService.js +373 -0
- package/dist/cjs/bondkit/types.d.ts +10 -4
- package/dist/cjs/bondkit/types.js +4 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +35 -9
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +63 -3
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -2
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +22 -20
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +10 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +8 -4
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +26 -10
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +6 -3
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +0 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -8
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/esm/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PointsBadge.js +4 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +8 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +1 -0
- package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
- package/dist/esm/anyspend/react/providers/index.js +1 -0
- package/dist/esm/anyspend/types/api.d.ts +11 -1
- package/dist/esm/anyspend/utils/orderPayload.js +1 -0
- package/dist/esm/bondkit/bondkitToken.d.ts +37 -2
- package/dist/esm/bondkit/bondkitToken.js +268 -2
- package/dist/esm/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/esm/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/esm/bondkit/config.d.ts +1 -1
- package/dist/esm/bondkit/config.js +5 -2
- package/dist/esm/bondkit/constants.d.ts +4 -0
- package/dist/esm/bondkit/constants.js +5 -0
- package/dist/esm/bondkit/index.d.ts +1 -0
- package/dist/esm/bondkit/index.js +2 -0
- package/dist/esm/bondkit/swapService.d.ts +43 -0
- package/dist/esm/bondkit/swapService.js +369 -0
- package/dist/esm/bondkit/types.d.ts +10 -4
- package/dist/esm/bondkit/types.js +4 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +36 -9
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +65 -5
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -2
- package/dist/esm/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +22 -20
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +10 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/types/anyspend/react/providers/index.d.ts +1 -0
- package/dist/types/anyspend/types/api.d.ts +11 -1
- package/dist/types/bondkit/bondkitToken.d.ts +37 -2
- package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/types/bondkit/config.d.ts +1 -1
- package/dist/types/bondkit/constants.d.ts +4 -0
- package/dist/types/bondkit/index.d.ts +1 -0
- package/dist/types/bondkit/swapService.d.ts +43 -0
- package/dist/types/bondkit/types.d.ts +10 -4
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/package.json +6 -5
- package/src/anyspend/react/components/AnySpend.tsx +24 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +55 -13
- package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +22 -0
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +0 -1
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +7 -4
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +13 -8
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +170 -44
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +61 -45
- package/src/anyspend/react/components/common/OrderDetails.tsx +8 -9
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
- package/src/anyspend/react/components/common/PanelOnramp.tsx +28 -15
- package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
- package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +1 -0
- package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
- package/src/anyspend/react/providers/index.ts +1 -0
- package/src/anyspend/types/api.ts +11 -1
- package/src/anyspend/types/api_req_res.ts +6 -10
- package/src/anyspend/utils/orderPayload.ts +1 -0
- package/src/bondkit/bondkitToken.ts +323 -3
- package/src/bondkit/bondkitTokenFactory.ts +2 -2
- package/src/bondkit/config.ts +5 -2
- package/src/bondkit/constants.ts +7 -0
- package/src/bondkit/index.ts +3 -0
- package/src/bondkit/swapService.ts +461 -0
- package/src/bondkit/types.ts +12 -5
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +51 -15
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +106 -32
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +60 -5
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
- package/src/global-account/react/hooks/useAuthentication.ts +1 -2
- package/src/global-account/react/hooks/useSimBalance.ts +2 -2
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +23 -21
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import { RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspend";
|
|
4
4
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
5
|
-
import { ShinyButton, useProfile } from "@b3dotfun/sdk/global-account/react";
|
|
5
|
+
import { ShinyButton, useAccountWallet, useProfile } from "@b3dotfun/sdk/global-account/react";
|
|
6
6
|
import centerTruncate from "@b3dotfun/sdk/shared/utils/centerTruncate";
|
|
7
7
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
8
8
|
import { motion } from "framer-motion";
|
|
9
9
|
import { ChevronRight, Loader2 } from "lucide-react";
|
|
10
|
-
import { useAccount } from "wagmi";
|
|
11
10
|
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
12
11
|
import { OrderDetailsCollapsible } from "./OrderDetailsCollapsible";
|
|
13
12
|
import { PaymentMethodSwitch } from "./PaymentMethodSwitch";
|
|
@@ -41,7 +40,11 @@ export default function ConnectWalletPayment({
|
|
|
41
40
|
}: ConnectWalletPaymentProps) {
|
|
42
41
|
const profile = useProfile({ address: order.recipientAddress });
|
|
43
42
|
const recipientName = profile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
44
|
-
const {
|
|
43
|
+
const { connectedEOAWallet, connectedSmartWallet } = useAccountWallet();
|
|
44
|
+
const connectedEvmAddress =
|
|
45
|
+
cryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET
|
|
46
|
+
? connectedSmartWallet?.getAccount()?.address
|
|
47
|
+
: connectedEOAWallet?.getAccount()?.address;
|
|
45
48
|
|
|
46
49
|
const srcToken = order.metadata.srcToken;
|
|
47
50
|
const dstToken = order.metadata.dstToken;
|
|
@@ -97,7 +100,7 @@ export default function ConnectWalletPayment({
|
|
|
97
100
|
Connected to:{" "}
|
|
98
101
|
{order.srcChain === RELAY_SOLANA_MAINNET_CHAIN_ID && phantomWalletAddress
|
|
99
102
|
? centerTruncate(phantomWalletAddress, 6)
|
|
100
|
-
: centerTruncate(
|
|
103
|
+
: centerTruncate(connectedEvmAddress || "")}
|
|
101
104
|
</span>
|
|
102
105
|
|
|
103
106
|
<PaymentMethodSwitch currentMethod={cryptoPaymentMethod} onMethodChange={onPaymentMethodChange} />
|
|
@@ -5,7 +5,6 @@ import { formatDisplayNumber } from "@b3dotfun/sdk/shared/utils/number";
|
|
|
5
5
|
import { ChevronRight } from "lucide-react";
|
|
6
6
|
import { motion } from "motion/react";
|
|
7
7
|
import { useEffect, useRef } from "react";
|
|
8
|
-
import { useAccount } from "wagmi";
|
|
9
8
|
import { components } from "../../../types/api";
|
|
10
9
|
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
11
10
|
import { OrderTokenAmount } from "./OrderTokenAmount";
|
|
@@ -25,6 +24,8 @@ interface CryptoPaySectionProps {
|
|
|
25
24
|
onSelectCryptoPaymentMethod: () => void;
|
|
26
25
|
// Quote data
|
|
27
26
|
anyspendQuote?: any;
|
|
27
|
+
// Token selection callback
|
|
28
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
export function CryptoPaySection({
|
|
@@ -38,16 +39,19 @@ export function CryptoPaySection({
|
|
|
38
39
|
selectedCryptoPaymentMethod,
|
|
39
40
|
onSelectCryptoPaymentMethod,
|
|
40
41
|
anyspendQuote,
|
|
42
|
+
onTokenSelect,
|
|
41
43
|
}: CryptoPaySectionProps) {
|
|
42
|
-
const {
|
|
43
|
-
const { data: profileData } = useProfile({ address: connectedAddress });
|
|
44
|
-
const connectedName = profileData?.displayName;
|
|
45
|
-
const { address: globalAddress } = useAccountWallet();
|
|
44
|
+
const { connectedSmartWallet, connectedEOAWallet } = useAccountWallet();
|
|
46
45
|
const { data: srcTokenMetadata } = useTokenData(selectedSrcToken?.chainId, selectedSrcToken?.address);
|
|
47
46
|
|
|
48
47
|
// Determine which address to use based on payment method
|
|
49
48
|
const walletAddress =
|
|
50
|
-
selectedCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET
|
|
49
|
+
selectedCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET
|
|
50
|
+
? connectedSmartWallet?.getAccount()?.address
|
|
51
|
+
: connectedEOAWallet?.getAccount()?.address;
|
|
52
|
+
|
|
53
|
+
const { data: profileData } = useProfile({ address: walletAddress });
|
|
54
|
+
const connectedName = profileData?.displayName;
|
|
51
55
|
|
|
52
56
|
// Add ref to track if we've applied metadata
|
|
53
57
|
const appliedSrcMetadataRef = useRef(false);
|
|
@@ -92,9 +96,9 @@ export function CryptoPaySection({
|
|
|
92
96
|
>
|
|
93
97
|
{selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (
|
|
94
98
|
<>
|
|
95
|
-
{
|
|
99
|
+
{walletAddress ? (
|
|
96
100
|
<div className="flex items-center gap-1">
|
|
97
|
-
{connectedName ? formatUsername(connectedName) : shortenAddress(
|
|
101
|
+
{connectedName ? formatUsername(connectedName) : shortenAddress(walletAddress || "")}
|
|
98
102
|
</div>
|
|
99
103
|
) : (
|
|
100
104
|
"Connect wallet"
|
|
@@ -131,6 +135,7 @@ export function CryptoPaySection({
|
|
|
131
135
|
setChainId={setSelectedSrcChainId}
|
|
132
136
|
token={selectedSrcToken}
|
|
133
137
|
setToken={setSelectedSrcToken}
|
|
138
|
+
onTokenSelect={onTokenSelect}
|
|
134
139
|
/>
|
|
135
140
|
<div className="flex items-center justify-between">
|
|
136
141
|
<div className="text-as-primary/50 flex h-5 items-center text-sm">
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
import { useAccountWallet } from "@b3dotfun/sdk/global-account/react";
|
|
4
4
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
5
5
|
import { shortenAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
|
|
6
|
+
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
6
7
|
import { WalletCoinbase, WalletMetamask, WalletPhantom, WalletRainbow, WalletWalletConnect } from "@web3icons/react";
|
|
7
8
|
import { ChevronLeft, ChevronRightCircle, Wallet, X, ZapIcon } from "lucide-react";
|
|
8
9
|
import { useState } from "react";
|
|
9
10
|
import { createPortal } from "react-dom";
|
|
10
11
|
import { toast } from "sonner";
|
|
12
|
+
import { useSetActiveWallet, useWalletInfo } from "thirdweb/react";
|
|
13
|
+
import { WalletId, createWallet } from "thirdweb/wallets";
|
|
11
14
|
import { useAccount, useConnect, useDisconnect, useWalletClient } from "wagmi";
|
|
12
15
|
|
|
13
16
|
export enum CryptoPaymentMethodType {
|
|
@@ -38,13 +41,69 @@ export function CryptoPaymentMethod({
|
|
|
38
41
|
onBack,
|
|
39
42
|
onSelectPaymentMethod,
|
|
40
43
|
}: CryptoPaymentMethodProps) {
|
|
41
|
-
const {
|
|
42
|
-
|
|
44
|
+
const {
|
|
45
|
+
wallet: globalWallet,
|
|
46
|
+
connectedEOAWallet: connectedEOAWallet,
|
|
47
|
+
connectedSmartWallet: connectedSmartWallet,
|
|
48
|
+
} = useAccountWallet();
|
|
49
|
+
const { connector, address, isConnected: wagmiWalletIsConnected } = useAccount();
|
|
43
50
|
const { connect, connectors, isPending } = useConnect();
|
|
44
51
|
const { disconnect } = useDisconnect();
|
|
45
52
|
const { data: walletClient } = useWalletClient();
|
|
46
53
|
const [showWalletModal, setShowWalletModal] = useState(false);
|
|
47
54
|
|
|
55
|
+
const setActiveWallet = useSetActiveWallet();
|
|
56
|
+
const { data: eoaWalletInfo } = useWalletInfo(connectedEOAWallet?.id);
|
|
57
|
+
|
|
58
|
+
const isConnected = !!connectedEOAWallet;
|
|
59
|
+
const globalAddress = connectedSmartWallet?.getAccount()?.address;
|
|
60
|
+
|
|
61
|
+
// Helper function to check if two addresses are the same
|
|
62
|
+
const isSameAddress = (addr1?: string, addr2?: string): boolean => {
|
|
63
|
+
if (!addr1 || !addr2) return false;
|
|
64
|
+
return addr1.toLowerCase() === addr2.toLowerCase();
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Check if connectedEOAWallet and wagmi wallet represent the same wallet
|
|
68
|
+
const connectedEOAAddress = connectedEOAWallet?.getAccount()?.address;
|
|
69
|
+
const wagmiAddress = address;
|
|
70
|
+
const isWalletDuplicated = isSameAddress(connectedEOAAddress, wagmiAddress);
|
|
71
|
+
|
|
72
|
+
// Determine which wallet to show (prefer connectedEOAWallet if both exist and are the same)
|
|
73
|
+
const shouldShowConnectedEOA = !!connectedEOAWallet;
|
|
74
|
+
const shouldShowWagmiWallet = wagmiWalletIsConnected && (!isWalletDuplicated || !connectedEOAWallet);
|
|
75
|
+
|
|
76
|
+
// Map wagmi connector names to thirdweb wallet IDs
|
|
77
|
+
const getThirdwebWalletId = (connectorName: string): WalletId | null => {
|
|
78
|
+
const walletMap: Record<string, WalletId> = {
|
|
79
|
+
MetaMask: "io.metamask",
|
|
80
|
+
"Coinbase Wallet": "com.coinbase.wallet",
|
|
81
|
+
Rainbow: "me.rainbow",
|
|
82
|
+
WalletConnect: "walletConnect",
|
|
83
|
+
Phantom: "app.phantom",
|
|
84
|
+
};
|
|
85
|
+
return walletMap[connectorName] || null;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Create thirdweb wallet from wagmi connector
|
|
89
|
+
const createThirdwebWalletFromConnector = async (connectorName: string) => {
|
|
90
|
+
const walletId = getThirdwebWalletId(connectorName);
|
|
91
|
+
if (!walletId) {
|
|
92
|
+
console.warn(`No thirdweb wallet ID found for connector: ${connectorName}`);
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
const thirdwebWallet = createWallet(walletId);
|
|
98
|
+
// Connect the wallet to sync with the existing wagmi connection
|
|
99
|
+
await thirdwebWallet.connect({ client });
|
|
100
|
+
return thirdwebWallet;
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error(`Failed to create thirdweb wallet for ${connectorName}:`, error);
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
48
107
|
// Define available wallet connectors
|
|
49
108
|
const availableConnectors = connectors.filter(connector =>
|
|
50
109
|
["MetaMask", "WalletConnect", "Coinbase Wallet", "Rainbow", "Phantom"].includes(connector.name),
|
|
@@ -161,57 +220,79 @@ export function CryptoPaymentMethod({
|
|
|
161
220
|
</div>
|
|
162
221
|
|
|
163
222
|
{/* Payment Methods */}
|
|
164
|
-
<div className="crypto-payment-methods flex flex-col gap-
|
|
165
|
-
{/* Connect Wallet Section */}
|
|
166
|
-
<button
|
|
167
|
-
onClick={() => {
|
|
168
|
-
// Always show wallet selection modal first
|
|
169
|
-
setShowWalletModal(true);
|
|
170
|
-
}}
|
|
171
|
-
className="crypto-payment-method-connect-wallet bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md"
|
|
172
|
-
>
|
|
173
|
-
<div className="flex items-center gap-3">
|
|
174
|
-
<div className="wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-blue-100">
|
|
175
|
-
<Wallet className="h-4 w-4 text-blue-600" />
|
|
176
|
-
</div>
|
|
177
|
-
<div className="flex flex-col items-start text-left">
|
|
178
|
-
<h4 className="text-as-primary font-semibold">Connect wallet</h4>
|
|
179
|
-
</div>
|
|
180
|
-
</div>
|
|
181
|
-
<ChevronRightCircle className="text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" />
|
|
182
|
-
</button>
|
|
183
|
-
|
|
184
|
-
{/* Transfer Crypto Section */}
|
|
185
|
-
<button
|
|
186
|
-
onClick={() => {
|
|
187
|
-
setSelectedPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
188
|
-
onSelectPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
189
|
-
}}
|
|
190
|
-
disabled={isCreatingOrder}
|
|
191
|
-
className="crypto-payment-method-transfer bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md"
|
|
192
|
-
>
|
|
193
|
-
<div className="flex items-center gap-3">
|
|
194
|
-
<div className="wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-orange-100">
|
|
195
|
-
<ZapIcon className="h-4 w-4" />
|
|
196
|
-
</div>
|
|
197
|
-
<div className="flex flex-col items-start text-left">
|
|
198
|
-
<h4 className="text-as-primary font-semibold">Transfer crypto</h4>
|
|
199
|
-
</div>
|
|
200
|
-
</div>
|
|
201
|
-
<ChevronRightCircle className="text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" />
|
|
202
|
-
</button>
|
|
203
|
-
|
|
223
|
+
<div className="crypto-payment-methods flex flex-col gap-4">
|
|
204
224
|
{/* Installed Wallets Section */}
|
|
205
|
-
{(
|
|
225
|
+
{(shouldShowConnectedEOA || shouldShowWagmiWallet || globalAddress) && (
|
|
206
226
|
<div className="installed-wallets">
|
|
207
227
|
<h3 className="text-as-primary/80 mb-3 text-sm font-medium">Connected wallets</h3>
|
|
208
228
|
<div className="space-y-2">
|
|
209
229
|
{/* Current Connected Wallet */}
|
|
210
|
-
|
|
230
|
+
|
|
231
|
+
{shouldShowConnectedEOA && (
|
|
211
232
|
<button
|
|
212
233
|
onClick={() => {
|
|
213
234
|
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
214
235
|
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
236
|
+
setActiveWallet(connectedEOAWallet);
|
|
237
|
+
toast.success(`Selected ${eoaWalletInfo?.name || connector?.name || "wallet"}`);
|
|
238
|
+
}}
|
|
239
|
+
className={cn(
|
|
240
|
+
"crypto-payment-method-connect-wallet w-full rounded-xl border p-4 text-left transition-all hover:shadow-md",
|
|
241
|
+
selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET
|
|
242
|
+
? "connected-wallet border-as-brand bg-as-brand/5"
|
|
243
|
+
: "border-as-border-secondary bg-as-surface-primary hover:border-as-secondary/80",
|
|
244
|
+
)}
|
|
245
|
+
>
|
|
246
|
+
<div className="flex items-center justify-between">
|
|
247
|
+
<div className="flex items-center gap-3">
|
|
248
|
+
<div className="wallet-icon flex h-10 w-10 items-center justify-center rounded-full bg-blue-100">
|
|
249
|
+
<Wallet className="h-5 w-5 text-blue-600" />
|
|
250
|
+
</div>
|
|
251
|
+
<div className="flex flex-col">
|
|
252
|
+
<span className="text-as-primary font-semibold">
|
|
253
|
+
{eoaWalletInfo?.name || connector?.name || "Connected Wallet"}
|
|
254
|
+
</span>
|
|
255
|
+
<span className="text-as-primary/60 text-sm">
|
|
256
|
+
{shortenAddress(connectedEOAWallet?.getAccount()?.address || "")}
|
|
257
|
+
</span>
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
<div className="flex items-center gap-2">
|
|
261
|
+
{selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET && (
|
|
262
|
+
<div className="h-2 w-2 rounded-full bg-green-500"></div>
|
|
263
|
+
)}
|
|
264
|
+
<button
|
|
265
|
+
onClick={e => {
|
|
266
|
+
e.stopPropagation();
|
|
267
|
+
disconnect();
|
|
268
|
+
toast.success("Wallet disconnected");
|
|
269
|
+
if (selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
270
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
271
|
+
}
|
|
272
|
+
}}
|
|
273
|
+
className="text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors"
|
|
274
|
+
>
|
|
275
|
+
<X className="h-4 w-4" />
|
|
276
|
+
</button>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
</button>
|
|
280
|
+
)}
|
|
281
|
+
|
|
282
|
+
{shouldShowWagmiWallet && (
|
|
283
|
+
<button
|
|
284
|
+
onClick={async () => {
|
|
285
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
286
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
287
|
+
|
|
288
|
+
// Create thirdweb wallet from wagmi connector
|
|
289
|
+
if (connector?.name) {
|
|
290
|
+
const thirdwebWallet = await createThirdwebWalletFromConnector(connector.name);
|
|
291
|
+
if (thirdwebWallet) {
|
|
292
|
+
setActiveWallet(thirdwebWallet);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
215
296
|
toast.success(`Selected ${connector?.name || "wallet"}`);
|
|
216
297
|
}}
|
|
217
298
|
className={cn(
|
|
@@ -293,6 +374,51 @@ export function CryptoPaymentMethod({
|
|
|
293
374
|
</div>
|
|
294
375
|
</div>
|
|
295
376
|
)}
|
|
377
|
+
|
|
378
|
+
{/* Other Payment Methods Section */}
|
|
379
|
+
<div className="other-payment-methods">
|
|
380
|
+
<h3 className="text-as-primary/80 mb-3 text-sm font-medium">Payment methods</h3>
|
|
381
|
+
<div className="space-y-3">
|
|
382
|
+
{/* Connect Wallet Section */}
|
|
383
|
+
<button
|
|
384
|
+
onClick={() => {
|
|
385
|
+
// Always show wallet selection modal first
|
|
386
|
+
setShowWalletModal(true);
|
|
387
|
+
}}
|
|
388
|
+
className="crypto-payment-method-connect-wallet bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md"
|
|
389
|
+
>
|
|
390
|
+
<div className="flex items-center gap-3">
|
|
391
|
+
<div className="wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-blue-100">
|
|
392
|
+
<Wallet className="h-4 w-4 text-blue-600" />
|
|
393
|
+
</div>
|
|
394
|
+
<div className="flex flex-col items-start text-left">
|
|
395
|
+
<h4 className="text-as-primary font-semibold">Connect wallet</h4>
|
|
396
|
+
</div>
|
|
397
|
+
</div>
|
|
398
|
+
<ChevronRightCircle className="text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" />
|
|
399
|
+
</button>
|
|
400
|
+
|
|
401
|
+
{/* Transfer Crypto Section */}
|
|
402
|
+
<button
|
|
403
|
+
onClick={() => {
|
|
404
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
405
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
406
|
+
}}
|
|
407
|
+
disabled={isCreatingOrder}
|
|
408
|
+
className="crypto-payment-method-transfer bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md"
|
|
409
|
+
>
|
|
410
|
+
<div className="flex items-center gap-3">
|
|
411
|
+
<div className="wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-orange-100">
|
|
412
|
+
<ZapIcon className="h-4 w-4" />
|
|
413
|
+
</div>
|
|
414
|
+
<div className="flex flex-col items-start text-left">
|
|
415
|
+
<h4 className="text-as-primary font-semibold">Transfer crypto</h4>
|
|
416
|
+
</div>
|
|
417
|
+
</div>
|
|
418
|
+
<ChevronRightCircle className="text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" />
|
|
419
|
+
</button>
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
296
422
|
</div>
|
|
297
423
|
</div>
|
|
298
424
|
|
|
@@ -5,7 +5,9 @@ import { formatDisplayNumber } from "@b3dotfun/sdk/shared/utils/number";
|
|
|
5
5
|
import { ChevronRight } from "lucide-react";
|
|
6
6
|
import { motion } from "motion/react";
|
|
7
7
|
import { components } from "../../../types/api";
|
|
8
|
+
import { useFeatureFlags } from "../../contexts/FeatureFlagsContext";
|
|
8
9
|
import { OrderTokenAmount } from "./OrderTokenAmount";
|
|
10
|
+
import { PointsBadge } from "./PointsBadge";
|
|
9
11
|
|
|
10
12
|
interface CryptoReceiveSectionProps {
|
|
11
13
|
isDepositMode?: boolean;
|
|
@@ -27,6 +29,8 @@ interface CryptoReceiveSectionProps {
|
|
|
27
29
|
// custom dst token data
|
|
28
30
|
dstTokenSymbol?: string;
|
|
29
31
|
dstTokenLogoURI?: string;
|
|
32
|
+
// Points navigation
|
|
33
|
+
onShowPointsDetail?: () => void;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
export function CryptoReceiveSection({
|
|
@@ -44,7 +48,10 @@ export function CryptoReceiveSection({
|
|
|
44
48
|
anyspendQuote,
|
|
45
49
|
dstTokenSymbol,
|
|
46
50
|
dstTokenLogoURI,
|
|
51
|
+
onShowPointsDetail,
|
|
47
52
|
}: CryptoReceiveSectionProps) {
|
|
53
|
+
const featureFlags = useFeatureFlags();
|
|
54
|
+
|
|
48
55
|
return (
|
|
49
56
|
<motion.div
|
|
50
57
|
initial={{ opacity: 0, y: 20, filter: "blur(10px)" }}
|
|
@@ -100,61 +107,70 @@ export function CryptoReceiveSection({
|
|
|
100
107
|
setToken={setSelectedDstToken || (() => {})}
|
|
101
108
|
/>
|
|
102
109
|
)}
|
|
103
|
-
<div className="text-as-primary/50 flex h-5 items-center text-sm">
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
anyspendQuote?.data?.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
<div className="text-as-primary/50 flex h-5 items-center justify-start gap-2 text-sm">
|
|
111
|
+
<div className="flex items-center gap-2">
|
|
112
|
+
{formatDisplayNumber(anyspendQuote?.data?.currencyOut?.amountUsd, {
|
|
113
|
+
style: "currency",
|
|
114
|
+
fallback: "",
|
|
115
|
+
})}
|
|
116
|
+
{anyspendQuote?.data?.currencyIn?.amountUsd &&
|
|
117
|
+
anyspendQuote?.data?.currencyOut?.amountUsd &&
|
|
118
|
+
(() => {
|
|
119
|
+
const calculatePriceImpact = (inputUsd?: string | number, outputUsd?: string | number) => {
|
|
120
|
+
if (!inputUsd || !outputUsd) {
|
|
121
|
+
return { percentage: "0.00", isNegative: false };
|
|
122
|
+
}
|
|
115
123
|
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
const input = Number(inputUsd);
|
|
125
|
+
const output = Number(outputUsd);
|
|
118
126
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
// Handle edge cases
|
|
128
|
+
if (input === 0 || isNaN(input) || isNaN(output) || input <= output) {
|
|
129
|
+
return { percentage: "0.00", isNegative: false };
|
|
130
|
+
}
|
|
123
131
|
|
|
124
|
-
|
|
132
|
+
const percentageValue = ((output - input) / input) * 100;
|
|
125
133
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
// Handle the -0.00% case
|
|
135
|
+
if (percentageValue > -0.005 && percentageValue < 0) {
|
|
136
|
+
return { percentage: "0.00", isNegative: false };
|
|
137
|
+
}
|
|
130
138
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
139
|
+
return {
|
|
140
|
+
percentage: Math.abs(percentageValue).toFixed(2),
|
|
141
|
+
isNegative: percentageValue < 0,
|
|
142
|
+
};
|
|
134
143
|
};
|
|
135
|
-
};
|
|
136
144
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
const { percentage, isNegative } = calculatePriceImpact(
|
|
146
|
+
anyspendQuote.data.currencyIn.amountUsd,
|
|
147
|
+
anyspendQuote.data.currencyOut.amountUsd,
|
|
148
|
+
);
|
|
141
149
|
|
|
142
|
-
|
|
143
|
-
|
|
150
|
+
// Parse the percentage as a number for comparison
|
|
151
|
+
const percentageNum = parseFloat(percentage);
|
|
144
152
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
153
|
+
// Don't show if less than 1%
|
|
154
|
+
if (percentageNum < 1) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
149
157
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
// Using inline style to ensure color displays
|
|
159
|
+
return (
|
|
160
|
+
<span className="ml-2" style={{ color: percentageNum >= 10 ? "red" : "#FFD700" }}>
|
|
161
|
+
({isNegative ? "-" : ""}
|
|
162
|
+
{percentage}%)
|
|
163
|
+
</span>
|
|
164
|
+
);
|
|
165
|
+
})()}
|
|
166
|
+
</div>
|
|
167
|
+
{featureFlags.showPoints && anyspendQuote?.data?.pointsAmount > 0 && (
|
|
168
|
+
<PointsBadge
|
|
169
|
+
pointsAmount={anyspendQuote.data.pointsAmount}
|
|
170
|
+
pointsMultiplier={anyspendQuote.data.pointsMultiplier}
|
|
171
|
+
onClick={() => onShowPointsDetail?.()}
|
|
172
|
+
/>
|
|
173
|
+
)}
|
|
158
174
|
</div>
|
|
159
175
|
</motion.div>
|
|
160
176
|
);
|
|
@@ -223,10 +223,9 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
223
223
|
// Read crypto payment method from URL parameters
|
|
224
224
|
const cryptoPaymentMethodFromUrl = searchParams.get("cryptoPaymentMethod") as CryptoPaymentMethodType | null;
|
|
225
225
|
const effectiveCryptoPaymentMethod =
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const orderStatusPaymentMethod = selectedCryptoPaymentMethod || effectiveCryptoPaymentMethod;
|
|
226
|
+
selectedCryptoPaymentMethod !== CryptoPaymentMethodType.NONE
|
|
227
|
+
? selectedCryptoPaymentMethod
|
|
228
|
+
: cryptoPaymentMethod || cryptoPaymentMethodFromUrl || CryptoPaymentMethodType.NONE;
|
|
230
229
|
|
|
231
230
|
const setB3ModalOpen = useModalStore((state: any) => state.setB3ModalOpen);
|
|
232
231
|
|
|
@@ -575,7 +574,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
575
574
|
if (refundTxs.length > 0) {
|
|
576
575
|
return (
|
|
577
576
|
<>
|
|
578
|
-
<OrderStatus order={order} selectedCryptoPaymentMethod={
|
|
577
|
+
<OrderStatus order={order} selectedCryptoPaymentMethod={effectiveCryptoPaymentMethod} />
|
|
579
578
|
<OrderDetailsCollapsible
|
|
580
579
|
order={order}
|
|
581
580
|
dstToken={dstToken}
|
|
@@ -653,7 +652,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
653
652
|
if (executeTx) {
|
|
654
653
|
return (
|
|
655
654
|
<>
|
|
656
|
-
<OrderStatus order={order} selectedCryptoPaymentMethod={
|
|
655
|
+
<OrderStatus order={order} selectedCryptoPaymentMethod={effectiveCryptoPaymentMethod} />
|
|
657
656
|
<OrderDetailsCollapsible
|
|
658
657
|
order={order}
|
|
659
658
|
dstToken={dstToken}
|
|
@@ -780,7 +779,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
780
779
|
if (relayTxs.length > 0 && relayTxs.every(tx => tx.status === "success")) {
|
|
781
780
|
return (
|
|
782
781
|
<>
|
|
783
|
-
<OrderStatus order={order} selectedCryptoPaymentMethod={
|
|
782
|
+
<OrderStatus order={order} selectedCryptoPaymentMethod={effectiveCryptoPaymentMethod} />
|
|
784
783
|
<OrderDetailsCollapsible
|
|
785
784
|
order={order}
|
|
786
785
|
dstToken={dstToken}
|
|
@@ -909,7 +908,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
909
908
|
if (depositTxs?.length || waitingForDeposit) {
|
|
910
909
|
return (
|
|
911
910
|
<>
|
|
912
|
-
<OrderStatus order={order} selectedCryptoPaymentMethod={
|
|
911
|
+
<OrderStatus order={order} selectedCryptoPaymentMethod={effectiveCryptoPaymentMethod} />
|
|
913
912
|
<OrderDetailsCollapsible
|
|
914
913
|
order={order}
|
|
915
914
|
dstToken={dstToken}
|
|
@@ -1008,7 +1007,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
1008
1007
|
|
|
1009
1008
|
return (
|
|
1010
1009
|
<>
|
|
1011
|
-
<OrderStatus order={order} selectedCryptoPaymentMethod={
|
|
1010
|
+
<OrderStatus order={order} selectedCryptoPaymentMethod={effectiveCryptoPaymentMethod} />
|
|
1012
1011
|
{statusDisplay === "processing" && (
|
|
1013
1012
|
<>
|
|
1014
1013
|
{order.onrampMetadata ? (
|
|
@@ -27,6 +27,7 @@ export function OrderTokenAmount({
|
|
|
27
27
|
innerClassName,
|
|
28
28
|
amountClassName,
|
|
29
29
|
tokenSelectClassName,
|
|
30
|
+
onTokenSelect,
|
|
30
31
|
}: {
|
|
31
32
|
disabled?: boolean;
|
|
32
33
|
inputValue: string;
|
|
@@ -43,6 +44,7 @@ export function OrderTokenAmount({
|
|
|
43
44
|
innerClassName?: string;
|
|
44
45
|
amountClassName?: string;
|
|
45
46
|
tokenSelectClassName?: string;
|
|
47
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
46
48
|
}) {
|
|
47
49
|
// Track previous token to detect changes
|
|
48
50
|
const prevTokenRef = useRef<string>(token.address);
|
|
@@ -64,6 +66,31 @@ export function OrderTokenAmount({
|
|
|
64
66
|
}, [token.address, chainId, context, onChangeInput]);
|
|
65
67
|
|
|
66
68
|
const handleTokenSelect = (newToken: any) => {
|
|
69
|
+
const token: components["schemas"]["Token"] = {
|
|
70
|
+
address: newToken.address,
|
|
71
|
+
chainId: newToken.chainId,
|
|
72
|
+
decimals: newToken.decimals,
|
|
73
|
+
metadata: { logoURI: newToken.logoURI },
|
|
74
|
+
name: newToken.name,
|
|
75
|
+
symbol: newToken.symbol,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Call the onTokenSelect callback if provided
|
|
79
|
+
if (onTokenSelect) {
|
|
80
|
+
let isDefaultPrevented = false;
|
|
81
|
+
const event = {
|
|
82
|
+
preventDefault: () => {
|
|
83
|
+
isDefaultPrevented = true;
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
onTokenSelect(token, event);
|
|
88
|
+
|
|
89
|
+
if (isDefaultPrevented) {
|
|
90
|
+
return; // Early return if callback prevented default behavior
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
67
94
|
// Mark that we're about to change tokens
|
|
68
95
|
prevTokenRef.current = "changing"; // Temporary value to force effect
|
|
69
96
|
|
|
@@ -71,14 +98,7 @@ export function OrderTokenAmount({
|
|
|
71
98
|
setChainId(newToken.chainId);
|
|
72
99
|
|
|
73
100
|
// Then set the new token
|
|
74
|
-
setToken(
|
|
75
|
-
address: newToken.address,
|
|
76
|
-
chainId: newToken.chainId, // Use the new chain ID
|
|
77
|
-
decimals: newToken.decimals,
|
|
78
|
-
metadata: { logoURI: newToken.logoURI },
|
|
79
|
-
name: newToken.name,
|
|
80
|
-
symbol: newToken.symbol,
|
|
81
|
-
});
|
|
101
|
+
setToken(token);
|
|
82
102
|
|
|
83
103
|
// If this is the source token, reset the amount immediately
|
|
84
104
|
if (context === "from") {
|