@b3dotfun/sdk 0.0.40 → 0.0.41-alpha.0
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 +11 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +17 -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 +33 -11
- 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 +1 -2
- 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 -11
- 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 +18 -8
- 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/services/anyspend.d.ts +1 -1
- package/dist/cjs/anyspend/services/anyspend.js +2 -0
- package/dist/cjs/anyspend/types/api.d.ts +51 -1
- package/dist/cjs/anyspend/utils/chain.js +1 -1
- package/dist/cjs/anyspend/utils/orderPayload.js +3 -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/components/TradingView.js +3 -4
- 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 +376 -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 +41 -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/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +3 -1
- package/dist/cjs/global-account/react/hooks/useAccountAssets.js +5 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +2 -3
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.js +32 -0
- package/dist/cjs/global-account/react/hooks/useQueryB3.js +5 -2
- package/dist/cjs/global-account/react/hooks/useQueryBSMNT.js +5 -2
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/cjs/global-account/react/hooks/useTokenBalancesByChain.js +7 -1
- package/dist/cjs/global-account/react/hooks/useTokenFromUrl.js +2 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +28 -24
- package/dist/cjs/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +11 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +17 -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 +33 -11
- 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 +1 -2
- 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 -11
- 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 +18 -8
- 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/services/anyspend.d.ts +1 -1
- package/dist/esm/anyspend/services/anyspend.js +2 -0
- package/dist/esm/anyspend/types/api.d.ts +51 -1
- package/dist/esm/anyspend/utils/chain.js +1 -1
- package/dist/esm/anyspend/utils/orderPayload.js +3 -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/components/TradingView.js +3 -4
- 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 +372 -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 +42 -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/index.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/index.js +1 -0
- package/dist/esm/global-account/react/hooks/useAccountAssets.js +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +2 -3
- package/dist/esm/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/esm/global-account/react/hooks/useGlobalAccount.js +29 -0
- package/dist/esm/global-account/react/hooks/useQueryB3.js +5 -2
- package/dist/esm/global-account/react/hooks/useQueryBSMNT.js +5 -2
- package/dist/esm/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/esm/global-account/react/hooks/useTokenBalancesByChain.js +4 -1
- package/dist/esm/global-account/react/hooks/useTokenFromUrl.js +2 -2
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +29 -25
- package/dist/esm/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +11 -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/services/anyspend.d.ts +1 -1
- package/dist/types/anyspend/types/api.d.ts +51 -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/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/types/shared/utils/fetchBalances.d.ts +1 -1
- package/package.json +6 -5
- package/src/anyspend/react/components/AnySpend.tsx +37 -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 +63 -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 +1 -2
- 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 +10 -14
- 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 +18 -8
- package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +1 -1
- package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +1 -1
- package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
- package/src/anyspend/react/providers/index.ts +1 -0
- package/src/anyspend/services/anyspend.ts +3 -1
- package/src/anyspend/types/api.ts +51 -1
- package/src/anyspend/types/api_req_res.ts +6 -10
- package/src/anyspend/utils/chain.ts +1 -1
- package/src/anyspend/utils/orderPayload.ts +3 -0
- package/src/bondkit/bondkitToken.ts +323 -3
- package/src/bondkit/bondkitTokenFactory.ts +2 -2
- package/src/bondkit/components/TradingView.tsx +3 -5
- 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 +464 -0
- package/src/bondkit/types.ts +12 -5
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +55 -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/index.ts +1 -0
- package/src/global-account/react/hooks/useAccountAssets.ts +4 -3
- package/src/global-account/react/hooks/useAuthentication.ts +2 -3
- package/src/global-account/react/hooks/useGlobalAccount.tsx +36 -0
- package/src/global-account/react/hooks/useOneBalance.tsx +1 -1
- package/src/global-account/react/hooks/useQueryB3.ts +22 -15
- package/src/global-account/react/hooks/useQueryBSMNT.ts +22 -15
- package/src/global-account/react/hooks/useSimBalance.ts +2 -2
- package/src/global-account/react/hooks/useTokenBalancesByChain.tsx +4 -1
- package/src/global-account/react/hooks/useTokenFromUrl.tsx +2 -2
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +30 -26
- package/src/shared/utils/fetchBalances.ts +1 -1
|
@@ -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
|
);
|
|
@@ -110,9 +110,6 @@ function getOrderSuccessText({
|
|
|
110
110
|
case "custom":
|
|
111
111
|
actionText = order.metadata.action || `executed contract`;
|
|
112
112
|
return `Successfully ${actionText}`;
|
|
113
|
-
case "hype_duel":
|
|
114
|
-
actionText = `deposited ${formattedActualDstAmount || "--"} HYPE`;
|
|
115
|
-
return `Successfully ${actionText} to ${recipient}`;
|
|
116
113
|
default:
|
|
117
114
|
throw new Error("Invalid order type");
|
|
118
115
|
}
|
|
@@ -226,10 +223,9 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
226
223
|
// Read crypto payment method from URL parameters
|
|
227
224
|
const cryptoPaymentMethodFromUrl = searchParams.get("cryptoPaymentMethod") as CryptoPaymentMethodType | null;
|
|
228
225
|
const effectiveCryptoPaymentMethod =
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const orderStatusPaymentMethod = selectedCryptoPaymentMethod || effectiveCryptoPaymentMethod;
|
|
226
|
+
selectedCryptoPaymentMethod !== CryptoPaymentMethodType.NONE
|
|
227
|
+
? selectedCryptoPaymentMethod
|
|
228
|
+
: cryptoPaymentMethod || cryptoPaymentMethodFromUrl || CryptoPaymentMethodType.NONE;
|
|
233
229
|
|
|
234
230
|
const setB3ModalOpen = useModalStore((state: any) => state.setB3ModalOpen);
|
|
235
231
|
|
|
@@ -578,7 +574,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
578
574
|
if (refundTxs.length > 0) {
|
|
579
575
|
return (
|
|
580
576
|
<>
|
|
581
|
-
<OrderStatus order={order} selectedCryptoPaymentMethod={
|
|
577
|
+
<OrderStatus order={order} selectedCryptoPaymentMethod={effectiveCryptoPaymentMethod} />
|
|
582
578
|
<OrderDetailsCollapsible
|
|
583
579
|
order={order}
|
|
584
580
|
dstToken={dstToken}
|
|
@@ -656,7 +652,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
656
652
|
if (executeTx) {
|
|
657
653
|
return (
|
|
658
654
|
<>
|
|
659
|
-
<OrderStatus order={order} selectedCryptoPaymentMethod={
|
|
655
|
+
<OrderStatus order={order} selectedCryptoPaymentMethod={effectiveCryptoPaymentMethod} />
|
|
660
656
|
<OrderDetailsCollapsible
|
|
661
657
|
order={order}
|
|
662
658
|
dstToken={dstToken}
|
|
@@ -667,8 +663,8 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
667
663
|
/>
|
|
668
664
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
669
665
|
<AccordionItem value="execute-details" className="order-details-execute-item">
|
|
670
|
-
<AccordionTrigger className="
|
|
671
|
-
<AccordionContent className="
|
|
666
|
+
<AccordionTrigger className="accordion-trigger">Transaction Details</AccordionTrigger>
|
|
667
|
+
<AccordionContent className="accordion-content pl-2">
|
|
672
668
|
<div className="relative flex w-full flex-col gap-4">
|
|
673
669
|
<div className="bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2">
|
|
674
670
|
<motion.div
|
|
@@ -783,7 +779,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
783
779
|
if (relayTxs.length > 0 && relayTxs.every(tx => tx.status === "success")) {
|
|
784
780
|
return (
|
|
785
781
|
<>
|
|
786
|
-
<OrderStatus order={order} selectedCryptoPaymentMethod={
|
|
782
|
+
<OrderStatus order={order} selectedCryptoPaymentMethod={effectiveCryptoPaymentMethod} />
|
|
787
783
|
<OrderDetailsCollapsible
|
|
788
784
|
order={order}
|
|
789
785
|
dstToken={dstToken}
|
|
@@ -912,7 +908,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
912
908
|
if (depositTxs?.length || waitingForDeposit) {
|
|
913
909
|
return (
|
|
914
910
|
<>
|
|
915
|
-
<OrderStatus order={order} selectedCryptoPaymentMethod={
|
|
911
|
+
<OrderStatus order={order} selectedCryptoPaymentMethod={effectiveCryptoPaymentMethod} />
|
|
916
912
|
<OrderDetailsCollapsible
|
|
917
913
|
order={order}
|
|
918
914
|
dstToken={dstToken}
|
|
@@ -1011,7 +1007,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
1011
1007
|
|
|
1012
1008
|
return (
|
|
1013
1009
|
<>
|
|
1014
|
-
<OrderStatus order={order} selectedCryptoPaymentMethod={
|
|
1010
|
+
<OrderStatus order={order} selectedCryptoPaymentMethod={effectiveCryptoPaymentMethod} />
|
|
1015
1011
|
{statusDisplay === "processing" && (
|
|
1016
1012
|
<>
|
|
1017
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") {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCoinbaseOnrampOptions, useGeoOnrampOptions } from "@b3dotfun/sdk/anyspend/react";
|
|
2
2
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
|
+
import { GetQuoteResponse } from "@b3dotfun/sdk/anyspend/types/api_req_res";
|
|
3
4
|
import { ALL_CHAINS } from "@b3dotfun/sdk/anyspend/utils/chain";
|
|
4
5
|
import { Input, useGetGeo, useProfile } from "@b3dotfun/sdk/global-account/react";
|
|
5
6
|
import { cn, formatUsername } from "@b3dotfun/sdk/shared/utils";
|
|
@@ -7,8 +8,10 @@ import { formatAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
|
|
|
7
8
|
import { ChevronRight, Wallet } from "lucide-react";
|
|
8
9
|
import { useRef } from "react";
|
|
9
10
|
import { toast } from "sonner";
|
|
11
|
+
import { useFeatureFlags } from "../../contexts/FeatureFlagsContext";
|
|
10
12
|
import { FiatPaymentMethod } from "./FiatPaymentMethod";
|
|
11
13
|
import { OrderTokenAmountFiat } from "./OrderTokenAmountFiat";
|
|
14
|
+
import { PointsBadge } from "./PointsBadge";
|
|
12
15
|
|
|
13
16
|
export function PanelOnramp({
|
|
14
17
|
srcAmountOnRamp,
|
|
@@ -25,6 +28,8 @@ export function PanelOnramp({
|
|
|
25
28
|
recipientSelectionPanelIndex,
|
|
26
29
|
dstTokenSymbol,
|
|
27
30
|
hideDstToken = false,
|
|
31
|
+
anyspendQuote,
|
|
32
|
+
onShowPointsDetail,
|
|
28
33
|
}: {
|
|
29
34
|
srcAmountOnRamp: string;
|
|
30
35
|
setSrcAmountOnRamp: (amount: string) => void;
|
|
@@ -40,7 +45,10 @@ export function PanelOnramp({
|
|
|
40
45
|
recipientSelectionPanelIndex: number;
|
|
41
46
|
dstTokenSymbol?: string;
|
|
42
47
|
hideDstToken?: boolean;
|
|
48
|
+
anyspendQuote?: GetQuoteResponse;
|
|
49
|
+
onShowPointsDetail?: () => void;
|
|
43
50
|
}) {
|
|
51
|
+
const featureFlags = useFeatureFlags();
|
|
44
52
|
// Get geo-based onramp options to access fee information
|
|
45
53
|
const { stripeWeb2Support } = useGeoOnrampOptions(srcAmountOnRamp);
|
|
46
54
|
|
|
@@ -245,21 +253,26 @@ export function PanelOnramp({
|
|
|
245
253
|
|
|
246
254
|
<div className="">
|
|
247
255
|
<div className="flex items-center justify-between">
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
256
|
+
<div className="flex items-center gap-2">
|
|
257
|
+
<span className="text-as-tertiarry text-sm">
|
|
258
|
+
{(() => {
|
|
259
|
+
const fee = getFeeFromApi(selectedPaymentMethod || FiatPaymentMethod.NONE);
|
|
260
|
+
return fee !== null ? `Total (included $${fee.toFixed(2)} fee)` : "Total";
|
|
261
|
+
})()}
|
|
262
|
+
</span>
|
|
263
|
+
{featureFlags.showPoints &&
|
|
264
|
+
anyspendQuote?.data?.pointsAmount &&
|
|
265
|
+
anyspendQuote?.data?.pointsAmount > 0 && (
|
|
266
|
+
<PointsBadge
|
|
267
|
+
pointsAmount={anyspendQuote.data.pointsAmount}
|
|
268
|
+
pointsMultiplier={anyspendQuote.data.pointsMultiplier}
|
|
269
|
+
onClick={() => onShowPointsDetail?.()}
|
|
270
|
+
/>
|
|
271
|
+
)}
|
|
272
|
+
</div>
|
|
273
|
+
<span className="text-as-primary font-semibold">
|
|
274
|
+
${getTotalAmount(selectedPaymentMethod || FiatPaymentMethod.NONE).toFixed(2)}
|
|
275
|
+
</span>
|
|
263
276
|
</div>
|
|
264
277
|
</div>
|
|
265
278
|
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface PointsBadgeProps {
|
|
2
|
+
pointsAmount: number;
|
|
3
|
+
pointsMultiplier?: number;
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function PointsBadge({ pointsAmount, pointsMultiplier, onClick }: PointsBadgeProps) {
|
|
8
|
+
return (
|
|
9
|
+
<button
|
|
10
|
+
className="bg-as-brand hover:scale-102 active:scale-98 relative flex cursor-pointer items-center gap-1 rounded-lg px-2 py-1 transition-all"
|
|
11
|
+
onClick={onClick}
|
|
12
|
+
>
|
|
13
|
+
<div className="pointer-events-none absolute inset-0 h-full w-full rounded-lg border border-white/10 border-t-white/20 bg-gradient-to-b from-white/10 to-white/0" />
|
|
14
|
+
<span className="relative text-xs text-white">
|
|
15
|
+
+{pointsAmount.toLocaleString()} pts
|
|
16
|
+
{pointsMultiplier && pointsMultiplier > 1 && <span className="ml-1 opacity-80">({pointsMultiplier}x)</span>}
|
|
17
|
+
</span>
|
|
18
|
+
</button>
|
|
19
|
+
);
|
|
20
|
+
}
|