@b3dotfun/sdk 0.0.83-test.0 → 0.0.83
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 +0 -3
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +0 -3
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +47 -177
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +0 -3
- package/dist/cjs/anyspend/utils/chain.d.ts +38 -0
- package/dist/cjs/anyspend/utils/chain.js +22 -1
- package/dist/cjs/anyspend/utils/token.d.ts +3 -0
- package/dist/cjs/anyspend/utils/token.js +17 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +12 -57
- package/dist/cjs/global-account/react/hooks/index.d.ts +0 -1
- package/dist/cjs/global-account/react/hooks/index.js +1 -3
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +63 -72
- package/dist/cjs/global-account/react/hooks/useTWAuth.d.ts +0 -3
- package/dist/cjs/global-account/react/hooks/useTWAuth.js +0 -8
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +24 -54
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +0 -3
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +0 -3
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +45 -175
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +0 -3
- package/dist/esm/anyspend/utils/chain.d.ts +38 -0
- package/dist/esm/anyspend/utils/chain.js +22 -1
- package/dist/esm/anyspend/utils/token.d.ts +3 -0
- package/dist/esm/anyspend/utils/token.js +15 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +12 -57
- package/dist/esm/global-account/react/hooks/index.d.ts +0 -1
- package/dist/esm/global-account/react/hooks/index.js +0 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +63 -72
- package/dist/esm/global-account/react/hooks/useTWAuth.d.ts +0 -3
- package/dist/esm/global-account/react/hooks/useTWAuth.js +0 -8
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +24 -54
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/utils/chain.d.ts +38 -0
- package/dist/types/anyspend/utils/token.d.ts +3 -0
- package/dist/types/global-account/react/hooks/index.d.ts +0 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useTWAuth.d.ts +0 -3
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +0 -4
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +1 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +0 -4
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +22 -253
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +0 -4
- package/src/anyspend/utils/chain.ts +31 -1
- package/src/anyspend/utils/token.ts +17 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +22 -77
- package/src/global-account/react/hooks/index.ts +0 -1
- package/src/global-account/react/hooks/useAuthentication.ts +85 -88
- package/src/global-account/react/hooks/useTWAuth.tsx +0 -10
- package/src/global-account/react/hooks/useTurnkeyAuth.ts +26 -59
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +0 -73
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +0 -76
- package/dist/cjs/global-account/react/hooks/useAuth.js +0 -338
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +0 -70
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +0 -76
- package/dist/esm/global-account/react/hooks/useAuth.js +0 -332
- package/dist/types/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
- package/dist/types/global-account/react/hooks/useAuth.d.ts +0 -76
- package/src/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.ts +0 -80
- package/src/global-account/react/hooks/useAuth.ts +0 -380
|
@@ -4,13 +4,8 @@ import { toast, useAccountWallet, WalletImage } from "../../../../global-account
|
|
|
4
4
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
5
5
|
import { shortenAddress } from "../../../../shared/utils/formatAddress.js";
|
|
6
6
|
import { client } from "../../../../shared/utils/thirdweb.js";
|
|
7
|
-
import { WalletCoinbase, WalletMetamask, WalletRainbow, WalletWalletConnect } from "@web3icons/react";
|
|
8
7
|
import { ChevronLeft, ChevronRightCircle, Wallet, X, ZapIcon } from "lucide-react";
|
|
9
|
-
import {
|
|
10
|
-
import { createPortal } from "react-dom";
|
|
11
|
-
import { useSetActiveWallet, useWalletInfo } from "thirdweb/react";
|
|
12
|
-
import { createWallet } from "thirdweb/wallets";
|
|
13
|
-
import { useAccount, useConnect, useDisconnect, useWalletClient } from "wagmi";
|
|
8
|
+
import { useConnectModal, useDisconnect, useWalletInfo } from "thirdweb/react";
|
|
14
9
|
import { useConnectedWalletDisplay } from "../../hooks/useConnectedWalletDisplay.js";
|
|
15
10
|
export var CryptoPaymentMethodType;
|
|
16
11
|
(function (CryptoPaymentMethodType) {
|
|
@@ -20,195 +15,70 @@ export var CryptoPaymentMethodType;
|
|
|
20
15
|
CryptoPaymentMethodType["TRANSFER_CRYPTO"] = "transfer_crypto";
|
|
21
16
|
})(CryptoPaymentMethodType || (CryptoPaymentMethodType = {}));
|
|
22
17
|
export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod, isCreatingOrder, onBack, onSelectPaymentMethod, }) {
|
|
23
|
-
const { connectedEOAWallet
|
|
24
|
-
const { connector, address } = useAccount();
|
|
25
|
-
const { connect, connectors, isPending } = useConnect();
|
|
18
|
+
const { connectedEOAWallet, connectedSmartWallet } = useAccountWallet();
|
|
26
19
|
const { disconnect } = useDisconnect();
|
|
27
|
-
const {
|
|
28
|
-
const [showWalletModal, setShowWalletModal] = useState(false);
|
|
29
|
-
const setActiveWallet = useSetActiveWallet();
|
|
20
|
+
const { connect: openConnectModal } = useConnectModal();
|
|
30
21
|
const { data: eoaWalletInfo } = useWalletInfo(connectedEOAWallet?.id);
|
|
31
|
-
const isConnected = !!connectedEOAWallet;
|
|
32
22
|
const globalAddress = connectedSmartWallet?.getAccount()?.address;
|
|
33
23
|
// Use custom hook to determine wallet display logic
|
|
34
|
-
const { shouldShowConnectedEOA
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const getThirdwebWalletId = (connectorName) => {
|
|
38
|
-
const walletMap = {
|
|
39
|
-
MetaMask: "io.metamask",
|
|
40
|
-
"Coinbase Wallet": "com.coinbase.wallet",
|
|
41
|
-
Rainbow: "me.rainbow",
|
|
42
|
-
WalletConnect: "walletConnect",
|
|
43
|
-
Phantom: "app.phantom",
|
|
44
|
-
};
|
|
45
|
-
return walletMap[connectorName] || null;
|
|
46
|
-
};
|
|
47
|
-
// Create thirdweb wallet from wagmi connector
|
|
48
|
-
const createThirdwebWalletFromConnector = async (connectorName) => {
|
|
49
|
-
const walletId = getThirdwebWalletId(connectorName);
|
|
50
|
-
if (!walletId) {
|
|
51
|
-
console.warn(`No thirdweb wallet ID found for connector: ${connectorName}`);
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
const thirdwebWallet = createWallet(walletId);
|
|
56
|
-
// Connect the wallet to sync with the existing wagmi connection
|
|
57
|
-
await thirdwebWallet.connect({ client });
|
|
58
|
-
return thirdwebWallet;
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
console.error(`Failed to create thirdweb wallet for ${connectorName}:`, error);
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
// Define available wallet connectors
|
|
66
|
-
const availableConnectors = connectors.filter(connector => ["MetaMask", "WalletConnect", "Coinbase Wallet", "Rainbow", "Phantom"].includes(connector.name));
|
|
67
|
-
// Define wallet options with icons and info
|
|
68
|
-
const walletOptions = [
|
|
69
|
-
{
|
|
70
|
-
id: "metamask",
|
|
71
|
-
name: "MetaMask",
|
|
72
|
-
icon: _jsx(WalletMetamask, { size: 48 }),
|
|
73
|
-
description: "Connect using MetaMask browser extension",
|
|
74
|
-
connector: availableConnectors.find(c => c.name === "MetaMask"),
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
id: "coinbase",
|
|
78
|
-
name: "Coinbase Wallet",
|
|
79
|
-
icon: _jsx(WalletCoinbase, { size: 48 }),
|
|
80
|
-
description: "Connect using Coinbase Wallet",
|
|
81
|
-
connector: availableConnectors.find(c => c.name === "Coinbase Wallet"),
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: "rainbow",
|
|
85
|
-
name: "Rainbow",
|
|
86
|
-
icon: _jsx(WalletRainbow, { size: 48 }),
|
|
87
|
-
description: "Connect using Rainbow wallet",
|
|
88
|
-
connector: availableConnectors.find(c => c.name === "Rainbow"),
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
id: "walletconnect",
|
|
92
|
-
name: "WalletConnect",
|
|
93
|
-
icon: _jsx(WalletWalletConnect, { size: 48 }),
|
|
94
|
-
description: "Connect using WalletConnect protocol",
|
|
95
|
-
connector: availableConnectors.find(c => c.name === "WalletConnect"),
|
|
96
|
-
},
|
|
97
|
-
].filter(wallet => wallet.connector); // Only show wallets that have available connectors
|
|
98
|
-
// Reset modal state when closing
|
|
99
|
-
const handleCloseModal = () => {
|
|
100
|
-
setShowWalletModal(false);
|
|
101
|
-
};
|
|
102
|
-
// Function to request wallet permissions for specific wallet
|
|
103
|
-
const requestWalletPermissions = async (walletConnector) => {
|
|
24
|
+
const { shouldShowConnectedEOA } = useConnectedWalletDisplay(selectedPaymentMethod);
|
|
25
|
+
// Handle wallet connection using thirdweb modal
|
|
26
|
+
const handleConnectWallet = async () => {
|
|
104
27
|
try {
|
|
105
|
-
//
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
// if (isConnected) {
|
|
109
|
-
// disconnect();
|
|
110
|
-
// // Small delay to ensure disconnection
|
|
111
|
-
// await new Promise(resolve => setTimeout(resolve, 100));
|
|
112
|
-
// }
|
|
113
|
-
await connect({ connector: walletConnector });
|
|
114
|
-
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
115
|
-
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
116
|
-
toast.success(`Connected to ${walletConnector.name}`);
|
|
117
|
-
return;
|
|
28
|
+
// Disconnect current wallet before connecting a new one
|
|
29
|
+
if (connectedEOAWallet) {
|
|
30
|
+
await disconnect(connectedEOAWallet);
|
|
118
31
|
}
|
|
119
|
-
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
method: "wallet_requestPermissions",
|
|
123
|
-
params: [{ eth_accounts: {} }],
|
|
124
|
-
});
|
|
125
|
-
toast.success("Account selection completed");
|
|
32
|
+
const wallet = await openConnectModal({ client, setActive: false });
|
|
33
|
+
if (wallet) {
|
|
34
|
+
// setActiveWallet(wallet);
|
|
126
35
|
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
127
36
|
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
128
|
-
|
|
129
|
-
else {
|
|
130
|
-
// Fallback: show modal for manual wallet selection
|
|
131
|
-
setShowWalletModal(true);
|
|
37
|
+
toast.success("Wallet connected");
|
|
132
38
|
}
|
|
133
39
|
}
|
|
134
40
|
catch (error) {
|
|
135
|
-
console.error("Failed to
|
|
41
|
+
console.error("Failed to connect wallet:", error);
|
|
136
42
|
if (error && typeof error === "object" && "message" in error) {
|
|
137
43
|
const errorMessage = error.message.toLowerCase();
|
|
138
44
|
if (errorMessage.includes("rejected") ||
|
|
139
45
|
errorMessage.includes("denied") ||
|
|
140
46
|
errorMessage.includes("cancelled")) {
|
|
141
|
-
|
|
47
|
+
// User cancelled - no toast needed
|
|
142
48
|
}
|
|
143
49
|
else {
|
|
144
|
-
toast.error("Failed to
|
|
50
|
+
toast.error("Failed to connect wallet");
|
|
145
51
|
}
|
|
146
52
|
}
|
|
147
|
-
else {
|
|
148
|
-
toast.error("Failed to open account selection");
|
|
149
|
-
}
|
|
150
53
|
}
|
|
151
54
|
};
|
|
152
|
-
return (
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
toast.success(`Selected ${connector?.name || "wallet"}`);
|
|
183
|
-
}, className: cn("crypto-payment-method-connect-wallet wagmi-wallet w-full rounded-xl border p-4 text-left transition-all hover:shadow-md", selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET
|
|
184
|
-
? "connected-wallet border-as-brand bg-as-brand/5"
|
|
185
|
-
: "border-as-border-secondary bg-as-surface-primary hover:border-as-secondary/80"), children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "wallet-icon flex h-10 w-10 items-center justify-center rounded-full bg-blue-100", children: _jsx(Wallet, { className: "h-5 w-5 text-blue-600" }) }), _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { className: "text-as-primary font-semibold", children: connector?.name || "Connected Wallet" }), _jsx("span", { className: "text-as-primary/60 text-sm", children: shortenAddress(address || "") })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET && (_jsx("div", { className: "h-2 w-2 rounded-full bg-green-500" })), _jsx("button", { onClick: e => {
|
|
186
|
-
e.stopPropagation();
|
|
187
|
-
disconnect();
|
|
188
|
-
toast.success("Wallet disconnected");
|
|
189
|
-
if (selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
190
|
-
setSelectedPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
191
|
-
}
|
|
192
|
-
}, className: "text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors", children: _jsx(X, { className: "h-4 w-4" }) })] })] }) })), globalAddress && (_jsx("button", { onClick: () => {
|
|
193
|
-
setSelectedPaymentMethod(CryptoPaymentMethodType.GLOBAL_WALLET);
|
|
194
|
-
onSelectPaymentMethod(CryptoPaymentMethodType.GLOBAL_WALLET);
|
|
195
|
-
toast.success("Selected B3 Account");
|
|
196
|
-
}, className: cn("crypto-payment-method-global-wallet w-full rounded-xl border p-4 text-left transition-all hover:shadow-md", selectedPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET
|
|
197
|
-
? "connected-wallet border-as-brand bg-as-brand/5"
|
|
198
|
-
: "border-as-border-secondary bg-as-surface-primary hover:border-as-secondary/80"), children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(WalletImage, { fallback: _jsx("div", { className: "wallet-icon flex h-10 w-10 items-center justify-center rounded-full bg-purple-100", children: _jsx(Wallet, { className: "h-5 w-5 text-purple-600" }) }) }), _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { className: "text-as-primary font-semibold", children: "Global Account" }), _jsx("span", { className: "text-as-primary/60 text-sm", children: shortenAddress(globalAddress || "") })] })] }), _jsx("div", { className: "flex items-center gap-2", children: selectedPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET && (_jsx("div", { className: "h-2 w-2 rounded-full bg-green-500" })) })] }) }))] })] })), _jsxs("div", { className: "other-payment-methods", children: [_jsx("h3", { className: "text-as-primary/80 mb-3 text-sm font-medium", children: "Payment methods" }), _jsxs("div", { className: "space-y-3", children: [_jsxs("button", { onClick: () => {
|
|
199
|
-
// Always show wallet selection modal first
|
|
200
|
-
setShowWalletModal(true);
|
|
201
|
-
}, className: "crypto-payment-method-connect-wallet bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-blue-100", children: _jsx(Wallet, { className: "h-4 w-4 text-blue-600" }) }), _jsx("div", { className: "flex flex-col items-start text-left", children: _jsx("h4", { className: "text-as-primary font-semibold", children: "Connect wallet" }) })] }), _jsx(ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] }), _jsxs("button", { onClick: () => {
|
|
202
|
-
setSelectedPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
203
|
-
onSelectPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
204
|
-
}, disabled: isCreatingOrder, className: "crypto-payment-method-transfer bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-orange-100", children: _jsx(ZapIcon, { className: "h-4 w-4" }) }), _jsx("div", { className: "flex flex-col items-start text-left", children: _jsx("h4", { className: "text-as-primary font-semibold", children: "Transfer crypto" }) })] }), _jsx(ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })] })] })] })] }), showWalletModal &&
|
|
205
|
-
createPortal(_jsx("div", { className: "wallet-connection-modal pointer-events-auto fixed inset-0 z-[9999] flex items-center justify-center bg-black/50", children: _jsxs("div", { className: "max-h-[80vh] w-[400px] max-w-[90vw] overflow-auto rounded-xl bg-white p-6 dark:bg-gray-900", children: [_jsxs("div", { className: "mb-4 flex items-center justify-between", children: [_jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: isConnected ? "Switch wallet or account" : "Choose wallet to connect" }), _jsx("button", { onClick: handleCloseModal, className: "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200", children: _jsx(X, { className: "h-5 w-5" }) })] }), _jsx("div", { className: "space-y-4", children: _jsx("div", { className: "space-y-3", children: walletOptions.map(walletOption => {
|
|
206
|
-
const isCurrentWallet = isConnected && connector?.name === walletOption.connector?.name;
|
|
207
|
-
return (_jsx("button", { onClick: async () => {
|
|
208
|
-
handleCloseModal();
|
|
209
|
-
await requestWalletPermissions(walletOption.connector);
|
|
210
|
-
}, disabled: isPending, className: `wallet-option w-full rounded-xl border p-4 text-left transition-all hover:shadow-md disabled:opacity-50 ${isCurrentWallet
|
|
211
|
-
? "wallet-option--active border-blue-500 bg-blue-50 dark:bg-blue-900/20"
|
|
212
|
-
: "border-gray-200 bg-white hover:border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:hover:border-gray-500"}`, children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-3", children: [walletOption.icon, _jsxs("div", { children: [_jsxs("div", { className: "wallet-option-name flex items-center gap-2", children: [_jsx("div", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: walletOption.name }), isCurrentWallet && (_jsx("span", { className: "rounded-full bg-blue-100 px-2 py-0.5 text-xs font-medium text-blue-700 dark:bg-blue-800 dark:text-blue-200", children: "Connected" }))] }), _jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400", children: isCurrentWallet ? "Switch account or reconnect" : walletOption.description })] })] }), _jsx(ChevronRightCircle, { className: "h-5 w-5 text-gray-400" })] }) }, walletOption.id));
|
|
213
|
-
}) }) })] }) }), typeof window !== "undefined" ? document.getElementById("b3-root") || document.body : document.body)] }));
|
|
55
|
+
return (_jsx("div", { className: "crypto-payment-method mx-auto h-fit w-[460px] max-w-full px-5 pb-5 pt-5 sm:px-0 sm:pt-5", 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" }) }) }), process.env.NODE_ENV === "development" && (_jsxs("div", { className: "rounded-lg border border-yellow-500/50 bg-yellow-50 p-3 dark:bg-yellow-950/20", children: [_jsx("p", { className: "mb-2 text-xs font-semibold text-yellow-800 dark:text-yellow-300", children: "\uD83E\uDDEA Toast Test (Dev Only)" }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx("button", { onClick: () => toast.success("Success! Transaction completed"), className: "rounded bg-green-600 px-2 py-1 text-xs font-medium text-white hover:bg-green-700", children: "Success" }), _jsx("button", { onClick: () => toast.error("Error! Transaction failed"), className: "rounded bg-red-600 px-2 py-1 text-xs font-medium text-white hover:bg-red-700", children: "Error" }), _jsx("button", { onClick: () => toast.info("Info: Processing your request..."), className: "rounded bg-blue-600 px-2 py-1 text-xs font-medium text-white hover:bg-blue-700", children: "Info" }), _jsx("button", { onClick: () => toast.warning("Warning: Low balance detected"), className: "rounded bg-yellow-600 px-2 py-1 text-xs font-medium text-white hover:bg-yellow-700", children: "Warning" }), _jsx("button", { onClick: () => {
|
|
56
|
+
toast.success("Multiple test 1");
|
|
57
|
+
setTimeout(() => toast.info("Multiple test 2"), 200);
|
|
58
|
+
setTimeout(() => toast.warning("Multiple test 3"), 400);
|
|
59
|
+
}, className: "rounded bg-purple-600 px-2 py-1 text-xs font-medium text-white hover:bg-purple-700", children: "Multiple" })] })] })), _jsxs("div", { className: "crypto-payment-methods flex flex-col gap-4", children: [(shouldShowConnectedEOA || 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: () => {
|
|
60
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
61
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
62
|
+
toast.success(`Selected ${eoaWalletInfo?.name || "wallet"}`);
|
|
63
|
+
}, className: cn("crypto-payment-method-connect-wallet eoa-wallet w-full rounded-xl border p-4 text-left transition-all hover:shadow-md", selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET
|
|
64
|
+
? "connected-wallet border-as-brand bg-as-brand/5"
|
|
65
|
+
: "border-as-border-secondary bg-as-surface-primary hover:border-as-secondary/80"), children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "wallet-icon flex h-10 w-10 items-center justify-center rounded-full bg-blue-100", children: _jsx(Wallet, { className: "h-5 w-5 text-blue-600" }) }), _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { className: "text-as-primary font-semibold", children: eoaWalletInfo?.name || "Connected Wallet" }), _jsx("span", { className: "text-as-primary/60 text-sm", children: shortenAddress(connectedEOAWallet?.getAccount()?.address || "") })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET && (_jsx("div", { className: "h-2 w-2 rounded-full bg-green-500" })), _jsx("button", { onClick: e => {
|
|
66
|
+
e.stopPropagation();
|
|
67
|
+
if (connectedEOAWallet) {
|
|
68
|
+
disconnect(connectedEOAWallet);
|
|
69
|
+
}
|
|
70
|
+
toast.success("Wallet disconnected");
|
|
71
|
+
if (selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
72
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
73
|
+
}
|
|
74
|
+
}, className: "text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors", children: _jsx(X, { className: "h-4 w-4" }) })] })] }) })), globalAddress && (_jsx("button", { onClick: () => {
|
|
75
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.GLOBAL_WALLET);
|
|
76
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.GLOBAL_WALLET);
|
|
77
|
+
toast.success("Selected B3 Account");
|
|
78
|
+
}, className: cn("crypto-payment-method-global-wallet w-full rounded-xl border p-4 text-left transition-all hover:shadow-md", selectedPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET
|
|
79
|
+
? "connected-wallet border-as-brand bg-as-brand/5"
|
|
80
|
+
: "border-as-border-secondary bg-as-surface-primary hover:border-as-secondary/80"), children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(WalletImage, { fallback: _jsx("div", { className: "wallet-icon flex h-10 w-10 items-center justify-center rounded-full bg-purple-100", children: _jsx(Wallet, { className: "h-5 w-5 text-purple-600" }) }) }), _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { className: "text-as-primary font-semibold", children: "Global Account" }), _jsx("span", { className: "text-as-primary/60 text-sm", children: shortenAddress(globalAddress || "") })] })] }), _jsx("div", { className: "flex items-center gap-2", children: selectedPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET && (_jsx("div", { className: "h-2 w-2 rounded-full bg-green-500" })) })] }) }))] })] })), _jsxs("div", { className: "other-payment-methods", children: [_jsx("h3", { className: "text-as-primary/80 mb-3 text-sm font-medium", children: "Payment methods" }), _jsxs("div", { className: "space-y-3", children: [_jsxs("button", { onClick: handleConnectWallet, className: "crypto-payment-method-connect-wallet bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-blue-100", children: _jsx(Wallet, { className: "h-4 w-4 text-blue-600" }) }), _jsx("div", { className: "flex flex-col items-start text-left", children: _jsx("h4", { className: "text-as-primary font-semibold", children: "Connect wallet" }) })] }), _jsx(ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] }), _jsxs("button", { onClick: () => {
|
|
81
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
82
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
83
|
+
}, disabled: isCreatingOrder, className: "crypto-payment-method-transfer bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-orange-100", children: _jsx(ZapIcon, { className: "h-4 w-4" }) }), _jsx("div", { className: "flex flex-col items-start text-left", children: _jsx("h4", { className: "text-as-primary font-semibold", children: "Transfer crypto" }) })] }), _jsx(ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })] })] })] })] }) }));
|
|
214
84
|
}
|
|
@@ -9,7 +9,6 @@ import { base, mainnet } from "viem/chains";
|
|
|
9
9
|
import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMethod.js";
|
|
10
10
|
import { FiatPaymentMethod } from "../components/common/FiatPaymentMethod.js";
|
|
11
11
|
import { useAutoSelectCryptoPaymentMethod } from "./useAutoSelectCryptoPaymentMethod.js";
|
|
12
|
-
import { useAutoSetActiveWalletFromWagmi } from "./useAutoSetActiveWalletFromWagmi.js";
|
|
13
12
|
import { useConnectedWalletDisplay } from "./useConnectedWalletDisplay.js";
|
|
14
13
|
import { useCryptoPaymentMethodState } from "./useCryptoPaymentMethodState.js";
|
|
15
14
|
import { useRecipientAddressState } from "./useRecipientAddressState.js";
|
|
@@ -49,8 +48,6 @@ export function useAnyspendFlow({ paymentType = "crypto", recipientAddress, load
|
|
|
49
48
|
// Recipient state with dual-state system (auto + explicit user selection)
|
|
50
49
|
const { address: globalAddress } = useAccountWallet();
|
|
51
50
|
const { walletAddress } = useConnectedWalletDisplay(effectiveCryptoPaymentMethod);
|
|
52
|
-
// Auto-set active wallet from wagmi
|
|
53
|
-
useAutoSetActiveWalletFromWagmi();
|
|
54
51
|
// Recipient address state - hook automatically manages priority: props > user selection > wallet/global
|
|
55
52
|
const { setSelectedRecipientAddress, effectiveRecipientAddress } = useRecipientAddressState({
|
|
56
53
|
recipientAddressFromProps: recipientAddress,
|
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
import { components } from "../../anyspend/types/api";
|
|
2
2
|
import { Account, Chain, PublicClient, Transport, WalletClient } from "viem";
|
|
3
3
|
import { ChainType, IBaseChain, IEVMChain, ISolanaChain } from "../types/chain";
|
|
4
|
+
export declare const hyperEVM: {
|
|
5
|
+
blockExplorers: {
|
|
6
|
+
readonly default: {
|
|
7
|
+
readonly name: "HyperEVM Explorer";
|
|
8
|
+
readonly url: "https://hyperevmscan.io/";
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
blockTime?: number | undefined | undefined;
|
|
12
|
+
contracts?: {
|
|
13
|
+
[x: string]: import("viem").ChainContract | {
|
|
14
|
+
[sourceId: number]: import("viem").ChainContract | undefined;
|
|
15
|
+
} | undefined;
|
|
16
|
+
ensRegistry?: import("viem").ChainContract | undefined;
|
|
17
|
+
ensUniversalResolver?: import("viem").ChainContract | undefined;
|
|
18
|
+
multicall3?: import("viem").ChainContract | undefined;
|
|
19
|
+
erc6492Verifier?: import("viem").ChainContract | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
ensTlds?: readonly string[] | undefined;
|
|
22
|
+
id: 999;
|
|
23
|
+
name: "HyperEVM";
|
|
24
|
+
nativeCurrency: {
|
|
25
|
+
readonly name: "HyperEVM";
|
|
26
|
+
readonly symbol: "HYPE";
|
|
27
|
+
readonly decimals: 18;
|
|
28
|
+
};
|
|
29
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
30
|
+
rpcUrls: {
|
|
31
|
+
readonly default: {
|
|
32
|
+
readonly http: readonly ["https://rpc.hyperliquid.xyz/evm"];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
sourceId?: number | undefined | undefined;
|
|
36
|
+
testnet?: boolean | undefined | undefined;
|
|
37
|
+
custom?: Record<string, unknown> | undefined;
|
|
38
|
+
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
39
|
+
formatters?: undefined;
|
|
40
|
+
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
41
|
+
};
|
|
4
42
|
export declare const EVM_MAINNET: Record<number, IEVMChain>;
|
|
5
43
|
export declare const EVM_TESTNET: Record<number, IEVMChain>;
|
|
6
44
|
export declare const SOLANA_MAINNET: ISolanaChain;
|
|
@@ -3,10 +3,17 @@ import invariant from "invariant";
|
|
|
3
3
|
import { createPublicClient, createWalletClient, defineChain, http, parseEther, } from "viem";
|
|
4
4
|
import { abstract, arbitrum, avalanche, b3, base, bsc, mainnet, optimism, polygon } from "viem/chains";
|
|
5
5
|
import { ChainType } from "../types/chain.js";
|
|
6
|
-
import { getAvaxToken, getBnbToken, getEthToken, getPolToken, getSolanaToken } from "./token.js";
|
|
6
|
+
import { getAvaxToken, getBnbToken, getEthToken, getHyperEVMNativeToken, getPolToken, getSolanaToken, HYPEREVM_CHAIN_ID, } from "./token.js";
|
|
7
7
|
function getCustomEvmChain(chain, rpcUrl) {
|
|
8
8
|
return defineChain({ ...chain, rpcUrls: { default: { http: [rpcUrl] } } });
|
|
9
9
|
}
|
|
10
|
+
export const hyperEVM = defineChain({
|
|
11
|
+
id: HYPEREVM_CHAIN_ID,
|
|
12
|
+
name: "HyperEVM",
|
|
13
|
+
nativeCurrency: { name: "HyperEVM", symbol: "HYPE", decimals: 18 },
|
|
14
|
+
rpcUrls: { default: { http: ["https://rpc.hyperliquid.xyz/evm"] } },
|
|
15
|
+
blockExplorers: { default: { name: "HyperEVM Explorer", url: "https://hyperevmscan.io/" } },
|
|
16
|
+
});
|
|
10
17
|
// export const b4testnet = defineChain({
|
|
11
18
|
// id: 19934,
|
|
12
19
|
// name: "B4 Testnet",
|
|
@@ -150,6 +157,20 @@ export const EVM_MAINNET = {
|
|
|
150
157
|
coingeckoName: "abstract",
|
|
151
158
|
wethAddress: "0x3439153eb7af838ad19d56e1571fbd09333c2809",
|
|
152
159
|
},
|
|
160
|
+
[hyperEVM.id]: {
|
|
161
|
+
id: hyperEVM.id,
|
|
162
|
+
name: hyperEVM.name,
|
|
163
|
+
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/64x64/32196.png",
|
|
164
|
+
type: ChainType.EVM,
|
|
165
|
+
nativeRequired: parseEther("0.01"),
|
|
166
|
+
canDepositNative: true,
|
|
167
|
+
defaultToken: getHyperEVMNativeToken(),
|
|
168
|
+
nativeToken: getHyperEVMNativeToken(),
|
|
169
|
+
viem: hyperEVM,
|
|
170
|
+
pollingInterval: 1000, // 1 second for Hyperliquid
|
|
171
|
+
coingeckoName: "hyperevm",
|
|
172
|
+
wethAddress: "0x5555555555555555555555555555555555555555",
|
|
173
|
+
},
|
|
153
174
|
};
|
|
154
175
|
export const EVM_TESTNET = {
|
|
155
176
|
// [sepolia.id]: {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { components } from "../../anyspend/types/api";
|
|
2
|
+
export declare const HYPERLIQUID_CHAIN_ID = 1337;
|
|
3
|
+
export declare const HYPEREVM_CHAIN_ID = 999;
|
|
2
4
|
export declare function isNativeToken(address: string): boolean;
|
|
3
5
|
export declare function getSolanaToken(): components["schemas"]["Token"];
|
|
4
6
|
export declare function getEthToken(chainId: number): components["schemas"]["Token"];
|
|
5
7
|
export declare function getPolToken(): components["schemas"]["Token"];
|
|
6
8
|
export declare function getBnbToken(): components["schemas"]["Token"];
|
|
7
9
|
export declare function getAvaxToken(): components["schemas"]["Token"];
|
|
10
|
+
export declare function getHyperEVMNativeToken(): components["schemas"]["Token"];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { avalanche, bsc, polygon } from "viem/chains";
|
|
2
1
|
import { RELAY_ETH_ADDRESS, RELAY_SOL_ADDRESS, RELAY_SOLANA_MAINNET_CHAIN_ID } from "../../anyspend/constants/index.js";
|
|
2
|
+
import { avalanche, bsc, polygon } from "viem/chains";
|
|
3
|
+
export const HYPERLIQUID_CHAIN_ID = 1337;
|
|
4
|
+
export const HYPEREVM_CHAIN_ID = 999;
|
|
3
5
|
export function isNativeToken(address) {
|
|
4
6
|
return address.toLowerCase() === RELAY_ETH_ADDRESS || address.toLowerCase() === RELAY_SOL_ADDRESS;
|
|
5
7
|
}
|
|
@@ -63,3 +65,15 @@ export function getAvaxToken() {
|
|
|
63
65
|
},
|
|
64
66
|
};
|
|
65
67
|
}
|
|
68
|
+
export function getHyperEVMNativeToken() {
|
|
69
|
+
return {
|
|
70
|
+
chainId: HYPEREVM_CHAIN_ID,
|
|
71
|
+
address: RELAY_ETH_ADDRESS,
|
|
72
|
+
symbol: "HYPE",
|
|
73
|
+
name: "HYPE",
|
|
74
|
+
decimals: 18,
|
|
75
|
+
metadata: {
|
|
76
|
+
logoURI: "https://s2.coinmarketcap.com/static/img/coins/64x64/32196.png",
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -3,7 +3,6 @@ import { Loading, useAuthStore, useB3, useGetAllTWSigners, useModalStore, } from
|
|
|
3
3
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
4
4
|
import { useCallback, useEffect, useState } from "react";
|
|
5
5
|
import { useActiveAccount } from "thirdweb/react";
|
|
6
|
-
import { TurnkeyAuthModal } from "../TurnkeyAuthModal.js";
|
|
7
6
|
import { SignInWithB3Privy } from "./SignInWithB3Privy.js";
|
|
8
7
|
import { LoginStep, LoginStepContainer } from "./steps/LoginStep.js";
|
|
9
8
|
import { LoginStepCustom } from "./steps/LoginStepCustom.js";
|
|
@@ -21,9 +20,7 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
21
20
|
const account = useActiveAccount();
|
|
22
21
|
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
23
22
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
24
|
-
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
25
23
|
const isConnected = useAuthStore(state => state.isConnected);
|
|
26
|
-
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
27
24
|
const setJustCompletedLogin = useAuthStore(state => state.setJustCompletedLogin);
|
|
28
25
|
const [refetchCount, setRefetchCount] = useState(0);
|
|
29
26
|
const [refetchError, setRefetchError] = useState(null);
|
|
@@ -125,10 +122,6 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
125
122
|
debug("Refetching user after Turnkey success...");
|
|
126
123
|
await refetchUser();
|
|
127
124
|
debug("User refetched successfully");
|
|
128
|
-
// Set authentication and connection state so UI updates properly
|
|
129
|
-
setIsAuthenticated(true);
|
|
130
|
-
setIsConnected(true);
|
|
131
|
-
setJustCompletedLogin(true);
|
|
132
125
|
// After user data is refreshed, close Turnkey modal and go back to sign-in flow
|
|
133
126
|
debug("Switching back to signInWithB3 modal");
|
|
134
127
|
setB3ModalContentType({
|
|
@@ -158,9 +151,6 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
158
151
|
closeAfterLogin,
|
|
159
152
|
source,
|
|
160
153
|
signersEnabled,
|
|
161
|
-
setIsAuthenticated,
|
|
162
|
-
setIsConnected,
|
|
163
|
-
setJustCompletedLogin,
|
|
164
154
|
]);
|
|
165
155
|
// Handle post-login flow after signers are loaded
|
|
166
156
|
useEffect(() => {
|
|
@@ -296,56 +286,21 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
296
286
|
if (refetchError) {
|
|
297
287
|
content = (_jsx(LoginStepContainer, { partnerId: partnerId, children: _jsx("div", { className: "p-4 text-center text-red-500", children: refetchError }) }));
|
|
298
288
|
}
|
|
289
|
+
else if (isAuthenticating || (isFetchingSigners && step === "login") || source === "requestPermissions") {
|
|
290
|
+
content = (_jsx(LoginStepContainer, { partnerId: partnerId, children: _jsx("div", { className: "my-8 flex min-h-[350px] items-center justify-center", children: _jsx(Loading, { variant: "white", size: "lg" }) }) }));
|
|
291
|
+
}
|
|
299
292
|
else if (step === "login") {
|
|
300
|
-
//
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
//
|
|
306
|
-
|
|
307
|
-
enableTurnkey,
|
|
308
|
-
turnkeyAuthCompleted,
|
|
309
|
-
isAuthenticated,
|
|
310
|
-
});
|
|
311
|
-
// Show Turnkey authentication as primary option
|
|
312
|
-
content = (_jsx(LoginStepContainer, { partnerId: partnerId, children: _jsx(TurnkeyAuthModal, { onSuccess: async (authenticatedUser) => {
|
|
313
|
-
debug("Turnkey authentication successful in primary flow", { authenticatedUser });
|
|
314
|
-
setTurnkeyAuthCompleted(true);
|
|
315
|
-
// After Turnkey auth, refetch user to get the full user object
|
|
316
|
-
await refetchUser();
|
|
317
|
-
// User is now authenticated via Turnkey
|
|
318
|
-
// Set both isAuthenticated and isConnected to true so UI updates properly
|
|
319
|
-
// Wallet connection is optional and can happen later for signing transactions
|
|
320
|
-
setIsAuthenticated(true);
|
|
321
|
-
setIsConnected(true);
|
|
322
|
-
setJustCompletedLogin(true);
|
|
323
|
-
// Call the login success callback
|
|
324
|
-
onLoginSuccess?.({});
|
|
325
|
-
}, onClose: () => {
|
|
326
|
-
// If user closes Turnkey modal, they can still use wallet connection as fallback
|
|
327
|
-
setTurnkeyAuthCompleted(true);
|
|
328
|
-
}, initialEmail: "", skipToOtp: false }) }));
|
|
293
|
+
// Custom strategy
|
|
294
|
+
if (strategies?.[0] === "privy") {
|
|
295
|
+
content = _jsx(SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
296
|
+
}
|
|
297
|
+
else if (strategies) {
|
|
298
|
+
// Strategies are explicitly provided
|
|
299
|
+
content = (_jsx(LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
329
300
|
}
|
|
330
301
|
else {
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
content = (_jsx(LoginStepContainer, { partnerId: partnerId, children: _jsx("div", { className: "my-8 flex min-h-[350px] items-center justify-center", children: _jsx(Loading, { variant: "white", size: "lg" }) }) }));
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
// Custom strategy
|
|
337
|
-
if (strategies?.[0] === "privy") {
|
|
338
|
-
content = _jsx(SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
339
|
-
}
|
|
340
|
-
else if (strategies) {
|
|
341
|
-
// Strategies are explicitly provided
|
|
342
|
-
content = (_jsx(LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
343
|
-
}
|
|
344
|
-
else {
|
|
345
|
-
// Default to handle all strategies we support
|
|
346
|
-
content = _jsx(LoginStep, { chain: chain, onSuccess: handleLoginSuccess, onError: onError });
|
|
347
|
-
}
|
|
348
|
-
}
|
|
302
|
+
// Default to handle all strategies we support
|
|
303
|
+
content = _jsx(LoginStep, { chain: chain, onSuccess: handleLoginSuccess, onError: onError });
|
|
349
304
|
}
|
|
350
305
|
}
|
|
351
306
|
return content;
|
|
@@ -3,7 +3,6 @@ export { useAccountAssets } from "./useAccountAssets";
|
|
|
3
3
|
export { useAccountWallet } from "./useAccountWallet";
|
|
4
4
|
export { useAddTWSessionKey } from "./useAddTWSessionKey";
|
|
5
5
|
export { useAnalytics } from "./useAnalytics";
|
|
6
|
-
export { useAuth } from "./useAuth";
|
|
7
6
|
export { useAuthentication } from "./useAuthentication";
|
|
8
7
|
export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
|
|
9
8
|
export { useB3EnsName } from "./useB3EnsName";
|
|
@@ -3,7 +3,6 @@ export { useAccountAssets } from "./useAccountAssets.js";
|
|
|
3
3
|
export { useAccountWallet } from "./useAccountWallet.js";
|
|
4
4
|
export { useAddTWSessionKey } from "./useAddTWSessionKey.js";
|
|
5
5
|
export { useAnalytics } from "./useAnalytics.js";
|
|
6
|
-
export { useAuth } from "./useAuth.js";
|
|
7
6
|
export { useAuthentication } from "./useAuthentication.js";
|
|
8
7
|
export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses.js";
|
|
9
8
|
export { useB3EnsName } from "./useB3EnsName.js";
|
|
@@ -41,8 +41,8 @@ export declare function useAuthentication(partnerId: string): {
|
|
|
41
41
|
name?: string | undefined;
|
|
42
42
|
address?: string | undefined;
|
|
43
43
|
email?: string | undefined;
|
|
44
|
-
phone?: string | undefined;
|
|
45
44
|
username?: string | undefined;
|
|
45
|
+
phone?: string | undefined;
|
|
46
46
|
fid?: string | undefined;
|
|
47
47
|
};
|
|
48
48
|
}[] | undefined;
|
|
@@ -63,6 +63,6 @@ export declare function useAuthentication(partnerId: string): {
|
|
|
63
63
|
turnkeyOtpId?: string | undefined;
|
|
64
64
|
};
|
|
65
65
|
} | undefined;
|
|
66
|
-
refetchUser: () => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
66
|
+
refetchUser: (wallet?: Wallet) => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
67
67
|
setUser: (newUser?: import("@b3dotfun/b3-api").Users) => void;
|
|
68
68
|
};
|