@wheelx-widget/widget 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8,13 +8,13 @@ var ethereum = require('@dynamic-labs/ethereum');
8
8
  var solana = require('@dynamic-labs/solana');
9
9
  var wagmiConnector = require('@dynamic-labs/wagmi-connector');
10
10
  var wagmi = require('wagmi');
11
+ var viem = require('viem');
11
12
  var chains$1 = require('wagmi/chains');
12
13
  var react$1 = require('@emotion/react');
13
14
  var jsxRuntime = require('react/jsx-runtime');
14
15
  var axios6 = require('axios');
15
16
  var zustand = require('zustand');
16
17
  var biFraction = require('bi-fraction');
17
- var viem = require('viem');
18
18
  var chains = require('viem/chains');
19
19
  var web3_js = require('@solana/web3.js');
20
20
  var utils = require('viem/utils');
@@ -26,6 +26,8 @@ var io5 = require('react-icons/io5');
26
26
  var fa6 = require('react-icons/fa6');
27
27
  var io = require('react-icons/io');
28
28
  var bs = require('react-icons/bs');
29
+ var hi2 = require('react-icons/hi2');
30
+ var ri = require('react-icons/ri');
29
31
 
30
32
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
31
33
 
@@ -181,7 +183,11 @@ var useWalletConnectedStore = zustand.create((set, get) => ({
181
183
  evmWalletConnectorId: null,
182
184
  setEvmWalletInfo: (address, connectorId) => set({ evmWalletAddress: address, evmWalletConnectorId: connectorId }),
183
185
  isEvmWalletMetamask: false,
184
- setIsEvmWalletMetamask: (isEvmWalletMetamask) => set({ isEvmWalletMetamask })
186
+ setIsEvmWalletMetamask: (isEvmWalletMetamask) => set({ isEvmWalletMetamask }),
187
+ isLoggingOut: false,
188
+ setIsLoggingOut: (isLoggingOut) => set({ isLoggingOut }),
189
+ lastDisconnectTimestamp: 0,
190
+ setLastDisconnectTimestamp: (ts) => set({ lastDisconnectTimestamp: ts })
185
191
  }));
186
192
 
187
193
  // src/stores/useSyncWalletConnectedStore.ts
@@ -191,14 +197,25 @@ var getEvmConnectorId = (wallet) => {
191
197
  };
