@b3dotfun/sdk 0.0.34 → 0.0.35-alpha.1
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.js +5 -3
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +5 -2
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +16 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +58 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +22 -15
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +12 -4
- package/dist/cjs/anyspend/react/components/common/PaySection.d.ts +2 -6
- package/dist/cjs/anyspend/react/components/common/PaySection.js +10 -15
- package/dist/cjs/anyspend/react/components/index.d.ts +2 -2
- package/dist/cjs/anyspend/react/components/index.js +5 -5
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +6 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +3 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +3 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +4 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +20 -0
- package/dist/cjs/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/dist/cjs/global-account/react/stores/useAuthStore.js +4 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +5 -3
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +5 -2
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +16 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +55 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +1 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +22 -15
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +12 -4
- package/dist/esm/anyspend/react/components/common/PaySection.d.ts +2 -6
- package/dist/esm/anyspend/react/components/common/PaySection.js +10 -15
- package/dist/esm/anyspend/react/components/index.d.ts +2 -2
- package/dist/esm/anyspend/react/components/index.js +2 -2
- package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +6 -3
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +3 -3
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +3 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +4 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.js +21 -1
- package/dist/esm/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/dist/esm/global-account/react/stores/useAuthStore.js +4 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/common/ConnectWalletPayment.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +16 -0
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +1 -0
- package/dist/types/anyspend/react/components/common/PaySection.d.ts +2 -6
- package/dist/types/anyspend/react/components/index.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -0
- package/dist/types/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +2 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +7 -6
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +2 -5
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +6 -1
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +153 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +80 -43
- package/src/anyspend/react/components/common/OrderDetails.tsx +13 -4
- package/src/anyspend/react/components/common/PaySection.tsx +64 -140
- package/src/anyspend/react/components/index.ts +2 -2
- package/src/global-account/react/components/B3DynamicModal.tsx +1 -6
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +92 -82
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +3 -3
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +3 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +5 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +3 -0
- package/src/global-account/react/hooks/useAuthentication.ts +24 -1
- package/src/global-account/react/stores/useAuthStore.ts +8 -0
- package/src/global-account/react/stores/useModalStore.ts +2 -0
- package/src/styles/index.css +5 -2
|
@@ -8,13 +8,13 @@ import { toast } from "sonner";
|
|
|
8
8
|
import { base } from "viem/chains";
|
|
9
9
|
import { PanelView, useAnyspendFlow } from "../hooks/useAnyspendFlow";
|
|
10
10
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper";
|
|
11
|
+
import { CryptoPaySection } from "./common/CryptoPaySection";
|
|
11
12
|
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod";
|
|
12
13
|
import { CryptoReceiveSection } from "./common/CryptoReceiveSection";
|
|
13
14
|
import { ErrorSection } from "./common/ErrorSection";
|
|
14
15
|
import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod";
|
|
15
16
|
import { OrderDetails } from "./common/OrderDetails";
|
|
16
17
|
import { OrderStatus } from "./common/OrderStatus";
|
|
17
|
-
import { PaySection } from "./common/PaySection";
|
|
18
18
|
import { RecipientSelection } from "./common/RecipientSelection";
|
|
19
19
|
|
|
20
20
|
import { ArrowDown } from "lucide-react";
|
|
@@ -191,8 +191,7 @@ function AnySpendDepositHypeInner({
|
|
|
191
191
|
<div className="relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2">
|
|
192
192
|
{/* Send section */}
|
|
193
193
|
{paymentType === "crypto" ? (
|
|
194
|
-
<
|
|
195
|
-
paymentType="crypto"
|
|
194
|
+
<CryptoPaySection
|
|
196
195
|
selectedSrcChainId={selectedSrcChainId}
|
|
197
196
|
setSelectedSrcChainId={setSelectedSrcChainId}
|
|
198
197
|
selectedSrcToken={selectedSrcToken}
|
|
@@ -201,9 +200,7 @@ function AnySpendDepositHypeInner({
|
|
|
201
200
|
setSrcAmount={setSrcAmount}
|
|
202
201
|
setIsSrcInputDirty={setIsSrcInputDirty}
|
|
203
202
|
selectedCryptoPaymentMethod={selectedCryptoPaymentMethod}
|
|
204
|
-
selectedFiatPaymentMethod={selectedFiatPaymentMethod}
|
|
205
203
|
onSelectCryptoPaymentMethod={() => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD)}
|
|
206
|
-
onSelectFiatPaymentMethod={() => setActivePanel(PanelView.FIAT_PAYMENT_METHOD)}
|
|
207
204
|
anyspendQuote={anyspendQuote}
|
|
208
205
|
/>
|
|
209
206
|
) : (
|
|
@@ -8,6 +8,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
10
|
import { useAccount } from "wagmi";
|
|
11
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
11
12
|
import { OrderDetailsCollapsible } from "./OrderDetailsCollapsible";
|
|
12
13
|
|
|
13
14
|
type Tournament = components["schemas"]["Tournament"];
|
|
@@ -22,6 +23,7 @@ interface ConnectWalletPaymentProps {
|
|
|
22
23
|
phantomWalletAddress?: string | null;
|
|
23
24
|
tournament?: Tournament;
|
|
24
25
|
nft?: NFT;
|
|
26
|
+
cryptoPaymentMethod: CryptoPaymentMethodType;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
export default function ConnectWalletPayment({
|
|
@@ -32,6 +34,7 @@ export default function ConnectWalletPayment({
|
|
|
32
34
|
phantomWalletAddress,
|
|
33
35
|
tournament,
|
|
34
36
|
nft,
|
|
37
|
+
cryptoPaymentMethod,
|
|
35
38
|
}: ConnectWalletPaymentProps) {
|
|
36
39
|
const profile = useProfile({ address: order.recipientAddress });
|
|
37
40
|
const recipientName = profile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
@@ -79,7 +82,9 @@ export default function ConnectWalletPayment({
|
|
|
79
82
|
<span className="whitespace-nowrap pl-4 text-lg md:text-sm">
|
|
80
83
|
{order.srcChain === RELAY_SOLANA_MAINNET_CHAIN_ID && phantomWalletAddress
|
|
81
84
|
? "Pay from Phantom Wallet"
|
|
82
|
-
:
|
|
85
|
+
: cryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET
|
|
86
|
+
? "Pay from Global Account"
|
|
87
|
+
: "Pay from Connected Wallet"}
|
|
83
88
|
</span>
|
|
84
89
|
<ChevronRight className="h-4 w-4" />
|
|
85
90
|
</>
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { useAccountWallet, useProfile, useTokenData } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import { formatUsername } from "@b3dotfun/sdk/shared/utils";
|
|
3
|
+
import { shortenAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
|
|
4
|
+
import { formatDisplayNumber } from "@b3dotfun/sdk/shared/utils/number";
|
|
5
|
+
import { ChevronRight } from "lucide-react";
|
|
6
|
+
import { motion } from "motion/react";
|
|
7
|
+
import { useEffect, useRef } from "react";
|
|
8
|
+
import { useAccount } from "wagmi";
|
|
9
|
+
import { components } from "../../../types/api";
|
|
10
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
11
|
+
import { OrderTokenAmount } from "./OrderTokenAmount";
|
|
12
|
+
import { TokenBalance } from "./TokenBalance";
|
|
13
|
+
|
|
14
|
+
interface CryptoPaySectionProps {
|
|
15
|
+
// Token state
|
|
16
|
+
selectedSrcChainId: number;
|
|
17
|
+
setSelectedSrcChainId: (chainId: number) => void;
|
|
18
|
+
selectedSrcToken: components["schemas"]["Token"];
|
|
19
|
+
setSelectedSrcToken: (token: components["schemas"]["Token"]) => void;
|
|
20
|
+
srcAmount: string;
|
|
21
|
+
setSrcAmount: (amount: string) => void;
|
|
22
|
+
setIsSrcInputDirty: (dirty: boolean) => void;
|
|
23
|
+
// Payment method state
|
|
24
|
+
selectedCryptoPaymentMethod: CryptoPaymentMethodType;
|
|
25
|
+
onSelectCryptoPaymentMethod: () => void;
|
|
26
|
+
// Quote data
|
|
27
|
+
anyspendQuote?: any;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function CryptoPaySection({
|
|
31
|
+
selectedSrcChainId,
|
|
32
|
+
setSelectedSrcChainId,
|
|
33
|
+
selectedSrcToken,
|
|
34
|
+
setSelectedSrcToken,
|
|
35
|
+
srcAmount,
|
|
36
|
+
setSrcAmount,
|
|
37
|
+
setIsSrcInputDirty,
|
|
38
|
+
selectedCryptoPaymentMethod,
|
|
39
|
+
onSelectCryptoPaymentMethod,
|
|
40
|
+
anyspendQuote,
|
|
41
|
+
}: CryptoPaySectionProps) {
|
|
42
|
+
const { address: connectedAddress, isConnected } = useAccount();
|
|
43
|
+
const { data: profileData } = useProfile({ address: connectedAddress });
|
|
44
|
+
const connectedName = profileData?.displayName;
|
|
45
|
+
const { address: globalAddress } = useAccountWallet();
|
|
46
|
+
const { data: srcTokenMetadata } = useTokenData(selectedSrcToken?.chainId, selectedSrcToken?.address);
|
|
47
|
+
|
|
48
|
+
// Determine which address to use based on payment method
|
|
49
|
+
const walletAddress =
|
|
50
|
+
selectedCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET ? globalAddress : connectedAddress;
|
|
51
|
+
|
|
52
|
+
// Add ref to track if we've applied metadata
|
|
53
|
+
const appliedSrcMetadataRef = useRef(false);
|
|
54
|
+
|
|
55
|
+
// Update source token with metadata
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (selectedSrcToken && srcTokenMetadata && !appliedSrcMetadataRef.current) {
|
|
58
|
+
// Mark as applied
|
|
59
|
+
appliedSrcMetadataRef.current = true;
|
|
60
|
+
|
|
61
|
+
const enhancedToken = {
|
|
62
|
+
...selectedSrcToken,
|
|
63
|
+
decimals: srcTokenMetadata.decimals || selectedSrcToken.decimals,
|
|
64
|
+
symbol: srcTokenMetadata.symbol || selectedSrcToken.symbol,
|
|
65
|
+
name: srcTokenMetadata.name || selectedSrcToken.name,
|
|
66
|
+
metadata: {
|
|
67
|
+
...selectedSrcToken.metadata,
|
|
68
|
+
logoURI: srcTokenMetadata?.logoURI || selectedSrcToken.metadata.logoURI,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
setSelectedSrcToken(enhancedToken);
|
|
72
|
+
}
|
|
73
|
+
}, [srcTokenMetadata, selectedSrcToken, setSelectedSrcToken]);
|
|
74
|
+
|
|
75
|
+
// Reset source token ref when address/chain changes
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
appliedSrcMetadataRef.current = false;
|
|
78
|
+
}, [selectedSrcToken.address, selectedSrcToken.chainId]);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<motion.div
|
|
82
|
+
initial={{ opacity: 0, y: 20, filter: "blur(10px)" }}
|
|
83
|
+
animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
|
|
84
|
+
transition={{ duration: 0.3, delay: 0, ease: "easeInOut" }}
|
|
85
|
+
className="pay-section bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6"
|
|
86
|
+
>
|
|
87
|
+
<div className="flex items-center justify-between">
|
|
88
|
+
<div className="text-as-primary/50 flex h-7 items-center text-sm">Pay</div>
|
|
89
|
+
<button
|
|
90
|
+
className="text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none"
|
|
91
|
+
onClick={onSelectCryptoPaymentMethod}
|
|
92
|
+
>
|
|
93
|
+
{selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (
|
|
94
|
+
<>
|
|
95
|
+
{isConnected ? (
|
|
96
|
+
<div className="flex items-center gap-1">
|
|
97
|
+
{connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress || "")}
|
|
98
|
+
</div>
|
|
99
|
+
) : (
|
|
100
|
+
"Connect wallet"
|
|
101
|
+
)}
|
|
102
|
+
<ChevronRight className="h-4 w-4" />
|
|
103
|
+
</>
|
|
104
|
+
) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET ? (
|
|
105
|
+
<>
|
|
106
|
+
Global Account
|
|
107
|
+
<ChevronRight className="h-4 w-4" />
|
|
108
|
+
</>
|
|
109
|
+
) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (
|
|
110
|
+
<>
|
|
111
|
+
Transfer crypto
|
|
112
|
+
<ChevronRight className="h-4 w-4" />
|
|
113
|
+
</>
|
|
114
|
+
) : (
|
|
115
|
+
<>
|
|
116
|
+
Select payment method
|
|
117
|
+
<ChevronRight className="h-4 w-4" />
|
|
118
|
+
</>
|
|
119
|
+
)}
|
|
120
|
+
</button>
|
|
121
|
+
</div>
|
|
122
|
+
<OrderTokenAmount
|
|
123
|
+
address={walletAddress}
|
|
124
|
+
context="from"
|
|
125
|
+
inputValue={srcAmount}
|
|
126
|
+
onChangeInput={value => {
|
|
127
|
+
setIsSrcInputDirty(true);
|
|
128
|
+
setSrcAmount(value);
|
|
129
|
+
}}
|
|
130
|
+
chainId={selectedSrcChainId}
|
|
131
|
+
setChainId={setSelectedSrcChainId}
|
|
132
|
+
token={selectedSrcToken}
|
|
133
|
+
setToken={setSelectedSrcToken}
|
|
134
|
+
/>
|
|
135
|
+
<div className="flex items-center justify-between">
|
|
136
|
+
<div className="text-as-primary/50 flex h-5 items-center text-sm">
|
|
137
|
+
{formatDisplayNumber(anyspendQuote?.data?.currencyIn?.amountUsd, {
|
|
138
|
+
style: "currency",
|
|
139
|
+
fallback: "",
|
|
140
|
+
})}
|
|
141
|
+
</div>
|
|
142
|
+
<TokenBalance
|
|
143
|
+
token={selectedSrcToken}
|
|
144
|
+
walletAddress={walletAddress}
|
|
145
|
+
onChangeInput={value => {
|
|
146
|
+
setIsSrcInputDirty(true);
|
|
147
|
+
setSrcAmount(value);
|
|
148
|
+
}}
|
|
149
|
+
/>
|
|
150
|
+
</div>
|
|
151
|
+
</motion.div>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
@@ -13,6 +13,7 @@ import { useAccount, useConnect, useDisconnect, useWalletClient } from "wagmi";
|
|
|
13
13
|
export enum CryptoPaymentMethodType {
|
|
14
14
|
NONE = "none",
|
|
15
15
|
CONNECT_WALLET = "connect_wallet",
|
|
16
|
+
GLOBAL_WALLET = "global_wallet",
|
|
16
17
|
TRANSFER_CRYPTO = "transfer_crypto",
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -37,7 +38,7 @@ export function CryptoPaymentMethod({
|
|
|
37
38
|
onBack,
|
|
38
39
|
onSelectPaymentMethod,
|
|
39
40
|
}: CryptoPaymentMethodProps) {
|
|
40
|
-
const { wallet: globalWallet } = useAccountWallet();
|
|
41
|
+
const { wallet: globalWallet, address: globalAddress } = useAccountWallet();
|
|
41
42
|
const { address, isConnected, connector } = useAccount();
|
|
42
43
|
const { connect, connectors, isPending } = useConnect();
|
|
43
44
|
const { disconnect } = useDisconnect();
|
|
@@ -201,58 +202,94 @@ export function CryptoPaymentMethod({
|
|
|
201
202
|
</button>
|
|
202
203
|
|
|
203
204
|
{/* Installed Wallets Section */}
|
|
204
|
-
{isConnected && (
|
|
205
|
+
{(isConnected || globalAddress) && (
|
|
205
206
|
<div className="installed-wallets">
|
|
206
207
|
<h3 className="text-as-primary/80 mb-3 text-sm font-medium">Connected wallets</h3>
|
|
207
208
|
<div className="space-y-2">
|
|
208
209
|
{/* Current Connected Wallet */}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
<div className="flex items-center
|
|
224
|
-
|
|
225
|
-
<img src={globalWallet.meta.icon} alt="Wallet" className="h-10 w-10 rounded-full" />
|
|
226
|
-
) : (
|
|
210
|
+
{isConnected && (
|
|
211
|
+
<button
|
|
212
|
+
onClick={() => {
|
|
213
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
214
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
215
|
+
toast.success(`Selected ${connector?.name || "wallet"}`);
|
|
216
|
+
}}
|
|
217
|
+
className={cn(
|
|
218
|
+
"crypto-payment-method-connect-wallet w-full rounded-xl border p-4 text-left transition-all hover:shadow-md",
|
|
219
|
+
selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET
|
|
220
|
+
? "connected-wallet border-as-brand bg-as-brand/5"
|
|
221
|
+
: "border-as-border-secondary bg-as-surface-primary hover:border-as-secondary/80",
|
|
222
|
+
)}
|
|
223
|
+
>
|
|
224
|
+
<div className="flex items-center justify-between">
|
|
225
|
+
<div className="flex items-center gap-3">
|
|
227
226
|
<div className="wallet-icon flex h-10 w-10 items-center justify-center rounded-full bg-blue-100">
|
|
228
227
|
<Wallet className="h-5 w-5 text-blue-600" />
|
|
229
228
|
</div>
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
<div className="flex flex-col">
|
|
230
|
+
<span className="text-as-primary font-semibold">{connector?.name || "Connected Wallet"}</span>
|
|
231
|
+
<span className="text-as-primary/60 text-sm">{shortenAddress(address || "")}</span>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
<div className="flex items-center gap-2">
|
|
235
|
+
{selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET && (
|
|
236
|
+
<div className="h-2 w-2 rounded-full bg-green-500"></div>
|
|
237
|
+
)}
|
|
238
|
+
<button
|
|
239
|
+
onClick={e => {
|
|
240
|
+
e.stopPropagation();
|
|
241
|
+
disconnect();
|
|
242
|
+
toast.success("Wallet disconnected");
|
|
243
|
+
if (selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
244
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
245
|
+
}
|
|
246
|
+
}}
|
|
247
|
+
className="text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors"
|
|
248
|
+
>
|
|
249
|
+
<X className="h-4 w-4" />
|
|
250
|
+
</button>
|
|
234
251
|
</div>
|
|
235
252
|
</div>
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
+
</button>
|
|
254
|
+
)}
|
|
255
|
+
|
|
256
|
+
{/* Global Wallet (B3 Account) */}
|
|
257
|
+
{globalAddress && (
|
|
258
|
+
<button
|
|
259
|
+
onClick={() => {
|
|
260
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.GLOBAL_WALLET);
|
|
261
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.GLOBAL_WALLET);
|
|
262
|
+
toast.success("Selected B3 Account");
|
|
263
|
+
}}
|
|
264
|
+
className={cn(
|
|
265
|
+
"crypto-payment-method-global-wallet w-full rounded-xl border p-4 text-left transition-all hover:shadow-md",
|
|
266
|
+
selectedPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET
|
|
267
|
+
? "connected-wallet border-as-brand bg-as-brand/5"
|
|
268
|
+
: "border-as-border-secondary bg-as-surface-primary hover:border-as-secondary/80",
|
|
269
|
+
)}
|
|
270
|
+
>
|
|
271
|
+
<div className="flex items-center justify-between">
|
|
272
|
+
<div className="flex items-center gap-3">
|
|
273
|
+
{globalWallet?.meta?.icon ? (
|
|
274
|
+
<img src={globalWallet.meta.icon} alt="Global Account" className="h-10 w-10 rounded-full" />
|
|
275
|
+
) : (
|
|
276
|
+
<div className="wallet-icon flex h-10 w-10 items-center justify-center rounded-full bg-purple-100">
|
|
277
|
+
<Wallet className="h-5 w-5 text-purple-600" />
|
|
278
|
+
</div>
|
|
279
|
+
)}
|
|
280
|
+
<div className="flex flex-col">
|
|
281
|
+
<span className="text-as-primary font-semibold">Global Account</span>
|
|
282
|
+
<span className="text-as-primary/60 text-sm">{shortenAddress(globalAddress || "")}</span>
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
285
|
+
<div className="flex items-center gap-2">
|
|
286
|
+
{selectedPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET && (
|
|
287
|
+
<div className="h-2 w-2 rounded-full bg-green-500"></div>
|
|
288
|
+
)}
|
|
289
|
+
</div>
|
|
253
290
|
</div>
|
|
254
|
-
</
|
|
255
|
-
|
|
291
|
+
</button>
|
|
292
|
+
)}
|
|
256
293
|
</div>
|
|
257
294
|
</div>
|
|
258
295
|
)}
|
|
@@ -240,7 +240,8 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
240
240
|
const [showQRCode, setShowQRCode] = useState(false);
|
|
241
241
|
const { isLoading: txLoading, isSuccess: txSuccess } = useWaitForTransactionReceipt({ hash: txHash });
|
|
242
242
|
|
|
243
|
-
const { switchChainAndExecuteWithEOA, isSwitchingOrExecuting } =
|
|
243
|
+
const { switchChainAndExecuteWithEOA, switchChainAndExecute, isSwitchingOrExecuting } =
|
|
244
|
+
useUnifiedChainSwitchAndExecute();
|
|
244
245
|
|
|
245
246
|
const roundedUpSrcAmount = useMemo(() => {
|
|
246
247
|
// Display the full transfer amount without rounding since users need to see the exact value they're transferring.
|
|
@@ -293,12 +294,18 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
293
294
|
value = BigInt(0);
|
|
294
295
|
}
|
|
295
296
|
|
|
296
|
-
|
|
297
|
+
// Use appropriate execution method based on payment method
|
|
298
|
+
let txHash: string | undefined;
|
|
299
|
+
if (effectiveCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET) {
|
|
300
|
+
txHash = await switchChainAndExecute(order.srcChain, { to, data: txData, value });
|
|
301
|
+
} else {
|
|
302
|
+
txHash = await switchChainAndExecuteWithEOA(order.srcChain, { to, data: txData, value });
|
|
303
|
+
}
|
|
297
304
|
|
|
298
305
|
if (txHash) {
|
|
299
306
|
setTxHash(txHash as `0x${string}`);
|
|
300
307
|
}
|
|
301
|
-
}, [order, switchChainAndExecuteWithEOA, depositDeficit]);
|
|
308
|
+
}, [order, switchChainAndExecuteWithEOA, switchChainAndExecute, depositDeficit, effectiveCryptoPaymentMethod]);
|
|
302
309
|
|
|
303
310
|
// Main payment handler that triggers chain switch and payment
|
|
304
311
|
const handlePayment = async () => {
|
|
@@ -994,7 +1001,8 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
994
1001
|
<>
|
|
995
1002
|
{order.onrampMetadata ? (
|
|
996
1003
|
<PaymentVendorUI order={order} dstTokenSymbol={dstToken.symbol} />
|
|
997
|
-
) : effectiveCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET
|
|
1004
|
+
) : effectiveCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ||
|
|
1005
|
+
effectiveCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET ? (
|
|
998
1006
|
<ConnectWalletPayment
|
|
999
1007
|
order={order}
|
|
1000
1008
|
onPayment={handlePayment}
|
|
@@ -1004,6 +1012,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
1004
1012
|
phantomWalletAddress={phantomWalletAddress}
|
|
1005
1013
|
tournament={tournament}
|
|
1006
1014
|
nft={nft}
|
|
1015
|
+
cryptoPaymentMethod={effectiveCryptoPaymentMethod}
|
|
1007
1016
|
/>
|
|
1008
1017
|
) : effectiveCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (
|
|
1009
1018
|
// Transfer Crypto Payment Method - Show new card-based UI
|