@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
|
@@ -22,7 +22,6 @@ const react_4 = require("react");
|
|
|
22
22
|
const viem_1 = require("viem");
|
|
23
23
|
const chains_1 = require("viem/chains");
|
|
24
24
|
const useAutoSelectCryptoPaymentMethod_1 = require("../hooks/useAutoSelectCryptoPaymentMethod");
|
|
25
|
-
const useAutoSetActiveWalletFromWagmi_1 = require("../hooks/useAutoSetActiveWalletFromWagmi");
|
|
26
25
|
const useConnectedWalletDisplay_1 = require("../hooks/useConnectedWalletDisplay");
|
|
27
26
|
const useCryptoPaymentMethodState_1 = require("../hooks/useCryptoPaymentMethodState");
|
|
28
27
|
const useRecipientAddressState_1 = require("../hooks/useRecipientAddressState");
|
|
@@ -320,8 +319,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
320
319
|
// );
|
|
321
320
|
const { address: globalAddress, wallet: globalWallet, connectedEOAWallet } = (0, react_2.useAccountWallet)();
|
|
322
321
|
const globalWalletImage = (0, useAccountWallet_1.useAccountWalletImage)();
|
|
323
|
-
// Auto-set active wallet from wagmi
|
|
324
|
-
(0, useAutoSetActiveWalletFromWagmi_1.useAutoSetActiveWalletFromWagmi)();
|
|
325
322
|
// Get wallet address based on selected payment method
|
|
326
323
|
const { walletAddress } = (0, useConnectedWalletDisplay_1.useConnectedWalletDisplay)(effectiveCryptoPaymentMethod);
|
|
327
324
|
// Recipient address state with dual-state system (auto + explicit user selection)
|
|
@@ -34,7 +34,7 @@ const react_1 = require("react");
|
|
|
34
34
|
const viem_1 = require("viem");
|
|
35
35
|
const AnySpendCustom_1 = require("./AnySpendCustom");
|
|
36
36
|
// Collector Club Shop contract on Base
|
|
37
|
-
const CC_SHOP_ADDRESS = "
|
|
37
|
+
const CC_SHOP_ADDRESS = "0x47366E64E4917dd4DdC04Fb9DC507c1dD2b87294";
|
|
38
38
|
const BASE_CHAIN_ID = 8453;
|
|
39
39
|
// ABI for buyPacksFor function only
|
|
40
40
|
const BUY_PACKS_FOR_ABI = {
|
|
@@ -52,7 +52,6 @@ const lucide_react_1 = require("lucide-react");
|
|
|
52
52
|
const react_4 = require("motion/react");
|
|
53
53
|
const react_5 = __importStar(require("react"));
|
|
54
54
|
const chains_1 = require("viem/chains");
|
|
55
|
-
const useAutoSetActiveWalletFromWagmi_1 = require("../hooks/useAutoSetActiveWalletFromWagmi");
|
|
56
55
|
const useCryptoPaymentMethodState_1 = require("../hooks/useCryptoPaymentMethodState");
|
|
57
56
|
const useRecipientAddressState_1 = require("../hooks/useRecipientAddressState");
|
|
58
57
|
const AnySpendFingerprintWrapper_1 = require("./AnySpendFingerprintWrapper");
|
|
@@ -150,8 +149,6 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
150
149
|
const hasMounted = (0, react_2.useHasMounted)();
|
|
151
150
|
const searchParams = (0, react_2.useSearchParamsSSR)();
|
|
152
151
|
const router = (0, react_2.useRouter)();
|
|
153
|
-
// Auto-set active wallet from wagmi
|
|
154
|
-
(0, useAutoSetActiveWalletFromWagmi_1.useAutoSetActiveWalletFromWagmi)();
|
|
155
152
|
const [activePanel, setActivePanel] = (0, react_5.useState)(loadOrder ? PanelView.ORDER_DETAILS : PanelView.CONFIRM_ORDER);
|
|
156
153
|
const [activeTab, setActiveTab] = (0, react_5.useState)(activeTabProps);
|
|
157
154
|
// Payment method state with dual-state system (auto + explicit user selection)
|
|
@@ -8,13 +8,8 @@ const react_1 = require("../../../../global-account/react");
|
|
|
8
8
|
const cn_1 = require("../../../../shared/utils/cn");
|
|
9
9
|
const formatAddress_1 = require("../../../../shared/utils/formatAddress");
|
|
10
10
|
const thirdweb_1 = require("../../../../shared/utils/thirdweb");
|
|
11
|
-
const react_2 = require("@web3icons/react");
|
|
12
11
|
const lucide_react_1 = require("lucide-react");
|
|
13
|
-
const
|
|
14
|
-
const react_dom_1 = require("react-dom");
|
|
15
|
-
const react_4 = require("thirdweb/react");
|
|
16
|
-
const wallets_1 = require("thirdweb/wallets");
|
|
17
|
-
const wagmi_1 = require("wagmi");
|
|
12
|
+
const react_2 = require("thirdweb/react");
|
|
18
13
|
const useConnectedWalletDisplay_1 = require("../../hooks/useConnectedWalletDisplay");
|
|
19
14
|
var CryptoPaymentMethodType;
|
|
20
15
|
(function (CryptoPaymentMethodType) {
|
|
@@ -24,195 +19,70 @@ var CryptoPaymentMethodType;
|
|
|
24
19
|
CryptoPaymentMethodType["TRANSFER_CRYPTO"] = "transfer_crypto";
|
|
25
20
|
})(CryptoPaymentMethodType || (exports.CryptoPaymentMethodType = CryptoPaymentMethodType = {}));
|
|
26
21
|
function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod, isCreatingOrder, onBack, onSelectPaymentMethod, }) {
|
|
27
|
-
const { connectedEOAWallet
|
|
28
|
-
const {
|
|
29
|
-
const { connect
|
|
30
|
-
const {
|
|
31
|
-
const { data: walletClient } = (0, wagmi_1.useWalletClient)();
|
|
32
|
-
const [showWalletModal, setShowWalletModal] = (0, react_3.useState)(false);
|
|
33
|
-
const setActiveWallet = (0, react_4.useSetActiveWallet)();
|
|
34
|
-
const { data: eoaWalletInfo } = (0, react_4.useWalletInfo)(connectedEOAWallet?.id);
|
|
35
|
-
const isConnected = !!connectedEOAWallet;
|
|
22
|
+
const { connectedEOAWallet, connectedSmartWallet } = (0, react_1.useAccountWallet)();
|
|
23
|
+
const { disconnect } = (0, react_2.useDisconnect)();
|
|
24
|
+
const { connect: openConnectModal } = (0, react_2.useConnectModal)();
|
|
25
|
+
const { data: eoaWalletInfo } = (0, react_2.useWalletInfo)(connectedEOAWallet?.id);
|
|
36
26
|
const globalAddress = connectedSmartWallet?.getAccount()?.address;
|
|
37
27
|
// Use custom hook to determine wallet display logic
|
|
38
|
-
const { shouldShowConnectedEOA
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const getThirdwebWalletId = (connectorName) => {
|
|
42
|
-
const walletMap = {
|
|
43
|
-
MetaMask: "io.metamask",
|
|
44
|
-
"Coinbase Wallet": "com.coinbase.wallet",
|
|
45
|
-
Rainbow: "me.rainbow",
|
|
46
|
-
WalletConnect: "walletConnect",
|
|
47
|
-
Phantom: "app.phantom",
|
|
48
|
-
};
|
|
49
|
-
return walletMap[connectorName] || null;
|
|
50
|
-
};
|
|
51
|
-
// Create thirdweb wallet from wagmi connector
|
|
52
|
-
const createThirdwebWalletFromConnector = async (connectorName) => {
|
|
53
|
-
const walletId = getThirdwebWalletId(connectorName);
|
|
54
|
-
if (!walletId) {
|
|
55
|
-
console.warn(`No thirdweb wallet ID found for connector: ${connectorName}`);
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
const thirdwebWallet = (0, wallets_1.createWallet)(walletId);
|
|
60
|
-
// Connect the wallet to sync with the existing wagmi connection
|
|
61
|
-
await thirdwebWallet.connect({ client: thirdweb_1.client });
|
|
62
|
-
return thirdwebWallet;
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
console.error(`Failed to create thirdweb wallet for ${connectorName}:`, error);
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
// Define available wallet connectors
|
|
70
|
-
const availableConnectors = connectors.filter(connector => ["MetaMask", "WalletConnect", "Coinbase Wallet", "Rainbow", "Phantom"].includes(connector.name));
|
|
71
|
-
// Define wallet options with icons and info
|
|
72
|
-
const walletOptions = [
|
|
73
|
-
{
|
|
74
|
-
id: "metamask",
|
|
75
|
-
name: "MetaMask",
|
|
76
|
-
icon: (0, jsx_runtime_1.jsx)(react_2.WalletMetamask, { size: 48 }),
|
|
77
|
-
description: "Connect using MetaMask browser extension",
|
|
78
|
-
connector: availableConnectors.find(c => c.name === "MetaMask"),
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
id: "coinbase",
|
|
82
|
-
name: "Coinbase Wallet",
|
|
83
|
-
icon: (0, jsx_runtime_1.jsx)(react_2.WalletCoinbase, { size: 48 }),
|
|
84
|
-
description: "Connect using Coinbase Wallet",
|
|
85
|
-
connector: availableConnectors.find(c => c.name === "Coinbase Wallet"),
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
id: "rainbow",
|
|
89
|
-
name: "Rainbow",
|
|
90
|
-
icon: (0, jsx_runtime_1.jsx)(react_2.WalletRainbow, { size: 48 }),
|
|
91
|
-
description: "Connect using Rainbow wallet",
|
|
92
|
-
connector: availableConnectors.find(c => c.name === "Rainbow"),
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
id: "walletconnect",
|
|
96
|
-
name: "WalletConnect",
|
|
97
|
-
icon: (0, jsx_runtime_1.jsx)(react_2.WalletWalletConnect, { size: 48 }),
|
|
98
|
-
description: "Connect using WalletConnect protocol",
|
|
99
|
-
connector: availableConnectors.find(c => c.name === "WalletConnect"),
|
|
100
|
-
},
|
|
101
|
-
].filter(wallet => wallet.connector); // Only show wallets that have available connectors
|
|
102
|
-
// Reset modal state when closing
|
|
103
|
-
const handleCloseModal = () => {
|
|
104
|
-
setShowWalletModal(false);
|
|
105
|
-
};
|
|
106
|
-
// Function to request wallet permissions for specific wallet
|
|
107
|
-
const requestWalletPermissions = async (walletConnector) => {
|
|
28
|
+
const { shouldShowConnectedEOA } = (0, useConnectedWalletDisplay_1.useConnectedWalletDisplay)(selectedPaymentMethod);
|
|
29
|
+
// Handle wallet connection using thirdweb modal
|
|
30
|
+
const handleConnectWallet = async () => {
|
|
108
31
|
try {
|
|
109
|
-
//
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
// if (isConnected) {
|
|
113
|
-
// disconnect();
|
|
114
|
-
// // Small delay to ensure disconnection
|
|
115
|
-
// await new Promise(resolve => setTimeout(resolve, 100));
|
|
116
|
-
// }
|
|
117
|
-
await connect({ connector: walletConnector });
|
|
118
|
-
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
119
|
-
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
120
|
-
react_1.toast.success(`Connected to ${walletConnector.name}`);
|
|
121
|
-
return;
|
|
32
|
+
// Disconnect current wallet before connecting a new one
|
|
33
|
+
if (connectedEOAWallet) {
|
|
34
|
+
await disconnect(connectedEOAWallet);
|
|
122
35
|
}
|
|
123
|
-
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
method: "wallet_requestPermissions",
|
|
127
|
-
params: [{ eth_accounts: {} }],
|
|
128
|
-
});
|
|
129
|
-
react_1.toast.success("Account selection completed");
|
|
36
|
+
const wallet = await openConnectModal({ client: thirdweb_1.client, setActive: false });
|
|
37
|
+
if (wallet) {
|
|
38
|
+
// setActiveWallet(wallet);
|
|
130
39
|
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
131
40
|
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
132
|
-
|
|
133
|
-
else {
|
|
134
|
-
// Fallback: show modal for manual wallet selection
|
|
135
|
-
setShowWalletModal(true);
|
|
41
|
+
react_1.toast.success("Wallet connected");
|
|
136
42
|
}
|
|
137
43
|
}
|
|
138
44
|
catch (error) {
|
|
139
|
-
console.error("Failed to
|
|
45
|
+
console.error("Failed to connect wallet:", error);
|
|
140
46
|
if (error && typeof error === "object" && "message" in error) {
|
|
141
47
|
const errorMessage = error.message.toLowerCase();
|
|
142
48
|
if (errorMessage.includes("rejected") ||
|
|
143
49
|
errorMessage.includes("denied") ||
|
|
144
50
|
errorMessage.includes("cancelled")) {
|
|
145
|
-
|
|
51
|
+
// User cancelled - no toast needed
|
|
146
52
|
}
|
|
147
53
|
else {
|
|
148
|
-
react_1.toast.error("Failed to
|
|
54
|
+
react_1.toast.error("Failed to connect wallet");
|
|
149
55
|
}
|
|
150
56
|
}
|
|
151
|
-
else {
|
|
152
|
-
react_1.toast.error("Failed to open account selection");
|
|
153
|
-
}
|
|
154
57
|
}
|
|
155
58
|
};
|
|
156
|
-
return ((0, jsx_runtime_1.
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
react_1.toast.success(`Selected ${connector?.name || "wallet"}`);
|
|
187
|
-
}, className: (0, cn_1.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
|
|
188
|
-
? "connected-wallet border-as-brand bg-as-brand/5"
|
|
189
|
-
: "border-as-border-secondary bg-as-surface-primary hover:border-as-secondary/80"), children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "wallet-icon flex h-10 w-10 items-center justify-center rounded-full bg-blue-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-5 w-5 text-blue-600" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary font-semibold", children: connector?.name || "Connected Wallet" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/60 text-sm", children: (0, formatAddress_1.shortenAddress)(address || "") })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET && ((0, jsx_runtime_1.jsx)("div", { className: "h-2 w-2 rounded-full bg-green-500" })), (0, jsx_runtime_1.jsx)("button", { onClick: e => {
|
|
190
|
-
e.stopPropagation();
|
|
191
|
-
disconnect();
|
|
192
|
-
react_1.toast.success("Wallet disconnected");
|
|
193
|
-
if (selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
194
|
-
setSelectedPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
195
|
-
}
|
|
196
|
-
}, className: "text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-4 w-4" }) })] })] }) })), globalAddress && ((0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
197
|
-
setSelectedPaymentMethod(CryptoPaymentMethodType.GLOBAL_WALLET);
|
|
198
|
-
onSelectPaymentMethod(CryptoPaymentMethodType.GLOBAL_WALLET);
|
|
199
|
-
react_1.toast.success("Selected B3 Account");
|
|
200
|
-
}, className: (0, cn_1.cn)("crypto-payment-method-global-wallet w-full rounded-xl border p-4 text-left transition-all hover:shadow-md", selectedPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET
|
|
201
|
-
? "connected-wallet border-as-brand bg-as-brand/5"
|
|
202
|
-
: "border-as-border-secondary bg-as-surface-primary hover:border-as-secondary/80"), children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)(react_1.WalletImage, { fallback: (0, jsx_runtime_1.jsx)("div", { className: "wallet-icon flex h-10 w-10 items-center justify-center rounded-full bg-purple-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-5 w-5 text-purple-600" }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary font-semibold", children: "Global Account" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/60 text-sm", children: (0, formatAddress_1.shortenAddress)(globalAddress || "") })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: selectedPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET && ((0, jsx_runtime_1.jsx)("div", { className: "h-2 w-2 rounded-full bg-green-500" })) })] }) }))] })] })), (0, jsx_runtime_1.jsxs)("div", { className: "other-payment-methods", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-as-primary/80 mb-3 text-sm font-medium", children: "Payment methods" }), (0, jsx_runtime_1.jsxs)("div", { className: "space-y-3", children: [(0, jsx_runtime_1.jsxs)("button", { onClick: () => {
|
|
203
|
-
// Always show wallet selection modal first
|
|
204
|
-
setShowWalletModal(true);
|
|
205
|
-
}, 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: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-blue-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-4 w-4 text-blue-600" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start text-left", children: (0, jsx_runtime_1.jsx)("h4", { className: "text-as-primary font-semibold", children: "Connect wallet" }) })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] }), (0, jsx_runtime_1.jsxs)("button", { onClick: () => {
|
|
206
|
-
setSelectedPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
207
|
-
onSelectPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
208
|
-
}, 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: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-orange-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ZapIcon, { className: "h-4 w-4" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start text-left", children: (0, jsx_runtime_1.jsx)("h4", { className: "text-as-primary font-semibold", children: "Transfer crypto" }) })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })] })] })] })] }), showWalletModal &&
|
|
209
|
-
(0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)("div", { className: "wallet-connection-modal pointer-events-auto fixed inset-0 z-[9999] flex items-center justify-center bg-black/50", children: (0, jsx_runtime_1.jsxs)("div", { className: "max-h-[80vh] w-[400px] max-w-[90vw] overflow-auto rounded-xl bg-white p-6 dark:bg-gray-900", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: isConnected ? "Switch wallet or account" : "Choose wallet to connect" }), (0, jsx_runtime_1.jsx)("button", { onClick: handleCloseModal, className: "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200", children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-5 w-5" }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "space-y-4", children: (0, jsx_runtime_1.jsx)("div", { className: "space-y-3", children: walletOptions.map(walletOption => {
|
|
210
|
-
const isCurrentWallet = isConnected && connector?.name === walletOption.connector?.name;
|
|
211
|
-
return ((0, jsx_runtime_1.jsx)("button", { onClick: async () => {
|
|
212
|
-
handleCloseModal();
|
|
213
|
-
await requestWalletPermissions(walletOption.connector);
|
|
214
|
-
}, disabled: isPending, className: `wallet-option w-full rounded-xl border p-4 text-left transition-all hover:shadow-md disabled:opacity-50 ${isCurrentWallet
|
|
215
|
-
? "wallet-option--active border-blue-500 bg-blue-50 dark:bg-blue-900/20"
|
|
216
|
-
: "border-gray-200 bg-white hover:border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:hover:border-gray-500"}`, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [walletOption.icon, (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "wallet-option-name flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: walletOption.name }), isCurrentWallet && ((0, jsx_runtime_1.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" }))] }), (0, jsx_runtime_1.jsx)("div", { className: "text-xs text-gray-500 dark:text-gray-400", children: isCurrentWallet ? "Switch account or reconnect" : walletOption.description })] })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "h-5 w-5 text-gray-400" })] }) }, walletOption.id));
|
|
217
|
-
}) }) })] }) }), typeof window !== "undefined" ? document.getElementById("b3-root") || document.body : document.body)] }));
|
|
59
|
+
return ((0, jsx_runtime_1.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: (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" }) }) }), process.env.NODE_ENV === "development" && ((0, jsx_runtime_1.jsxs)("div", { className: "rounded-lg border border-yellow-500/50 bg-yellow-50 p-3 dark:bg-yellow-950/20", children: [(0, jsx_runtime_1.jsx)("p", { className: "mb-2 text-xs font-semibold text-yellow-800 dark:text-yellow-300", children: "\uD83E\uDDEA Toast Test (Dev Only)" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-wrap gap-2", children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => react_1.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" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => react_1.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" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => react_1.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" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => react_1.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" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
60
|
+
react_1.toast.success("Multiple test 1");
|
|
61
|
+
setTimeout(() => react_1.toast.info("Multiple test 2"), 200);
|
|
62
|
+
setTimeout(() => react_1.toast.warning("Multiple test 3"), 400);
|
|
63
|
+
}, className: "rounded bg-purple-600 px-2 py-1 text-xs font-medium text-white hover:bg-purple-700", children: "Multiple" })] })] })), (0, jsx_runtime_1.jsxs)("div", { className: "crypto-payment-methods flex flex-col gap-4", children: [(shouldShowConnectedEOA || 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: () => {
|
|
64
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
65
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
66
|
+
react_1.toast.success(`Selected ${eoaWalletInfo?.name || "wallet"}`);
|
|
67
|
+
}, className: (0, cn_1.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
|
|
68
|
+
? "connected-wallet border-as-brand bg-as-brand/5"
|
|
69
|
+
: "border-as-border-secondary bg-as-surface-primary hover:border-as-secondary/80"), children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "wallet-icon flex h-10 w-10 items-center justify-center rounded-full bg-blue-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-5 w-5 text-blue-600" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary font-semibold", children: eoaWalletInfo?.name || "Connected Wallet" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/60 text-sm", children: (0, formatAddress_1.shortenAddress)(connectedEOAWallet?.getAccount()?.address || "") })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET && ((0, jsx_runtime_1.jsx)("div", { className: "h-2 w-2 rounded-full bg-green-500" })), (0, jsx_runtime_1.jsx)("button", { onClick: e => {
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
if (connectedEOAWallet) {
|
|
72
|
+
disconnect(connectedEOAWallet);
|
|
73
|
+
}
|
|
74
|
+
react_1.toast.success("Wallet disconnected");
|
|
75
|
+
if (selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
76
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
77
|
+
}
|
|
78
|
+
}, className: "text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-4 w-4" }) })] })] }) })), globalAddress && ((0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
79
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.GLOBAL_WALLET);
|
|
80
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.GLOBAL_WALLET);
|
|
81
|
+
react_1.toast.success("Selected B3 Account");
|
|
82
|
+
}, className: (0, cn_1.cn)("crypto-payment-method-global-wallet w-full rounded-xl border p-4 text-left transition-all hover:shadow-md", selectedPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET
|
|
83
|
+
? "connected-wallet border-as-brand bg-as-brand/5"
|
|
84
|
+
: "border-as-border-secondary bg-as-surface-primary hover:border-as-secondary/80"), children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)(react_1.WalletImage, { fallback: (0, jsx_runtime_1.jsx)("div", { className: "wallet-icon flex h-10 w-10 items-center justify-center rounded-full bg-purple-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-5 w-5 text-purple-600" }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary font-semibold", children: "Global Account" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/60 text-sm", children: (0, formatAddress_1.shortenAddress)(globalAddress || "") })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: selectedPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET && ((0, jsx_runtime_1.jsx)("div", { className: "h-2 w-2 rounded-full bg-green-500" })) })] }) }))] })] })), (0, jsx_runtime_1.jsxs)("div", { className: "other-payment-methods", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-as-primary/80 mb-3 text-sm font-medium", children: "Payment methods" }), (0, jsx_runtime_1.jsxs)("div", { className: "space-y-3", children: [(0, jsx_runtime_1.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: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-blue-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-4 w-4 text-blue-600" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start text-left", children: (0, jsx_runtime_1.jsx)("h4", { className: "text-as-primary font-semibold", children: "Connect wallet" }) })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] }), (0, jsx_runtime_1.jsxs)("button", { onClick: () => {
|
|
85
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
86
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
87
|
+
}, 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: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-orange-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ZapIcon, { className: "h-4 w-4" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start text-left", children: (0, jsx_runtime_1.jsx)("h4", { className: "text-as-primary font-semibold", children: "Transfer crypto" }) })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })] })] })] })] }) }));
|
|
218
88
|
}
|
|
@@ -13,7 +13,6 @@ const chains_1 = require("viem/chains");
|
|
|
13
13
|
const CryptoPaymentMethod_1 = require("../components/common/CryptoPaymentMethod");
|
|
14
14
|
const FiatPaymentMethod_1 = require("../components/common/FiatPaymentMethod");
|
|
15
15
|
const useAutoSelectCryptoPaymentMethod_1 = require("./useAutoSelectCryptoPaymentMethod");
|
|
16
|
-
const useAutoSetActiveWalletFromWagmi_1 = require("./useAutoSetActiveWalletFromWagmi");
|
|
17
16
|
const useConnectedWalletDisplay_1 = require("./useConnectedWalletDisplay");
|
|
18
17
|
const useCryptoPaymentMethodState_1 = require("./useCryptoPaymentMethodState");
|
|
19
18
|
const useRecipientAddressState_1 = require("./useRecipientAddressState");
|
|
@@ -53,8 +52,6 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
53
52
|
// Recipient state with dual-state system (auto + explicit user selection)
|
|
54
53
|
const { address: globalAddress } = (0, react_2.useAccountWallet)();
|
|
55
54
|
const { walletAddress } = (0, useConnectedWalletDisplay_1.useConnectedWalletDisplay)(effectiveCryptoPaymentMethod);
|
|
56
|
-
// Auto-set active wallet from wagmi
|
|
57
|
-
(0, useAutoSetActiveWalletFromWagmi_1.useAutoSetActiveWalletFromWagmi)();
|
|
58
55
|
// Recipient address state - hook automatically manages priority: props > user selection > wallet/global
|
|
59
56
|
const { setSelectedRecipientAddress, effectiveRecipientAddress } = (0, useRecipientAddressState_1.useRecipientAddressState)({
|
|
60
57
|
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,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ALL_CHAINS = exports.SOLANA_CHAINS = exports.EVM_CHAINS = exports.SOLANA_MAINNET = exports.EVM_TESTNET = exports.EVM_MAINNET = void 0;
|
|
6
|
+
exports.ALL_CHAINS = exports.SOLANA_CHAINS = exports.EVM_CHAINS = exports.SOLANA_MAINNET = exports.EVM_TESTNET = exports.EVM_MAINNET = exports.hyperEVM = void 0;
|
|
7
7
|
exports.getSolanaChains = getSolanaChains;
|
|
8
8
|
exports.getAllEvmChains = getAllEvmChains;
|
|
9
9
|
exports.getChainType = getChainType;
|
|
@@ -31,6 +31,13 @@ const token_1 = require("./token");
|
|
|
31
31
|
function getCustomEvmChain(chain, rpcUrl) {
|
|
32
32
|
return (0, viem_1.defineChain)({ ...chain, rpcUrls: { default: { http: [rpcUrl] } } });
|
|
33
33
|
}
|
|
34
|
+
exports.hyperEVM = (0, viem_1.defineChain)({
|
|
35
|
+
id: token_1.HYPEREVM_CHAIN_ID,
|
|
36
|
+
name: "HyperEVM",
|
|
37
|
+
nativeCurrency: { name: "HyperEVM", symbol: "HYPE", decimals: 18 },
|
|
38
|
+
rpcUrls: { default: { http: ["https://rpc.hyperliquid.xyz/evm"] } },
|
|
39
|
+
blockExplorers: { default: { name: "HyperEVM Explorer", url: "https://hyperevmscan.io/" } },
|
|
40
|
+
});
|
|
34
41
|
// export const b4testnet = defineChain({
|
|
35
42
|
// id: 19934,
|
|
36
43
|
// name: "B4 Testnet",
|
|
@@ -174,6 +181,20 @@ exports.EVM_MAINNET = {
|
|
|
174
181
|
coingeckoName: "abstract",
|
|
175
182
|
wethAddress: "0x3439153eb7af838ad19d56e1571fbd09333c2809",
|
|
176
183
|
},
|
|
184
|
+
[exports.hyperEVM.id]: {
|
|
185
|
+
id: exports.hyperEVM.id,
|
|
186
|
+
name: exports.hyperEVM.name,
|
|
187
|
+
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/64x64/32196.png",
|
|
188
|
+
type: chain_1.ChainType.EVM,
|
|
189
|
+
nativeRequired: (0, viem_1.parseEther)("0.01"),
|
|
190
|
+
canDepositNative: true,
|
|
191
|
+
defaultToken: (0, token_1.getHyperEVMNativeToken)(),
|
|
192
|
+
nativeToken: (0, token_1.getHyperEVMNativeToken)(),
|
|
193
|
+
viem: exports.hyperEVM,
|
|
194
|
+
pollingInterval: 1000, // 1 second for Hyperliquid
|
|
195
|
+
coingeckoName: "hyperevm",
|
|
196
|
+
wethAddress: "0x5555555555555555555555555555555555555555",
|
|
197
|
+
},
|
|
177
198
|
};
|
|
178
199
|
exports.EVM_TESTNET = {
|
|
179
200
|
// [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,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HYPEREVM_CHAIN_ID = exports.HYPERLIQUID_CHAIN_ID = void 0;
|
|
3
4
|
exports.isNativeToken = isNativeToken;
|
|
4
5
|
exports.getSolanaToken = getSolanaToken;
|
|
5
6
|
exports.getEthToken = getEthToken;
|
|
6
7
|
exports.getPolToken = getPolToken;
|
|
7
8
|
exports.getBnbToken = getBnbToken;
|
|
8
9
|
exports.getAvaxToken = getAvaxToken;
|
|
9
|
-
|
|
10
|
+
exports.getHyperEVMNativeToken = getHyperEVMNativeToken;
|
|
10
11
|
const constants_1 = require("../../anyspend/constants");
|
|
12
|
+
const chains_1 = require("viem/chains");
|
|
13
|
+
exports.HYPERLIQUID_CHAIN_ID = 1337;
|
|
14
|
+
exports.HYPEREVM_CHAIN_ID = 999;
|
|
11
15
|
function isNativeToken(address) {
|
|
12
16
|
return address.toLowerCase() === constants_1.RELAY_ETH_ADDRESS || address.toLowerCase() === constants_1.RELAY_SOL_ADDRESS;
|
|
13
17
|
}
|
|
@@ -71,3 +75,15 @@ function getAvaxToken() {
|
|
|
71
75
|
},
|
|
72
76
|
};
|
|
73
77
|
}
|
|
78
|
+
function getHyperEVMNativeToken() {
|
|
79
|
+
return {
|
|
80
|
+
chainId: exports.HYPEREVM_CHAIN_ID,
|
|
81
|
+
address: constants_1.RELAY_ETH_ADDRESS,
|
|
82
|
+
symbol: "HYPE",
|
|
83
|
+
name: "HYPE",
|
|
84
|
+
decimals: 18,
|
|
85
|
+
metadata: {
|
|
86
|
+
logoURI: "https://s2.coinmarketcap.com/static/img/coins/64x64/32196.png",
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -6,7 +6,6 @@ const react_1 = require("../../../../global-account/react");
|
|
|
6
6
|
const debug_1 = require("../../../../shared/utils/debug");
|
|
7
7
|
const react_2 = require("react");
|
|
8
8
|
const react_3 = require("thirdweb/react");
|
|
9
|
-
const TurnkeyAuthModal_1 = require("../TurnkeyAuthModal");
|
|
10
9
|
const SignInWithB3Privy_1 = require("./SignInWithB3Privy");
|
|
11
10
|
const LoginStep_1 = require("./steps/LoginStep");
|
|
12
11
|
const LoginStepCustom_1 = require("./steps/LoginStepCustom");
|
|
@@ -24,9 +23,7 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
24
23
|
const account = (0, react_3.useActiveAccount)();
|
|
25
24
|
const isAuthenticating = (0, react_1.useAuthStore)(state => state.isAuthenticating);
|
|
26
25
|
const isAuthenticated = (0, react_1.useAuthStore)(state => state.isAuthenticated);
|
|
27
|
-
const setIsAuthenticated = (0, react_1.useAuthStore)(state => state.setIsAuthenticated);
|
|
28
26
|
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
29
|
-
const setIsConnected = (0, react_1.useAuthStore)(state => state.setIsConnected);
|
|
30
27
|
const setJustCompletedLogin = (0, react_1.useAuthStore)(state => state.setJustCompletedLogin);
|
|
31
28
|
const [refetchCount, setRefetchCount] = (0, react_2.useState)(0);
|
|
32
29
|
const [refetchError, setRefetchError] = (0, react_2.useState)(null);
|
|
@@ -128,10 +125,6 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
128
125
|
debug("Refetching user after Turnkey success...");
|
|
129
126
|
await refetchUser();
|
|
130
127
|
debug("User refetched successfully");
|
|
131
|
-
// Set authentication and connection state so UI updates properly
|
|
132
|
-
setIsAuthenticated(true);
|
|
133
|
-
setIsConnected(true);
|
|
134
|
-
setJustCompletedLogin(true);
|
|
135
128
|
// After user data is refreshed, close Turnkey modal and go back to sign-in flow
|
|
136
129
|
debug("Switching back to signInWithB3 modal");
|
|
137
130
|
setB3ModalContentType({
|
|
@@ -161,9 +154,6 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
161
154
|
closeAfterLogin,
|
|
162
155
|
source,
|
|
163
156
|
signersEnabled,
|
|
164
|
-
setIsAuthenticated,
|
|
165
|
-
setIsConnected,
|
|
166
|
-
setJustCompletedLogin,
|
|
167
157
|
]);
|
|
168
158
|
// Handle post-login flow after signers are loaded
|
|
169
159
|
(0, react_2.useEffect)(() => {
|
|
@@ -299,56 +289,21 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
299
289
|
if (refetchError) {
|
|
300
290
|
content = ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)("div", { className: "p-4 text-center text-red-500", children: refetchError }) }));
|
|
301
291
|
}
|
|
292
|
+
else if (isAuthenticating || (isFetchingSigners && step === "login") || source === "requestPermissions") {
|
|
293
|
+
content = ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)("div", { className: "my-8 flex min-h-[350px] items-center justify-center", children: (0, jsx_runtime_1.jsx)(react_1.Loading, { variant: "white", size: "lg" }) }) }));
|
|
294
|
+
}
|
|
302
295
|
else if (step === "login") {
|
|
303
|
-
//
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
//
|
|
309
|
-
|
|
310
|
-
enableTurnkey,
|
|
311
|
-
turnkeyAuthCompleted,
|
|
312
|
-
isAuthenticated,
|
|
313
|
-
});
|
|
314
|
-
// Show Turnkey authentication as primary option
|
|
315
|
-
content = ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)(TurnkeyAuthModal_1.TurnkeyAuthModal, { onSuccess: async (authenticatedUser) => {
|
|
316
|
-
debug("Turnkey authentication successful in primary flow", { authenticatedUser });
|
|
317
|
-
setTurnkeyAuthCompleted(true);
|
|
318
|
-
// After Turnkey auth, refetch user to get the full user object
|
|
319
|
-
await refetchUser();
|
|
320
|
-
// User is now authenticated via Turnkey
|
|
321
|
-
// Set both isAuthenticated and isConnected to true so UI updates properly
|
|
322
|
-
// Wallet connection is optional and can happen later for signing transactions
|
|
323
|
-
setIsAuthenticated(true);
|
|
324
|
-
setIsConnected(true);
|
|
325
|
-
setJustCompletedLogin(true);
|
|
326
|
-
// Call the login success callback
|
|
327
|
-
onLoginSuccess?.({});
|
|
328
|
-
}, onClose: () => {
|
|
329
|
-
// If user closes Turnkey modal, they can still use wallet connection as fallback
|
|
330
|
-
setTurnkeyAuthCompleted(true);
|
|
331
|
-
}, initialEmail: "", skipToOtp: false }) }));
|
|
296
|
+
// Custom strategy
|
|
297
|
+
if (strategies?.[0] === "privy") {
|
|
298
|
+
content = (0, jsx_runtime_1.jsx)(SignInWithB3Privy_1.SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
299
|
+
}
|
|
300
|
+
else if (strategies) {
|
|
301
|
+
// Strategies are explicitly provided
|
|
302
|
+
content = ((0, jsx_runtime_1.jsx)(LoginStepCustom_1.LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
332
303
|
}
|
|
333
304
|
else {
|
|
334
|
-
//
|
|
335
|
-
|
|
336
|
-
content = ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)("div", { className: "my-8 flex min-h-[350px] items-center justify-center", children: (0, jsx_runtime_1.jsx)(react_1.Loading, { variant: "white", size: "lg" }) }) }));
|
|
337
|
-
}
|
|
338
|
-
else {
|
|
339
|
-
// Custom strategy
|
|
340
|
-
if (strategies?.[0] === "privy") {
|
|
341
|
-
content = (0, jsx_runtime_1.jsx)(SignInWithB3Privy_1.SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
342
|
-
}
|
|
343
|
-
else if (strategies) {
|
|
344
|
-
// Strategies are explicitly provided
|
|
345
|
-
content = ((0, jsx_runtime_1.jsx)(LoginStepCustom_1.LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
346
|
-
}
|
|
347
|
-
else {
|
|
348
|
-
// Default to handle all strategies we support
|
|
349
|
-
content = (0, jsx_runtime_1.jsx)(LoginStep_1.LoginStep, { chain: chain, onSuccess: handleLoginSuccess, onError: onError });
|
|
350
|
-
}
|
|
351
|
-
}
|
|
305
|
+
// Default to handle all strategies we support
|
|
306
|
+
content = (0, jsx_runtime_1.jsx)(LoginStep_1.LoginStep, { chain: chain, onSuccess: handleLoginSuccess, onError: onError });
|
|
352
307
|
}
|
|
353
308
|
}
|
|
354
309
|
return content;
|