@b3dotfun/sdk 0.0.61-alpha.2 → 0.0.61-alpha.4
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/AnyspendDepositHype.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +17 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +19 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +1 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +2 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +22 -2
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +3 -1
- package/src/global-account/react/stores/useModalStore.ts +2 -0
|
@@ -20,5 +20,6 @@ export interface AnySpendDepositHypeProps {
|
|
|
20
20
|
preventDefault: () => void;
|
|
21
21
|
}) => void;
|
|
22
22
|
customUsdInputValues?: string[];
|
|
23
|
+
preferEoa?: boolean;
|
|
23
24
|
}
|
|
24
25
|
export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -24,8 +24,10 @@ const FiatPaymentMethod_1 = require("./common/FiatPaymentMethod");
|
|
|
24
24
|
const OrderDetails_1 = require("./common/OrderDetails");
|
|
25
25
|
const PointsDetailPanel_1 = require("./common/PointsDetailPanel");
|
|
26
26
|
const RecipientSelection_1 = require("./common/RecipientSelection");
|
|
27
|
+
const react_4 = require("thirdweb/react");
|
|
27
28
|
const lucide_react_1 = require("lucide-react");
|
|
28
29
|
const PanelOnramp_1 = require("./common/PanelOnramp");
|
|
30
|
+
const utils_1 = require("../../utils");
|
|
29
31
|
const SLIPPAGE_PERCENT = 3;
|
|
30
32
|
exports.HYPE_TOKEN_DETAILS = {
|
|
31
33
|
SYMBOL: "HYPE",
|
|
@@ -35,7 +37,7 @@ function AnySpendDepositHype(props) {
|
|
|
35
37
|
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
36
38
|
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(AnySpendDepositHypeInner, { ...props }) }));
|
|
37
39
|
}
|
|
38
|
-
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, }) {
|
|
40
|
+
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, }) {
|
|
39
41
|
// Use shared flow hook
|
|
40
42
|
const { activePanel, setActivePanel, orderId, setOrderId, oat, selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, dstAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod, selectedFiatPaymentMethod, setSelectedFiatPaymentMethod, selectedRecipientAddress, setSelectedRecipientAddress, recipientName, globalAddress, anyspendQuote, isLoadingAnyspendQuote, activeInputAmountInWei, geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support, createOrder, isCreatingOrder, createOnrampOrder, isCreatingOnrampOrder, } = (0, useAnyspendFlow_1.useAnyspendFlow)({
|
|
41
43
|
paymentType,
|
|
@@ -48,6 +50,20 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
48
50
|
slippage: SLIPPAGE_PERCENT,
|
|
49
51
|
disableUrlParamManagement: true,
|
|
50
52
|
});
|
|
53
|
+
const { connectedEOAWallet: connectedEOAWallet } = (0, react_1.useAccountWallet)();
|
|
54
|
+
const setActiveWallet = (0, react_4.useSetActiveWallet)();
|
|
55
|
+
const activeWallet = (0, react_4.useActiveWallet)();
|
|
56
|
+
const setGlobalAccountWallet = (0, utils_1.useGlobalWalletState)(state => state.setGlobalAccountWallet);
|
|
57
|
+
const appliedPreferEoa = (0, react_3.useRef)(false);
|
|
58
|
+
(0, react_3.useEffect)(() => {
|
|
59
|
+
if (preferEoa && !appliedPreferEoa.current) {
|
|
60
|
+
if (connectedEOAWallet) {
|
|
61
|
+
appliedPreferEoa.current = true;
|
|
62
|
+
setGlobalAccountWallet(activeWallet);
|
|
63
|
+
setActiveWallet(connectedEOAWallet);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}, [preferEoa, connectedEOAWallet, setActiveWallet, activeWallet, setGlobalAccountWallet]);
|
|
51
67
|
// Button state logic
|
|
52
68
|
const btnInfo = (0, react_3.useMemo)(() => {
|
|
53
69
|
if (activeInputAmountInWei === "0")
|
|
@@ -7,7 +7,7 @@ import { B3ContextType } from "./types";
|
|
|
7
7
|
/**
|
|
8
8
|
* Main B3Provider component
|
|
9
9
|
*/
|
|
10
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, connectors, }: {
|
|
10
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors, }: {
|
|
11
11
|
theme: "light" | "dark";
|
|
12
12
|
children: React.ReactNode;
|
|
13
13
|
accountOverride?: Account;
|
|
@@ -23,6 +23,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
23
23
|
partnerId: string;
|
|
24
24
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
25
25
|
connectors?: CreateConnectorFn[];
|
|
26
|
+
overrideDefaultConnectors?: boolean;
|
|
26
27
|
}): import("react/jsx-runtime").JSX.Element;
|
|
27
28
|
/**
|
|
28
29
|
* Inner provider component that provides the actual B3Context
|
|
@@ -32,7 +32,7 @@ const queryClient = new react_query_1.QueryClient();
|
|
|
32
32
|
/**
|
|
33
33
|
* Main B3Provider component
|
|
34
34
|
*/
|
|
35
|
-
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connectors, }) {
|
|
35
|
+
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors = false, }) {
|
|
36
36
|
// Initialize Google Analytics on mount
|
|
37
37
|
(0, react_2.useEffect)(() => {
|
|
38
38
|
(0, analytics_1.loadGA4Script)();
|
|
@@ -41,7 +41,7 @@ function B3Provider({ theme = "light", children, accountOverride, environment, a
|
|
|
41
41
|
(0, react_2.useEffect)(() => {
|
|
42
42
|
(0, client_manager_1.setClientType)(clientType);
|
|
43
43
|
}, [clientType]);
|
|
44
|
-
const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls, connectors });
|
|
44
|
+
const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls, connectors, overrideDefaultConnectors });
|
|
45
45
|
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, children: (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" }), (0, jsx_runtime_1.jsx)(sonner_1.Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }) }));
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -312,6 +312,8 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
|
|
|
312
312
|
onSuccess?: (amount?: string) => void;
|
|
313
313
|
/** Custom USD input values for quick amount buttons in fiat onramp */
|
|
314
314
|
customUsdInputValues?: string[];
|
|
315
|
+
/** prefer eoa wallet */
|
|
316
|
+
preferEoa?: boolean;
|
|
315
317
|
}
|
|
316
318
|
export interface AvatarEditorModalProps extends BaseModalProps {
|
|
317
319
|
/** Modal type identifier */
|
|
@@ -20,5 +20,6 @@ export interface AnySpendDepositHypeProps {
|
|
|
20
20
|
preventDefault: () => void;
|
|
21
21
|
}) => void;
|
|
22
22
|
customUsdInputValues?: string[];
|
|
23
|
+
preferEoa?: boolean;
|
|
23
24
|
}
|
|
24
25
|
export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { B3_TOKEN } from "../../../anyspend/index.js";
|
|
3
|
-
import { Button, ShinyButton, StyleRoot, TransitionPanel } from "../../../global-account/react/index.js";
|
|
3
|
+
import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet } from "../../../global-account/react/index.js";
|
|
4
4
|
import { cn } from "../../../shared/utils/cn.js";
|
|
5
5
|
import invariant from "invariant";
|
|
6
6
|
import { motion } from "motion/react";
|
|
7
|
-
import { useMemo } from "react";
|
|
7
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
8
8
|
import { toast } from "sonner";
|
|
9
9
|
import { base } from "viem/chains";
|
|
10
10
|
import { PanelView, useAnyspendFlow } from "../hooks/useAnyspendFlow.js";
|
|
@@ -17,8 +17,10 @@ import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaym
|
|
|
17
17
|
import { OrderDetails } from "./common/OrderDetails.js";
|
|
18
18
|
import { PointsDetailPanel } from "./common/PointsDetailPanel.js";
|
|
19
19
|
import { RecipientSelection } from "./common/RecipientSelection.js";
|
|
20
|
+
import { useActiveWallet, useSetActiveWallet } from "thirdweb/react";
|
|
20
21
|
import { ArrowDown, Loader2 } from "lucide-react";
|
|
21
22
|
import { PanelOnramp } from "./common/PanelOnramp.js";
|
|
23
|
+
import { useGlobalWalletState } from "../../utils/index.js";
|
|
22
24
|
const SLIPPAGE_PERCENT = 3;
|
|
23
25
|
export const HYPE_TOKEN_DETAILS = {
|
|
24
26
|
SYMBOL: "HYPE",
|
|
@@ -28,7 +30,7 @@ export function AnySpendDepositHype(props) {
|
|
|
28
30
|
const fingerprintConfig = getFingerprintConfig();
|
|
29
31
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendDepositHypeInner, { ...props }) }));
|
|
30
32
|
}
|
|
31
|
-
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, }) {
|
|
33
|
+
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, }) {
|
|
32
34
|
// Use shared flow hook
|
|
33
35
|
const { activePanel, setActivePanel, orderId, setOrderId, oat, selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, dstAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod, selectedFiatPaymentMethod, setSelectedFiatPaymentMethod, selectedRecipientAddress, setSelectedRecipientAddress, recipientName, globalAddress, anyspendQuote, isLoadingAnyspendQuote, activeInputAmountInWei, geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support, createOrder, isCreatingOrder, createOnrampOrder, isCreatingOnrampOrder, } = useAnyspendFlow({
|
|
34
36
|
paymentType,
|
|
@@ -41,6 +43,20 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
41
43
|
slippage: SLIPPAGE_PERCENT,
|
|
42
44
|
disableUrlParamManagement: true,
|
|
43
45
|
});
|
|
46
|
+
const { connectedEOAWallet: connectedEOAWallet } = useAccountWallet();
|
|
47
|
+
const setActiveWallet = useSetActiveWallet();
|
|
48
|
+
const activeWallet = useActiveWallet();
|
|
49
|
+
const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
|
|
50
|
+
const appliedPreferEoa = useRef(false);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (preferEoa && !appliedPreferEoa.current) {
|
|
53
|
+
if (connectedEOAWallet) {
|
|
54
|
+
appliedPreferEoa.current = true;
|
|
55
|
+
setGlobalAccountWallet(activeWallet);
|
|
56
|
+
setActiveWallet(connectedEOAWallet);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, [preferEoa, connectedEOAWallet, setActiveWallet, activeWallet, setGlobalAccountWallet]);
|
|
44
60
|
// Button state logic
|
|
45
61
|
const btnInfo = useMemo(() => {
|
|
46
62
|
if (activeInputAmountInWei === "0")
|
|
@@ -7,7 +7,7 @@ import { B3ContextType } from "./types";
|
|
|
7
7
|
/**
|
|
8
8
|
* Main B3Provider component
|
|
9
9
|
*/
|
|
10
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, connectors, }: {
|
|
10
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors, }: {
|
|
11
11
|
theme: "light" | "dark";
|
|
12
12
|
children: React.ReactNode;
|
|
13
13
|
accountOverride?: Account;
|
|
@@ -23,6 +23,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
23
23
|
partnerId: string;
|
|
24
24
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
25
25
|
connectors?: CreateConnectorFn[];
|
|
26
|
+
overrideDefaultConnectors?: boolean;
|
|
26
27
|
}): import("react/jsx-runtime").JSX.Element;
|
|
27
28
|
/**
|
|
28
29
|
* Inner provider component that provides the actual B3Context
|
|
@@ -28,7 +28,7 @@ const queryClient = new QueryClient();
|
|
|
28
28
|
/**
|
|
29
29
|
* Main B3Provider component
|
|
30
30
|
*/
|
|
31
|
-
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connectors, }) {
|
|
31
|
+
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors = false, }) {
|
|
32
32
|
// Initialize Google Analytics on mount
|
|
33
33
|
useEffect(() => {
|
|
34
34
|
loadGA4Script();
|
|
@@ -37,7 +37,7 @@ export function B3Provider({ theme = "light", children, accountOverride, environ
|
|
|
37
37
|
useEffect(() => {
|
|
38
38
|
setClientType(clientType);
|
|
39
39
|
}, [clientType]);
|
|
40
|
-
const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls, connectors });
|
|
40
|
+
const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors });
|
|
41
41
|
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, children: _jsx(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, children: _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" }), _jsx(Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }) }));
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
@@ -312,6 +312,8 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
|
|
|
312
312
|
onSuccess?: (amount?: string) => void;
|
|
313
313
|
/** Custom USD input values for quick amount buttons in fiat onramp */
|
|
314
314
|
customUsdInputValues?: string[];
|
|
315
|
+
/** prefer eoa wallet */
|
|
316
|
+
preferEoa?: boolean;
|
|
315
317
|
}
|
|
316
318
|
export interface AvatarEditorModalProps extends BaseModalProps {
|
|
317
319
|
/** Modal type identifier */
|
|
@@ -20,5 +20,6 @@ export interface AnySpendDepositHypeProps {
|
|
|
20
20
|
preventDefault: () => void;
|
|
21
21
|
}) => void;
|
|
22
22
|
customUsdInputValues?: string[];
|
|
23
|
+
preferEoa?: boolean;
|
|
23
24
|
}
|
|
24
25
|
export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,7 +7,7 @@ import { B3ContextType } from "./types";
|
|
|
7
7
|
/**
|
|
8
8
|
* Main B3Provider component
|
|
9
9
|
*/
|
|
10
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, connectors, }: {
|
|
10
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors, }: {
|
|
11
11
|
theme: "light" | "dark";
|
|
12
12
|
children: React.ReactNode;
|
|
13
13
|
accountOverride?: Account;
|
|
@@ -23,6 +23,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
23
23
|
partnerId: string;
|
|
24
24
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
25
25
|
connectors?: CreateConnectorFn[];
|
|
26
|
+
overrideDefaultConnectors?: boolean;
|
|
26
27
|
}): import("react/jsx-runtime").JSX.Element;
|
|
27
28
|
/**
|
|
28
29
|
* Inner provider component that provides the actual B3Context
|
|
@@ -312,6 +312,8 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
|
|
|
312
312
|
onSuccess?: (amount?: string) => void;
|
|
313
313
|
/** Custom USD input values for quick amount buttons in fiat onramp */
|
|
314
314
|
customUsdInputValues?: string[];
|
|
315
|
+
/** prefer eoa wallet */
|
|
316
|
+
preferEoa?: boolean;
|
|
315
317
|
}
|
|
316
318
|
export interface AvatarEditorModalProps extends BaseModalProps {
|
|
317
319
|
/** Modal type identifier */
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { B3_TOKEN } from "@b3dotfun/sdk/anyspend";
|
|
2
2
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
|
-
import { Button, ShinyButton, StyleRoot, TransitionPanel } from "@b3dotfun/sdk/global-account/react";
|
|
3
|
+
import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet } from "@b3dotfun/sdk/global-account/react";
|
|
4
4
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
5
5
|
import invariant from "invariant";
|
|
6
6
|
import { motion } from "motion/react";
|
|
7
|
-
import { useMemo } from "react";
|
|
7
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
8
8
|
import { toast } from "sonner";
|
|
9
9
|
import { base } from "viem/chains";
|
|
10
10
|
import { PanelView, useAnyspendFlow } from "../hooks/useAnyspendFlow";
|
|
@@ -17,9 +17,11 @@ import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaym
|
|
|
17
17
|
import { OrderDetails } from "./common/OrderDetails";
|
|
18
18
|
import { PointsDetailPanel } from "./common/PointsDetailPanel";
|
|
19
19
|
import { RecipientSelection } from "./common/RecipientSelection";
|
|
20
|
+
import { useActiveWallet, useSetActiveWallet } from "thirdweb/react";
|
|
20
21
|
|
|
21
22
|
import { ArrowDown, Loader2 } from "lucide-react";
|
|
22
23
|
import { PanelOnramp } from "./common/PanelOnramp";
|
|
24
|
+
import { useGlobalWalletState } from "../../utils";
|
|
23
25
|
|
|
24
26
|
const SLIPPAGE_PERCENT = 3;
|
|
25
27
|
|
|
@@ -43,6 +45,7 @@ export interface AnySpendDepositHypeProps {
|
|
|
43
45
|
*/
|
|
44
46
|
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
45
47
|
customUsdInputValues?: string[];
|
|
48
|
+
preferEoa?: boolean;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
export function AnySpendDepositHype(props: AnySpendDepositHypeProps) {
|
|
@@ -66,6 +69,7 @@ function AnySpendDepositHypeInner({
|
|
|
66
69
|
mainFooter,
|
|
67
70
|
onTokenSelect,
|
|
68
71
|
customUsdInputValues,
|
|
72
|
+
preferEoa,
|
|
69
73
|
}: AnySpendDepositHypeProps) {
|
|
70
74
|
// Use shared flow hook
|
|
71
75
|
const {
|
|
@@ -113,6 +117,22 @@ function AnySpendDepositHypeInner({
|
|
|
113
117
|
disableUrlParamManagement: true,
|
|
114
118
|
});
|
|
115
119
|
|
|
120
|
+
const { connectedEOAWallet: connectedEOAWallet } = useAccountWallet();
|
|
121
|
+
const setActiveWallet = useSetActiveWallet();
|
|
122
|
+
const activeWallet = useActiveWallet();
|
|
123
|
+
const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
|
|
124
|
+
const appliedPreferEoa = useRef(false);
|
|
125
|
+
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (preferEoa && !appliedPreferEoa.current) {
|
|
128
|
+
if (connectedEOAWallet) {
|
|
129
|
+
appliedPreferEoa.current = true;
|
|
130
|
+
setGlobalAccountWallet(activeWallet);
|
|
131
|
+
setActiveWallet(connectedEOAWallet);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, [preferEoa, connectedEOAWallet, setActiveWallet, activeWallet, setGlobalAccountWallet]);
|
|
135
|
+
|
|
116
136
|
// Button state logic
|
|
117
137
|
const btnInfo: { text: string; disable: boolean; error: boolean; loading: boolean } = useMemo(() => {
|
|
118
138
|
if (activeInputAmountInWei === "0") return { text: "Enter an amount", disable: true, error: false, loading: false };
|
|
@@ -57,6 +57,7 @@ export function B3Provider({
|
|
|
57
57
|
partnerId,
|
|
58
58
|
onConnect,
|
|
59
59
|
connectors,
|
|
60
|
+
overrideDefaultConnectors = false,
|
|
60
61
|
}: {
|
|
61
62
|
theme: "light" | "dark";
|
|
62
63
|
children: React.ReactNode;
|
|
@@ -73,6 +74,7 @@ export function B3Provider({
|
|
|
73
74
|
partnerId: string;
|
|
74
75
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
75
76
|
connectors?: CreateConnectorFn[];
|
|
77
|
+
overrideDefaultConnectors?: boolean;
|
|
76
78
|
}) {
|
|
77
79
|
// Initialize Google Analytics on mount
|
|
78
80
|
useEffect(() => {
|
|
@@ -83,7 +85,7 @@ export function B3Provider({
|
|
|
83
85
|
useEffect(() => {
|
|
84
86
|
setClientType(clientType);
|
|
85
87
|
}, [clientType]);
|
|
86
|
-
const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls, connectors });
|
|
88
|
+
const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors });
|
|
87
89
|
|
|
88
90
|
return (
|
|
89
91
|
<ThirdwebProvider>
|
|
@@ -330,6 +330,8 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
|
|
|
330
330
|
onSuccess?: (amount?: string) => void;
|
|
331
331
|
/** Custom USD input values for quick amount buttons in fiat onramp */
|
|
332
332
|
customUsdInputValues?: string[];
|
|
333
|
+
/** prefer eoa wallet */
|
|
334
|
+
preferEoa?: boolean;
|
|
333
335
|
}
|
|
334
336
|
|
|
335
337
|
export interface AvatarEditorModalProps extends BaseModalProps {
|