@b3dotfun/sdk 0.0.64-alpha.1 → 0.0.64-alpha.2
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/AnySpendCustomExactIn.js +1 -5
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +1 -5
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +0 -4
- package/dist/cjs/anyspend/utils/index.d.ts +0 -1
- package/dist/cjs/anyspend/utils/index.js +0 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +4 -7
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.js +3 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +2 -6
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -6
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +1 -5
- package/dist/esm/anyspend/utils/index.d.ts +0 -1
- package/dist/esm/anyspend/utils/index.js +0 -1
- package/dist/esm/global-account/react/components/B3DynamicModal.js +5 -8
- package/dist/esm/global-account/react/hooks/useGlobalAccount.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/useGlobalAccount.js +3 -0
- package/dist/types/anyspend/utils/index.d.ts +0 -1
- package/dist/types/global-account/react/hooks/useGlobalAccount.d.ts +1 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +2 -6
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +2 -6
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +1 -6
- package/src/anyspend/utils/index.ts +0 -1
- package/src/global-account/react/components/B3DynamicModal.tsx +5 -9
- package/src/global-account/react/hooks/useGlobalAccount.tsx +3 -1
- package/dist/cjs/anyspend/utils/accountStore.d.ts +0 -7
- package/dist/cjs/anyspend/utils/accountStore.js +0 -8
- package/dist/esm/anyspend/utils/accountStore.d.ts +0 -7
- package/dist/esm/anyspend/utils/accountStore.js +0 -5
- package/dist/types/anyspend/utils/accountStore.d.ts +0 -7
- package/src/anyspend/utils/accountStore.ts +0 -12
|
@@ -14,7 +14,6 @@ const react_2 = require("motion/react");
|
|
|
14
14
|
const react_3 = require("react");
|
|
15
15
|
const sonner_1 = require("sonner");
|
|
16
16
|
const react_4 = require("thirdweb/react");
|
|
17
|
-
const utils_2 = require("../../utils");
|
|
18
17
|
const useAnyspendFlow_1 = require("../hooks/useAnyspendFlow");
|
|
19
18
|
const AnySpendFingerprintWrapper_1 = require("./AnySpendFingerprintWrapper");
|
|
20
19
|
const CryptoPaySection_1 = require("./common/CryptoPaySection");
|
|
@@ -53,18 +52,15 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
53
52
|
});
|
|
54
53
|
const { connectedEOAWallet } = (0, react_1.useAccountWallet)();
|
|
55
54
|
const setActiveWallet = (0, react_4.useSetActiveWallet)();
|
|
56
|
-
const activeWallet = (0, react_4.useActiveWallet)();
|
|
57
|
-
const setGlobalAccountWallet = (0, utils_2.useGlobalWalletState)(state => state.setGlobalAccountWallet);
|
|
58
55
|
const appliedPreferEoa = (0, react_3.useRef)(false);
|
|
59
56
|
(0, react_3.useEffect)(() => {
|
|
60
57
|
if (preferEoa && !appliedPreferEoa.current) {
|
|
61
58
|
if (connectedEOAWallet) {
|
|
62
59
|
appliedPreferEoa.current = true;
|
|
63
|
-
setGlobalAccountWallet(activeWallet);
|
|
64
60
|
setActiveWallet(connectedEOAWallet);
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
|
-
}, [preferEoa, connectedEOAWallet, setActiveWallet
|
|
63
|
+
}, [preferEoa, connectedEOAWallet, setActiveWallet]);
|
|
68
64
|
const selectedRecipientOrDefault = selectedRecipientAddress ?? recipientAddress;
|
|
69
65
|
const expectedDstAmountRaw = anyspendQuote?.data?.currencyOut?.amount ?? "0";
|
|
70
66
|
const buildCustomPayload = (_recipient) => {
|
|
@@ -26,7 +26,6 @@ const OrderDetails_1 = require("./common/OrderDetails");
|
|
|
26
26
|
const PointsDetailPanel_1 = require("./common/PointsDetailPanel");
|
|
27
27
|
const RecipientSelection_1 = require("./common/RecipientSelection");
|
|
28
28
|
const lucide_react_1 = require("lucide-react");
|
|
29
|
-
const utils_1 = require("../../utils");
|
|
30
29
|
const PanelOnramp_1 = require("./common/PanelOnramp");
|
|
31
30
|
const SLIPPAGE_PERCENT = 3;
|
|
32
31
|
exports.HYPE_TOKEN_DETAILS = {
|
|
@@ -52,18 +51,15 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
52
51
|
});
|
|
53
52
|
const { connectedEOAWallet: connectedEOAWallet } = (0, react_1.useAccountWallet)();
|
|
54
53
|
const setActiveWallet = (0, react_4.useSetActiveWallet)();
|
|
55
|
-
const activeWallet = (0, react_4.useActiveWallet)();
|
|
56
|
-
const setGlobalAccountWallet = (0, utils_1.useGlobalWalletState)(state => state.setGlobalAccountWallet);
|
|
57
54
|
const appliedPreferEoa = (0, react_3.useRef)(false);
|
|
58
55
|
(0, react_3.useEffect)(() => {
|
|
59
56
|
if (preferEoa && !appliedPreferEoa.current) {
|
|
60
57
|
if (connectedEOAWallet) {
|
|
61
58
|
appliedPreferEoa.current = true;
|
|
62
|
-
setGlobalAccountWallet(activeWallet);
|
|
63
59
|
setActiveWallet(connectedEOAWallet);
|
|
64
60
|
}
|
|
65
61
|
}
|
|
66
|
-
}, [preferEoa, connectedEOAWallet, setActiveWallet
|
|
62
|
+
}, [preferEoa, connectedEOAWallet, setActiveWallet]);
|
|
67
63
|
// Button state logic
|
|
68
64
|
const btnInfo = (0, react_3.useMemo)(() => {
|
|
69
65
|
if (activeInputAmountInWei === "0")
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.CryptoPaymentMethodType = void 0;
|
|
5
5
|
exports.CryptoPaymentMethod = CryptoPaymentMethod;
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const utils_1 = require("../../../../anyspend/utils");
|
|
8
7
|
const react_1 = require("../../../../global-account/react");
|
|
9
8
|
const cn_1 = require("../../../../shared/utils/cn");
|
|
10
9
|
const formatAddress_1 = require("../../../../shared/utils/formatAddress");
|
|
@@ -34,8 +33,6 @@ function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod,
|
|
|
34
33
|
const [showWalletModal, setShowWalletModal] = (0, react_3.useState)(false);
|
|
35
34
|
const setActiveWallet = (0, react_4.useSetActiveWallet)();
|
|
36
35
|
const { data: eoaWalletInfo } = (0, react_4.useWalletInfo)(connectedEOAWallet?.id);
|
|
37
|
-
const activeWallet = (0, react_4.useActiveWallet)();
|
|
38
|
-
const setGlobalAccountWallet = (0, utils_1.useGlobalWalletState)(state => state.setGlobalAccountWallet);
|
|
39
36
|
const isConnected = !!connectedEOAWallet;
|
|
40
37
|
const globalAddress = connectedSmartWallet?.getAccount()?.address;
|
|
41
38
|
// Use custom hook to determine wallet display logic
|
|
@@ -166,7 +163,6 @@ function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod,
|
|
|
166
163
|
return ((0, jsx_runtime_1.jsxs)("div", { className: "crypto-payment-method mx-auto h-fit w-[460px] max-w-full", children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("relative flex flex-col gap-10"), children: [(0, jsx_runtime_1.jsx)("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary absolute flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, { className: "h-6 w-6" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-around gap-4", children: (0, jsx_runtime_1.jsx)("div", { className: "flex-1 text-center", children: (0, jsx_runtime_1.jsx)("h2", { className: "text-as-primary text-lg font-semibold", children: "Select a payment method" }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "crypto-payment-methods flex flex-col gap-4", children: [(shouldShowConnectedEOA || shouldShowWagmiWallet || globalAddress) && ((0, jsx_runtime_1.jsxs)("div", { className: "installed-wallets", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-as-primary/80 mb-3 text-sm font-medium", children: "Connected wallets" }), (0, jsx_runtime_1.jsxs)("div", { className: "space-y-2", children: [shouldShowConnectedEOA && ((0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
167
164
|
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
168
165
|
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
169
|
-
setGlobalAccountWallet(activeWallet);
|
|
170
166
|
if (connectedEOAWallet) {
|
|
171
167
|
setActiveWallet(connectedEOAWallet);
|
|
172
168
|
}
|
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./accountStore"), exports);
|
|
18
17
|
__exportStar(require("./address"), exports);
|
|
19
18
|
__exportStar(require("./chain"), exports);
|
|
20
19
|
__exportStar(require("./format"), exports);
|
|
@@ -6,7 +6,6 @@ const react_1 = require("../../../anyspend/react");
|
|
|
6
6
|
const AnyspendDepositHype_1 = require("../../../anyspend/react/components/AnyspendDepositHype");
|
|
7
7
|
const AnySpendStakeUpside_1 = require("../../../anyspend/react/components/AnySpendStakeUpside");
|
|
8
8
|
const AnySpendStakeUpsideExactIn_1 = require("../../../anyspend/react/components/AnySpendStakeUpsideExactIn");
|
|
9
|
-
const utils_1 = require("../../../anyspend/utils");
|
|
10
9
|
const react_2 = require("../../../global-account/react");
|
|
11
10
|
const cn_1 = require("../../../shared/utils/cn");
|
|
12
11
|
const debug_1 = require("../../../shared/utils/debug");
|
|
@@ -27,19 +26,17 @@ function B3DynamicModal() {
|
|
|
27
26
|
const { theme } = (0, useB3_1.useB3)();
|
|
28
27
|
const isMobile = (0, react_2.useIsMobile)();
|
|
29
28
|
const prevIsOpenRef = (0, react_3.useRef)(isOpen);
|
|
30
|
-
const
|
|
31
|
-
const setGlobalAccountWallet = (0, utils_1.useGlobalWalletState)(state => state.setGlobalAccountWallet);
|
|
29
|
+
const { wallet } = (0, react_2.useGlobalAccount)();
|
|
32
30
|
const setActiveWallet = (0, react_4.useSetActiveWallet)();
|
|
33
31
|
// anyspend cleanup global account chnages by setting account back
|
|
34
32
|
(0, react_3.useEffect)(() => {
|
|
35
33
|
if (prevIsOpenRef.current && !isOpen) {
|
|
36
|
-
if (
|
|
37
|
-
setActiveWallet(
|
|
38
|
-
setGlobalAccountWallet(undefined);
|
|
34
|
+
if (wallet) {
|
|
35
|
+
setActiveWallet(wallet);
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
38
|
prevIsOpenRef.current = isOpen;
|
|
42
|
-
}, [isOpen,
|
|
39
|
+
}, [isOpen, wallet, setActiveWallet]);
|
|
43
40
|
// Define arrays for different modal type groups
|
|
44
41
|
const fullWidthTypes = [
|
|
45
42
|
"anySpend",
|
|
@@ -10,6 +10,7 @@ function useGlobalAccount() {
|
|
|
10
10
|
const wallets = (0, react_3.useConnectedWallets)();
|
|
11
11
|
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
12
12
|
const [globalAccount, setGlobalAccount] = (0, react_2.useState)(undefined);
|
|
13
|
+
const [globalAccountWallet, setGlobalAccountWallet] = (0, react_2.useState)(undefined);
|
|
13
14
|
const [address, setAddress] = (0, react_2.useState)(undefined);
|
|
14
15
|
const walletInfo = (0, react_3.useWalletInfo)(globalAccount?.id);
|
|
15
16
|
(0, react_2.useEffect)(() => {
|
|
@@ -20,6 +21,7 @@ function useGlobalAccount() {
|
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
23
|
const globalAccountWallet = wallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
24
|
+
setGlobalAccountWallet(globalAccountWallet);
|
|
23
25
|
const account = globalAccountWallet?.getAccount();
|
|
24
26
|
setGlobalAccount(globalAccountWallet);
|
|
25
27
|
setAddress(account?.address);
|
|
@@ -28,5 +30,6 @@ function useGlobalAccount() {
|
|
|
28
30
|
account: globalAccount,
|
|
29
31
|
address,
|
|
30
32
|
info: walletInfo,
|
|
33
|
+
wallet: globalAccountWallet,
|
|
31
34
|
};
|
|
32
35
|
}
|
|
@@ -7,8 +7,7 @@ import { ArrowDown, Loader2 } from "lucide-react";
|
|
|
7
7
|
import { motion } from "motion/react";
|
|
8
8
|
import { useEffect, useMemo, useRef } from "react";
|
|
9
9
|
import { toast } from "sonner";
|
|
10
|
-
import {
|
|
11
|
-
import { useGlobalWalletState } from "../../utils/index.js";
|
|
10
|
+
import { useSetActiveWallet } from "thirdweb/react";
|
|
12
11
|
import { PanelView, useAnyspendFlow } from "../hooks/useAnyspendFlow.js";
|
|
13
12
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
|
|
14
13
|
import { CryptoPaySection } from "./common/CryptoPaySection.js";
|
|
@@ -47,18 +46,15 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
47
46
|
});
|
|
48
47
|
const { connectedEOAWallet } = useAccountWallet();
|
|
49
48
|
const setActiveWallet = useSetActiveWallet();
|
|
50
|
-
const activeWallet = useActiveWallet();
|
|
51
|
-
const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
|
|
52
49
|
const appliedPreferEoa = useRef(false);
|
|
53
50
|
useEffect(() => {
|
|
54
51
|
if (preferEoa && !appliedPreferEoa.current) {
|
|
55
52
|
if (connectedEOAWallet) {
|
|
56
53
|
appliedPreferEoa.current = true;
|
|
57
|
-
setGlobalAccountWallet(activeWallet);
|
|
58
54
|
setActiveWallet(connectedEOAWallet);
|
|
59
55
|
}
|
|
60
56
|
}
|
|
61
|
-
}, [preferEoa, connectedEOAWallet, setActiveWallet
|
|
57
|
+
}, [preferEoa, connectedEOAWallet, setActiveWallet]);
|
|
62
58
|
const selectedRecipientOrDefault = selectedRecipientAddress ?? recipientAddress;
|
|
63
59
|
const expectedDstAmountRaw = anyspendQuote?.data?.currencyOut?.amount ?? "0";
|
|
64
60
|
const buildCustomPayload = (_recipient) => {
|
|
@@ -6,7 +6,7 @@ import invariant from "invariant";
|
|
|
6
6
|
import { motion } from "motion/react";
|
|
7
7
|
import { useEffect, useMemo, useRef } from "react";
|
|
8
8
|
import { toast } from "sonner";
|
|
9
|
-
import {
|
|
9
|
+
import { useSetActiveWallet } from "thirdweb/react";
|
|
10
10
|
import { base } from "viem/chains";
|
|
11
11
|
import { PanelView, useAnyspendFlow } from "../hooks/useAnyspendFlow.js";
|
|
12
12
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
|
|
@@ -19,7 +19,6 @@ import { OrderDetails } from "./common/OrderDetails.js";
|
|
|
19
19
|
import { PointsDetailPanel } from "./common/PointsDetailPanel.js";
|
|
20
20
|
import { RecipientSelection } from "./common/RecipientSelection.js";
|
|
21
21
|
import { ArrowDown, Loader2 } from "lucide-react";
|
|
22
|
-
import { useGlobalWalletState } from "../../utils/index.js";
|
|
23
22
|
import { PanelOnramp } from "./common/PanelOnramp.js";
|
|
24
23
|
const SLIPPAGE_PERCENT = 3;
|
|
25
24
|
export const HYPE_TOKEN_DETAILS = {
|
|
@@ -45,18 +44,15 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
45
44
|
});
|
|
46
45
|
const { connectedEOAWallet: connectedEOAWallet } = useAccountWallet();
|
|
47
46
|
const setActiveWallet = useSetActiveWallet();
|
|
48
|
-
const activeWallet = useActiveWallet();
|
|
49
|
-
const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
|
|
50
47
|
const appliedPreferEoa = useRef(false);
|
|
51
48
|
useEffect(() => {
|
|
52
49
|
if (preferEoa && !appliedPreferEoa.current) {
|
|
53
50
|
if (connectedEOAWallet) {
|
|
54
51
|
appliedPreferEoa.current = true;
|
|
55
|
-
setGlobalAccountWallet(activeWallet);
|
|
56
52
|
setActiveWallet(connectedEOAWallet);
|
|
57
53
|
}
|
|
58
54
|
}
|
|
59
|
-
}, [preferEoa, connectedEOAWallet, setActiveWallet
|
|
55
|
+
}, [preferEoa, connectedEOAWallet, setActiveWallet]);
|
|
60
56
|
// Button state logic
|
|
61
57
|
const btnInfo = useMemo(() => {
|
|
62
58
|
if (activeInputAmountInWei === "0")
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useGlobalWalletState } from "../../../../anyspend/utils/index.js";
|
|
4
3
|
import { useAccountWallet } from "../../../../global-account/react/index.js";
|
|
5
4
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
6
5
|
import { shortenAddress } from "../../../../shared/utils/formatAddress.js";
|
|
@@ -10,7 +9,7 @@ import { ChevronLeft, ChevronRightCircle, Wallet, X, ZapIcon } from "lucide-reac
|
|
|
10
9
|
import { useState } from "react";
|
|
11
10
|
import { createPortal } from "react-dom";
|
|
12
11
|
import { toast } from "sonner";
|
|
13
|
-
import {
|
|
12
|
+
import { useSetActiveWallet, useWalletInfo } from "thirdweb/react";
|
|
14
13
|
import { createWallet } from "thirdweb/wallets";
|
|
15
14
|
import { useAccount, useConnect, useDisconnect, useWalletClient } from "wagmi";
|
|
16
15
|
import { useConnectedWalletDisplay } from "../../hooks/useConnectedWalletDisplay.js";
|
|
@@ -30,8 +29,6 @@ export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentM
|
|
|
30
29
|
const [showWalletModal, setShowWalletModal] = useState(false);
|
|
31
30
|
const setActiveWallet = useSetActiveWallet();
|
|
32
31
|
const { data: eoaWalletInfo } = useWalletInfo(connectedEOAWallet?.id);
|
|
33
|
-
const activeWallet = useActiveWallet();
|
|
34
|
-
const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
|
|
35
32
|
const isConnected = !!connectedEOAWallet;
|
|
36
33
|
const globalAddress = connectedSmartWallet?.getAccount()?.address;
|
|
37
34
|
// Use custom hook to determine wallet display logic
|
|
@@ -162,7 +159,6 @@ export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentM
|
|
|
162
159
|
return (_jsxs("div", { className: "crypto-payment-method mx-auto h-fit w-[460px] max-w-full", children: [_jsxs("div", { className: cn("relative flex flex-col gap-10"), children: [_jsx("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary absolute flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: _jsx(ChevronLeft, { className: "h-6 w-6" }) }), _jsx("div", { className: "flex items-center justify-around gap-4", children: _jsx("div", { className: "flex-1 text-center", children: _jsx("h2", { className: "text-as-primary text-lg font-semibold", children: "Select a payment method" }) }) }), _jsxs("div", { className: "crypto-payment-methods flex flex-col gap-4", children: [(shouldShowConnectedEOA || shouldShowWagmiWallet || globalAddress) && (_jsxs("div", { className: "installed-wallets", children: [_jsx("h3", { className: "text-as-primary/80 mb-3 text-sm font-medium", children: "Connected wallets" }), _jsxs("div", { className: "space-y-2", children: [shouldShowConnectedEOA && (_jsx("button", { onClick: () => {
|
|
163
160
|
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
164
161
|
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
165
|
-
setGlobalAccountWallet(activeWallet);
|
|
166
162
|
if (connectedEOAWallet) {
|
|
167
163
|
setActiveWallet(connectedEOAWallet);
|
|
168
164
|
}
|
|
@@ -3,8 +3,7 @@ import { AnySpend, AnySpendBondKit, AnySpendBuySpin, AnySpendNFT, AnyspendSignat
|
|
|
3
3
|
import { AnySpendDepositHype } from "../../../anyspend/react/components/AnyspendDepositHype.js";
|
|
4
4
|
import { AnySpendStakeUpside } from "../../../anyspend/react/components/AnySpendStakeUpside.js";
|
|
5
5
|
import { AnySpendStakeUpsideExactIn } from "../../../anyspend/react/components/AnySpendStakeUpsideExactIn.js";
|
|
6
|
-
import {
|
|
7
|
-
import { useIsMobile, useModalStore } from "../../../global-account/react/index.js";
|
|
6
|
+
import { useGlobalAccount, useIsMobile, useModalStore } from "../../../global-account/react/index.js";
|
|
8
7
|
import { cn } from "../../../shared/utils/cn.js";
|
|
9
8
|
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
10
9
|
import { useEffect, useRef } from "react";
|
|
@@ -24,19 +23,17 @@ export function B3DynamicModal() {
|
|
|
24
23
|
const { theme } = useB3();
|
|
25
24
|
const isMobile = useIsMobile();
|
|
26
25
|
const prevIsOpenRef = useRef(isOpen);
|
|
27
|
-
const
|
|
28
|
-
const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
|
|
26
|
+
const { wallet } = useGlobalAccount();
|
|
29
27
|
const setActiveWallet = useSetActiveWallet();
|
|
30
28
|
// anyspend cleanup global account chnages by setting account back
|
|
31
29
|
useEffect(() => {
|
|
32
30
|
if (prevIsOpenRef.current && !isOpen) {
|
|
33
|
-
if (
|
|
34
|
-
setActiveWallet(
|
|
35
|
-
setGlobalAccountWallet(undefined);
|
|
31
|
+
if (wallet) {
|
|
32
|
+
setActiveWallet(wallet);
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
prevIsOpenRef.current = isOpen;
|
|
39
|
-
}, [isOpen,
|
|
36
|
+
}, [isOpen, wallet, setActiveWallet]);
|
|
40
37
|
// Define arrays for different modal type groups
|
|
41
38
|
const fullWidthTypes = [
|
|
42
39
|
"anySpend",
|
|
@@ -7,6 +7,7 @@ export function useGlobalAccount() {
|
|
|
7
7
|
const wallets = useConnectedWallets();
|
|
8
8
|
const isConnected = useAuthStore(state => state.isConnected);
|
|
9
9
|
const [globalAccount, setGlobalAccount] = useState(undefined);
|
|
10
|
+
const [globalAccountWallet, setGlobalAccountWallet] = useState(undefined);
|
|
10
11
|
const [address, setAddress] = useState(undefined);
|
|
11
12
|
const walletInfo = useWalletInfo(globalAccount?.id);
|
|
12
13
|
useEffect(() => {
|
|
@@ -17,6 +18,7 @@ export function useGlobalAccount() {
|
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
20
|
const globalAccountWallet = wallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
21
|
+
setGlobalAccountWallet(globalAccountWallet);
|
|
20
22
|
const account = globalAccountWallet?.getAccount();
|
|
21
23
|
setGlobalAccount(globalAccountWallet);
|
|
22
24
|
setAddress(account?.address);
|
|
@@ -25,5 +27,6 @@ export function useGlobalAccount() {
|
|
|
25
27
|
account: globalAccount,
|
|
26
28
|
address,
|
|
27
29
|
info: walletInfo,
|
|
30
|
+
wallet: globalAccountWallet,
|
|
28
31
|
};
|
|
29
32
|
}
|
package/package.json
CHANGED
|
@@ -8,8 +8,7 @@ import { ArrowDown, Loader2 } from "lucide-react";
|
|
|
8
8
|
import { motion } from "motion/react";
|
|
9
9
|
import { useEffect, useMemo, useRef } from "react";
|
|
10
10
|
import { toast } from "sonner";
|
|
11
|
-
import {
|
|
12
|
-
import { useGlobalWalletState } from "../../utils";
|
|
11
|
+
import { useSetActiveWallet } from "thirdweb/react";
|
|
13
12
|
import { PanelView, useAnyspendFlow } from "../hooks/useAnyspendFlow";
|
|
14
13
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper";
|
|
15
14
|
import { CryptoPaySection } from "./common/CryptoPaySection";
|
|
@@ -145,19 +144,16 @@ function AnySpendCustomExactInInner({
|
|
|
145
144
|
|
|
146
145
|
const { connectedEOAWallet } = useAccountWallet();
|
|
147
146
|
const setActiveWallet = useSetActiveWallet();
|
|
148
|
-
const activeWallet = useActiveWallet();
|
|
149
|
-
const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
|
|
150
147
|
const appliedPreferEoa = useRef(false);
|
|
151
148
|
|
|
152
149
|
useEffect(() => {
|
|
153
150
|
if (preferEoa && !appliedPreferEoa.current) {
|
|
154
151
|
if (connectedEOAWallet) {
|
|
155
152
|
appliedPreferEoa.current = true;
|
|
156
|
-
setGlobalAccountWallet(activeWallet);
|
|
157
153
|
setActiveWallet(connectedEOAWallet);
|
|
158
154
|
}
|
|
159
155
|
}
|
|
160
|
-
}, [preferEoa, connectedEOAWallet, setActiveWallet
|
|
156
|
+
}, [preferEoa, connectedEOAWallet, setActiveWallet]);
|
|
161
157
|
|
|
162
158
|
const selectedRecipientOrDefault = selectedRecipientAddress ?? recipientAddress;
|
|
163
159
|
|
|
@@ -6,7 +6,7 @@ import invariant from "invariant";
|
|
|
6
6
|
import { motion } from "motion/react";
|
|
7
7
|
import { useEffect, useMemo, useRef } from "react";
|
|
8
8
|
import { toast } from "sonner";
|
|
9
|
-
import {
|
|
9
|
+
import { useSetActiveWallet } from "thirdweb/react";
|
|
10
10
|
import { base } from "viem/chains";
|
|
11
11
|
import { PanelView, useAnyspendFlow } from "../hooks/useAnyspendFlow";
|
|
12
12
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper";
|
|
@@ -20,7 +20,6 @@ import { PointsDetailPanel } from "./common/PointsDetailPanel";
|
|
|
20
20
|
import { RecipientSelection } from "./common/RecipientSelection";
|
|
21
21
|
|
|
22
22
|
import { ArrowDown, Loader2 } from "lucide-react";
|
|
23
|
-
import { useGlobalWalletState } from "../../utils";
|
|
24
23
|
import { PanelOnramp } from "./common/PanelOnramp";
|
|
25
24
|
|
|
26
25
|
const SLIPPAGE_PERCENT = 3;
|
|
@@ -119,19 +118,16 @@ function AnySpendDepositHypeInner({
|
|
|
119
118
|
|
|
120
119
|
const { connectedEOAWallet: connectedEOAWallet } = useAccountWallet();
|
|
121
120
|
const setActiveWallet = useSetActiveWallet();
|
|
122
|
-
const activeWallet = useActiveWallet();
|
|
123
|
-
const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
|
|
124
121
|
const appliedPreferEoa = useRef(false);
|
|
125
122
|
|
|
126
123
|
useEffect(() => {
|
|
127
124
|
if (preferEoa && !appliedPreferEoa.current) {
|
|
128
125
|
if (connectedEOAWallet) {
|
|
129
126
|
appliedPreferEoa.current = true;
|
|
130
|
-
setGlobalAccountWallet(activeWallet);
|
|
131
127
|
setActiveWallet(connectedEOAWallet);
|
|
132
128
|
}
|
|
133
129
|
}
|
|
134
|
-
}, [preferEoa, connectedEOAWallet, setActiveWallet
|
|
130
|
+
}, [preferEoa, connectedEOAWallet, setActiveWallet]);
|
|
135
131
|
|
|
136
132
|
// Button state logic
|
|
137
133
|
const btnInfo: { text: string; disable: boolean; error: boolean; loading: boolean } = useMemo(() => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useGlobalWalletState } from "@b3dotfun/sdk/anyspend/utils";
|
|
4
3
|
import { useAccountWallet } from "@b3dotfun/sdk/global-account/react";
|
|
5
4
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
6
5
|
import { shortenAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
|
|
@@ -10,7 +9,7 @@ import { ChevronLeft, ChevronRightCircle, Wallet, X, ZapIcon } from "lucide-reac
|
|
|
10
9
|
import { useState } from "react";
|
|
11
10
|
import { createPortal } from "react-dom";
|
|
12
11
|
import { toast } from "sonner";
|
|
13
|
-
import {
|
|
12
|
+
import { useSetActiveWallet, useWalletInfo } from "thirdweb/react";
|
|
14
13
|
import { WalletId, createWallet } from "thirdweb/wallets";
|
|
15
14
|
import { useAccount, useConnect, useDisconnect, useWalletClient } from "wagmi";
|
|
16
15
|
import { useConnectedWalletDisplay } from "../../hooks/useConnectedWalletDisplay";
|
|
@@ -56,9 +55,6 @@ export function CryptoPaymentMethod({
|
|
|
56
55
|
const setActiveWallet = useSetActiveWallet();
|
|
57
56
|
const { data: eoaWalletInfo } = useWalletInfo(connectedEOAWallet?.id);
|
|
58
57
|
|
|
59
|
-
const activeWallet = useActiveWallet();
|
|
60
|
-
const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
|
|
61
|
-
|
|
62
58
|
const isConnected = !!connectedEOAWallet;
|
|
63
59
|
const globalAddress = connectedSmartWallet?.getAccount()?.address;
|
|
64
60
|
|
|
@@ -225,7 +221,6 @@ export function CryptoPaymentMethod({
|
|
|
225
221
|
onClick={() => {
|
|
226
222
|
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
227
223
|
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
228
|
-
setGlobalAccountWallet(activeWallet);
|
|
229
224
|
if (connectedEOAWallet) {
|
|
230
225
|
setActiveWallet(connectedEOAWallet);
|
|
231
226
|
}
|
|
@@ -12,8 +12,7 @@ import {
|
|
|
12
12
|
import { AnySpendDepositHype } from "@b3dotfun/sdk/anyspend/react/components/AnyspendDepositHype";
|
|
13
13
|
import { AnySpendStakeUpside } from "@b3dotfun/sdk/anyspend/react/components/AnySpendStakeUpside";
|
|
14
14
|
import { AnySpendStakeUpsideExactIn } from "@b3dotfun/sdk/anyspend/react/components/AnySpendStakeUpsideExactIn";
|
|
15
|
-
import {
|
|
16
|
-
import { useIsMobile, useModalStore } from "@b3dotfun/sdk/global-account/react";
|
|
15
|
+
import { useGlobalAccount, useIsMobile, useModalStore } from "@b3dotfun/sdk/global-account/react";
|
|
17
16
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
18
17
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
19
18
|
import { useEffect, useRef } from "react";
|
|
@@ -35,22 +34,19 @@ export function B3DynamicModal() {
|
|
|
35
34
|
const { theme } = useB3();
|
|
36
35
|
const isMobile = useIsMobile();
|
|
37
36
|
const prevIsOpenRef = useRef(isOpen);
|
|
38
|
-
|
|
39
|
-
const globalAccountWallet = useGlobalWalletState(state => state.globalAccountWallet);
|
|
40
|
-
const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
|
|
37
|
+
const { wallet } = useGlobalAccount();
|
|
41
38
|
const setActiveWallet = useSetActiveWallet();
|
|
42
39
|
|
|
43
40
|
// anyspend cleanup global account chnages by setting account back
|
|
44
41
|
useEffect(() => {
|
|
45
42
|
if (prevIsOpenRef.current && !isOpen) {
|
|
46
|
-
if (
|
|
47
|
-
setActiveWallet(
|
|
48
|
-
setGlobalAccountWallet(undefined);
|
|
43
|
+
if (wallet) {
|
|
44
|
+
setActiveWallet(wallet);
|
|
49
45
|
}
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
prevIsOpenRef.current = isOpen;
|
|
53
|
-
}, [isOpen,
|
|
49
|
+
}, [isOpen, wallet, setActiveWallet]);
|
|
54
50
|
|
|
55
51
|
// Define arrays for different modal type groups
|
|
56
52
|
const fullWidthTypes = [
|
|
@@ -10,6 +10,7 @@ export function useGlobalAccount() {
|
|
|
10
10
|
const wallets = useConnectedWallets();
|
|
11
11
|
const isConnected = useAuthStore(state => state.isConnected);
|
|
12
12
|
const [globalAccount, setGlobalAccount] = useState<Wallet | undefined>(undefined);
|
|
13
|
+
const [globalAccountWallet, setGlobalAccountWallet] = useState<Wallet | undefined>(undefined);
|
|
13
14
|
const [address, setAddress] = useState<string | undefined>(undefined);
|
|
14
15
|
const walletInfo = useWalletInfo(globalAccount?.id);
|
|
15
16
|
|
|
@@ -22,7 +23,7 @@ export function useGlobalAccount() {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
const globalAccountWallet = wallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
25
|
-
|
|
26
|
+
setGlobalAccountWallet(globalAccountWallet);
|
|
26
27
|
const account = globalAccountWallet?.getAccount();
|
|
27
28
|
setGlobalAccount(globalAccountWallet);
|
|
28
29
|
setAddress(account?.address);
|
|
@@ -32,5 +33,6 @@ export function useGlobalAccount() {
|
|
|
32
33
|
account: globalAccount,
|
|
33
34
|
address,
|
|
34
35
|
info: walletInfo,
|
|
36
|
+
wallet: globalAccountWallet,
|
|
35
37
|
};
|
|
36
38
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Wallet } from "thirdweb/wallets";
|
|
2
|
-
interface GlobalWalletState {
|
|
3
|
-
globalAccountWallet?: Wallet;
|
|
4
|
-
setGlobalAccountWallet: (account?: Wallet) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare const useGlobalWalletState: import("zustand").UseBoundStore<import("zustand").StoreApi<GlobalWalletState>>;
|
|
7
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useGlobalWalletState = void 0;
|
|
4
|
-
const zustand_1 = require("zustand");
|
|
5
|
-
exports.useGlobalWalletState = (0, zustand_1.create)(set => ({
|
|
6
|
-
globalAccountWallet: undefined,
|
|
7
|
-
setGlobalAccountWallet: account => set({ globalAccountWallet: account }),
|
|
8
|
-
}));
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Wallet } from "thirdweb/wallets";
|
|
2
|
-
interface GlobalWalletState {
|
|
3
|
-
globalAccountWallet?: Wallet;
|
|
4
|
-
setGlobalAccountWallet: (account?: Wallet) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare const useGlobalWalletState: import("zustand").UseBoundStore<import("zustand").StoreApi<GlobalWalletState>>;
|
|
7
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Wallet } from "thirdweb/wallets";
|
|
2
|
-
interface GlobalWalletState {
|
|
3
|
-
globalAccountWallet?: Wallet;
|
|
4
|
-
setGlobalAccountWallet: (account?: Wallet) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare const useGlobalWalletState: import("zustand").UseBoundStore<import("zustand").StoreApi<GlobalWalletState>>;
|
|
7
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Wallet } from "thirdweb/wallets";
|
|
2
|
-
import { create } from "zustand";
|
|
3
|
-
|
|
4
|
-
interface GlobalWalletState {
|
|
5
|
-
globalAccountWallet?: Wallet;
|
|
6
|
-
setGlobalAccountWallet: (account?: Wallet) => void;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const useGlobalWalletState = create<GlobalWalletState>(set => ({
|
|
10
|
-
globalAccountWallet: undefined,
|
|
11
|
-
setGlobalAccountWallet: account => set({ globalAccountWallet: account }),
|
|
12
|
-
}));
|