@0xsquid/react-hooks 8.0.0 → 8.0.1-para-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/hooks/onramp/useFiatToCrypto.d.ts +6 -28
  2. package/dist/hooks/squid/useSquid.d.ts +2 -2
  3. package/dist/hooks/swap/useDepositAddress.d.ts +2 -2
  4. package/dist/hooks/tokens/useAllConnectedWalletBalances.d.ts +5 -11
  5. package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.d.ts +1 -1
  6. package/dist/hooks/tokens/useBalance.d.ts +1 -1
  7. package/dist/hooks/tokens/useMultipleTokenPrices.d.ts +2 -2
  8. package/dist/hooks/tokens/useNativeBalance.d.ts +2 -2
  9. package/dist/hooks/tokens/useTokenHistoricalData.d.ts +4 -4
  10. package/dist/hooks/transaction/send/useEstimateSendTransactionGas.d.ts +1 -1
  11. package/dist/hooks/transaction/send/useSendTransactionGas.d.ts +1 -1
  12. package/dist/hooks/transaction/useAllTransactionsStatus.d.ts +3 -29
  13. package/dist/hooks/transaction/useApproval.d.ts +2 -2
  14. package/dist/hooks/transaction/useExecuteTransaction.d.ts +2 -2
  15. package/dist/hooks/transaction/useGetRoute.d.ts +19 -13
  16. package/dist/hooks/transaction/useSwapTransactionStatus.d.ts +1 -1
  17. package/dist/hooks/wallet/useAddToken.d.ts +1 -1
  18. package/dist/hooks/wallet/useEns.d.ts +2 -2
  19. package/dist/hooks/wallet/useMultiChainWallet.d.ts +1 -1
  20. package/dist/hooks/wallet/useWallet.d.ts +1 -1
  21. package/dist/hooks/xrpl/useXrplTrustLine.d.ts +5 -5
  22. package/dist/{index-_Qp4Ou3J.js → index-BxbblIad.js} +1075 -1068
  23. package/dist/{index-_Qp4Ou3J.js.map → index-BxbblIad.js.map} +1 -1
  24. package/dist/{index-BtOPNnH5.js → index-CvsT0xf8.js} +1073 -1069
  25. package/dist/{index-BtOPNnH5.js.map → index-CvsT0xf8.js.map} +1 -1
  26. package/dist/index.esm.js +5 -3
  27. package/dist/index.esm.js.map +1 -1
  28. package/dist/index.js +6 -7
  29. package/dist/index.js.map +1 -1
  30. package/dist/provider/index.d.ts +2 -0
  31. package/dist/{secretService-DdVLwd-q.js → secretService-BjLmYyy4.js} +6 -4
  32. package/dist/{secretService-DdVLwd-q.js.map → secretService-BjLmYyy4.js.map} +1 -1
  33. package/dist/{secretService-CR2RaJtB.js → secretService-nvn8-zjs.js} +6 -4
  34. package/dist/{secretService-CR2RaJtB.js.map → secretService-nvn8-zjs.js.map} +1 -1
  35. package/dist/services/internal/configService.d.ts +0 -1
  36. package/dist/{stellarService.client-BvSwmxzo.js → stellarService.client-BuIqVMl2.js} +6 -4
  37. package/dist/{stellarService.client-BvSwmxzo.js.map → stellarService.client-BuIqVMl2.js.map} +1 -1
  38. package/dist/{stellarService.client-7rBIc_IW.js → stellarService.client-ep6_7QVE.js} +6 -4
  39. package/dist/{stellarService.client-7rBIc_IW.js.map → stellarService.client-ep6_7QVE.js.map} +1 -1
  40. package/package.json +14 -12
@@ -1,7 +1,7 @@
1
1
  import { ChainType, ActionType, SquidDataType, BridgeType, BridgeProvider, FeeType } from '@0xsquid/squid-types';
2
2
  import { zeroAddress as zeroAddress$1, parseUnits, formatUnits, isAddress, SwitchChainError, UserRejectedRequestError, erc20Abi, defineChain } from 'viem';
3
3
  import React, { useMemo, useCallback, useState, useEffect, createContext, useContext, useRef } from 'react';
4
- import { useQuery, useMutation, useQueries, useQueryClient, QueryClient, QueryClientProvider } from '@tanstack/react-query';
4
+ import { useQuery, useMutation, useQueryClient, QueryClient, QueryClientProvider, useQueries } from '@tanstack/react-query';
5
5
  import { fromBech32 } from '@cosmjs/encoding';
6
6
  import * as bitcoin from 'bitcoinjs-lib';
7
7
  import { address } from 'bitcoinjs-lib';
@@ -22,7 +22,7 @@ import getSymbolFromCurrency from 'currency-symbol-map';
22
22
  import Fuse from 'fuse.js';
23
23
  import { create } from 'zustand';
24
24
  import { persist } from 'zustand/middleware';
25
- import { useAccount, useConnectors, useConnect, useDisconnect, useSwitchChain, useBalance, useReadContract, createConfig, http, useWalletClient, usePublicClient, WagmiProvider } from 'wagmi';
25
+ import { useAccount, useConnectors, useConnect, useDisconnect, useSwitchChain, useBalance, useReadContract, createConfig, http, WagmiProvider, useWalletClient, usePublicClient } from 'wagmi';
26
26
  import SafeAppsSDK, { TransactionStatus as TransactionStatus$1 } from '@safe-global/safe-apps-sdk';
27
27
  import { getWallets } from '@wallet-standard/core';
28
28
  import { SlushWallet } from '@mysten/slush-wallet';
@@ -30,11 +30,13 @@ import { StargateClient, SigningStargateClient } from '@cosmjs/stargate';
30
30
  import { SuiClient } from '@mysten/sui/client';
31
31
  import { coin as coin$1 } from '@cosmjs/proto-signing';
32
32
  import { Transaction as Transaction$2 } from '@mysten/sui/transactions';
33
+ import { paraConnector } from '@getpara/wagmi-v2-integration';
34
+ import Para from '@getpara/web-sdk';
33
35
  import { injected, safe, metaMask, coinbaseWallet, walletConnect } from 'wagmi/connectors';
34
- import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
35
- import { InjectiveSigningStargateClient } from '@injectivelabs/sdk-ts/dist/cjs/core/stargate/index.js';
36
36
  import { Squid } from '@0xsquid/sdk';
37
37
  import { mainnet } from 'viem/chains';
38
+ import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
39
+ import { InjectiveSigningStargateClient } from '@injectivelabs/sdk-ts/dist/cjs/core/stargate/index.js';
38
40
 
39
41
  const squidApiBaseUrl = "https://api.uatsquidrouter.com";
40
42
 
@@ -26765,9 +26767,6 @@ const getConfigWithDefaults = (config) => {
26765
26767
  postHook: get$3(config, "postHook", defaultConfigValues.postHook),
26766
26768
  };
26767
26769
  };
26768
- const randomIntFromInterval = (min, max) => {
26769
- return Math.floor(Math.random() * (max - min + 1) + min);
26770
- };
26771
26770
  const getTokensForChain = (tokens, chainId) => {
26772
26771
  return chainId ? tokens.filter((t) => t.chainId === chainId) : tokens;
26773
26772
  };