192
198
  var useSyncWalletConnectedStore = () => {
193
199
  const userWallets = sdkReactCore.useUserWallets();
194
- const { address: wagmiAddress, connector: wagmiConnector, isConnected } = wagmi.useAccount();
200
+ const { address: wagmiAddress, connector: wagmiConnector } = wagmi.useAccount();
195
201
  const {
196
202
  setSolanaWalletAddress,
197
203
  setIsSolanaWalletConnected,
198
204
  setEvmWalletInfo,
199
- setIsEthWalletConnected
205
+ setIsEthWalletConnected,
206
+ isLoggingOut,
207
+ lastDisconnectTimestamp
200
208
  } = useWalletConnectedStore();
201
209
  React5.useEffect(() => {
210
+ if (isLoggingOut) return;
211
+ const msSinceDisconnect = Date.now() - lastDisconnectTimestamp;
212
+ if (msSinceDisconnect < 2e3) {
213
+ const { isEthWalletConnected, isSolanaWalletConnected } = useWalletConnectedStore.getState();
214
+ const hasNoConnectedWallets = !isEthWalletConnected && !isSolanaWalletConnected;
215
+ if (hasNoConnectedWallets) {
216
+ return;
217
+ }
218
+ }
202
219
  const solanaWallet = userWallets.find((wallet) => {
203
220
  const chain = String(
204
221
  wallet.chain ?? ""
@@ -214,15 +231,16 @@ var useSyncWalletConnectedStore = () => {
214
231
  ).toLowerCase();
215
232
  return chain.includes("evm");
216
233
  });
217
- const evmAddress = evmWallet?.address ?? wagmiAddress ?? null;
234
+ const evmAddress = evmWallet?.address ?? (evmWallet ? wagmiAddress : null) ?? null;
218
235
  const evmConnectorId = wagmiConnector?.id ?? getEvmConnectorId(evmWallet) ?? null;
219
236
  setEvmWalletInfo(evmAddress, evmConnectorId);
220
- setIsEthWalletConnected(Boolean(evmAddress || isConnected));
237
+ setIsEthWalletConnected(Boolean(evmAddress));
221
238
  }, [
222
239
  userWallets,
223
240
  wagmiAddress,
224
241
  wagmiConnector?.id,
225
- isConnected,
242
+ isLoggingOut,
243
+ lastDisconnectTimestamp,
226
244
  setSolanaWalletAddress,
227
245
  setIsSolanaWalletConnected,
228
246
  setEvmWalletInfo,
@@ -231,7 +249,8 @@ var useSyncWalletConnectedStore = () => {
231
249
  };
232
250
  var useEvmAddress = () => {
233
251
  const { address } = wagmi.useAccount();
234
- const { evmWalletAddress } = useWalletConnectedStore();
252
+ const { evmWalletAddress, isEthWalletConnected } = useWalletConnectedStore();
253
+ if (!isEthWalletConnected) return void 0;
235
254
  return evmWalletAddress || address;
236
255
  };
237
256
  var FavoritesContext = React5.createContext({
@@ -434,21 +453,140 @@ var useTokenFavoritesContext = () => {
434
453
  if (c === void 0) throw new Error("useTokenFavoritesContext must be used within TokenFavoritesProvider");
435
454
  return c;
436
455
  };
437
- var supportedChains = [chains$1.mainnet, chains$1.base, chains$1.soneium, chains$1.polygon, chains$1.arbitrum, chains$1.optimism, chains$1.sepolia, chains$1.arbitrumSepolia, chains$1.optimismSepolia, chains$1.baseSepolia, chains$1.unichainSepolia, chains$1.arcTestnet];
456
+ var tempo = viem.defineChain({
457
+ id: 4217,
458
+ name: "Tempo",
459
+ network: "Tempo",
460
+ nativeCurrency: { name: "USD", symbol: "USD", decimals: 6 },
461
+ rpcUrls: { default: { http: ["https://rpc.tempo.xyz"] } },
462
+ blockExplorers: { default: { name: "Tempo Explorer", url: "https://explore.tempo.xyz" } },
463
+ testnet: true
464
+ });
465
+ var katana = viem.defineChain({ id: 747474, name: "Katana", network: "Katana", nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://rpc.katana.network"] } }, blockExplorers: { default: { name: "Katana Explorer", url: "https://explorer.katanarpc.com" } } });
466
+ var hyperevm = viem.defineChain({ id: 999, name: "HyperEVM", network: "HyperEVM", nativeCurrency: { name: "HYPE", symbol: "HYPE", decimals: 18 }, rpcUrls: { default: { http: ["https://rpc.hyperliquid.xyz/evm", "https://rpc.hypurrscan.io"] } }, blockExplorers: { default: { name: "Purrsec", url: "https://hyperevmscan.io" } } });
467
+ var stable = viem.defineChain({ id: 988, name: "Stable", network: "Stable", nativeCurrency: { name: "STB", symbol: "STB", decimals: 18 }, rpcUrls: { default: { http: ["https://rpc.stable.xyz"] } }, blockExplorers: { default: { name: "Stablescan", url: "https://stablescan.xyz" } } });
468
+ var monad = viem.defineChain({ id: 143, name: "Monad", network: "Monad", nativeCurrency: { name: "MON", symbol: "MON", decimals: 18 }, rpcUrls: { default: { http: ["https://rpc.monad.xyz", "https://rpc1.monad.xyz"] } }, blockExplorers: { default: { name: "MonadVision", url: "https://monadvision.com" } } });
469
+ var metis = viem.defineChain({ id: 1088, name: "Metis", network: "Metis", nativeCurrency: { name: "METIS", symbol: "METIS", decimals: 18 }, rpcUrls: { default: { http: ["https://metis.api.onfinality.io/public", "https://metis-public.nodies.app"] } }, blockExplorers: { default: { name: "Metis Explorer", url: "https://explorer.metis.io" } } });
470
+ var polygonZkEvm = viem.defineChain({ id: 1101, name: "Polygon zkEVM", network: "Polygon zkEVM", nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://zkevm-rpc.com"] } }, blockExplorers: { default: { name: "PolygonScan zkEVM", url: "https://www.oklink.com/polygon-zkevm" } } });
471
+ var megaeth = viem.defineChain({ id: 4326, name: "MegaETH", network: "MegaETH", nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://mainnet.megaeth.com/rpc"] } }, blockExplorers: { default: { name: "MegaETH Explorer", url: "https://megaeth.blockscout.com/" } } });
472
+ var pharos = viem.defineChain({ id: 1672, name: "Pharos", network: "Pharos", nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://rpc.pharos.xyz"] } }, blockExplorers: { default: { name: "Pharoscan", url: "https://pharosscan.xyz" } } });
473
+ var kite = viem.defineChain({ id: 2366, name: "Kite", network: "Kite", nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://rpc.gokite.ai/"] } }, blockExplorers: { default: { name: "Kitescan", url: "https://kitescan.ai/" } } });
474
+ var plasma = viem.defineChain({ id: 9745, name: "Plasma", network: "Plasma", nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://rpc.plasma.to"] } }, blockExplorers: { default: { name: "Plasma Explorer", url: "https://plasmascan.to" } }, testnet: true });
475
+ var rari = viem.defineChain({ id: 1380012617, name: "RARI", network: "RARI", nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://mainnet.rpc.rarichain.org/http"] } }, blockExplorers: { default: { name: "RARI Explorer", url: "https://mainnet.explorer.rarichain.org/" } }, testnet: true });
476
+ var stabletestnet = viem.defineChain({ id: 2201, name: "Stable Testnet", network: "Stable Testnet", nativeCurrency: { name: "STB", symbol: "STB", decimals: 18 }, rpcUrls: { default: { http: ["https://rpc.testnet.stable.xyz"] } }, blockExplorers: { default: { name: "Stablescan Testnet", url: "https://testnet.stablescan.xyz" } }, testnet: true });
477
+ var giwa = viem.defineChain({ id: 91342, name: "GIWA Testnet", network: "GIWA Testnet", nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://sepolia-rpc.giwa.io"] } }, blockExplorers: { default: { name: "GIWA Explorer", url: "https://sepolia-explorer.giwa.io" } }, testnet: true });
478
+ var robinhoodTestnet = viem.defineChain({ id: 46630, name: "Robinhood Testnet", network: "Robinhood Testnet", nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://rpc.testnet.chain.robinhood.com"] } }, blockExplorers: { default: { name: "Robinhood Explorer", url: "https://explorer.testnet.chain.robinhood.com/" } }, testnet: true });
479
+ var litvm = viem.defineChain({ id: 4441, name: "LitVM Testnet", network: "LitVM Testnet", nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://liteforge.rpc.caldera.xyz/http"] } }, blockExplorers: { default: { name: "LitVM Explorer", url: "https://liteforge.explorer.caldera.xyz" } }, testnet: true });
480
+ var supportedChains = [
481
+ // Mainnet (wagmi/chains)
482
+ chains$1.mainnet,
483
+ chains$1.arbitrum,
484
+ chains$1.optimism,
485
+ chains$1.unichain,
486
+ chains$1.base,
487
+ chains$1.ink,
488
+ chains$1.linea,
489
+ chains$1.soneium,
490
+ chains$1.bsc,
491
+ chains$1.worldchain,
492
+ chains$1.opBNB,
493
+ chains$1.mode,
494
+ chains$1.lisk,
495
+ chains$1.zksync,
496
+ chains$1.celo,
497
+ chains$1.polygon,
498
+ chains$1.avalanche,
499
+ chains$1.plumeMainnet,
500
+ chains$1.zora,
501
+ chains$1.sonic,
502
+ chains$1.berachain,
503
+ chains$1.bob,
504
+ chains$1.abstract,
505
+ chains$1.morph,
506
+ chains$1.taiko,
507
+ chains$1.scroll,
508
+ chains$1.hemi,
509
+ chains$1.xLayer,
510
+ chains$1.mantle,
511
+ chains$1.cronos,
512
+ chains$1.gravity,
513
+ chains$1.blast,
514
+ chains$1.manta,
515
+ chains$1.zircuit,
516
+ chains$1.xdc,
517
+ chains$1.sei,
518
+ chains$1.plume,
519
+ chains$1.gnosis,
520
+ chains$1.hashkey,
521
+ chains$1.flowMainnet,
522
+ chains$1.etherlink,
523
+ chains$1.ronin,
524
+ chains$1.flare,
525
+ chains$1.rootstock,
526
+ chains$1.iota,
527
+ chains$1.pulsechain,
528
+ // Mainnet (custom chains — not in wagmi/chains)
529
+ katana,
530
+ hyperevm,
531
+ stable,
532
+ monad,
533
+ metis,
534
+ polygonZkEvm,
535
+ megaeth,
536
+ pharos,
537
+ kite,
538
+ tempo,
539
+ plasma,
540
+ rari,
541
+ // Testnet (wagmi/chains)
542
+ chains$1.sepolia,
543
+ chains$1.arbitrumSepolia,
544
+ chains$1.optimismSepolia,
545
+ chains$1.baseSepolia,
546
+ chains$1.unichainSepolia,
547
+ chains$1.arcTestnet,
548
+ // Testnet (custom chains — not in wagmi/chains)
549
+ stabletestnet,
550
+ giwa,
551
+ robinhoodTestnet,
552
+ litvm
553
+ ];
438
554
  var CORS_FRIENDLY_RPC_MAP = {
555
+ // wagmi/chains mainnet
439
556
  1: "https://eth-mainnet.public.blastapi.io",
440
557
  8453: "https://mainnet.base.org",
441
558
  1868: "https://soneium.rpc.scs.startale.com",
442
559
  137: "https://polygon-rpc.com",
560
+ 56: "https://bsc-dataseed.binance.org",
561
+ 130: "https://rpc.therpc.io/unichain",
562
+ 196: "https://rpc.xlayer.io",
443
563
  42161: "https://arbitrum.gateway.tenderly.co",
444
564
  10: "https://optimism.gateway.tenderly.co",
565
+ // Custom chains (mainnet)
566
+ 4217: "https://rpc.tempo.xyz",
567
+ 747474: "https://rpc.katana.network",
568
+ 999: "https://rpc.hyperliquid.xyz/evm",
569
+ 988: "https://rpc.stable.xyz",
570
+ 143: "https://rpc.monad.xyz",
571
+ 1088: "https://metis.api.onfinality.io/public",
572
+ 1101: "https://zkevm-rpc.com",
573
+ 4326: "https://mainnet.megaeth.com/rpc",
574
+ 1672: "https://rpc.pharos.xyz",
575
+ 2366: "https://rpc.gokite.ai/",
576
+ 9745: "https://rpc.plasma.to",
577
+ 1380012617: "https://mainnet.rpc.rarichain.org/http",
445
578
  // Testnet
446
579
  11155111: "https://ethereum-sepolia.publicnode.com",
447
580
  421614: "https://sepolia-rollup.arbitrum.io/rpc",
448
581
  11155420: "https://optimism-sepolia.gateway.tenderly.co",
449
582
  84532: "https://sepolia.base.org",
450
583
  1301: "https://sepolia.unichain.org",
451
- 5042002: "https://rpc.testnet.arc.network"
584
+ 5042002: "https://rpc.testnet.arc.network",
585
+ // Custom chains (testnet)
586
+ 2201: "https://rpc.testnet.stable.xyz",
587
+ 91342: "https://sepolia-rpc.giwa.io",
588
+ 46630: "https://rpc.testnet.chain.robinhood.com",
589
+ 4441: "https://liteforge.rpc.caldera.xyz/http"
452
590
  };
453
591
  function buildStableTransports() {
454
592
  const transports = {};
@@ -522,35 +660,8 @@ function ChainsAndTokensLoader({ children, config }) {
522
660
  if (data.deposit_platforms?.prediction?.tokens) l.push(...data.deposit_platforms.prediction.tokens);
523
661
  return l;
524
662
  }, [data]);
525
- const filteredChains = React5.useMemo(() => {
526
- if (!allChains) return null;
527
- const fromChains = config?.from?.chains;
528
- const toChains = config?.to?.chains;
529
- if (!fromChains?.length && !toChains?.length) return allChains;
530
- const allowedSet = /* @__PURE__ */ new Set();
531
- fromChains?.forEach((id) => allowedSet.add(id));
532
- toChains?.forEach((id) => allowedSet.add(id));
533
- return allChains.filter((c) => allowedSet.has(c.chain_id));
534
- }, [allChains, config?.from?.chains, config?.to?.chains]);
535
- const filteredTokens = React5.useMemo(() => {
536
- if (!allTokens) return null;
537
- const fromTokenConfig = config?.from?.chainTokens;
538
- const toTokenConfig = config?.to?.chainTokens;
539
- if (!fromTokenConfig && !toTokenConfig) return allTokens;
540
- const allowedSet = /* @__PURE__ */ new Set();
541
- const addTokens = (tc) => {
542
- if (!tc) return;
543
- for (const entries of Object.values(tc)) {
544
- for (const t of entries) {
545
- allowedSet.add(`${t.chainId}:${t.address.toLowerCase()}`);
546
- }
547
- }
548
- };
549
- addTokens(fromTokenConfig);
550
- addTokens(toTokenConfig);
551
- if (allowedSet.size === 0) return allTokens;
552
- return allTokens.filter((t) => allowedSet.has(`${t.chain_id}:${t.address.toLowerCase()}`));
553
- }, [allTokens, config?.from?.chainTokens, config?.to?.chainTokens]);
663
+ const filteredChains = allChains;
664
+ const filteredTokens = allTokens;
554
665
  React5__namespace.default.useEffect(() => {
555
666
  if (filteredChains && !initialDataRef.current) {
556
667
  setChains(filteredChains);
@@ -888,6 +999,16 @@ var formatDate = (dateString) => {
888
999
  const formattedTime = `${month}/${day}/${year} ${hours}:${minutes}:${seconds}`;
889
1000
  return formattedTime;
890
1001
  };
1002
+ var dateFormatter = (isoString) => {
1003
+ const date = new Date(isoString);
1004
+ const month = String(date.getMonth() + 1).padStart(2, "0");
1005
+ const day = String(date.getDate()).padStart(2, "0");
1006
+ const year = date.getFullYear();
1007
+ const hours = String(date.getHours()).padStart(2, "0");
1008
+ const minutes = String(date.getMinutes()).padStart(2, "0");
1009
+ const seconds = String(date.getSeconds()).padStart(2, "0");
1010
+ return `${month}/${day}/${year} ${hours}:${minutes}:${seconds}`;
1011
+ };
891
1012
 
892
1013
  // src/utils/address.ts
893
1014
  var sliceAddress = (address, startLength = 4, endLength = 4) => {
@@ -959,25 +1080,6 @@ var isSolanaChain = (chain_id) => {
959
1080
  return chain_id === SOLANA_MAINNET.chain_id;
960
1081
  };
961
1082
 
962
- // src/utils/shortLinkRegex.ts
963
- var toRegex = /^\/[a-zA-Z0-9]+$/;
964
- var toAndTokenRegex = /^\/(?!from)[a-zA-Z0-9-+]+&[a-zA-Z0-9-+.₮Ï]+$/;
965
- var fromRegex = /^\/from&[a-zA-Z0-9-+]+$/;
966
- var fromAndTokenRegex = /^\/from&[a-zA-Z0-9-+]+&[a-zA-Z0-9-+.₮Ï]+$/;
967
- var fromAndToRegex = /^\/[a-zA-Z0-9-+]+\/[a-zA-Z0-9-+]+$/;
968
- var fromAndTokenAndToAndTokenRegex = /^\/[a-zA-Z0-9-+]+&[a-zA-Z0-9-+.₮Ï]+\/[a-zA-Z0-9-+]+&[a-zA-Z0-9-+.₮Ï]+$/;
969
- var allRegexPatterns = [
970
- toRegex,
971
- toAndTokenRegex,
972
- fromRegex,
973
- fromAndTokenRegex,
974
- fromAndToRegex,
975
- fromAndTokenAndToAndTokenRegex
976
- ];
977
- function matchesAnyPatternUsingArray(inputString) {
978
- return allRegexPatterns.some((regex) => regex.test(inputString));
979
- }
980
-
981
1083
  // src/utils/tokenSelectionCache.ts
982
1084
  var TOKEN_SELECTION = "tokenSelection";
983
1085
  var tokenSelectionStore = new localstorage_default(TOKEN_SELECTION);
@@ -1065,7 +1167,7 @@ var logger = {
1065
1167
  error: errorWithTimestamp,
1066
1168
  debug: debugWithTimestamp
1067
1169
  };
1068
- var wagmiSupportedChains = [chains$1.mainnet, chains$1.base, chains$1.soneium, chains$1.polygon, chains$1.arbitrum, chains$1.optimism];
1170
+ var wagmiSupportedChains = [chains$1.mainnet, chains$1.base, chains$1.soneium, chains$1.polygon, chains$1.arbitrum, chains$1.optimism, chains$1.bsc];
1069
1171
  var getTxLink = (txHash, chainId) => {
1070
1172
  if (isSolanaChain(chainId)) {
1071
1173
  return `${SOLANA_MAINNET.explorerUrl}/tx/${txHash}`;
@@ -1137,20 +1239,6 @@ var isSolanaChain2 = (chain_id) => {
1137
1239
  };
1138
1240
 
1139
1241
  // src/core/hooks/useSwapAndBridgeContextStore.ts
1140
- function findItemByName(arr, targetName) {
1141
- const foundItem = arr.find(
1142
- (item) => item.name.replace(/\s+/g, "").toLowerCase() === targetName.replace(/\s+/g, "").toLowerCase()
1143
- );
1144
- return [foundItem !== void 0, foundItem];
1145
- }
1146
- function findItemBySymbol(arr, targetName, chainId, platform_id) {
1147
- const foundItem = arr.find((item) => {
1148
- {
1149
- return item.symbol.replace(/\s+/g, "").toLowerCase() === targetName.replace(/\s+/g, "").toLowerCase() && item.chain_id === chainId;
1150
- }
1151
- });
1152
- return [foundItem !== void 0, foundItem];
1153
- }
1154
1242
  var DEFAULT_FROM_TOKEN = {
1155
1243
  name: "Base",
1156
1244
  address: viem.zeroAddress,
@@ -1253,8 +1341,6 @@ var useInitSwapAndBridgeState = (config) => {
1253
1341
  const {
1254
1342
  setFromTokenInfo,
1255
1343
  setToTokenInfo,
1256
- setIsShortLink,
1257
- setShortLink,
1258
1344
  setFromAmount,
1259
1345
  setToAmount
1260
1346
  } = useSwapAndBridgeContextStore();
@@ -1264,11 +1350,6 @@ var useInitSwapAndBridgeState = (config) => {
1264
1350
  const address = useEvmAddress();
1265
1351
  const { resetTxState } = useTxStateContextStore();
1266
1352
  const hasInitialized = React5.useRef(false);
1267
- const currentPathname = React5.useMemo(() => {
1268
- if (typeof window === "undefined") return "/";
1269
- return window.location.pathname;
1270
- }, []);
1271
- const pathname = currentPathname;
1272
1353
  React5.useEffect(() => {
1273
1354
  if (hasInitialized.current) return;
1274
1355
  if (!chains || !tokens) return;
@@ -1281,6 +1362,14 @@ var useInitSwapAndBridgeState = (config) => {
1281
1362
  (t) => t.chain_id === config.from?.defaultToken?.chainId && t.address.toLowerCase() === config.from?.defaultToken?.address.toLowerCase()
1282
1363
  );
1283
1364
  }
1365
+ if (!defaultToken) {
1366
+ const ct = config.from?.chainTokens?.[fromChain.chain_id];
1367
+ if (ct?.length) {
1368
+ defaultToken = tokens.find(
1369
+ (t) => t.chain_id === ct[0].chainId && t.address.toLowerCase() === ct[0].address.toLowerCase()
1370
+ );
1371
+ }
1372
+ }
1284
1373
  if (!defaultToken) {
1285
1374
  defaultToken = tokens.find(
1286
1375
  (t) => t.chain_id === fromChain.chain_id && t.address.toLowerCase() === fromChain.eth_token.toLowerCase()
@@ -1300,6 +1389,14 @@ var useInitSwapAndBridgeState = (config) => {
1300
1389
  (t) => t.chain_id === config.to?.defaultToken?.chainId && t.address.toLowerCase() === config.to?.defaultToken?.address.toLowerCase()
1301
1390
  );
1302
1391
  }
1392
+ if (!defaultToken) {
1393
+ const ct = config.to?.chainTokens?.[toChain.chain_id];
1394
+ if (ct?.length) {
1395
+ defaultToken = tokens.find(
1396
+ (t) => t.chain_id === ct[0].chainId && t.address.toLowerCase() === ct[0].address.toLowerCase()
1397
+ );
1398
+ }
1399
+ }
1303
1400
  if (!defaultToken) {
1304
1401
  defaultToken = tokens.find(
1305
1402
  (t) => t.chain_id === toChain.chain_id && t.address.toLowerCase() === toChain.eth_token.toLowerCase()
@@ -1310,49 +1407,15 @@ var useInitSwapAndBridgeState = (config) => {
1310
1407
  }
1311
1408
  }
1312
1409
  }
1313
- if (matchesAnyPatternUsingArray(pathname) && chains && tokens) {
1314
- setIsShortLink(true);
1315
- setShortLink(pathname);
1316
- try {
1317
- const decodedPath = decodeURIComponent(pathname);
1318
- const match = decodedPath.match(
1319
- /^\/([a-zA-Z0-9-+]+)&([a-zA-Z0-9-+.₮Ï]+)\/([a-zA-Z0-9-+]+)&([a-zA-Z0-9-+.₮Ï]+)$/
1320
- );
1321
- if (match) {
1322
- const [, fromChainName, fromTokenSymbol, toChainName, toTokenSymbol] = match;
1323
- const [, foundFromChain] = findItemByName(
1324
- chains,
1325
- fromChainName
1326
- );
1327
- const [, foundToChain] = findItemByName(
1328
- chains,
1329
- toChainName
1330
- );
1331
- if (foundFromChain && foundToChain && tokens) {
1332
- const [, foundFromToken] = findItemBySymbol(
1333
- tokens,
1334
- fromTokenSymbol,
1335
- foundFromChain.chain_id
1336
- );
1337
- const [, foundToToken] = findItemBySymbol(
1338
- tokens,
1339
- toTokenSymbol,
1340
- foundToChain.chain_id
1341
- );
1342
- if (foundFromToken && foundToToken) {
1343
- setFromTokenInfo(foundFromToken);
1344
- setToTokenInfo(foundToToken);
1345
- }
1346
- }
1347
- }
1348
- } catch {
1410
+ const hasConfigFrom = !!(config?.from?.defaultChainId || config?.from?.chainTokens || config?.from?.defaultToken);
1411
+ const hasConfigTo = !!(config?.to?.defaultChainId || config?.to?.chainTokens || config?.to?.defaultToken);
1412
+ if (!hasConfigFrom && !hasConfigTo) {
1413
+ const cached = tokenSelectionStore.get(address || "default");
1414
+ if (cached?.from && cached?.to) {
1415
+ setFromTokenInfo(cached.from);
1416
+ setToTokenInfo(cached.to);
1349
1417
  }
1350
1418
  }
1351
- const cached = tokenSelectionStore.get(address || "default");
1352
- if (cached?.from && cached?.to && !matchesAnyPatternUsingArray(pathname)) {
1353
- setFromTokenInfo(cached.from);
1354
- setToTokenInfo(cached.to);
1355
- }
1356
1419
  hasInitialized.current = true;
1357
1420
  return () => {
1358
1421
  setFromAmount("");
@@ -1361,15 +1424,12 @@ var useInitSwapAndBridgeState = (config) => {
1361
1424
  resetTxState();
1362
1425
  };
1363
1426
  }, [
1364
- pathname,
1365
1427
  address,
1366
1428
  chains,
1367
1429
  tokens,
1368
1430
  config,
1369
1431
  setFromTokenInfo,
1370
1432
  setToTokenInfo,
1371
- setIsShortLink,
1372
- setShortLink,
1373
1433
  setFromAmount,
1374
1434
  setToAmount,
1375
1435
  setDifferentAddress,
@@ -3405,6 +3465,12 @@ var FormButton = ({
3405
3465
  }) => {
3406
3466
  const { theme } = useWidgetTheme();
3407
3467
  const address = useEvmAddress();
3468
+ const {
3469
+ solanaWalletAddress,
3470
+ isSolanaWalletConnected,
3471
+ isEthWalletConnected,
3472
+ evmWalletConnectorId
3473
+ } = useWalletConnectedStore();
3408
3474
  const {
3409
3475
  address: wagmiAddress,
3410
3476
  connector,
@@ -3422,8 +3488,11 @@ var FormButton = ({
3422
3488
  return dynamicEvmWallet?.address || void 0;
3423
3489
  }, [userWallets]);
3424
3490
  const effectiveEvmAddress = React5.useMemo(
3425
- () => address || wagmiAddress || dynamicEvmWalletAddress || void 0,
3426
- [address, wagmiAddress, dynamicEvmWalletAddress]
3491
+ () => {
3492
+ if (!isEthWalletConnected) return void 0;
3493
+ return address || wagmiAddress || dynamicEvmWalletAddress || void 0;
3494
+ },
3495
+ [address, wagmiAddress, dynamicEvmWalletAddress, isEthWalletConnected]
3427
3496
  );
3428
3497
  const { openModal, openConnectModal } = useWalletConnectModal();
3429
3498
  const slippage = address ? slippageStore.get(address) : void 0;
@@ -3452,15 +3521,9 @@ var FormButton = ({
3452
3521
  } = useUSDTHandler(fromTokenInfo.chain_id);
3453
3522
  const { isSelectPredictionChain, slippagePolicies, chains } = useChainsStore();
3454
3523
  const { differentAddress } = useDifferentAddressStore();
3455
- const {
3456
- solanaWalletAddress,
3457
- isSolanaWalletConnected,
3458
- isEthWalletConnected,
3459
- evmWalletConnectorId
3460
- } = useWalletConnectedStore();
3461
3524
  const connectors = wagmi.useConnectors();
3462
3525
  const hasEvmUiWallet = Boolean(
3463
- effectiveEvmAddress || isEthWalletConnected || isWagmiConnected
3526
+ effectiveEvmAddress || isEthWalletConnected
3464
3527
  );
3465
3528
  const hasEvmExecutionWallet = Boolean(
3466
3529
  effectiveEvmAddress && (isWagmiConnected && connector || evmWalletConnectorId && connectors.some((c) => c.id === evmWalletConnectorId) || isEthWalletConnected && connectors.length > 0)
@@ -4227,13 +4290,13 @@ function filterTokenUnType(items, excludeTypes) {
4227
4290
  var mainnet3 = { id: 1 };
4228
4291
 
4229
4292
  // src/consts/monad.ts
4230
- var monad = { id: 10143 };
4293
+ var monad2 = { id: 10143 };
4231
4294
 
4232
4295
  // src/consts/stable.ts
4233
- var stable = { id: 1 };
4296
+ var stable2 = { id: 1 };
4234
4297
 
4235
4298
  // src/core/SelectTokenModal/hooks/useChainsAndTokensForSelect.ts
4236
- [mainnet3.id, chains.base.id, chains.ink.id, chains.bsc.id, monad.id, chains.soneium.id, stable.id];
4299
+ [mainnet3.id, chains.base.id, chains.ink.id, chains.bsc.id, monad2.id, chains.soneium.id, stable2.id];
4237
4300
  var useChainsAndTokensForSelect = ({
4238
4301
  data,
4239
4302
  selectedChain,
@@ -4699,20 +4762,6 @@ function countLeadingZerosAfterDecimal(numStr) {
4699
4762
  if (firstNonZeroIndex === -1) return 0;
4700
4763
  return firstNonZeroIndex;
4701
4764
  }
4702
- function findItemByName2(arr, targetName) {
4703
- const foundItem = arr.find(
4704
- (item) => item.name.replace(/\s+/g, "").toLowerCase() === targetName.replace(/\s+/g, "").toLowerCase()
4705
- );
4706
- return [foundItem !== void 0, foundItem];
4707
- }
4708
- function findItemBySymbol2(arr, targetName, chainId, platform_id) {
4709
- const foundItem = arr.find((item) => {
4710
- {
4711
- return item.symbol.replace(/\s+/g, "").toLowerCase() === targetName.replace(/\s+/g, "").toLowerCase() && item.chain_id === chainId;
4712
- }
4713
- });
4714
- return [foundItem !== void 0, foundItem];
4715
- }
4716
4765
  var TokenAmountHeading = ({
4717
4766
  amount,
4718
4767
  decimals,
@@ -4720,13 +4769,14 @@ var TokenAmountHeading = ({
4720
4769
  suffix,
4721
4770
  ...props
4722
4771
  }) => {
4772
+ const { theme } = useWidgetTheme();
4723
4773
  const _amount = formatTokenAmount({
4724
4774
  amount,
4725
4775
  decimals
4726
4776
  });
4727
4777
  const leadingZeros = countLeadingZerosAfterDecimal(_amount);
4728
4778
  if (leadingZeros > 5) {
4729
- return /* @__PURE__ */ jsxRuntime.jsxs(Heading, { variant: "heading8", ...props, as: "div", children: [
4779
+ return /* @__PURE__ */ jsxRuntime.jsxs(Heading, { variant: "heading8", ...props, as: "div", color: theme.defaultTextColor, whiteSpace: "nowrap", children: [
4730
4780
  prefix,
4731
4781
  " ",
4732
4782
  _amount.slice(0, 3),
@@ -4745,7 +4795,7 @@ var TokenAmountHeading = ({
4745
4795
  suffix
4746
4796
  ] });
4747
4797
  }
4748
- return /* @__PURE__ */ jsxRuntime.jsxs(Heading, { variant: "heading11", ...props, as: "div", children: [
4798
+ return /* @__PURE__ */ jsxRuntime.jsxs(Heading, { variant: "heading11", ...props, as: "div", color: theme.defaultTextColor, whiteSpace: "nowrap", children: [
4749
4799
  prefix,
4750
4800
  " ",
4751
4801
  _amount,
@@ -6293,6 +6343,7 @@ var SelectTokenModal = ({
6293
6343
  allTokens: tokens
6294
6344
  });
6295
6345
  const { userHasSelectedFromNetwork, setUserHasSelectedFromNetwork } = useUserHasSelectedFromNetwork();
6346
+ const prevUserHasSelectedRef = React5.useRef(userHasSelectedFromNetwork);
6296
6347
  const { chains } = useChainsStore();
6297
6348
  const [disableTestnetLimit, setDisableTestnetLimit] = React5.useState(false);
6298
6349
  const [tempSelectAll, setTempSelectAll] = React5.useState(false);
@@ -6327,6 +6378,8 @@ var SelectTokenModal = ({
6327
6378
  setTempSelectedPlatformId(null);
6328
6379
  }
6329
6380
  }
6381
+ const userJustSelected = userHasSelectedFromNetwork && !prevUserHasSelectedRef.current;
6382
+ prevUserHasSelectedRef.current = userHasSelectedFromNetwork;
6330
6383
  if (isSelectingFromToken) {
6331
6384
  if (isLoadingUserBalances) return;
6332
6385
  if (isArcTestnetShortLink) {
@@ -6340,7 +6393,9 @@ var SelectTokenModal = ({
6340
6393
  setSelectedChain(null);
6341
6394
  } else {
6342
6395
  setIsSelectAll(false);
6343
- setSelectedChain(fromChainId);
6396
+ if (!userJustSelected) {
6397
+ setSelectedChain(fromChainId);
6398
+ }
6344
6399
  }
6345
6400
  } else {
6346
6401
  setIsSelectAll(false);
@@ -8322,127 +8377,6 @@ var FormBody = ({
8322
8377
  const { tokens } = useTokensStore();
8323
8378
  const [isFromHyperChain, setIsFromHyperChain] = React5.useState(false);
8324
8379
  const [isToHyperChain, setIsToHyperChain] = React5.useState(false);
8325
- const pathname = typeof window !== "undefined" ? window.location.pathname : "";
8326
- const replaceLink = React5.useCallback((url) => {
8327
- if (typeof window !== "undefined") {
8328
- window.history.replaceState(null, "", url);
8329
- }
8330
- }, []);
8331
- const updateSearchParams = React5.useCallback(
8332
- (params) => {
8333
- if (typeof window === "undefined") return;
8334
- const searchParams = window?.location?.search;
8335
- const newParams = new URLSearchParams(searchParams);
8336
- Object.entries(params).forEach(([key, value]) => {
8337
- newParams.set(key, value);
8338
- });
8339
- const newPath = decodeURIComponent(pathname.replace(/\/+$/, ""));
8340
- if (tokens && chains && matchesAnyPatternUsingArray(newPath)) {
8341
- if (toRegex.test(newPath)) {
8342
- const [exists, chainsInfo2] = findItemByName2(
8343
- chains || [],
8344
- newPath.replace("/", "")
8345
- );
8346
- if (!exists) return;
8347
- const foundItem = tokens.find(
8348
- (item) => item.chain_id === chainsInfo2?.chain_id
8349
- );
8350
- if (foundItem) {
8351
- newParams.set("to_chain", foundItem.chain_id.toString());
8352
- newParams.set("to_token", foundItem.address.toString());
8353
- }
8354
- } else if (toAndTokenRegex.test(newPath)) {
8355
- const arr = newPath.replace("/", "").split("&");
8356
- const [exists, chainsInfo2] = findItemByName2(chains, arr[0]);
8357
- if (!exists) return;
8358
- const [result, foundItem] = findItemBySymbol2(
8359
- tokens,
8360
- arr[1],
8361
- chainsInfo2?.chain_id
8362
- );
8363
- if (!result) return;
8364
- if (result && foundItem) {
8365
- newParams.set("to_chain", foundItem.chain_id.toString());
8366
- newParams.set("to_token", foundItem.address.toString());
8367
- }
8368
- } else if (fromRegex.test(newPath)) {
8369
- const arr = newPath.split("&");
8370
- const [exists, chainsInfo2] = findItemByName2(chains, arr[1]);
8371
- if (!exists) return;
8372
- const foundItem = tokens.find(
8373
- (item) => item.chain_id === chainsInfo2?.chain_id
8374
- );
8375
- if (foundItem) {
8376
- newParams.set("from_chain", foundItem.chain_id.toString());
8377
- newParams.set("from_token", foundItem.address.toString());
8378
- }
8379
- } else if (fromAndTokenRegex.test(newPath)) {
8380
- const arr = newPath.replace("/", "").split("&");
8381
- const [exists, chainsInfo2] = findItemByName2(chains, arr[0]);
8382
- if (!exists) return;
8383
- const [result, foundItem] = findItemBySymbol2(
8384
- tokens,
8385
- arr[1],
8386
- chainsInfo2?.chain_id
8387
- );
8388
- if (!result) return;
8389
- if (result && foundItem) {
8390
- newParams.set("from_chain", foundItem.chain_id.toString());
8391
- newParams.set("from_token", foundItem.address.toString());
8392
- }
8393
- } else if (fromAndToRegex.test(newPath)) {
8394
- const arr = newPath.split("/");
8395
- const [resultFrom, fromChainsInfo] = findItemByName2(chains, arr[1]);
8396
- if (!resultFrom) return;
8397
- const foundFromItem = tokens.find(
8398
- (item) => item.chain_id === fromChainsInfo?.chain_id
8399
- );
8400
- if (!foundFromItem) return;
8401
- newParams.set("from_chain", foundFromItem.chain_id.toString());
8402
- newParams.set("from_token", foundFromItem.address.toString());
8403
- const [resultTo, toChainsInfo] = findItemByName2(chains, arr[2]);
8404
- if (!resultTo) return;
8405
- const foundToItem = tokens.find(
8406
- (item) => item.chain_id === toChainsInfo?.chain_id
8407
- );
8408
- if (!foundToItem) return;
8409
- newParams.set("to_chain", foundToItem.chain_id.toString());
8410
- newParams.set("to_token", foundToItem.address.toString());
8411
- } else if (fromAndTokenAndToAndTokenRegex.test(newPath)) {
8412
- const arr = newPath.split("/");
8413
- const arrFrom = arr[1].split("&");
8414
- const [resultFrom, fromChainsInfo] = findItemByName2(
8415
- chains,
8416
- arrFrom[0]
8417
- );
8418
- if (!resultFrom) return;
8419
- const [resultFromToken, fromTokenInfo2] = findItemBySymbol2(
8420
- tokens,
8421
- arrFrom[1],
8422
- fromChainsInfo?.chain_id
8423
- );
8424
- if (!resultFromToken) return;
8425
- const arrTo = arr[2].split("&");
8426
- const [resultTo, toChainsInfo] = findItemByName2(chains, arrTo[0]);
8427
- if (!resultTo) return;
8428
- const [resultToToken, toTokenInfo2] = findItemBySymbol2(
8429
- tokens,
8430
- arrTo[1],
8431
- toChainsInfo?.chain_id
8432
- );
8433
- if (!resultToToken) return;
8434
- if (fromTokenInfo2 && toTokenInfo2) {
8435
- newParams.set("to_chain", toTokenInfo2.chain_id.toString());
8436
- newParams.set("to_token", toTokenInfo2.address.toString());
8437
- newParams.set("from_chain", fromTokenInfo2.chain_id.toString());
8438
- newParams.set("from_token", fromTokenInfo2.address.toString());
8439
- }
8440
- }
8441
- }
8442
- replaceLink(`${pathname.replace(pathname, "")}/?${newParams.toString()}`);
8443
- },
8444
- [pathname, replaceLink, chains, tokens]
8445
- );
8446
8380
  const [isModalOpen, setIsModalOpen] = React5.useState(false);
8447
8381
  const [isDifferentAddressDialogOpen, setIsDifferentAddressDialogOpen] = React5.useState(false);
8448
8382
  const [isSelectingFromToken, setIsSelectingFromToken] = React5.useState(false);
@@ -8653,15 +8587,12 @@ var FormBody = ({
8653
8587
  }, [tokens]);
8654
8588
  const handleSelectToken = React5.useCallback(
8655
8589
  (tokenInfo) => {
8656
- const params = {};
8657
8590
  const isTestnetChain = (chainId) => {
8658
8591
  const chainInfo = chains?.find((chain) => chain.chain_id === chainId);
8659
8592
  return chainInfo?.is_testnet === true;
8660
8593
  };
8661
8594
  if (isSelectingFromToken) {
8662
8595
  setFromTokenInfo(tokenInfo);
8663
- params.from_chain = tokenInfo.chain_id.toString();
8664
- params.from_token = tokenInfo.address;
8665
8596
  if (isTestnetChain(tokenInfo.chain_id)) {
8666
8597
  const isNativeToken = tokenInfo.tags?.includes("native") || tokenInfo.address === viem.zeroAddress;
8667
8598
  if (isNativeToken) {
@@ -8670,8 +8601,6 @@ var FormBody = ({
8670
8601
  );
8671
8602
  if (otherToken) {
8672
8603
  setToTokenInfo(otherToken);
8673
- params.to_chain = otherToken.chain_id.toString();
8674
- params.to_token = otherToken.address;
8675
8604
  }
8676
8605
  } else {
8677
8606
  const nativeToken = tokens?.find(
@@ -8679,16 +8608,12 @@ var FormBody = ({
8679
8608
  );
8680
8609
  if (nativeToken && (nativeToken.chain_id !== toTokenInfo?.chain_id || nativeToken.address !== toTokenInfo?.address)) {
8681
8610
  setToTokenInfo(nativeToken);
8682
- params.to_chain = nativeToken.chain_id.toString();
8683
- params.to_token = nativeToken.address;
8684
8611
  } else if (!nativeToken) {
8685
8612
  const otherToken = tokens?.find(
8686
8613
  (t) => t.chain_id === tokenInfo.chain_id && t.address !== tokenInfo.address
8687
8614
  );
8688
8615
  if (otherToken) {
8689
8616
  setToTokenInfo(otherToken);
8690
- params.to_chain = otherToken.chain_id.toString();
8691
- params.to_token = otherToken.address;
8692
8617
  }
8693
8618
  }
8694
8619
  }
@@ -8699,15 +8624,11 @@ var FormBody = ({
8699
8624
  );
8700
8625
  if (baseEthToken) {
8701
8626
  setToTokenInfo(baseEthToken);
8702
- params.to_chain = baseEthToken.chain_id.toString();
8703
- params.to_token = baseEthToken.address;
8704
8627
  }
8705
8628
  }
8706
8629
  }
8707
8630
  } else {
8708
8631
  setToTokenInfo(tokenInfo);
8709
- params.to_chain = tokenInfo.chain_id.toString();
8710
- params.to_token = tokenInfo.address;
8711
8632
  if (isTestnetChain(tokenInfo.chain_id)) {
8712
8633
  const isNativeToken = tokenInfo.tags?.includes("native") || tokenInfo.address === viem.zeroAddress;
8713
8634
  if (isNativeToken) {
@@ -8716,8 +8637,6 @@ var FormBody = ({
8716
8637
  );
8717
8638
  if (otherToken) {
8718
8639
  setFromTokenInfo(otherToken);
8719
- params.from_chain = otherToken.chain_id.toString();
8720
- params.from_token = otherToken.address;
8721
8640
  }
8722
8641
  } else {
8723
8642
  const nativeToken = tokens?.find(
@@ -8725,16 +8644,12 @@ var FormBody = ({
8725
8644
  );
8726
8645
  if (nativeToken && (nativeToken.chain_id !== fromTokenInfo?.chain_id || nativeToken.address !== fromTokenInfo?.address)) {
8727
8646
  setFromTokenInfo(nativeToken);
8728
- params.from_chain = nativeToken.chain_id.toString();
8729
- params.from_token = nativeToken.address;
8730
8647
  } else if (!nativeToken) {
8731
8648
  const otherToken = tokens?.find(
8732
8649
  (t) => t.chain_id === tokenInfo.chain_id && t.address !== tokenInfo.address
8733
8650
  );
8734
8651
  if (otherToken) {
8735
8652
  setFromTokenInfo(otherToken);
8736
- params.from_chain = otherToken.chain_id.toString();
8737
- params.from_token = otherToken.address;
8738
8653
  }
8739
8654
  }
8740
8655
  }
@@ -8745,13 +8660,10 @@ var FormBody = ({
8745
8660
  );
8746
8661
  if (soneiumEthToken) {
8747
8662
  setFromTokenInfo(soneiumEthToken);
8748
- params.from_chain = soneiumEthToken.chain_id.toString();
8749
- params.from_token = soneiumEthToken.address;
8750
8663
  }
8751
8664
  }
8752
8665
  }
8753
8666
  }
8754
- updateSearchParams(params);
8755
8667
  handleCloseModal();
8756
8668
  setQuoteInfo(initialQuoteInfo);
8757
8669
  saveTokenSelection();
@@ -8762,7 +8674,6 @@ var FormBody = ({
8762
8674
  setFromTokenInfo,
8763
8675
  setQuoteInfo,
8764
8676
  setToTokenInfo,
8765
- updateSearchParams,
8766
8677
  tokens,
8767
8678
  fromTokenInfo,
8768
8679
  toTokenInfo,
@@ -8780,12 +8691,6 @@ var FormBody = ({
8780
8691
  const _fromAmount = toAmount;
8781
8692
  setDifferentAddress(void 0);
8782
8693
  switchTokens();
8783
- updateSearchParams({
8784
- from_chain: _fromTokenInfo.chain_id.toString(),
8785
- from_token: _fromTokenInfo.address,
8786
- to_chain: _toTokenInfo.chain_id.toString(),
8787
- to_token: _toTokenInfo.address
8788
- });
8789
8694
  const _fromAddress = () => {
8790
8695
  if (_fromTokenInfo.isSolana) {
8791
8696
  return solanaWalletAddress || "";
@@ -9140,7 +9045,9 @@ var SlippageSettings = ({ refetchQuote }) => {
9140
9045
  base: "20px",
9141
9046
  md: "22px"
9142
9047
  },
9143
- as: SettingsIcon
9048
+ as: SettingsIcon,
9049
+ position: "relative",
9050
+ top: "-2px"
9144
9051
  }
9145
9052
  ),
9146
9053
  showYellowDot && /* @__PURE__ */ jsxRuntime.jsx(
@@ -9367,10 +9274,92 @@ var FormTop = ({
9367
9274
  quoteInfo,
9368
9275
  clearLockedRequestId,
9369
9276
  refreshInterval = 30,
9370
- hideCountdown = false
9277
+ hideCountdown = false,
9278
+ onHistoryClick
9371
9279
  }) => {
9372
9280
  const { isLoading: isLoadingRefresh } = useRefreshLoading();
9373
9281
  const { theme } = useWidgetTheme();
9282
+ const { disconnect } = wagmi.useDisconnect();
9283
+ const connectors = wagmi.useConnectors();
9284
+ const { connector: wagmiConnector } = wagmi.useAccount();
9285
+ const { removeWallet } = sdkReactCore.useDynamicContext();
9286
+ const userWallets = sdkReactCore.useUserWallets();
9287
+ const {
9288
+ isEthWalletConnected,
9289
+ evmWalletConnectorId,
9290
+ isSolanaWalletConnected,
9291
+ setEvmWalletInfo,
9292
+ setIsEthWalletConnected,
9293
+ setSolanaWalletAddress,
9294
+ setIsSolanaWalletConnected,
9295
+ setIsLoggingOut: setStoreLoggingOut,
9296
+ setLastDisconnectTimestamp
9297
+ } = useWalletConnectedStore();
9298
+ const isAnyWalletConnected = isEthWalletConnected || isSolanaWalletConnected;
9299
+ const [isLogoutDialogOpen, setIsLogoutDialogOpen] = React5.useState(false);
9300
+ const [isLoggingOut, setIsLoggingOut] = React5.useState(false);
9301
+ const handleLogout = React5.useCallback(async () => {
9302
+ setIsLoggingOut(true);
9303
+ setStoreLoggingOut(true);
9304
+ const currentEvmConnectorId = evmWalletConnectorId;
9305
+ try {
9306
+ for (const wallet of userWallets) {
9307
+ const walletId = wallet.id || wallet.walletId;
9308
+ if (walletId) {
9309
+ try {
9310
+ await removeWallet(walletId);
9311
+ } catch (e) {
9312
+ console.error("Dynamic removeWallet failed:", e);
9313
+ }
9314
+ }
9315
+ }
9316
+ const evmConnector = connectors.find((c) => c.id === currentEvmConnectorId);
9317
+ if (evmConnector) {
9318
+ disconnect({ connector: evmConnector });
9319
+ } else if (wagmiConnector) {
9320
+ disconnect({ connector: wagmiConnector });
9321
+ }
9322
+ if (typeof window !== "undefined") {
9323
+ window.localStorage.removeItem("wagmi.cache");
9324
+ window.localStorage.removeItem("wagmi.wallet");
9325
+ window.sessionStorage.removeItem("wagmi.cache");
9326
+ window.sessionStorage.removeItem("wagmi.wallet");
9327
+ const storages = [window.localStorage, window.sessionStorage];
9328
+ storages.forEach((storage) => {
9329
+ const keysToRemove = [];
9330
+ for (let i = 0; i < storage.length; i++) {
9331
+ const key = storage.key(i);
9332
+ if (key && (key.startsWith("dynamic_") || key.includes("_dynamic_"))) {
9333
+ keysToRemove.push(key);
9334
+ }
9335
+ }
9336
+ keysToRemove.forEach((key) => storage.removeItem(key));
9337
+ });
9338
+ }
9339
+ setEvmWalletInfo(null, null);
9340
+ setIsEthWalletConnected(false);
9341
+ setSolanaWalletAddress(null);
9342
+ setIsSolanaWalletConnected(false);
9343
+ setLastDisconnectTimestamp(Date.now());
9344
+ } finally {
9345
+ setStoreLoggingOut(false);
9346
+ setIsLoggingOut(false);
9347
+ setIsLogoutDialogOpen(false);
9348
+ }
9349
+ }, [
9350
+ userWallets,
9351
+ removeWallet,
9352
+ connectors,
9353
+ evmWalletConnectorId,
9354
+ wagmiConnector,
9355
+ disconnect,
9356
+ setEvmWalletInfo,
9357
+ setIsEthWalletConnected,
9358
+ setSolanaWalletAddress,
9359
+ setIsSolanaWalletConnected,
9360
+ setStoreLoggingOut,
9361
+ setLastDisconnectTimestamp
9362
+ ]);
9374
9363
  const isPolling = Boolean(quoteInfo?.request_id && !isLoadingRefresh);
9375
9364
  const [countdown, setCountdown] = React5.useState(refreshInterval);
9376
9365
  React5.useEffect(() => {
@@ -9408,7 +9397,24 @@ var FormTop = ({
9408
9397
  children: "Bridge & Swap"
9409
9398
  }
9410
9399
  ),
9411
- /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { color: theme.weakTextColor || "#81728C", children: [
9400
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { color: theme.weakTextColor, children: [
9401
+ isAnyWalletConnected && /* @__PURE__ */ jsxRuntime.jsx(
9402
+ react.Box,
9403
+ {
9404
+ w: "21px",
9405
+ h: "21px",
9406
+ display: "flex",
9407
+ alignItems: "center",
9408
+ justifyContent: "center",
9409
+ cursor: "pointer",
9410
+ onClick: onHistoryClick,
9411
+ title: "Transaction history",
9412
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 32 32", children: [
9413
+ /* @__PURE__ */ jsxRuntime.jsx("path", { fill: theme.weakTextColor, d: "M14 2l-8 8v20h22v-28h-14zM14 4.8v5.2h-5.2l5.2-5.2zM26 28h-18v-16h8v-8h10v24z" }),
9414
+ /* @__PURE__ */ jsxRuntime.jsx("path", { fill: theme.weakTextColor, d: "M10 14h14v2h-14v-2zM10 18h14v2h-14v-2zM10 22h14v2h-14v-2z" })
9415
+ ] })
9416
+ }
9417
+ ),
9412
9418
  /* @__PURE__ */ jsxRuntime.jsxs(
9413
9419
  react.HStack,
9414
9420
  {
@@ -9478,8 +9484,36 @@ var FormTop = ({
9478
9484
  ]
9479
9485
  }
9480
9486
  ),
9481
- /* @__PURE__ */ jsxRuntime.jsx(SlippageSettings, { refetchQuote })
9482
- ] })
9487
+ /* @__PURE__ */ jsxRuntime.jsx(SlippageSettings, { refetchQuote }),
9488
+ isAnyWalletConnected && /* @__PURE__ */ jsxRuntime.jsx(
9489
+ react.HStack,
9490
+ {
9491
+ w: "30px",
9492
+ h: "30px",
9493
+ display: "flex",
9494
+ alignItems: "center",
9495
+ justifyContent: "center",
9496
+ cursor: "pointer",
9497
+ title: "Disconnect all wallets",
9498
+ onClick: () => setIsLogoutDialogOpen(true),
9499
+ children: /* @__PURE__ */ jsxRuntime.jsx(io.IoMdLogOut, { style: { width: "22px", height: "22px" }, color: theme.weakTextColor })
9500
+ }
9501
+ )
9502
+ ] }),
9503
+ /* @__PURE__ */ jsxRuntime.jsx(react.Dialog.Root, { open: isLogoutDialogOpen, onOpenChange: (e) => setIsLogoutDialogOpen(e.open), children: /* @__PURE__ */ jsxRuntime.jsxs(react.Portal, { children: [
9504
+ /* @__PURE__ */ jsxRuntime.jsx(react.Dialog.Backdrop, {}),
9505
+ /* @__PURE__ */ jsxRuntime.jsx(react.Dialog.Positioner, { justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxRuntime.jsxs(react.Dialog.Content, { bgColor: theme.defaultBgColor, color: theme.defaultTextColor, width: ["90vw", "400px"], children: [
9506
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Dialog.Header, { justifyContent: "center", children: [
9507
+ /* @__PURE__ */ jsxRuntime.jsx(react.Dialog.Title, { padding: "15px 0", children: "Disconnect Wallet" }),
9508
+ /* @__PURE__ */ jsxRuntime.jsx(react.Dialog.CloseTrigger, {})
9509
+ ] }),
9510
+ /* @__PURE__ */ jsxRuntime.jsx(react.Dialog.Body, { marginBottom: "20px", children: /* @__PURE__ */ jsxRuntime.jsx(react.Text, { textAlign: "center", padding: ["0 15px", "0 30px"], children: "This operation will disconnect all connected wallets." }) }),
9511
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Dialog.Footer, { padding: ["10px 20px 20px"], justifyContent: "center", children: [
9512
+ /* @__PURE__ */ jsxRuntime.jsx(react.Dialog.ActionTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Button, { variant: "outline", disabled: isLoggingOut, w: "100px", bgColor: theme.normalButtonBg, color: theme.normalButtonText, children: "Cancel" }) }),
9513
+ /* @__PURE__ */ jsxRuntime.jsx(react.Button, { bgColor: theme.highlightButtonBg, color: theme.highlightButtonText, onClick: handleLogout, loading: isLoggingOut, w: "100px", children: "Disconnect" })
9514
+ ] })
9515
+ ] }) })
9516
+ ] }) })
9483
9517
  ] });
9484
9518
  };
9485
9519
  var Timer = ({ stop, onTick }) => {
@@ -10440,6 +10474,381 @@ var TxState = ({
10440
10474
  }
10441
10475
  ) });
10442
10476
  };
10477
+ async function getOrderHistory(address, offset = 0, limit = 4) {
10478
+ const url = `${BASE_API_URL}/v1/orders`;
10479
+ const res = await axios6__default.default.get(url, {
10480
+ params: {
10481
+ address: Array.isArray(address) ? address : [address],
10482
+ offset,
10483
+ limit
10484
+ },
10485
+ paramsSerializer: {
10486
+ indexes: null
10487
+ }
10488
+ });
10489
+ return res.data;
10490
+ }
10491
+ var useOrderHistory = (address, address2, offset, limit) => {
10492
+ const addresses = address && address2 ? [address, address2] : address;
10493
+ return reactQuery.useQuery({
10494
+ queryKey: ["orderHistory", addresses, offset],
10495
+ queryFn: () => addresses ? getOrderHistory(addresses, offset, limit) : Promise.reject("No address provided"),
10496
+ enabled: !!addresses,
10497
+ placeholderData: reactQuery.keepPreviousData,
10498
+ refetchOnWindowFocus: false
10499
+ });
10500
+ };
10501
+ function SuccessIcon() {
10502
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Box, { w: "16px", h: "16px", borderRadius: "full", bg: "#00CBB3", display: "flex", alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "10", height: "8", viewBox: "0 0 10 8", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M1 4L3.5 6.5L9 1", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) });
10503
+ }
10504
+ function ErrorIcon() {
10505
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Box, { w: "16px", h: "16px", borderRadius: "full", bg: "#FF4267", display: "flex", alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "8", height: "8", viewBox: "0 0 8 8", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M1 1L7 7M7 1L1 7", stroke: "white", strokeWidth: "1.5", strokeLinecap: "round" }) }) });
10506
+ }
10507
+ function PendingIcon() {
10508
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Box, { w: "16px", h: "16px", borderRadius: "full", bg: "#FFD200", display: "flex", alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "8", height: "8", viewBox: "0 0 8 8", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "4", cy: "4", r: "3", stroke: "white", strokeWidth: "1.5" }) }) });
10509
+ }
10510
+ function getStatusIcon(status) {
10511
+ switch (status) {
10512
+ case "Filled":
10513
+ return /* @__PURE__ */ jsxRuntime.jsx(SuccessIcon, {});
10514
+ case "Refund":
10515
+ case "Failed":
10516
+ return /* @__PURE__ */ jsxRuntime.jsx(ErrorIcon, {});
10517
+ case "Open":
10518
+ return /* @__PURE__ */ jsxRuntime.jsx(PendingIcon, {});
10519
+ default:
10520
+ return /* @__PURE__ */ jsxRuntime.jsx(SuccessIcon, {});
10521
+ }
10522
+ }
10523
+ function OrderHistoryItem({ order }) {
10524
+ const { theme } = useWidgetTheme();
10525
+ const fromTokenInfo = order.from_token_info;
10526
+ const toTokenInfo = order.to_token_info;
10527
+ const isSameChainSwap = order.from_chain === order.to_chain;
10528
+ const renderTxLink = (txHash, chainId, label) => {
10529
+ const link = getTxLink(txHash, chainId);
10530
+ if (!link) {
10531
+ return /* @__PURE__ */ jsxRuntime.jsx(Text2, { variant: "content8", color: theme.defaultTextColor, children: sliceAddress(txHash, 6) });
10532
+ }
10533
+ return /* @__PURE__ */ jsxRuntime.jsx("a", { href: link, target: "_blank", rel: "noreferrer", style: { textDecoration: "none" }, children: /* @__PURE__ */ jsxRuntime.jsx(react.HStack, { gap: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text2, { variant: "content8", color: theme.highlightTextColor, children: sliceAddress(txHash, 6) }) }) });
10534
+ };
10535
+ return /* @__PURE__ */ jsxRuntime.jsxs(
10536
+ react.Box,
10537
+ {
10538
+ w: "100%",
10539
+ borderRadius: "12px",
10540
+ p: "10px 15px",
10541
+ bg: theme.assistBgColor,
10542
+ _hover: { bg: theme.highlightBgColor },
10543
+ transition: "background 0.15s",
10544
+ children: [
10545
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { justify: "center", mb: 2, children: [
10546
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { gap: 1.5, children: [
10547
+ getStatusIcon(isSameChainSwap ? "Filled" : order.status),
10548
+ /* @__PURE__ */ jsxRuntime.jsx(
10549
+ Text2,
10550
+ {
10551
+ variant: "content7",
10552
+ color: theme.defaultTextColor || "#15003E",
10553
+ fontWeight: 500,
10554
+ children: isSameChainSwap ? "Filled" : order.status
10555
+ }
10556
+ )
10557
+ ] }),
10558
+ /* @__PURE__ */ jsxRuntime.jsx(Text2, { variant: "content8", color: theme.weakTextColor || "#81728C", children: dateFormatter(order.open_timestamp) })
10559
+ ] }),
10560
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { justify: "space-between", w: "100%", children: [
10561
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { gap: 2, mb: 1.5, children: [
10562
+ /* @__PURE__ */ jsxRuntime.jsx(react.Box, { w: "32px", h: "32px", flexShrink: 0, marginRight: "10px", children: /* @__PURE__ */ jsxRuntime.jsx(
10563
+ TokenIconWithNetworkLogo,
10564
+ {
10565
+ w: "100%",
10566
+ h: "100%",
10567
+ tokenInfo: fromTokenInfo
10568
+ }
10569
+ ) }),
10570
+ /* @__PURE__ */ jsxRuntime.jsxs(react.VStack, { align: "start", gap: 0.5, flex: 1, w: "80px", children: [
10571
+ /* @__PURE__ */ jsxRuntime.jsx(
10572
+ TokenAmountHeading,
10573
+ {
10574
+ amount: new biFraction.Fraction(order.from_amount),
10575
+ decimals: fromTokenInfo?.decimals,
10576
+ suffix: fromTokenInfo?.symbol,
10577
+ variant: "heading12"
10578
+ }
10579
+ ),
10580
+ /* @__PURE__ */ jsxRuntime.jsx(react.HStack, { gap: 1, children: renderTxLink(order.open_tx_hash, order.from_chain) })
10581
+ ] })
10582
+ ] }),
10583
+ /* @__PURE__ */ jsxRuntime.jsx(react.HStack, { justify: "center", my: 0.5, flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(hi2.HiMiniArrowRight, { color: theme.weakTextColor, width: "30px", height: "30px" }) }),
10584
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { gap: 2, mt: 0, children: [
10585
+ /* @__PURE__ */ jsxRuntime.jsxs(react.VStack, { align: "start", gap: 0.5, flex: 1, w: "80px", children: [
10586
+ /* @__PURE__ */ jsxRuntime.jsx(
10587
+ TokenAmountHeading,
10588
+ {
10589
+ amount: new biFraction.Fraction(order.to_amount || order.amount_out || "0"),
10590
+ decimals: toTokenInfo?.decimals,
10591
+ suffix: toTokenInfo?.symbol,
10592
+ variant: "heading12",
10593
+ justifyContent: "flex-end",
10594
+ width: "100%",
10595
+ display: "flex"
10596
+ }
10597
+ ),
10598
+ /* @__PURE__ */ jsxRuntime.jsx(react.HStack, { gap: 1, justifyContent: "flex-end", w: "100%", children: isSameChainSwap ? renderTxLink(order.open_tx_hash, order.from_chain) : order.fill_tx_hash ? renderTxLink(order.fill_tx_hash, order.to_chain) : /* @__PURE__ */ jsxRuntime.jsx(Text2, { variant: "content8", color: theme.defaultTextColor, children: "Receiving..." }) })
10599
+ ] }),
10600
+ /* @__PURE__ */ jsxRuntime.jsx(react.Box, { w: "32px", h: "32px", flexShrink: 0, marginRight: "10px", marginLeft: "3px", children: /* @__PURE__ */ jsxRuntime.jsx(
10601
+ TokenIconWithNetworkLogo,
10602
+ {
10603
+ w: "100%",
10604
+ h: "100%",
10605
+ tokenInfo: toTokenInfo
10606
+ }
10607
+ ) })
10608
+ ] })
10609
+ ] })
10610
+ ]
10611
+ }
10612
+ );
10613
+ }
10614
+ var PaginationButton = ({
10615
+ currentPage,
10616
+ page,
10617
+ onClick
10618
+ }) => {
10619
+ const { theme } = useWidgetTheme();
10620
+ return /* @__PURE__ */ jsxRuntime.jsx(
10621
+ react.Box,
10622
+ {
10623
+ bg: currentPage === page ? theme.highlightButtonBg : "transparent",
10624
+ color: currentPage === page ? theme.highlightButtonText : theme.weakTextColor,
10625
+ w: "24px",
10626
+ h: "24px",
10627
+ borderRadius: "full",
10628
+ display: "flex",
10629
+ alignItems: "center",
10630
+ justifyContent: "center",
10631
+ cursor: "pointer",
10632
+ onClick,
10633
+ fontSize: "12px",
10634
+ fontWeight: 500,
10635
+ transition: "all 0.2s",
10636
+ children: page
10637
+ }
10638
+ );
10639
+ };
10640
+ function OrderHistoryPagination({
10641
+ currentPage,
10642
+ totalPages,
10643
+ setCurrentPage
10644
+ }) {
10645
+ const { theme } = useWidgetTheme();
10646
+ const handlePrevious = () => {
10647
+ if (currentPage > 1) setCurrentPage(currentPage - 1);
10648
+ };
10649
+ const handleNext = () => {
10650
+ if (currentPage < totalPages) setCurrentPage(currentPage + 1);
10651
+ };
10652
+ if (totalPages <= 1) return null;
10653
+ return /* @__PURE__ */ jsxRuntime.jsxs(
10654
+ react.HStack,
10655
+ {
10656
+ justify: "space-between",
10657
+ align: "center",
10658
+ pt: 2,
10659
+ pb: 1,
10660
+ gap: 2,
10661
+ w: "100%",
10662
+ children: [
10663
+ /* @__PURE__ */ jsxRuntime.jsx(
10664
+ react.Button,
10665
+ {
10666
+ variant: "plain",
10667
+ onClick: handlePrevious,
10668
+ disabled: currentPage === 1,
10669
+ h: "28px",
10670
+ minW: "28px",
10671
+ p: 0,
10672
+ children: /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { gap: 0, color: currentPage === 1 ? theme.disabledButtonText || "#B5B5B5" : theme.defaultTextColor || "#15003E", children: [
10673
+ /* @__PURE__ */ jsxRuntime.jsx(BackIcon, { size: 20 }),
10674
+ /* @__PURE__ */ jsxRuntime.jsx(Text2, { variant: "content7", fontSize: "11px", children: "Prev" })
10675
+ ] })
10676
+ }
10677
+ ),
10678
+ /* @__PURE__ */ jsxRuntime.jsx(react.HStack, { gap: 1, color: theme.weakTextColor || "#81728C", children: totalPages <= 7 ? Array.from({ length: totalPages }, (_, i) => i + 1).map((page) => /* @__PURE__ */ jsxRuntime.jsx(
10679
+ PaginationButton,
10680
+ {
10681
+ currentPage,
10682
+ page,
10683
+ onClick: () => setCurrentPage(page)
10684
+ },
10685
+ page
10686
+ )) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10687
+ /* @__PURE__ */ jsxRuntime.jsx(
10688
+ PaginationButton,
10689
+ {
10690
+ currentPage,
10691
+ page: 1,
10692
+ onClick: () => setCurrentPage(1)
10693
+ }
10694
+ ),
10695
+ currentPage > 4 && /* @__PURE__ */ jsxRuntime.jsx(Text2, { variant: "content7", fontSize: "12px", children: "..." }),
10696
+ Array.from({ length: 3 }, (_, i) => {
10697
+ const page = currentPage - 1 + i;
10698
+ if (page > 1 && page < totalPages) {
10699
+ return /* @__PURE__ */ jsxRuntime.jsx(
10700
+ PaginationButton,
10701
+ {
10702
+ currentPage,
10703
+ page,
10704
+ onClick: () => setCurrentPage(page)
10705
+ },
10706
+ page
10707
+ );
10708
+ }
10709
+ return null;
10710
+ }),
10711
+ currentPage < totalPages - 3 && /* @__PURE__ */ jsxRuntime.jsx(Text2, { variant: "content7", fontSize: "12px", children: "..." }),
10712
+ totalPages > 1 && /* @__PURE__ */ jsxRuntime.jsx(
10713
+ PaginationButton,
10714
+ {
10715
+ currentPage,
10716
+ page: totalPages,
10717
+ onClick: () => setCurrentPage(totalPages)
10718
+ }
10719
+ )
10720
+ ] }) }),
10721
+ /* @__PURE__ */ jsxRuntime.jsx(
10722
+ react.Button,
10723
+ {
10724
+ variant: "plain",
10725
+ onClick: handleNext,
10726
+ disabled: currentPage === totalPages,
10727
+ h: "28px",
10728
+ minW: "28px",
10729
+ p: 0,
10730
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
10731
+ react.HStack,
10732
+ {
10733
+ gap: 0,
10734
+ color: currentPage === totalPages ? theme.disabledButtonText || "#B5B5B5" : theme.defaultTextColor || "#15003E",
10735
+ children: [
10736
+ /* @__PURE__ */ jsxRuntime.jsx(Text2, { variant: "content7", fontSize: "11px", children: "Next" }),
10737
+ /* @__PURE__ */ jsxRuntime.jsx(react.Box, { transform: "rotate(180deg)", children: /* @__PURE__ */ jsxRuntime.jsx(BackIcon, { size: 20 }) })
10738
+ ]
10739
+ }
10740
+ )
10741
+ }
10742
+ )
10743
+ ]
10744
+ }
10745
+ );
10746
+ }
10747
+ var PAGE_SIZE = 4;
10748
+ function OrderHistory({ address, solanaAddress, onBack }) {
10749
+ const { theme } = useWidgetTheme();
10750
+ const [currentPage, setCurrentPage] = React5.useState(1);
10751
+ const [offset, setOffset] = React5.useState(0);
10752
+ const { data, isLoading, error, isFetching } = useOrderHistory(
10753
+ address,
10754
+ solanaAddress,
10755
+ offset,
10756
+ PAGE_SIZE
10757
+ );
10758
+ const totalItems = data?.total || 0;
10759
+ const totalPages = Math.ceil(totalItems / PAGE_SIZE);
10760
+ const currentOrders = data?.orders || [];
10761
+ const handlePageChange = (page) => {
10762
+ const newOffset = (page - 1) * PAGE_SIZE;
10763
+ setOffset(newOffset);
10764
+ setCurrentPage(page);
10765
+ };
10766
+ const renderContent = () => {
10767
+ if (isLoading) {
10768
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.VStack, { gap: 4, py: 10, align: "center", w: "100%", children: [
10769
+ /* @__PURE__ */ jsxRuntime.jsx(react.Spinner, { size: "md", color: theme.highlightTextColor }),
10770
+ /* @__PURE__ */ jsxRuntime.jsx(Text2, { variant: "content7", color: theme.weakTextColor || "#81728C", children: "Loading transactions..." })
10771
+ ] });
10772
+ }
10773
+ if (error) {
10774
+ return /* @__PURE__ */ jsxRuntime.jsx(
10775
+ react.Box,
10776
+ {
10777
+ border: "1px solid #FF4267",
10778
+ borderRadius: "8px",
10779
+ p: 3,
10780
+ my: 4,
10781
+ bg: "#FFF5F5",
10782
+ children: /* @__PURE__ */ jsxRuntime.jsx(Text2, { variant: "content7", color: "#FF4267", textAlign: "center", children: "Failed to load transaction history. Please try again." })
10783
+ }
10784
+ );
10785
+ }
10786
+ if (currentOrders.length === 0) {
10787
+ const emptyColor = theme.defaultBorderColor || "#E0D8E8";
10788
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.VStack, { gap: 4, py: 10, align: "center", w: "100%", children: [
10789
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "48", height: "48", viewBox: "0 0 48 48", fill: "none", children: [
10790
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "4", y: "8", width: "40", height: "32", rx: "4", stroke: emptyColor, strokeWidth: "2", fill: "none" }),
10791
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M16 20H32", stroke: emptyColor, strokeWidth: "2", strokeLinecap: "round" }),
10792
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M16 28H28", stroke: emptyColor, strokeWidth: "2", strokeLinecap: "round" })
10793
+ ] }),
10794
+ /* @__PURE__ */ jsxRuntime.jsx(Text2, { variant: "content7", color: theme.weakTextColor || "#81728C", textAlign: "center", children: "No transaction history yet" })
10795
+ ] });
10796
+ }
10797
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { position: "relative", w: "100%", children: [
10798
+ isFetching && /* @__PURE__ */ jsxRuntime.jsx(
10799
+ react.Box,
10800
+ {
10801
+ position: "absolute",
10802
+ zIndex: 10,
10803
+ top: 0,
10804
+ left: 0,
10805
+ right: 0,
10806
+ bottom: 0,
10807
+ display: "flex",
10808
+ alignItems: "center",
10809
+ justifyContent: "center",
10810
+ children: /* @__PURE__ */ jsxRuntime.jsx(react.Spinner, { size: "sm", color: theme.highlightTextColor })
10811
+ }
10812
+ ),
10813
+ /* @__PURE__ */ jsxRuntime.jsx(react.VStack, { gap: 2.5, w: "100%", children: currentOrders.map((order) => /* @__PURE__ */ jsxRuntime.jsx(OrderHistoryItem, { order }, order.order_id)) }),
10814
+ /* @__PURE__ */ jsxRuntime.jsx(
10815
+ OrderHistoryPagination,
10816
+ {
10817
+ currentPage,
10818
+ totalPages,
10819
+ setCurrentPage: handlePageChange
10820
+ }
10821
+ )
10822
+ ] });
10823
+ };
10824
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.VStack, { w: "100%", gap: 4, align: "start", children: [
10825
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { w: "100%", justify: "space-between", align: "center", children: [
10826
+ /* @__PURE__ */ jsxRuntime.jsx(
10827
+ react.Button,
10828
+ {
10829
+ variant: "plain",
10830
+ onClick: onBack,
10831
+ h: "24px",
10832
+ minW: "24px",
10833
+ p: 0,
10834
+ children: /* @__PURE__ */ jsxRuntime.jsx(ri.RiArrowGoBackFill, { color: theme.defaultTextColor, size: 20 })
10835
+ }
10836
+ ),
10837
+ /* @__PURE__ */ jsxRuntime.jsx(
10838
+ Text2,
10839
+ {
10840
+ color: theme.defaultTextColor,
10841
+ textAlign: "center",
10842
+ fontWeight: 600,
10843
+ fontSize: "16px",
10844
+ children: "Transaction history"
10845
+ }
10846
+ ),
10847
+ /* @__PURE__ */ jsxRuntime.jsx(react.Box, { w: "24px" })
10848
+ ] }),
10849
+ renderContent()
10850
+ ] });
10851
+ }
10443
10852
  var initialQuoteInfo = {
10444
10853
  isFetching: false,
10445
10854
  error: null,
@@ -10488,6 +10897,7 @@ var MainForm = ({ config }) => {
10488
10897
  const refreshIntervalRef = React5.useRef(30);
10489
10898
  const timerRef = React5.useRef(null);
10490
10899
  const isQuoteStoppedRef = React5.useRef(false);
10900
+ const [showHistory, setShowHistory] = React5.useState(false);
10491
10901
  const { differentAddress } = useDifferentAddressStore();
10492
10902
  const { chains, slippagePolicies } = useChainsStore();
10493
10903
  const prevAddressRef = React5.useRef(address);
@@ -10892,6 +11302,16 @@ var MainForm = ({ config }) => {
10892
11302
  }
10893
11303
  ) });
10894
11304
  }
11305
+ if (showHistory) {
11306
+ return /* @__PURE__ */ jsxRuntime.jsx(
11307
+ OrderHistory,
11308
+ {
11309
+ address,
11310
+ solanaAddress: solanaWalletAddress || void 0,
11311
+ onBack: () => setShowHistory(false)
11312
+ }
11313
+ );
11314
+ }
10895
11315
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10896
11316
  /* @__PURE__ */ jsxRuntime.jsx(
10897
11317
  FormTop,
@@ -10900,7 +11320,8 @@ var MainForm = ({ config }) => {
10900
11320
  quoteInfo,
10901
11321
  clearLockedRequestId,
10902
11322
  refreshInterval,
10903
- hideCountdown: isETHtoETHBridge(fromTokenInfo, toTokenInfo, chains)
11323
+ hideCountdown: isETHtoETHBridge(fromTokenInfo, toTokenInfo, chains),
11324
+ onHistoryClick: () => setShowHistory(true)
10904
11325
  }
10905
11326
  ),
10906
11327
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -10971,7 +11392,23 @@ var MainForm = ({ config }) => {
10971
11392
  src: "https://wheelx.fi/images/success-sprites.png",
10972
11393
  alt: "success"
10973
11394
  }
10974
- )
11395
+ ),
11396
+ !showHistory && /* @__PURE__ */ jsxRuntime.jsx(react.HStack, { w: "100%", justifyContent: "center", alignItems: "center", opacity: "0.7", fontSize: "13px", children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: "https://wheelx.fi/", target: "_blank", style: { display: "block" }, children: /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { color: theme.weakTextColor, fontSize: "12px", alignContent: "center", alignItems: "center", w: "100%", children: [
11397
+ /* @__PURE__ */ jsxRuntime.jsx(react.Box, { children: "Powered by" }),
11398
+ /* @__PURE__ */ jsxRuntime.jsx(
11399
+ react.Box,
11400
+ {
11401
+ w: "14px",
11402
+ h: "14px",
11403
+ backgroundColor: "currentColor",
11404
+ maskSize: "contain",
11405
+ maskRepeat: "no-repeat",
11406
+ maskPosition: "center center",
11407
+ maskImage: "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA/CAMAAACLtlvuAAAAeFBMVEUAAAAVAD4VAD4VAD4VAD4VAD4dAEAUAD8VAD4VAD8VAD4VAD4VAD8XAD8VAD4VAD4VAD4XAD8XAD8VAD4VAD4VAD8VAD8XAD8XAD8VAD4WAD8WAD8WAD8VAD4XAD8XAD8XAD8WAD4VAD4VAD4WAD8WAD8VAD4TAD0voTQoAAAAJnRSTlMA+ufG7bEXnPRh0KlsPuHZj3RDvLZWSiwfl1wwE6MmDAaIfcE6USqlGmwAAAMlSURBVEjHnZbpgqowDEZTFqnsiCgoAm4f7/+GVypMpkivjueXSo6pNWlD/2GfC+E29BU7KKKv5BgK/8vE36deT/L9Czma5D19wRWKLX3CJk1v2gfu4AaGGJ3tLLSJKjw4rYvWEMMEUHijObwVthS5A0Be2t8x1dw9YqQc9soCrocVkSWGQstiIF89XnCM4Y/Z0cqHc6AHSla06ZDvzjE6xc+3boCCiOWRFP4FI5uZXMuxGD24RAsylRYEFFZLM0I8EWvSZeYERX+gFwoH2Ma4klG2AenA2tEC3ZFC2HAN8srpd2fcqaNljv2ZqvlvZndNFFtkQiZE5MFdkGtrcKnpTwb3giNNNsucl2NeaXEiYptldh+IqyFxSZMdsKy7lC33t2MTEedmWbm8Pm9pq3EgzVaycrWy2IoF+YyaZnYGpG2n9plZa+tehWm4IvJjIs2+JnggJfRyLBFSmaVhzUfshoRLDFfy68mBs2p+Ef10uLzJ8/z8m9jPH1hQdkkenrgy1I86/HA2LCklC08cBx8iMJKTjyeJE+c2kyccbQ0P+ImFEZcu09qcTL9fWQ4Nyw5pTG2TqF7O4uVrMrHzUSFqh28KOrJsvU18YPG+6XBRd4nXPavktlKXC5F2boSe2pUT9AK44T4otfbhYepU7oVS4vZT51zGLb1Q4/zbPXBXVZodJ7RALrS8LGu5j7z5ek0VWl6W2eatmZM4nFeXyZv2vMHFNEhk7LKs5fZBBk5oeM26TJXKHfbm8SZJ6mTKyzLn3uNinEnWheTLl2W2E2TZZkHtrgCsGD69uyVd40ziS2dlkDcSit44kyRRjHBRDpDIdzPJjVw40YucAbvo7Uzy8CIHTtb+kksPsGu6v5tJLNWluxiQQbhx5O1+sQHkpRZjmEmmAikzHxACAsC26LSYNb1QWEC8m+9iRZ0pRmffkI4fe4heYj7D7hty+4i+Ieg3qo2aL9zz2F0O6j+7WZ+N5wqsv7oFV/C+t//mRr37+03wF7fpfX0Z6eduPblsZ594a991gxjbdLu1nzeId90GlUQeuHb1Rk7xQDiCm8cax5oHCen8A09+fN7BIX4wAAAAAElFTkSuQmCC)"
11408
+ }
11409
+ ),
11410
+ /* @__PURE__ */ jsxRuntime.jsx(react.Box, { children: "WheelX" })
11411
+ ] }) }) })
10975
11412
  ]
10976
11413
  }
10977
11414
  ),
@@ -10985,39 +11422,7 @@ var MainForm = ({ config }) => {
10985
11422
  md: "480px"
10986
11423
  }
10987
11424
  }
10988
- ),
10989
- /* @__PURE__ */ jsxRuntime.jsx(react.Box, { marginTop: "30px", fontSize: "14px", children: /* @__PURE__ */ jsxRuntime.jsx(
10990
- "a",
10991
- {
10992
- href: "https://github.com/wheelx-fi/wheelx-contracts/blob/main/audits/ABDK_WheelX_WheelXContracts_v_1_0.pdf",
10993
- target: "_blank",
10994
- children: /* @__PURE__ */ jsxRuntime.jsxs(
10995
- Text2,
10996
- {
10997
- color: "#5D6270",
10998
- display: "flex",
10999
- alignItems: "center",
11000
- justifyContent: "center",
11001
- children: [
11002
- "Audited By",
11003
- " ",
11004
- /* @__PURE__ */ jsxRuntime.jsx(
11005
- react.Image,
11006
- {
11007
- display: "block",
11008
- width: "70px",
11009
- height: "28px",
11010
- marginLeft: "2px",
11011
- objectFit: "contain",
11012
- src: "https://wheelx.fi/images/adbk.png",
11013
- alt: ""
11014
- }
11015
- )
11016
- ]
11017
- }
11018
- )
11019
- }
11020
- ) })
11425
+ )
11021
11426
  ] })
11022
11427
  }
11023
11428
  ),