@b3dotfun/sdk 0.0.65 → 0.0.66-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.js +38 -24
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +22 -9
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +44 -13
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.js +41 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +14 -251
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +2 -10
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/index.js +4 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +5 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +16 -10
- package/dist/cjs/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +7 -5
- package/dist/cjs/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.js +13 -9
- package/dist/cjs/anyspend/react/hooks/useCryptoPaymentMethodState.d.ts +42 -0
- package/dist/cjs/anyspend/react/hooks/useCryptoPaymentMethodState.js +51 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +3 -0
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +6 -14
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +21 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +38 -24
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +22 -9
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +44 -13
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.d.ts +11 -0
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.js +38 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +15 -249
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +2 -10
- package/dist/esm/anyspend/react/components/index.d.ts +1 -0
- package/dist/esm/anyspend/react/components/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +5 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +16 -10
- package/dist/esm/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +7 -5
- package/dist/esm/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.js +13 -9
- package/dist/esm/anyspend/react/hooks/useCryptoPaymentMethodState.d.ts +42 -0
- package/dist/esm/anyspend/react/hooks/useCryptoPaymentMethodState.js +48 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +3 -0
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +6 -14
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +21 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnySpendDepositUpside.d.ts +11 -0
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +1 -1
- package/dist/types/anyspend/react/components/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +5 -1
- package/dist/types/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +7 -5
- package/dist/types/anyspend/react/hooks/useCryptoPaymentMethodState.d.ts +42 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +21 -1
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +50 -29
- package/src/anyspend/react/components/AnySpendCustom.tsx +28 -15
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +54 -13
- package/src/anyspend/react/components/AnySpendDepositUpside.tsx +81 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +36 -526
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +2 -13
- package/src/anyspend/react/components/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +24 -12
- package/src/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.ts +20 -12
- package/src/anyspend/react/hooks/useCryptoPaymentMethodState.ts +71 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +3 -0
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +6 -12
- package/src/global-account/react/stores/useModalStore.ts +22 -0
- package/src/styles/index.css +8 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCryptoPaymentMethodState = useCryptoPaymentMethodState;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const CryptoPaymentMethod_1 = require("../components/common/CryptoPaymentMethod");
|
|
6
|
+
/**
|
|
7
|
+
* Custom hook to manage crypto payment method state with dual-state system:
|
|
8
|
+
*
|
|
9
|
+
* - `cryptoPaymentMethod`: Auto-selected based on wallet availability and balance
|
|
10
|
+
* - `selectedCryptoPaymentMethod`: Explicitly selected by user
|
|
11
|
+
* - `effectiveCryptoPaymentMethod`: User selection takes priority over auto-selection
|
|
12
|
+
*
|
|
13
|
+
* This allows automatic payment method suggestions while respecting explicit user choices.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const {
|
|
18
|
+
* cryptoPaymentMethod,
|
|
19
|
+
* setCryptoPaymentMethod,
|
|
20
|
+
* selectedCryptoPaymentMethod,
|
|
21
|
+
* setSelectedCryptoPaymentMethod,
|
|
22
|
+
* effectiveCryptoPaymentMethod,
|
|
23
|
+
* resetPaymentMethods
|
|
24
|
+
* } = useCryptoPaymentMethodState();
|
|
25
|
+
*
|
|
26
|
+
* // Use effectiveCryptoPaymentMethod for display
|
|
27
|
+
* // Use setSelectedCryptoPaymentMethod when user explicitly selects
|
|
28
|
+
* // Call resetPaymentMethods when switching tabs or going back
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function useCryptoPaymentMethodState() {
|
|
32
|
+
// cryptoPaymentMethod: auto-selected based on balance
|
|
33
|
+
const [cryptoPaymentMethod, setCryptoPaymentMethod] = (0, react_1.useState)(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE);
|
|
34
|
+
// selectedCryptoPaymentMethod: explicitly selected by user (NONE means no explicit selection)
|
|
35
|
+
const [selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod] = (0, react_1.useState)(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE);
|
|
36
|
+
// The effective payment method (user selection takes priority over auto-selection)
|
|
37
|
+
const effectiveCryptoPaymentMethod = selectedCryptoPaymentMethod !== CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE ? selectedCryptoPaymentMethod : cryptoPaymentMethod;
|
|
38
|
+
// Helper function to reset both states
|
|
39
|
+
const resetPaymentMethods = () => {
|
|
40
|
+
setCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE);
|
|
41
|
+
setSelectedCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE);
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
cryptoPaymentMethod,
|
|
45
|
+
setCryptoPaymentMethod,
|
|
46
|
+
selectedCryptoPaymentMethod,
|
|
47
|
+
setSelectedCryptoPaymentMethod,
|
|
48
|
+
effectiveCryptoPaymentMethod,
|
|
49
|
+
resetPaymentMethods,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -20,6 +20,7 @@ const RequestPermissions_1 = require("./RequestPermissions/RequestPermissions");
|
|
|
20
20
|
const SignInWithB3Flow_1 = require("./SignInWithB3/SignInWithB3Flow");
|
|
21
21
|
const dialog_1 = require("./ui/dialog");
|
|
22
22
|
const drawer_1 = require("./ui/drawer");
|
|
23
|
+
const AnySpendDepositUpside_1 = require("../../../anyspend/react/components/AnySpendDepositUpside");
|
|
23
24
|
const debug = (0, debug_1.debugB3React)("B3DynamicModal");
|
|
24
25
|
function B3DynamicModal() {
|
|
25
26
|
const { isOpen, setB3ModalOpen, contentType, history, navigateBack } = (0, react_2.useModalStore)();
|
|
@@ -105,6 +106,8 @@ function B3DynamicModal() {
|
|
|
105
106
|
return (0, jsx_runtime_1.jsx)(AnySpendStakeUpside_1.AnySpendStakeUpside, { ...contentType, mode: "modal" });
|
|
106
107
|
case "anySpendStakeUpsideExactIn":
|
|
107
108
|
return (0, jsx_runtime_1.jsx)(AnySpendStakeUpsideExactIn_1.AnySpendStakeUpsideExactIn, { ...contentType, mode: "modal" });
|
|
109
|
+
case "anySpendDepositUpside":
|
|
110
|
+
return (0, jsx_runtime_1.jsx)(AnySpendDepositUpside_1.AnySpendDepositUpside, { ...contentType, mode: "modal" });
|
|
108
111
|
case "anySpendBuySpin":
|
|
109
112
|
return (0, jsx_runtime_1.jsx)(react_1.AnySpendBuySpin, { ...contentType, mode: "modal" });
|
|
110
113
|
case "anySpendSignatureMint":
|
|
@@ -12,7 +12,6 @@ const invariant_1 = __importDefault(require("invariant"));
|
|
|
12
12
|
const react_1 = require("react");
|
|
13
13
|
const sonner_1 = require("sonner");
|
|
14
14
|
const thirdweb_2 = require("thirdweb");
|
|
15
|
-
const react_2 = require("thirdweb/react");
|
|
16
15
|
const viem_1 = require("viem");
|
|
17
16
|
const wagmi_1 = require("wagmi");
|
|
18
17
|
const components_1 = require("../components");
|
|
@@ -25,7 +24,6 @@ const partnerId = String(process.env.PUBLIC_THIRDWEB_PARTNER_ID ||
|
|
|
25
24
|
function useUnifiedChainSwitchAndExecute() {
|
|
26
25
|
const { switchChainAsync } = (0, wagmi_1.useSwitchChain)();
|
|
27
26
|
const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = (0, react_1.useState)(false);
|
|
28
|
-
const activeWallet = (0, react_2.useActiveWallet)();
|
|
29
27
|
const { isActiveSmartWallet, isActiveEOAWallet, connectedEOAWallet } = (0, useAccountWallet_1.useAccountWallet)();
|
|
30
28
|
const { account: aaAccount } = (0, components_1.useB3)();
|
|
31
29
|
// Handle EOA wallet chain switch and execute transaction
|
|
@@ -40,18 +38,18 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
40
38
|
sonner_1.toast.error(`Chain ${targetChainId} is not supported`);
|
|
41
39
|
return;
|
|
42
40
|
}
|
|
43
|
-
const currentChainId =
|
|
41
|
+
const currentChainId = connectedEOAWallet?.getChain()?.id;
|
|
44
42
|
const onCorrectChain = currentChainId === targetChainId;
|
|
45
43
|
// Helper function to execute the transaction
|
|
46
44
|
const executeTransaction = async () => {
|
|
47
|
-
const signer =
|
|
45
|
+
const signer = connectedEOAWallet?.getAccount();
|
|
48
46
|
if (!signer) {
|
|
49
47
|
throw new Error("No account connected");
|
|
50
48
|
}
|
|
51
49
|
// Coinbase Smart Wallet specific chain switching (different behavior from other wallets)
|
|
52
50
|
const walletChain = connectedEOAWallet.getChain();
|
|
53
51
|
if (walletChain?.id !== targetChainId) {
|
|
54
|
-
|
|
52
|
+
connectedEOAWallet?.switchChain((0, supported_1.getThirdwebChain)(targetChainId));
|
|
55
53
|
}
|
|
56
54
|
(0, invariant_1.default)((0, viem_1.isAddress)(params.to), "params.to is not a valid address");
|
|
57
55
|
const result = await signer.sendTransaction({
|
|
@@ -103,7 +101,7 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
103
101
|
finally {
|
|
104
102
|
setIsSwitchingOrExecuting(false);
|
|
105
103
|
}
|
|
106
|
-
}, [connectedEOAWallet,
|
|
104
|
+
}, [connectedEOAWallet, switchChainAsync]);
|
|
107
105
|
// Handle AA wallet transaction (no chain switch needed for AA)
|
|
108
106
|
const handleAASendTransaction = (0, react_1.useCallback)(async (targetChainId, params) => {
|
|
109
107
|
if (!aaAccount) {
|
|
@@ -159,14 +157,8 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
159
157
|
if (isActiveSmartWallet) {
|
|
160
158
|
return handleAASendTransaction(targetChainId, params);
|
|
161
159
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
sonner_1.toast.error("No wallet connected");
|
|
167
|
-
return undefined;
|
|
168
|
-
}
|
|
169
|
-
}, [isActiveSmartWallet, isActiveEOAWallet, handleAASendTransaction, handleEOASwitchChainAndSendTransaction]);
|
|
160
|
+
return handleEOASwitchChainAndSendTransaction(targetChainId, params);
|
|
161
|
+
}, [isActiveSmartWallet, handleAASendTransaction, handleEOASwitchChainAndSendTransaction]);
|
|
170
162
|
return {
|
|
171
163
|
switchChainAndExecute,
|
|
172
164
|
switchChainAndExecuteWithEOA: handleEOASwitchChainAndSendTransaction,
|
|
@@ -260,6 +260,26 @@ export interface AnySpendStakeUpsideExactInProps extends BaseModalProps {
|
|
|
260
260
|
/** Callback function called when the stake is successful */
|
|
261
261
|
onSuccess?: () => void;
|
|
262
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Props for the AnySpend Deposit Upside (Exact In) modal
|
|
265
|
+
* Handles token deposit operations using the custom exact in flow
|
|
266
|
+
*/
|
|
267
|
+
export interface AnySpendDepositUpsideProps extends BaseModalProps {
|
|
268
|
+
/** Modal type identifier */
|
|
269
|
+
type: "anySpendDepositUpside";
|
|
270
|
+
/** Source token address */
|
|
271
|
+
sourceTokenAddress?: string;
|
|
272
|
+
/** Source token address */
|
|
273
|
+
sourceTokenChainId?: number;
|
|
274
|
+
/** Recipient address to deposit tokens for */
|
|
275
|
+
recipientAddress: string;
|
|
276
|
+
/** Deposit contract address */
|
|
277
|
+
depositContractAddress: string;
|
|
278
|
+
/** Token to deposit */
|
|
279
|
+
token: components["schemas"]["Token"];
|
|
280
|
+
/** Callback function called when the deposit is successful */
|
|
281
|
+
onSuccess?: () => void;
|
|
282
|
+
}
|
|
263
283
|
/**
|
|
264
284
|
* Props for the AnySpend Buy Spin modal
|
|
265
285
|
* Handles spin wheel entry purchases
|
|
@@ -360,7 +380,7 @@ export interface ProfileEditorModalProps extends BaseModalProps {
|
|
|
360
380
|
/**
|
|
361
381
|
* Union type of all possible modal content types
|
|
362
382
|
*/
|
|
363
|
-
export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps | ProfileEditorModalProps;
|
|
383
|
+
export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendDepositUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps | ProfileEditorModalProps;
|
|
364
384
|
/**
|
|
365
385
|
* State interface for the modal store
|
|
366
386
|
*/
|
|
@@ -14,6 +14,7 @@ import { parseUnits } from "viem";
|
|
|
14
14
|
import { base, mainnet } from "viem/chains";
|
|
15
15
|
import { useAutoSelectCryptoPaymentMethod } from "../hooks/useAutoSelectCryptoPaymentMethod.js";
|
|
16
16
|
import { useAutoSetActiveWalletFromWagmi } from "../hooks/useAutoSetActiveWalletFromWagmi.js";
|
|
17
|
+
import { useCryptoPaymentMethodState } from "../hooks/useCryptoPaymentMethodState.js";
|
|
17
18
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
|
|
18
19
|
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod.js";
|
|
19
20
|
import { CryptoPaySection } from "./common/CryptoPaySection.js";
|
|
@@ -77,9 +78,8 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
77
78
|
setActivePanel(targetPanel);
|
|
78
79
|
}, [activePanel]);
|
|
79
80
|
const [customRecipients, setCustomRecipients] = useState([]);
|
|
80
|
-
//
|
|
81
|
-
const
|
|
82
|
-
// Add state for selected fiat payment method
|
|
81
|
+
// Payment method state with dual-state system (auto + explicit user selection)
|
|
82
|
+
const { cryptoPaymentMethod, setCryptoPaymentMethod, selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod, effectiveCryptoPaymentMethod, resetPaymentMethods, } = useCryptoPaymentMethodState();
|
|
83
83
|
const [selectedFiatPaymentMethod, setSelectedFiatPaymentMethod] = useState(FiatPaymentMethod.NONE);
|
|
84
84
|
// const [newRecipientAddress, setNewRecipientAddress] = useState("");
|
|
85
85
|
// const recipientInputRef = useRef<HTMLInputElement>(null);
|
|
@@ -95,7 +95,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
95
95
|
});
|
|
96
96
|
const [selectedSrcToken, setSelectedSrcToken] = useState(srcTokenFromUrl);
|
|
97
97
|
const { data: srcTokenMetadata } = useTokenData(selectedSrcToken?.chainId, selectedSrcToken?.address);
|
|
98
|
-
const [srcAmount, setSrcAmount] = useState(searchParams.get("fromAmount") || "0
|
|
98
|
+
const [srcAmount, setSrcAmount] = useState(searchParams.get("fromAmount") || "0");
|
|
99
99
|
// State for onramp amount
|
|
100
100
|
const [srcAmountOnRamp, setSrcAmountOnRamp] = useState(searchParams.get("fromAmount") || "5");
|
|
101
101
|
// State for destination chain/token selection
|
|
@@ -331,8 +331,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
331
331
|
// Auto-select crypto payment method based on available wallets and balance
|
|
332
332
|
useAutoSelectCryptoPaymentMethod({
|
|
333
333
|
paymentType: activeTab,
|
|
334
|
+
cryptoPaymentMethod,
|
|
335
|
+
setCryptoPaymentMethod,
|
|
334
336
|
selectedCryptoPaymentMethod,
|
|
335
|
-
setSelectedCryptoPaymentMethod,
|
|
336
337
|
hasEnoughBalance,
|
|
337
338
|
isBalanceLoading,
|
|
338
339
|
});
|
|
@@ -453,9 +454,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
453
454
|
// Add orderId and payment method to URL for persistence
|
|
454
455
|
const params = new URLSearchParams(searchParams.toString()); // Preserve existing params
|
|
455
456
|
params.set("orderId", orderId);
|
|
456
|
-
if (
|
|
457
|
-
console.log("Setting cryptoPaymentMethod in URL:",
|
|
458
|
-
params.set("cryptoPaymentMethod",
|
|
457
|
+
if (effectiveCryptoPaymentMethod !== CryptoPaymentMethodType.NONE) {
|
|
458
|
+
console.log("Setting cryptoPaymentMethod in URL:", effectiveCryptoPaymentMethod);
|
|
459
|
+
params.set("cryptoPaymentMethod", effectiveCryptoPaymentMethod);
|
|
459
460
|
}
|
|
460
461
|
else {
|
|
461
462
|
console.log("Payment method is NONE, not setting in URL");
|
|
@@ -517,18 +518,18 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
517
518
|
if (activeTab === "crypto") {
|
|
518
519
|
// For crypto: check payment method first, then recipient
|
|
519
520
|
// If no payment method selected, show "Choose payment method"
|
|
520
|
-
if (
|
|
521
|
+
if (effectiveCryptoPaymentMethod === CryptoPaymentMethodType.NONE) {
|
|
521
522
|
return { text: "Choose payment method", disable: false, error: false, loading: false };
|
|
522
523
|
}
|
|
523
524
|
// Check recipient after payment method
|
|
524
525
|
if (!recipientAddress)
|
|
525
526
|
return { text: "Select recipient", disable: false, error: false, loading: false };
|
|
526
527
|
// If payment method selected, show appropriate action
|
|
527
|
-
if (
|
|
528
|
-
|
|
528
|
+
if (effectiveCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ||
|
|
529
|
+
effectiveCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET) {
|
|
529
530
|
return { text: "Swap", disable: false, error: false, loading: false };
|
|
530
531
|
}
|
|
531
|
-
if (
|
|
532
|
+
if (effectiveCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO) {
|
|
532
533
|
return { text: "Continue to payment", disable: false, error: false, loading: false };
|
|
533
534
|
}
|
|
534
535
|
}
|
|
@@ -542,7 +543,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
542
543
|
isCreatingOnrampOrder,
|
|
543
544
|
anyspendQuote,
|
|
544
545
|
activeTab,
|
|
545
|
-
|
|
546
|
+
effectiveCryptoPaymentMethod,
|
|
546
547
|
selectedFiatPaymentMethod,
|
|
547
548
|
]);
|
|
548
549
|
// Handle main button click
|
|
@@ -570,7 +571,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
570
571
|
if (activeTab === "crypto") {
|
|
571
572
|
// For crypto: check payment method first, then recipient
|
|
572
573
|
// If no payment method selected, show payment method selection
|
|
573
|
-
if (
|
|
574
|
+
if (effectiveCryptoPaymentMethod === CryptoPaymentMethodType.NONE) {
|
|
574
575
|
console.log("No payment method selected, showing selection panel");
|
|
575
576
|
navigateToPanel(PanelView.CRYPTO_PAYMENT_METHOD, "forward");
|
|
576
577
|
return;
|
|
@@ -582,11 +583,11 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
582
583
|
}
|
|
583
584
|
invariant(recipientAddress, "Recipient address is not found");
|
|
584
585
|
// If payment method is selected, create order with payment method info
|
|
585
|
-
if (
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
console.log("Creating crypto order with payment method:",
|
|
589
|
-
await handleCryptoSwap(
|
|
586
|
+
if (effectiveCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ||
|
|
587
|
+
effectiveCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET ||
|
|
588
|
+
effectiveCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO) {
|
|
589
|
+
console.log("Creating crypto order with payment method:", effectiveCryptoPaymentMethod);
|
|
590
|
+
await handleCryptoSwap(effectiveCryptoPaymentMethod);
|
|
590
591
|
return;
|
|
591
592
|
}
|
|
592
593
|
}
|
|
@@ -760,12 +761,21 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
760
761
|
};
|
|
761
762
|
}, [activePanel, navigateBack]);
|
|
762
763
|
const historyView = (_jsx("div", { className: "mx-auto flex w-[560px] max-w-full flex-col items-center", children: _jsx(OrderHistory, { mode: mode, onBack: navigateBack, onSelectOrder: onSelectOrder }) }));
|
|
763
|
-
const orderDetailsView = (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTxs: oat.data.relayTxs, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, selectedCryptoPaymentMethod:
|
|
764
|
+
const orderDetailsView = (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTxs: oat.data.relayTxs, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod, onPaymentMethodChange: method => {
|
|
765
|
+
// When user explicitly changes payment method, set it as selected
|
|
766
|
+
setSelectedCryptoPaymentMethod(method);
|
|
767
|
+
}, points: oat.data.points || undefined, onBack: () => {
|
|
764
768
|
setOrderId(undefined);
|
|
765
769
|
navigateBack();
|
|
766
|
-
|
|
770
|
+
// Reset payment methods when going back
|
|
771
|
+
resetPaymentMethods();
|
|
767
772
|
} })) }) }));
|
|
768
|
-
const mainView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && (_jsxs("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && (_jsx("div", { className: "relative", children: _jsx("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), _jsx("div", { children: _jsxs("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), _jsx(TabSection, { activeTab: activeTab, setActiveTab:
|
|
773
|
+
const mainView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && (_jsxs("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && (_jsx("div", { className: "relative", children: _jsx("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), _jsx("div", { children: _jsxs("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), _jsx(TabSection, { activeTab: activeTab, setActiveTab: tab => {
|
|
774
|
+
setActiveTab(tab);
|
|
775
|
+
// Reset payment methods when switching tabs
|
|
776
|
+
resetPaymentMethods();
|
|
777
|
+
setSelectedFiatPaymentMethod(FiatPaymentMethod.NONE);
|
|
778
|
+
}, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? (_jsx(CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, isSrcInputDirty: isSrcInputDirty, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => navigateToPanel(PanelView.CRYPTO_PAYMENT_METHOD, "forward"), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect, onShowFeeDetail: () => navigateToPanel(PanelView.FEE_DETAIL, "forward") })) : (_jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: (panelIndex) => {
|
|
769
779
|
// Map panel index to navigation with direction
|
|
770
780
|
const panelsWithForwardNav = [PanelView.FIAT_PAYMENT_METHOD, PanelView.RECIPIENT_SELECTION];
|
|
771
781
|
if (panelsWithForwardNav.includes(panelIndex)) {
|
|
@@ -796,7 +806,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
796
806
|
}, children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab === "crypto" && (_jsx(CryptoReceiveSection, { isDepositMode: false, isBuyMode: isBuyMode, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => navigateToPanel(PanelView.RECIPIENT_SELECTION, "forward"), setRecipientAddress: setRecipientAddress, recipientAddressFromProps: recipientAddressFromProps, globalAddress: globalAddress, dstAmount: dstAmount, dstToken: selectedDstToken, selectedDstChainId: selectedDstChainId, setSelectedDstChainId: setSelectedDstChainId, setSelectedDstToken: setSelectedDstToken, isSrcInputDirty: isSrcInputDirty, onChangeDstAmount: value => {
|
|
797
807
|
setIsSrcInputDirty(false);
|
|
798
808
|
setDstAmount(value);
|
|
799
|
-
}, anyspendQuote: anyspendQuote, onShowPointsDetail: () => navigateToPanel(PanelView.POINTS_DETAIL, "forward"), onShowFeeDetail: () => navigateToPanel(PanelView.FEE_DETAIL, "forward"), selectedCryptoPaymentMethod:
|
|
809
|
+
}, anyspendQuote: anyspendQuote, onShowPointsDetail: () => navigateToPanel(PanelView.POINTS_DETAIL, "forward"), onShowFeeDetail: () => navigateToPanel(PanelView.FEE_DETAIL, "forward"), selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }))] }), _jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: cn("mt-4 flex w-full max-w-[460px] flex-col gap-2"), children: [_jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: cn("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: _jsxs("div", { className: "flex items-center justify-center gap-2", children: [btnInfo.loading && _jsx(Loader2, { className: "h-4 w-4 animate-spin" }), btnInfo.text] }) }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? (_jsxs(Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [_jsx(HistoryIcon, { className: "h-4 w-4" }), " ", _jsx("span", { className: "pr-4", children: "Transaction History" })] })) : null] })] }));
|
|
800
810
|
const onrampPaymentView = (_jsx(PanelOnrampPayment, { srcAmountOnRamp: srcAmountOnRamp, recipientName: recipientName || undefined, recipientAddress: recipientAddress, isBuyMode: isBuyMode, destinationTokenChainId: destinationTokenChainId, destinationTokenAddress: destinationTokenAddress, selectedDstChainId: selectedDstChainId, selectedDstToken: selectedDstToken, orderType: "swap", anyspendQuote: anyspendQuote, globalAddress: globalAddress, onOrderCreated: orderId => {
|
|
801
811
|
setOrderId(orderId);
|
|
802
812
|
navigateToPanel(PanelView.ORDER_DETAILS, "forward");
|
|
@@ -816,7 +826,11 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
816
826
|
setRecipientAddress(address);
|
|
817
827
|
navigateBack();
|
|
818
828
|
} }));
|
|
819
|
-
const cryptoPaymentMethodView = (_jsx(CryptoPaymentMethod, { globalAddress: globalAddress, globalWallet: globalWallet, selectedPaymentMethod:
|
|
829
|
+
const cryptoPaymentMethodView = (_jsx(CryptoPaymentMethod, { globalAddress: globalAddress, globalWallet: globalWallet, selectedPaymentMethod: effectiveCryptoPaymentMethod, setSelectedPaymentMethod: method => {
|
|
830
|
+
// When user explicitly selects a payment method, save it
|
|
831
|
+
setSelectedCryptoPaymentMethod(method);
|
|
832
|
+
}, isCreatingOrder: isCreatingOrder, onBack: navigateBack, onSelectPaymentMethod: (method) => {
|
|
833
|
+
// When user explicitly selects a payment method, save it and go back
|
|
820
834
|
setSelectedCryptoPaymentMethod(method);
|
|
821
835
|
navigateBack();
|
|
822
836
|
} }));
|
|
@@ -15,6 +15,7 @@ import { toast } from "sonner";
|
|
|
15
15
|
import { base } from "viem/chains";
|
|
16
16
|
import { useFeatureFlags } from "../contexts/FeatureFlagsContext.js";
|
|
17
17
|
import { useAutoSetActiveWalletFromWagmi } from "../hooks/useAutoSetActiveWalletFromWagmi.js";
|
|
18
|
+
import { useCryptoPaymentMethodState } from "../hooks/useCryptoPaymentMethodState.js";
|
|
18
19
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
|
|
19
20
|
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod.js";
|
|
20
21
|
import { FeeBreakDown } from "./common/FeeBreakDown.js";
|
|
@@ -115,8 +116,9 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
115
116
|
useAutoSetActiveWalletFromWagmi();
|
|
116
117
|
const [activePanel, setActivePanel] = useState(loadOrder ? PanelView.ORDER_DETAILS : PanelView.CONFIRM_ORDER);
|
|
117
118
|
const [activeTab, setActiveTab] = useState(activeTabProps);
|
|
118
|
-
//
|
|
119
|
-
|
|
119
|
+
// Payment method state with dual-state system (auto + explicit user selection)
|
|
120
|
+
// Note: AnySpendCustom doesn't use auto-selection, only explicit user selection
|
|
121
|
+
const { setSelectedCryptoPaymentMethod, effectiveCryptoPaymentMethod, resetPaymentMethods } = useCryptoPaymentMethodState();
|
|
120
122
|
const [selectedFiatPaymentMethod, setSelectedFiatPaymentMethod] = useState(FiatPaymentMethod.NONE);
|
|
121
123
|
// Get current user's wallet
|
|
122
124
|
const currentWallet = useAccountWallet();
|
|
@@ -365,7 +367,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
365
367
|
return;
|
|
366
368
|
}
|
|
367
369
|
// Check payment method selection for crypto tab
|
|
368
|
-
if (activeTab === "crypto" &&
|
|
370
|
+
if (activeTab === "crypto" && effectiveCryptoPaymentMethod === CryptoPaymentMethodType.NONE) {
|
|
369
371
|
setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD);
|
|
370
372
|
return;
|
|
371
373
|
}
|
|
@@ -440,9 +442,14 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
440
442
|
const historyView = (_jsx("div", { className: cn("mx-auto flex w-full max-w-2xl flex-col items-center p-5", mode === "modal" && "bg-b3-react-background"), children: _jsx(OrderHistory, { mode: mode, onBack: () => {
|
|
441
443
|
setActivePanel(PanelView.HISTORY);
|
|
442
444
|
}, onSelectOrder: onSelectOrder }) }));
|
|
443
|
-
const orderDetailsView = (_jsxs("div", { className: cn("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background rounded-xl"), children: [oat && (_jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTxs: oat.data.relayTxs, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: activeTab === "fiat" ? CryptoPaymentMethodType.NONE :
|
|
445
|
+
const orderDetailsView = (_jsxs("div", { className: cn("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background rounded-xl"), children: [oat && (_jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTxs: oat.data.relayTxs, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: activeTab === "fiat" ? CryptoPaymentMethodType.NONE : effectiveCryptoPaymentMethod, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod, onPaymentMethodChange: method => {
|
|
446
|
+
// When user explicitly changes payment method, set it as selected
|
|
447
|
+
setSelectedCryptoPaymentMethod(method);
|
|
448
|
+
}, onBack: () => {
|
|
444
449
|
setOrderId(undefined);
|
|
445
450
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
451
|
+
// Reset payment methods when going back
|
|
452
|
+
resetPaymentMethods();
|
|
446
453
|
// Remove orderId from URL when canceling
|
|
447
454
|
const params = new URLSearchParams(searchParams.toString());
|
|
448
455
|
params.delete("orderId");
|
|
@@ -462,17 +469,19 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
462
469
|
// Confirm order view.
|
|
463
470
|
const confirmOrderView = (_jsxs("div", { className: "relative mx-auto flex w-full flex-col items-center", children: [header({ anyspendPrice: anyspendQuote, isLoadingAnyspendPrice: isLoadingAnyspendQuote }), _jsxs(Tabs, { value: activeTab, onValueChange: value => setActiveTab(value), className: "bg-b3-react-background max-h-[60dvh] w-full overflow-y-auto p-5", children: [_jsx("div", { className: "w-full", children: _jsxs("div", { className: "bg-as-surface-secondary relative mb-4 grid h-10 grid-cols-2 rounded-xl", children: [_jsx("div", { className: cn("bg-as-brand absolute bottom-0 left-0 top-0 z-0 rounded-xl transition-transform duration-100", "h-full w-1/2", activeTab === "fiat" ? "translate-x-full" : "translate-x-0"), style: { willChange: "transform" } }), _jsx("button", { className: cn("relative z-10 h-full w-full rounded-xl px-3 text-sm font-medium transition-colors duration-100", activeTab === "crypto" ? "text-white" : "text-as-primary/70 hover:bg-as-on-surface-2 bg-transparent"), onClick: () => {
|
|
464
471
|
setActiveTab("crypto");
|
|
465
|
-
|
|
472
|
+
// Reset payment methods when switching tabs
|
|
473
|
+
resetPaymentMethods();
|
|
466
474
|
setSelectedFiatPaymentMethod(FiatPaymentMethod.NONE);
|
|
467
475
|
}, children: "Pay with crypto" }), isOnrampSupported ? (_jsx("button", { className: cn("relative z-10 h-full w-full rounded-xl px-3 text-sm font-medium transition-colors duration-100", activeTab === "fiat" ? "text-white" : "text-as-primary/70 hover:bg-as-on-surface-2 bg-transparent"), onClick: () => {
|
|
468
476
|
setActiveTab("fiat");
|
|
469
|
-
|
|
477
|
+
// Reset payment methods when switching tabs
|
|
478
|
+
resetPaymentMethods();
|
|
470
479
|
setSelectedFiatPaymentMethod(FiatPaymentMethod.NONE);
|
|
471
480
|
}, children: "Pay with fiat" })) : (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { className: cn("relative z-10 h-full w-full rounded-xl px-3 text-sm font-medium transition-colors duration-100", "text-as-primary/50 cursor-not-allowed bg-transparent"), disabled: true, children: "Pay with fiat" }) }), _jsx(TooltipContent, { children: _jsx("span", { className: "text-as-primary w-[140px]", children: "Fiat payments are not supported for this amount" }) })] }))] }) }), _jsx(TabsContent, { value: "crypto", children: _jsxs("div", { className: "mt-2 flex flex-col gap-6", children: [_jsxs("div", { className: "border-as-border-secondary bg-as-surface-secondary flex w-full flex-col gap-4 rounded-xl border p-4", children: [_jsxs(motion.div, { initial: false, animate: {
|
|
472
481
|
opacity: hasMounted ? 1 : 0,
|
|
473
482
|
y: hasMounted ? 0 : 20,
|
|
474
483
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
475
|
-
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children:
|
|
484
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: effectiveCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (_jsxs(_Fragment, { children: [connectedAddress ? (_jsx(_Fragment, { children: _jsx("span", { className: "text-as-tertiarry flex items-center gap-1", children: connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress || "") }) })) : ("Connect wallet"), _jsx(ChevronRight, { className: "h-4 w-4" })] })) : effectiveCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (_jsxs(_Fragment, { children: ["Transfer crypto", _jsx(ChevronRight, { className: "h-4 w-4" })] })) : (_jsxs(_Fragment, { children: ["Select payment method", _jsx(ChevronRight, { className: "h-4 w-4" })] })) })] }), _jsx("div", { className: "divider w-full" }), recipientSection, _jsx("div", { className: "divider w-full" }), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs(motion.div, { initial: false, animate: {
|
|
476
485
|
opacity: hasMounted ? 1 : 0,
|
|
477
486
|
y: hasMounted ? 0 : 20,
|
|
478
487
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -488,7 +497,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
488
497
|
opacity: hasMounted ? 1 : 0,
|
|
489
498
|
y: hasMounted ? 0 : 20,
|
|
490
499
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
491
|
-
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", disabled: isCreatingOrder || isLoadingAnyspendQuote || !anyspendQuote, onClick: () => handleConfirmOrder(), className: "relative w-full", children: isCreatingOrder ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Creating order..." })] })) : isLoadingAnyspendQuote ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Loading quote..." })] })) : !recipientAddress ? ("Select recipient") :
|
|
500
|
+
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", disabled: isCreatingOrder || isLoadingAnyspendQuote || !anyspendQuote, onClick: () => handleConfirmOrder(), className: "relative w-full", children: isCreatingOrder ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Creating order..." })] })) : isLoadingAnyspendQuote ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Loading quote..." })] })) : !recipientAddress ? ("Select recipient") : effectiveCryptoPaymentMethod === CryptoPaymentMethodType.NONE ? ("Choose payment method") : anyspendQuote ? (_jsxs(_Fragment, { children: [_jsx("span", { children: "Checkout" }), _jsx(ChevronRightCircle, { className: "absolute right-0 top-1/2 size-6 -translate-y-1/2 opacity-70" })] })) : ("No quote found") }) }) })] }) }), _jsx(TabsContent, { value: "fiat", children: _jsxs("div", { className: "mt-2 flex flex-col gap-6", children: [_jsxs("div", { className: "border-as-border-secondary bg-as-surface-secondary flex w-full flex-col gap-4 rounded-xl border p-4", children: [_jsxs(motion.div, { initial: false, animate: {
|
|
492
501
|
opacity: hasMounted ? 1 : 0,
|
|
493
502
|
y: hasMounted ? 0 : 20,
|
|
494
503
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -515,7 +524,11 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
515
524
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
516
525
|
} }) }));
|
|
517
526
|
// Crypto payment method view
|
|
518
|
-
const cryptoPaymentMethodView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: _jsx(CryptoPaymentMethod, { globalAddress: currentWallet?.wallet?.address, globalWallet: currentWallet?.wallet, selectedPaymentMethod:
|
|
527
|
+
const cryptoPaymentMethodView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: _jsx(CryptoPaymentMethod, { globalAddress: currentWallet?.wallet?.address, globalWallet: currentWallet?.wallet, selectedPaymentMethod: effectiveCryptoPaymentMethod, setSelectedPaymentMethod: method => {
|
|
528
|
+
// When user explicitly selects a payment method, save it
|
|
529
|
+
setSelectedCryptoPaymentMethod(method);
|
|
530
|
+
}, isCreatingOrder: isCreatingOrder, onBack: () => setActivePanel(PanelView.CONFIRM_ORDER), onSelectPaymentMethod: (method) => {
|
|
531
|
+
// When user explicitly selects a payment method, save it and go back
|
|
519
532
|
setSelectedCryptoPaymentMethod(method);
|
|
520
533
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
521
534
|
} }) }));
|
|
@@ -24,7 +24,9 @@ export interface AnySpendCustomExactInProps {
|
|
|
24
24
|
}) => void;
|
|
25
25
|
customUsdInputValues?: string[];
|
|
26
26
|
preferEoa?: boolean;
|
|
27
|
-
customExactInConfig
|
|
27
|
+
customExactInConfig?: CustomExactInConfig;
|
|
28
|
+
orderType?: "hype_duel" | "custom_exact_in";
|
|
29
|
+
minDestinationAmount?: number;
|
|
28
30
|
header?: ({ anyspendPrice, isLoadingAnyspendPrice, }: {
|
|
29
31
|
anyspendPrice: GetQuoteResponse | undefined;
|
|
30
32
|
isLoadingAnyspendPrice: boolean;
|