@@ -26795,7 +26794,9 @@ const fetchHighestBalanceToken = (fetchCachedBalance, chainId) => {
26795
26794
  if (fetchCachedBalance) {
26796
26795
  const queryCache = fetchCachedBalance?.queryClient?.getQueryCache();
26797
26796
  // get cached balance from key
26798
- const cache = queryCache?.find(keys().allTokensBalance(fetchCachedBalance?.address, !isNaN(Number(chainId)) ? ChainType.EVM : ChainType.COSMOS));
26797
+ const cache = queryCache?.find({
26798
+ queryKey: keys().allTokensBalance(fetchCachedBalance?.address, !isNaN(Number(chainId)) ? ChainType.EVM : ChainType.COSMOS),
26799
+ });
26799
26800
  // Parse result to TokenWithBalance[]
26800
26801
  const cacheResult = cache?.state.data ?? [];
26801
26802
  if (cacheResult.length > 0) {
@@ -27451,7 +27452,7 @@ const filterViewableTokens = (tokens, config, direction) => {
27451
27452
  };
27452
27453
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
27453
27454
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
27454
- const { fetchAllSecretBalances } = await import('./secretService-CR2RaJtB.js');
27455
+ const { fetchAllSecretBalances } = await import('./secretService-nvn8-zjs.js');
27455
27456
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
27456
27457
  };
27457
27458
  function getTokenAssetsKey(token) {
@@ -29210,13 +29211,16 @@ const useSquid = () => {
29210
29211
  * Fetch squid info
29211
29212
  * Will refetch every minute
29212
29213
  */
29213
- const squidInfoQuery = useQuery(keys().squidInfo(), async () => {
29214
- if (squid) {
29215
- await squid?.init();
29216
- initializeSquidWithAssetsColors(squid, assetsColors);
29217
- return squid;
29214
+ const squidInfoQuery = useQuery({
29215
+ queryKey: keys().squidInfo(),
29216
+ queryFn: async () => {
29217
+ if (squid) {
29218
+ await squid?.init();
29219
+ initializeSquidWithAssetsColors(squid, assetsColors);
29220
+ return squid;
29221
+ }
29222
+ return null;
29218
29223
  }
29219
- return null;
29220
29224
  });
29221
29225
  const tokens = useMemo(() => {
29222
29226
  if ((squidInfoQuery?.data?.tokens ?? []).length > 0) {
@@ -29332,47 +29336,11 @@ const FINAL_TRANSACTION_STATUSES = [
29332
29336
  "completed",
29333
29337
  "failed",
29334
29338
  ];
29335
- /**
29336
- * Configuration for transaction status tracking
29337
- */
29338
- const createTransactionStatusConfig = ({ transactionId, walletAddress, providerId, replaceTransactionStatus, }) => {
29339
- return {
29340
- queryKey: keys().fiatToCryptoStatus(transactionId),
29341
- queryFn: () => new OnrampService().getTransactionStatus(transactionId, walletAddress, providerId),
29342
- enabled: !!transactionId && !!walletAddress && !!providerId,
29343
- retry: TX_STATUS_CONSTANTS.RETRY_COUNT,
29344
- retryDelay: TX_STATUS_CONSTANTS.RETRY_DELAY,
29345
- refetchInterval: (data) => {
29346
- if (data?.status && FINAL_TRANSACTION_STATUSES.includes(data.status)) {
29347
- return false;
29348
- }
29349
- return TX_STATUS_CONSTANTS.REFETCH_INTERVAL;
29350
- },
29351
- onSuccess: (data) => {
29352
- if (data) {
29353
- replaceTransactionStatus({
29354
- txType: HistoryTxType.BUY,
29355
- orderId: transactionId,
29356
- status: data.status,
29357
- transactionHash: data.transactionHash,
29358
- });
29359
- }
29360
- },
29361
- onError: () => {
29362
- replaceTransactionStatus({
29363
- txType: HistoryTxType.BUY,
29364
- orderId: transactionId,
29365
- status: "failed",
29366
- transactionHash: undefined,
29367
- });
29368
- },
29369
- };
29370
- };
29371
29339
  /**
29372
29340
  * Fetches quotes for fiat to crypto conversion with provider details.
29373
29341
  * Returns available rates, fees, and supported payment methods for the conversion.
29374
29342
  */
29375
- const useGetFiatQuote = ({ fiatCurrency, cryptoCurrencyID, amount, region, paymentMethod, enabled = true, onSuccess, }) => {
29343
+ const useGetFiatQuote = ({ fiatCurrency, cryptoCurrencyID, amount, region, paymentMethod, enabled = true, }) => {
29376
29344
  const service = useMemo(() => new OnrampService(), []);
29377
29345
  const { data: config } = useGetOnRampConfig();
29378
29346
  return useQuery({
@@ -29408,7 +29376,6 @@ const useGetFiatQuote = ({ fiatCurrency, cryptoCurrencyID, amount, region, payme
29408
29376
  return quoteResponse;
29409
29377
  },
29410
29378
  enabled: enabled && !!fiatCurrency && !!cryptoCurrencyID && amount > 0,
29411
- onSuccess,
29412
29379
  });
29413
29380
  };
29414
29381
  /**
@@ -29425,7 +29392,7 @@ const useGetOnRampConfig = () => {
29425
29392
  chains,
29426
29393
  tokens,
29427
29394
  }),
29428
- cacheTime: 1000 * 60 * 60,
29395
+ gcTime: 1000 * 60 * 60,
29429
29396
  staleTime: 1000 * 60 * 30, // 30 minutes
29430
29397
  });
29431
29398
  };
@@ -29483,49 +29450,11 @@ const useExecuteFiatQuote = () => {
29483
29450
  },
29484
29451
  });
29485
29452
  };
29486
- /**
29487
- * Tracks the status of a single fiat to crypto transaction.
29488
- */
29489
- const useFiatOnRampTxStatus = (transactionId, walletAddress, providerId) => {
29490
- const replaceTransactionStatus = useHistoryStore((state) => state.replaceTransactionStatus);
29491
- return useQuery({
29492
- ...createTransactionStatusConfig({
29493
- transactionId,
29494
- walletAddress,
29495
- providerId,
29496
- replaceTransactionStatus,
29497
- }),
29498
- });
29499
- };
29500
- /**
29501
- * Tracks all pending fiat transactions.
29502
- */
29503
- const useFiatTransactions = () => {
29504
- const transactions = useHistoryStore((state) => state.transactions.filter((tx) => tx.txType === HistoryTxType.BUY));
29505
- const replaceTransactionStatus = useHistoryStore((state) => state.replaceTransactionStatus);
29506
- const pendingTransactions = useMemo(() => transactions?.filter((tx) => !FINAL_TRANSACTION_STATUSES.includes(tx.data.status)) ?? [], [transactions]);
29507
- const queries = useQueries({
29508
- queries: pendingTransactions.map((tx) => ({
29509
- ...createTransactionStatusConfig({
29510
- transactionId: tx.data.orderId,
29511
- walletAddress: tx.data.toAddress,
29512
- providerId: tx.data.providerId,
29513
- replaceTransactionStatus,
29514
- }),
29515
- })),
29516
- });
29517
- return {
29518
- transactions: transactions.map((tx) => tx.data),
29519
- isLoading: queries.some((q) => q.isLoading),
29520
- isError: queries.some((q) => q.isError),
29521
- };
29522
- };
29523
29453
  /**
29524
29454
  * Gets currency details including symbol and limits.
29525
29455
  * Example: USD → { symbol: "$", name: "US Dollar", ... }
29526
29456
  */
29527
29457
  const useCurrencyDetails = (currencyCode) => {
29528
- const { data: config } = useGetOnRampConfig();
29529
29458
  return useMemo(() => {
29530
29459
  if (!currencyCode)
29531
29460
  return undefined;
@@ -29538,7 +29467,7 @@ const useCurrencyDetails = (currencyCode) => {
29538
29467
  };
29539
29468
  }
29540
29469
  return undefined;
29541
- }, [currencyCode, config?.supportedFiats]);
29470
+ }, [currencyCode]);
29542
29471
  };
29543
29472
  /**
29544
29473
  * Gets country details with flag URL and localized name.
@@ -29565,23 +29494,6 @@ const useAvailableQuotes = (quotes) => {
29565
29494
  return uniqueQuotes;
29566
29495
  }, [quotes]);
29567
29496
  };
29568
- /**
29569
- * Gets the recommended quote based on best rates or provider preferences.
29570
- * Falls back to first available quote if no specific recommendation.
29571
- */
29572
- const useRecommendedQuote = (quotes, recommendedQuote) => {
29573
- const availableQuotes = useAvailableQuotes(quotes);
29574
- return useMemo(() => {
29575
- if (!availableQuotes.length)
29576
- return undefined;
29577
- if (!recommendedQuote)
29578
- return availableQuotes[0];
29579
- // Try to find the recommended quote among available quotes
29580
- const recommendedAvailableQuote = availableQuotes.find((quote) => quote.onrampProviderId === recommendedQuote.onrampProviderId);
29581
- // If recommended quote is not available, return first available quote
29582
- return recommendedAvailableQuote ?? availableQuotes[0];
29583
- }, [availableQuotes, recommendedQuote]);
29584
- };
29585
29497
  /**
29586
29498
  * Fetches the available payment methods for a given fiat and crypto currency pair.
29587
29499
  * The first item in the returned array is the most recommended.
@@ -29684,7 +29596,7 @@ const middleStepChecker = (statusResponse) => {
29684
29596
  }
29685
29597
  return TransactionStatus.ERROR;
29686
29598
  }
29687
- if (statusResponse?.isInitialLoading) {
29599
+ if (statusResponse?.isLoading) {
29688
29600
  return TransactionStatus.INITIAL_LOADING;
29689
29601
  }
29690
29602
  return TransactionStatus.ONGOING;
@@ -30129,7 +30041,7 @@ const useClient = () => {
30129
30041
  queryFn: getUserCountry,
30130
30042
  enabled: isClient,
30131
30043
  retry: false,
30132
- cacheTime: CACHE_TIME,
30044
+ gcTime: CACHE_TIME,
30133
30045
  staleTime: STALE_TIME,
30134
30046
  });
30135
30047
  const userCountry = countryData?.countryCode || DEFAULT_COUNTRY_CODE;
@@ -30230,11 +30142,13 @@ function useDebouncedValue(value, delay) {
30230
30142
  * @returns the ENS data of the given address
30231
30143
  */
30232
30144
  function useEnsDataForAddress({ address, options, }) {
30233
- const ensQuery = useQuery(keys().ensData(address?.toLowerCase()), () => EnsService.getEnsDataFromAddress(address), {
30145
+ const ensQuery = useQuery({
30146
+ queryKey: keys().ensData(address?.toLowerCase()),
30147
+ queryFn: () => EnsService.getEnsDataFromAddress(address),
30234
30148
  ...options,
30235
30149
  enabled: Boolean(address?.trim()) &&
30236
30150
  (options?.enabled === undefined ? true : options.enabled),
30237
- cacheTime: Infinity,
30151
+ gcTime: Infinity,
30238
30152
  });
30239
30153
  return ensQuery;
30240
30154
  }
@@ -30250,14 +30164,16 @@ function useEnsDataForAddress({ address, options, }) {
30250
30164
  */
30251
30165
  function useEnsSearch({ name, enabled = true, delayMs = 500, }) {
30252
30166
  const debouncedName = useDebouncedValue(enabled ? name : undefined, delayMs);
30253
- const ensSearchQuery = useQuery(keys().ensSearch(debouncedName), () => {
30254
- const isExactEnsSearch = checkIsExactEns(debouncedName);
30255
- return isExactEnsSearch
30256
- ? EnsService.getExactEns(debouncedName)
30257
- : EnsService.searchEnsNames(debouncedName);
30258
- }, {
30167
+ const ensSearchQuery = useQuery({
30168
+ queryKey: keys().ensSearch(debouncedName),
30169
+ queryFn: () => {
30170
+ const isExactEnsSearch = checkIsExactEns(debouncedName);
30171
+ return isExactEnsSearch
30172
+ ? EnsService.getExactEns(debouncedName)
30173
+ : EnsService.searchEnsNames(debouncedName);
30174
+ },
30259
30175
  enabled: Boolean(debouncedName?.trim()) && enabled,
30260
- cacheTime: Infinity,
30176
+ gcTime: Infinity,
30261
30177
  });
30262
30178
  return ensSearchQuery;
30263
30179
  }
@@ -30278,23 +30194,25 @@ function checkIsExactEns(name = "") {
30278
30194
 
30279
30195
  const useCosmosForChain = (chain) => {
30280
30196
  const { keplrTypeWallet } = useCosmosSigner({ chain });
30281
- const cosmosAddressQuery = useQuery(keys().cosmosAddress(chain?.chainId), async () => {
30282
- if (!chain || !keplrTypeWallet)
30283
- return "";
30284
- try {
30285
- const address = await getCosmosKey(chain.chainId, keplrTypeWallet);
30286
- return address ?? "";
30287
- }
30288
- catch (error) {
30289
- await suggestChainOrThrow({
30290
- chain: chain,
30291
- error,
30292
- keplrTypeWallet,
30293
- });
30294
- const address = await getCosmosKey(chain.chainId, keplrTypeWallet);
30295
- return address ?? "";
30296
- }
30297
- }, {
30197
+ const cosmosAddressQuery = useQuery({
30198
+ queryKey: keys().cosmosAddress(chain?.chainId),
30199
+ queryFn: async () => {
30200
+ if (!chain || !keplrTypeWallet)
30201
+ return "";
30202
+ try {
30203
+ const address = await getCosmosKey(chain.chainId, keplrTypeWallet);
30204
+ return address ?? "";
30205
+ }
30206
+ catch (error) {
30207
+ await suggestChainOrThrow({
30208
+ chain: chain,
30209
+ error,
30210
+ keplrTypeWallet,
30211
+ });
30212
+ const address = await getCosmosKey(chain.chainId, keplrTypeWallet);
30213
+ return address ?? "";
30214
+ }
30215
+ },
30298
30216
  enabled: !!keplrTypeWallet && chain?.chainType === ChainType.COSMOS,
30299
30217
  });
30300
30218
  return cosmosAddressQuery;
@@ -30371,12 +30289,14 @@ const useIsSameAddressAndGnosisContext = () => {
30371
30289
 
30372
30290
  function useBitcoin() {
30373
30291
  const connectedBitcoinWallet = useWalletStore((store) => store.connectedWalletsByChainType[ChainType.BTC]);
30374
- const connectBitcoin = useMutation(async ({ wallet, }) => {
30375
- const { address } = await wallet.connector.requestAccount();
30376
- return {
30377
- wallet,
30378
- address,
30379
- };
30292
+ const connectBitcoin = useMutation({
30293
+ mutationFn: async ({ wallet, }) => {
30294
+ const { address } = await wallet.connector.requestAccount();
30295
+ return {
30296
+ wallet,
30297
+ address,
30298
+ };
30299
+ }
30380
30300
  });
30381
30301
  return {
30382
30302
  connectBitcoin,
@@ -30416,15 +30336,17 @@ function useEvm() {
30416
30336
  const { wallets } = useEvmWallets();
30417
30337
  const connectedEvmWallet = useWalletStore((store) => store.connectedWalletsByChainType[ChainType.EVM]);
30418
30338
  const recentEvmWalletId = useWalletStore((store) => store.recentConnectorIds[ChainType.EVM]);
30419
- const connectEvm = useMutation(async ({ wallet, }) => {
30420
- const result = await connectAsync({
30421
- connector: wallet.connector,
30422
- });
30423
- const [firstAddress] = result.accounts;
30424
- return {
30425
- wallet,
30426
- address: firstAddress,
30427
- };
30339
+ const connectEvm = useMutation({
30340
+ mutationFn: async ({ wallet, }) => {
30341
+ const result = await connectAsync({
30342
+ connector: wallet.connector,
30343
+ });
30344
+ const [firstAddress] = result.accounts;
30345
+ return {
30346
+ wallet,
30347
+ address: firstAddress,
30348
+ };
30349
+ }
30428
30350
  });
30429
30351
  const disconnectEvm = useCallback(async () => {
30430
30352
  disconnect({ connector: connectedEvmWallet.wallet?.connector });
@@ -30518,21 +30440,23 @@ function useSolana() {
30518
30440
  const { wallets } = useSolanaWallets();
30519
30441
  const connectedSolanaWallet = useWalletStore((store) => store.connectedWalletsByChainType[ChainType.SOLANA]);
30520
30442
  const recentSolanaWalletId = useWalletStore((store) => store.recentConnectorIds[ChainType.SOLANA]);
30521
- const connectSolana = useMutation(async ({ wallet, }) => {
30522
- try {
30523
- // try to connect silently first
30524
- await wallet.connector.autoConnect();
30525
- }
30526
- catch {
30527
- // if auto-connect fails (e.g. not authorized yet)
30528
- // fallback to connect via popup
30529
- await wallet.connector.connect();
30443
+ const connectSolana = useMutation({
30444
+ mutationFn: async ({ wallet, }) => {
30445
+ try {
30446
+ // try to connect silently first
30447
+ await wallet.connector.autoConnect();
30448
+ }
30449
+ catch {
30450
+ // if auto-connect fails (e.g. not authorized yet)
30451
+ // fallback to connect via popup
30452
+ await wallet.connector.connect();
30453
+ }
30454
+ const address = wallet.connector.wallet.accounts[0].address;
30455
+ return {
30456
+ wallet,
30457
+ address,
30458
+ };
30530
30459
  }
30531
- const address = wallet.connector.wallet.accounts[0].address;
30532
- return {
30533
- wallet,
30534
- address,
30535
- };
30536
30460
  });
30537
30461
  const disconnectSolana = useCallback(async () => {
30538
30462
  await connectedSolanaWallet.wallet?.connector.disconnect();
@@ -30607,7 +30531,7 @@ function useStellarWallets() {
30607
30531
  return;
30608
30532
  try {
30609
30533
  const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
30610
- const { formatStellarWallet } = await import('./stellarService.client-BvSwmxzo.js');
30534
+ const { formatStellarWallet } = await import('./stellarService.client-BuIqVMl2.js');
30611
30535
  const modules = initializeAllModules();
30612
30536
  const promises = modules.map(async (module) => {
30613
30537
  const isAvailable = await module.isAvailable();
@@ -30635,12 +30559,14 @@ function useStellarWallets() {
30635
30559
  function useStellar() {
30636
30560
  const { wallets } = useStellarWallets();
30637
30561
  const connectedStellarWallet = useWalletStore((store) => store.connectedWalletsByChainType[ChainType.STELLAR]);
30638
- const connectStellar = useMutation(async ({ wallet, }) => {
30639
- const { address } = await wallet.connector.getAddress();
30640
- return {
30641
- wallet,
30642
- address,
30643
- };
30562
+ const connectStellar = useMutation({
30563
+ mutationFn: async ({ wallet, }) => {
30564
+ const { address } = await wallet.connector.getAddress();
30565
+ return {
30566
+ wallet,
30567
+ address,
30568
+ };
30569
+ }
30644
30570
  });
30645
30571
  const disconnectStellar = useCallback(async () => {
30646
30572
  await connectedStellarWallet.wallet?.connector.disconnect?.();
@@ -30692,22 +30618,24 @@ function useSui() {
30692
30618
  const recentSuiWalletId = useWalletStore((store) => store.recentConnectorIds[ChainType.SUI]);
30693
30619
  const setConnectedWallet = useWalletStore((store) => store.setConnectedWallet);
30694
30620
  const disconnectWallet = useWalletStore((store) => store.disconnectWallet);
30695
- const connectSui = useMutation(async ({ wallet, }) => {
30696
- let account;
30697
- try {
30698
- // try to connect silently first
30699
- account = await wallet.connector.connect({ silent: true });
30700
- }
30701
- catch {
30702
- // if auto-connect fails (e.g. not authorized yet)
30703
- // fallback to connect via popup
30704
- account = await wallet.connector.connect();
30621
+ const connectSui = useMutation({
30622
+ mutationFn: async ({ wallet, }) => {
30623
+ let account;
30624
+ try {
30625
+ // try to connect silently first
30626
+ account = await wallet.connector.connect({ silent: true });
30627
+ }
30628
+ catch {
30629
+ // if auto-connect fails (e.g. not authorized yet)
30630
+ // fallback to connect via popup
30631
+ account = await wallet.connector.connect();
30632
+ }
30633
+ return {
30634
+ wallet,
30635
+ address: account.account.address,
30636
+ account: account.account,
30637
+ };
30705
30638
  }
30706
- return {
30707
- wallet,
30708
- address: account.account.address,
30709
- account: account.account,
30710
- };
30711
30639
  });
30712
30640
  const disconnectSui = useCallback(async () => {
30713
30641
  await connectedSuiWallet.wallet?.connector.disconnect();
@@ -31016,12 +30944,14 @@ function useXrpl() {
31016
30944
  const recentXrplWalletId = useWalletStore((store) => store.recentConnectorIds[ChainType.XRPL]);
31017
30945
  const setConnectedWallet = useWalletStore((store) => store.setConnectedWallet);
31018
30946
  const disconnectWallet = useWalletStore((store) => store.disconnectWallet);
31019
- const connectXrpl = useMutation(async ({ wallet, }) => {
31020
- const xrplConnectedAddress = await wallet.connector.connect();
31021
- return {
31022
- wallet,
31023
- address: xrplConnectedAddress,
31024
- };
30947
+ const connectXrpl = useMutation({
30948
+ mutationFn: async ({ wallet, }) => {
30949
+ const xrplConnectedAddress = await wallet.connector.connect();
30950
+ return {
30951
+ wallet,
30952
+ address: xrplConnectedAddress,
30953
+ };
30954
+ }
31025
30955
  });
31026
30956
  const disconnectXrpl = useCallback(async () => {
31027
30957
  await connectedXrplWallet?.wallet?.connector.disconnect?.();
@@ -31408,18 +31338,19 @@ const useMultiChainWallet = (chain) => {
31408
31338
  /**
31409
31339
  * Change current network for desired chain
31410
31340
  */
31411
- const changeNetworkIfNeeded = useMutation(async () => {
31412
- const isNotOnDesiredChain = chain?.chainType === ChainType.EVM &&
31413
- currentEvmChain?.id !== Number(chain.chainId);
31414
- if (isNotOnDesiredChain) {
31415
- await switchChainAsync({
31416
- chainId: Number(chain.chainId),
31417
- });
31418
- }
31419
- // Implement keplr change network
31420
- // Looks like there are no method to do that at the moment
31421
- return false;
31422
- }, {
31341
+ const changeNetworkIfNeeded = useMutation({
31342
+ mutationFn: async () => {
31343
+ const isNotOnDesiredChain = chain?.chainType === ChainType.EVM &&
31344
+ currentEvmChain?.id !== Number(chain.chainId);
31345
+ if (isNotOnDesiredChain) {
31346
+ await switchChainAsync({
31347
+ chainId: Number(chain.chainId),
31348
+ });
31349
+ }
31350
+ // Implement keplr change network
31351
+ // Looks like there are no method to do that at the moment
31352
+ return false;
31353
+ },
31423
31354
  onError: async (error) => {
31424
31355
  if (error instanceof UserRejectedRequestError) {
31425
31356
  return;
@@ -31431,7 +31362,7 @@ const useMultiChainWallet = (chain) => {
31431
31362
  provider,
31432
31363
  });
31433
31364
  }
31434
- },
31365
+ }
31435
31366
  });
31436
31367
  const isChainTypeConnected = useCallback((chainType) => {
31437
31368
  if (isGnosisConnected && chainType === ChainType.EVM) {
@@ -31779,51 +31710,53 @@ const useCosmos = () => {
31779
31710
  clientWindow?.removeEventListener("keplr_keystorechange", () => handleKeplrAccountChanged());
31780
31711
  };
31781
31712
  }, [handleKeplrAccountChanged, clientWindow]);
31782
- const connectCosmos = useMutation(async ({ chain, wallet, approveAllChains = true, }) => {
31783
- const chainInfos = getCosmosChainInfosObject(chain);
31784
- const cosmosWalletObject = wallet.connector().provider;
31785
- if (cosmosWalletObject) {
31786
- setCosmosChainId(chainInfos.chainId.toString());
31787
- try {
31788
- if (approveAllChains &&
31789
- typeof cosmosWalletObject.getChainInfosWithoutEndpoints ===
31790
- "function") {
31791
- try {
31792
- const addedChains = await cosmosWalletObject.getChainInfosWithoutEndpoints();
31793
- const addedChainIds = addedChains?.map((addedChain) => addedChain.chainId);
31794
- const chainsToEnable = cosmosChains
31795
- .filter((c) => addedChainIds?.includes(c.chainId.toString()))
31796
- .map((c) => c.chainId.toString());
31797
- await cosmosWalletObject.enable(chainsToEnable);
31713
+ const connectCosmos = useMutation({
31714
+ mutationFn: async ({ chain, wallet, approveAllChains = true, }) => {
31715
+ const chainInfos = getCosmosChainInfosObject(chain);
31716
+ const cosmosWalletObject = wallet.connector().provider;
31717
+ if (cosmosWalletObject) {
31718
+ setCosmosChainId(chainInfos.chainId.toString());
31719
+ try {
31720
+ if (approveAllChains &&
31721
+ typeof cosmosWalletObject.getChainInfosWithoutEndpoints ===
31722
+ "function") {
31723
+ try {
31724
+ const addedChains = await cosmosWalletObject.getChainInfosWithoutEndpoints();
31725
+ const addedChainIds = addedChains?.map((addedChain) => addedChain.chainId);
31726
+ const chainsToEnable = cosmosChains
31727
+ .filter((c) => addedChainIds?.includes(c.chainId.toString()))
31728
+ .map((c) => c.chainId.toString());
31729
+ await cosmosWalletObject.enable(chainsToEnable);
31730
+ }
31731
+ catch (error) {
31732
+ console.warn("Failed to get chain infos, falling back to single chain enable", error);
31733
+ await cosmosWalletObject.enable(chainInfos.chainId);
31734
+ }
31798
31735
  }
31799
- catch (error) {
31800
- console.warn("Failed to get chain infos, falling back to single chain enable", error);
31736
+ else {
31801
31737
  await cosmosWalletObject.enable(chainInfos.chainId);
31802
31738
  }
31739
+ const address = await getAddress({
31740
+ chainId: chain.chainId.toString(),
31741
+ cosmosWalletObject,
31742
+ wallet,
31743
+ });
31744
+ if (address) {
31745
+ updateWalletStore(wallet, cosmosWalletObject, address);
31746
+ return address;
31747
+ }
31803
31748
  }
31804
- else {
31805
- await cosmosWalletObject.enable(chainInfos.chainId);
31806
- }
31807
- const address = await getAddress({
31808
- chainId: chain.chainId.toString(),
31809
- cosmosWalletObject,
31810
- wallet,
31811
- });
31812
- if (address) {
31813
- updateWalletStore(wallet, cosmosWalletObject, address);
31814
- return address;
31749
+ catch (error) {
31750
+ await suggestChainOrThrow({
31751
+ chain,
31752
+ error,
31753
+ keplrTypeWallet: cosmosWalletObject,
31754
+ });
31755
+ return connectCosmos.mutateAsync({ chain, wallet });
31815
31756
  }
31816
31757
  }
31817
- catch (error) {
31818
- await suggestChainOrThrow({
31819
- chain,
31820
- error,
31821
- keplrTypeWallet: cosmosWalletObject,
31822
- });
31823
- return connectCosmos.mutateAsync({ chain, wallet });
31824
- }
31758
+ return undefined;
31825
31759
  }
31826
- return undefined;
31827
31760
  });
31828
31761
  const clearData = () => {
31829
31762
  disconnectWallet(ChainType.COSMOS);
@@ -31977,11 +31910,11 @@ const useSquidQueryClient = () => {
31977
31910
  const queryClient = useQueryClient();
31978
31911
  const invalidateQueries = (key) => {
31979
31912
  const prefixKey = getPrefixKey(key);
31980
- queryClient.invalidateQueries(prefixKey);
31913
+ queryClient.invalidateQueries({ queryKey: prefixKey });
31981
31914
  };
31982
31915
  const refetchQueries = (key) => {
31983
31916
  const prefixKey = getPrefixKey(key);
31984
- queryClient.refetchQueries(prefixKey);
31917
+ queryClient.refetchQueries({ queryKey: prefixKey });
31985
31918
  };
31986
31919
  const invalidateAndRefetchQueries = (key) => {
31987
31920
  invalidateQueries(key);
@@ -33488,17 +33421,19 @@ function useDepositAddress(squidRoute) {
33488
33421
  toggleDepositFlow(false);
33489
33422
  setDeposit(null);
33490
33423
  }, [toggleDepositFlow, setDeposit]);
33491
- const getRouteWithDeposit = useMutation(async ({ route }) => {
33492
- if (!squid)
33493
- throw new Error("Squid SDK not initialized");
33494
- const depositAddressResponse = (await squid.executeRoute({
33495
- signer: {},
33496
- route,
33497
- }));
33498
- setDeposit(depositAddressResponse);
33499
- return {
33500
- depositAddress: depositAddressResponse,
33501
- };
33424
+ const getRouteWithDeposit = useMutation({
33425
+ mutationFn: async ({ route }) => {
33426
+ if (!squid)
33427
+ throw new Error("Squid SDK not initialized");
33428
+ const depositAddressResponse = (await squid.executeRoute({
33429
+ signer: {},
33430
+ route,
33431
+ }));
33432
+ setDeposit(depositAddressResponse);
33433
+ return {
33434
+ depositAddress: depositAddressResponse,
33435
+ };
33436
+ }
33502
33437
  });
33503
33438
  return {
33504
33439
  isEnabled,
@@ -33582,53 +33517,55 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
33582
33517
  xrplTokens.length,
33583
33518
  stellarTokens.length,
33584
33519
  ]);
33585
- const query = useQuery(keys().allTokensBalance(address, chainType, direction), async () => {
33586
- // Return zero balances if no address
33587
- if (!address) {
33588
- const defaultTokens = placeholderData.tokens;
33520
+ const query = useQuery({
33521
+ queryKey: keys().allTokensBalance(address, chainType, direction),
33522
+ queryFn: async () => {
33523
+ // Return zero balances if no address
33524
+ if (!address) {
33525
+ const defaultTokens = placeholderData.tokens;
33526
+ return {
33527
+ tokens: defaultTokens,
33528
+ totalUsdBalance: calculateTotalUsdBalanceUSD(defaultTokens),
33529
+ };
33530
+ }
33531
+ let fetchedTokens = [];
33532
+ // Fetch tokens based on chain type
33533
+ switch (chainType) {
33534
+ case ChainType.EVM:
33535
+ fetchedTokens = await getAllEvmTokensBalance(evmTokens, address, evmChains);
33536
+ break;
33537
+ case ChainType.COSMOS:
33538
+ const addresses = await getAllKeysForSupportedCosmosChains(cosmosChains.map((c) => c.chainId), keplrTypeWallet);
33539
+ fetchedTokens = await getAllCosmosBalances({
33540
+ addresses,
33541
+ cosmosChains,
33542
+ cosmosTokens,
33543
+ });
33544
+ break;
33545
+ case ChainType.SOLANA:
33546
+ fetchedTokens = await getAllSolanaTokensBalance(solanaTokens, address);
33547
+ break;
33548
+ case ChainType.BTC:
33549
+ fetchedTokens = await getAllBitcoinTokensBalance(address, bitcoinTokens);
33550
+ break;
33551
+ case ChainType.SUI:
33552
+ fetchedTokens = await getAllSuiTokensBalance(address, suiTokens, suiChains);
33553
+ break;
33554
+ case ChainType.XRPL:
33555
+ fetchedTokens = await getAllXrplTokensBalance(address, xrplTokens, xrplChains);
33556
+ break;
33557
+ case ChainType.STELLAR:
33558
+ fetchedTokens = await getAllStellarTokensBalance(address, stellarTokens, stellarChains);
33559
+ break;
33560
+ default:
33561
+ fetchedTokens = placeholderData.tokens;
33562
+ break;
33563
+ }
33589
33564
  return {
33590
- tokens: defaultTokens,
33591
- totalUsdBalance: calculateTotalUsdBalanceUSD(defaultTokens),
33565
+ tokens: fetchedTokens,
33566
+ totalUsdBalance: calculateTotalUsdBalanceUSD(fetchedTokens),
33592
33567
  };
33593
- }
33594
- let fetchedTokens = [];
33595
- // Fetch tokens based on chain type
33596
- switch (chainType) {
33597
- case ChainType.EVM:
33598
- fetchedTokens = await getAllEvmTokensBalance(evmTokens, address, evmChains);
33599
- break;
33600
- case ChainType.COSMOS:
33601
- const addresses = await getAllKeysForSupportedCosmosChains(cosmosChains.map((c) => c.chainId), keplrTypeWallet);
33602
- fetchedTokens = await getAllCosmosBalances({
33603
- addresses,
33604
- cosmosChains,
33605
- cosmosTokens,
33606
- });
33607
- break;
33608
- case ChainType.SOLANA:
33609
- fetchedTokens = await getAllSolanaTokensBalance(solanaTokens, address);
33610
- break;
33611
- case ChainType.BTC:
33612
- fetchedTokens = await getAllBitcoinTokensBalance(address, bitcoinTokens);
33613
- break;
33614
- case ChainType.SUI:
33615
- fetchedTokens = await getAllSuiTokensBalance(address, suiTokens, suiChains);
33616
- break;
33617
- case ChainType.XRPL:
33618
- fetchedTokens = await getAllXrplTokensBalance(address, xrplTokens, xrplChains);
33619
- break;
33620
- case ChainType.STELLAR:
33621
- fetchedTokens = await getAllStellarTokensBalance(address, stellarTokens, stellarChains);
33622
- break;
33623
- default:
33624
- fetchedTokens = placeholderData.tokens;
33625
- break;
33626
- }
33627
- return {
33628
- tokens: fetchedTokens,
33629
- totalUsdBalance: calculateTotalUsdBalanceUSD(fetchedTokens),
33630
- };
33631
- }, {
33568
+ },
33632
33569
  ...queryOptions,
33633
33570
  enabled: isQueryEnabled,
33634
33571
  });
@@ -33643,7 +33580,7 @@ const BALANCE_STALE_TIME = 60000; // 1 minute
33643
33580
  const BALANCE_CACHE_TIME = 300000; // 5 minutes
33644
33581
  const useAllConnectedWalletBalances = ({ direction, queryOptions = {
33645
33582
  staleTime: BALANCE_STALE_TIME,
33646
- cacheTime: BALANCE_CACHE_TIME,
33583
+ gcTime: BALANCE_CACHE_TIME,
33647
33584
  refetchOnWindowFocus: true,
33648
33585
  refetchOnMount: true,
33649
33586
  }, } = {}) => {
@@ -33724,9 +33661,9 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
33724
33661
  }, [balanceQueries]);
33725
33662
  // Aggregate loading states
33726
33663
  const queryStates = useMemo(() => ({
33727
- isInitialLoading: Object.values(balanceQueries).some((q) => q.isInitialLoading),
33728
- isFetching: Object.values(balanceQueries).some((q) => q.isFetching),
33729
33664
  isLoading: Object.values(balanceQueries).some((q) => q.isLoading),
33665
+ isFetching: Object.values(balanceQueries).some((q) => q.isFetching),
33666
+ isPending: Object.values(balanceQueries).some((q) => q.isPending),
33730
33667
  isRefetching: Object.values(balanceQueries).some((q) => q.isRefetching),
33731
33668
  isError: Object.values(balanceQueries).some((q) => q.isError),
33732
33669
  isSuccess: Object.values(balanceQueries).every((q) => q.isSuccess),
@@ -33768,7 +33705,7 @@ function useNativeTokenForChain(chain) {
33768
33705
 
33769
33706
  const useEvmNativeBalance = ({ address, chain, }) => {
33770
33707
  const { isChainTypeConnected } = useWallet();
33771
- const { data: nativeEvmBalance, isLoading } = useBalance({
33708
+ const { data: nativeEvmBalance, isPending } = useBalance({
33772
33709
  address: address,
33773
33710
  chainId: Number(chain?.chainId),
33774
33711
  query: {
@@ -33790,13 +33727,13 @@ const useEvmNativeBalance = ({ address, chain, }) => {
33790
33727
  }, [nativeEvmBalance?.decimals, nativeEvmBalance?.value]);
33791
33728
  return {
33792
33729
  balance,
33793
- isLoading,
33730
+ isPending,
33794
33731
  };
33795
33732
  };
33796
33733
  const useCosmosNativeBalance = ({ address, chain, }) => {
33797
33734
  const { isConnected: isCosmosConnected } = useCosmosContext();
33798
33735
  const { nativeToken: nativeCosmosToken } = useNativeTokenForChain(chain);
33799
- const { balance: rawBalance, isLoading } = useCosmosBalance({
33736
+ const { balance: rawBalance, isPending } = useCosmosBalance({
33800
33737
  chain,
33801
33738
  token: nativeCosmosToken,
33802
33739
  userAddress: address,
@@ -33811,16 +33748,18 @@ const useCosmosNativeBalance = ({ address, chain, }) => {
33811
33748
  };
33812
33749
  }
33813
33750
  }, [nativeCosmosToken?.decimals, rawBalance]);
33814
- return { balance, isLoading };
33751
+ return { balance, isPending };
33815
33752
  };
33816
33753
  const useBitcoinNativeBalance = ({ chain, address, }) => {
33817
33754
  const { nativeToken } = useNativeTokenForChain(chain);
33818
- const { data: rawBalance = "0", isLoading } = useQuery(keys().balance(chain?.chainId, nativeToken?.address, address), async () => {
33819
- if (!address || !nativeToken)
33820
- return "0";
33821
- const balance = await getBitcoinNativeBalance(address);
33822
- return formatBNToReadable(balance, nativeToken.decimals);
33823
- }, {
33755
+ const { data: rawBalance = "0", isPending } = useQuery({
33756
+ queryKey: keys().balance(chain?.chainId, nativeToken?.address, address),
33757
+ queryFn: async () => {
33758
+ if (!address || !nativeToken)
33759
+ return "0";
33760
+ const balance = await getBitcoinNativeBalance(address);
33761
+ return formatBNToReadable(balance, nativeToken.decimals);
33762
+ },
33824
33763
  enabled: chain?.chainType === ChainType.BTC &&
33825
33764
  nativeToken?.decimals != null &&
33826
33765
  isWalletAddressValid(chain, address),
@@ -33839,15 +33778,17 @@ const useBitcoinNativeBalance = ({ chain, address, }) => {
33839
33778
  }, [nativeToken?.decimals, rawBalance]);
33840
33779
  return {
33841
33780
  balance,
33842
- isLoading,
33781
+ isPending,
33843
33782
  };
33844
33783
  };
33845
33784
  const useSolanaNativeBalance = ({ chain, address, }) => {
33846
33785
  const { nativeToken } = useNativeTokenForChain(chain);
33847
- const { data: rawBalance, isLoading } = useQuery(keys().balance(chain?.chainId, nativeToken?.address, address), async () => {
33848
- const balance = await getSolanaNativeBalance(address);
33849
- return formatBNToReadable(balance, nativeToken.decimals);
33850
- }, {
33786
+ const { data: rawBalance, isPending } = useQuery({
33787
+ queryKey: keys().balance(chain?.chainId, nativeToken?.address, address),
33788
+ queryFn: async () => {
33789
+ const balance = await getSolanaNativeBalance(address);
33790
+ return formatBNToReadable(balance, nativeToken.decimals);
33791
+ },
33851
33792
  enabled: !!address &&
33852
33793
  nativeToken?.decimals != null &&
33853
33794
  chain?.chainType === ChainType.SOLANA,
@@ -33866,12 +33807,12 @@ const useSolanaNativeBalance = ({ chain, address, }) => {
33866
33807
  }, [nativeToken?.decimals, rawBalance]);
33867
33808
  return {
33868
33809
  balance,
33869
- isLoading,
33810
+ isPending,
33870
33811
  };
33871
33812
  };
33872
33813
  const useSuiNativeBalance = ({ address, chain, }) => {
33873
33814
  const { nativeToken } = useNativeTokenForChain(chain);
33874
- const { balance: rawBalance, isLoading } = useSuiBalance({
33815
+ const { balance: rawBalance, isPending } = useSuiBalance({
33875
33816
  chain,
33876
33817
  token: nativeToken,
33877
33818
  userAddress: address,
@@ -33886,12 +33827,12 @@ const useSuiNativeBalance = ({ address, chain, }) => {
33886
33827
  }, [nativeToken?.decimals, rawBalance]);
33887
33828
  return {
33888
33829
  balance,
33889
- isLoading,
33830
+ isPending,
33890
33831
  };
33891
33832
  };
33892
33833
  const useXrplNativeBalance = ({ address, chain, }) => {
33893
33834
  const { nativeToken } = useNativeTokenForChain(chain);
33894
- const { balance: rawBalance, isLoading } = useXrplBalance({
33835
+ const { balance: rawBalance, isPending } = useXrplBalance({
33895
33836
  chain,
33896
33837
  token: nativeToken,
33897
33838
  userAddress: address,
@@ -33907,12 +33848,12 @@ const useXrplNativeBalance = ({ address, chain, }) => {
33907
33848
  }, [nativeToken?.decimals, rawBalance]);
33908
33849
  return {
33909
33850
  balance,
33910
- isLoading,
33851
+ isPending,
33911
33852
  };
33912
33853
  };
33913
33854
  const useStellarNativeBalance = ({ address, chain, }) => {
33914
33855
  const { nativeToken } = useNativeTokenForChain(chain);
33915
- const { balance: rawBalance, isLoading } = useStellarBalance({
33856
+ const { balance: rawBalance, isPending } = useStellarBalance({
33916
33857
  chain,
33917
33858
  token: nativeToken,
33918
33859
  userAddress: address,
@@ -33928,7 +33869,7 @@ const useStellarNativeBalance = ({ address, chain, }) => {
33928
33869
  }, [nativeToken?.decimals, rawBalance]);
33929
33870
  return {
33930
33871
  balance,
33931
- isLoading,
33872
+ isPending,
33932
33873
  };
33933
33874
  };
33934
33875
  const useNativeBalance = (chain) => {
@@ -33936,28 +33877,28 @@ const useNativeBalance = (chain) => {
33936
33877
  const { data: cosmosAddressForChain } = useCosmosForChain(chain);
33937
33878
  // Cosmos is a special case because the address changes on every chain
33938
33879
  // so we can't use the default cosmos connected address
33939
- const { balance: nativeCosmosBalance, isLoading: isCosmosLoading } = useCosmosNativeBalance({
33880
+ const { balance: nativeCosmosBalance, isPending: isCosmosPending } = useCosmosNativeBalance({
33940
33881
  address: cosmosAddressForChain,
33941
33882
  chain,
33942
33883
  });
33943
- const { balance: nativeEvmBalance, isLoading: isEvmLoading } = useEvmNativeBalance({ address: connectedAddresses[ChainType.EVM], chain });
33944
- const { balance: nativeBitcoinBalance, isLoading: isBitcoinLoading } = useBitcoinNativeBalance({
33884
+ const { balance: nativeEvmBalance, isPending: isEvmPending } = useEvmNativeBalance({ address: connectedAddresses[ChainType.EVM], chain });
33885
+ const { balance: nativeBitcoinBalance, isPending: isBitcoinPending } = useBitcoinNativeBalance({
33945
33886
  address: connectedAddresses[ChainType.BTC],
33946
33887
  chain,
33947
33888
  });
33948
- const { balance: nativeSolanaBalance, isLoading: isSolanaLoading } = useSolanaNativeBalance({
33889
+ const { balance: nativeSolanaBalance, isPending: isSolanaPending } = useSolanaNativeBalance({
33949
33890
  address: connectedAddresses[ChainType.SOLANA],
33950
33891
  chain,
33951
33892
  });
33952
- const { balance: nativeSuiBalance, isLoading: isSuiLoading } = useSuiNativeBalance({
33893
+ const { balance: nativeSuiBalance, isPending: isSuiPending } = useSuiNativeBalance({
33953
33894
  address: connectedAddresses[ChainType.SUI],
33954
33895
  chain,
33955
33896
  });
33956
- const { balance: nativeXrplBalance, isLoading: isXrpLoading } = useXrplNativeBalance({
33897
+ const { balance: nativeXrplBalance, isPending: isXrplPending } = useXrplNativeBalance({
33957
33898
  address: connectedAddresses[ChainType.XRPL],
33958
33899
  chain,
33959
33900
  });
33960
- const { balance: nativeStellarBalance, isLoading: isStellarLoading } = useStellarNativeBalance({
33901
+ const { balance: nativeStellarBalance, isPending: isStellarPending } = useStellarNativeBalance({
33961
33902
  address: connectedAddresses[ChainType.STELLAR],
33962
33903
  chain,
33963
33904
  });
@@ -34002,36 +33943,36 @@ const useNativeBalance = (chain) => {
34002
33943
  nativeXrplBalance,
34003
33944
  nativeStellarBalance,
34004
33945
  ]);
34005
- const isLoading = useMemo(() => {
33946
+ const isPending = useMemo(() => {
34006
33947
  if (!chain?.chainType)
34007
33948
  return false;
34008
33949
  switch (chain.chainType) {
34009
33950
  case ChainType.EVM:
34010
- return isEvmLoading;
33951
+ return isEvmPending;
34011
33952
  case ChainType.COSMOS:
34012
- return isCosmosLoading;
33953
+ return isCosmosPending;
34013
33954
  case ChainType.BTC:
34014
- return isBitcoinLoading;
33955
+ return isBitcoinPending;
34015
33956
  case ChainType.SOLANA:
34016
- return isSolanaLoading;
33957
+ return isSolanaPending;
34017
33958
  case ChainType.SUI:
34018
- return isSuiLoading;
33959
+ return isSuiPending;
34019
33960
  case ChainType.XRPL:
34020
- return isXrpLoading;
33961
+ return isXrplPending;
34021
33962
  case ChainType.STELLAR:
34022
- return isStellarLoading;
33963
+ return isStellarPending;
34023
33964
  }
34024
33965
  }, [
34025
33966
  chain?.chainType,
34026
- isEvmLoading,
34027
- isCosmosLoading,
34028
- isBitcoinLoading,
34029
- isSolanaLoading,
34030
- isSuiLoading,
34031
- isXrpLoading,
34032
- isStellarLoading,
33967
+ isEvmPending,
33968
+ isCosmosPending,
33969
+ isBitcoinPending,
33970
+ isSolanaPending,
33971
+ isSuiPending,
33972
+ isXrplPending,
33973
+ isStellarPending,
34033
33974
  ]);
34034
- return { nativeBalance, nativeBalanceFormatted, isLoading };
33975
+ return { nativeBalance, nativeBalanceFormatted, isPending };
34035
33976
  };
34036
33977
 
34037
33978
  const DEFAULT_REFRESH_INTERVAL_MS = 15000;
@@ -34040,7 +33981,7 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
34040
33981
  const isNativeToken = token?.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
34041
33982
  const userAddressParsed = userAddress;
34042
33983
  // Only fetch using useBalance if it's a native token
34043
- const { data: nativeBalance, isLoading: isNativeTokenLoading } = useBalance({
33984
+ const { data: nativeBalance, isPending: isNativeTokenPending } = useBalance({
34044
33985
  address: userAddressParsed,
34045
33986
  chainId: Number(chain?.chainId),
34046
33987
  query: {
@@ -34056,7 +33997,7 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
34056
33997
  });
34057
33998
  // Only fetch using useReadContract if it's not a native token
34058
33999
  // This is temporary, because of wagmi error: https://github.com/wevm/wagmi/issues/4353
34059
- const { data: erc20Balance, isLoading: isErc20Loading } = useReadContract({
34000
+ const { data: erc20Balance, isPending: isErc20Pending } = useReadContract({
34060
34001
  address: token?.address,
34061
34002
  abi: erc20Abi,
34062
34003
  functionName: "balanceOf",
@@ -34072,15 +34013,15 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
34072
34013
  },
34073
34014
  });
34074
34015
  const balance = isNativeToken ? nativeBalance?.value : erc20Balance;
34075
- const isLoading = isNativeToken ? isNativeTokenLoading : isErc20Loading;
34016
+ const isPending = isNativeToken ? isNativeTokenPending : isErc20Pending;
34076
34017
  const formattedBalance = balance != null && token?.decimals != null
34077
34018
  ? formatBNToReadable(balance, token.decimals)
34078
34019
  : "0";
34079
- return { balance: formattedBalance, isLoading };
34020
+ return { balance: formattedBalance, isPending };
34080
34021
  };
34081
34022
  const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
34082
34023
  const { isConnected } = useCosmosContext();
34083
- const { data: balance = "0", isLoading } = useQuery({
34024
+ const { data: balance = "0", isPending } = useQuery({
34084
34025
  queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
34085
34026
  queryFn: async () => {
34086
34027
  if (!userAddress || !token || chain?.chainType !== ChainType.COSMOS) {
@@ -34100,10 +34041,10 @@ const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIn
34100
34041
  refetchInterval: refreshIntervalMs,
34101
34042
  retry: 2,
34102
34043
  });
34103
- return { balance, isLoading };
34044
+ return { balance, isPending };
34104
34045
  };
34105
34046
  const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
34106
- const { data: balance = "0", isLoading } = useQuery({
34047
+ const { data: balance = "0", isPending } = useQuery({
34107
34048
  queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
34108
34049
  queryFn: async () => {
34109
34050
  if (!userAddress || !token)
@@ -34118,11 +34059,11 @@ const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIn
34118
34059
  refetchInterval: refreshIntervalMs,
34119
34060
  retry: 2,
34120
34061
  });
34121
- return { balance, isLoading };
34062
+ return { balance, isPending };
34122
34063
  };
34123
34064
  // TODO: implement fetching balances for all bitcoin tokens
34124
34065
  const useBitcoinBalance = ({ userAddress, chain, }) => {
34125
- const { balance: balanceBn, isLoading } = useBitcoinNativeBalance({
34066
+ const { balance: balanceBn, isPending } = useBitcoinNativeBalance({
34126
34067
  address: userAddress,
34127
34068
  chain,
34128
34069
  });
@@ -34131,10 +34072,10 @@ const useBitcoinBalance = ({ userAddress, chain, }) => {
34131
34072
  return "0";
34132
34073
  return formatBNToReadable(balanceBn?.value, balanceBn?.decimals);
34133
34074
  }, [balanceBn]);
34134
- return { balance, isLoading };
34075
+ return { balance, isPending };
34135
34076
  };
34136
34077
  const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
34137
- const { data: balance = "0", isLoading } = useQuery({
34078
+ const { data: balance = "0", isPending } = useQuery({
34138
34079
  queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
34139
34080
  queryFn: async () => {
34140
34081
  if (!userAddress ||
@@ -34154,10 +34095,10 @@ const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshInter
34154
34095
  refetchInterval: refreshIntervalMs,
34155
34096
  retry: 2,
34156
34097
  });
34157
- return { balance, isLoading };
34098
+ return { balance, isPending };
34158
34099
  };
34159
34100
  const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
34160
- const { data: balance = "0", isLoading } = useQuery({
34101
+ const { data: balance = "0", isPending } = useQuery({
34161
34102
  queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
34162
34103
  queryFn: async () => {
34163
34104
  if (!userAddress || !token || !chain)
@@ -34174,10 +34115,10 @@ const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs
34174
34115
  refetchInterval: refreshIntervalMs,
34175
34116
  retry: 2,
34176
34117
  });
34177
- return { balance, isLoading };
34118
+ return { balance, isPending };
34178
34119
  };
34179
34120
  const useStellarBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
34180
- const { data: balance = "0", isLoading } = useQuery({
34121
+ const { data: balance = "0", isPending } = useQuery({
34181
34122
  queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
34182
34123
  queryFn: async () => {
34183
34124
  if (!userAddress || !token || !chain)
@@ -34194,7 +34135,7 @@ const useStellarBalance = ({ userAddress, chain, enabled, token, refreshInterval
34194
34135
  refetchInterval: refreshIntervalMs,
34195
34136
  retry: 2,
34196
34137
  });
34197
- return { balance, isLoading };
34138
+ return { balance, isPending };
34198
34139
  };
34199
34140
 
34200
34141
  /**
@@ -34315,7 +34256,7 @@ const useMultipleTokenPrices = (tokens) => {
34315
34256
  return {
34316
34257
  tokenPrices,
34317
34258
  getTokenPrice,
34318
- isLoading: coinGeckoQuery.isLoading,
34259
+ isPending: coinGeckoQuery.isPending,
34319
34260
  isError: coinGeckoQuery.isError,
34320
34261
  error: coinGeckoQuery.error,
34321
34262
  refetch: coinGeckoQuery.refetch,
@@ -34464,13 +34405,17 @@ const fetchTokensData = async (tokens) => {
34464
34405
 
34465
34406
  // Coingecko has a limit for some queries for multiple tokens, not sure what it is, but let's use 100 for now
34466
34407
  const useHistoricalData = (coingeckoId, timeFrame) => {
34467
- return useQuery(keys().historicalData(coingeckoId, timeFrame), () => fetchHistoricalData(coingeckoId, timeFrame), {
34408
+ return useQuery({
34409
+ queryKey: keys().historicalData(coingeckoId, timeFrame),
34410
+ queryFn: () => fetchHistoricalData(coingeckoId, timeFrame),
34468
34411
  staleTime: 5 * 60 * 1000,
34469
34412
  enabled: !!coingeckoId,
34470
34413
  });
34471
34414
  };
34472
34415
  const useTokensData = (tokens) => {
34473
- return useQuery(keys().tokensData(tokens), () => fetchTokensData(tokens), {
34416
+ return useQuery({
34417
+ queryKey: keys().tokensData(tokens),
34418
+ queryFn: () => fetchTokensData(tokens),
34474
34419
  staleTime: 60 * 1000,
34475
34420
  enabled: !!tokens && tokens.length > 0,
34476
34421
  });
@@ -34775,7 +34720,7 @@ function useSendTransactionGas({ chain, token, from, }) {
34775
34720
  }
34776
34721
 
34777
34722
  function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
34778
- const { data: estimatedGas = BigInt(0), isLoading } = useSendTransactionGas({
34723
+ const { data: estimatedGas = BigInt(0), isPending } = useSendTransactionGas({
34779
34724
  chain,
34780
34725
  token,
34781
34726
  from,
@@ -34820,7 +34765,7 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
34820
34765
  return {
34821
34766
  estimatedGas,
34822
34767
  isBalanceEnough,
34823
- isLoading,
34768
+ isPending,
34824
34769
  isNativeBalanceEnoughToPayGasFees,
34825
34770
  minAmountValueWarnMsg,
34826
34771
  };
@@ -35066,6 +35011,126 @@ async function sendTransactionStellar({ amount, signer, to, token, chain, }) {
35066
35011
  };
35067
35012
  }
35068
35013
 
35014
+ // Prevent fetching too soon after the first successful request.
35015
+ const DEFAULT_STALE_TIME = 8000;
35016
+ const defaultOptions = {
35017
+ queries: {
35018
+ staleTime: DEFAULT_STALE_TIME,
35019
+ refetchOnWindowFocus: false,
35020
+ retry: false,
35021
+ retryOnMount: false,
35022
+ },
35023
+ };
35024
+
35025
+ const queryClient = new QueryClient({ defaultOptions });
35026
+ const verifyIntegratorIdValidity = (integratorId) => {
35027
+ if (!integratorId) {
35028
+ throw new Error("Integrator ID is required");
35029
+ }
35030
+ };
35031
+ const SquidProvider = ({ children, config, placeholder, }) => {
35032
+ verifyIntegratorIdValidity(config.integratorId);
35033
+ const [wagmiConfig, setWagmiConfig] = useState();
35034
+ const sdkInitializedRef = useRef(false);
35035
+ const initializeSdk = useCallback(async () => {
35036
+ if (sdkInitializedRef.current) {
35037
+ return;
35038
+ }
35039
+ sdkInitializedRef.current = true;
35040
+ try {
35041
+ const squid = new Squid({
35042
+ integratorId: config.integratorId,
35043
+ baseUrl: config.apiUrl ?? squidApiBaseUrl,
35044
+ });
35045
+ const [sdkInfoResponse, assetsColorsResponse] = await Promise.allSettled([
35046
+ squid.init(),
35047
+ fetchAssetsColors(),
35048
+ ]);
35049
+ if (sdkInfoResponse.status === "rejected") {
35050
+ throw sdkInfoResponse.reason;
35051
+ }
35052
+ if (assetsColorsResponse.status === "fulfilled") {
35053
+ useAssetsColorsStore.setState(assetsColorsResponse.value);
35054
+ initializeSquidWithAssetsColors(squid, assetsColorsResponse.value);
35055
+ }
35056
+ const shouldResetSwapRouteStore =
35057
+ // reset swap route if specified in config
35058
+ !config?.loadPreviousStateFromLocalStorage ||
35059
+ // or if initial assets are provided
35060
+ !isEmptyObject(config.initialAssets?.from) ||
35061
+ !isEmptyObject(config.initialAssets?.to);
35062
+ if (shouldResetSwapRouteStore) {
35063
+ useSwapRoutePersistStore.setState({
35064
+ swapRoute: undefined,
35065
+ });
35066
+ }
35067
+ useSquidStore.setState((_) => ({
35068
+ squid,
35069
+ maintenanceMode: { active: false, message: undefined },
35070
+ }));
35071
+ const newWagmiConfig = createWagmiConfig(squid.chains);
35072
+ setWagmiConfig(newWagmiConfig);
35073
+ useConfigStore.setState({
35074
+ isInitialized: true,
35075
+ config: getConfigWithDefaults(config),
35076
+ });
35077
+ }
35078
+ catch (error) {
35079
+ const isAxios503Error = error.isAxiosError &&
35080
+ error.response?.status === 503;
35081
+ if (isAxios503Error) {
35082
+ const maintenanceMessage = error.response?.data
35083
+ ?.message ?? undefined;
35084
+ // Even with an error, we want wagmi to be defined so that we can display the maintenance mode layout
35085
+ // Create wagmi config with mainnet as fallback in maintenance mode
35086
+ const newWagmiConfig = createConfig({
35087
+ chains: [mainnet],
35088
+ connectors: [injected()],
35089
+ transports: {
35090
+ [mainnet.id]: http(),
35091
+ },
35092
+ });
35093
+ setWagmiConfig(newWagmiConfig);
35094
+ useConfigStore.setState({
35095
+ isInitialized: false,
35096
+ config: getConfigWithDefaults(config),
35097
+ });
35098
+ useSquidStore.setState({
35099
+ squid: undefined,
35100
+ maintenanceMode: {
35101
+ active: true,
35102
+ message: maintenanceMessage,
35103
+ },
35104
+ });
35105
+ }
35106
+ else {
35107
+ console.error("Error initializing SDK:", error);
35108
+ }
35109
+ }
35110
+ }, [config]);
35111
+ useEffect(() => {
35112
+ initializeSdk();
35113
+ }, [initializeSdk]);
35114
+ return wagmiConfig ? (React.createElement(WagmiProvider, { reconnectOnMount: false, config: wagmiConfig },
35115
+ React.createElement(QueryClientProvider, { client: queryClient },
35116
+ React.createElement(StellarProvider, null,
35117
+ React.createElement(EvmProvider, null,
35118
+ React.createElement(XrplProvider, null,
35119
+ React.createElement(SuiProvider, null,
35120
+ React.createElement(SolanaProvider, null,
35121
+ React.createElement(BitcoinProvider, null,
35122
+ React.createElement(CosmosProvider, null, children)))))))))) : (placeholder);
35123
+ };
35124
+
35125
+ const para = new Para("beta_c529f95c6a31bfb50487b0929a19b682");
35126
+ const connector = paraConnector({
35127
+ para,
35128
+ appName: SQUID_METADATA.name,
35129
+ isGuestModeEnabled: false,
35130
+ hideWallets: true,
35131
+ options: {},
35132
+ queryClient: queryClient,
35133
+ });
35069
35134
  const createWagmiConfig = (squidChains) => {
35070
35135
  const filteredEvmChains = squidChains.filter((chain) => chain.chainType === ChainType.EVM);
35071
35136
  if (filteredEvmChains.length === 0) {
@@ -35121,6 +35186,8 @@ const createWagmiConfig = (squidChains) => {
35121
35186
  description: SQUID_METADATA.description,
35122
35187
  },
35123
35188
  }),
35189
+ // @ts-expect-error - TODO: fix types
35190
+ connector,
35124
35191
  ],
35125
35192
  });
35126
35193
  };
@@ -35403,7 +35470,9 @@ function useSendTransaction({ to, amount, token, chain, }) {
35403
35470
  });
35404
35471
  },
35405
35472
  onSuccess: (tx, variables) => {
35406
- queryClient.invalidateQueries(getPrefixKey(QueryKeys.Balance));
35473
+ queryClient.invalidateQueries({
35474
+ queryKey: getPrefixKey(QueryKeys.Balance),
35475
+ });
35407
35476
  setTransactionState(variables.id, tx);
35408
35477
  persistTransaction({
35409
35478
  txType: HistoryTxType.SEND,
@@ -35730,9 +35799,10 @@ const useAllTransactionsStatus = ({ enabled }) => {
35730
35799
  queryKey: keys().fiatToCryptoStatus(data.orderId),
35731
35800
  retry: TX_STATUS_CONSTANTS.RETRY_COUNT,
35732
35801
  retryDelay: TX_STATUS_CONSTANTS.RETRY_DELAY,
35733
- refetchInterval: (data) => {
35734
- if (data?.status &&
35735
- FINAL_TRANSACTION_STATUSES.includes(data.status)) {
35802
+ refetchInterval: (query) => {
35803
+ const { state } = query;
35804
+ if (state.data?.status &&
35805
+ FINAL_TRANSACTION_STATUSES.includes(state.data.status)) {
35736
35806
  return false;
35737
35807
  }
35738
35808
  return TX_STATUS_CONSTANTS.REFETCH_INTERVAL;
@@ -35792,7 +35862,7 @@ const useAllTransactionsStatus = ({ enabled }) => {
35792
35862
  queries: enabled && config.apiUrl ? statusQueries : [],
35793
35863
  });
35794
35864
  return {
35795
- isLoading: queries.some((q) => q.isLoading),
35865
+ isPending: queries.some((q) => q.isPending),
35796
35866
  isError: queries.some((q) => q.isError),
35797
35867
  data: queries.map((q) => q.data).filter(Boolean),
35798
35868
  };
@@ -36051,16 +36121,18 @@ const useApproval = ({ squidRoute, }) => {
36051
36121
  * On Error: Showing the error message if any
36052
36122
  * @returns {boolean} approved
36053
36123
  */
36054
- const routeApproved = useQuery(keys().routeApproved(squidRoute, allowanceInWei), async () => {
36055
- // Approval is only needed for EVM chains
36056
- if (getChainType(squidRoute?.params.fromChain) === ChainType.EVM) {
36057
- return hasAllowance;
36058
- }
36059
- return true;
36060
- }, {
36124
+ const routeApproved = useQuery({
36125
+ queryKey: keys().routeApproved(squidRoute, allowanceInWei),
36126
+ queryFn: async () => {
36127
+ // Approval is only needed for EVM chains
36128
+ if (getChainType(squidRoute?.params.fromChain) === ChainType.EVM) {
36129
+ return hasAllowance;
36130
+ }
36131
+ return true;
36132
+ },
36061
36133
  enabled: !!squidRoute &&
36062
36134
  !!sourceUserAddress &&
36063
- !allowanceQuery?.isLoading &&
36135
+ !allowanceQuery?.isPending &&
36064
36136
  allowanceQuery?.isFetched,
36065
36137
  });
36066
36138
  // USDT has a very specific way of handling approvals
@@ -36149,81 +36221,84 @@ const useApproval = ({ squidRoute, }) => {
36149
36221
  /**
36150
36222
  * Manually approve route if necessary
36151
36223
  */
36152
- const approveRoute = useMutation(async () => {
36153
- try {
36154
- if (fromToken?.address === nativeEvmTokenAddress) {
36155
- return true;
36156
- }
36157
- if (!!squidRoute && walletClient && fromToken && evmSigner && squid) {
36158
- await approveSpecificTokenToZero(fromToken);
36159
- try {
36160
- // If needed, we can switch the chain here
36161
- // If already on the correct chain, this will do nothing
36162
- await switchChainAsync({ chainId: Number(fromChain?.chainId) });
36163
- }
36164
- catch (error) {
36165
- console.error("Error switching network:", error);
36224
+ const approveRoute = useMutation({
36225
+ mutationFn: async () => {
36226
+ try {
36227
+ if (fromToken?.address === nativeEvmTokenAddress) {
36228
+ return true;
36166
36229
  }
36167
- let approveTx;
36168
- if (useIcs20) {
36169
- const channel = squidRoute.estimate.actions[0].data
36170
- .ibcChannel;
36171
- const ics20Interface = new ethers.Interface(ics20Abi);
36172
- const approveData = ics20Interface.encodeFunctionData("approve", [
36173
- squidRoute.params.fromAddress,
36174
- [
36175
- {
36176
- sourcePort: "transfer",
36177
- sourceChannel: channel,
36178
- spendLimit: [
36179
- {
36180
- denom: squidRoute.estimate.actions[0].fromToken
36181
- .originalAddress,
36182
- amount: squidRoute.params.fromAmount,
36183
- },
36184
- ],
36185
- allowList: [],
36186
- allowedPacketData: ["*"],
36230
+ if (!!squidRoute && walletClient && fromToken && evmSigner && squid) {
36231
+ await approveSpecificTokenToZero(fromToken);
36232
+ try {
36233
+ // If needed, we can switch the chain here
36234
+ // If already on the correct chain, this will do nothing
36235
+ await switchChainAsync({ chainId: Number(fromChain?.chainId) });
36236
+ }
36237
+ catch (error) {
36238
+ console.error("Error switching network:", error);
36239
+ }
36240
+ let approveTx;
36241
+ if (useIcs20) {
36242
+ const channel = squidRoute.estimate.actions[0].data
36243
+ .ibcChannel;
36244
+ const ics20Interface = new ethers.Interface(ics20Abi);
36245
+ const approveData = ics20Interface.encodeFunctionData("approve", [
36246
+ squidRoute.params.fromAddress,
36247
+ [
36248
+ {
36249
+ sourcePort: "transfer",
36250
+ sourceChannel: channel,
36251
+ spendLimit: [
36252
+ {
36253
+ denom: squidRoute.estimate.actions[0].fromToken
36254
+ .originalAddress,
36255
+ amount: squidRoute.params.fromAmount,
36256
+ },
36257
+ ],
36258
+ allowList: [],
36259
+ allowedPacketData: ["*"],
36260
+ },
36261
+ ],
36262
+ ]);
36263
+ approveTx = await evmSigner.sendTransaction({
36264
+ to: squidRoute.transactionRequest.target,
36265
+ data: approveData,
36266
+ value: "0",
36267
+ gasLimit: squidRoute.transactionRequest
36268
+ .gasLimit,
36269
+ gasPrice: squidRoute.transactionRequest
36270
+ .gasPrice,
36271
+ });
36272
+ }
36273
+ else {
36274
+ approveTx = await squid.approveRoute({
36275
+ route: squidRoute,
36276
+ signer: evmSigner,
36277
+ // For security reasons, we don't want to allow infinite approvals in our frontends
36278
+ executionSettings: {
36279
+ infiniteApproval: false,
36187
36280
  },
36188
- ],
36189
- ]);
36190
- approveTx = await evmSigner.sendTransaction({
36191
- to: squidRoute.transactionRequest.target,
36192
- data: approveData,
36193
- value: "0",
36194
- gasLimit: squidRoute.transactionRequest
36195
- .gasLimit,
36196
- gasPrice: squidRoute.transactionRequest
36197
- .gasPrice,
36198
- });
36199
- }
36200
- else {
36201
- approveTx = await squid.approveRoute({
36202
- route: squidRoute,
36203
- signer: evmSigner,
36204
- // For security reasons, we don't want to allow infinite approvals in our frontends
36205
- executionSettings: {
36206
- infiniteApproval: false,
36207
- },
36208
- });
36209
- }
36210
- if (isProblematicConnector(activeConnector)) {
36211
- await sleep(3_000);
36281
+ });
36282
+ }
36283
+ if (isProblematicConnector(activeConnector)) {
36284
+ await sleep(3_000);
36285
+ }
36286
+ await approveTx?.wait();
36287
+ return true;
36212
36288
  }
36213
- await approveTx?.wait();
36214
- return true;
36289
+ return false;
36215
36290
  }
36216
- return false;
36217
- }
36218
- catch (error) {
36219
- // Keep the error in the console to debug future issues
36220
- console.error(error);
36221
- return false;
36222
- }
36223
- }, {
36291
+ catch (error) {
36292
+ // Keep the error in the console to debug future issues
36293
+ console.error(error);
36294
+ return false;
36295
+ }
36296
+ },
36224
36297
  onSuccess: async () => {
36225
36298
  await allowanceQuery?.refetch();
36226
- queryClient.invalidateQueries(getPrefixKey(QueryKeys.RouteApproved));
36299
+ queryClient.invalidateQueries({
36300
+ queryKey: getPrefixKey(QueryKeys.RouteApproved),
36301
+ });
36227
36302
  // After an approval, we refetch the transaction query with all required parameters
36228
36303
  // This is to ensure we're using the latest expiry timestamp
36229
36304
  if (squidRoute) {
@@ -39343,8 +39418,10 @@ const useExecuteTransaction = (squidRoute) => {
39343
39418
  }
39344
39419
  }, [cosmosSigner, fromChain]);
39345
39420
  const resetQueriesAfterTxSigned = () => {
39346
- queryClient.refetchQueries(getPrefixKey(QueryKeys.Balance));
39347
- queryClient.invalidateQueries(getPrefixKey(QueryKeys.Transaction));
39421
+ queryClient.refetchQueries({ queryKey: getPrefixKey(QueryKeys.Balance) });
39422
+ queryClient.invalidateQueries({
39423
+ queryKey: getPrefixKey(QueryKeys.Transaction),
39424
+ });
39348
39425
  };
39349
39426
  const dispatchSignatureRequestEvent = useCallback((route) => {
39350
39427
  WidgetEvents.getInstance().dispatchSwapTxSignatureRequested({
@@ -39362,62 +39439,64 @@ const useExecuteTransaction = (squidRoute) => {
39362
39439
  txHash,
39363
39440
  }, findToken);
39364
39441
  }, [findToken]);
39365
- const swapMutationCosmos = useMutation(async ({ id, route }) => {
39366
- const fromChainId = route?.params.fromChain;
39367
- if (cosmosSigner && fromChainId) {
39368
- try {
39369
- const signingClient = await getCosmosSignerClient();
39370
- const signerAddress = (await cosmosSigner.getAccounts())[0].address;
39371
- if (signerAddress && signingClient && route) {
39372
- dispatchSignatureRequestEvent(route);
39373
- const tx$1 = (await squid?.executeRoute({
39374
- signer: signingClient,
39375
- signerAddress,
39376
- route,
39377
- }));
39378
- // set the tx state to loading, as soon as user signed the tx
39379
- setTransactionState({
39380
- txHash: "",
39381
- route,
39382
- status: TransactionStatus.ONGOING,
39383
- sourceStatus: TransactionStatus.ONGOING,
39384
- id,
39385
- });
39386
- // broadcast the signed tx to get hash and listen to events
39387
- const response = await signingClient.broadcastTx(tx.TxRaw.encode(tx$1).finish());
39388
- const hash = response.transactionHash;
39389
- if (hash) {
39390
- resetQueriesAfterTxSigned();
39391
- }
39392
- // Dispatch event so it can be listened from outside the widget
39393
- WidgetEvents.getInstance().dispatchSwapExecuteCall(route, hash);
39394
- const txParams = setTransactionState({
39395
- route,
39396
- txHash: hash,
39397
- userAddress: sourceUserAddress,
39398
- status: TransactionStatus.ONGOING,
39399
- sourceStatus: TransactionStatus.ONGOING,
39400
- axelarUrl: undefined,
39401
- id,
39402
- });
39403
- if (txParams) {
39404
- addSwapTransaction({
39405
- ...txParams,
39406
- params: route.params,
39407
- estimate: route.estimate,
39442
+ const swapMutationCosmos = useMutation({
39443
+ mutationFn: async ({ id, route }) => {
39444
+ const fromChainId = route?.params.fromChain;
39445
+ if (cosmosSigner && fromChainId) {
39446
+ try {
39447
+ const signingClient = await getCosmosSignerClient();
39448
+ const signerAddress = (await cosmosSigner.getAccounts())[0].address;
39449
+ if (signerAddress && signingClient && route) {
39450
+ dispatchSignatureRequestEvent(route);
39451
+ const tx$1 = (await squid?.executeRoute({
39452
+ signer: signingClient,
39453
+ signerAddress,
39454
+ route,
39455
+ }));
39456
+ // set the tx state to loading, as soon as user signed the tx
39457
+ setTransactionState({
39458
+ txHash: "",
39459
+ route,
39460
+ status: TransactionStatus.ONGOING,
39461
+ sourceStatus: TransactionStatus.ONGOING,
39462
+ id,
39463
+ });
39464
+ // broadcast the signed tx to get hash and listen to events
39465
+ const response = await signingClient.broadcastTx(tx.TxRaw.encode(tx$1).finish());
39466
+ const hash = response.transactionHash;
39467
+ if (hash) {
39468
+ resetQueriesAfterTxSigned();
39469
+ }
39470
+ // Dispatch event so it can be listened from outside the widget
39471
+ WidgetEvents.getInstance().dispatchSwapExecuteCall(route, hash);
39472
+ const txParams = setTransactionState({
39473
+ route,
39474
+ txHash: hash,
39475
+ userAddress: sourceUserAddress,
39476
+ status: TransactionStatus.ONGOING,
39477
+ sourceStatus: TransactionStatus.ONGOING,
39478
+ axelarUrl: undefined,
39479
+ id,
39408
39480
  });
39481
+ if (txParams) {
39482
+ addSwapTransaction({
39483
+ ...txParams,
39484
+ params: route.params,
39485
+ estimate: route.estimate,
39486
+ });
39487
+ }
39488
+ return response.code === 0;
39409
39489
  }
39410
- return response.code === 0;
39411
39490
  }
39412
- }
39413
- catch (error) {
39414
- console.error("Error executing Cosmos transaction", error);
39415
- if (isUserRejectionError(normalizeError(error))) {
39416
- throw new Error("Request rejected");
39491
+ catch (error) {
39492
+ console.error("Error executing Cosmos transaction", error);
39493
+ if (isUserRejectionError(normalizeError(error))) {
39494
+ throw new Error("Request rejected");
39495
+ }
39417
39496
  }
39418
39497
  }
39419
- }
39420
- throw new Error("Need all parameters");
39498
+ throw new Error("Need all parameters");
39499
+ },
39421
39500
  });
39422
39501
  // If the transaction is replaced, we need to update the transaction hash
39423
39502
  // Transaction replaced can mean that the user has speed up the transaction for example
@@ -39470,97 +39549,126 @@ const useExecuteTransaction = (squidRoute) => {
39470
39549
  throw error;
39471
39550
  }
39472
39551
  }, [replaceSwapTransactionNonce, setTransactionState, sourceUserAddress]);
39473
- const swapMutationEvm = useMutation(async ({ id, route }) => {
39474
- await changeNetworkIfNeeded.mutateAsync();
39475
- if (!route || !squid || !evmSigner) {
39476
- throw new Error("Need all parameters");
39477
- }
39478
- dispatchSignatureRequestEvent(route);
39479
- const txResponse = (await squid.executeRoute({
39480
- bypassBalanceChecks: true,
39481
- signer: evmSigner,
39482
- route,
39483
- }));
39484
- let hash = txResponse.hash;
39485
- if (activeConnector?.id === "safe") {
39486
- hash = await getGnosisTransactionHash(txResponse.hash);
39487
- }
39488
- if (hash) {
39489
- resetQueriesAfterTxSigned();
39490
- }
39491
- // Dispatch event so it can be listened from outside the widget
39492
- WidgetEvents.getInstance().dispatchSwapExecuteCall(route, hash);
39493
- if (route.transactionRequest) {
39494
- const txParams = setTransactionState({
39552
+ const swapMutationEvm = useMutation({
39553
+ mutationFn: async ({ id, route }) => {
39554
+ await changeNetworkIfNeeded.mutateAsync();
39555
+ if (!route || !squid || !evmSigner) {
39556
+ throw new Error("Need all parameters");
39557
+ }
39558
+ dispatchSignatureRequestEvent(route);
39559
+ const txResponse = (await squid.executeRoute({
39560
+ bypassBalanceChecks: true,
39561
+ signer: evmSigner,
39495
39562
  route,
39496
- txHash: hash,
39497
- nonce: txResponse.nonce,
39498
- userAddress: sourceUserAddress,
39499
- status: TransactionStatus.INITIAL_LOADING,
39500
- sourceStatus: TransactionStatus.ONGOING,
39501
- axelarUrl: undefined,
39502
- id,
39503
- });
39504
- if (txParams) {
39505
- addSwapTransaction({
39506
- ...txParams,
39507
- params: route.params,
39508
- estimate: route.estimate,
39509
- });
39563
+ }));
39564
+ let hash = txResponse.hash;
39565
+ if (activeConnector?.id === "safe") {
39566
+ hash = await getGnosisTransactionHash(txResponse.hash);
39510
39567
  }
39511
- }
39512
- try {
39513
- if (isProblematicConnector(activeConnector)) {
39514
- await sleep(3_000);
39568
+ if (hash) {
39569
+ resetQueriesAfterTxSigned();
39515
39570
  }
39516
- const response = await txResponse.wait();
39517
- return response;
39518
- }
39519
- catch (error) {
39520
- return handleTransactionReplacementError({
39521
- error,
39522
- route,
39523
- status: TransactionStatus.INITIAL_LOADING,
39524
- sourceStatus: TransactionStatus.ONGOING,
39525
- userAddress: sourceUserAddress,
39526
- axelarUrl: undefined,
39527
- id,
39528
- });
39529
- }
39530
- });
39531
- const swapMutationSolana = useMutation(async ({ id, route }) => {
39532
- try {
39533
- if (!route) {
39534
- throw new Error("Route is required");
39571
+ // Dispatch event so it can be listened from outside the widget
39572
+ WidgetEvents.getInstance().dispatchSwapExecuteCall(route, hash);
39573
+ if (route.transactionRequest) {
39574
+ const txParams = setTransactionState({
39575
+ route,
39576
+ txHash: hash,
39577
+ nonce: txResponse.nonce,
39578
+ userAddress: sourceUserAddress,
39579
+ status: TransactionStatus.INITIAL_LOADING,
39580
+ sourceStatus: TransactionStatus.ONGOING,
39581
+ axelarUrl: undefined,
39582
+ id,
39583
+ });
39584
+ if (txParams) {
39585
+ addSwapTransaction({
39586
+ ...txParams,
39587
+ params: route.params,
39588
+ estimate: route.estimate,
39589
+ });
39590
+ }
39535
39591
  }
39536
- if (!solanaSigner) {
39537
- throw new Error("Solana signer is required");
39592
+ try {
39593
+ if (isProblematicConnector(activeConnector)) {
39594
+ await sleep(3_000);
39595
+ }
39596
+ const response = await txResponse.wait();
39597
+ return response;
39538
39598
  }
39539
- if (!route.params.fromAddress || !route.params.toAddress) {
39540
- throw new Error("From or to address is required");
39599
+ catch (error) {
39600
+ return handleTransactionReplacementError({
39601
+ error,
39602
+ route,
39603
+ status: TransactionStatus.INITIAL_LOADING,
39604
+ sourceStatus: TransactionStatus.ONGOING,
39605
+ userAddress: sourceUserAddress,
39606
+ axelarUrl: undefined,
39607
+ id,
39608
+ });
39541
39609
  }
39542
- const isDirectTransfer = isDepositRoute(route);
39543
- // Means it's a transfer to a deposit address
39544
- // Instead of a Swap/Contract call using a DEX like Jupiter
39545
- if (isDirectTransfer) {
39546
- // Get the deposit address from the squidRoute
39547
- const depositData = useDepositAddressStore.getState().deposit;
39548
- // Validate params
39549
- if (!depositData?.depositAddress) {
39550
- throw new Error("Deposit address is required");
39610
+ },
39611
+ });
39612
+ const swapMutationSolana = useMutation({
39613
+ mutationFn: async ({ id, route }) => {
39614
+ try {
39615
+ if (!route) {
39616
+ throw new Error("Route is required");
39617
+ }
39618
+ if (!solanaSigner) {
39619
+ throw new Error("Solana signer is required");
39620
+ }
39621
+ if (!route.params.fromAddress || !route.params.toAddress) {
39622
+ throw new Error("From or to address is required");
39623
+ }
39624
+ const isDirectTransfer = isDepositRoute(route);
39625
+ // Means it's a transfer to a deposit address
39626
+ // Instead of a Swap/Contract call using a DEX like Jupiter
39627
+ if (isDirectTransfer) {
39628
+ // Get the deposit address from the squidRoute
39629
+ const depositData = useDepositAddressStore.getState().deposit;
39630
+ // Validate params
39631
+ if (!depositData?.depositAddress) {
39632
+ throw new Error("Deposit address is required");
39633
+ }
39634
+ const signature = await executeSolanaTransfer({
39635
+ amount: BigInt(route.params.fromAmount),
39636
+ target: depositData.depositAddress,
39637
+ signer: solanaSigner,
39638
+ connection: solanaConnection,
39639
+ sourceToken: findToken(route.params.fromToken, route?.params?.fromChain),
39640
+ onSigned: (txHash) => {
39641
+ WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
39642
+ const txParams = setTransactionState({
39643
+ route,
39644
+ txHash,
39645
+ transactionIdForStatus: depositData.chainflipStatusTrackingId,
39646
+ userAddress: sourceUserAddress,
39647
+ status: TransactionStatus.INITIAL_LOADING,
39648
+ sourceStatus: TransactionStatus.ONGOING,
39649
+ id,
39650
+ });
39651
+ if (txParams) {
39652
+ addSwapTransaction({
39653
+ ...txParams,
39654
+ params: route.params,
39655
+ estimate: route.estimate,
39656
+ });
39657
+ }
39658
+ },
39659
+ });
39660
+ return signature;
39551
39661
  }
39552
- const signature = await executeSolanaTransfer({
39553
- amount: BigInt(route.params.fromAmount),
39554
- target: depositData.depositAddress,
39662
+ const signature = await executeSolanaSwap({
39663
+ route,
39555
39664
  signer: solanaSigner,
39556
39665
  connection: solanaConnection,
39557
- sourceToken: findToken(route.params.fromToken, route?.params?.fromChain),
39558
39666
  onSigned: (txHash) => {
39559
39667
  WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
39560
39668
  const txParams = setTransactionState({
39561
39669
  route,
39562
39670
  txHash,
39563
- transactionIdForStatus: depositData.chainflipStatusTrackingId,
39671
+ transactionIdForStatus: undefined,
39564
39672
  userAddress: sourceUserAddress,
39565
39673
  status: TransactionStatus.INITIAL_LOADING,
39566
39674
  sourceStatus: TransactionStatus.ONGOING,
@@ -39577,39 +39685,13 @@ const useExecuteTransaction = (squidRoute) => {
39577
39685
  });
39578
39686
  return signature;
39579
39687
  }
39580
- const signature = await executeSolanaSwap({
39581
- route,
39582
- signer: solanaSigner,
39583
- connection: solanaConnection,
39584
- onSigned: (txHash) => {
39585
- WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
39586
- const txParams = setTransactionState({
39587
- route,
39588
- txHash,
39589
- transactionIdForStatus: undefined,
39590
- userAddress: sourceUserAddress,
39591
- status: TransactionStatus.INITIAL_LOADING,
39592
- sourceStatus: TransactionStatus.ONGOING,
39593
- id,
39594
- });
39595
- if (txParams) {
39596
- addSwapTransaction({
39597
- ...txParams,
39598
- params: route.params,
39599
- estimate: route.estimate,
39600
- });
39601
- }
39602
- },
39603
- });
39604
- return signature;
39605
- }
39606
- catch (error) {
39607
- console.error("Solana transaction failed:", error);
39608
- throw error instanceof Error
39609
- ? error
39610
- : new Error("Failed to execute Solana transaction");
39611
- }
39612
- }, {
39688
+ catch (error) {
39689
+ console.error("Solana transaction failed:", error);
39690
+ throw error instanceof Error
39691
+ ? error
39692
+ : new Error("Failed to execute Solana transaction");
39693
+ }
39694
+ },
39613
39695
  onError: (error, variables) => {
39614
39696
  const currentTx = getTransaction(variables.id);
39615
39697
  const errorObject = getTransactionError(error);
@@ -39630,7 +39712,9 @@ const useExecuteTransaction = (squidRoute) => {
39630
39712
  },
39631
39713
  onSuccess: (_data, variables) => {
39632
39714
  const currentTx = getTransaction(variables.id);
39633
- queryClient.invalidateQueries(getPrefixKey(QueryKeys.Balances));
39715
+ queryClient.invalidateQueries({
39716
+ queryKey: getPrefixKey(QueryKeys.Balances),
39717
+ });
39634
39718
  if (isSameChain && currentTx?.transactionId) {
39635
39719
  replaceSwapTransactionStatus({
39636
39720
  transactionId: currentTx.transactionId,
@@ -39647,197 +39731,207 @@ const useExecuteTransaction = (squidRoute) => {
39647
39731
  });
39648
39732
  },
39649
39733
  });
39650
- const swapMutationBitcoin = useMutation(async ({ id, route }) => {
39651
- const { depositAddress, amount: sendAmount, chainflipStatusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
39652
- if (!depositAddress) {
39653
- throw new Error(`Invalid deposit address: ${depositAddress}`);
39654
- }
39655
- if (!sendAmount) {
39656
- throw new Error(`Invalid send amount: ${sendAmount}`);
39657
- }
39658
- const allParamsValid = route && bitcoinSigner && depositAddress && sendAmount;
39659
- await changeNetworkIfNeeded.mutateAsync();
39660
- if (allParamsValid) {
39661
- dispatchSignatureRequestEvent(route);
39662
- const { txHash } = await bitcoinSigner.sendBTC(depositAddress, Number(sendAmount));
39734
+ const swapMutationBitcoin = useMutation({
39735
+ mutationFn: async ({ id, route }) => {
39736
+ const { depositAddress, amount: sendAmount, chainflipStatusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
39737
+ if (!depositAddress) {
39738
+ throw new Error(`Invalid deposit address: ${depositAddress}`);
39739
+ }
39740
+ if (!sendAmount) {
39741
+ throw new Error(`Invalid send amount: ${sendAmount}`);
39742
+ }
39743
+ const allParamsValid = route && bitcoinSigner && depositAddress && sendAmount;
39744
+ await changeNetworkIfNeeded.mutateAsync();
39745
+ if (allParamsValid) {
39746
+ dispatchSignatureRequestEvent(route);
39747
+ const { txHash } = await bitcoinSigner.sendBTC(depositAddress, Number(sendAmount));
39748
+ if (txHash) {
39749
+ resetQueriesAfterTxSigned();
39750
+ }
39751
+ // Dispatch event so it can be listened from outside the widget
39752
+ WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
39753
+ if (route.transactionRequest) {
39754
+ const txParams = setTransactionState({
39755
+ route,
39756
+ txHash,
39757
+ // When bridging from Bitcoin we need to send the chainflipId to the status endpoint
39758
+ // instead of the Bitcoin transaction hash
39759
+ transactionIdForStatus: chainflipStatusTrackingId,
39760
+ userAddress: sourceUserAddress,
39761
+ status: TransactionStatus.INITIAL_LOADING,
39762
+ sourceStatus: TransactionStatus.ONGOING,
39763
+ axelarUrl: undefined,
39764
+ id,
39765
+ });
39766
+ if (txParams) {
39767
+ addSwapTransaction({
39768
+ ...txParams,
39769
+ params: route.params,
39770
+ estimate: route.estimate,
39771
+ });
39772
+ }
39773
+ }
39774
+ }
39775
+ else {
39776
+ throw new Error("Need all parameters");
39777
+ }
39778
+ },
39779
+ });
39780
+ const swapMutationXrpl = useMutation({
39781
+ mutationFn: async ({ id, route }) => {
39782
+ if (!route?.transactionRequest || !xrplSigner) {
39783
+ throw new Error("Need all parameters");
39784
+ }
39785
+ if (route.transactionRequest.type !== SquidDataType.OnChainExecution) {
39786
+ throw new Error("Invalid route type");
39787
+ }
39788
+ const { data } = route.transactionRequest;
39789
+ const paymentTx = parseXrplPaymentTx(data);
39790
+ if (!paymentTx)
39791
+ throw new Error("Could not parse transaction");
39792
+ const fromChainId = route.params.fromChain;
39793
+ const xrplNetwork = getXrplNetwork(fromChainId);
39794
+ if (xrplNetwork == null) {
39795
+ throw new Error(`No XRPL network found for chainId '${fromChainId}'`);
39796
+ }
39797
+ const txRes = await xrplSigner.signAndSubmit({
39798
+ tx: paymentTx,
39799
+ network: xrplNetwork,
39800
+ });
39801
+ const txParams = setTransactionState({
39802
+ txHash: txRes.hash,
39803
+ id,
39804
+ sourceStatus: TransactionStatus.ONGOING,
39805
+ status: TransactionStatus.ONGOING,
39806
+ route: route,
39807
+ userAddress: sourceUserAddress,
39808
+ });
39809
+ if (txParams && route) {
39810
+ addSwapTransaction({
39811
+ ...txParams,
39812
+ params: route.params,
39813
+ estimate: route.estimate,
39814
+ });
39815
+ }
39816
+ if (txRes.status !== XrplTxStatus.SUCCESS) {
39817
+ throw new Error(`Transaction failed with status: ${txRes.status}`);
39818
+ }
39819
+ },
39820
+ });
39821
+ const swapMutationSui = useMutation({
39822
+ mutationFn: async ({ id, route }) => {
39823
+ if (!route || !suiSigner || !fromChain) {
39824
+ throw new Error("Need all parameters");
39825
+ }
39826
+ if (route.transactionRequest?.type !== SquidDataType.OnChainExecution) {
39827
+ throw new Error("Invalid route type");
39828
+ }
39829
+ const suiWalletState = connectedWalletsByChainType[ChainType.SUI];
39830
+ if (!suiWalletState.account) {
39831
+ throw new Error("Sui wallet is missing account data");
39832
+ }
39833
+ const fromChainId = route.params.fromChain;
39834
+ const suiChain = getSuiChain(fromChainId);
39835
+ if (!suiChain) {
39836
+ throw new Error(`Source chain (${fromChainId}) does not match any Sui chain`);
39837
+ }
39838
+ const suiClient = await getClient(fromChain);
39839
+ const txJson = route.transactionRequest.data;
39840
+ const tx = Transaction$2.from(txJson);
39841
+ const signedTx = await suiSigner.signTransaction({
39842
+ transaction: tx,
39843
+ account: suiWalletState.account,
39844
+ chain: suiChain,
39845
+ });
39846
+ // execute transaction without waiting for confirmation
39847
+ const txResponse = await suiClient.executeTransactionBlock({
39848
+ signature: signedTx.signature,
39849
+ transactionBlock: signedTx.bytes,
39850
+ });
39851
+ const txHash = txResponse.digest;
39663
39852
  if (txHash) {
39664
39853
  resetQueriesAfterTxSigned();
39665
39854
  }
39666
- // Dispatch event so it can be listened from outside the widget
39667
39855
  WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
39668
- if (route.transactionRequest) {
39669
- const txParams = setTransactionState({
39670
- route,
39671
- txHash,
39672
- // When bridging from Bitcoin we need to send the chainflipId to the status endpoint
39673
- // instead of the Bitcoin transaction hash
39674
- transactionIdForStatus: chainflipStatusTrackingId,
39675
- userAddress: sourceUserAddress,
39676
- status: TransactionStatus.INITIAL_LOADING,
39677
- sourceStatus: TransactionStatus.ONGOING,
39678
- axelarUrl: undefined,
39679
- id,
39856
+ const txParams = setTransactionState({
39857
+ route,
39858
+ txHash,
39859
+ userAddress: sourceUserAddress,
39860
+ status: TransactionStatus.INITIAL_LOADING,
39861
+ sourceStatus: TransactionStatus.ONGOING,
39862
+ id,
39863
+ });
39864
+ if (txParams) {
39865
+ addSwapTransaction({
39866
+ ...txParams,
39867
+ params: route.params,
39868
+ estimate: route.estimate,
39680
39869
  });
39681
- if (txParams) {
39682
- addSwapTransaction({
39683
- ...txParams,
39684
- params: route.params,
39685
- estimate: route.estimate,
39686
- });
39687
- }
39688
39870
  }
39689
- }
39690
- else {
39691
- throw new Error("Need all parameters");
39692
- }
39693
- });
39694
- const swapMutationXrpl = useMutation(async ({ id, route }) => {
39695
- if (!route?.transactionRequest || !xrplSigner) {
39696
- throw new Error("Need all parameters");
39697
- }
39698
- if (route.transactionRequest.type !== SquidDataType.OnChainExecution) {
39699
- throw new Error("Invalid route type");
39700
- }
39701
- const { data } = route.transactionRequest;
39702
- const paymentTx = parseXrplPaymentTx(data);
39703
- if (!paymentTx)
39704
- throw new Error("Could not parse transaction");
39705
- const fromChainId = route.params.fromChain;
39706
- const xrplNetwork = getXrplNetwork(fromChainId);
39707
- if (xrplNetwork == null) {
39708
- throw new Error(`No XRPL network found for chainId '${fromChainId}'`);
39709
- }
39710
- const txRes = await xrplSigner.signAndSubmit({
39711
- tx: paymentTx,
39712
- network: xrplNetwork,
39713
- });
39714
- const txParams = setTransactionState({
39715
- txHash: txRes.hash,
39716
- id,
39717
- sourceStatus: TransactionStatus.ONGOING,
39718
- status: TransactionStatus.ONGOING,
39719
- route: route,
39720
- userAddress: sourceUserAddress,
39721
- });
39722
- if (txParams && route) {
39723
- addSwapTransaction({
39724
- ...txParams,
39725
- params: route.params,
39726
- estimate: route.estimate,
39871
+ // wait for transaction confirmation
39872
+ await suiClient.waitForTransaction({
39873
+ digest: txHash,
39727
39874
  });
39728
- }
39729
- if (txRes.status !== XrplTxStatus.SUCCESS) {
39730
- throw new Error(`Transaction failed with status: ${txRes.status}`);
39731
- }
39732
- }, {});
39733
- const swapMutationSui = useMutation(async ({ id, route }) => {
39734
- if (!route || !suiSigner || !fromChain) {
39735
- throw new Error("Need all parameters");
39736
- }
39737
- if (route.transactionRequest?.type !== SquidDataType.OnChainExecution) {
39738
- throw new Error("Invalid route type");
39739
- }
39740
- const suiWalletState = connectedWalletsByChainType[ChainType.SUI];
39741
- if (!suiWalletState.account) {
39742
- throw new Error("Sui wallet is missing account data");
39743
- }
39744
- const fromChainId = route.params.fromChain;
39745
- const suiChain = getSuiChain(fromChainId);
39746
- if (!suiChain) {
39747
- throw new Error(`Source chain (${fromChainId}) does not match any Sui chain`);
39748
- }
39749
- const suiClient = await getClient(fromChain);
39750
- const txJson = route.transactionRequest.data;
39751
- const tx = Transaction$2.from(txJson);
39752
- const signedTx = await suiSigner.signTransaction({
39753
- transaction: tx,
39754
- account: suiWalletState.account,
39755
- chain: suiChain,
39756
- });
39757
- // execute transaction without waiting for confirmation
39758
- const txResponse = await suiClient.executeTransactionBlock({
39759
- signature: signedTx.signature,
39760
- transactionBlock: signedTx.bytes,
39761
- });
39762
- const txHash = txResponse.digest;
39763
- if (txHash) {
39764
- resetQueriesAfterTxSigned();
39765
- }
39766
- WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
39767
- const txParams = setTransactionState({
39768
- route,
39769
- txHash,
39770
- userAddress: sourceUserAddress,
39771
- status: TransactionStatus.INITIAL_LOADING,
39772
- sourceStatus: TransactionStatus.ONGOING,
39773
- id,
39774
- });
39775
- if (txParams) {
39776
- addSwapTransaction({
39777
- ...txParams,
39778
- params: route.params,
39779
- estimate: route.estimate,
39875
+ },
39876
+ });
39877
+ const swapMutationStellar = useMutation({
39878
+ mutationFn: async ({ id, route }) => {
39879
+ if (!stellarSigner || !route || !squid || !fromChain) {
39880
+ throw new Error("Need all parameters");
39881
+ }
39882
+ const fromChainId = route.params.fromChain;
39883
+ const stellarNetwork = getStellarNetwork(fromChainId);
39884
+ if (stellarNetwork == null) {
39885
+ throw new Error(`No Stellar network found for chainId ${fromChainId}`);
39886
+ }
39887
+ const { data: xdrHex, gasPrice } = route.transactionRequest;
39888
+ const { address } = await stellarSigner.getAddress();
39889
+ const client = await getClient(fromChain);
39890
+ const account = await client.getAccount(address);
39891
+ const operation = xdr.Operation.fromXDR(xdrHex, "hex");
39892
+ const builtTransaction = new TransactionBuilder(account, {
39893
+ fee: gasPrice || (BigInt(BASE_FEE) * BigInt(2)).toString(),
39894
+ networkPassphrase: stellarNetwork,
39895
+ })
39896
+ .addOperation(operation)
39897
+ .setTimeout(300)
39898
+ .build();
39899
+ const preparedTransaction = await client.prepareTransaction(builtTransaction);
39900
+ const { signedTxXdr } = await stellarSigner.signTransaction(preparedTransaction.toXDR(), {
39901
+ networkPassphrase: stellarNetwork,
39780
39902
  });
39781
- }
39782
- // wait for transaction confirmation
39783
- await suiClient.waitForTransaction({
39784
- digest: txHash,
39785
- });
39786
- }, {});
39787
- const swapMutationStellar = useMutation(async ({ id, route }) => {
39788
- if (!stellarSigner || !route || !squid || !fromChain) {
39789
- throw new Error("Need all parameters");
39790
- }
39791
- const fromChainId = route.params.fromChain;
39792
- const stellarNetwork = getStellarNetwork(fromChainId);
39793
- if (stellarNetwork == null) {
39794
- throw new Error(`No Stellar network found for chainId ${fromChainId}`);
39795
- }
39796
- const { data: xdrHex, gasPrice } = route.transactionRequest;
39797
- const { address } = await stellarSigner.getAddress();
39798
- const client = await getClient(fromChain);
39799
- const account = await client.getAccount(address);
39800
- const operation = xdr.Operation.fromXDR(xdrHex, "hex");
39801
- const builtTransaction = new TransactionBuilder(account, {
39802
- fee: gasPrice || (BigInt(BASE_FEE) * BigInt(2)).toString(),
39803
- networkPassphrase: stellarNetwork,
39804
- })
39805
- .addOperation(operation)
39806
- .setTimeout(300)
39807
- .build();
39808
- const preparedTransaction = await client.prepareTransaction(builtTransaction);
39809
- const { signedTxXdr } = await stellarSigner.signTransaction(preparedTransaction.toXDR(), {
39810
- networkPassphrase: stellarNetwork,
39811
- });
39812
- const signedTransaction = new Transaction$1(signedTxXdr, stellarNetwork);
39813
- // get hash before submitting
39814
- const hash = signedTransaction.hash().toString("hex");
39815
- if (hash) {
39816
- resetQueriesAfterTxSigned();
39817
- }
39818
- // Dispatch event so it can be listened from outside the widget
39819
- WidgetEvents.getInstance().dispatchSwapExecuteCall(route, hash);
39820
- const txParams = setTransactionState({
39821
- route,
39822
- txHash: hash,
39823
- userAddress: sourceUserAddress,
39824
- status: TransactionStatus.INITIAL_LOADING,
39825
- sourceStatus: TransactionStatus.ONGOING,
39826
- id,
39827
- });
39828
- if (txParams) {
39829
- addSwapTransaction({
39830
- ...txParams,
39831
- params: route.params,
39832
- estimate: route.estimate,
39903
+ const signedTransaction = new Transaction$1(signedTxXdr, stellarNetwork);
39904
+ // get hash before submitting
39905
+ const hash = signedTransaction.hash().toString("hex");
39906
+ if (hash) {
39907
+ resetQueriesAfterTxSigned();
39908
+ }
39909
+ // Dispatch event so it can be listened from outside the widget
39910
+ WidgetEvents.getInstance().dispatchSwapExecuteCall(route, hash);
39911
+ const txParams = setTransactionState({
39912
+ route,
39913
+ txHash: hash,
39914
+ userAddress: sourceUserAddress,
39915
+ status: TransactionStatus.INITIAL_LOADING,
39916
+ sourceStatus: TransactionStatus.ONGOING,
39917
+ id,
39833
39918
  });
39834
- }
39835
- const sentTransaction = await client.sendTransaction(signedTransaction);
39836
- await client.waitForTransaction(sentTransaction.hash);
39837
- }, {});
39919
+ if (txParams) {
39920
+ addSwapTransaction({
39921
+ ...txParams,
39922
+ params: route.params,
39923
+ estimate: route.estimate,
39924
+ });
39925
+ }
39926
+ const sentTransaction = await client.sendTransaction(signedTransaction);
39927
+ await client.waitForTransaction(sentTransaction.hash);
39928
+ },
39929
+ });
39838
39930
  const handleTransactionSuccess = useCallback((id) => {
39839
39931
  const currentTx = getTransaction(id);
39840
- queryClient.invalidateQueries(getPrefixKey(QueryKeys.Balances));
39932
+ queryClient.invalidateQueries({
39933
+ queryKey: getPrefixKey(QueryKeys.Balances),
39934
+ });
39841
39935
  if (isSameChain && currentTx?.transactionId) {
39842
39936
  replaceSwapTransactionStatus({
39843
39937
  transactionId: currentTx.transactionId,
@@ -39889,38 +39983,39 @@ const useExecuteTransaction = (squidRoute) => {
39889
39983
  setTransactionStoreState,
39890
39984
  squidRoute,
39891
39985
  ]);
39892
- const swapMutation = useMutation(async (mutationParams) => {
39893
- if (!mutationParams.route)
39894
- throw new Error("route is required");
39895
- const sourceChain = findChain(mutationParams.route.params?.fromChain);
39896
- if (!sourceChain)
39897
- throw new Error("Could not find source chain");
39898
- switch (sourceChain.chainType) {
39899
- case ChainType.COSMOS: {
39900
- return swapMutationCosmos.mutateAsync(mutationParams);
39901
- }
39902
- case ChainType.EVM: {
39903
- return swapMutationEvm.mutateAsync(mutationParams);
39904
- }
39905
- case ChainType.BTC: {
39906
- return swapMutationBitcoin.mutateAsync(mutationParams);
39907
- }
39908
- case ChainType.SOLANA: {
39909
- return swapMutationSolana.mutateAsync(mutationParams);
39910
- }
39911
- case ChainType.SUI: {
39912
- return swapMutationSui.mutateAsync(mutationParams);
39913
- }
39914
- case ChainType.XRPL: {
39915
- return swapMutationXrpl.mutateAsync(mutationParams);
39916
- }
39917
- case ChainType.STELLAR: {
39918
- return swapMutationStellar.mutateAsync(mutationParams);
39986
+ const swapMutation = useMutation({
39987
+ mutationFn: async (mutationParams) => {
39988
+ if (!mutationParams.route)
39989
+ throw new Error("route is required");
39990
+ const sourceChain = findChain(mutationParams.route.params?.fromChain);
39991
+ if (!sourceChain)
39992
+ throw new Error("Could not find source chain");
39993
+ switch (sourceChain.chainType) {
39994
+ case ChainType.COSMOS: {
39995
+ return swapMutationCosmos.mutateAsync(mutationParams);
39996
+ }
39997
+ case ChainType.EVM: {
39998
+ return swapMutationEvm.mutateAsync(mutationParams);
39999
+ }
40000
+ case ChainType.BTC: {
40001
+ return swapMutationBitcoin.mutateAsync(mutationParams);
40002
+ }
40003
+ case ChainType.SOLANA: {
40004
+ return swapMutationSolana.mutateAsync(mutationParams);
40005
+ }
40006
+ case ChainType.SUI: {
40007
+ return swapMutationSui.mutateAsync(mutationParams);
40008
+ }
40009
+ case ChainType.XRPL: {
40010
+ return swapMutationXrpl.mutateAsync(mutationParams);
40011
+ }
40012
+ case ChainType.STELLAR: {
40013
+ return swapMutationStellar.mutateAsync(mutationParams);
40014
+ }
40015
+ default:
40016
+ throw new Error(`Swap mutation not implemented for chain type: ${sourceChain.chainType}`);
39919
40017
  }
39920
- default:
39921
- throw new Error(`Swap mutation not implemented for chain type: ${sourceChain.chainType}`);
39922
- }
39923
- }, {
40018
+ },
39924
40019
  onMutate: (variables) => {
39925
40020
  useTransactionStore.setState({
39926
40021
  txLocalId: variables.id,
@@ -39969,7 +40064,7 @@ const useExecuteTransaction = (squidRoute) => {
39969
40064
  toToken,
39970
40065
  toChain,
39971
40066
  fromChain,
39972
- isLoading: swapMutation.isLoading,
40067
+ isPending: swapMutation.isPending,
39973
40068
  error: swapMutation.error,
39974
40069
  };
39975
40070
  };
@@ -40030,57 +40125,59 @@ const useGetRoute = () => {
40030
40125
  * These data will be used to trigger the transaction
40031
40126
  * @returns {Route} Route data
40032
40127
  */
40033
- return useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice, bypassGuardrails, quoteOnly, fromChainType, postHook, preHook, }) => {
40034
- if (!fromChain || !toChain || !fromToken || !toToken || !fromPrice) {
40035
- return undefined;
40036
- }
40037
- // Dispatch requestQuote event
40038
- dispatchRequestQuoteEvent({
40039
- fromChain,
40040
- toChain,
40041
- fromToken: fromToken.address,
40042
- toToken: toToken.address,
40043
- fromAmount: fromPrice,
40044
- fromAddress: sourceUserAddress,
40045
- toAddress: destinationAddress,
40046
- });
40047
- const isEvmSwap = Number(fromChain) > 0 && Number(toChain) > 0;
40048
- const cosmosFallbackAddresses = quoteOnly || isEvmSwap ? undefined : await getCosmosFallbackAddresses();
40049
- const fromTokenAddress = fromToken.address;
40050
- const toTokenAddress = toToken.address;
40051
- const fromAmount = parseToBigInt(fromPrice?.toString() ?? "0", fromToken?.decimals).toString();
40052
- const fromAddress = sourceUserAddress ??
40053
- chainTypeToZeroAddressMap[fromChainType ?? ChainType.EVM];
40054
- const params = {
40055
- fromChain,
40056
- fromToken: fromTokenAddress,
40057
- fromAddress,
40058
- fromAmount,
40059
- toChain,
40060
- toToken: toTokenAddress,
40061
- toAddress: destinationAddress ?? "",
40062
- quoteOnly,
40063
- slippage: config.slippage === 0 ? undefined : config.slippage,
40064
- bypassGuardrails,
40065
- preHook,
40066
- postHook,
40067
- };
40068
- // If the swap is involving cosmos chains, we need to add the fallback addresses (if any)
40069
- if (cosmosFallbackAddresses &&
40070
- cosmosFallbackAddresses.length > 0 &&
40071
- cosmosFallbackAddresses[0].address) {
40072
- params.fallbackAddresses = cosmosFallbackAddresses;
40073
- }
40074
- const { route } = await squid.getRoute({
40075
- ...params,
40076
- });
40077
- // Cache the route data
40078
- // Useful when the getRoute mutation is called from another hook
40079
- queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, config.slippage, config.enableGetGasOnDestination, sourceUserAddress, config.degenMode, destinationAddress, swapRoute?.fallbackAddress, quoteOnly, fromChainType, config.preHook, config.postHook), route);
40080
- return route;
40128
+ return useMutation({
40129
+ mutationFn: async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice, bypassGuardrails, quoteOnly, fromChainType, postHook, preHook, }) => {
40130
+ if (!fromChain || !toChain || !fromToken || !toToken || !fromPrice) {
40131
+ return undefined;
40132
+ }
40133
+ // Dispatch requestQuote event
40134
+ dispatchRequestQuoteEvent({
40135
+ fromChain,
40136
+ toChain,
40137
+ fromToken: fromToken.address,
40138
+ toToken: toToken.address,
40139
+ fromAmount: fromPrice,
40140
+ fromAddress: sourceUserAddress,
40141
+ toAddress: destinationAddress,
40142
+ });
40143
+ const isEvmSwap = Number(fromChain) > 0 && Number(toChain) > 0;
40144
+ const cosmosFallbackAddresses = quoteOnly || isEvmSwap ? undefined : await getCosmosFallbackAddresses();
40145
+ const fromTokenAddress = fromToken.address;
40146
+ const toTokenAddress = toToken.address;
40147
+ const fromAmount = parseToBigInt(fromPrice?.toString() ?? "0", fromToken?.decimals).toString();
40148
+ const fromAddress = sourceUserAddress ??
40149
+ chainTypeToZeroAddressMap[fromChainType ?? ChainType.EVM];
40150
+ const params = {
40151
+ fromChain,
40152
+ fromToken: fromTokenAddress,
40153
+ fromAddress,
40154
+ fromAmount,
40155
+ toChain,
40156
+ toToken: toTokenAddress,
40157
+ toAddress: destinationAddress ?? "",
40158
+ quoteOnly,
40159
+ slippage: config.slippage === 0 ? undefined : config.slippage,
40160
+ bypassGuardrails,
40161
+ preHook,
40162
+ postHook,
40163
+ };
40164
+ // If the swap is involving cosmos chains, we need to add the fallback addresses (if any)
40165
+ if (cosmosFallbackAddresses &&
40166
+ cosmosFallbackAddresses.length > 0 &&
40167
+ cosmosFallbackAddresses[0].address) {
40168
+ params.fallbackAddresses = cosmosFallbackAddresses;
40169
+ }
40170
+ const { route } = await squid.getRoute({
40171
+ ...params,
40172
+ });
40173
+ // Cache the route data
40174
+ // Useful when the getRoute mutation is called from another hook
40175
+ queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, config.slippage, config.enableGetGasOnDestination, sourceUserAddress, config.degenMode, destinationAddress, swapRoute?.fallbackAddress, quoteOnly, fromChainType, config.preHook, config.postHook), route);
40176
+ return route;
40177
+ },
40081
40178
  });
40082
40179
  };
40083
- const useGetRouteWrapper = ({ enabled, cacheTime = 5 * 60 * 1000, // 5 minutes
40180
+ const useGetRouteWrapper = ({ enabled, gcTime = 5 * 60 * 1000, // 5 minutes
40084
40181
  staleTime = 60 * 1000, // 1 minute
40085
40182
  refetchOnWindowFocus = (query) => Date.now() - query.state.dataUpdatedAt > 30000, // Update if older than 30 seconds, when window is focused
40086
40183
  refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true, }) => {
@@ -40130,25 +40227,27 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
40130
40227
  * These data will be used to trigger the transaction
40131
40228
  * @returns {Route} Route data
40132
40229
  */
40133
- const squidRoute = useQuery(squidRouteQueryKeys, async () => {
40134
- const route = await getRouteMutation.mutateAsync({
40135
- fromChain: fromChain?.chainId,
40136
- toChain: toChain?.chainId,
40137
- fromToken,
40138
- toToken,
40139
- sourceUserAddress,
40140
- destinationAddress,
40141
- fromPrice,
40142
- bypassGuardrails: config.degenMode,
40143
- quoteOnly,
40144
- fromChainType: fromChain?.chainType,
40145
- postHook: config.postHook,
40146
- preHook: config.preHook,
40147
- });
40148
- return route;
40149
- }, {
40230
+ const squidRoute = useQuery({
40231
+ queryKey: squidRouteQueryKeys,
40232
+ queryFn: async () => {
40233
+ const route = await getRouteMutation.mutateAsync({
40234
+ fromChain: fromChain?.chainId,
40235
+ toChain: toChain?.chainId,
40236
+ fromToken,
40237
+ toToken,
40238
+ sourceUserAddress,
40239
+ destinationAddress,
40240
+ fromPrice,
40241
+ bypassGuardrails: config.degenMode,
40242
+ quoteOnly,
40243
+ fromChainType: fromChain?.chainType,
40244
+ postHook: config.postHook,
40245
+ preHook: config.preHook,
40246
+ });
40247
+ return route;
40248
+ },
40150
40249
  enabled: queryEnabled,
40151
- cacheTime,
40250
+ gcTime,
40152
40251
  staleTime,
40153
40252
  refetchOnWindowFocus,
40154
40253
  refetchIntervalInBackground,
@@ -40157,7 +40256,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
40157
40256
  /**
40158
40257
  * If last updated data is older than X seconds and the query is currently loading, show loading indicator
40159
40258
  */
40160
- const showLoading = useMemo(() => squidRoute.isFetching || squidRoute.isRefetching, [squidRoute.isFetching, squidRoute.isRefetching]);
40259
+ const showLoading = squidRoute.isFetching || squidRoute.isRefetching;
40161
40260
  return {
40162
40261
  squidRoute,
40163
40262
  showLoading,
@@ -40189,7 +40288,7 @@ function useSendTransactionStatus({ chain, txHash, }) {
40189
40288
  transactionId: txHash,
40190
40289
  txType: HistoryTxType.SEND,
40191
40290
  });
40192
- const { data: status } = useQuery({
40291
+ const { data: status, isSuccess, isError, } = useQuery({
40193
40292
  queryKey: keys().sendTransactionStatus(txHash, chain?.chainId),
40194
40293
  queryFn: async () => {
40195
40294
  if (!chain || !txHash)
@@ -40199,17 +40298,30 @@ function useSendTransactionStatus({ chain, txHash, }) {
40199
40298
  txHash,
40200
40299
  });
40201
40300
  },
40202
- onSuccess: (txStatus) => {
40203
- setIsTransactionComplete(txStatus !== SendTransactionStatus.ONGOING);
40204
- if (txStatus != null && !!txHash) {
40301
+ refetchInterval: chain
40302
+ ? getSendTxStatusRefetchInterval(chain.chainType)
40303
+ : false,
40304
+ enabled: !!chain &&
40305
+ !!txHash &&
40306
+ !isTransactionComplete &&
40307
+ !!currentHistoryItem &&
40308
+ !isHistoryTransactionEnded({
40309
+ data: currentHistoryItem?.data,
40310
+ txType: HistoryTxType.SEND,
40311
+ }),
40312
+ });
40313
+ useEffect(() => {
40314
+ if (isSuccess) {
40315
+ setIsTransactionComplete(status !== SendTransactionStatus.ONGOING);
40316
+ if (status != null && !!txHash) {
40205
40317
  replaceTransactionStatus({
40206
40318
  txType: HistoryTxType.SEND,
40207
- status: txStatus,
40319
+ status: status,
40208
40320
  hash: txHash,
40209
40321
  });
40210
40322
  }
40211
- },
40212
- onError() {
40323
+ }
40324
+ if (isError) {
40213
40325
  setIsTransactionComplete(true);
40214
40326
  if (txHash) {
40215
40327
  replaceTransactionStatus({
@@ -40218,19 +40330,8 @@ function useSendTransactionStatus({ chain, txHash, }) {
40218
40330
  hash: txHash,
40219
40331
  });
40220
40332
  }
40221
- },
40222
- refetchInterval: chain
40223
- ? getSendTxStatusRefetchInterval(chain.chainType)
40224
- : false,
40225
- enabled: !!chain &&
40226
- !!txHash &&
40227
- !isTransactionComplete &&
40228
- !!currentHistoryItem &&
40229
- !isHistoryTransactionEnded({
40230
- data: currentHistoryItem?.data,
40231
- txType: HistoryTxType.SEND,
40232
- }),
40233
- });
40333
+ }
40334
+ }, [isError, isSuccess, replaceTransactionStatus, status, txHash]);
40234
40335
  return {
40235
40336
  status: status ?? currentHistoryItem?.data?.status,
40236
40337
  };
@@ -40264,7 +40365,9 @@ const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocu
40264
40365
  apiUrl: latestConfig.apiUrl,
40265
40366
  });
40266
40367
  }, [transaction]);
40267
- const transactionStatusQuery = useQuery(keys().swapTransactionStatus(transaction?.transactionId), fetchTransactionStatusWithLatestConfig, {
40368
+ const transactionStatusQuery = useQuery({
40369
+ queryKey: keys().swapTransactionStatus(transaction?.transactionId),
40370
+ queryFn: fetchTransactionStatusWithLatestConfig,
40268
40371
  enabled: enabled &&
40269
40372
  transaction?.transactionId !== "0" &&
40270
40373
  !!transaction?.transactionId &&
@@ -40278,12 +40381,12 @@ const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocu
40278
40381
  data: currentHistoryItem?.data,
40279
40382
  txType: HistoryTxType.SWAP,
40280
40383
  }),
40281
- refetchInterval(statusResponse) {
40384
+ refetchInterval({ state }) {
40282
40385
  // If the status response is something telling that the transaction
40283
40386
  // is finished, then store transaction history state if success
40284
40387
  // And return false to indicate refetcher to stop
40285
- if (statusResponse &&
40286
- transactionEndStatuses.includes(getTransactionStatus(statusResponse) ?? "")) {
40388
+ if (state.data &&
40389
+ transactionEndStatuses.includes(getTransactionStatus(state.data) ?? "")) {
40287
40390
  return false;
40288
40391
  }
40289
40392
  return refetchInterval; // Had to handle a variable here because after onError, we want the interval to stop
@@ -40292,7 +40395,10 @@ const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocu
40292
40395
  retryDelay: getChainType(transaction?.fromChain) === ChainType.COSMOS ? 5000 : 3000,
40293
40396
  retry: getChainType(transaction?.fromChain) === ChainType.COSMOS ? 6 : retry,
40294
40397
  refetchOnWindowFocus,
40295
- onSuccess: (statusResponse) => {
40398
+ });
40399
+ useEffect(() => {
40400
+ if (transactionStatusQuery.isSuccess && transactionStatusQuery.data) {
40401
+ const statusResponse = transactionStatusQuery.data;
40296
40402
  // Dispatch event
40297
40403
  WidgetEvents.getInstance().dispatchSwapStatus(statusResponse.squidTransactionStatus ?? "");
40298
40404
  const endStatus = getTransactionEndStatus({ statusResponse });
@@ -40304,8 +40410,9 @@ const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocu
40304
40410
  status: endStatus,
40305
40411
  });
40306
40412
  }
40307
- },
40308
- onError: (error) => {
40413
+ }
40414
+ if (transactionStatusQuery.isError) {
40415
+ const error = transactionStatusQuery.error;
40309
40416
  // `fetchTransactionStatus` throws an error with a cause being an AxiosError
40310
40417
  const is404 = is404Error(error.cause);
40311
40418
  if (!transaction?.transactionId)
@@ -40326,8 +40433,15 @@ const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocu
40326
40433
  status: TransactionStatus.ERROR,
40327
40434
  });
40328
40435
  }
40329
- },
40330
- });
40436
+ }
40437
+ }, [
40438
+ transactionStatusQuery.isSuccess,
40439
+ transactionStatusQuery.isError,
40440
+ transaction?.transactionId,
40441
+ transactionStatusQuery.error,
40442
+ replaceSwapTransactionStatus,
40443
+ transactionStatusQuery.data,
40444
+ ]);
40331
40445
  return {
40332
40446
  transactionStatusQuery,
40333
40447
  latestStatus: transactionStatusQuery.data
@@ -40370,7 +40484,7 @@ const useAvatar = (seed = zeroAddress) => {
40370
40484
  },
40371
40485
  // data is static, so no need to refetch
40372
40486
  refetchOnWindowFocus: false,
40373
- cacheTime: Infinity,
40487
+ gcTime: Infinity,
40374
40488
  staleTime: Infinity,
40375
40489
  });
40376
40490
  return avatar || "";
@@ -40412,38 +40526,40 @@ const useAddToken = (chainToCompare, tokenToCompare) => {
40412
40526
  /**
40413
40527
  * Add token to wallet
40414
40528
  */
40415
- const addToken = useMutation(async ({ chain: _chain, token: _token, }) => {
40416
- const token = _token ?? tokenToCompare;
40417
- const chain = _chain ?? chainToCompare;
40418
- if (token && chain?.chainType === ChainType.EVM) {
40419
- const provider = await connector?.getProvider();
40420
- // Switch network if needed
40421
- if (currentEvmChain?.id.toString() !== token?.chainId) {
40422
- try {
40423
- await switchChainAsync({
40424
- chainId: +token.chainId,
40425
- });
40426
- }
40427
- catch (error) {
40428
- console.debug("Error switching network:", error);
40429
- if (isEvmChainNotSupportedError(error)) {
40430
- await addEthereumChain({
40431
- chain,
40432
- provider,
40433
- });
40529
+ const addToken = useMutation({
40530
+ mutationFn: async ({ chain: _chain, token: _token, }) => {
40531
+ const token = _token ?? tokenToCompare;
40532
+ const chain = _chain ?? chainToCompare;
40533
+ if (token && chain?.chainType === ChainType.EVM) {
40534
+ const provider = await connector?.getProvider();
40535
+ // Switch network if needed
40536
+ if (currentEvmChain?.id.toString() !== token?.chainId) {
40537
+ try {
40434
40538
  await switchChainAsync({
40435
40539
  chainId: +token.chainId,
40436
40540
  });
40437
40541
  }
40542
+ catch (error) {
40543
+ console.debug("Error switching network:", error);
40544
+ if (isEvmChainNotSupportedError(error)) {
40545
+ await addEthereumChain({
40546
+ chain,
40547
+ provider,
40548
+ });
40549
+ await switchChainAsync({
40550
+ chainId: +token.chainId,
40551
+ });
40552
+ }
40553
+ }
40554
+ // Metamask is not popping the second modal if we don't wait a bit
40555
+ // eslint-disable-next-line no-promise-executor-return
40556
+ await new Promise((resolve) => setTimeout(resolve, 100));
40438
40557
  }
40439
- // Metamask is not popping the second modal if we don't wait a bit
40440
- // eslint-disable-next-line no-promise-executor-return
40441
- await new Promise((resolve) => setTimeout(resolve, 100));
40558
+ await addTokenToWallet({ token, provider });
40442
40559
  }
40443
- await addTokenToWallet({ token, provider });
40560
+ // TODO: Implement keplr add token
40561
+ return false;
40444
40562
  }
40445
- // TODO: Implement keplr add token
40446
- return false;
40447
40563
  });
40448
40564
  return {
40449
40565
  addToken,
@@ -40648,7 +40764,9 @@ function useXrplTrustLine({ address, chain, token, amount }) {
40648
40764
  }
40649
40765
  },
40650
40766
  async onSuccess() {
40651
- queryClient.invalidateQueries(getPrefixKey(QueryKeys.XrplTrustLine));
40767
+ queryClient.invalidateQueries({
40768
+ queryKey: getPrefixKey(QueryKeys.XrplTrustLine),
40769
+ });
40652
40770
  },
40653
40771
  });
40654
40772
  /**
@@ -40715,116 +40833,5 @@ function useXrplTrustLine({ address, chain, token, amount }) {
40715
40833
  };
40716
40834
  }
40717
40835
 
40718
- // Prevent fetching too soon after the first successful request.
40719
- const DEFAULT_STALE_TIME = 8000;
40720
- const defaultOptions = {
40721
- queries: {
40722
- staleTime: DEFAULT_STALE_TIME,
40723
- refetchOnWindowFocus: false,
40724
- retry: false,
40725
- retryOnMount: false,
40726
- },
40727
- };
40728
-
40729
- const queryClient = new QueryClient({ defaultOptions });
40730
- const verifyIntegratorIdValidity = (integratorId) => {
40731
- if (!integratorId) {
40732
- throw new Error("Integrator ID is required");
40733
- }
40734
- };
40735
- const SquidProvider = ({ children, config, placeholder, }) => {
40736
- verifyIntegratorIdValidity(config.integratorId);
40737
- const [wagmiConfig, setWagmiConfig] = useState();
40738
- const sdkInitializedRef = useRef(false);
40739
- const initializeSdk = useCallback(async () => {
40740
- if (sdkInitializedRef.current) {
40741
- return;
40742
- }
40743
- sdkInitializedRef.current = true;
40744
- try {
40745
- const squid = new Squid({
40746
- integratorId: config.integratorId,
40747
- baseUrl: config.apiUrl ?? squidApiBaseUrl,
40748
- });
40749
- const [sdkInfoResponse, assetsColorsResponse] = await Promise.allSettled([
40750
- squid.init(),
40751
- fetchAssetsColors(),
40752
- ]);
40753
- if (sdkInfoResponse.status === "rejected") {
40754
- throw sdkInfoResponse.reason;
40755
- }
40756
- if (assetsColorsResponse.status === "fulfilled") {
40757
- useAssetsColorsStore.setState(assetsColorsResponse.value);
40758
- initializeSquidWithAssetsColors(squid, assetsColorsResponse.value);
40759
- }
40760
- const shouldResetSwapRouteStore =
40761
- // reset swap route if specified in config
40762
- !config?.loadPreviousStateFromLocalStorage ||
40763
- // or if initial assets are provided
40764
- !isEmptyObject(config.initialAssets?.from) ||
40765
- !isEmptyObject(config.initialAssets?.to);
40766
- if (shouldResetSwapRouteStore) {
40767
- useSwapRoutePersistStore.setState({
40768
- swapRoute: undefined,
40769
- });
40770
- }
40771
- useSquidStore.setState((_) => ({
40772
- squid,
40773
- maintenanceMode: { active: false, message: undefined },
40774
- }));
40775
- const newWagmiConfig = createWagmiConfig(squid.chains);
40776
- setWagmiConfig(newWagmiConfig);
40777
- useConfigStore.setState({
40778
- isInitialized: true,
40779
- config: getConfigWithDefaults(config),
40780
- });
40781
- }
40782
- catch (error) {
40783
- const isAxios503Error = error.isAxiosError &&
40784
- error.response?.status === 503;
40785
- if (isAxios503Error) {
40786
- const maintenanceMessage = error.response?.data
40787
- ?.message ?? undefined;
40788
- // Even with an error, we want wagmi to be defined so that we can display the maintenance mode layout
40789
- // Create wagmi config with mainnet as fallback in maintenance mode
40790
- const newWagmiConfig = createConfig({
40791
- chains: [mainnet],
40792
- connectors: [injected()],
40793
- transports: {
40794
- [mainnet.id]: http(),
40795
- },
40796
- });
40797
- setWagmiConfig(newWagmiConfig);
40798
- useConfigStore.setState({
40799
- isInitialized: false,
40800
- config: getConfigWithDefaults(config),
40801
- });
40802
- useSquidStore.setState({
40803
- squid: undefined,
40804
- maintenanceMode: {
40805
- active: true,
40806
- message: maintenanceMessage,
40807
- },
40808
- });
40809
- }
40810
- else {
40811
- console.error("Error initializing SDK:", error);
40812
- }
40813
- }
40814
- }, [config]);
40815
- useEffect(() => {
40816
- initializeSdk();
40817
- }, [initializeSdk]);
40818
- return wagmiConfig ? (React.createElement(WagmiProvider, { reconnectOnMount: false, config: wagmiConfig },
40819
- React.createElement(QueryClientProvider, { client: queryClient },
40820
- React.createElement(StellarProvider, null,
40821
- React.createElement(EvmProvider, null,
40822
- React.createElement(XrplProvider, null,
40823
- React.createElement(SuiProvider, null,
40824
- React.createElement(SolanaProvider, null,
40825
- React.createElement(BitcoinProvider, null,
40826
- React.createElement(CosmosProvider, null, children)))))))))) : (placeholder);
40827
- };
40828
-
40829
- export { useNativeBalance as $, AxelarStatusResponseType as A, useAddressBookStore as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useAssetsColorsStore as E, useFavoriteTokensStore as F, useHistoryStore as G, HistoryTxType as H, useSendTransactionStore as I, useConfigStore as J, useSquidStore as K, useSwapRoutePersistStore as L, useTransactionStore as M, ConnectingWalletStatus as N, useWalletStore as O, useDepositAddress as P, useSwap as Q, useAllConnectedWalletBalances as R, SquidStatusErrorType as S, TransactionErrorType as T, useAllTokensWithBalanceForChainType as U, useCosmosBalance as V, WindowWalletFlag as W, XamanXrplNetwork as X, useEvmBalance as Y, useMultiChainBalance as Z, useMultipleTokenPrices as _, chainTypeToZeroAddressMap as a, findToken as a$, useNativeTokenForChain as a0, useSingleTokenPrice as a1, useSquidTokens as a2, useHistoricalData as a3, useTokensData as a4, useEstimateSendTransaction as a5, useSendTransaction as a6, useSendTransactionGas as a7, useAllTransactionsStatus as a8, useApproval as a9, useGetFiatQuote as aA, useGetOnRampConfig as aB, useExecuteFiatQuote as aC, useFiatOnRampTxStatus as aD, useFiatTransactions as aE, useCurrencyDetails as aF, useCountryDetails as aG, useAvailableQuotes as aH, useRecommendedQuote as aI, useGetOnrampPaymentTypes as aJ, useSuggestedFiatAmounts as aK, SquidProvider as aL, EnsService as aM, getXummClient as aN, isXamanXAppContext as aO, getQueryHeaders as aP, getStatusCode as aQ, is404Error as aR, assetsBaseUrl as aS, shareSubgraphId as aT, sortTokensBySharedSubgraphIds as aU, getSupportedChainIdsForDirection as aV, filterChains as aW, filterTokens as aX, getTokenImage as aY, getNewSwapParamsFromInput as aZ, sortAllTokens as a_, useEstimate as aa, useEstimatePriceImpact as ab, useExecuteTransaction as ac, useGetRoute as ad, useGetRouteWrapper as ae, useRouteWarnings as af, useSendTransactionStatus as ag, useSwapTransactionStatus as ah, useAvatar as ai, useHistory as aj, useUserParams as ak, useDebouncedValue as al, useAddToken as am, useAutoConnect as an, useEnsDataForAddress as ao, useEnsSearch as ap, useGnosisContext as aq, useIsSameAddressAndGnosisContext as ar, useIntegratorContext as as, useMultiChainWallet as at, useSigner as au, useWallet as av, useWallets as aw, useXrplTrustLine as ax, TX_STATUS_CONSTANTS as ay, FINAL_TRANSACTION_STATUSES as az, destinationAddressResetValue as b, isSolanaAddressValid as b$, findNativeToken as b0, normalizeIbcAddress as b1, groupTokensBySymbol as b2, groupTokensByChainId as b3, filterViewableTokens as b4, getSecretNetworkBalances as b5, getTokenAssetsKey as b6, fetchAssetsColors as b7, initializeSquidWithAssetsColors as b8, isEmptyObject as b9, isSwapRouteError as bA, isStatusError as bB, createQuoteRequestParamsHash as bC, WidgetEvents as bD, EvmNetworkNotSupportedErrorCode as bE, addEthereumChain as bF, parseEvmAddress as bG, formatEvmWallet as bH, filterWagmiConnector as bI, getUserCountry as bJ, getCountryData as bK, getCurrencyData as bL, adaptiveRound as bM, getSuggestedAmountsForCurrency as bN, parseToBigInt as bO, roundNumericValue as bP, formatUnitsRounded as bQ, formatTokenAmount as bR, formatUsdAmount as bS, trimExtraDecimals as bT, getNumericValue as bU, cleanAmount as bV, convertTokenAmountToUSD as bW, convertUSDToTokenAmount as bX, calculateTotal24hChange as bY, searchTokens as bZ, filterSolanaWallets as b_, normalizeTokenSymbol as ba, areTokenSymbolsCompatible as bb, isEvmosChain as bc, getConfigWithDefaults as bd, randomIntFromInterval as be, getTokensForChain as bf, getFirstAvailableChainId as bg, fetchHighestBalanceToken as bh, getInitialOrDefaultTokenAddressForChain as bi, getInitialTokenAddressForChain as bj, filterTokensForDestination as bk, getInitialChainIdFromConfig as bl, getCosmosKey as bm, getKeysSettled as bn, getAllKeysForSupportedCosmosChains as bo, isCosmosAddressValid as bp, getCosmosSigningClient as bq, getCosmosChainInfosObject as br, connectCosmosWallet as bs, isFallbackAddressNeeded as bt, suggestChainOrThrow as bu, normalizeError as bv, transactionErrorCode as bw, isUserRejectionError as bx, getTransactionError as by, handleTransactionErrorEvents as bz, chainTypeToNativeTokenAddressMap as c, executeSolanaSwap as c0, executeSolanaTransfer as c1, formatTransactionHistoryDate as c2, getAxelarExplorerTxUrl as c3, getSourceExplorerTxUrl as c4, getMainExplorerUrl as c5, formatDistance as c6, formatSeconds as c7, formatSwapTxStatusResponseForStorage as c8, simplifyRouteAction as c9, sortWallets as cA, areSameAddress as cB, sortAddressBook as cC, calculateTotalUsdBalanceUSD as cD, addTokenToWallet as cE, isEvmChainNotSupportedError as cF, getWalletSupportedChainTypes as cG, getConnectorForChainType as cH, walletSupportsChainType as cI, connectWallet as cJ, cancelConnectWallet as cK, isProblematicConnector as cL, mergeWallets as cM, isXionSmartContractAddress as cN, isXrplAddressValid as cO, buildXrplTrustSetTx as cP, getXrplNetwork as cQ, parseXrplPaymentTx as cR, fetchSwapTransactionStatus as ca, compareTransactionIds as cb, isCoralBridgeAction as cc, sleep as cd, isDepositRoute as ce, isChainflipBridgeTransaction as cf, getHistoryTransactionId as cg, getStepStatuses as ch, getHalfSuccessState as ci, getStepsInfos as cj, getSwapTxStatusRefetchInterval as ck, getSendTxStatusRefetchInterval as cl, chainflipMultihopBridgeType as cm, getBridgeType as cn, getTransactionStatus as co, getTransactionEndStatus as cp, isHistoryTransactionPending as cq, isHistoryTransactionFailed as cr, isHistoryTransactionWarning as cs, isHistoryTransactionEnded as ct, formatHash as cu, isWalletAddressValid as cv, redirectToExtensionsStore as cw, accessProperty as cx, populateWallets as cy, getDefaultChain as cz, definedInWindow as d, fallbackAddressResetValue as e, formatBNToReadable as f, nativeCosmosTokenAddress as g, nativeEvmTokenAddress as h, nativeSolanaTokenAddress as i, nativeStellarTokenAddress as j, nativeSuiTokenAddress as k, nativeXrplTokenAddress as l, CosmosProvider as m, nativeBitcoinTokenAddress as n, SendTransactionStatus as o, TransactionStatus as p, useTrackSearchEmpty as q, useSquidChains as r, useClient as s, useCosmosForChain as t, useCosmosContext as u, useKeyboardNavigation as v, walletIconBaseUrl as w, useSquidQueryClient as x, useSquid as y, useStellarAccountActivation as z };
40830
- //# sourceMappingURL=index-_Qp4Ou3J.js.map
40836
+ export { useNativeBalance as $, AxelarStatusResponseType as A, useAddressBookStore as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useAssetsColorsStore as E, useFavoriteTokensStore as F, useHistoryStore as G, HistoryTxType as H, useSendTransactionStore as I, useConfigStore as J, useSquidStore as K, useSwapRoutePersistStore as L, useTransactionStore as M, ConnectingWalletStatus as N, useWalletStore as O, useDepositAddress as P, useSwap as Q, useAllConnectedWalletBalances as R, SquidStatusErrorType as S, TransactionErrorType as T, useAllTokensWithBalanceForChainType as U, useCosmosBalance as V, WindowWalletFlag as W, XamanXrplNetwork as X, useEvmBalance as Y, useMultiChainBalance as Z, useMultipleTokenPrices as _, chainTypeToZeroAddressMap as a, normalizeIbcAddress as a$, useNativeTokenForChain as a0, useSingleTokenPrice as a1, useSquidTokens as a2, useHistoricalData as a3, useTokensData as a4, useEstimateSendTransaction as a5, useSendTransaction as a6, useSendTransactionGas as a7, useAllTransactionsStatus as a8, useApproval as a9, useGetFiatQuote as aA, useGetOnRampConfig as aB, useExecuteFiatQuote as aC, useCurrencyDetails as aD, useCountryDetails as aE, useAvailableQuotes as aF, useGetOnrampPaymentTypes as aG, useSuggestedFiatAmounts as aH, queryClient as aI, SquidProvider as aJ, EnsService as aK, getXummClient as aL, isXamanXAppContext as aM, getQueryHeaders as aN, getStatusCode as aO, is404Error as aP, assetsBaseUrl as aQ, shareSubgraphId as aR, sortTokensBySharedSubgraphIds as aS, getSupportedChainIdsForDirection as aT, filterChains as aU, filterTokens as aV, getTokenImage as aW, getNewSwapParamsFromInput as aX, sortAllTokens as aY, findToken as aZ, findNativeToken as a_, useEstimate as aa, useEstimatePriceImpact as ab, useExecuteTransaction as ac, useGetRoute as ad, useGetRouteWrapper as ae, useRouteWarnings as af, useSendTransactionStatus as ag, useSwapTransactionStatus as ah, useAvatar as ai, useHistory as aj, useUserParams as ak, useDebouncedValue as al, useAddToken as am, useAutoConnect as an, useEnsDataForAddress as ao, useEnsSearch as ap, useGnosisContext as aq, useIsSameAddressAndGnosisContext as ar, useIntegratorContext as as, useMultiChainWallet as at, useSigner as au, useWallet as av, useWallets as aw, useXrplTrustLine as ax, TX_STATUS_CONSTANTS as ay, FINAL_TRANSACTION_STATUSES as az, destinationAddressResetValue as b, formatTransactionHistoryDate as b$, groupTokensBySymbol as b0, groupTokensByChainId as b1, filterViewableTokens as b2, getSecretNetworkBalances as b3, getTokenAssetsKey as b4, fetchAssetsColors as b5, initializeSquidWithAssetsColors as b6, isEmptyObject as b7, normalizeTokenSymbol as b8, areTokenSymbolsCompatible as b9, WidgetEvents as bA, EvmNetworkNotSupportedErrorCode as bB, addEthereumChain as bC, parseEvmAddress as bD, formatEvmWallet as bE, filterWagmiConnector as bF, getUserCountry as bG, getCountryData as bH, getCurrencyData as bI, adaptiveRound as bJ, getSuggestedAmountsForCurrency as bK, parseToBigInt as bL, roundNumericValue as bM, formatUnitsRounded as bN, formatTokenAmount as bO, formatUsdAmount as bP, trimExtraDecimals as bQ, getNumericValue as bR, cleanAmount as bS, convertTokenAmountToUSD as bT, convertUSDToTokenAmount as bU, calculateTotal24hChange as bV, searchTokens as bW, filterSolanaWallets as bX, isSolanaAddressValid as bY, executeSolanaSwap as bZ, executeSolanaTransfer as b_, isEvmosChain as ba, getConfigWithDefaults as bb, getTokensForChain as bc, getFirstAvailableChainId as bd, fetchHighestBalanceToken as be, getInitialOrDefaultTokenAddressForChain as bf, getInitialTokenAddressForChain as bg, filterTokensForDestination as bh, getInitialChainIdFromConfig as bi, getCosmosKey as bj, getKeysSettled as bk, getAllKeysForSupportedCosmosChains as bl, isCosmosAddressValid as bm, getCosmosSigningClient as bn, getCosmosChainInfosObject as bo, connectCosmosWallet as bp, isFallbackAddressNeeded as bq, suggestChainOrThrow as br, normalizeError as bs, transactionErrorCode as bt, isUserRejectionError as bu, getTransactionError as bv, handleTransactionErrorEvents as bw, isSwapRouteError as bx, isStatusError as by, createQuoteRequestParamsHash as bz, chainTypeToNativeTokenAddressMap as c, getAxelarExplorerTxUrl as c0, getSourceExplorerTxUrl as c1, getMainExplorerUrl as c2, formatDistance as c3, formatSeconds as c4, formatSwapTxStatusResponseForStorage as c5, simplifyRouteAction as c6, fetchSwapTransactionStatus as c7, compareTransactionIds as c8, isCoralBridgeAction as c9, calculateTotalUsdBalanceUSD as cA, addTokenToWallet as cB, isEvmChainNotSupportedError as cC, getWalletSupportedChainTypes as cD, getConnectorForChainType as cE, walletSupportsChainType as cF, connectWallet as cG, cancelConnectWallet as cH, isProblematicConnector as cI, mergeWallets as cJ, isXionSmartContractAddress as cK, isXrplAddressValid as cL, buildXrplTrustSetTx as cM, getXrplNetwork as cN, parseXrplPaymentTx as cO, sleep as ca, isDepositRoute as cb, isChainflipBridgeTransaction as cc, getHistoryTransactionId as cd, getStepStatuses as ce, getHalfSuccessState as cf, getStepsInfos as cg, getSwapTxStatusRefetchInterval as ch, getSendTxStatusRefetchInterval as ci, chainflipMultihopBridgeType as cj, getBridgeType as ck, getTransactionStatus as cl, getTransactionEndStatus as cm, isHistoryTransactionPending as cn, isHistoryTransactionFailed as co, isHistoryTransactionWarning as cp, isHistoryTransactionEnded as cq, formatHash as cr, isWalletAddressValid as cs, redirectToExtensionsStore as ct, accessProperty as cu, populateWallets as cv, getDefaultChain as cw, sortWallets as cx, areSameAddress as cy, sortAddressBook as cz, definedInWindow as d, fallbackAddressResetValue as e, formatBNToReadable as f, nativeCosmosTokenAddress as g, nativeEvmTokenAddress as h, nativeSolanaTokenAddress as i, nativeStellarTokenAddress as j, nativeSuiTokenAddress as k, nativeXrplTokenAddress as l, CosmosProvider as m, nativeBitcoinTokenAddress as n, SendTransactionStatus as o, TransactionStatus as p, useTrackSearchEmpty as q, useSquidChains as r, useClient as s, useCosmosForChain as t, useCosmosContext as u, useKeyboardNavigation as v, walletIconBaseUrl as w, useSquidQueryClient as x, useSquid as y, useStellarAccountActivation as z };
40837
+ //# sourceMappingURL=index-BxbblIad.js.map