@wheelx-widget/widget 0.1.11 → 0.1.12
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/README.md +63 -0
- package/dist/index.d.mts +76 -13
- package/dist/index.d.ts +76 -13
- package/dist/index.js +1274 -295
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1276 -305
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React5 from 'react';
|
|
2
|
-
import React5__default, { createContext, memo, useState, useMemo, useRef, useEffect, useContext, createElement, useCallback } from 'react';
|
|
3
|
-
import { defineRecipe, chakra, Tooltip as Tooltip$1, Portal,
|
|
2
|
+
import React5__default, { createContext, forwardRef, memo, useState, useMemo, useRef, useEffect, useContext, createElement, useCallback } from 'react';
|
|
3
|
+
import { createToaster, defineRecipe, chakra, Tooltip as Tooltip$1, Portal, Box, Image, VStack, HStack, InputGroup, Input, Icon, useBreakpointValue, Dialog, Spinner, Link, Button, Text, Popover, Switch, Collapsible, useDisclosure } from '@chakra-ui/react';
|
|
4
4
|
import { useQuery, QueryClient, QueryClientProvider, useMutation, keepPreviousData } from '@tanstack/react-query';
|
|
5
5
|
import { useUserWallets, DynamicContextProvider, useRpcProviders, useDynamicContext, useTokenBalances, ChainEnum, useDynamicModals, useIsLoggedIn } from '@dynamic-labs/sdk-react-core';
|
|
6
6
|
import { EthereumWalletConnectors } from '@dynamic-labs/ethereum';
|
|
@@ -8,17 +8,17 @@ import { SolanaWalletConnectorsWithConfig } from '@dynamic-labs/solana';
|
|
|
8
8
|
import { DynamicWagmiConnector } from '@dynamic-labs/wagmi-connector';
|
|
9
9
|
import { useAccount, WagmiProvider, useChainId, useConfig, useReconnect, createConfig, useDisconnect, useConnectors, useEstimateFeesPerGas, fallback, http as http$1, useWaitForTransactionReceipt, useSendTransaction } from 'wagmi';
|
|
10
10
|
import { defineChain, zeroAddress, createPublicClient, http, parseUnits, erc20Abi, formatUnits, isAddress, hexToString, createClient, custom } from 'viem';
|
|
11
|
-
import {
|
|
11
|
+
import { unichainSepolia, unichain, baseSepolia, base as base$1, optimismSepolia, optimism, arbitrumSepolia, arbitrum, sepolia, mainnet, polygon, bsc, avalanche, zksync, linea, scroll, mantle, blast, celo, gnosis, sonic, zora, mode, taiko, sei, xdc, ink, soneium as soneium$1, worldchain, opBNB, lisk, morph, bob, abstract, hemi, xLayer, cronos, gravity, manta, zircuit, berachain, plumeMainnet, plume, hashkey, flowMainnet, etherlink, ronin, flare, rootstock, iota, pulsechain, arcTestnet } from 'wagmi/chains';
|
|
12
12
|
import { ThemeProvider } from '@emotion/react';
|
|
13
13
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
14
14
|
import axios6, { AxiosError } from 'axios';
|
|
15
15
|
import { create } from 'zustand';
|
|
16
16
|
import { Fraction, RoundingMode } from 'bi-fraction';
|
|
17
|
-
import { base, soneium, ink, bsc } from 'viem/chains';
|
|
17
|
+
import { base, soneium, ink as ink$1, bsc as bsc$1 } from 'viem/chains';
|
|
18
18
|
import { PublicKey, VersionedTransaction, VersionedMessage, Transaction } from '@solana/web3.js';
|
|
19
19
|
import { parseAccount, getAddress } from 'viem/utils';
|
|
20
20
|
import { writeContract as writeContract$1, waitForTransactionReceipt as waitForTransactionReceipt$1, getTransaction, call, readContract as readContract$1 } from 'viem/actions';
|
|
21
|
-
import { MdOutlineStarOutline, MdOutlineStarPurple500, MdFavoriteBorder, MdFavorite } from 'react-icons/md';
|
|
21
|
+
import { MdOutlineStarOutline, MdOutlineStarPurple500, MdFavoriteBorder, MdFavorite, MdLocalGasStation } from 'react-icons/md';
|
|
22
22
|
import { WalletIcon as WalletIcon$1 } from '@dynamic-labs/wallet-book';
|
|
23
23
|
import { FiEdit } from 'react-icons/fi';
|
|
24
24
|
import { IoAddCircleOutline, IoClose } from 'react-icons/io5';
|
|
@@ -45,7 +45,8 @@ var defaultTheme = {
|
|
|
45
45
|
normalButtonBg: "#F5F6F8",
|
|
46
46
|
normalButtonText: "#1A1D26",
|
|
47
47
|
disabledButtonBg: "#E2E4E8",
|
|
48
|
-
disabledButtonText: "#A0A4AE"
|
|
48
|
+
disabledButtonText: "#A0A4AE",
|
|
49
|
+
getGasSwitchColorPalette: "purple"
|
|
49
50
|
};
|
|
50
51
|
var WidgetThemeContext = createContext({
|
|
51
52
|
theme: defaultTheme
|
|
@@ -64,9 +65,15 @@ var WidgetThemeProvider = ({
|
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
// src/api/consts.ts
|
|
67
|
-
var
|
|
68
|
+
var _baseApiUrl = "https://api.wheelx.fi";
|
|
69
|
+
function getBaseApiUrl() {
|
|
70
|
+
return _baseApiUrl;
|
|
71
|
+
}
|
|
72
|
+
function setBaseApiUrl(url) {
|
|
73
|
+
_baseApiUrl = url;
|
|
74
|
+
}
|
|
68
75
|
async function getChainsAndTokens() {
|
|
69
|
-
const url = `${
|
|
76
|
+
const url = `${getBaseApiUrl()}/v1/chain-info`;
|
|
70
77
|
const res = await axios6.get(url);
|
|
71
78
|
return res.data;
|
|
72
79
|
}
|
|
@@ -76,6 +83,7 @@ var useChainsAndTokens = (enabled = true) => {
|
|
|
76
83
|
queryFn: () => getChainsAndTokens(),
|
|
77
84
|
enabled,
|
|
78
85
|
staleTime: 30 * 1e3,
|
|
86
|
+
// 30s:与 ISR 对齐,避免客户端立即重复请求
|
|
79
87
|
refetchOnWindowFocus: false
|
|
80
88
|
});
|
|
81
89
|
return result;
|
|
@@ -160,10 +168,12 @@ var useWalletConnectedStore = create((set, get) => ({
|
|
|
160
168
|
setEvmWalletInfo: (address, connectorId) => set({ evmWalletAddress: address, evmWalletConnectorId: connectorId }),
|
|
161
169
|
isEvmWalletMetamask: false,
|
|
162
170
|
setIsEvmWalletMetamask: (isEvmWalletMetamask) => set({ isEvmWalletMetamask }),
|
|
171
|
+
// Widget: logging-out guard
|
|
163
172
|
isLoggingOut: false,
|
|
164
173
|
setIsLoggingOut: (isLoggingOut) => set({ isLoggingOut }),
|
|
174
|
+
// Widget: disconnect timestamp for 2-second auto-reconnect guard
|
|
165
175
|
lastDisconnectTimestamp: 0,
|
|
166
|
-
setLastDisconnectTimestamp: (
|
|
176
|
+
setLastDisconnectTimestamp: (timestamp) => set({ lastDisconnectTimestamp: timestamp })
|
|
167
177
|
}));
|
|
168
178
|
|
|
169
179
|
// src/stores/useSyncWalletConnectedStore.ts
|
|
@@ -182,15 +192,16 @@ var useSyncWalletConnectedStore = () => {
|
|
|
182
192
|
isLoggingOut,
|
|
183
193
|
lastDisconnectTimestamp
|
|
184
194
|
} = useWalletConnectedStore();
|
|
195
|
+
const guardRef = useRef({
|
|
196
|
+
isLoggingOut: false,
|
|
197
|
+
lastDisconnectTimestamp: 0
|
|
198
|
+
});
|
|
199
|
+
guardRef.current = { isLoggingOut, lastDisconnectTimestamp };
|
|
185
200
|
useEffect(() => {
|
|
186
|
-
if (isLoggingOut) return;
|
|
187
|
-
const msSinceDisconnect = Date.now() - lastDisconnectTimestamp;
|
|
188
|
-
if (msSinceDisconnect < 2e3) {
|
|
189
|
-
|
|
190
|
-
const hasNoConnectedWallets = !isEthWalletConnected && !isSolanaWalletConnected;
|
|
191
|
-
if (hasNoConnectedWallets) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
201
|
+
if (guardRef.current.isLoggingOut) return;
|
|
202
|
+
const msSinceDisconnect = Date.now() - guardRef.current.lastDisconnectTimestamp;
|
|
203
|
+
if (guardRef.current.lastDisconnectTimestamp > 0 && msSinceDisconnect < 2e3) {
|
|
204
|
+
return;
|
|
194
205
|
}
|
|
195
206
|
const solanaWallet = userWallets.find((wallet) => {
|
|
196
207
|
const chain = String(
|
|
@@ -207,16 +218,10 @@ var useSyncWalletConnectedStore = () => {
|
|
|
207
218
|
).toLowerCase();
|
|
208
219
|
return chain.includes("evm");
|
|
209
220
|
});
|
|
210
|
-
const
|
|
211
|
-
let evmAddress = null;
|
|
212
|
-
if (hasEverDisconnected && !evmWallet) {
|
|
213
|
-
evmAddress = null;
|
|
214
|
-
} else {
|
|
215
|
-
evmAddress = evmWallet?.address ?? wagmiAddress ?? null;
|
|
216
|
-
}
|
|
221
|
+
const evmAddress = evmWallet?.address ?? wagmiAddress ?? null;
|
|
217
222
|
const evmConnectorId = wagmiConnector?.id ?? getEvmConnectorId(evmWallet) ?? null;
|
|
218
223
|
setEvmWalletInfo(evmAddress, evmConnectorId);
|
|
219
|
-
setIsEthWalletConnected(Boolean(evmAddress || isConnected
|
|
224
|
+
setIsEthWalletConnected(Boolean(evmAddress || isConnected));
|
|
220
225
|
}, [
|
|
221
226
|
userWallets,
|
|
222
227
|
wagmiAddress,
|
|
@@ -248,79 +253,116 @@ var FavoritesContext = createContext({
|
|
|
248
253
|
isLoading: true,
|
|
249
254
|
walletAddress: void 0
|
|
250
255
|
});
|
|
251
|
-
var FavoritesProvider = ({
|
|
256
|
+
var FavoritesProvider = ({
|
|
257
|
+
children
|
|
258
|
+
}) => {
|
|
252
259
|
const address = useEvmAddress();
|
|
260
|
+
const { isConnected } = useAccount();
|
|
253
261
|
const [favorites, setFavorites] = useState([]);
|
|
254
262
|
const [isLoading, setIsLoading] = useState(true);
|
|
255
|
-
const mountedRef = useRef(false);
|
|
256
263
|
const getStorageKey = useCallback(() => {
|
|
257
264
|
if (!address) return null;
|
|
258
265
|
return `web3-favorites-${address.toLowerCase()}`;
|
|
259
266
|
}, [address]);
|
|
260
267
|
useEffect(() => {
|
|
261
|
-
|
|
262
|
-
const id = requestAnimationFrame(() => {
|
|
263
|
-
if (!mountedRef.current) return;
|
|
268
|
+
const loadFavorites = async () => {
|
|
264
269
|
if (!address) {
|
|
265
270
|
setFavorites([]);
|
|
266
271
|
setIsLoading(false);
|
|
267
272
|
return;
|
|
268
273
|
}
|
|
269
274
|
try {
|
|
270
|
-
const
|
|
271
|
-
if (!
|
|
275
|
+
const storageKey = getStorageKey();
|
|
276
|
+
if (!storageKey) {
|
|
272
277
|
setIsLoading(false);
|
|
273
278
|
return;
|
|
274
279
|
}
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
277
|
-
|
|
280
|
+
const stored = localStorage.getItem(storageKey);
|
|
281
|
+
if (stored) {
|
|
282
|
+
const parsedFavorites = JSON.parse(stored);
|
|
283
|
+
setFavorites(parsedFavorites);
|
|
284
|
+
}
|
|
285
|
+
} catch (error) {
|
|
286
|
+
console.error("Failed to load favorites from localStorage:", error);
|
|
278
287
|
setFavorites([]);
|
|
279
288
|
} finally {
|
|
280
289
|
setIsLoading(false);
|
|
281
290
|
}
|
|
282
|
-
});
|
|
283
|
-
return () => {
|
|
284
|
-
mountedRef.current = false;
|
|
285
|
-
cancelAnimationFrame(id);
|
|
286
291
|
};
|
|
292
|
+
loadFavorites();
|
|
287
293
|
}, [address, getStorageKey]);
|
|
288
|
-
const
|
|
294
|
+
const saveFavorites = (newFavorites) => {
|
|
289
295
|
if (typeof window === "undefined") return;
|
|
290
|
-
const
|
|
291
|
-
if (!
|
|
296
|
+
const storageKey = getStorageKey();
|
|
297
|
+
if (!storageKey) return;
|
|
292
298
|
try {
|
|
293
|
-
localStorage.setItem(
|
|
294
|
-
setFavorites(
|
|
295
|
-
} catch (
|
|
299
|
+
localStorage.setItem(storageKey, JSON.stringify(newFavorites));
|
|
300
|
+
setFavorites(newFavorites);
|
|
301
|
+
} catch (error) {
|
|
302
|
+
console.error("Failed to save favorites to localStorage:", error);
|
|
296
303
|
}
|
|
297
304
|
};
|
|
298
|
-
const addFavorite = (
|
|
299
|
-
if (!address)
|
|
300
|
-
|
|
301
|
-
|
|
305
|
+
const addFavorite = (networkId, networkName = "Unknown Network") => {
|
|
306
|
+
if (!isConnected || !address) {
|
|
307
|
+
console.warn("Cannot add favorite: No wallet connected");
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const existingIndex = favorites.findIndex(
|
|
311
|
+
(fav) => fav.networkId === networkId
|
|
312
|
+
);
|
|
313
|
+
if (existingIndex === -1) {
|
|
314
|
+
const newFavorite = {
|
|
315
|
+
networkId,
|
|
316
|
+
networkName,
|
|
317
|
+
timestamp: Date.now()
|
|
318
|
+
};
|
|
319
|
+
const updatedFavorites = [...favorites, newFavorite];
|
|
320
|
+
saveFavorites(updatedFavorites);
|
|
321
|
+
}
|
|
302
322
|
};
|
|
303
|
-
const removeFavorite = (
|
|
304
|
-
if (!address)
|
|
305
|
-
|
|
323
|
+
const removeFavorite = (networkId) => {
|
|
324
|
+
if (!isConnected || !address) {
|
|
325
|
+
console.warn("Cannot remove favorite: No wallet connected");
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
const updatedFavorites = favorites.filter(
|
|
329
|
+
(fav) => fav.networkId !== networkId
|
|
330
|
+
);
|
|
331
|
+
saveFavorites(updatedFavorites);
|
|
332
|
+
};
|
|
333
|
+
const isFavorite = (networkId) => {
|
|
334
|
+
return favorites.some((fav) => fav.networkId === networkId);
|
|
306
335
|
};
|
|
307
|
-
const isFavorite = (nId) => favorites.some((f) => f.networkId === nId);
|
|
308
336
|
const clearFavorites = () => {
|
|
309
|
-
if (!address) return;
|
|
310
|
-
const
|
|
311
|
-
if (!
|
|
337
|
+
if (!isConnected || !address) return;
|
|
338
|
+
const storageKey = getStorageKey();
|
|
339
|
+
if (!storageKey) return;
|
|
312
340
|
try {
|
|
313
|
-
localStorage.removeItem(
|
|
341
|
+
localStorage.removeItem(storageKey);
|
|
314
342
|
setFavorites([]);
|
|
315
|
-
} catch (
|
|
343
|
+
} catch (error) {
|
|
344
|
+
console.error("Failed to clear favorites:", error);
|
|
316
345
|
}
|
|
317
346
|
};
|
|
318
|
-
|
|
347
|
+
const contextValue = {
|
|
348
|
+
favorites,
|
|
349
|
+
addFavorite,
|
|
350
|
+
removeFavorite,
|
|
351
|
+
isFavorite,
|
|
352
|
+
clearFavorites,
|
|
353
|
+
isLoading,
|
|
354
|
+
walletAddress: address
|
|
355
|
+
};
|
|
356
|
+
return /* @__PURE__ */ jsx(FavoritesContext.Provider, { value: contextValue, children });
|
|
319
357
|
};
|
|
320
358
|
var useFavoritesContext = () => {
|
|
321
|
-
const
|
|
322
|
-
if (
|
|
323
|
-
|
|
359
|
+
const context = useContext(FavoritesContext);
|
|
360
|
+
if (context === void 0) {
|
|
361
|
+
throw new Error(
|
|
362
|
+
"useFavoritesContext must be used within a FavoritesProvider"
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
return context;
|
|
324
366
|
};
|
|
325
367
|
|
|
326
368
|
// src/core/SelectTokenModal/storageUtils.ts
|
|
@@ -353,88 +395,229 @@ var TokenFavoritesContext = createContext({
|
|
|
353
395
|
walletAddress: void 0,
|
|
354
396
|
storageError: null
|
|
355
397
|
});
|
|
356
|
-
var TokenFavoritesProvider = ({
|
|
398
|
+
var TokenFavoritesProvider = ({
|
|
399
|
+
children
|
|
400
|
+
}) => {
|
|
357
401
|
const address = useEvmAddress();
|
|
402
|
+
const { isConnected } = useAccount();
|
|
358
403
|
const [favorites, setFavorites] = useState([]);
|
|
359
404
|
const [isLoading, setIsLoading] = useState(true);
|
|
360
405
|
const [storageError, setStorageError] = useState(null);
|
|
361
|
-
const mountedRef = useRef(false);
|
|
362
406
|
const getStorageKey = useCallback(() => {
|
|
363
407
|
if (!address) return null;
|
|
364
408
|
return `web3-token-favorites-${address.toLowerCase()}`;
|
|
365
409
|
}, [address]);
|
|
366
410
|
useEffect(() => {
|
|
367
|
-
|
|
368
|
-
const id = requestAnimationFrame(() => {
|
|
369
|
-
if (!mountedRef.current) return;
|
|
411
|
+
const loadFavorites = async () => {
|
|
370
412
|
if (!address) {
|
|
371
413
|
setFavorites([]);
|
|
372
414
|
setIsLoading(false);
|
|
373
415
|
return;
|
|
374
416
|
}
|
|
375
417
|
try {
|
|
376
|
-
const
|
|
377
|
-
if (!
|
|
418
|
+
const storageKey = getStorageKey();
|
|
419
|
+
if (!storageKey) {
|
|
378
420
|
setIsLoading(false);
|
|
379
421
|
return;
|
|
380
422
|
}
|
|
381
|
-
const
|
|
382
|
-
if (
|
|
383
|
-
|
|
423
|
+
const stored = localStorage.getItem(storageKey);
|
|
424
|
+
if (stored) {
|
|
425
|
+
const parsedFavorites = JSON.parse(stored);
|
|
426
|
+
setFavorites(parsedFavorites);
|
|
427
|
+
}
|
|
428
|
+
} catch (error) {
|
|
429
|
+
console.error("Failed to load favorites from localStorage:", error);
|
|
384
430
|
setFavorites([]);
|
|
385
431
|
} finally {
|
|
386
432
|
setIsLoading(false);
|
|
387
433
|
}
|
|
388
|
-
});
|
|
389
|
-
return () => {
|
|
390
|
-
mountedRef.current = false;
|
|
391
|
-
cancelAnimationFrame(id);
|
|
392
434
|
};
|
|
435
|
+
loadFavorites();
|
|
393
436
|
}, [address, getStorageKey]);
|
|
394
|
-
const saveFavorites = (
|
|
437
|
+
const saveFavorites = (newFavorites) => {
|
|
395
438
|
if (typeof window === "undefined") return;
|
|
396
439
|
if (!isLocalStorageSupported()) {
|
|
397
|
-
setStorageError("
|
|
440
|
+
setStorageError("you browser can not using local storage");
|
|
398
441
|
return;
|
|
399
442
|
}
|
|
400
|
-
const
|
|
401
|
-
if (!
|
|
443
|
+
const storageKey = getStorageKey();
|
|
444
|
+
if (!storageKey) return;
|
|
402
445
|
try {
|
|
403
|
-
localStorage.setItem(
|
|
404
|
-
setFavorites(
|
|
405
|
-
} catch (
|
|
446
|
+
localStorage.setItem(storageKey, JSON.stringify(newFavorites));
|
|
447
|
+
setFavorites(newFavorites);
|
|
448
|
+
} catch (error) {
|
|
449
|
+
console.error("Failed to save favorites to localStorage:", error);
|
|
406
450
|
}
|
|
407
451
|
};
|
|
408
|
-
const addFavorite = (
|
|
409
|
-
if (!address)
|
|
410
|
-
|
|
411
|
-
|
|
452
|
+
const addFavorite = (chainId, tokenAddress, symbol, decimals, logo, name, tags) => {
|
|
453
|
+
if (!isConnected || !address) {
|
|
454
|
+
console.warn("Cannot add favorite: No wallet connected");
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const existingIndex = favorites.findIndex(
|
|
458
|
+
(fav) => fav.chain_id === chainId && fav.address === tokenAddress
|
|
459
|
+
);
|
|
460
|
+
if (existingIndex === -1) {
|
|
461
|
+
const newFavorite = {
|
|
462
|
+
chain_id: chainId,
|
|
463
|
+
address: tokenAddress,
|
|
464
|
+
symbol,
|
|
465
|
+
decimals,
|
|
466
|
+
logo,
|
|
467
|
+
name,
|
|
468
|
+
tags,
|
|
469
|
+
timestamp: Date.now()
|
|
470
|
+
};
|
|
471
|
+
const updatedFavorites = [...favorites, newFavorite];
|
|
472
|
+
saveFavorites(updatedFavorites);
|
|
473
|
+
}
|
|
412
474
|
};
|
|
413
|
-
const removeFavorite = (
|
|
414
|
-
if (!address)
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
475
|
+
const removeFavorite = (chainId, tokenAddress) => {
|
|
476
|
+
if (!isConnected || !address) {
|
|
477
|
+
console.warn("Cannot remove favorite: No wallet connected");
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
setFavorites((prevFavorites) => {
|
|
481
|
+
const updatedFavorites = prevFavorites.filter(
|
|
482
|
+
(fav) => !(fav.chain_id === chainId && fav.address === tokenAddress)
|
|
483
|
+
);
|
|
484
|
+
saveFavorites(updatedFavorites);
|
|
485
|
+
return updatedFavorites;
|
|
419
486
|
});
|
|
420
487
|
};
|
|
421
|
-
const isFavorite = (
|
|
488
|
+
const isFavorite = (chainId, tokenAddress) => {
|
|
489
|
+
return favorites.some(
|
|
490
|
+
(fav) => fav.chain_id === chainId && fav.address === tokenAddress
|
|
491
|
+
);
|
|
492
|
+
};
|
|
422
493
|
const clearFavorites = () => {
|
|
423
|
-
if (!address) return;
|
|
424
|
-
const
|
|
425
|
-
if (!
|
|
494
|
+
if (!isConnected || !address) return;
|
|
495
|
+
const storageKey = getStorageKey();
|
|
496
|
+
if (!storageKey) return;
|
|
426
497
|
try {
|
|
427
|
-
localStorage.removeItem(
|
|
498
|
+
localStorage.removeItem(storageKey);
|
|
428
499
|
setFavorites([]);
|
|
429
|
-
} catch (
|
|
500
|
+
} catch (error) {
|
|
501
|
+
console.error("Failed to clear favorites:", error);
|
|
430
502
|
}
|
|
431
503
|
};
|
|
432
|
-
|
|
504
|
+
const contextValue = {
|
|
505
|
+
favorites,
|
|
506
|
+
addFavorite,
|
|
507
|
+
removeFavorite,
|
|
508
|
+
isFavorite,
|
|
509
|
+
clearFavorites,
|
|
510
|
+
isLoading,
|
|
511
|
+
storageError,
|
|
512
|
+
walletAddress: address
|
|
513
|
+
};
|
|
514
|
+
return /* @__PURE__ */ jsx(TokenFavoritesContext.Provider, { value: contextValue, children });
|
|
433
515
|
};
|
|
434
516
|
var useTokenFavoritesContext = () => {
|
|
435
|
-
const
|
|
436
|
-
if (
|
|
437
|
-
|
|
517
|
+
const context = useContext(TokenFavoritesContext);
|
|
518
|
+
if (context === void 0) {
|
|
519
|
+
throw new Error(
|
|
520
|
+
"useFavoritesContext must be used within a token FavoritesProvider"
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
return context;
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
// src/utils/platform.ts
|
|
527
|
+
var isReactNativeWebView = () => {
|
|
528
|
+
if (typeof window === "undefined") return false;
|
|
529
|
+
return !!window.ReactNativeWebView;
|
|
530
|
+
};
|
|
531
|
+
var isWebView = () => {
|
|
532
|
+
if (typeof window === "undefined" || typeof navigator === "undefined") return false;
|
|
533
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
534
|
+
if (ua.includes("wv") || ua.includes("android-webview")) return true;
|
|
535
|
+
if ((ua.includes("iphone") || ua.includes("ipad")) && !ua.includes("safari") && !ua.includes("crios"))
|
|
536
|
+
return true;
|
|
537
|
+
if (isReactNativeWebView()) return true;
|
|
538
|
+
return false;
|
|
539
|
+
};
|
|
540
|
+
var isMobileDevice = () => {
|
|
541
|
+
if (typeof navigator === "undefined" || typeof window === "undefined") return false;
|
|
542
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
543
|
+
const isMobile = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile/i.test(ua);
|
|
544
|
+
const hasTouchScreen = "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
545
|
+
return isMobile || hasTouchScreen && window.innerWidth < 1024;
|
|
546
|
+
};
|
|
547
|
+
var shouldInterceptDeepLinks = () => {
|
|
548
|
+
return isReactNativeWebView();
|
|
549
|
+
};
|
|
550
|
+
var isDeepLinkUrl = (url) => {
|
|
551
|
+
if (!url) return false;
|
|
552
|
+
const lower = url.toLowerCase();
|
|
553
|
+
return /^[a-z][a-z0-9+.-]*:\/\//i.test(url) && !lower.startsWith("http://") && !lower.startsWith("https://") && !lower.startsWith("about:") && !lower.startsWith("javascript:") && !lower.startsWith("data:") && !lower.startsWith("blob:") && !lower.startsWith("file:") || // WalletConnect v2: wc:<topic>@2?param=value (no "://")
|
|
554
|
+
lower.startsWith("wc:") || // Android intent:// URLs
|
|
555
|
+
lower.startsWith("intent://");
|
|
556
|
+
};
|
|
557
|
+
var KNOWN_WALLET_UNIVERSAL_LINKS = {
|
|
558
|
+
// MetaMask
|
|
559
|
+
"https://metamask.app.link/": "https://metamask.app.link/",
|
|
560
|
+
// Phantom — /ul/v1/* are encrypted session API endpoints that ONLY work
|
|
561
|
+
// with the https://phantom.app domain. Do NOT convert to phantom://.
|
|
562
|
+
// Both key and value are identical → convertToDeepLink() returns as-is.
|
|
563
|
+
"https://phantom.app/": "https://phantom.app/",
|
|
564
|
+
// Coinbase Wallet
|
|
565
|
+
"https://go.cb-w.com/": "https://go.cb-w.com/",
|
|
566
|
+
// Trust Wallet
|
|
567
|
+
"https://link.trustwallet.com/": "https://link.trustwallet.com/",
|
|
568
|
+
// Rainbow
|
|
569
|
+
"https://rnbwapp.com/": "https://rnbwapp.com/",
|
|
570
|
+
// OKX Wallet
|
|
571
|
+
"https://www.okx.com/": "https://www.okx.com/",
|
|
572
|
+
"https://okx.com/": "https://okx.com/",
|
|
573
|
+
// BitGet / BitKeep
|
|
574
|
+
"https://bitkeep.com/": "https://bitkeep.com/",
|
|
575
|
+
"https://bitget.com/": "https://bitget.com/",
|
|
576
|
+
// TokenPocket
|
|
577
|
+
"https://rn.tokenpocket.pro/": "https://rn.tokenpocket.pro/",
|
|
578
|
+
// SafePal
|
|
579
|
+
"https://safepal.io/": "https://safepal.io/",
|
|
580
|
+
// Zerion
|
|
581
|
+
"https://zerion.io/": "https://zerion.io/",
|
|
582
|
+
// Ledger Live
|
|
583
|
+
"https://ledger.live/": "https://ledger.live/"
|
|
584
|
+
};
|
|
585
|
+
var convertToDeepLink = (url) => {
|
|
586
|
+
if (!url) return url;
|
|
587
|
+
for (const [prefix, scheme] of Object.entries(KNOWN_WALLET_UNIVERSAL_LINKS)) {
|
|
588
|
+
if (url.toLowerCase().startsWith(prefix)) {
|
|
589
|
+
return url.slice(prefix.length) ? scheme + url.slice(prefix.length) : scheme;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
return url;
|
|
593
|
+
};
|
|
594
|
+
var isWalletRelatedUrl = (url) => {
|
|
595
|
+
if (!url) return false;
|
|
596
|
+
if (isDeepLinkUrl(url)) return true;
|
|
597
|
+
const lower = url.toLowerCase();
|
|
598
|
+
return Object.keys(KNOWN_WALLET_UNIVERSAL_LINKS).some(
|
|
599
|
+
(prefix) => lower.startsWith(prefix)
|
|
600
|
+
);
|
|
601
|
+
};
|
|
602
|
+
var handleDeepLink = (url, handler) => {
|
|
603
|
+
if (handler) {
|
|
604
|
+
handler(url);
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
const rnWebView = window.ReactNativeWebView;
|
|
608
|
+
if (rnWebView?.postMessage) {
|
|
609
|
+
rnWebView.postMessage(
|
|
610
|
+
JSON.stringify({
|
|
611
|
+
type: "WHEELX_DEEP_LINK",
|
|
612
|
+
url,
|
|
613
|
+
timestamp: Date.now()
|
|
614
|
+
})
|
|
615
|
+
);
|
|
616
|
+
console.log("[WheelX Widget] Sent deep link via ReactNativeWebView.postMessage:", url);
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
window.dispatchEvent(new CustomEvent("wheelx:deepLink", { detail: { url } }));
|
|
620
|
+
console.log("[WheelX Widget] Dispatched wheelx:deepLink event:", url);
|
|
438
621
|
};
|
|
439
622
|
var tempo = defineChain({
|
|
440
623
|
id: 4217,
|
|
@@ -467,10 +650,10 @@ var supportedChains = [
|
|
|
467
650
|
optimism,
|
|
468
651
|
unichain,
|
|
469
652
|
base$1,
|
|
470
|
-
ink
|
|
653
|
+
ink,
|
|
471
654
|
linea,
|
|
472
655
|
soneium$1,
|
|
473
|
-
bsc
|
|
656
|
+
bsc,
|
|
474
657
|
worldchain,
|
|
475
658
|
opBNB,
|
|
476
659
|
mode,
|
|
@@ -626,12 +809,95 @@ function LoadingSkeleton() {
|
|
|
626
809
|
}
|
|
627
810
|
);
|
|
628
811
|
}
|
|
812
|
+
function DeepLinkInterceptor({ config }) {
|
|
813
|
+
const interceptorInstalled = useRef(false);
|
|
814
|
+
useEffect(() => {
|
|
815
|
+
if (typeof window === "undefined") return;
|
|
816
|
+
if (interceptorInstalled.current) return;
|
|
817
|
+
if (!shouldInterceptDeepLinks()) return;
|
|
818
|
+
interceptorInstalled.current = true;
|
|
819
|
+
const originalOpen = window.open.bind(window);
|
|
820
|
+
window.open = function(...args) {
|
|
821
|
+
const url = typeof args[0] === "string" ? args[0] : "";
|
|
822
|
+
if (url && isWalletRelatedUrl(url)) {
|
|
823
|
+
const deepLink = convertToDeepLink(url);
|
|
824
|
+
console.log("[WheelX Widget] Intercepted window.open deep link:", url, "\u2192", deepLink);
|
|
825
|
+
handleDeepLink(deepLink, config?.onDeepLink);
|
|
826
|
+
return null;
|
|
827
|
+
}
|
|
828
|
+
return originalOpen(...args);
|
|
829
|
+
};
|
|
830
|
+
let originalLocationHrefSetter = null;
|
|
831
|
+
try {
|
|
832
|
+
const proto = Object.getPrototypeOf(window.location);
|
|
833
|
+
const desc = Object.getOwnPropertyDescriptor(proto, "href");
|
|
834
|
+
if (desc?.set) {
|
|
835
|
+
originalLocationHrefSetter = desc.set.bind(window.location);
|
|
836
|
+
Object.defineProperty(window.location, "href", {
|
|
837
|
+
...desc,
|
|
838
|
+
set(value) {
|
|
839
|
+
if (isWalletRelatedUrl(value)) {
|
|
840
|
+
const deepLink = convertToDeepLink(value);
|
|
841
|
+
console.log("[WheelX Widget] Intercepted location.href deep link:", value, "\u2192", deepLink);
|
|
842
|
+
handleDeepLink(deepLink, config?.onDeepLink);
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
return originalLocationHrefSetter.call(window.location, value);
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
console.log("[WheelX Widget] location.href interceptor INSTALLED successfully");
|
|
849
|
+
} else {
|
|
850
|
+
console.warn("[WheelX Widget] location.href interceptor NOT installed: no setter descriptor found");
|
|
851
|
+
}
|
|
852
|
+
} catch (e) {
|
|
853
|
+
console.warn("[WheelX Widget] location.href interceptor FAILED:", String(e));
|
|
854
|
+
}
|
|
855
|
+
const handleClick = (e) => {
|
|
856
|
+
const target = e.target;
|
|
857
|
+
const anchor = target.closest("a");
|
|
858
|
+
if (!anchor) return;
|
|
859
|
+
const href = anchor.getAttribute("href") || "";
|
|
860
|
+
if (href && isWalletRelatedUrl(href)) {
|
|
861
|
+
e.preventDefault();
|
|
862
|
+
e.stopPropagation();
|
|
863
|
+
const deepLink = convertToDeepLink(href);
|
|
864
|
+
console.log("[WheelX Widget] Intercepted anchor click deep link:", href, "\u2192", deepLink);
|
|
865
|
+
handleDeepLink(deepLink, config?.onDeepLink);
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
const handleBeforeUnload = () => {
|
|
869
|
+
const currentHref = window.location.href;
|
|
870
|
+
if (isWalletRelatedUrl(currentHref)) {
|
|
871
|
+
console.log("[WheelX Widget] Detected deep link navigation in beforeunload:", currentHref);
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
document.addEventListener("click", handleClick, true);
|
|
875
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
876
|
+
console.log("[WheelX Widget] Deep link interceptor installed for WebView environment");
|
|
877
|
+
return () => {
|
|
878
|
+
document.removeEventListener("click", handleClick, true);
|
|
879
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
880
|
+
window.open = originalOpen;
|
|
881
|
+
if (originalLocationHrefSetter) {
|
|
882
|
+
try {
|
|
883
|
+
const proto = Object.getPrototypeOf(window.location);
|
|
884
|
+
const originalDesc = Object.getOwnPropertyDescriptor(proto, "href");
|
|
885
|
+
if (originalDesc) {
|
|
886
|
+
Object.defineProperty(window.location, "href", originalDesc);
|
|
887
|
+
}
|
|
888
|
+
} catch (_) {
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
}, []);
|
|
893
|
+
return null;
|
|
894
|
+
}
|
|
629
895
|
function ChainsAndTokensLoader({ children, config }) {
|
|
630
896
|
const { data } = useChainsAndTokens(true);
|
|
631
897
|
const { setChains, setSlippagePolicies } = useChainsStore();
|
|
632
898
|
const { setTokens } = useTokensStore();
|
|
633
899
|
const initialDataRef = React5__default.useRef(false);
|
|
634
|
-
const
|
|
900
|
+
const allChains2 = useMemo(() => {
|
|
635
901
|
if (!data?.chains) return null;
|
|
636
902
|
const l = [...data.chains];
|
|
637
903
|
if (data.deposit_platforms?.prediction?.chains) l.push(...data.deposit_platforms.prediction.chains);
|
|
@@ -643,7 +909,7 @@ function ChainsAndTokensLoader({ children, config }) {
|
|
|
643
909
|
if (data.deposit_platforms?.prediction?.tokens) l.push(...data.deposit_platforms.prediction.tokens);
|
|
644
910
|
return l;
|
|
645
911
|
}, [data]);
|
|
646
|
-
const filteredChains =
|
|
912
|
+
const filteredChains = allChains2;
|
|
647
913
|
const filteredTokens = allTokens;
|
|
648
914
|
React5__default.useEffect(() => {
|
|
649
915
|
if (filteredChains && !initialDataRef.current) {
|
|
@@ -668,6 +934,9 @@ function ChainsAndTokensLoader({ children, config }) {
|
|
|
668
934
|
var DEFAULT_ENVIRONMENT_ID = "f217660e-2cec-470b-a8f4-ac655b16f802";
|
|
669
935
|
var solanaRpcUrl = "https://mainnet.helius-rpc.com/?api-key=7337bed2-6c3a-472f-b06f-9b2be0e1392f";
|
|
670
936
|
var WheelXProvider = ({ config, children }) => {
|
|
937
|
+
if (config?.apiBaseUrl) {
|
|
938
|
+
setBaseApiUrl(config.apiBaseUrl);
|
|
939
|
+
}
|
|
671
940
|
const queryClient = useMemo(() => new QueryClient(), []);
|
|
672
941
|
const evmNetworks = useMemo(() => supportedChains.map((chain) => ({
|
|
673
942
|
chainId: chain.id,
|
|
@@ -678,18 +947,46 @@ var WheelXProvider = ({ config, children }) => {
|
|
|
678
947
|
blockExplorerUrls: chain.blockExplorers?.default?.url ? [chain.blockExplorers.default.url] : []
|
|
679
948
|
})), []);
|
|
680
949
|
const solanaConnectors = useMemo(() => SolanaWalletConnectorsWithConfig({ customRpcUrls: { solana: [solanaRpcUrl] } }), []);
|
|
681
|
-
const dynamicSettings = useMemo(() =>
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
950
|
+
const dynamicSettings = useMemo(() => {
|
|
951
|
+
const isRN = isReactNativeWebView();
|
|
952
|
+
return {
|
|
953
|
+
environmentId: config?.dynamicEnvironmentId || DEFAULT_ENVIRONMENT_ID,
|
|
954
|
+
walletConnectors: [EthereumWalletConnectors, solanaConnectors],
|
|
955
|
+
enableConnectOnlyFallback: false,
|
|
956
|
+
initialAuthenticationMode: "connect-only",
|
|
957
|
+
// ── mobileExperience ──────────────────────────────────────
|
|
958
|
+
// H5 / DApp browser: use simple global string (original behavior).
|
|
959
|
+
// The browser natively handles https:// universal links to open
|
|
960
|
+
// wallet apps — no interception needed.
|
|
961
|
+
//
|
|
962
|
+
// React Native WebView: use per-wallet object config so each wallet
|
|
963
|
+
// explicitly uses 'redirect' mode, forcing the SDK to generate deep
|
|
964
|
+
// link URLs that our DeepLinkInterceptor can catch and forward.
|
|
965
|
+
...isRN ? {
|
|
966
|
+
mobileExperience: {
|
|
967
|
+
okx: "redirect",
|
|
968
|
+
phantom: "redirect",
|
|
969
|
+
metamask: "redirect",
|
|
970
|
+
default: "redirect"
|
|
971
|
+
}
|
|
972
|
+
} : {
|
|
973
|
+
mobileExperience: "redirect"
|
|
974
|
+
},
|
|
975
|
+
// In React Native WebView, use 'native' so Dynamic SDK generates
|
|
976
|
+
// phantom://, metamask:// etc. — these custom schemes route directly
|
|
977
|
+
// to the wallet app via Linking.openURL(), avoiding the browser.
|
|
978
|
+
// In H5 / DApp, use 'universal' so the browser handles the https://
|
|
979
|
+
// universal links normally.
|
|
980
|
+
deepLinkPreference: isRN ? "native" : "universal",
|
|
981
|
+
defaultNumberOfWalletsToShow: 25,
|
|
982
|
+
overrides: { evmNetworks }
|
|
983
|
+
};
|
|
984
|
+
}, [evmNetworks, solanaConnectors, config?.dynamicEnvironmentId]);
|
|
691
985
|
const wagmiConfig = useMemo(() => getWagmiConfig(), []);
|
|
692
|
-
return /* @__PURE__ */ jsx(WidgetThemeProvider, { theme: config?.theme, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(DynamicContextProvider, { settings: dynamicSettings, children: /* @__PURE__ */ jsx(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */
|
|
986
|
+
return /* @__PURE__ */ jsx(WidgetThemeProvider, { theme: config?.theme, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(DynamicContextProvider, { settings: dynamicSettings, children: /* @__PURE__ */ jsx(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsxs(DynamicWagmiConnector, { children: [
|
|
987
|
+
/* @__PURE__ */ jsx(DeepLinkInterceptor, { config }),
|
|
988
|
+
/* @__PURE__ */ jsx(ChainsAndTokensLoader, { config, children })
|
|
989
|
+
] }) }) }) }) });
|
|
693
990
|
};
|
|
694
991
|
var createQuoteMutationError = (message, extra) => {
|
|
695
992
|
const quoteError = new Error(message);
|
|
@@ -716,7 +1013,7 @@ var useGetQuote = (signal) => useMutation({
|
|
|
716
1013
|
mutationFn: async (requestBody) => {
|
|
717
1014
|
try {
|
|
718
1015
|
const res = await axios6.post(
|
|
719
|
-
`${
|
|
1016
|
+
`${getBaseApiUrl()}/v1/quote`,
|
|
720
1017
|
{
|
|
721
1018
|
...requestBody,
|
|
722
1019
|
quote_only: true
|
|
@@ -779,7 +1076,7 @@ var useGetQuote = (signal) => useMutation({
|
|
|
779
1076
|
}
|
|
780
1077
|
});
|
|
781
1078
|
async function getTokenInfo(value, chainId) {
|
|
782
|
-
const url = `${
|
|
1079
|
+
const url = `${getBaseApiUrl()}/v1/token-info`;
|
|
783
1080
|
const res = await axios6.get(url, {
|
|
784
1081
|
params: {
|
|
785
1082
|
address: value,
|
|
@@ -796,12 +1093,13 @@ var useTokenInfo = ({
|
|
|
796
1093
|
const result = useQuery({
|
|
797
1094
|
queryKey: ["tokenInfo", value, chainId],
|
|
798
1095
|
queryFn: () => getTokenInfo(value, chainId),
|
|
1096
|
+
// enabled: !!value && isAddress(value)
|
|
799
1097
|
enabled: !!value && !!chainId
|
|
800
1098
|
});
|
|
801
1099
|
return result;
|
|
802
1100
|
};
|
|
803
1101
|
async function getUsdPrice(tokens) {
|
|
804
|
-
const url = `${
|
|
1102
|
+
const url = `${getBaseApiUrl()}/v1/token-price`;
|
|
805
1103
|
const res = await axios6.post(url, tokens);
|
|
806
1104
|
return res.data;
|
|
807
1105
|
}
|
|
@@ -815,15 +1113,25 @@ var useUsdPrice = (tokens) => {
|
|
|
815
1113
|
});
|
|
816
1114
|
};
|
|
817
1115
|
var getHyperliquidBalance = async (address) => {
|
|
1116
|
+
const newUrl = `https://api.hyperliquid.xyz/info`;
|
|
818
1117
|
try {
|
|
819
|
-
const response = await fetch(
|
|
1118
|
+
const response = await fetch(`${newUrl}`, {
|
|
820
1119
|
method: "POST",
|
|
821
|
-
headers: {
|
|
822
|
-
|
|
1120
|
+
headers: {
|
|
1121
|
+
"Content-Type": "application/json"
|
|
1122
|
+
},
|
|
1123
|
+
body: JSON.stringify({
|
|
1124
|
+
type: "clearinghouseState",
|
|
1125
|
+
user: address
|
|
1126
|
+
})
|
|
823
1127
|
});
|
|
824
1128
|
return await response.json();
|
|
825
1129
|
} catch (error) {
|
|
826
|
-
return {
|
|
1130
|
+
return {
|
|
1131
|
+
code: 1,
|
|
1132
|
+
message: error,
|
|
1133
|
+
withdrawable: null
|
|
1134
|
+
};
|
|
827
1135
|
}
|
|
828
1136
|
};
|
|
829
1137
|
var useHyperliquidBalance = (address, enabled) => {
|
|
@@ -843,7 +1151,7 @@ var useHyperliquidBalance = (address, enabled) => {
|
|
|
843
1151
|
};
|
|
844
1152
|
async function getOrderDetail(orderId) {
|
|
845
1153
|
const res = await axios6.get(
|
|
846
|
-
`${
|
|
1154
|
+
`${getBaseApiUrl()}/v1/order/${orderId}`
|
|
847
1155
|
);
|
|
848
1156
|
return res.data;
|
|
849
1157
|
}
|
|
@@ -866,6 +1174,7 @@ var useIntervalGetOrderDetailPlus = ({
|
|
|
866
1174
|
},
|
|
867
1175
|
refetchOnMount: false,
|
|
868
1176
|
retry: false,
|
|
1177
|
+
// Disable React Query's built-in retries; rely on refetchInterval for continuous polling
|
|
869
1178
|
enabled: queryEnabled
|
|
870
1179
|
});
|
|
871
1180
|
useEffect(() => {
|
|
@@ -891,14 +1200,22 @@ var useIntervalGetOrderDetailPlus = ({
|
|
|
891
1200
|
};
|
|
892
1201
|
};
|
|
893
1202
|
async function getTokenBalance(address) {
|
|
894
|
-
const url = `${
|
|
895
|
-
const res = await axios6.get(url, {
|
|
1203
|
+
const url = `${getBaseApiUrl()}/v1/token-balances`;
|
|
1204
|
+
const res = await axios6.get(url, {
|
|
1205
|
+
params: {
|
|
1206
|
+
address
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
896
1209
|
return res.data;
|
|
897
1210
|
}
|
|
898
1211
|
async function getSolanaTokenBalance(address) {
|
|
899
1212
|
if (!address) return [];
|
|
900
|
-
const url = `${
|
|
901
|
-
const res = await axios6.get(url, {
|
|
1213
|
+
const url = `${getBaseApiUrl()}/v1/token-balances`;
|
|
1214
|
+
const res = await axios6.get(url, {
|
|
1215
|
+
params: {
|
|
1216
|
+
address
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
902
1219
|
return res.data;
|
|
903
1220
|
}
|
|
904
1221
|
async function getAllTokenBalances(evmAddress, solanaAddress) {
|
|
@@ -909,11 +1226,12 @@ async function getAllTokenBalances(evmAddress, solanaAddress) {
|
|
|
909
1226
|
return [...evmBalances || [], ...solanaBalances || []];
|
|
910
1227
|
}
|
|
911
1228
|
var useAllTokenBalance = (evmAddress, solanaAddress) => {
|
|
912
|
-
|
|
1229
|
+
const result = useQuery({
|
|
913
1230
|
queryKey: ["allTokenBalance", evmAddress, solanaAddress],
|
|
914
1231
|
queryFn: () => getAllTokenBalances(evmAddress, solanaAddress),
|
|
915
1232
|
enabled: !!evmAddress || !!solanaAddress
|
|
916
1233
|
});
|
|
1234
|
+
return result;
|
|
917
1235
|
};
|
|
918
1236
|
var useDifferentAddressStore = create((set) => ({
|
|
919
1237
|
differentAddress: void 0,
|
|
@@ -921,6 +1239,10 @@ var useDifferentAddressStore = create((set) => ({
|
|
|
921
1239
|
isDepositPlatformToken: false,
|
|
922
1240
|
setIsDepositPlatformToken: (isDepositPlatformToken) => set({ isDepositPlatformToken })
|
|
923
1241
|
}));
|
|
1242
|
+
var useGetGasStore = create((set) => ({
|
|
1243
|
+
sponsorGas: false,
|
|
1244
|
+
setSponsorGas: (sponsorGas) => set({ sponsorGas })
|
|
1245
|
+
}));
|
|
924
1246
|
var useWalletConnectModal = () => {
|
|
925
1247
|
const { setShowAuthFlow } = useDynamicContext();
|
|
926
1248
|
const { setShowLinkNewWalletModal } = useDynamicModals();
|
|
@@ -1034,6 +1356,7 @@ var Store = class {
|
|
|
1034
1356
|
setStorageData(data) {
|
|
1035
1357
|
setLocalStorage(this.key, JSON.stringify(data));
|
|
1036
1358
|
}
|
|
1359
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1037
1360
|
get(label) {
|
|
1038
1361
|
const data = this.getStorageData();
|
|
1039
1362
|
return data[label] || null;
|
|
@@ -1153,7 +1476,7 @@ var logger = {
|
|
|
1153
1476
|
error: errorWithTimestamp,
|
|
1154
1477
|
debug: debugWithTimestamp
|
|
1155
1478
|
};
|
|
1156
|
-
var wagmiSupportedChains = [mainnet, base$1, soneium$1, polygon, arbitrum, optimism, bsc
|
|
1479
|
+
var wagmiSupportedChains = [mainnet, base$1, soneium$1, polygon, arbitrum, optimism, bsc];
|
|
1157
1480
|
var getTxLink = (txHash, chainId) => {
|
|
1158
1481
|
if (isSolanaChain(chainId)) {
|
|
1159
1482
|
return `${SOLANA_MAINNET.explorerUrl}/tx/${txHash}`;
|
|
@@ -1173,35 +1496,28 @@ var openFunctionHash = "0x3448bbc2203c608599ad448eeb1007cea04b788ac631f9f558e8dd
|
|
|
1173
1496
|
function isApproveValid(approve) {
|
|
1174
1497
|
return approve != null && typeof approve === "object" && Object.keys(approve).length > 0 && approve.amount !== void 0 && approve.spender !== void 0 && approve.token !== void 0;
|
|
1175
1498
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
loading: (_opts) => {
|
|
1188
|
-
},
|
|
1189
|
-
create: (_opts) => "",
|
|
1190
|
-
remove: (_id) => {
|
|
1191
|
-
},
|
|
1192
|
-
isActive: (_id) => false,
|
|
1193
|
-
closeAll: () => {
|
|
1194
|
-
},
|
|
1195
|
-
close: (_id) => {
|
|
1196
|
-
}
|
|
1499
|
+
var toaster = createToaster({
|
|
1500
|
+
placement: "top-end",
|
|
1501
|
+
pauseOnPageIdle: true
|
|
1502
|
+
});
|
|
1503
|
+
var bottomToaster = createToaster({
|
|
1504
|
+
placement: "bottom-end",
|
|
1505
|
+
pauseOnPageIdle: true
|
|
1506
|
+
});
|
|
1507
|
+
var topToaster = createToaster({
|
|
1508
|
+
placement: "top",
|
|
1509
|
+
pauseOnPageIdle: true
|
|
1197
1510
|
});
|
|
1198
|
-
var toaster = createToastStub();
|
|
1199
1511
|
var initialState = {
|
|
1512
|
+
// fromTxHash:
|
|
1513
|
+
// '0x635470331be4c59357ff80b62c596ba5b09508d8c1572477ad7b2f4f0a0bd1a7' as `0x${string}`,
|
|
1200
1514
|
fromTxHash: null,
|
|
1201
1515
|
toTxHash: null,
|
|
1202
1516
|
startTrading: false,
|
|
1203
1517
|
solanaFromTxHash: null,
|
|
1204
1518
|
isSolanaTransaction: false
|
|
1519
|
+
// fromValue: null,
|
|
1520
|
+
// tryAgain: false
|
|
1205
1521
|
};
|
|
1206
1522
|
var useTxStateContextStore = create((set) => ({
|
|
1207
1523
|
...initialState,
|
|
@@ -1440,9 +1756,6 @@ var useResetSwapAndBridgeState = () => {
|
|
|
1440
1756
|
prevPathnameRef.current = currentPathname;
|
|
1441
1757
|
}, []);
|
|
1442
1758
|
};
|
|
1443
|
-
var logger2 = {
|
|
1444
|
-
error: (...args) => console.error(...args)
|
|
1445
|
-
};
|
|
1446
1759
|
var useGuardChain = (callback, requiredChainId) => {
|
|
1447
1760
|
const [isSwitching, setIsSwitching] = useState(false);
|
|
1448
1761
|
const cb = useRef(callback);
|
|
@@ -1455,29 +1768,42 @@ var useGuardChain = (callback, requiredChainId) => {
|
|
|
1455
1768
|
isSwitching,
|
|
1456
1769
|
sendTx: useCallback(async () => {
|
|
1457
1770
|
if (chainId !== requiredChainId) {
|
|
1771
|
+
console.log("###chainId is !== requiredChainId, need switch chain###");
|
|
1772
|
+
console.log(
|
|
1773
|
+
"###current chainId:",
|
|
1774
|
+
chainId,
|
|
1775
|
+
"requiredChainId:",
|
|
1776
|
+
requiredChainId
|
|
1777
|
+
);
|
|
1458
1778
|
try {
|
|
1459
1779
|
setIsSwitching(true);
|
|
1460
1780
|
await connectRequiredChain(config, requiredChainId, connector);
|
|
1781
|
+
console.log("###switch chain success###");
|
|
1782
|
+
console.log("### reconnecting wagmi connector ###");
|
|
1461
1783
|
try {
|
|
1462
1784
|
await reconnectAsync();
|
|
1463
|
-
} catch {
|
|
1785
|
+
} catch (reconnectError) {
|
|
1786
|
+
console.log("### reconnect failed, but continuing ###", reconnectError);
|
|
1464
1787
|
}
|
|
1465
1788
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
1466
1789
|
setIsSwitching(false);
|
|
1467
1790
|
cb.current();
|
|
1468
1791
|
} catch (error) {
|
|
1469
1792
|
setIsSwitching(false);
|
|
1470
|
-
|
|
1793
|
+
console.log("###switch chain fail###");
|
|
1794
|
+
logger.error("switch chain error", error);
|
|
1471
1795
|
throw new Error(
|
|
1472
1796
|
`Failed to switch to ${getChainName(config, requiredChainId)}. Please switch manually in your wallet.`
|
|
1473
1797
|
);
|
|
1474
1798
|
}
|
|
1475
1799
|
} else {
|
|
1476
1800
|
if (!connector) {
|
|
1801
|
+
console.log("### connector is undefined on correct chain, reconnecting... ###");
|
|
1477
1802
|
try {
|
|
1478
1803
|
await reconnectAsync();
|
|
1479
1804
|
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
1480
|
-
} catch {
|
|
1805
|
+
} catch (reconnectError) {
|
|
1806
|
+
console.log("### reconnect failed ###", reconnectError);
|
|
1481
1807
|
}
|
|
1482
1808
|
}
|
|
1483
1809
|
cb.current();
|
|
@@ -1494,13 +1820,24 @@ async function connectRequiredChain(config, chainId, connector) {
|
|
|
1494
1820
|
if (!chain) {
|
|
1495
1821
|
throw new Error(`Chain with id ${chainId} not found in config`);
|
|
1496
1822
|
}
|
|
1823
|
+
console.log("### connectRequiredChain ###", {
|
|
1824
|
+
chainId,
|
|
1825
|
+
chainName: chain.name
|
|
1826
|
+
});
|
|
1827
|
+
console.log("### connector ###", connector?.name, connector?.id);
|
|
1497
1828
|
let provider;
|
|
1498
1829
|
if (connector) {
|
|
1499
1830
|
try {
|
|
1500
1831
|
if (connector.id && connector.name) {
|
|
1501
1832
|
provider = await connector.getProvider?.();
|
|
1833
|
+
console.log("### Got provider from connector ###", {
|
|
1834
|
+
connectorName: connector.name,
|
|
1835
|
+
connectorId: connector.id,
|
|
1836
|
+
isMetaMask: provider?.isMetaMask
|
|
1837
|
+
});
|
|
1502
1838
|
}
|
|
1503
|
-
} catch {
|
|
1839
|
+
} catch (e) {
|
|
1840
|
+
console.log("### Failed to get provider from connector, will use fallback ###", e);
|
|
1504
1841
|
}
|
|
1505
1842
|
}
|
|
1506
1843
|
if (!provider) {
|
|
@@ -1520,17 +1857,30 @@ async function connectRequiredChain(config, chainId, connector) {
|
|
|
1520
1857
|
} else {
|
|
1521
1858
|
provider = ethereum;
|
|
1522
1859
|
}
|
|
1860
|
+
console.log("### Fallback to window.ethereum ###", {
|
|
1861
|
+
isMetaMask: provider?.isMetaMask,
|
|
1862
|
+
isOkxWallet: provider?.isOkxWallet
|
|
1863
|
+
});
|
|
1523
1864
|
}
|
|
1524
1865
|
if (!provider) {
|
|
1525
1866
|
throw new Error("No wallet provider found");
|
|
1526
1867
|
}
|
|
1868
|
+
console.log("### Provider info ###", {
|
|
1869
|
+
isMetaMask: provider.isMetaMask,
|
|
1870
|
+
isConnected: provider.isConnected?.()
|
|
1871
|
+
});
|
|
1527
1872
|
try {
|
|
1873
|
+
console.log("### Trying wallet_switchEthereumChain ###");
|
|
1528
1874
|
await provider.request({
|
|
1529
1875
|
method: "wallet_switchEthereumChain",
|
|
1530
1876
|
params: [{ chainId: `0x${chainId.toString(16)}` }]
|
|
1531
1877
|
});
|
|
1878
|
+
console.log("### wallet_switchEthereumChain success ###");
|
|
1532
1879
|
} catch (switchError) {
|
|
1880
|
+
console.log("### switchChain error ###", switchError);
|
|
1881
|
+
console.log("### error.code ###", switchError?.code);
|
|
1533
1882
|
if (switchError?.code === 4902) {
|
|
1883
|
+
console.log("### Chain not found, adding to wallet ###");
|
|
1534
1884
|
const addChainParams = {
|
|
1535
1885
|
chainId: `0x${chainId.toString(16)}`,
|
|
1536
1886
|
chainName: chain.name,
|
|
@@ -1538,16 +1888,20 @@ async function connectRequiredChain(config, chainId, connector) {
|
|
|
1538
1888
|
name: chain.nativeCurrency.name,
|
|
1539
1889
|
symbol: chain.nativeCurrency.symbol,
|
|
1540
1890
|
decimals: 18
|
|
1891
|
+
// Metamask requires decimals to be 18
|
|
1541
1892
|
},
|
|
1542
1893
|
rpcUrls: chain.rpcUrls.default.http,
|
|
1543
1894
|
blockExplorerUrls: chain.blockExplorers?.default ? [chain.blockExplorers.default.url] : []
|
|
1544
1895
|
};
|
|
1896
|
+
console.log("### addChainParams ###", addChainParams);
|
|
1545
1897
|
try {
|
|
1546
1898
|
await provider.request({
|
|
1547
1899
|
method: "wallet_addEthereumChain",
|
|
1548
1900
|
params: [addChainParams]
|
|
1549
1901
|
});
|
|
1902
|
+
console.log("### Chain added successfully ###");
|
|
1550
1903
|
} catch (addError) {
|
|
1904
|
+
console.log("### wallet_addEthereumChain error ###", addError);
|
|
1551
1905
|
throw addError;
|
|
1552
1906
|
}
|
|
1553
1907
|
} else {
|
|
@@ -1592,11 +1946,311 @@ var useRefreshLoading = () => {
|
|
|
1592
1946
|
}, [isLoading, setIsLoading]);
|
|
1593
1947
|
return { isLoading, startLoading };
|
|
1594
1948
|
};
|
|
1949
|
+
var katana2 = /* @__PURE__ */ defineChain({
|
|
1950
|
+
id: 747474,
|
|
1951
|
+
name: "Katana",
|
|
1952
|
+
network: "katana",
|
|
1953
|
+
nativeCurrency: {
|
|
1954
|
+
name: "Ether",
|
|
1955
|
+
symbol: "ETH",
|
|
1956
|
+
decimals: 18
|
|
1957
|
+
},
|
|
1958
|
+
rpcUrls: {
|
|
1959
|
+
default: {
|
|
1960
|
+
http: ["https://rpc.katana.network"]
|
|
1961
|
+
}
|
|
1962
|
+
},
|
|
1963
|
+
blockExplorers: {
|
|
1964
|
+
default: {
|
|
1965
|
+
name: "katana explorer",
|
|
1966
|
+
url: "https://explorer.katanarpc.com"
|
|
1967
|
+
}
|
|
1968
|
+
},
|
|
1969
|
+
contracts: {
|
|
1970
|
+
multicall3: {
|
|
1971
|
+
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
1972
|
+
blockCreated: 1898013
|
|
1973
|
+
}
|
|
1974
|
+
},
|
|
1975
|
+
testnet: false
|
|
1976
|
+
});
|
|
1977
|
+
var hyperevm2 = /* @__PURE__ */ defineChain({
|
|
1978
|
+
id: 999,
|
|
1979
|
+
name: "HyperEVM",
|
|
1980
|
+
network: "HYPE",
|
|
1981
|
+
nativeCurrency: {
|
|
1982
|
+
name: "HYPER",
|
|
1983
|
+
symbol: "HYPER",
|
|
1984
|
+
decimals: 18
|
|
1985
|
+
},
|
|
1986
|
+
rpcUrls: {
|
|
1987
|
+
default: {
|
|
1988
|
+
http: ["https://rpc.hyperliquid.xyz/evm", "https://rpc.hypurrscan.io"]
|
|
1989
|
+
}
|
|
1990
|
+
},
|
|
1991
|
+
blockExplorers: {
|
|
1992
|
+
default: {
|
|
1993
|
+
name: "Purrsec",
|
|
1994
|
+
url: "https://hyperevmscan.io"
|
|
1995
|
+
}
|
|
1996
|
+
},
|
|
1997
|
+
contracts: {
|
|
1998
|
+
multicall3: {
|
|
1999
|
+
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
2000
|
+
blockCreated: 13051
|
|
2001
|
+
}
|
|
2002
|
+
},
|
|
2003
|
+
testnet: false
|
|
2004
|
+
});
|
|
2005
|
+
var plasma2 = /* @__PURE__ */ defineChain({
|
|
2006
|
+
id: 9745,
|
|
2007
|
+
name: "Plasma",
|
|
2008
|
+
network: "Plasma",
|
|
2009
|
+
nativeCurrency: {
|
|
2010
|
+
name: "Plasma",
|
|
2011
|
+
symbol: "XPL",
|
|
2012
|
+
decimals: 18
|
|
2013
|
+
},
|
|
2014
|
+
rpcUrls: {
|
|
2015
|
+
default: {
|
|
2016
|
+
http: ["https://rpc.plasma.to"]
|
|
2017
|
+
}
|
|
2018
|
+
},
|
|
2019
|
+
blockExplorers: {
|
|
2020
|
+
default: {
|
|
2021
|
+
name: "Plasma explorer",
|
|
2022
|
+
url: "https://plasmascan.to"
|
|
2023
|
+
}
|
|
2024
|
+
},
|
|
2025
|
+
contracts: {
|
|
2026
|
+
multicall3: {
|
|
2027
|
+
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
2028
|
+
blockCreated: 1
|
|
2029
|
+
}
|
|
2030
|
+
},
|
|
2031
|
+
testnet: true
|
|
2032
|
+
});
|
|
2033
|
+
var rari2 = /* @__PURE__ */ defineChain({
|
|
2034
|
+
id: 1380012617,
|
|
2035
|
+
name: "RARI",
|
|
2036
|
+
network: "rari",
|
|
2037
|
+
nativeCurrency: {
|
|
2038
|
+
name: "Ether",
|
|
2039
|
+
symbol: "ETH",
|
|
2040
|
+
decimals: 18
|
|
2041
|
+
},
|
|
2042
|
+
rpcUrls: {
|
|
2043
|
+
default: {
|
|
2044
|
+
http: ["https://mainnet.rpc.rarichain.org/http"]
|
|
2045
|
+
}
|
|
2046
|
+
},
|
|
2047
|
+
blockExplorers: {
|
|
2048
|
+
default: {
|
|
2049
|
+
name: "RARI explorer",
|
|
2050
|
+
url: "https://mainnet.explorer.rarichain.org/"
|
|
2051
|
+
}
|
|
2052
|
+
},
|
|
2053
|
+
contracts: {
|
|
2054
|
+
multicall3: {
|
|
2055
|
+
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
2056
|
+
blockCreated: 1898013
|
|
2057
|
+
}
|
|
2058
|
+
},
|
|
2059
|
+
testnet: true
|
|
2060
|
+
});
|
|
2061
|
+
|
|
2062
|
+
// src/consts/stable.ts
|
|
2063
|
+
var stable2 = { tokens: [], id: 1 };
|
|
2064
|
+
|
|
2065
|
+
// src/consts/monad.ts
|
|
2066
|
+
var monad2 = { tokens: [], chains: [], id: 10143 };
|
|
2067
|
+
|
|
2068
|
+
// src/consts/mainnet.ts
|
|
2069
|
+
var mainnet3 = { tokens: [], chains: [], id: 1 };
|
|
2070
|
+
var metis2 = /* @__PURE__ */ defineChain({
|
|
2071
|
+
id: 1088,
|
|
2072
|
+
name: "Metis",
|
|
2073
|
+
nativeCurrency: {
|
|
2074
|
+
decimals: 18,
|
|
2075
|
+
name: "Metis",
|
|
2076
|
+
symbol: "METIS"
|
|
2077
|
+
},
|
|
2078
|
+
rpcUrls: {
|
|
2079
|
+
default: {
|
|
2080
|
+
http: [
|
|
2081
|
+
"https://metis.api.onfinality.io/public",
|
|
2082
|
+
"https://metis-public.nodies.app",
|
|
2083
|
+
"https://metis-andromeda.rpc.thirdweb.com",
|
|
2084
|
+
"https://metis.drpc.org"
|
|
2085
|
+
],
|
|
2086
|
+
webSocket: ["wss://metis-rpc.publicnode.com", "wss://metis.drpc.org"]
|
|
2087
|
+
}
|
|
2088
|
+
},
|
|
2089
|
+
blockExplorers: {
|
|
2090
|
+
default: {
|
|
2091
|
+
name: "Metis Explorer",
|
|
2092
|
+
url: "https://explorer.metis.io",
|
|
2093
|
+
apiUrl: "https://api.routescan.io/v2/network/mainnet/evm/1088/etherscan/api"
|
|
2094
|
+
}
|
|
2095
|
+
},
|
|
2096
|
+
contracts: {
|
|
2097
|
+
multicall3: {
|
|
2098
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
2099
|
+
blockCreated: 2338552
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
});
|
|
2103
|
+
var polygonZkEvm2 = /* @__PURE__ */ defineChain({
|
|
2104
|
+
id: 1101,
|
|
2105
|
+
name: "Polygon zkEVM",
|
|
2106
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
2107
|
+
rpcUrls: {
|
|
2108
|
+
default: {
|
|
2109
|
+
http: ["https://zkevm-rpc.com"]
|
|
2110
|
+
}
|
|
2111
|
+
},
|
|
2112
|
+
blockExplorers: {
|
|
2113
|
+
default: {
|
|
2114
|
+
name: "PolygonScan",
|
|
2115
|
+
url: "https://www.oklink.com/polygon-zkevm",
|
|
2116
|
+
apiUrl: "https://api-zkevm.polygonscan.com/api"
|
|
2117
|
+
}
|
|
2118
|
+
},
|
|
2119
|
+
contracts: {
|
|
2120
|
+
multicall3: {
|
|
2121
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
2122
|
+
blockCreated: 57746
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
});
|
|
2126
|
+
var megaeth2 = /* @__PURE__ */ defineChain({
|
|
2127
|
+
id: 4326,
|
|
2128
|
+
name: "MegaETH",
|
|
2129
|
+
network: "MegaETH",
|
|
2130
|
+
nativeCurrency: {
|
|
2131
|
+
name: "ETH",
|
|
2132
|
+
symbol: "ETH",
|
|
2133
|
+
decimals: 18
|
|
2134
|
+
},
|
|
2135
|
+
rpcUrls: {
|
|
2136
|
+
default: {
|
|
2137
|
+
http: ["https://mainnet.megaeth.com/rpc"]
|
|
2138
|
+
}
|
|
2139
|
+
},
|
|
2140
|
+
blockExplorers: {
|
|
2141
|
+
default: {
|
|
2142
|
+
name: "megaeth explorer",
|
|
2143
|
+
url: "https://megaeth.blockscout.com/"
|
|
2144
|
+
}
|
|
2145
|
+
},
|
|
2146
|
+
contracts: {
|
|
2147
|
+
multicall3: {
|
|
2148
|
+
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
2149
|
+
blockCreated: 0
|
|
2150
|
+
}
|
|
2151
|
+
},
|
|
2152
|
+
testnet: false
|
|
2153
|
+
});
|
|
2154
|
+
|
|
2155
|
+
// src/consts/chainsInfo.ts
|
|
2156
|
+
var allChains = [
|
|
2157
|
+
{ chain: mainnet, networkType: "mainnet" },
|
|
2158
|
+
{ chain: arbitrum, networkType: "mainnet" },
|
|
2159
|
+
{ chain: optimism, networkType: "mainnet" },
|
|
2160
|
+
{ chain: base$1, networkType: "mainnet" },
|
|
2161
|
+
{ chain: polygon, networkType: "mainnet" },
|
|
2162
|
+
{ chain: bsc, networkType: "mainnet" },
|
|
2163
|
+
{ chain: avalanche, networkType: "mainnet" },
|
|
2164
|
+
{ chain: zksync, networkType: "mainnet" },
|
|
2165
|
+
{ chain: linea, networkType: "mainnet" },
|
|
2166
|
+
{ chain: scroll, networkType: "mainnet" },
|
|
2167
|
+
{ chain: mantle, networkType: "mainnet" },
|
|
2168
|
+
{ chain: blast, networkType: "mainnet" },
|
|
2169
|
+
{ chain: celo, networkType: "mainnet" },
|
|
2170
|
+
{ chain: gnosis, networkType: "mainnet" },
|
|
2171
|
+
{ chain: sonic, networkType: "mainnet" },
|
|
2172
|
+
{ chain: zora, networkType: "mainnet" },
|
|
2173
|
+
{ chain: mode, networkType: "mainnet" },
|
|
2174
|
+
{ chain: taiko, networkType: "mainnet" },
|
|
2175
|
+
{ chain: sei, networkType: "mainnet" },
|
|
2176
|
+
{ chain: xdc, networkType: "mainnet" },
|
|
2177
|
+
{ chain: ink, networkType: "mainnet" },
|
|
2178
|
+
{ chain: soneium$1, networkType: "mainnet" },
|
|
2179
|
+
{ chain: worldchain, networkType: "mainnet" },
|
|
2180
|
+
{ chain: unichain, networkType: "mainnet" },
|
|
2181
|
+
{ chain: opBNB, networkType: "mainnet" },
|
|
2182
|
+
{ chain: lisk, networkType: "mainnet" },
|
|
2183
|
+
{ chain: morph, networkType: "mainnet" },
|
|
2184
|
+
{ chain: bob, networkType: "mainnet" },
|
|
2185
|
+
{ chain: abstract, networkType: "mainnet" },
|
|
2186
|
+
{ chain: hemi, networkType: "mainnet" },
|
|
2187
|
+
{ chain: xLayer, networkType: "mainnet" },
|
|
2188
|
+
{ chain: cronos, networkType: "mainnet" },
|
|
2189
|
+
{ chain: gravity, networkType: "mainnet" },
|
|
2190
|
+
{ chain: manta, networkType: "mainnet" },
|
|
2191
|
+
{ chain: zircuit, networkType: "mainnet" },
|
|
2192
|
+
{ chain: berachain, networkType: "mainnet" },
|
|
2193
|
+
{ chain: plumeMainnet, networkType: "mainnet" },
|
|
2194
|
+
{ chain: plume, networkType: "mainnet" },
|
|
2195
|
+
{ chain: hashkey, networkType: "mainnet" },
|
|
2196
|
+
{ chain: flowMainnet, networkType: "mainnet" },
|
|
2197
|
+
{ chain: etherlink, networkType: "mainnet" },
|
|
2198
|
+
{ chain: ronin, networkType: "mainnet" },
|
|
2199
|
+
{ chain: flare, networkType: "mainnet" },
|
|
2200
|
+
{ chain: rootstock, networkType: "mainnet" },
|
|
2201
|
+
{ chain: iota, networkType: "mainnet" },
|
|
2202
|
+
{ chain: pulsechain, networkType: "mainnet" },
|
|
2203
|
+
// custom chains
|
|
2204
|
+
{ chain: katana2, networkType: "mainnet" },
|
|
2205
|
+
{ chain: hyperevm2, networkType: "mainnet" },
|
|
2206
|
+
{ chain: plasma2, networkType: "mainnet" },
|
|
2207
|
+
{ chain: rari2, networkType: "mainnet" },
|
|
2208
|
+
{ chain: stable2, networkType: "mainnet" },
|
|
2209
|
+
{ chain: monad2, networkType: "mainnet" },
|
|
2210
|
+
{ chain: mainnet3, networkType: "mainnet" },
|
|
2211
|
+
{ chain: metis2, networkType: "mainnet" },
|
|
2212
|
+
{ chain: polygonZkEvm2, networkType: "mainnet" },
|
|
2213
|
+
{ chain: megaeth2, networkType: "mainnet" },
|
|
2214
|
+
// testnet
|
|
2215
|
+
{ chain: sepolia, networkType: "testnet" },
|
|
2216
|
+
{ chain: arbitrumSepolia, networkType: "testnet" },
|
|
2217
|
+
{ chain: optimismSepolia, networkType: "testnet" },
|
|
2218
|
+
{ chain: baseSepolia, networkType: "testnet" },
|
|
2219
|
+
{ chain: unichainSepolia, networkType: "testnet" }
|
|
2220
|
+
];
|
|
2221
|
+
var testnetIdMapMainnetId = {
|
|
2222
|
+
[sepolia.id]: mainnet.id,
|
|
2223
|
+
[arbitrumSepolia.id]: arbitrum.id,
|
|
2224
|
+
[optimismSepolia.id]: optimism.id,
|
|
2225
|
+
[baseSepolia.id]: base$1.id,
|
|
2226
|
+
[unichainSepolia.id]: unichain.id
|
|
2227
|
+
};
|
|
2228
|
+
var chainsInfo = allChains.reduce(
|
|
2229
|
+
(acc, { chain }) => {
|
|
2230
|
+
acc[chain.id] = {
|
|
2231
|
+
name: chain.name ?? `Chain ${chain.id}`,
|
|
2232
|
+
id: chain.id,
|
|
2233
|
+
icon: chain.testnet ? `https://wheelx.fi/images/networks/${testnetIdMapMainnetId[chain.id] || chain.id}.png` : `https://wheelx.fi/images/networks/${chain.id}.png`,
|
|
2234
|
+
explorer: chain.blockExplorers?.default?.url,
|
|
2235
|
+
rpc: chain.rpcUrls?.default?.http?.[0] ?? ""
|
|
2236
|
+
};
|
|
2237
|
+
return acc;
|
|
2238
|
+
},
|
|
2239
|
+
{}
|
|
2240
|
+
);
|
|
2241
|
+
var defaultRpc = allChains.reduce(
|
|
2242
|
+
(acc, { chain }) => {
|
|
2243
|
+
acc[chain.id] = chain.rpcUrls?.default?.http?.[0] ?? "";
|
|
2244
|
+
return acc;
|
|
2245
|
+
},
|
|
2246
|
+
{}
|
|
2247
|
+
);
|
|
2248
|
+
|
|
2249
|
+
// src/core/hooks/useTokenBalance.ts
|
|
1595
2250
|
var FRONTEND_MAX_RETRY_COUNT = 3;
|
|
1596
2251
|
var REQUEST_TIMEOUT = 4e3;
|
|
1597
2252
|
var BALANCE_REFETCH_INTERVAL = 12e3;
|
|
1598
2253
|
var chainRpcMode = /* @__PURE__ */ new Map();
|
|
1599
|
-
var defaultRpc = {};
|
|
1600
2254
|
var getBalanceByClient = async (client, address, tokenAddress) => {
|
|
1601
2255
|
if (tokenAddress) {
|
|
1602
2256
|
const [value2, decimals, symbol] = await Promise.all([
|
|
@@ -1722,9 +2376,10 @@ var selectSolanaConnection = (providers) => {
|
|
|
1722
2376
|
defaultProvider: solanaProviders?.[0]?.provider ?? null
|
|
1723
2377
|
};
|
|
1724
2378
|
};
|
|
1725
|
-
var useSolanaTokenBalance = (tokenMintAddress, isEnabled = true) => {
|
|
2379
|
+
var useSolanaTokenBalance = (tokenMintAddress, isEnabled = true, ownerAddress) => {
|
|
1726
2380
|
const { solanaWalletAddress } = useWalletConnectedStore();
|
|
1727
2381
|
const { defaultProvider: connection } = useRpcProviders(selectSolanaConnection);
|
|
2382
|
+
const resolvedOwnerAddress = ownerAddress || solanaWalletAddress;
|
|
1728
2383
|
const normalizedTokenMint = normalizeAddress(tokenMintAddress);
|
|
1729
2384
|
const isSolToken = !tokenMintAddress || normalizedTokenMint === normalizeAddress(SOL_MINT_ADDRESS) || normalizedTokenMint === normalizeAddress(SOL_NATIVE_ADDRESS);
|
|
1730
2385
|
const {
|
|
@@ -1734,7 +2389,7 @@ var useSolanaTokenBalance = (tokenMintAddress, isEnabled = true) => {
|
|
|
1734
2389
|
error,
|
|
1735
2390
|
fetchAccountBalances
|
|
1736
2391
|
} = useTokenBalances({
|
|
1737
|
-
accountAddress:
|
|
2392
|
+
accountAddress: resolvedOwnerAddress || void 0,
|
|
1738
2393
|
chainName: ChainEnum.Sol,
|
|
1739
2394
|
networkId: SOLANA_MAINNET_NETWORK_ID,
|
|
1740
2395
|
includeNativeBalance: true,
|
|
@@ -1748,7 +2403,7 @@ var useSolanaTokenBalance = (tokenMintAddress, isEnabled = true) => {
|
|
|
1748
2403
|
useEffect(() => {
|
|
1749
2404
|
let cancelled = false;
|
|
1750
2405
|
const fetchByRpc = async () => {
|
|
1751
|
-
if (!isEnabled || !
|
|
2406
|
+
if (!isEnabled || !resolvedOwnerAddress || !connection) {
|
|
1752
2407
|
setRpcData(null);
|
|
1753
2408
|
setRpcError(null);
|
|
1754
2409
|
setRpcLoading(false);
|
|
@@ -1757,7 +2412,7 @@ var useSolanaTokenBalance = (tokenMintAddress, isEnabled = true) => {
|
|
|
1757
2412
|
setRpcLoading(true);
|
|
1758
2413
|
setRpcError(null);
|
|
1759
2414
|
try {
|
|
1760
|
-
const owner = new PublicKey(
|
|
2415
|
+
const owner = new PublicKey(resolvedOwnerAddress);
|
|
1761
2416
|
if (isSolToken) {
|
|
1762
2417
|
const lamports = await connection.getBalance(owner);
|
|
1763
2418
|
if (cancelled) return;
|
|
@@ -1806,9 +2461,9 @@ var useSolanaTokenBalance = (tokenMintAddress, isEnabled = true) => {
|
|
|
1806
2461
|
return () => {
|
|
1807
2462
|
cancelled = true;
|
|
1808
2463
|
};
|
|
1809
|
-
}, [connection, isEnabled, isSolToken,
|
|
2464
|
+
}, [connection, isEnabled, isSolToken, resolvedOwnerAddress, tokenMintAddress]);
|
|
1810
2465
|
const dynamicData = useMemo(() => {
|
|
1811
|
-
if (!isEnabled || !
|
|
2466
|
+
if (!isEnabled || !resolvedOwnerAddress) return null;
|
|
1812
2467
|
if (isSolToken) {
|
|
1813
2468
|
const native = tokenBalances.find((item) => item.isNative);
|
|
1814
2469
|
if (!native) {
|
|
@@ -1843,12 +2498,12 @@ var useSolanaTokenBalance = (tokenMintAddress, isEnabled = true) => {
|
|
|
1843
2498
|
formatted: String(targetToken.balance ?? 0),
|
|
1844
2499
|
symbol: targetToken.symbol || ""
|
|
1845
2500
|
};
|
|
1846
|
-
}, [isEnabled, isSolToken, normalizedTokenMint,
|
|
2501
|
+
}, [isEnabled, isSolToken, normalizedTokenMint, resolvedOwnerAddress, tokenBalances]);
|
|
1847
2502
|
const data = useMemo(() => {
|
|
1848
|
-
if (!isEnabled || !
|
|
2503
|
+
if (!isEnabled || !resolvedOwnerAddress) return null;
|
|
1849
2504
|
if (rpcData) return rpcData;
|
|
1850
2505
|
return dynamicData;
|
|
1851
|
-
}, [dynamicData, isEnabled, rpcData,
|
|
2506
|
+
}, [dynamicData, isEnabled, rpcData, resolvedOwnerAddress]);
|
|
1852
2507
|
return {
|
|
1853
2508
|
data,
|
|
1854
2509
|
isLoading: isLoading || rpcLoading,
|
|
@@ -2487,24 +3142,29 @@ function useRetryAbleTransactionReceipt(hash, chain_id, maxRetries = 6) {
|
|
|
2487
3142
|
lastError
|
|
2488
3143
|
};
|
|
2489
3144
|
}
|
|
2490
|
-
|
|
2491
|
-
// src/core/utils/consts.ts
|
|
2492
3145
|
var nullAddress = "0x0000000000000000000000000000000000000000";
|
|
3146
|
+
var hyperliquidChainId = 998;
|
|
2493
3147
|
var ETH_TO_ETH_BRIDGE_SLIPPAGE = 0;
|
|
2494
3148
|
var ETH_TO_ETH_BRIDGE_REFRESH_INTERVAL = 15;
|
|
2495
|
-
|
|
2496
|
-
if (!chains) return false;
|
|
2497
|
-
|
|
2498
|
-
const
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
const
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
3149
|
+
function isETHtoETHBridge(fromTokenInfo, toTokenInfo, chains) {
|
|
3150
|
+
if (!fromTokenInfo || !toTokenInfo || !chains) return false;
|
|
3151
|
+
if (fromTokenInfo.chain_id === toTokenInfo.chain_id) return false;
|
|
3152
|
+
const fromChain = chains.find(
|
|
3153
|
+
(c) => c.chain_id === fromTokenInfo.chain_id
|
|
3154
|
+
);
|
|
3155
|
+
const toChain = chains.find(
|
|
3156
|
+
(c) => c.chain_id === toTokenInfo.chain_id
|
|
3157
|
+
);
|
|
3158
|
+
const fromIsETH = fromTokenInfo.address === fromChain?.eth_token || fromTokenInfo.tags?.includes("native");
|
|
3159
|
+
const toIsETH = toTokenInfo.address === toChain?.eth_token || toTokenInfo.tags?.includes("native");
|
|
3160
|
+
return fromIsETH && toIsETH;
|
|
3161
|
+
}
|
|
2505
3162
|
var STABLECOIN_SAME_CHAIN_SLIPPAGE = 10;
|
|
2506
3163
|
var STABLECOIN_CROSS_CHAIN_SLIPPAGE = 50;
|
|
2507
3164
|
var STABLECOIN_REFRESH_INTERVAL = 30;
|
|
3165
|
+
var STABLECOIN_SAME_CHAIN_WARN_SLIPPAGE = 5;
|
|
3166
|
+
var STABLECOIN_CROSS_CHAIN_WARN_SLIPPAGE = 20;
|
|
3167
|
+
var HIGH_SLIPPAGE_WARN_THRESHOLD = 300;
|
|
2508
3168
|
function isStablecoin(tokenInfo) {
|
|
2509
3169
|
if (!tokenInfo?.categories) return false;
|
|
2510
3170
|
return tokenInfo.categories.includes("stablecoin");
|
|
@@ -2534,7 +3194,26 @@ function getDefaultSlippage(policy, isBridge, isSameChain) {
|
|
|
2534
3194
|
if (isBridge) return 200;
|
|
2535
3195
|
return 0;
|
|
2536
3196
|
}
|
|
2537
|
-
|
|
3197
|
+
function getLowSlippageWarnThreshold(fromTokenInfo, toTokenInfo, matchedPolicy, isETHtoETH = false) {
|
|
3198
|
+
if (!fromTokenInfo || !toTokenInfo) return 0;
|
|
3199
|
+
if (isETHtoETH) return 0;
|
|
3200
|
+
const isSameChain = fromTokenInfo.chain_id === toTokenInfo.chain_id;
|
|
3201
|
+
const isBridge = !isSameChain;
|
|
3202
|
+
if (isStablecoin(fromTokenInfo) && isStablecoin(toTokenInfo)) {
|
|
3203
|
+
return isBridge ? STABLECOIN_CROSS_CHAIN_WARN_SLIPPAGE : STABLECOIN_SAME_CHAIN_WARN_SLIPPAGE;
|
|
3204
|
+
}
|
|
3205
|
+
if (matchedPolicy?.min_slippage !== void 0) {
|
|
3206
|
+
return matchedPolicy.min_slippage;
|
|
3207
|
+
}
|
|
3208
|
+
return 0;
|
|
3209
|
+
}
|
|
3210
|
+
function isNativeToken(tokenInfo) {
|
|
3211
|
+
if (!tokenInfo) return false;
|
|
3212
|
+
if (isSolanaChain2(tokenInfo.chain_id)) {
|
|
3213
|
+
return tokenInfo.symbol?.toUpperCase() === "SOL" || String(tokenInfo.address) === "11111111111111111111111111111111";
|
|
3214
|
+
}
|
|
3215
|
+
return tokenInfo.address === zeroAddress || tokenInfo.tags?.includes("native");
|
|
3216
|
+
}
|
|
2538
3217
|
var calculateSlippage = (slippage) => {
|
|
2539
3218
|
if (!slippage) return;
|
|
2540
3219
|
const slippageFraction = new Fraction(slippage);
|
|
@@ -2546,31 +3225,86 @@ var formatSlippage = (slippage) => {
|
|
|
2546
3225
|
};
|
|
2547
3226
|
|
|
2548
3227
|
// src/core/utils/debounce.ts
|
|
2549
|
-
function debounce2(func,
|
|
2550
|
-
let
|
|
3228
|
+
function debounce2(func, delay) {
|
|
3229
|
+
let timeoutId = null;
|
|
2551
3230
|
return (...args) => {
|
|
2552
|
-
if (
|
|
2553
|
-
|
|
3231
|
+
if (timeoutId) {
|
|
3232
|
+
clearTimeout(timeoutId);
|
|
3233
|
+
}
|
|
3234
|
+
timeoutId = setTimeout(() => {
|
|
2554
3235
|
func(...args);
|
|
2555
|
-
|
|
3236
|
+
timeoutId = null;
|
|
3237
|
+
}, delay);
|
|
2556
3238
|
};
|
|
2557
3239
|
}
|
|
2558
3240
|
|
|
2559
3241
|
// src/core/utils/defaultData.ts
|
|
2560
3242
|
var saveDay = [
|
|
2561
|
-
{
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
{
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
{
|
|
2572
|
-
|
|
2573
|
-
|
|
3243
|
+
{
|
|
3244
|
+
name: "Blast",
|
|
3245
|
+
chainId: 81457,
|
|
3246
|
+
day: 8
|
|
3247
|
+
},
|
|
3248
|
+
{
|
|
3249
|
+
name: "Bob",
|
|
3250
|
+
chainId: 60808,
|
|
3251
|
+
day: 5
|
|
3252
|
+
},
|
|
3253
|
+
{
|
|
3254
|
+
name: "Celo",
|
|
3255
|
+
chainId: 42220,
|
|
3256
|
+
day: 7
|
|
3257
|
+
},
|
|
3258
|
+
{
|
|
3259
|
+
name: "Gravity",
|
|
3260
|
+
chainId: 1625,
|
|
3261
|
+
day: 7
|
|
3262
|
+
},
|
|
3263
|
+
{
|
|
3264
|
+
name: "Hashkey Chain",
|
|
3265
|
+
chainId: 177,
|
|
3266
|
+
day: 7
|
|
3267
|
+
},
|
|
3268
|
+
{
|
|
3269
|
+
name: "Ink",
|
|
3270
|
+
chainId: 57073,
|
|
3271
|
+
day: 7
|
|
3272
|
+
},
|
|
3273
|
+
{
|
|
3274
|
+
name: "Lisk",
|
|
3275
|
+
chainId: 1135,
|
|
3276
|
+
day: 7
|
|
3277
|
+
},
|
|
3278
|
+
{
|
|
3279
|
+
name: "Mode",
|
|
3280
|
+
chainId: 34443,
|
|
3281
|
+
day: 7
|
|
3282
|
+
},
|
|
3283
|
+
{
|
|
3284
|
+
name: "opBNB",
|
|
3285
|
+
chainId: 204,
|
|
3286
|
+
day: 7
|
|
3287
|
+
},
|
|
3288
|
+
{
|
|
3289
|
+
name: "RARI",
|
|
3290
|
+
chainId: 1380012617,
|
|
3291
|
+
day: 8
|
|
3292
|
+
},
|
|
3293
|
+
{
|
|
3294
|
+
name: "Unichain",
|
|
3295
|
+
chainId: 130,
|
|
3296
|
+
day: 7
|
|
3297
|
+
},
|
|
3298
|
+
{
|
|
3299
|
+
name: "Worldchain",
|
|
3300
|
+
chainId: 480,
|
|
3301
|
+
day: 7
|
|
3302
|
+
},
|
|
3303
|
+
{
|
|
3304
|
+
name: "Zora",
|
|
3305
|
+
chainId: 7777777,
|
|
3306
|
+
day: 7
|
|
3307
|
+
}
|
|
2574
3308
|
];
|
|
2575
3309
|
|
|
2576
3310
|
// ../../node_modules/@wagmi/core/dist/esm/utils/getAction.js
|
|
@@ -2900,29 +3634,6 @@ var getErc20Approval = (config) => {
|
|
|
2900
3634
|
};
|
|
2901
3635
|
|
|
2902
3636
|
// src/core/utils/index.ts
|
|
2903
|
-
var getOrderedTokensChainSearch = (tokens) => tokens;
|
|
2904
|
-
var getOrderedTokensAssets = (tokens) => tokens;
|
|
2905
|
-
var mergeAndDeduplicate = (a, b, key = "") => [...a, ...b];
|
|
2906
|
-
var STABLECOIN_SAME_CHAIN_WARN_SLIPPAGE = 5;
|
|
2907
|
-
var STABLECOIN_CROSS_CHAIN_WARN_SLIPPAGE = 20;
|
|
2908
|
-
var HIGH_SLIPPAGE_WARN_THRESHOLD = 300;
|
|
2909
|
-
function isStablecoin2(tokenInfo) {
|
|
2910
|
-
if (!tokenInfo?.categories) return false;
|
|
2911
|
-
return tokenInfo.categories.includes("stablecoin");
|
|
2912
|
-
}
|
|
2913
|
-
function getLowSlippageWarnThreshold(fromTokenInfo, toTokenInfo, matchedPolicy, isETHtoETH = false) {
|
|
2914
|
-
if (!fromTokenInfo || !toTokenInfo) return 0;
|
|
2915
|
-
if (isETHtoETH) return 0;
|
|
2916
|
-
const isSameChain = fromTokenInfo.chain_id === toTokenInfo.chain_id;
|
|
2917
|
-
const isBridge = !isSameChain;
|
|
2918
|
-
if (isStablecoin2(fromTokenInfo) && isStablecoin2(toTokenInfo)) {
|
|
2919
|
-
return isBridge ? STABLECOIN_CROSS_CHAIN_WARN_SLIPPAGE : STABLECOIN_SAME_CHAIN_WARN_SLIPPAGE;
|
|
2920
|
-
}
|
|
2921
|
-
if (matchedPolicy?.min_slippage !== void 0) {
|
|
2922
|
-
return matchedPolicy.min_slippage;
|
|
2923
|
-
}
|
|
2924
|
-
return 0;
|
|
2925
|
-
}
|
|
2926
3637
|
var formatDecimalNum = (val, fixed = 6) => {
|
|
2927
3638
|
if (val === void 0 || val === null || val === "") return "";
|
|
2928
3639
|
const num = Number(val);
|
|
@@ -3405,7 +4116,47 @@ var BoxWithBg = ({
|
|
|
3405
4116
|
}) => {
|
|
3406
4117
|
return /* @__PURE__ */ jsx(Box, { w: "100%", bg: "#F5F6FF", borderRadius: "16px", p: 3, ...props, children });
|
|
3407
4118
|
};
|
|
3408
|
-
var OptimizedImage = (
|
|
4119
|
+
var OptimizedImage = forwardRef(
|
|
4120
|
+
({
|
|
4121
|
+
src,
|
|
4122
|
+
alt,
|
|
4123
|
+
width,
|
|
4124
|
+
height,
|
|
4125
|
+
fill = false,
|
|
4126
|
+
objectFit = "cover",
|
|
4127
|
+
w,
|
|
4128
|
+
h,
|
|
4129
|
+
...props
|
|
4130
|
+
}, ref) => {
|
|
4131
|
+
const boxWidth = w ?? width;
|
|
4132
|
+
const boxHeight = h ?? height;
|
|
4133
|
+
const isPercentWidth = typeof boxWidth === "string" && boxWidth.endsWith("%");
|
|
4134
|
+
const shouldUseFill = fill || isPercentWidth;
|
|
4135
|
+
return /* @__PURE__ */ jsx(
|
|
4136
|
+
Box,
|
|
4137
|
+
{
|
|
4138
|
+
ref,
|
|
4139
|
+
position: shouldUseFill ? "relative" : "static",
|
|
4140
|
+
overflow: "hidden",
|
|
4141
|
+
w,
|
|
4142
|
+
h,
|
|
4143
|
+
...props,
|
|
4144
|
+
children: /* @__PURE__ */ jsx(
|
|
4145
|
+
Image,
|
|
4146
|
+
{
|
|
4147
|
+
src,
|
|
4148
|
+
alt,
|
|
4149
|
+
width: shouldUseFill ? "100%" : boxWidth,
|
|
4150
|
+
height: shouldUseFill ? "100%" : boxHeight,
|
|
4151
|
+
objectFit,
|
|
4152
|
+
loading: "lazy"
|
|
4153
|
+
}
|
|
4154
|
+
)
|
|
4155
|
+
}
|
|
4156
|
+
);
|
|
4157
|
+
}
|
|
4158
|
+
);
|
|
4159
|
+
OptimizedImage.displayName = "OptimizedImage";
|
|
3409
4160
|
|
|
3410
4161
|
// src/core/utils/twoApprove.ts
|
|
3411
4162
|
var useUSDTHandler = () => {
|
|
@@ -3447,7 +4198,9 @@ var FormButton = ({
|
|
|
3447
4198
|
clearLockedRequestId,
|
|
3448
4199
|
lockedRequestId,
|
|
3449
4200
|
getQuote,
|
|
3450
|
-
currentRequestId
|
|
4201
|
+
currentRequestId,
|
|
4202
|
+
skipEvmWalletConnect = false,
|
|
4203
|
+
skipSolanaWalletConnect = false
|
|
3451
4204
|
}) => {
|
|
3452
4205
|
const { theme } = useWidgetTheme();
|
|
3453
4206
|
const address = useEvmAddress();
|
|
@@ -3667,11 +4420,19 @@ var FormButton = ({
|
|
|
3667
4420
|
console.log("[Transaction] Connectors empty but wallet detected, triggering Dynamic reconnect...");
|
|
3668
4421
|
openModal();
|
|
3669
4422
|
setUserCancelsTransaction(true);
|
|
4423
|
+
toaster.create({
|
|
4424
|
+
description: "Please reconnect your EVM wallet and try again",
|
|
4425
|
+
type: "info"
|
|
4426
|
+
});
|
|
3670
4427
|
return;
|
|
3671
4428
|
}
|
|
3672
4429
|
if (!txOwner || !txConnector) {
|
|
3673
4430
|
setUserCancelsTransaction(true);
|
|
3674
4431
|
openConnectModal();
|
|
4432
|
+
toaster.create({
|
|
4433
|
+
description: "Please reconnect EVM wallet and try again",
|
|
4434
|
+
type: "error"
|
|
4435
|
+
});
|
|
3675
4436
|
return;
|
|
3676
4437
|
}
|
|
3677
4438
|
try {
|
|
@@ -3932,6 +4693,10 @@ var FormButton = ({
|
|
|
3932
4693
|
const handleSolanaSwap = async () => {
|
|
3933
4694
|
if (!isSolanaWalletConnected || !solanaWalletAddress) {
|
|
3934
4695
|
setUserCancelsTransaction(true);
|
|
4696
|
+
toaster.create({
|
|
4697
|
+
description: "Please reconnect Solana wallet and try again",
|
|
4698
|
+
type: "error"
|
|
4699
|
+
});
|
|
3935
4700
|
openModal();
|
|
3936
4701
|
return;
|
|
3937
4702
|
}
|
|
@@ -4014,7 +4779,7 @@ var FormButton = ({
|
|
|
4014
4779
|
}
|
|
4015
4780
|
) });
|
|
4016
4781
|
}
|
|
4017
|
-
if ((fromTokenInfo.isSolana || toTokenInfo.isSolana) && !solanaWalletAddress) {
|
|
4782
|
+
if ((fromTokenInfo.isSolana || toTokenInfo.isSolana) && !solanaWalletAddress && !(skipSolanaWalletConnect && !fromTokenInfo.isSolana)) {
|
|
4018
4783
|
return renderSolanaWalletConnectButton();
|
|
4019
4784
|
}
|
|
4020
4785
|
if (!fromTokenInfo.isSolana && !hasEvmUiWallet) {
|
|
@@ -4026,14 +4791,14 @@ var FormButton = ({
|
|
|
4026
4791
|
}
|
|
4027
4792
|
return renderEvmWalletConnectButton();
|
|
4028
4793
|
} else if (!hasEvmUiWallet && solanaWalletAddress) {
|
|
4029
|
-
if (!fromTokenInfo.isSolana && !toTokenInfo.isSolana || !fromTokenInfo.isSolana && toTokenInfo.isSolana || fromTokenInfo.isSolana && !toTokenInfo.isSolana) {
|
|
4794
|
+
if (!fromTokenInfo.isSolana && !toTokenInfo.isSolana || !fromTokenInfo.isSolana && toTokenInfo.isSolana || fromTokenInfo.isSolana && !toTokenInfo.isSolana && !skipEvmWalletConnect) {
|
|
4030
4795
|
return renderEvmWalletConnectButton("EVM");
|
|
4031
4796
|
}
|
|
4032
4797
|
} else if (hasEvmUiWallet && !solanaWalletAddress) {
|
|
4033
|
-
if (fromTokenInfo.isSolana || toTokenInfo.isSolana) {
|
|
4798
|
+
if (fromTokenInfo.isSolana || toTokenInfo.isSolana && !skipSolanaWalletConnect) {
|
|
4034
4799
|
return renderSolanaWalletConnectButton();
|
|
4035
4800
|
}
|
|
4036
|
-
if (fromTokenInfo.isSolana && toTokenInfo.isSolana || !fromTokenInfo.isSolana && toTokenInfo.isSolana || fromTokenInfo.isSolana && !toTokenInfo.isSolana) {
|
|
4801
|
+
if (fromTokenInfo.isSolana && toTokenInfo.isSolana || !fromTokenInfo.isSolana && toTokenInfo.isSolana && !skipSolanaWalletConnect || fromTokenInfo.isSolana && !toTokenInfo.isSolana) {
|
|
4037
4802
|
return renderSolanaWalletConnectButton();
|
|
4038
4803
|
}
|
|
4039
4804
|
}
|
|
@@ -4147,9 +4912,10 @@ var FormButton = ({
|
|
|
4147
4912
|
)
|
|
4148
4913
|
] });
|
|
4149
4914
|
};
|
|
4150
|
-
function
|
|
4915
|
+
function getOrderedTokensAssets(tokens, selectedChain, propertyName) {
|
|
4151
4916
|
return tokens?.filter((token) => {
|
|
4152
|
-
return true;
|
|
4917
|
+
if (!selectedChain) return true;
|
|
4918
|
+
return token.chain_id === selectedChain;
|
|
4153
4919
|
}).sort((a, b) => {
|
|
4154
4920
|
if (a.usdPrice === null && b.usdPrice === null) {
|
|
4155
4921
|
if (a.balance && b.balance) {
|
|
@@ -4251,6 +5017,48 @@ function getOrderedTokensChainNormal(tokens, selectedChain, propertyName) {
|
|
|
4251
5017
|
return 0;
|
|
4252
5018
|
});
|
|
4253
5019
|
}
|
|
5020
|
+
function getOrderedTokensChainSearch(tokens, selectedChain) {
|
|
5021
|
+
return tokens?.filter((token) => {
|
|
5022
|
+
if (!selectedChain) return true;
|
|
5023
|
+
return token.chain_id === selectedChain;
|
|
5024
|
+
}).sort((a, b) => {
|
|
5025
|
+
if (a.usdPrice && b.usdPrice && a.balance && b.balance) {
|
|
5026
|
+
if (a.balance === "NaN" && b.balance !== "NaN") {
|
|
5027
|
+
return -1;
|
|
5028
|
+
}
|
|
5029
|
+
if (a.balance !== "NaN" && b.balance === "NaN") {
|
|
5030
|
+
return 1;
|
|
5031
|
+
}
|
|
5032
|
+
if (a.balance === "NaN" && b.balance === "NaN") {
|
|
5033
|
+
return 0;
|
|
5034
|
+
}
|
|
5035
|
+
const aBalance = new Fraction(a.usdPrice).mul(a.balance);
|
|
5036
|
+
const bBalance = new Fraction(b.usdPrice).mul(b.balance);
|
|
5037
|
+
if (aBalance.gt(bBalance)) return -1;
|
|
5038
|
+
if (aBalance.lt(bBalance)) return 1;
|
|
5039
|
+
}
|
|
5040
|
+
if (a.balance && b.balance) {
|
|
5041
|
+
if (a.balance === "NaN" && b.balance !== "NaN") {
|
|
5042
|
+
return -1;
|
|
5043
|
+
}
|
|
5044
|
+
if (a.balance !== "NaN" && b.balance === "NaN") {
|
|
5045
|
+
return 1;
|
|
5046
|
+
}
|
|
5047
|
+
if (a.balance === "NaN" && b.balance === "NaN") {
|
|
5048
|
+
return 0;
|
|
5049
|
+
}
|
|
5050
|
+
if (new Fraction(a.balance).gt(new Fraction(b.balance))) return -1;
|
|
5051
|
+
if (new Fraction(a.balance).lt(new Fraction(b.balance))) return 1;
|
|
5052
|
+
}
|
|
5053
|
+
if (a.balance && !b.balance) return -1;
|
|
5054
|
+
if (!a.balance && b.balance) return 1;
|
|
5055
|
+
const aIsDin = a.token_type === "preset";
|
|
5056
|
+
const bIsDin = b.token_type === "preset";
|
|
5057
|
+
if (aIsDin && !bIsDin) return -1;
|
|
5058
|
+
if (!aIsDin && bIsDin) return 1;
|
|
5059
|
+
return 0;
|
|
5060
|
+
});
|
|
5061
|
+
}
|
|
4254
5062
|
function processChains(favorites, allNetworks) {
|
|
4255
5063
|
const favoriteNetworkIds = new Set(favorites.map((fav) => fav.networkId));
|
|
4256
5064
|
const favoriteChains = allNetworks.filter(
|
|
@@ -4261,6 +5069,28 @@ function processChains(favorites, allNetworks) {
|
|
|
4261
5069
|
);
|
|
4262
5070
|
return { favoriteChains, nonFavoriteChains };
|
|
4263
5071
|
}
|
|
5072
|
+
function mergeAndDeduplicate(arr1, arr2) {
|
|
5073
|
+
const mergedArray = [...arr1, ...arr2];
|
|
5074
|
+
const map = /* @__PURE__ */ new Map();
|
|
5075
|
+
for (const item of mergedArray) {
|
|
5076
|
+
const key = `${item.address}-${item.chain_id}`;
|
|
5077
|
+
if (!map.has(key)) {
|
|
5078
|
+
map.set(key, item);
|
|
5079
|
+
} else {
|
|
5080
|
+
const existingItem = map.get(key);
|
|
5081
|
+
const existingHasPreset = existingItem.token_type === "preset";
|
|
5082
|
+
const currentHasPreset = item.token_type === "preset";
|
|
5083
|
+
if (existingHasPreset && !currentHasPreset) {
|
|
5084
|
+
continue;
|
|
5085
|
+
} else if (!existingHasPreset && currentHasPreset) {
|
|
5086
|
+
map.set(key, item);
|
|
5087
|
+
} else {
|
|
5088
|
+
continue;
|
|
5089
|
+
}
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
return Array.from(map.values());
|
|
5093
|
+
}
|
|
4264
5094
|
function filterTokenByType(items, searchString) {
|
|
4265
5095
|
return items.filter((item) => item.categories?.includes(searchString));
|
|
4266
5096
|
}
|
|
@@ -4272,17 +5102,8 @@ function filterTokenUnType(items, excludeTypes) {
|
|
|
4272
5102
|
});
|
|
4273
5103
|
}
|
|
4274
5104
|
|
|
4275
|
-
// src/consts/mainnet.ts
|
|
4276
|
-
var mainnet3 = { id: 1 };
|
|
4277
|
-
|
|
4278
|
-
// src/consts/monad.ts
|
|
4279
|
-
var monad2 = { id: 10143 };
|
|
4280
|
-
|
|
4281
|
-
// src/consts/stable.ts
|
|
4282
|
-
var stable2 = { id: 1 };
|
|
4283
|
-
|
|
4284
5105
|
// src/core/SelectTokenModal/hooks/useChainsAndTokensForSelect.ts
|
|
4285
|
-
[mainnet3.id, base.id, ink.id, bsc.id, monad2.id, soneium.id, stable2.id];
|
|
5106
|
+
[mainnet3.id, base.id, ink$1.id, bsc$1.id, monad2.id, soneium.id, stable2.id];
|
|
4286
5107
|
var useChainsAndTokensForSelect = ({
|
|
4287
5108
|
data,
|
|
4288
5109
|
selectedChain,
|
|
@@ -4298,7 +5119,7 @@ var useChainsAndTokensForSelect = ({
|
|
|
4298
5119
|
],
|
|
4299
5120
|
[data?.chains, data?.deposit_platforms?.prediction?.chains]
|
|
4300
5121
|
);
|
|
4301
|
-
const
|
|
5122
|
+
const allChains2 = useMemo(() => {
|
|
4302
5123
|
if (!allowedChainIds || allowedChainIds.length === 0) return rawChains;
|
|
4303
5124
|
const allowedSet = new Set(allowedChainIds);
|
|
4304
5125
|
return rawChains.filter((c) => allowedSet.has(c.chain_id));
|
|
@@ -4327,39 +5148,39 @@ var useChainsAndTokensForSelect = ({
|
|
|
4327
5148
|
setSearchTokensValue("");
|
|
4328
5149
|
}, []);
|
|
4329
5150
|
const popularChains = useMemo(
|
|
4330
|
-
() => (
|
|
5151
|
+
() => (allChains2 ?? []).filter((chain) => chain.is_popular === true).sort((a, b) => {
|
|
4331
5152
|
const nameA = a.name.toLowerCase();
|
|
4332
5153
|
const nameB = b.name.toLowerCase();
|
|
4333
5154
|
if (nameA < nameB) return -1;
|
|
4334
5155
|
if (nameA > nameB) return 1;
|
|
4335
5156
|
return 0;
|
|
4336
5157
|
}),
|
|
4337
|
-
[
|
|
5158
|
+
[allChains2]
|
|
4338
5159
|
);
|
|
4339
5160
|
const currentChain = useMemo(() => {
|
|
4340
5161
|
if (selectedChainByPlatformId) {
|
|
4341
|
-
return
|
|
5162
|
+
return allChains2?.find(
|
|
4342
5163
|
(chain) => chain.platform_id === selectedChainByPlatformId
|
|
4343
5164
|
);
|
|
4344
5165
|
} else {
|
|
4345
|
-
return
|
|
5166
|
+
return allChains2?.find((chain) => chain.chain_id === selectedChain);
|
|
4346
5167
|
}
|
|
4347
|
-
}, [
|
|
5168
|
+
}, [allChains2, selectedChain]);
|
|
4348
5169
|
const searchChains = useMemo(() => {
|
|
4349
|
-
return
|
|
5170
|
+
return allChains2?.filter((chain) => {
|
|
4350
5171
|
if (searchChainsValue === "") return false;
|
|
4351
5172
|
return chain.name.toLowerCase().includes(searchChainsValue.toLowerCase()) || chain.chain_id.toString().includes(searchChainsValue.toLowerCase());
|
|
4352
5173
|
});
|
|
4353
|
-
}, [
|
|
5174
|
+
}, [allChains2, searchChainsValue]);
|
|
4354
5175
|
const orderedChains = useMemo(
|
|
4355
|
-
() =>
|
|
5176
|
+
() => allChains2?.filter((chain) => !chain.is_popular).sort((a, b) => {
|
|
4356
5177
|
const firstCharA = a.name.toLowerCase();
|
|
4357
5178
|
const firstCharB = b.name.toLowerCase();
|
|
4358
5179
|
if (firstCharA < firstCharB) return -1;
|
|
4359
5180
|
if (firstCharA > firstCharB) return 1;
|
|
4360
5181
|
return 0;
|
|
4361
5182
|
}),
|
|
4362
|
-
[
|
|
5183
|
+
[allChains2]
|
|
4363
5184
|
);
|
|
4364
5185
|
const tokensWithBalances = useMemo(() => {
|
|
4365
5186
|
if (!allTokens) return void 0;
|
|
@@ -4419,7 +5240,7 @@ var useChainsAndTokensForSelect = ({
|
|
|
4419
5240
|
handleSearchChains,
|
|
4420
5241
|
handleSearchTokens,
|
|
4421
5242
|
resetSearch,
|
|
4422
|
-
allChains
|
|
5243
|
+
allChains: allChains2
|
|
4423
5244
|
};
|
|
4424
5245
|
};
|
|
4425
5246
|
var useUserHasSelectedFromNetwork = create(
|
|
@@ -4465,15 +5286,15 @@ var useSearchTokens = ({
|
|
|
4465
5286
|
if (filteredTokens) {
|
|
4466
5287
|
const newArr = mergeAndDeduplicate(tokenWithBalances, filteredTokens);
|
|
4467
5288
|
if (!selectedChain) {
|
|
4468
|
-
return getOrderedTokensAssets(newArr);
|
|
5289
|
+
return getOrderedTokensAssets(newArr, selectedChain);
|
|
4469
5290
|
} else {
|
|
4470
|
-
return getOrderedTokensChainSearch(newArr);
|
|
5291
|
+
return getOrderedTokensChainSearch(newArr, selectedChain);
|
|
4471
5292
|
}
|
|
4472
5293
|
} else {
|
|
4473
5294
|
if (!selectedChain) {
|
|
4474
|
-
return getOrderedTokensAssets(tokenWithBalances);
|
|
5295
|
+
return getOrderedTokensAssets(tokenWithBalances, selectedChain);
|
|
4475
5296
|
} else {
|
|
4476
|
-
return getOrderedTokensChainSearch(tokenWithBalances);
|
|
5297
|
+
return getOrderedTokensChainSearch(tokenWithBalances, selectedChain);
|
|
4477
5298
|
}
|
|
4478
5299
|
}
|
|
4479
5300
|
} else {
|
|
@@ -4482,9 +5303,9 @@ var useSearchTokens = ({
|
|
|
4482
5303
|
return token.symbol.toLowerCase().includes(searchTokensValue.toLowerCase());
|
|
4483
5304
|
});
|
|
4484
5305
|
if (!selectedChain) {
|
|
4485
|
-
return getOrderedTokensAssets(filteredTokens);
|
|
5306
|
+
return getOrderedTokensAssets(filteredTokens, selectedChain);
|
|
4486
5307
|
} else {
|
|
4487
|
-
return getOrderedTokensChainSearch(filteredTokens);
|
|
5308
|
+
return getOrderedTokensChainSearch(filteredTokens, selectedChain);
|
|
4488
5309
|
}
|
|
4489
5310
|
}
|
|
4490
5311
|
}, [newAllToken, searchTokenInfoResult, searchTokensValue, selectedChain]);
|
|
@@ -4755,14 +5576,13 @@ var TokenAmountHeading = ({
|
|
|
4755
5576
|
suffix,
|
|
4756
5577
|
...props
|
|
4757
5578
|
}) => {
|
|
4758
|
-
const { theme } = useWidgetTheme();
|
|
4759
5579
|
const _amount = formatTokenAmount({
|
|
4760
5580
|
amount,
|
|
4761
5581
|
decimals
|
|
4762
5582
|
});
|
|
4763
5583
|
const leadingZeros = countLeadingZerosAfterDecimal(_amount);
|
|
4764
5584
|
if (leadingZeros > 5) {
|
|
4765
|
-
return /* @__PURE__ */ jsxs(Heading, { variant: "heading8", ...props, as: "div",
|
|
5585
|
+
return /* @__PURE__ */ jsxs(Heading, { variant: "heading8", ...props, as: "div", whiteSpace: "nowrap", children: [
|
|
4766
5586
|
prefix,
|
|
4767
5587
|
" ",
|
|
4768
5588
|
_amount.slice(0, 3),
|
|
@@ -4781,7 +5601,7 @@ var TokenAmountHeading = ({
|
|
|
4781
5601
|
suffix
|
|
4782
5602
|
] });
|
|
4783
5603
|
}
|
|
4784
|
-
return /* @__PURE__ */ jsxs(Heading, { variant: "heading11", ...props, as: "div",
|
|
5604
|
+
return /* @__PURE__ */ jsxs(Heading, { variant: "heading11", ...props, as: "div", whiteSpace: "nowrap", children: [
|
|
4785
5605
|
prefix,
|
|
4786
5606
|
" ",
|
|
4787
5607
|
_amount,
|
|
@@ -4802,7 +5622,7 @@ var TokenAmountText = ({
|
|
|
4802
5622
|
});
|
|
4803
5623
|
const leadingZeros = countLeadingZerosAfterDecimal(_amount);
|
|
4804
5624
|
if (leadingZeros > 5) {
|
|
4805
|
-
return /* @__PURE__ */ jsxs(Text2, { variant: "
|
|
5625
|
+
return /* @__PURE__ */ jsxs(Text2, { variant: "content7", ...props, as: "div", children: [
|
|
4806
5626
|
prefix,
|
|
4807
5627
|
" ",
|
|
4808
5628
|
_amount.slice(0, 3),
|
|
@@ -4821,7 +5641,7 @@ var TokenAmountText = ({
|
|
|
4821
5641
|
suffix
|
|
4822
5642
|
] });
|
|
4823
5643
|
}
|
|
4824
|
-
return /* @__PURE__ */ jsxs(Text2, { variant: "content7", ...props, children: [
|
|
5644
|
+
return /* @__PURE__ */ jsxs(Text2, { variant: "content7", ...props, as: "div", children: [
|
|
4825
5645
|
prefix,
|
|
4826
5646
|
" ",
|
|
4827
5647
|
_amount,
|
|
@@ -4829,7 +5649,6 @@ var TokenAmountText = ({
|
|
|
4829
5649
|
suffix
|
|
4830
5650
|
] });
|
|
4831
5651
|
};
|
|
4832
|
-
var chainsInfo = {};
|
|
4833
5652
|
var TokenIconWithNetworkLogo = ({
|
|
4834
5653
|
tokenInfo,
|
|
4835
5654
|
customChainLogo,
|
|
@@ -4877,7 +5696,7 @@ var TokenIconWithNetworkLogo = ({
|
|
|
4877
5696
|
w,
|
|
4878
5697
|
h,
|
|
4879
5698
|
borderRadius: "full",
|
|
4880
|
-
src: logo ||
|
|
5699
|
+
src: logo || `/images/default-token-icon.png`,
|
|
4881
5700
|
alt: name || "",
|
|
4882
5701
|
objectFit: "cover",
|
|
4883
5702
|
priority
|
|
@@ -5379,7 +6198,7 @@ var TokenList = ({
|
|
|
5379
6198
|
}
|
|
5380
6199
|
}
|
|
5381
6200
|
if (isSelectAll) {
|
|
5382
|
-
return
|
|
6201
|
+
return getOrderedTokensAssets(userTokens)?.map((token, index) => {
|
|
5383
6202
|
return /* @__PURE__ */ jsx(
|
|
5384
6203
|
TokenAndAddress,
|
|
5385
6204
|
{
|
|
@@ -5574,7 +6393,7 @@ var AllChainsIcon = () => {
|
|
|
5574
6393
|
/* @__PURE__ */ jsx(
|
|
5575
6394
|
Image,
|
|
5576
6395
|
{
|
|
5577
|
-
src: "
|
|
6396
|
+
src: "/images/networks/1.png",
|
|
5578
6397
|
alt: "ethereum",
|
|
5579
6398
|
w: "10px",
|
|
5580
6399
|
h: "10px",
|
|
@@ -5584,7 +6403,7 @@ var AllChainsIcon = () => {
|
|
|
5584
6403
|
/* @__PURE__ */ jsx(
|
|
5585
6404
|
Image,
|
|
5586
6405
|
{
|
|
5587
|
-
src: "
|
|
6406
|
+
src: "/images/networks/56.png",
|
|
5588
6407
|
alt: "bnb",
|
|
5589
6408
|
w: "10px",
|
|
5590
6409
|
h: "10px",
|
|
@@ -5596,7 +6415,7 @@ var AllChainsIcon = () => {
|
|
|
5596
6415
|
/* @__PURE__ */ jsx(
|
|
5597
6416
|
Image,
|
|
5598
6417
|
{
|
|
5599
|
-
src: "
|
|
6418
|
+
src: "/images/networks/8453.png",
|
|
5600
6419
|
alt: "base",
|
|
5601
6420
|
w: "10px",
|
|
5602
6421
|
h: "10px",
|
|
@@ -5606,7 +6425,7 @@ var AllChainsIcon = () => {
|
|
|
5606
6425
|
/* @__PURE__ */ jsx(
|
|
5607
6426
|
Image,
|
|
5608
6427
|
{
|
|
5609
|
-
src: "
|
|
6428
|
+
src: "/images/networks/42161.png",
|
|
5610
6429
|
alt: "arbitrum",
|
|
5611
6430
|
w: "10px",
|
|
5612
6431
|
h: "10px",
|
|
@@ -6313,7 +7132,7 @@ var SelectTokenModal = ({
|
|
|
6313
7132
|
handleSearchChains,
|
|
6314
7133
|
handleSearchTokens,
|
|
6315
7134
|
resetSearch,
|
|
6316
|
-
allChains
|
|
7135
|
+
allChains: allChains2
|
|
6317
7136
|
} = useChainsAndTokensForSelect({
|
|
6318
7137
|
data,
|
|
6319
7138
|
selectedChain,
|
|
@@ -6440,7 +7259,7 @@ var SelectTokenModal = ({
|
|
|
6440
7259
|
[handleClose, onSelectToken]
|
|
6441
7260
|
);
|
|
6442
7261
|
const [isMobileChainsOpen, setIsMobileChainsOpen] = useState(false);
|
|
6443
|
-
const selectedChainInfo =
|
|
7262
|
+
const selectedChainInfo = allChains2?.find((chain) => {
|
|
6444
7263
|
if (selectedChainByPlatformId) {
|
|
6445
7264
|
return chain.platform_id === selectedChainByPlatformId;
|
|
6446
7265
|
} else {
|
|
@@ -6678,7 +7497,8 @@ var TokenSelectAndInput = ({
|
|
|
6678
7497
|
totalGasFee,
|
|
6679
7498
|
isLoadingFeeData,
|
|
6680
7499
|
isInsufficientBalance,
|
|
6681
|
-
onOpenDialog
|
|
7500
|
+
onOpenDialog,
|
|
7501
|
+
config
|
|
6682
7502
|
}) => {
|
|
6683
7503
|
const address = useEvmAddress();
|
|
6684
7504
|
const userWallets = useUserWallets();
|
|
@@ -7009,6 +7829,21 @@ var TokenSelectAndInput = ({
|
|
|
7009
7829
|
}
|
|
7010
7830
|
if (address && !solanaWalletAddress) {
|
|
7011
7831
|
if (!fromTokenInfo.isSolana && isSolanaChain2(toTokenInfo.chain_id) || fromTokenInfo.isSolana && isSolanaChain2(toTokenInfo.chain_id)) {
|
|
7832
|
+
if (config?.solanaDifferentAddress) {
|
|
7833
|
+
return /* @__PURE__ */ jsxs(HStack, { gap: 1, children: [
|
|
7834
|
+
renderSolanaWalletIcon(),
|
|
7835
|
+
/* @__PURE__ */ jsx(
|
|
7836
|
+
Text2,
|
|
7837
|
+
{
|
|
7838
|
+
variant: "content8",
|
|
7839
|
+
backgroundColor: theme.highlightBgColor,
|
|
7840
|
+
padding: "2px",
|
|
7841
|
+
color: theme.highlightTextColor,
|
|
7842
|
+
children: sliceAddress(config.solanaDifferentAddress)
|
|
7843
|
+
}
|
|
7844
|
+
)
|
|
7845
|
+
] });
|
|
7846
|
+
}
|
|
7012
7847
|
return /* @__PURE__ */ jsxs(
|
|
7013
7848
|
HStack,
|
|
7014
7849
|
{
|
|
@@ -7048,6 +7883,21 @@ var TokenSelectAndInput = ({
|
|
|
7048
7883
|
if (!fromTokenInfo.isSolana && isSolanaChain2(toTokenInfo.chain_id) || fromTokenInfo.isSolana && isSolanaChain2(toTokenInfo.chain_id)) {
|
|
7049
7884
|
return renderSolanaAddress(solanaWalletAddress);
|
|
7050
7885
|
} else {
|
|
7886
|
+
if (config?.evmDifferentAddress) {
|
|
7887
|
+
return /* @__PURE__ */ jsxs(HStack, { gap: 1, children: [
|
|
7888
|
+
walletIcon,
|
|
7889
|
+
/* @__PURE__ */ jsx(
|
|
7890
|
+
Text2,
|
|
7891
|
+
{
|
|
7892
|
+
variant: "content8",
|
|
7893
|
+
backgroundColor: theme.highlightBgColor,
|
|
7894
|
+
padding: "2px",
|
|
7895
|
+
color: theme.highlightTextColor,
|
|
7896
|
+
children: sliceAddress(config.evmDifferentAddress)
|
|
7897
|
+
}
|
|
7898
|
+
)
|
|
7899
|
+
] });
|
|
7900
|
+
}
|
|
7051
7901
|
return /* @__PURE__ */ jsxs(
|
|
7052
7902
|
HStack,
|
|
7053
7903
|
{
|
|
@@ -7323,10 +8173,10 @@ var TokenSelectAndInput = ({
|
|
|
7323
8173
|
bottom: ["6px", "8px"],
|
|
7324
8174
|
left: 0,
|
|
7325
8175
|
paddingRight: [2, 4],
|
|
7326
|
-
children: !isFrom && !isDepositPlatformToken && /* @__PURE__ */ jsx(Fragment, { children: tokenInfo.isSolana ? solanaWalletAddress && /* @__PURE__ */ jsxs(Text2, { variant: "content8", children: [
|
|
8176
|
+
children: !isFrom && !isDepositPlatformToken && /* @__PURE__ */ jsx(Fragment, { children: tokenInfo.isSolana ? (solanaWalletAddress || config?.solanaDifferentAddress) && /* @__PURE__ */ jsxs(Text2, { variant: "content8", children: [
|
|
7327
8177
|
"Balance: ",
|
|
7328
8178
|
displayBalance
|
|
7329
|
-
] }) : address && /* @__PURE__ */ jsxs(Text2, { variant: "content8", children: [
|
|
8179
|
+
] }) : (address || config?.evmDifferentAddress) && /* @__PURE__ */ jsxs(Text2, { variant: "content8", children: [
|
|
7330
8180
|
"Balance: ",
|
|
7331
8181
|
displayBalance
|
|
7332
8182
|
] }) })
|
|
@@ -8129,6 +8979,12 @@ var DifferentAddressDialogInner = ({
|
|
|
8129
8979
|
isDepositPlatformToken
|
|
8130
8980
|
]);
|
|
8131
8981
|
useEffect(() => {
|
|
8982
|
+
if (isAddressError) {
|
|
8983
|
+
bottomToaster.error({
|
|
8984
|
+
description: isSolanaTarget ? "This address is not a valid Solana address." : "This address is not a EVM address.",
|
|
8985
|
+
duration: 3e3
|
|
8986
|
+
});
|
|
8987
|
+
}
|
|
8132
8988
|
}, [isAddressError, isSolanaTarget]);
|
|
8133
8989
|
return /* @__PURE__ */ jsx(
|
|
8134
8990
|
Dialog.Root,
|
|
@@ -8334,6 +9190,92 @@ var DifferentAddressDialog = ({
|
|
|
8334
9190
|
);
|
|
8335
9191
|
};
|
|
8336
9192
|
var DifferentAddressDialog_default = DifferentAddressDialog;
|
|
9193
|
+
var GetGas = ({ tokenInfo, onToggle, config }) => {
|
|
9194
|
+
const { theme } = useWidgetTheme();
|
|
9195
|
+
const { solanaWalletAddress } = useWalletConnectedStore();
|
|
9196
|
+
const address = useEvmAddress();
|
|
9197
|
+
const { sponsorGas, setSponsorGas } = useGetGasStore();
|
|
9198
|
+
const { tokens } = useTokensStore();
|
|
9199
|
+
const { chains } = useChainsStore();
|
|
9200
|
+
const isNative = useMemo(() => isNativeToken(tokenInfo), [tokenInfo]);
|
|
9201
|
+
const supportSponsorGas = useMemo(() => {
|
|
9202
|
+
if (!chains) return false;
|
|
9203
|
+
const chain = chains.find((c) => c.chain_id === tokenInfo.chain_id);
|
|
9204
|
+
return chain?.support_sponsor_gas ?? false;
|
|
9205
|
+
}, [chains, tokenInfo.chain_id]);
|
|
9206
|
+
const nativeToken = useMemo(() => {
|
|
9207
|
+
if (!tokens) return null;
|
|
9208
|
+
return tokens.find(
|
|
9209
|
+
(t) => t.chain_id === tokenInfo.chain_id && isNativeToken(t)
|
|
9210
|
+
);
|
|
9211
|
+
}, [tokens, tokenInfo.chain_id]);
|
|
9212
|
+
const isSolana = useMemo(() => {
|
|
9213
|
+
return isSolanaChain2(tokenInfo.chain_id);
|
|
9214
|
+
}, [tokenInfo.chain_id]);
|
|
9215
|
+
const evmOwnerAddress = !isSolana && !address && config?.evmDifferentAddress ? config.evmDifferentAddress : void 0;
|
|
9216
|
+
const evmNativeBalance = useTokenBalance2({
|
|
9217
|
+
chainId: tokenInfo.chain_id,
|
|
9218
|
+
tokenAddress: void 0,
|
|
9219
|
+
connectAddress: evmOwnerAddress
|
|
9220
|
+
});
|
|
9221
|
+
const solanaOwnerAddress = isSolana && !solanaWalletAddress && config?.solanaDifferentAddress ? config.solanaDifferentAddress : void 0;
|
|
9222
|
+
const { data: solanaNativeBalanceData } = useSolanaTokenBalance(
|
|
9223
|
+
void 0,
|
|
9224
|
+
isSolana,
|
|
9225
|
+
solanaOwnerAddress
|
|
9226
|
+
);
|
|
9227
|
+
const nativeBalance = useMemo(() => {
|
|
9228
|
+
if (isSolana) return solanaNativeBalanceData ?? void 0;
|
|
9229
|
+
return evmNativeBalance;
|
|
9230
|
+
}, [isSolana, solanaNativeBalanceData, evmNativeBalance]);
|
|
9231
|
+
useEffect(() => {
|
|
9232
|
+
if (!supportSponsorGas || isNative || nativeBalance === void 0) {
|
|
9233
|
+
setSponsorGas(false);
|
|
9234
|
+
return;
|
|
9235
|
+
}
|
|
9236
|
+
setSponsorGas(nativeBalance.value === 0n);
|
|
9237
|
+
}, [supportSponsorGas, isNative, nativeBalance, setSponsorGas]);
|
|
9238
|
+
const shouldShow = supportSponsorGas && !isNative && nativeBalance !== void 0 && nativeBalance.value === 0n;
|
|
9239
|
+
if (!shouldShow) return null;
|
|
9240
|
+
return /* @__PURE__ */ jsxs(
|
|
9241
|
+
HStack,
|
|
9242
|
+
{
|
|
9243
|
+
w: "100%",
|
|
9244
|
+
h: "42px",
|
|
9245
|
+
padding: "0 14px",
|
|
9246
|
+
fontSize: "12px",
|
|
9247
|
+
color: theme.defaultTextColor,
|
|
9248
|
+
backgroundColor: theme.highlightBgColor,
|
|
9249
|
+
borderRadius: "10px",
|
|
9250
|
+
gap: 0,
|
|
9251
|
+
children: [
|
|
9252
|
+
/* @__PURE__ */ jsx(MdLocalGasStation, { width: "14px", height: "14px" }),
|
|
9253
|
+
/* @__PURE__ */ jsxs(Box, { flex: 1, marginLeft: "5px", children: [
|
|
9254
|
+
"Get $",
|
|
9255
|
+
nativeToken?.symbol ?? "ETH",
|
|
9256
|
+
" as gas"
|
|
9257
|
+
] }),
|
|
9258
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(
|
|
9259
|
+
Switch.Root,
|
|
9260
|
+
{
|
|
9261
|
+
colorPalette: theme.getGasSwitchColorPalette ?? "purple",
|
|
9262
|
+
checked: sponsorGas,
|
|
9263
|
+
onCheckedChange: (e) => {
|
|
9264
|
+
setSponsorGas(e.checked);
|
|
9265
|
+
onToggle?.();
|
|
9266
|
+
},
|
|
9267
|
+
children: [
|
|
9268
|
+
/* @__PURE__ */ jsx(Switch.HiddenInput, {}),
|
|
9269
|
+
/* @__PURE__ */ jsx(Switch.Control, {}),
|
|
9270
|
+
/* @__PURE__ */ jsx(Switch.Label, {})
|
|
9271
|
+
]
|
|
9272
|
+
}
|
|
9273
|
+
) })
|
|
9274
|
+
]
|
|
9275
|
+
}
|
|
9276
|
+
);
|
|
9277
|
+
};
|
|
9278
|
+
var GetGas_default = GetGas;
|
|
8337
9279
|
var FormBody = ({
|
|
8338
9280
|
getQuote,
|
|
8339
9281
|
quoteInfo,
|
|
@@ -8369,6 +9311,7 @@ var FormBody = ({
|
|
|
8369
9311
|
const [isInsufficientBalance, setIsInsufficientBalance] = useState(false);
|
|
8370
9312
|
const address = useEvmAddress();
|
|
8371
9313
|
const { solanaWalletAddress } = useWalletConnectedStore();
|
|
9314
|
+
const { sponsorGas } = useGetGasStore();
|
|
8372
9315
|
const slippage = address ? slippageStore.get(address) : customSlippage !== void 0 ? { value: customSlippage } : void 0;
|
|
8373
9316
|
const fromTokenBalanceNormal = useTokenBalance2({
|
|
8374
9317
|
chainId: fromTokenInfo.chain_id,
|
|
@@ -8378,6 +9321,11 @@ var FormBody = ({
|
|
|
8378
9321
|
chainId: toTokenInfo.chain_id,
|
|
8379
9322
|
tokenAddress: toTokenInfo.address === zeroAddress ? void 0 : toTokenInfo.address
|
|
8380
9323
|
});
|
|
9324
|
+
const toTokenFixedEvmBalance = useTokenBalance2({
|
|
9325
|
+
chainId: toTokenInfo.chain_id,
|
|
9326
|
+
tokenAddress: toTokenInfo.address === zeroAddress ? void 0 : toTokenInfo.address,
|
|
9327
|
+
connectAddress: config?.evmDifferentAddress ? config.evmDifferentAddress : void 0
|
|
9328
|
+
});
|
|
8381
9329
|
const { data: fromTokenBalanceHyperBack } = useHyperliquidBalance(
|
|
8382
9330
|
address,
|
|
8383
9331
|
isFromHyperChain
|
|
@@ -8433,10 +9381,10 @@ var FormBody = ({
|
|
|
8433
9381
|
}, [fromTokenInfo.isSolana, solanaWalletAddress, address]);
|
|
8434
9382
|
const toAddress = useMemo(() => {
|
|
8435
9383
|
if (toTokenInfo.isSolana) {
|
|
8436
|
-
return solanaWalletAddress || "";
|
|
9384
|
+
return config?.solanaDifferentAddress || solanaWalletAddress || "";
|
|
8437
9385
|
}
|
|
8438
|
-
return differentAddress || address || "";
|
|
8439
|
-
}, [toTokenInfo.isSolana, solanaWalletAddress, differentAddress, address]);
|
|
9386
|
+
return config?.evmDifferentAddress || differentAddress || address || "";
|
|
9387
|
+
}, [toTokenInfo.isSolana, solanaWalletAddress, differentAddress, address, config?.solanaDifferentAddress, config?.evmDifferentAddress]);
|
|
8440
9388
|
const isFromNativeSOL = fromTokenInfo.isSolana && (fromTokenInfo.symbol?.toUpperCase() === "SOL" || fromTokenInfo.address === "11111111111111111111111111111111");
|
|
8441
9389
|
const isToNativeSOL = toTokenInfo.isSolana && (toTokenInfo.symbol?.toUpperCase() === "SOL" || toTokenInfo.address === "11111111111111111111111111111111");
|
|
8442
9390
|
const fromTokenBalanceSolana = useSolanaTokenBalance(
|
|
@@ -8465,19 +9413,29 @@ var FormBody = ({
|
|
|
8465
9413
|
]);
|
|
8466
9414
|
const toTokenBalance = useMemo(() => {
|
|
8467
9415
|
if (toTokenInfo.isSolana) {
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
9416
|
+
if (toTokenBalanceSolana.data) {
|
|
9417
|
+
return {
|
|
9418
|
+
decimals: toTokenBalanceSolana.data.decimals,
|
|
9419
|
+
value: toTokenBalanceSolana.data.value,
|
|
9420
|
+
formatted: toTokenBalanceSolana.data.formatted
|
|
9421
|
+
};
|
|
9422
|
+
}
|
|
9423
|
+
return void 0;
|
|
9424
|
+
}
|
|
9425
|
+
if (isToHyperChain) return toTokenBalanceHyper;
|
|
9426
|
+
if (!address && config?.evmDifferentAddress && toTokenFixedEvmBalance) {
|
|
9427
|
+
return toTokenFixedEvmBalance;
|
|
8473
9428
|
}
|
|
8474
|
-
return
|
|
9429
|
+
return toTokenBalanceNormal;
|
|
8475
9430
|
}, [
|
|
8476
9431
|
toTokenInfo.isSolana,
|
|
8477
9432
|
toTokenBalanceSolana.data,
|
|
8478
9433
|
isToHyperChain,
|
|
8479
9434
|
toTokenBalanceHyper,
|
|
8480
|
-
toTokenBalanceNormal
|
|
9435
|
+
toTokenBalanceNormal,
|
|
9436
|
+
address,
|
|
9437
|
+
config?.evmDifferentAddress,
|
|
9438
|
+
toTokenFixedEvmBalance
|
|
8481
9439
|
]);
|
|
8482
9440
|
const balanceInfo = useMemo(() => {
|
|
8483
9441
|
const fromBalance = new Fraction(fromTokenBalance?.value ?? 0n);
|
|
@@ -8580,8 +9538,8 @@ var FormBody = ({
|
|
|
8580
9538
|
if (isSelectingFromToken) {
|
|
8581
9539
|
setFromTokenInfo(tokenInfo);
|
|
8582
9540
|
if (isTestnetChain(tokenInfo.chain_id)) {
|
|
8583
|
-
const
|
|
8584
|
-
if (
|
|
9541
|
+
const isNativeToken2 = tokenInfo.tags?.includes("native") || tokenInfo.address === zeroAddress;
|
|
9542
|
+
if (isNativeToken2) {
|
|
8585
9543
|
const otherToken = tokens?.find(
|
|
8586
9544
|
(t) => t.chain_id === tokenInfo.chain_id && t.address !== tokenInfo.address
|
|
8587
9545
|
);
|
|
@@ -8616,8 +9574,8 @@ var FormBody = ({
|
|
|
8616
9574
|
} else {
|
|
8617
9575
|
setToTokenInfo(tokenInfo);
|
|
8618
9576
|
if (isTestnetChain(tokenInfo.chain_id)) {
|
|
8619
|
-
const
|
|
8620
|
-
if (
|
|
9577
|
+
const isNativeToken2 = tokenInfo.tags?.includes("native") || tokenInfo.address === zeroAddress;
|
|
9578
|
+
if (isNativeToken2) {
|
|
8621
9579
|
const otherToken = tokens?.find(
|
|
8622
9580
|
(t) => t.chain_id === tokenInfo.chain_id && t.address !== tokenInfo.address
|
|
8623
9581
|
);
|
|
@@ -8685,9 +9643,9 @@ var FormBody = ({
|
|
|
8685
9643
|
};
|
|
8686
9644
|
const _toAddress = () => {
|
|
8687
9645
|
if (_toTokenInfo.isSolana) {
|
|
8688
|
-
return solanaWalletAddress || "";
|
|
9646
|
+
return config?.solanaDifferentAddress || solanaWalletAddress || "";
|
|
8689
9647
|
}
|
|
8690
|
-
return differentAddress || address || "";
|
|
9648
|
+
return config?.evmDifferentAddress || differentAddress || address || "";
|
|
8691
9649
|
};
|
|
8692
9650
|
const vCode = extractVPathSegment();
|
|
8693
9651
|
await getQuote({
|
|
@@ -8701,7 +9659,8 @@ var FormBody = ({
|
|
|
8701
9659
|
slippage: calculateSlippage(slippage?.value),
|
|
8702
9660
|
toTokenDecimals: _toTokenInfo.decimals,
|
|
8703
9661
|
affiliation: vCode,
|
|
8704
|
-
to_platform_id: _toTokenInfo.platform_id || 0
|
|
9662
|
+
to_platform_id: _toTokenInfo.platform_id || 0,
|
|
9663
|
+
sponsor_gas: sponsorGas
|
|
8705
9664
|
});
|
|
8706
9665
|
saveTokenSelection();
|
|
8707
9666
|
};
|
|
@@ -8725,7 +9684,8 @@ var FormBody = ({
|
|
|
8725
9684
|
slippage: calculateSlippage(slippage?.value) || autoSlippage,
|
|
8726
9685
|
toTokenDecimals: toTokenInfo.decimals,
|
|
8727
9686
|
affiliation: vCode,
|
|
8728
|
-
to_platform_id: toTokenInfo.platform_id || 0
|
|
9687
|
+
to_platform_id: toTokenInfo.platform_id || 0,
|
|
9688
|
+
sponsor_gas: sponsorGas
|
|
8729
9689
|
});
|
|
8730
9690
|
};
|
|
8731
9691
|
const handleToAmountChange = (value) => {
|
|
@@ -8743,7 +9703,8 @@ var FormBody = ({
|
|
|
8743
9703
|
amount: parseUnits(fromAmount, fromTokenInfo.decimals).toString(),
|
|
8744
9704
|
slippage: calculateSlippage(slippage?.value),
|
|
8745
9705
|
toTokenDecimals: toTokenInfo.decimals,
|
|
8746
|
-
to_platform_id: toTokenInfo.platform_id || 0
|
|
9706
|
+
to_platform_id: toTokenInfo.platform_id || 0,
|
|
9707
|
+
sponsor_gas: sponsorGas
|
|
8747
9708
|
});
|
|
8748
9709
|
};
|
|
8749
9710
|
if (fromAddress && fromAmount) {
|
|
@@ -8806,12 +9767,14 @@ var FormBody = ({
|
|
|
8806
9767
|
userBalance: balanceInfo.toBalance,
|
|
8807
9768
|
usdPrice: toTokenUsdPrice,
|
|
8808
9769
|
isInsufficientBalance,
|
|
8809
|
-
onOpenDialog: handleOpenDifferentAddressDialog
|
|
9770
|
+
onOpenDialog: handleOpenDifferentAddressDialog,
|
|
9771
|
+
config
|
|
8810
9772
|
}
|
|
8811
9773
|
)
|
|
8812
9774
|
]
|
|
8813
9775
|
}
|
|
8814
9776
|
),
|
|
9777
|
+
/* @__PURE__ */ jsx(GetGas_default, { tokenInfo: toTokenInfo, onToggle: refetchQuote, config }),
|
|
8815
9778
|
/* @__PURE__ */ jsx(
|
|
8816
9779
|
FormButton,
|
|
8817
9780
|
{
|
|
@@ -8834,7 +9797,9 @@ var FormBody = ({
|
|
|
8834
9797
|
currentRequestId: quoteInfo.request_id,
|
|
8835
9798
|
clearLockedRequestId,
|
|
8836
9799
|
lockedRequestId,
|
|
8837
|
-
getQuote
|
|
9800
|
+
getQuote,
|
|
9801
|
+
skipEvmWalletConnect: !toTokenInfo.isSolana && !!config?.evmDifferentAddress,
|
|
9802
|
+
skipSolanaWalletConnect: toTokenInfo.isSolana && !!config?.solanaDifferentAddress
|
|
8838
9803
|
}
|
|
8839
9804
|
),
|
|
8840
9805
|
/* @__PURE__ */ jsx(
|
|
@@ -8911,7 +9876,7 @@ var SlippageSettings = ({ refetchQuote }) => {
|
|
|
8911
9876
|
[fromTokenInfo, toTokenInfo, chains]
|
|
8912
9877
|
);
|
|
8913
9878
|
const isStablecoinPair = useMemo(
|
|
8914
|
-
() =>
|
|
9879
|
+
() => isStablecoin(fromTokenInfo) && isStablecoin(toTokenInfo),
|
|
8915
9880
|
[fromTokenInfo, toTokenInfo]
|
|
8916
9881
|
);
|
|
8917
9882
|
const isSameChain = useMemo(
|
|
@@ -9789,6 +10754,11 @@ var TxState = ({
|
|
|
9789
10754
|
}
|
|
9790
10755
|
}, [isError]);
|
|
9791
10756
|
useEffect(() => {
|
|
10757
|
+
if (timeOut && isTransactionBlocked) {
|
|
10758
|
+
topToaster.error({
|
|
10759
|
+
description: `This transaction is stuck on the source network. Please go to the wallet's activity section to speed up or cancel the transaction.`
|
|
10760
|
+
});
|
|
10761
|
+
}
|
|
9792
10762
|
}, [isTransactionBlocked, timeOut]);
|
|
9793
10763
|
useEffect(() => {
|
|
9794
10764
|
if (isSolanaTransaction && solanaFromTxHash) {
|
|
@@ -10461,7 +11431,7 @@ var TxState = ({
|
|
|
10461
11431
|
) });
|
|
10462
11432
|
};
|
|
10463
11433
|
async function getOrderHistory(address, offset = 0, limit = 4) {
|
|
10464
|
-
const url = `${
|
|
11434
|
+
const url = `${getBaseApiUrl()}/v1/orders`;
|
|
10465
11435
|
const res = await axios6.get(url, {
|
|
10466
11436
|
params: {
|
|
10467
11437
|
address: Array.isArray(address) ? address : [address],
|
|
@@ -10897,10 +11867,10 @@ var MainForm = ({ config }) => {
|
|
|
10897
11867
|
}, [fromTokenInfo.isSolana, solanaWalletAddress, address]);
|
|
10898
11868
|
const toAddress = useMemo(() => {
|
|
10899
11869
|
if (toTokenInfo.isSolana) {
|
|
10900
|
-
return solanaWalletAddress || "";
|
|
11870
|
+
return config?.solanaDifferentAddress || solanaWalletAddress || "";
|
|
10901
11871
|
}
|
|
10902
|
-
return differentAddress || address || "";
|
|
10903
|
-
}, [toTokenInfo.isSolana, solanaWalletAddress, differentAddress, address]);
|
|
11872
|
+
return config?.evmDifferentAddress || differentAddress || address || "";
|
|
11873
|
+
}, [toTokenInfo.isSolana, solanaWalletAddress, differentAddress, address, config?.solanaDifferentAddress, config?.evmDifferentAddress]);
|
|
10904
11874
|
useEffect(() => {
|
|
10905
11875
|
if (timerRef.current && (new Fraction(fromAmount).eq(0) || fromTxHash || solanaFromTxHash || address)) {
|
|
10906
11876
|
clearTimeout(timerRef.current);
|
|
@@ -11179,7 +12149,8 @@ var MainForm = ({ config }) => {
|
|
|
11179
12149
|
affiliation: vCode,
|
|
11180
12150
|
slippage: isAutoSlippage ? slippageValue && slippageValue !== "0" ? calculateSlippage(slippageValue) : slippageValue === "0" ? 0 : void 0 : calculateSlippage(slippageValue || slippage?.value),
|
|
11181
12151
|
toTokenDecimals: toTokenInfo.decimals,
|
|
11182
|
-
to_platform_id: toTokenInfo.platform_id || 0
|
|
12152
|
+
to_platform_id: toTokenInfo.platform_id || 0,
|
|
12153
|
+
sponsor_gas: useGetGasStore.getState().sponsorGas
|
|
11183
12154
|
});
|
|
11184
12155
|
},
|
|
11185
12156
|
[
|
|
@@ -11426,6 +12397,6 @@ var MainForm = ({ config }) => {
|
|
|
11426
12397
|
};
|
|
11427
12398
|
var WheelXWidget = MainForm;
|
|
11428
12399
|
|
|
11429
|
-
export { WheelXProvider, WheelXWidget, WidgetThemeProvider, defaultTheme, getChainsAndTokens, mergeTokensWithCompositeKey, useChainsAndTokens, useChainsStore, useDifferentAddressStore, useEvmAddress, useGuardChain, useInitSwapAndBridgeState, useRefreshLoading, useResetSwapAndBridgeState, useSwapAndBridgeContextStore, useSyncWalletConnectedStore, useTokenBalance2 as useTokenBalance, useTokensStore, useTxStateContextStore, useWalletConnectedStore, useWidgetTheme };
|
|
12400
|
+
export { KNOWN_WALLET_UNIVERSAL_LINKS, WheelXProvider, WheelXWidget, WidgetThemeProvider, convertToDeepLink, defaultTheme, getChainsAndTokens, isDeepLinkUrl, isMobileDevice, isReactNativeWebView, isWalletRelatedUrl, isWebView, mergeTokensWithCompositeKey, shouldInterceptDeepLinks, useChainsAndTokens, useChainsStore, useDifferentAddressStore, useEvmAddress, useGuardChain, useInitSwapAndBridgeState, useRefreshLoading, useResetSwapAndBridgeState, useSwapAndBridgeContextStore, useSyncWalletConnectedStore, useTokenBalance2 as useTokenBalance, useTokensStore, useTxStateContextStore, useWalletConnectedStore, useWidgetTheme };
|
|
11430
12401
|
//# sourceMappingURL=index.mjs.map
|
|
11431
12402
|
//# sourceMappingURL=index.mjs.map
|