@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
|
@@ -19,12 +19,13 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
19
19
|
import { toast } from "sonner";
|
|
20
20
|
import { parseUnits } from "viem";
|
|
21
21
|
import { base, mainnet } from "viem/chains";
|
|
22
|
-
import { useAccount } from "wagmi";
|
|
23
22
|
import { components } from "../../types/api";
|
|
24
23
|
import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMethod";
|
|
25
24
|
import { FiatPaymentMethod } from "../components/common/FiatPaymentMethod";
|
|
26
25
|
import { useAutoSelectCryptoPaymentMethod } from "./useAutoSelectCryptoPaymentMethod";
|
|
27
26
|
import { useAutoSetActiveWalletFromWagmi } from "./useAutoSetActiveWalletFromWagmi";
|
|
27
|
+
import { useConnectedWalletDisplay } from "./useConnectedWalletDisplay";
|
|
28
|
+
import { useCryptoPaymentMethodState } from "./useCryptoPaymentMethodState";
|
|
28
29
|
|
|
29
30
|
export enum PanelView {
|
|
30
31
|
MAIN,
|
|
@@ -85,22 +86,28 @@ export function useAnyspendFlow({
|
|
|
85
86
|
const defaultDstToken = B3_TOKEN; // Default destination token
|
|
86
87
|
const [selectedSrcToken, setSelectedSrcToken] = useState<components["schemas"]["Token"]>(defaultSrcToken);
|
|
87
88
|
const [selectedDstToken, setSelectedDstToken] = useState<components["schemas"]["Token"]>(defaultDstToken);
|
|
88
|
-
const [srcAmount, setSrcAmount] = useState<string>(paymentType === "fiat" ? "5" : "0
|
|
89
|
+
const [srcAmount, setSrcAmount] = useState<string>(paymentType === "fiat" ? "5" : "0");
|
|
89
90
|
const [dstAmount, setDstAmount] = useState<string>("");
|
|
90
91
|
const [isSrcInputDirty, setIsSrcInputDirty] = useState(true);
|
|
91
92
|
|
|
92
93
|
// Derive destination chain ID from token or prop (cannot change)
|
|
93
94
|
const selectedDstChainId = destinationTokenChainId || selectedDstToken.chainId;
|
|
94
95
|
|
|
95
|
-
// Payment method state
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
// Payment method state with dual-state system (auto + explicit user selection)
|
|
97
|
+
const {
|
|
98
|
+
cryptoPaymentMethod,
|
|
99
|
+
setCryptoPaymentMethod,
|
|
100
|
+
selectedCryptoPaymentMethod,
|
|
101
|
+
setSelectedCryptoPaymentMethod,
|
|
102
|
+
effectiveCryptoPaymentMethod,
|
|
103
|
+
resetPaymentMethods,
|
|
104
|
+
} = useCryptoPaymentMethodState();
|
|
105
|
+
|
|
99
106
|
const [selectedFiatPaymentMethod, setSelectedFiatPaymentMethod] = useState<FiatPaymentMethod>(FiatPaymentMethod.NONE);
|
|
100
107
|
|
|
101
108
|
// Recipient state
|
|
102
109
|
const { address: globalAddress } = useAccountWallet();
|
|
103
|
-
const {
|
|
110
|
+
const { walletAddress } = useConnectedWalletDisplay(effectiveCryptoPaymentMethod);
|
|
104
111
|
const [selectedRecipientAddress, setSelectedRecipientAddress] = useState<string | undefined>(recipientAddress);
|
|
105
112
|
const recipientProfile = useProfile({ address: selectedRecipientAddress, fresh: true });
|
|
106
113
|
const recipientName = recipientProfile.data?.name;
|
|
@@ -118,7 +125,7 @@ export function useAnyspendFlow({
|
|
|
118
125
|
// Check token balance for crypto payments
|
|
119
126
|
const { rawBalance, isLoading: isBalanceLoading } = useTokenBalance({
|
|
120
127
|
token: selectedSrcToken,
|
|
121
|
-
address:
|
|
128
|
+
address: walletAddress,
|
|
122
129
|
});
|
|
123
130
|
|
|
124
131
|
// Check if user has enough balance
|
|
@@ -135,8 +142,9 @@ export function useAnyspendFlow({
|
|
|
135
142
|
// Auto-select crypto payment method based on available wallets and balance
|
|
136
143
|
useAutoSelectCryptoPaymentMethod({
|
|
137
144
|
paymentType,
|
|
145
|
+
cryptoPaymentMethod,
|
|
146
|
+
setCryptoPaymentMethod,
|
|
138
147
|
selectedCryptoPaymentMethod,
|
|
139
|
-
setSelectedCryptoPaymentMethod,
|
|
140
148
|
hasEnoughBalance,
|
|
141
149
|
isBalanceLoading,
|
|
142
150
|
});
|
|
@@ -248,9 +256,9 @@ export function useAnyspendFlow({
|
|
|
248
256
|
if (!disableUrlParamManagement) {
|
|
249
257
|
const params = new URLSearchParams(searchParams.toString()); // Preserve existing params
|
|
250
258
|
params.set("orderId", newOrderId);
|
|
251
|
-
if (
|
|
252
|
-
console.log("Setting cryptoPaymentMethod in URL:",
|
|
253
|
-
params.set("cryptoPaymentMethod",
|
|
259
|
+
if (effectiveCryptoPaymentMethod !== CryptoPaymentMethodType.NONE) {
|
|
260
|
+
console.log("Setting cryptoPaymentMethod in URL:", effectiveCryptoPaymentMethod);
|
|
261
|
+
params.set("cryptoPaymentMethod", effectiveCryptoPaymentMethod);
|
|
254
262
|
} else {
|
|
255
263
|
console.log("Payment method is NONE, not setting in URL");
|
|
256
264
|
}
|
|
@@ -316,8 +324,12 @@ export function useAnyspendFlow({
|
|
|
316
324
|
isSrcInputDirty,
|
|
317
325
|
setIsSrcInputDirty,
|
|
318
326
|
// Payment methods
|
|
327
|
+
cryptoPaymentMethod,
|
|
328
|
+
setCryptoPaymentMethod,
|
|
319
329
|
selectedCryptoPaymentMethod,
|
|
320
330
|
setSelectedCryptoPaymentMethod,
|
|
331
|
+
effectiveCryptoPaymentMethod,
|
|
332
|
+
resetPaymentMethods,
|
|
321
333
|
selectedFiatPaymentMethod,
|
|
322
334
|
setSelectedFiatPaymentMethod,
|
|
323
335
|
// Recipient
|
|
@@ -5,10 +5,12 @@ import { useConnectedWalletDisplay } from "./useConnectedWalletDisplay";
|
|
|
5
5
|
interface UseAutoSelectCryptoPaymentMethodParams {
|
|
6
6
|
/** Current payment type (crypto or fiat) */
|
|
7
7
|
paymentType?: "crypto" | "fiat";
|
|
8
|
-
/**
|
|
8
|
+
/** Auto-selected payment method based on balance (not used in hook logic, but part of state management) */
|
|
9
|
+
cryptoPaymentMethod: CryptoPaymentMethodType;
|
|
10
|
+
/** Function to update the auto-selected payment method */
|
|
11
|
+
setCryptoPaymentMethod: (method: CryptoPaymentMethodType) => void;
|
|
12
|
+
/** User explicitly selected payment method (NONE means no explicit selection) */
|
|
9
13
|
selectedCryptoPaymentMethod: CryptoPaymentMethodType;
|
|
10
|
-
/** Function to update the selected payment method */
|
|
11
|
-
setSelectedCryptoPaymentMethod: (method: CryptoPaymentMethodType) => void;
|
|
12
14
|
/** Whether user has enough balance to pay */
|
|
13
15
|
hasEnoughBalance: boolean;
|
|
14
16
|
/** Whether balance is still loading */
|
|
@@ -20,7 +22,7 @@ interface UseAutoSelectCryptoPaymentMethodParams {
|
|
|
20
22
|
* based on available wallets and balance.
|
|
21
23
|
*
|
|
22
24
|
* Auto-selection logic:
|
|
23
|
-
* - Only auto-selects when
|
|
25
|
+
* - Only auto-selects when selectedCryptoPaymentMethod is NONE (user hasn't explicitly chosen)
|
|
24
26
|
* - If EOA/Wagmi wallet connected + has balance → CONNECT_WALLET
|
|
25
27
|
* - If EOA/Wagmi wallet connected + insufficient balance → TRANSFER_CRYPTO
|
|
26
28
|
* - If only Global wallet available → GLOBAL_WALLET
|
|
@@ -28,8 +30,9 @@ interface UseAutoSelectCryptoPaymentMethodParams {
|
|
|
28
30
|
*/
|
|
29
31
|
export function useAutoSelectCryptoPaymentMethod({
|
|
30
32
|
paymentType = "crypto",
|
|
33
|
+
cryptoPaymentMethod: _cryptoPaymentMethod,
|
|
34
|
+
setCryptoPaymentMethod,
|
|
31
35
|
selectedCryptoPaymentMethod,
|
|
32
|
-
setSelectedCryptoPaymentMethod,
|
|
33
36
|
hasEnoughBalance,
|
|
34
37
|
isBalanceLoading,
|
|
35
38
|
}: UseAutoSelectCryptoPaymentMethodParams) {
|
|
@@ -37,8 +40,13 @@ export function useAutoSelectCryptoPaymentMethod({
|
|
|
37
40
|
const { suggestedPaymentMethod } = useConnectedWalletDisplay(selectedCryptoPaymentMethod);
|
|
38
41
|
|
|
39
42
|
useEffect(() => {
|
|
40
|
-
// Only auto-select when on crypto payment type
|
|
41
|
-
if (paymentType !== "crypto"
|
|
43
|
+
// Only auto-select when on crypto payment type
|
|
44
|
+
if (paymentType !== "crypto") {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Only auto-switch if user hasn't explicitly selected a payment method
|
|
49
|
+
if (selectedCryptoPaymentMethod !== CryptoPaymentMethodType.NONE) {
|
|
42
50
|
return;
|
|
43
51
|
}
|
|
44
52
|
|
|
@@ -48,25 +56,25 @@ export function useAutoSelectCryptoPaymentMethod({
|
|
|
48
56
|
// Otherwise, default to TRANSFER_CRYPTO if balance is insufficient
|
|
49
57
|
if (!isBalanceLoading) {
|
|
50
58
|
if (hasEnoughBalance && suggestedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
51
|
-
|
|
59
|
+
setCryptoPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
52
60
|
} else if (!hasEnoughBalance && suggestedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
53
61
|
// Wallet connected but insufficient balance - suggest transfer
|
|
54
|
-
|
|
62
|
+
setCryptoPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
55
63
|
} else {
|
|
56
64
|
// Use suggested method (e.g., GLOBAL_WALLET)
|
|
57
|
-
|
|
65
|
+
setCryptoPaymentMethod(suggestedPaymentMethod);
|
|
58
66
|
}
|
|
59
67
|
} else {
|
|
60
68
|
// Balance still loading, use suggested method
|
|
61
|
-
|
|
69
|
+
setCryptoPaymentMethod(suggestedPaymentMethod);
|
|
62
70
|
}
|
|
63
71
|
}
|
|
64
72
|
}, [
|
|
65
73
|
paymentType,
|
|
74
|
+
setCryptoPaymentMethod,
|
|
66
75
|
selectedCryptoPaymentMethod,
|
|
67
76
|
suggestedPaymentMethod,
|
|
68
77
|
hasEnoughBalance,
|
|
69
78
|
isBalanceLoading,
|
|
70
|
-
setSelectedCryptoPaymentMethod,
|
|
71
79
|
]);
|
|
72
80
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMethod";
|
|
3
|
+
|
|
4
|
+
interface UseCryptoPaymentMethodStateResult {
|
|
5
|
+
/** Auto-selected payment method based on balance */
|
|
6
|
+
cryptoPaymentMethod: CryptoPaymentMethodType;
|
|
7
|
+
/** Function to update the auto-selected payment method */
|
|
8
|
+
setCryptoPaymentMethod: (method: CryptoPaymentMethodType) => void;
|
|
9
|
+
/** User explicitly selected payment method (NONE means no explicit selection) */
|
|
10
|
+
selectedCryptoPaymentMethod: CryptoPaymentMethodType;
|
|
11
|
+
/** Function to update the user-selected payment method */
|
|
12
|
+
setSelectedCryptoPaymentMethod: (method: CryptoPaymentMethodType) => void;
|
|
13
|
+
/** Effective payment method (user selection takes priority over auto-selection) */
|
|
14
|
+
effectiveCryptoPaymentMethod: CryptoPaymentMethodType;
|
|
15
|
+
/** Reset both payment method states to NONE */
|
|
16
|
+
resetPaymentMethods: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Custom hook to manage crypto payment method state with dual-state system:
|
|
21
|
+
*
|
|
22
|
+
* - `cryptoPaymentMethod`: Auto-selected based on wallet availability and balance
|
|
23
|
+
* - `selectedCryptoPaymentMethod`: Explicitly selected by user
|
|
24
|
+
* - `effectiveCryptoPaymentMethod`: User selection takes priority over auto-selection
|
|
25
|
+
*
|
|
26
|
+
* This allows automatic payment method suggestions while respecting explicit user choices.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const {
|
|
31
|
+
* cryptoPaymentMethod,
|
|
32
|
+
* setCryptoPaymentMethod,
|
|
33
|
+
* selectedCryptoPaymentMethod,
|
|
34
|
+
* setSelectedCryptoPaymentMethod,
|
|
35
|
+
* effectiveCryptoPaymentMethod,
|
|
36
|
+
* resetPaymentMethods
|
|
37
|
+
* } = useCryptoPaymentMethodState();
|
|
38
|
+
*
|
|
39
|
+
* // Use effectiveCryptoPaymentMethod for display
|
|
40
|
+
* // Use setSelectedCryptoPaymentMethod when user explicitly selects
|
|
41
|
+
* // Call resetPaymentMethods when switching tabs or going back
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function useCryptoPaymentMethodState(): UseCryptoPaymentMethodStateResult {
|
|
45
|
+
// cryptoPaymentMethod: auto-selected based on balance
|
|
46
|
+
const [cryptoPaymentMethod, setCryptoPaymentMethod] = useState<CryptoPaymentMethodType>(CryptoPaymentMethodType.NONE);
|
|
47
|
+
|
|
48
|
+
// selectedCryptoPaymentMethod: explicitly selected by user (NONE means no explicit selection)
|
|
49
|
+
const [selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod] = useState<CryptoPaymentMethodType>(
|
|
50
|
+
CryptoPaymentMethodType.NONE,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
// The effective payment method (user selection takes priority over auto-selection)
|
|
54
|
+
const effectiveCryptoPaymentMethod =
|
|
55
|
+
selectedCryptoPaymentMethod !== CryptoPaymentMethodType.NONE ? selectedCryptoPaymentMethod : cryptoPaymentMethod;
|
|
56
|
+
|
|
57
|
+
// Helper function to reset both states
|
|
58
|
+
const resetPaymentMethods = () => {
|
|
59
|
+
setCryptoPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
60
|
+
setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
cryptoPaymentMethod,
|
|
65
|
+
setCryptoPaymentMethod,
|
|
66
|
+
selectedCryptoPaymentMethod,
|
|
67
|
+
setSelectedCryptoPaymentMethod,
|
|
68
|
+
effectiveCryptoPaymentMethod,
|
|
69
|
+
resetPaymentMethods,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -26,6 +26,7 @@ import { RequestPermissions } from "./RequestPermissions/RequestPermissions";
|
|
|
26
26
|
import { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
27
27
|
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "./ui/dialog";
|
|
28
28
|
import { Drawer, DrawerContent, DrawerDescription, DrawerTitle } from "./ui/drawer";
|
|
29
|
+
import { AnySpendDepositUpside } from "@b3dotfun/sdk/anyspend/react/components/AnySpendDepositUpside";
|
|
29
30
|
|
|
30
31
|
const debug = debugB3React("B3DynamicModal");
|
|
31
32
|
|
|
@@ -130,6 +131,8 @@ export function B3DynamicModal() {
|
|
|
130
131
|
return <AnySpendStakeUpside {...contentType} mode="modal" />;
|
|
131
132
|
case "anySpendStakeUpsideExactIn":
|
|
132
133
|
return <AnySpendStakeUpsideExactIn {...contentType} mode="modal" />;
|
|
134
|
+
case "anySpendDepositUpside":
|
|
135
|
+
return <AnySpendDepositUpside {...contentType} mode="modal" />;
|
|
133
136
|
case "anySpendBuySpin":
|
|
134
137
|
return <AnySpendBuySpin {...contentType} mode="modal" />;
|
|
135
138
|
case "anySpendSignatureMint":
|
|
@@ -6,7 +6,6 @@ import invariant from "invariant";
|
|
|
6
6
|
import { useCallback, useState } from "react";
|
|
7
7
|
import { toast } from "sonner";
|
|
8
8
|
import { prepareTransaction, sendTransaction as twSendTransaction } from "thirdweb";
|
|
9
|
-
import { useActiveWallet } from "thirdweb/react";
|
|
10
9
|
import { isAddress } from "viem";
|
|
11
10
|
import { useSwitchChain } from "wagmi";
|
|
12
11
|
import { useB3 } from "../components";
|
|
@@ -29,7 +28,6 @@ invariant(partnerId, "Partner ID is required");
|
|
|
29
28
|
export function useUnifiedChainSwitchAndExecute() {
|
|
30
29
|
const { switchChainAsync } = useSwitchChain();
|
|
31
30
|
const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = useState(false);
|
|
32
|
-
const activeWallet = useActiveWallet();
|
|
33
31
|
|
|
34
32
|
const { isActiveSmartWallet, isActiveEOAWallet, connectedEOAWallet } = useAccountWallet();
|
|
35
33
|
const { account: aaAccount } = useB3();
|
|
@@ -49,12 +47,12 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
49
47
|
return;
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
const currentChainId =
|
|
50
|
+
const currentChainId = connectedEOAWallet?.getChain()?.id;
|
|
53
51
|
const onCorrectChain = currentChainId === targetChainId;
|
|
54
52
|
|
|
55
53
|
// Helper function to execute the transaction
|
|
56
54
|
const executeTransaction = async (): Promise<string> => {
|
|
57
|
-
const signer =
|
|
55
|
+
const signer = connectedEOAWallet?.getAccount();
|
|
58
56
|
if (!signer) {
|
|
59
57
|
throw new Error("No account connected");
|
|
60
58
|
}
|
|
@@ -62,7 +60,7 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
62
60
|
// Coinbase Smart Wallet specific chain switching (different behavior from other wallets)
|
|
63
61
|
const walletChain = connectedEOAWallet.getChain();
|
|
64
62
|
if (walletChain?.id !== targetChainId) {
|
|
65
|
-
|
|
63
|
+
connectedEOAWallet?.switchChain(getThirdwebChain(targetChainId));
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
invariant(isAddress(params.to), "params.to is not a valid address");
|
|
@@ -121,7 +119,7 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
121
119
|
setIsSwitchingOrExecuting(false);
|
|
122
120
|
}
|
|
123
121
|
},
|
|
124
|
-
[connectedEOAWallet,
|
|
122
|
+
[connectedEOAWallet, switchChainAsync],
|
|
125
123
|
);
|
|
126
124
|
|
|
127
125
|
// Handle AA wallet transaction (no chain switch needed for AA)
|
|
@@ -186,14 +184,10 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
186
184
|
// Check which wallet type is active
|
|
187
185
|
if (isActiveSmartWallet) {
|
|
188
186
|
return handleAASendTransaction(targetChainId, params);
|
|
189
|
-
} else if (isActiveEOAWallet) {
|
|
190
|
-
return handleEOASwitchChainAndSendTransaction(targetChainId, params);
|
|
191
|
-
} else {
|
|
192
|
-
toast.error("No wallet connected");
|
|
193
|
-
return undefined;
|
|
194
187
|
}
|
|
188
|
+
return handleEOASwitchChainAndSendTransaction(targetChainId, params);
|
|
195
189
|
},
|
|
196
|
-
[isActiveSmartWallet,
|
|
190
|
+
[isActiveSmartWallet, handleAASendTransaction, handleEOASwitchChainAndSendTransaction],
|
|
197
191
|
);
|
|
198
192
|
|
|
199
193
|
return {
|
|
@@ -276,6 +276,27 @@ export interface AnySpendStakeUpsideExactInProps extends BaseModalProps {
|
|
|
276
276
|
onSuccess?: () => void;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Props for the AnySpend Deposit Upside (Exact In) modal
|
|
281
|
+
* Handles token deposit operations using the custom exact in flow
|
|
282
|
+
*/
|
|
283
|
+
export interface AnySpendDepositUpsideProps extends BaseModalProps {
|
|
284
|
+
/** Modal type identifier */
|
|
285
|
+
type: "anySpendDepositUpside";
|
|
286
|
+
/** Source token address */
|
|
287
|
+
sourceTokenAddress?: string;
|
|
288
|
+
/** Source token address */
|
|
289
|
+
sourceTokenChainId?: number;
|
|
290
|
+
/** Recipient address to deposit tokens for */
|
|
291
|
+
recipientAddress: string;
|
|
292
|
+
/** Deposit contract address */
|
|
293
|
+
depositContractAddress: string;
|
|
294
|
+
/** Token to deposit */
|
|
295
|
+
token: components["schemas"]["Token"];
|
|
296
|
+
/** Callback function called when the deposit is successful */
|
|
297
|
+
onSuccess?: () => void;
|
|
298
|
+
}
|
|
299
|
+
|
|
279
300
|
/**
|
|
280
301
|
* Props for the AnySpend Buy Spin modal
|
|
281
302
|
* Handles spin wheel entry purchases
|
|
@@ -397,6 +418,7 @@ export type ModalContentType =
|
|
|
397
418
|
| AnySpendStakeB3ExactInProps
|
|
398
419
|
| AnySpendStakeUpsideProps
|
|
399
420
|
| AnySpendStakeUpsideExactInProps
|
|
421
|
+
| AnySpendDepositUpsideProps
|
|
400
422
|
| AnySpendBuySpinProps
|
|
401
423
|
| AnySpendSignatureMintProps
|
|
402
424
|
| AnySpendBondKitProps
|
package/src/styles/index.css
CHANGED
|
@@ -630,6 +630,14 @@ Dark version
|
|
|
630
630
|
font-size: 16px !important;
|
|
631
631
|
}
|
|
632
632
|
}
|
|
633
|
+
|
|
634
|
+
input[placeholder="Search Wallet"] {
|
|
635
|
+
padding-left: 48px !important;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
li[style="list-style: none;"] {
|
|
639
|
+
margin-bottom: 12px !important;
|
|
640
|
+
}
|
|
633
641
|
}
|
|
634
642
|
/* Radix UI Accordion animations */
|
|
635
643
|
@keyframes accordion-down {
|