@0xsquid/react-hooks 8.12.0 → 8.12.1-beta-arc.0

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 (43) hide show
  1. package/dist/core/constants.d.ts +1 -0
  2. package/dist/hooks/transaction/send/useEstimateSendTransactionGas.d.ts +3 -0
  3. package/dist/{index-CJVX-7hj.js → index-BBJD55XX.js} +375 -80
  4. package/dist/index-BBJD55XX.js.map +1 -0
  5. package/dist/{index-C3owE9lb.js → index-CLzjMzS_.js} +374 -81
  6. package/dist/index-CLzjMzS_.js.map +1 -0
  7. package/dist/{index.es-CTKuR0LC.js → index.es-BVCh4tlV.js} +2 -2
  8. package/dist/{index.es-CTKuR0LC.js.map → index.es-BVCh4tlV.js.map} +1 -1
  9. package/dist/{index.es-09IsADsA.js → index.es-BiK_wjSb.js} +2 -2
  10. package/dist/{index.es-09IsADsA.js.map → index.es-BiK_wjSb.js.map} +1 -1
  11. package/dist/index.esm.js +1 -1
  12. package/dist/index.js +3 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/{secretService-GHdReJBs.js → secretService-BZ06HTOJ.js} +2 -2
  15. package/dist/{secretService-GHdReJBs.js.map → secretService-BZ06HTOJ.js.map} +1 -1
  16. package/dist/{secretService--tJFCkzT.js → secretService-DkE9yz1o.js} +2 -2
  17. package/dist/{secretService--tJFCkzT.js.map → secretService-DkE9yz1o.js.map} +1 -1
  18. package/dist/server.esm.js +1 -0
  19. package/dist/server.esm.js.map +1 -1
  20. package/dist/server.js +1 -0
  21. package/dist/server.js.map +1 -1
  22. package/dist/services/internal/arcService.d.ts +7 -0
  23. package/dist/services/internal/assetsService.d.ts +8 -2
  24. package/dist/services/internal/configService.d.ts +14 -3
  25. package/dist/services/internal/estimateService.d.ts +12 -2
  26. package/dist/services/internal/tempoService.d.ts +2 -0
  27. package/dist/services/internal/walletService.d.ts +1 -1
  28. package/dist/{stellarService.client-DAxgO3m3.js → stellarService.client-DtA9zkRt.js} +2 -2
  29. package/dist/{stellarService.client-DAxgO3m3.js.map → stellarService.client-DtA9zkRt.js.map} +1 -1
  30. package/dist/{stellarService.client-DvA-2pXq.js → stellarService.client-fnyXRadt.js} +2 -2
  31. package/dist/{stellarService.client-DvA-2pXq.js.map → stellarService.client-fnyXRadt.js.map} +1 -1
  32. package/dist/tests/arcAssetsService.test.d.ts +1 -0
  33. package/dist/tests/arcConfigService.test.d.ts +1 -0
  34. package/dist/tests/arcGasAccounting.test.d.ts +1 -0
  35. package/dist/tests/arcWalletService.test.d.ts +1 -0
  36. package/dist/tests/fixtures/arc.d.ts +8 -0
  37. package/dist/tests/useArcApproval.test.d.ts +1 -0
  38. package/dist/tests/useArcSendEstimate.test.d.ts +1 -0
  39. package/dist/tests/useNativeTokenForChain.test.d.ts +1 -0
  40. package/dist/tests/useSwapArcSelection.test.d.ts +1 -0
  41. package/package.json +1 -1
  42. package/dist/index-C3owE9lb.js.map +0 -1
  43. package/dist/index-CJVX-7hj.js.map +0 -1
@@ -132,6 +132,7 @@ const CHAIN_IDS = {
132
132
  MANTRA: "5888",
133
133
  CITREA: "4114",
134
134
  TEMPO: "4217",
135
+ ARC: "5042",
135
136
  // others
136
137
  BITCOIN: "bitcoin",
137
138
  SOLANA: "solana-mainnet-beta",
@@ -20943,6 +20944,24 @@ const isBitcoinAddressValid = (address$1) => {
20943
20944
  }
20944
20945
  };
20945
20946
 
20947
+ const arcUsdcTokenAddress = "0x3600000000000000000000000000000000000000";
20948
+ const isArcChain = (chainId) => chainId === CHAIN_IDS.ARC;
20949
+ const isArcUsdcToken = (token) => isArcChain(token?.chainId) &&
20950
+ token?.address.toLowerCase() === arcUsdcTokenAddress;
20951
+ const isArcNativeToken = (token) => isArcChain(token?.chainId) &&
20952
+ token?.address.toLowerCase() === nativeEvmTokenAddress;
20953
+ const normalizeArcTokenAddress = (chainId, address) => isArcChain(chainId) && address?.toLowerCase() === nativeEvmTokenAddress
20954
+ ? arcUsdcTokenAddress
20955
+ : address;
20956
+ const deduplicateArcBalances = (tokens) => {
20957
+ const canonicalChains = new Set(tokens
20958
+ .filter((token) => isArcChain(token.chainId) &&
20959
+ token.address?.toLowerCase() === arcUsdcTokenAddress)
20960
+ .map((token) => token.chainId));
20961
+ return tokens.filter((token) => !(canonicalChains.has(token.chainId) &&
20962
+ token.address?.toLowerCase() === nativeEvmTokenAddress));
20963
+ };
20964
+
20946
20965
  function getCantonCommandId(memo) {
20947
20966
  return `canton-${memo}`;
20948
20967
  }
@@ -22179,7 +22198,7 @@ function sortAddressBook(a, b, selectedAddress) {
22179
22198
  return 0;
22180
22199
  }
22181
22200
  const calculateTotalUsdBalanceUSD = (tokens) => {
22182
- const totalUsd = tokens.reduce((total, token) => {
22201
+ const totalUsd = deduplicateArcBalances(tokens).reduce((total, token) => {
22183
22202
  const balance = parseFloat(token.balance);
22184
22203
  const usdPrice = token.usdPrice ?? 0;
22185
22204
  const balanceUsd = balance * usdPrice;
@@ -22991,22 +23010,36 @@ const getFirstAvailableChainId = (config, direction, chains = []) => {
22991
23010
  // if no initial chain ID is found in config, return the first available chain ID
22992
23011
  return availableChains.length > 0 ? availableChains[0].chainId : undefined;
22993
23012
  };
22994
- const fetchHighestBalanceToken = (fetchCachedBalance, chainId) => {
23013
+ const fetchHighestBalanceToken = (fetchCachedBalance, chainId, selectableTokens, direction) => {
22995
23014
  let address = undefined;
22996
23015
  if (fetchCachedBalance) {
22997
23016
  const queryCache = fetchCachedBalance?.queryClient?.getQueryCache();
23017
+ const directionCache = isArcChain(chainId) && direction
23018
+ ? queryCache?.find(keys().allTokensBalance(fetchCachedBalance.address, ChainType.EVM, direction))
23019
+ : undefined;
22998
23020
  // get cached balance from key
22999
- const cache = queryCache?.find(keys().allTokensBalance(fetchCachedBalance?.address, !isNaN(Number(chainId)) ? ChainType.EVM : ChainType.COSMOS));
23000
- // Parse result to TokenWithBalance[]
23001
- const cacheResult = cache?.state.data ?? [];
23021
+ const cache = directionCache?.state.data !== undefined
23022
+ ? directionCache
23023
+ : queryCache?.find(keys().allTokensBalance(fetchCachedBalance?.address, !isNaN(Number(chainId)) ? ChainType.EVM : ChainType.COSMOS));
23024
+ const cacheData = cache?.state.data;
23025
+ const cacheResult = Array.isArray(cacheData)
23026
+ ? cacheData
23027
+ : isArcChain(chainId)
23028
+ ? (cacheData?.tokens ?? [])
23029
+ : [];
23002
23030
  if (cacheResult.length > 0) {
23003
- const tokensWithBalance = cacheResult.filter((t) => t.chainId === chainId && Number(t.balance) > 0);
23031
+ const tokensWithBalance = deduplicateArcBalances(cacheResult).filter((t) => t.chainId === chainId &&
23032
+ Number(t.balance) > 0 &&
23033
+ (!selectableTokens ||
23034
+ selectableTokens.some((token) => token.chainId === t.chainId &&
23035
+ token.address.toLowerCase() ===
23036
+ normalizeArcTokenAddress(t.chainId, t.address)?.toLowerCase())));
23004
23037
  if (tokensWithBalance.length > 0) {
23005
23038
  // Return the token with the highest balance
23006
23039
  // TODO: At the moment we're not taking into account usd price
23007
23040
  const tokenWithHighestBalance = tokensWithBalance.reduce((prev, current) => Number(prev.balance) > Number(current.balance) ? prev : current);
23008
23041
  if (tokenWithHighestBalance) {
23009
- address = tokenWithHighestBalance.address;
23042
+ address = normalizeArcTokenAddress(tokenWithHighestBalance.chainId, tokenWithHighestBalance.address);
23010
23043
  }
23011
23044
  }
23012
23045
  }
@@ -23017,6 +23050,21 @@ const findNativeTokenForChainType = (tokens) => {
23017
23050
  return tokens.find((t) => t.address.toLowerCase() ===
23018
23051
  chainTypeToNativeTokenAddressMap[t.type].toLowerCase());
23019
23052
  };
23053
+ const getTokenAddressForSelection = ({ tokens, config, chainId, address, direction, excludeToken, }) => {
23054
+ if (!isArcChain(chainId))
23055
+ return address;
23056
+ const normalizedAddress = normalizeArcTokenAddress(chainId, address);
23057
+ const excludedAddress = normalizeArcTokenAddress(excludeToken?.chainId, excludeToken?.address);
23058
+ if (!chainId ||
23059
+ !normalizedAddress ||
23060
+ (excludeToken?.chainId === chainId &&
23061
+ normalizedAddress.toLowerCase() === excludedAddress?.toLowerCase()) ||
23062
+ !getSupportedChainIdsForDirection([chainId], config, direction).includes(chainId)) {
23063
+ return undefined;
23064
+ }
23065
+ return filterViewableTokens(tokens, config, direction).find((token) => token.chainId === chainId &&
23066
+ token.address.toLowerCase() === normalizedAddress.toLowerCase())?.address;
23067
+ };
23020
23068
  /**
23021
23069
  * Returns the default token address for a specific chain and direction based on config.
23022
23070
  * If no default tokens are set in config, returns the native token for the specified chain
@@ -23034,6 +23082,25 @@ const getInitialOrDefaultTokenAddressForChain = ({ tokens, config, chainId, dire
23034
23082
  const supportedChainIds = getSupportedChainIdsForDirection([chainId], config, direction);
23035
23083
  if (!supportedChainIds.includes(chainId))
23036
23084
  return;
23085
+ if (isArcChain(chainId)) {
23086
+ const selectAddress = (address) => getTokenAddressForSelection({
23087
+ tokens,
23088
+ config,
23089
+ chainId,
23090
+ address,
23091
+ direction,
23092
+ excludeToken,
23093
+ });
23094
+ const selectableTokens = tokens.filter((token) => token.chainId === chainId &&
23095
+ !isArcNativeToken(token) &&
23096
+ selectAddress(token.address) !== undefined);
23097
+ return (selectAddress(config.defaultTokensPerChain?.find((token) => token.chainId === chainId)
23098
+ ?.address) ??
23099
+ selectAddress(getInitialTokenAddressForChain({ tokens, config, chainId, direction })) ??
23100
+ selectAddress(fetchHighestBalanceToken(fetchCachedBalance, chainId, selectableTokens, direction)) ??
23101
+ selectAddress(arcUsdcTokenAddress) ??
23102
+ selectableTokens[0]?.address);
23103
+ }
23037
23104
  const configDefaultTokenForChain = config.defaultTokensPerChain?.find((token) => token.chainId == chainId);
23038
23105
  // get default token from config
23039
23106
  if (configDefaultTokenForChain &&
@@ -23077,6 +23144,23 @@ const getInitialTokenAddressForChain = ({ chainId, config, direction, tokens, un
23077
23144
  const initialAsset = config.initialAssets?.[direction];
23078
23145
  if (!initialAsset)
23079
23146
  return undefined;
23147
+ if (isArcChain(chainId)) {
23148
+ const address = isNamedTokenConfig(initialAsset)
23149
+ ? tokens.find((token) => token.chainId === chainId &&
23150
+ !isArcNativeToken(token) &&
23151
+ token.symbol.toLowerCase() === initialAsset.symbol?.toLowerCase())?.address
23152
+ : initialAsset.chainId === chainId
23153
+ ? initialAsset.address
23154
+ : undefined;
23155
+ return getTokenAddressForSelection({
23156
+ tokens,
23157
+ config,
23158
+ chainId,
23159
+ address,
23160
+ direction,
23161
+ excludeToken: { chainId, address: unavailableTokenAddress },
23162
+ });
23163
+ }
23080
23164
  if (isNamedTokenConfig(initialAsset)) {
23081
23165
  if (!initialAsset.symbol)
23082
23166
  return undefined;
@@ -23291,7 +23375,39 @@ const handleDestinationAddressOnSwapChange = ({ fromChainId, fromTokenAddress, t
23291
23375
  if (destinationTokensFiltered.find((t) => t.address === lowerCaseDestinationTokenAddress) === undefined) {
23292
23376
  destinationTokenAddress = defaultToAddress;
23293
23377
  }
23294
- return lowerCaseDestinationTokenAddress;
23378
+ return isArcChain(toChainId ?? swapRoute?.toChainId)
23379
+ ? destinationTokenAddress?.toLowerCase()
23380
+ : lowerCaseDestinationTokenAddress;
23381
+ };
23382
+ const normalizeSwapParamsForSelection = ({ swapParams, tokens, chains, config, }) => {
23383
+ const fromTokenAddress = getTokenAddressForSelection({
23384
+ tokens,
23385
+ config,
23386
+ chainId: swapParams.fromChainId,
23387
+ address: swapParams.fromTokenAddress,
23388
+ direction: "from",
23389
+ });
23390
+ const fromToken = tokens.find((token) => token.chainId === swapParams.fromChainId &&
23391
+ token.address.toLowerCase() === fromTokenAddress?.toLowerCase());
23392
+ const toTokenAddress = getTokenAddressForSelection({
23393
+ tokens: isArcChain(swapParams.toChainId)
23394
+ ? filterTokensForDestination({
23395
+ tokens,
23396
+ selectedDestinationChain: chains.find((chain) => chain.chainId === swapParams.toChainId),
23397
+ selectedSourceToken: fromToken,
23398
+ removeSourceToken: true,
23399
+ })
23400
+ : tokens,
23401
+ config,
23402
+ chainId: swapParams.toChainId,
23403
+ address: swapParams.toTokenAddress,
23404
+ direction: "to",
23405
+ excludeToken: {
23406
+ chainId: swapParams.fromChainId,
23407
+ address: fromTokenAddress,
23408
+ },
23409
+ });
23410
+ return { ...swapParams, fromTokenAddress, toTokenAddress };
23295
23411
  };
23296
23412
  /**
23297
23413
  * When user changes something from the SwapView
@@ -23303,10 +23419,19 @@ const handleDestinationAddressOnSwapChange = ({ fromChainId, fromTokenAddress, t
23303
23419
  * If only destination token is changed but source is not, and they were the same, then source token updates to something else
23304
23420
  *
23305
23421
  */
23306
- const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute, tokens, chains, config, queryClient, connectedSourceAddress, }) => {
23307
- const { fromChainId, fromTokenAddress, toChainId, toTokenAddress, destinationAddress, fallbackAddress, depositRefundAddress, } = inputParams;
23422
+ const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute: storedSwapRoute, tokens, chains, config, queryClient, connectedSourceAddress, }) => {
23423
+ const initialSwapRoute = storedSwapRoute
23424
+ ? {
23425
+ ...storedSwapRoute,
23426
+ fromTokenAddress: normalizeArcTokenAddress(storedSwapRoute.fromChainId, storedSwapRoute.fromTokenAddress),
23427
+ toTokenAddress: normalizeArcTokenAddress(storedSwapRoute.toChainId, storedSwapRoute.toTokenAddress),
23428
+ }
23429
+ : undefined;
23430
+ const { fromChainId, toChainId, destinationAddress, fallbackAddress, depositRefundAddress, } = inputParams;
23308
23431
  const srcChainId = fromChainId ?? initialSwapRoute?.fromChainId;
23309
23432
  const destinationChainId = toChainId ?? initialSwapRoute?.toChainId;
23433
+ const fromTokenAddress = normalizeArcTokenAddress(srcChainId, inputParams.fromTokenAddress);
23434
+ const toTokenAddress = normalizeArcTokenAddress(destinationChainId, inputParams.toTokenAddress);
23310
23435
  const defaultFromAddress = getInitialOrDefaultTokenAddressForChain({
23311
23436
  tokens,
23312
23437
  config,
@@ -23382,15 +23507,20 @@ const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute, tokens, chai
23382
23507
  const newDepositRefundAddress = sourceChainChanged
23383
23508
  ? undefined
23384
23509
  : depositRefundAddress || initialSwapRoute?.depositRefundAddress;
23385
- return {
23386
- fromChainId: srcChainId,
23387
- fromTokenAddress: sourceTokenAddress,
23388
- toChainId: destinationChainId,
23389
- toTokenAddress: destinationTokenAddress,
23390
- destinationAddress: newDestinationAddress,
23391
- fallbackAddress: newFallbackAddress,
23392
- depositRefundAddress: newDepositRefundAddress,
23393
- };
23510
+ return normalizeSwapParamsForSelection({
23511
+ swapParams: {
23512
+ fromChainId: srcChainId,
23513
+ fromTokenAddress: sourceTokenAddress,
23514
+ toChainId: destinationChainId,
23515
+ toTokenAddress: destinationTokenAddress,
23516
+ destinationAddress: newDestinationAddress,
23517
+ fallbackAddress: newFallbackAddress,
23518
+ depositRefundAddress: newDepositRefundAddress,
23519
+ },
23520
+ tokens,
23521
+ chains,
23522
+ config,
23523
+ });
23394
23524
  };
23395
23525
  /* Sorts tokens based on the following order:
23396
23526
  * 1. Native token on chain ID "1" (Ethereum) comes first.
@@ -23448,8 +23578,10 @@ const sortAllTokens = (tokenA, tokenB) => {
23448
23578
  return 0;
23449
23579
  };
23450
23580
  const findToken = (tokens, chainId, address) => tokens.find((t) => t.chainId === chainId && t.address === address);
23451
- const findNativeToken = (tokens, chain) => tokens.find((t) => t.symbol.toUpperCase() === chain.nativeCurrency.symbol.toUpperCase() &&
23452
- t.chainId == chain.chainId);
23581
+ const findNativeToken = (tokens, chain) => tokens.find((t) => t.chainId === chain.chainId &&
23582
+ (isArcChain(chain.chainId)
23583
+ ? isArcNativeToken(t)
23584
+ : t.symbol.toUpperCase() === chain.nativeCurrency.symbol.toUpperCase()));
23453
23585
  const normalizeIbcAddress = (address) => {
23454
23586
  if (!address.toLowerCase().startsWith("ibc/")) {
23455
23587
  return address;
@@ -23519,9 +23651,7 @@ function selectGroupDefaultInfo(tokens) {
23519
23651
  const groupTokensBySymbol = (tokens, chainType) => {
23520
23652
  const groups = {};
23521
23653
  // Filter tokens by chain type if specified
23522
- const filteredTokens = chainType
23523
- ? tokens.filter((token) => token.type === chainType)
23524
- : tokens;
23654
+ const filteredTokens = deduplicateArcBalances(chainType ? tokens.filter((token) => token.type === chainType) : tokens);
23525
23655
  // First pass: group by coingeckoId or symbol
23526
23656
  filteredTokens.forEach((token) => {
23527
23657
  const groupKey = token.coingeckoId || token.symbol.split(".")[0];
@@ -23597,7 +23727,7 @@ const groupTokensBySymbol = (tokens, chainType) => {
23597
23727
  */
23598
23728
  const groupTokensByChainId = (tokens, chains) => {
23599
23729
  const groups = {};
23600
- tokens.forEach((token) => {
23730
+ deduplicateArcBalances(tokens).forEach((token) => {
23601
23731
  const chainData = chains.find((chain) => chain.chainId === token.chainId);
23602
23732
  const groupKey = token.chainId;
23603
23733
  if (!groups[groupKey]) {
@@ -23645,6 +23775,8 @@ const filterViewableTokens = (tokens, config, direction) => {
23645
23775
  { chainId: CHAIN_IDS.DCHAIN, address: nativeEvmTokenAddress },
23646
23776
  ];
23647
23777
  return (tokens.filter((token) => {
23778
+ if (isArcNativeToken(token))
23779
+ return false;
23648
23780
  if (direction) {
23649
23781
  const parsedDirection = getParsedDirection(direction);
23650
23782
  const availableTokensForDirection = config.availableTokens?.[parsedDirection];
@@ -23660,7 +23792,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23660
23792
  };
23661
23793
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
23662
23794
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
23663
- const { fetchAllSecretBalances } = await import('./secretService--tJFCkzT.js');
23795
+ const { fetchAllSecretBalances } = await import('./secretService-DkE9yz1o.js');
23664
23796
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
23665
23797
  };
23666
23798
  function getTokenAssetsKey(token) {
@@ -28087,7 +28219,7 @@ function useStellarWallets() {
28087
28219
  try {
28088
28220
  const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
28089
28221
  const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
28090
- const { formatStellarWallet } = await import('./stellarService.client-DAxgO3m3.js');
28222
+ const { formatStellarWallet } = await import('./stellarService.client-DtA9zkRt.js');
28091
28223
  const modules = [...initializeAllModules(), new LedgerModule()];
28092
28224
  const promises = modules.map(async (module) => {
28093
28225
  const isAvailable = await module.isAvailable();
@@ -29015,12 +29147,27 @@ const useMultiChainWallet = (chain) => {
29015
29147
  };
29016
29148
 
29017
29149
  const useSwap = () => {
29018
- const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, } = useConfigStore((state) => state.config);
29150
+ const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, availableTokens, } = useConfigStore((state) => state.config);
29019
29151
  const fromPrice = useTransactionStore((state) => state.fromPrice);
29020
- const { swapRoute } = useSwapRoutePersistStore();
29152
+ const { swapRoute: storedSwapRoute } = useSwapRoutePersistStore();
29021
29153
  const { tokens } = useSquidTokens();
29022
29154
  const queryClient = useQueryClient();
29023
29155
  const { chains, supportedDestinationChains, supportedSourceChains } = useSquidChains();
29156
+ const swapRoute = useMemo(() => storedSwapRoute
29157
+ ? normalizeSwapParamsForSelection({
29158
+ swapParams: storedSwapRoute,
29159
+ tokens,
29160
+ chains,
29161
+ config: { disabledChains, availableChains, availableTokens },
29162
+ })
29163
+ : undefined, [
29164
+ storedSwapRoute,
29165
+ tokens,
29166
+ chains,
29167
+ disabledChains,
29168
+ availableChains,
29169
+ availableTokens,
29170
+ ]);
29024
29171
  const sourceChainId = useMemo(() => swapRoute?.fromChainId ??
29025
29172
  (initialAssets?.from
29026
29173
  ? resolveChainIdFromAsset(initialAssets.from, supportedSourceChains)
@@ -29031,13 +29178,23 @@ const useSwap = () => {
29031
29178
  : undefined), [swapRoute?.toChainId, supportedDestinationChains, initialAssets?.to]);
29032
29179
  const fromChain = useMemo(() => supportedSourceChains.find((c) => c.chainId === swapRoute?.fromChainId), [swapRoute?.fromChainId, supportedSourceChains]);
29033
29180
  const toChain = useMemo(() => supportedDestinationChains.find((c) => c.chainId === swapRoute?.toChainId), [swapRoute?.toChainId, supportedDestinationChains]);
29034
- const fromTokens = useMemo(() => getTokensForChain(tokens, sourceChainId), [tokens, sourceChainId]);
29181
+ const fromTokens = useMemo(() => {
29182
+ const chainTokens = getTokensForChain(tokens, sourceChainId);
29183
+ return isArcChain(sourceChainId)
29184
+ ? filterViewableTokens(chainTokens, { availableTokens }, "from")
29185
+ : chainTokens;
29186
+ }, [tokens, sourceChainId, availableTokens]);
29035
29187
  const fromToken = useMemo(() => fromTokens.find((t) => t.address.toLowerCase() === swapRoute?.fromTokenAddress?.toLowerCase()), [fromTokens, swapRoute?.fromTokenAddress]);
29036
- const toTokens = useMemo(() => filterTokensForDestination({
29037
- tokens: getTokensForChain(tokens, destChainId),
29038
- selectedDestinationChain: toChain,
29039
- selectedSourceToken: fromToken,
29040
- }), [destChainId, toChain, fromToken, tokens]);
29188
+ const toTokens = useMemo(() => {
29189
+ const destinationTokens = filterTokensForDestination({
29190
+ tokens: getTokensForChain(tokens, destChainId),
29191
+ selectedDestinationChain: toChain,
29192
+ selectedSourceToken: fromToken,
29193
+ });
29194
+ return isArcChain(destChainId)
29195
+ ? filterViewableTokens(destinationTokens, { availableTokens }, "to")
29196
+ : destinationTokens;
29197
+ }, [destChainId, toChain, fromToken, tokens, availableTokens]);
29041
29198
  const toToken = useMemo(() => toTokens.find((t) => t.address.toLowerCase() === swapRoute?.toTokenAddress?.toLowerCase()), [toTokens, swapRoute?.toTokenAddress]);
29042
29199
  const isSameChain = sourceChainId === destChainId;
29043
29200
  const tokenItems = useMemo(() => ({ from: fromTokens, to: toTokens }), [fromTokens, toTokens]);
@@ -29085,6 +29242,7 @@ const useSwap = () => {
29085
29242
  defaultTokensPerChain,
29086
29243
  disabledChains,
29087
29244
  availableChains,
29245
+ availableTokens,
29088
29246
  },
29089
29247
  queryClient,
29090
29248
  connectedSourceAddress: connectedSourceAddress.address,
@@ -29124,6 +29282,7 @@ const useSwap = () => {
29124
29282
  defaultTokensPerChain,
29125
29283
  disabledChains,
29126
29284
  availableChains,
29285
+ availableTokens,
29127
29286
  initialAssets,
29128
29287
  queryClient,
29129
29288
  swapRoute,
@@ -29179,6 +29338,10 @@ const useSwap = () => {
29179
29338
  },
29180
29339
  direction: "to",
29181
29340
  });
29341
+ if ([defaultFromChainId, defaultToChainId].some((chainId) => isArcChain(chainId) &&
29342
+ !tokens.some((token) => token.chainId === chainId && !isArcNativeToken(token)))) {
29343
+ return;
29344
+ }
29182
29345
  const fromTokenAddress = getInitialOrDefaultTokenAddressForChain({
29183
29346
  tokens,
29184
29347
  config: {
@@ -29186,6 +29349,7 @@ const useSwap = () => {
29186
29349
  defaultTokensPerChain,
29187
29350
  disabledChains,
29188
29351
  availableChains,
29352
+ availableTokens,
29189
29353
  },
29190
29354
  chainId: defaultFromChainId,
29191
29355
  direction: "from",
@@ -29197,6 +29361,7 @@ const useSwap = () => {
29197
29361
  defaultTokensPerChain,
29198
29362
  disabledChains,
29199
29363
  availableChains,
29364
+ availableTokens,
29200
29365
  },
29201
29366
  chainId: defaultToChainId,
29202
29367
  direction: "to",
@@ -29221,6 +29386,7 @@ const useSwap = () => {
29221
29386
  initialAssets,
29222
29387
  disabledChains,
29223
29388
  availableChains,
29389
+ availableTokens,
29224
29390
  defaultTokensPerChain,
29225
29391
  tokens,
29226
29392
  ]);
@@ -31012,17 +31178,18 @@ function useNativeTokenForChain(chain) {
31012
31178
  return cantonTokens;
31013
31179
  }
31014
31180
  };
31181
+ const tokens = getTokensForChainType();
31015
31182
  const nativeTokenForChainType = useMemo(() => {
31016
31183
  if (!chain)
31017
31184
  return undefined;
31018
- return findNativeToken(getTokensForChainType(), chain);
31019
- }, [chain]);
31185
+ return findNativeToken(tokens, chain);
31186
+ }, [chain, tokens]);
31020
31187
  return { nativeToken: nativeTokenForChainType };
31021
31188
  }
31022
31189
 
31023
31190
  const useEvmNativeBalance = ({ address, chain, }) => {
31024
31191
  const { isChainTypeConnected } = useWallet();
31025
- const { data: nativeEvmBalance, isLoading } = useBalance({
31192
+ const { data: nativeEvmBalance, isLoading, isError, } = useBalance({
31026
31193
  address: address,
31027
31194
  chainId: Number(chain?.chainId),
31028
31195
  query: {
@@ -31034,6 +31201,8 @@ const useEvmNativeBalance = ({ address, chain, }) => {
31034
31201
  },
31035
31202
  });
31036
31203
  const balance = useMemo(() => {
31204
+ if (isArcChain(chain?.chainId) && isError)
31205
+ return undefined;
31037
31206
  if (nativeEvmBalance?.decimals != null && nativeEvmBalance?.value != null) {
31038
31207
  if (chain?.chainId === CHAIN_IDS.HEDERA) {
31039
31208
  return {
@@ -31047,7 +31216,12 @@ const useEvmNativeBalance = ({ address, chain, }) => {
31047
31216
  };
31048
31217
  }
31049
31218
  return;
31050
- }, [nativeEvmBalance?.decimals, nativeEvmBalance?.value, chain?.chainId]);
31219
+ }, [
31220
+ nativeEvmBalance?.decimals,
31221
+ nativeEvmBalance?.value,
31222
+ chain?.chainId,
31223
+ isError,
31224
+ ]);
31051
31225
  return {
31052
31226
  balance,
31053
31227
  isLoading,
@@ -31534,7 +31708,7 @@ function hederaWalletConnect(parameters) {
31534
31708
  const optionalChains = config.chains.map((x) => x.id);
31535
31709
  if (!optionalChains.length)
31536
31710
  return;
31537
- const { EthereumProvider } = await import('./index.es-09IsADsA.js');
31711
+ const { EthereumProvider } = await import('./index.es-BiK_wjSb.js');
31538
31712
  const rawProvider = await EthereumProvider.init({
31539
31713
  ...restParameters,
31540
31714
  disableProviderPing: true,
@@ -32849,6 +33023,27 @@ function useSourceChainGasToken({ fromChain, fromToken, }) {
32849
33023
  normalizeFee: convertTempoFeeToStablecoinUnits,
32850
33024
  };
32851
33025
  }
33026
+ if (isArcChain(fromChain.chainId)) {
33027
+ const isUsdc = isArcUsdcToken(fromToken);
33028
+ const isNative = isArcNativeToken(fromToken);
33029
+ if (fromToken.chainId !== fromChain.chainId ||
33030
+ nativeBalance.decimals !== 18 ||
33031
+ (isUsdc && fromToken.decimals !== 6) ||
33032
+ (isNative && fromToken.decimals !== 18)) {
33033
+ return null;
33034
+ }
33035
+ return {
33036
+ fromTokenPaysGasFees: isUsdc || isNative,
33037
+ gasTokenBalanceWei: nativeBalance.value,
33038
+ normalizeFee: (fee) => fee,
33039
+ fromAmountToGasUnits: isUsdc
33040
+ ? (amount) => amount * 10n ** 12n
33041
+ : undefined,
33042
+ gasUnitsToFromAmount: isUsdc
33043
+ ? (amount) => amount / 10n ** 12n
33044
+ : undefined,
33045
+ };
33046
+ }
32852
33047
  return {
32853
33048
  fromTokenPaysGasFees: fromToken.address.toLowerCase() ===
32854
33049
  chainTypeToNativeTokenAddressMap[fromToken.type].toLowerCase(),
@@ -32856,10 +33051,10 @@ function useSourceChainGasToken({ fromChain, fromToken, }) {
32856
33051
  normalizeFee: (fee) => fee,
32857
33052
  };
32858
33053
  }, [
32859
- fromToken?.address,
32860
- fromToken?.type,
33054
+ fromToken,
32861
33055
  fromChain?.chainId,
32862
33056
  nativeBalance?.value,
33057
+ nativeBalance?.decimals,
32863
33058
  tempoFeeData,
32864
33059
  ]);
32865
33060
  /**
@@ -32874,9 +33069,20 @@ function useSourceChainGasToken({ fromChain, fromToken, }) {
32874
33069
  return evmTokens.find((t) => t.chainId === fromChain.chainId &&
32875
33070
  t.address.toLowerCase() === tempoFeeData.gasTokenAddress.toLowerCase());
32876
33071
  }
33072
+ if (isArcChain(fromChain.chainId)) {
33073
+ return nativeToken?.decimals === 18
33074
+ ? {
33075
+ ...nativeToken,
33076
+ symbol: fromChain.nativeCurrency.symbol,
33077
+ name: fromChain.nativeCurrency.name,
33078
+ }
33079
+ : undefined;
33080
+ }
32877
33081
  return nativeToken;
32878
33082
  }, [
32879
33083
  fromChain?.chainId,
33084
+ fromChain?.nativeCurrency.symbol,
33085
+ fromChain?.nativeCurrency.name,
32880
33086
  fromToken?.address,
32881
33087
  nativeToken,
32882
33088
  tempoFeeData,
@@ -33035,22 +33241,57 @@ const calculateTotalNativeFees = ({ expressFeeCost, firstFeeCost, firstGasCost,
33035
33241
  (sameTokenBetweenFees
33036
33242
  ? BigInt(firstFeeCost?.amount ?? "0") + BigInt(firstGasCost?.amount ?? "0")
33037
33243
  : BigInt(firstGasCost?.amount ?? "0"));
33244
+ const addGasReserve = (fee) => (fee * 110n + 99n) / 100n;
33245
+ const calculateArcGasCosts = (gasCosts) => {
33246
+ const sourceGasCosts = gasCosts.filter((cost) => isArcChain(cost.token.chainId));
33247
+ if (sourceGasCosts.length === 0)
33248
+ return undefined;
33249
+ let total = 0n;
33250
+ for (const { amount, token } of sourceGasCosts) {
33251
+ const fee = BigInt(amount);
33252
+ if (fee <= 0n)
33253
+ return undefined;
33254
+ if (isArcUsdcToken(token) && token.decimals === 6) {
33255
+ total += fee * 10n ** 12n;
33256
+ }
33257
+ else if (isArcNativeToken(token) && token.decimals === 18) {
33258
+ total += fee;
33259
+ }
33260
+ else {
33261
+ return undefined;
33262
+ }
33263
+ }
33264
+ return total;
33265
+ };
33266
+ const calculateTotalGasBalanceNeeded = ({ fromAmount, networkFeesWei, chainFeeParams, }) => {
33267
+ if (!chainFeeParams || networkFeesWei == null)
33268
+ return undefined;
33269
+ if (!chainFeeParams.fromTokenPaysGasFees)
33270
+ return networkFeesWei;
33271
+ const amount = BigInt(fromAmount ?? "0");
33272
+ const amountInGasUnits = chainFeeParams.fromAmountToGasUnits?.(amount) ?? amount;
33273
+ return amountInGasUnits + networkFeesWei;
33274
+ };
33038
33275
  const checkIsGasBalanceEnough = ({ fromAmount, networkFeesWei, chainFeeParams, }) => {
33039
33276
  if (!chainFeeParams)
33040
33277
  return false;
33041
- if (chainFeeParams.fromTokenPaysGasFees) {
33042
- return (BigInt(fromAmount ?? "0") + networkFeesWei <=
33043
- chainFeeParams.gasTokenBalanceWei);
33044
- }
33045
- return networkFeesWei <= chainFeeParams.gasTokenBalanceWei;
33278
+ const total = calculateTotalGasBalanceNeeded({
33279
+ fromAmount,
33280
+ networkFeesWei,
33281
+ chainFeeParams,
33282
+ });
33283
+ return total != null && total <= chainFeeParams.gasTokenBalanceWei;
33046
33284
  };
33047
33285
  const calculateMinAmountValueWarnMsg = ({ networkFeesWei, chainFeeParams, fromTokenDecimals, }) => {
33048
- if (!chainFeeParams?.fromTokenPaysGasFees)
33286
+ if (!chainFeeParams?.fromTokenPaysGasFees || networkFeesWei == null)
33049
33287
  return undefined;
33050
33288
  const minAmount = chainFeeParams.gasTokenBalanceWei - networkFeesWei;
33051
33289
  if (minAmount <= BigInt(0))
33052
33290
  return undefined;
33053
- return formatBNToReadable(minAmount, fromTokenDecimals);
33291
+ const amountInTokenUnits = chainFeeParams.gasUnitsToFromAmount?.(minAmount) ?? minAmount;
33292
+ if (amountInTokenUnits <= 0n)
33293
+ return undefined;
33294
+ return formatBNToReadable(amountInTokenUnits, fromTokenDecimals);
33054
33295
  };
33055
33296
  /**
33056
33297
  * Calculates the estimated duration of a route
@@ -33099,14 +33340,22 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
33099
33340
  const expectedGasRefundCostUSD = convertTokenAmountToUSD(formatBNToReadable(expectedGasRefundCost, firstFeeCost?.token.decimals ?? 18), firstFeeCost?.token.usdPrice ?? "0");
33100
33341
  const sameTokenBetweenFees = firstFeeCost?.token.address === firstGasCost?.token.address &&
33101
33342
  firstFeeCost?.token.chainId === firstGasCost?.token.chainId;
33102
- const totalNativeFees = calculateTotalNativeFees({
33103
- expressFeeCost,
33104
- firstFeeCost,
33105
- firstGasCost,
33106
- sameTokenBetweenFees,
33107
- });
33108
- const totalFeesInNativeTokenPlusRatio = (totalNativeFees * BigInt(110)) / BigInt(100);
33109
- const networkFeesWei = chainFeeParams?.normalizeFee(totalFeesInNativeTokenPlusRatio) ?? BigInt(0);
33343
+ const totalNativeFees = isArcChain(fromChain?.chainId)
33344
+ ? calculateArcGasCosts(allGasCosts)
33345
+ : calculateTotalNativeFees({
33346
+ expressFeeCost,
33347
+ firstFeeCost,
33348
+ firstGasCost,
33349
+ sameTokenBetweenFees,
33350
+ });
33351
+ const totalFeesInNativeTokenPlusRatio = totalNativeFees == null
33352
+ ? undefined
33353
+ : isArcChain(fromChain?.chainId)
33354
+ ? addGasReserve(totalNativeFees)
33355
+ : (totalNativeFees * BigInt(110)) / BigInt(100);
33356
+ const networkFeesWei = totalFeesInNativeTokenPlusRatio == null
33357
+ ? undefined
33358
+ : chainFeeParams?.normalizeFee(totalFeesInNativeTokenPlusRatio);
33110
33359
  const isGasBalanceEnough = checkIsGasBalanceEnough({
33111
33360
  chainFeeParams,
33112
33361
  fromAmount,
@@ -33122,10 +33371,12 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
33122
33371
  estimatedRouteDuration: squidRoute?.estimate?.estimatedRouteDuration,
33123
33372
  isSingleChainRoute,
33124
33373
  });
33125
- // gas fees + fromAmount (if fromToken is gas token)
33126
- const totalGasBalanceNeeded = networkFeesWei +
33127
- BigInt(chainFeeParams?.fromTokenPaysGasFees ? (fromAmount ?? 0) : 0);
33128
- const gasBalanceNeeded = gasToken
33374
+ const totalGasBalanceNeeded = calculateTotalGasBalanceNeeded({
33375
+ fromAmount,
33376
+ networkFeesWei,
33377
+ chainFeeParams,
33378
+ });
33379
+ const gasBalanceNeeded = gasToken && totalGasBalanceNeeded != null
33129
33380
  ? formatBNToReadable(totalGasBalanceNeeded, gasToken.decimals)
33130
33381
  : undefined;
33131
33382
  return {
@@ -33147,7 +33398,7 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
33147
33398
  expectedGasRefundCostUSD,
33148
33399
  sameTokenBetweenFees,
33149
33400
  fromTokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
33150
- totalNativeFees,
33401
+ totalNativeFees: totalNativeFees ?? 0n,
33151
33402
  isGasBalanceEnough,
33152
33403
  minAmountValueWarnMsg,
33153
33404
  estimatedRouteDuration,
@@ -33196,8 +33447,12 @@ function useSendTransactionGas({ chain, token, from, }) {
33196
33447
  case ChainType.EVM: {
33197
33448
  const client = await getClient(chain);
33198
33449
  const feeData = await client.getFeeData();
33199
- if (!feeData.maxFeePerGas)
33450
+ if (!feeData.maxFeePerGas) {
33451
+ if (isArcChain(chain.chainId)) {
33452
+ throw new Error("Gas price is unavailable");
33453
+ }
33200
33454
  return BigInt(0);
33455
+ }
33201
33456
  let maxFeePerGas = feeData.maxFeePerGas;
33202
33457
  if (token.chainId === CHAIN_IDS.HEDERA) {
33203
33458
  maxFeePerGas = scaleWeiToHbar(BigInt(feeData.maxFeePerGas));
@@ -33217,6 +33472,9 @@ function useSendTransactionGas({ chain, token, from, }) {
33217
33472
  value: 1,
33218
33473
  chainId: chain.chainId,
33219
33474
  });
33475
+ if (isArcChain(chain.chainId) && gas <= 0n) {
33476
+ throw new Error("Gas estimate is unavailable");
33477
+ }
33220
33478
  return gas * maxFeePerGas;
33221
33479
  }
33222
33480
  const erc20Interface = new Interface(erc20Abi);
@@ -33231,6 +33489,9 @@ function useSendTransactionGas({ chain, token, from, }) {
33231
33489
  chainId: chain.chainId,
33232
33490
  });
33233
33491
  const feeWei = gas * maxFeePerGas;
33492
+ if (isArcChain(chain.chainId) && feeWei <= 0n) {
33493
+ throw new Error("Gas estimate is unavailable");
33494
+ }
33234
33495
  // Tempo gas fees are denominated 18 units,
33235
33496
  // this value needs to be scaled to 6 decimals
33236
33497
  if (chain.chainId === CHAIN_IDS.TEMPO) {
@@ -33278,35 +33539,45 @@ function useSendTransactionGas({ chain, token, from, }) {
33278
33539
  }
33279
33540
 
33280
33541
  function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
33281
- const { data: estimatedGas = BigInt(0), isLoading } = useSendTransactionGas({
33542
+ const { data, isLoading, isFetching, isError, refetch } = useSendTransactionGas({
33282
33543
  chain,
33283
33544
  token,
33284
33545
  from,
33285
33546
  });
33547
+ const estimatedGas = isError || isFetching ? undefined : data;
33548
+ const networkFeesWei = estimatedGas == null
33549
+ ? undefined
33550
+ : isArcChain(chain?.chainId)
33551
+ ? addGasReserve(estimatedGas)
33552
+ : estimatedGas;
33286
33553
  const { chainFeeParams, gasToken } = useSourceChainGasToken({
33287
33554
  fromChain: chain,
33288
33555
  fromToken: token,
33289
33556
  });
33290
33557
  const isGasBalanceEnough = useMemo(() => {
33291
- if (!amount || !token?.decimals)
33558
+ if (!amount || token?.decimals == null || !gasToken)
33292
33559
  return false;
33293
33560
  return checkIsGasBalanceEnough({
33294
33561
  fromAmount: parseToBigInt(amount, token.decimals).toString(),
33295
- networkFeesWei: estimatedGas,
33562
+ networkFeesWei,
33296
33563
  chainFeeParams,
33297
33564
  });
33298
- }, [amount, estimatedGas, token, chainFeeParams]);
33565
+ }, [amount, networkFeesWei, token, chainFeeParams, gasToken]);
33299
33566
  const gasBalanceNeeded = useMemo(() => {
33300
- if (!amount || !token?.decimals || !gasToken?.decimals)
33567
+ if (!amount || token?.decimals == null || gasToken?.decimals == null)
33568
+ return undefined;
33569
+ const totalGasBalanceNeeded = calculateTotalGasBalanceNeeded({
33570
+ fromAmount: parseToBigInt(amount, token.decimals).toString(),
33571
+ networkFeesWei,
33572
+ chainFeeParams,
33573
+ });
33574
+ if (totalGasBalanceNeeded == null)
33301
33575
  return undefined;
33302
- // gas fees + fromAmount (if fromToken is gas token)
33303
- const totalGasBalanceNeeded = estimatedGas +
33304
- parseToBigInt(chainFeeParams?.fromTokenPaysGasFees ? (amount ?? "0") : "0", token.decimals);
33305
33576
  return formatBNToReadable(totalGasBalanceNeeded, gasToken.decimals);
33306
33577
  }, [
33307
33578
  amount,
33308
- chainFeeParams?.fromTokenPaysGasFees,
33309
- estimatedGas,
33579
+ chainFeeParams,
33580
+ networkFeesWei,
33310
33581
  gasToken?.decimals,
33311
33582
  token?.decimals,
33312
33583
  ]);
@@ -33317,20 +33588,22 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
33317
33588
  parseToBigInt(amount, token.decimals));
33318
33589
  }, [amount, balance, token?.decimals]);
33319
33590
  const minAmountValueWarnMsg = useMemo(() => {
33320
- if (!token?.address || !estimatedGas || !chainFeeParams)
33591
+ if (!token?.address || !gasToken || !chainFeeParams)
33321
33592
  return undefined;
33322
33593
  return calculateMinAmountValueWarnMsg({
33323
33594
  chainFeeParams,
33324
- networkFeesWei: estimatedGas,
33595
+ networkFeesWei,
33325
33596
  fromTokenDecimals: token.decimals,
33326
33597
  });
33327
- }, [estimatedGas, token, chainFeeParams]);
33598
+ }, [networkFeesWei, token, chainFeeParams, gasToken]);
33328
33599
  return {
33329
33600
  estimatedGas,
33330
33601
  gasBalanceNeeded,
33331
33602
  isBalanceEnough,
33332
33603
  tokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
33333
- isLoading,
33604
+ isLoading: isLoading || isFetching,
33605
+ isError,
33606
+ refetchGasEstimate: refetch,
33334
33607
  isGasBalanceEnough,
33335
33608
  minAmountValueWarnMsg,
33336
33609
  };
@@ -34231,6 +34504,19 @@ const useApproval = ({ squidRoute, }) => {
34231
34504
  const { getChainType } = useSquidChains();
34232
34505
  const { switchChainAsync } = useSwitchChain();
34233
34506
  const { connectedAddress: { address: sourceUserAddress }, } = useMultiChainWallet(fromChain);
34507
+ const arcNativeBalanceQuery = useBalance({
34508
+ address: sourceUserAddress,
34509
+ chainId: Number(fromChain?.chainId),
34510
+ query: { enabled: false },
34511
+ });
34512
+ const arcTokenBalanceQuery = useReadContract({
34513
+ address: fromToken?.address,
34514
+ abi: erc20Abi,
34515
+ functionName: "balanceOf",
34516
+ args: [sourceUserAddress],
34517
+ chainId: Number(fromChain?.chainId),
34518
+ query: { enabled: false },
34519
+ });
34234
34520
  const isSagaEvmSameChainSwap = isSameChain &&
34235
34521
  fromChain?.chainId.toString() === CHAIN_IDS.SAGA_EVM.toString();
34236
34522
  // Swaps on SagaEVM are regular EVM transactions, following the standard ERC20 approve/allowance mechanism.
@@ -34391,13 +34677,20 @@ const useApproval = ({ squidRoute, }) => {
34391
34677
  return false;
34392
34678
  }
34393
34679
  }, {
34394
- onSuccess: async () => {
34680
+ onSuccess: async (approved) => {
34681
+ if (approved && isArcChain(fromChain?.chainId)) {
34682
+ await Promise.all([
34683
+ arcNativeBalanceQuery.refetch({ throwOnError: true }),
34684
+ arcTokenBalanceQuery.refetch({ throwOnError: true }),
34685
+ ]);
34686
+ queryClient.invalidateQueries(getPrefixKey(QueryKeys.AllTokensBalance));
34687
+ }
34395
34688
  await allowanceQuery?.refetch();
34396
34689
  queryClient.invalidateQueries(getPrefixKey(QueryKeys.RouteApproved));
34397
34690
  // After an approval, we refetch the transaction query with all required parameters
34398
34691
  // This is to ensure we're using the latest expiry timestamp
34399
34692
  if (squidRoute) {
34400
- queryClient.refetchQueries({
34693
+ await queryClient.refetchQueries({
34401
34694
  queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken, fromPrice, squidRoute.params.slippage, squidRoute.params.fromAddress, squidRoute.params.bypassGuardrails, squidRoute.params.toAddress, squidRoute.params.fallbackAddresses?.[0]?.address, squidRoute.params.quoteOnly, getChainType(squidRoute.params.fromChain), squidRoute.params.preHook, squidRoute.params.postHook,
34402
34695
  // TODO: update types
34403
34696
  squidRoute.params?.overrideGasRefundAddress),
@@ -39173,5 +39466,5 @@ const SquidProvider = ({ children, config, placeholder, }) => {
39173
39466
  React.createElement(CosmosProvider, null, children))))))))))) : (placeholder);
39174
39467
  };
39175
39468
 
39176
- export { useWalletStore as $, AxelarStatusResponseType as A, useHederaAccountActivation as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useHederaTokenAssociations as E, useKeyboardNavigation as F, useSquidQueryClient as G, HistoryTxType as H, useSquid as I, useStellarAccountActivation as J, useStellarTrustLine as K, useAddressBookStore as L, useAssetsColorsStore as M, Nr as N, useFavoriteTokensStore as O, useHistoryStore as P, QueryKeys as Q, useSendTransactionStore as R, SquidStatusErrorType as S, TransactionErrorType as T, useConfigStore as U, useSquidStore as V, Wo as W, XamanXrplNetwork as X, useSwapRoutePersistStore as Y, useTransactionStore as Z, ConnectingWalletStatus as _, WindowWalletFlag as a, useAvailableQuotes as a$, useDepositAddress as a0, useSwap as a1, buildUrlSearchParamsFromSwapEvent as a2, parseInitialAssetsFromUrl as a3, useUrlSwapParams as a4, useAllConnectedWalletBalances as a5, useAllTokensWithBalanceForChainType as a6, useCosmosBalance as a7, useEvmBalance as a8, useMultiChainBalance as a9, useRouteWarnings as aA, useSendTransactionStatus as aB, useSwapTransactionStatus as aC, useAvatar as aD, useHistory as aE, useDebouncedValue as aF, useAddToken as aG, useAutoConnect as aH, useEnsDataForAddress as aI, useEnsSearch as aJ, useGnosisContext as aK, useIsSameAddressAndGnosisContext as aL, useIntegratorContext as aM, useMultiChainWallet as aN, useSigner as aO, useWallet as aP, useWallets as aQ, useXrplTrustLine as aR, TX_STATUS_CONSTANTS as aS, FINAL_TRANSACTION_STATUSES as aT, useGetFiatQuote as aU, useGetOnRampConfig as aV, useExecuteFiatQuote as aW, useFiatOnRampTxStatus as aX, useFiatTransactions as aY, useCurrencyDetails as aZ, useCountryDetails as a_, useMultipleTokenPrices as aa, useBitcoinNativeBalance as ab, useCosmosNativeBalance as ac, useEvmNativeBalance as ad, useNativeBalance as ae, useSolanaNativeBalance as af, useStellarNativeBalance as ag, useSuiNativeBalance as ah, useXrplNativeBalance as ai, useNativeTokenForChain as aj, useSingleTokenPrice as ak, useSourceChainGasToken as al, useSquidTokens as am, useHistoricalData as an, useTokensData as ao, useEstimateSendTransaction as ap, useSendTransaction as aq, useSendTransactionGas as ar, useAllTransactionsStatus as as, useApproval as at, useDepositTransactionStatus as au, useEstimate as av, useEstimatePriceImpact as aw, useExecuteTransaction as ax, useGetRoute as ay, useGetRouteWrapper as az, DEFAULT_ROUTE_REFETCH_INTERVAL as b, addEthereumChain as b$, useRecommendedQuote as b0, useGetOnrampPaymentTypes as b1, useSuggestedFiatAmounts as b2, SquidProvider as b3, EnsService as b4, getXummClient as b5, isXamanXAppContext as b6, getQueryHeaders as b7, getStatusCode as b8, is404Error as b9, randomIntFromInterval as bA, getTokensForChain as bB, getFirstAvailableChainId as bC, fetchHighestBalanceToken as bD, getInitialOrDefaultTokenAddressForChain as bE, getInitialTokenAddressForChain as bF, filterTokensForDestination as bG, getInitialChainIdFromConfig as bH, getCosmosKey as bI, getKeysSettled as bJ, getAllKeysForSupportedCosmosChains as bK, isCosmosAddressValid as bL, getCosmosSigningClient as bM, getCosmosChainInfosObject as bN, connectCosmosWallet as bO, isFallbackAddressNeeded as bP, suggestChainOrThrow as bQ, normalizeError as bR, transactionErrorCode as bS, isUserRejectionError as bT, getTransactionError as bU, handleTransactionErrorEvents as bV, isSwapRouteError as bW, isStatusError as bX, createQuoteRequestParamsHash as bY, WidgetEvents as bZ, EvmNetworkNotSupportedErrorCode as b_, assetsBaseUrl as ba, shareSubgraphId as bb, sortTokensBySharedSubgraphIds as bc, getSupportedChainIdsForDirection as bd, filterChains as be, filterTokens as bf, getTokenImage as bg, getNewSwapParamsFromInput as bh, sortAllTokens as bi, findToken as bj, findNativeToken as bk, normalizeIbcAddress as bl, groupTokensBySymbol as bm, groupTokensByChainId as bn, filterViewableTokens as bo, getSecretNetworkBalances as bp, getTokenAssetsKey as bq, fetchAssetsColors as br, isSupportedChainType as bs, initializeSquidData as bt, isEmptyObject as bu, normalizeTokenSymbol as bv, areTokenSymbolsCompatible as bw, isEvmosChain as bx, resolveChainIdFromAsset as by, getConfigWithDefaults as bz, chainTypeToNativeTokenAddressMap as c, chainflipMultihopBridgeType as c$, parseEvmAddress as c0, formatEvmWallet as c1, filterWagmiConnector as c2, waitForReceiptWithRetry as c3, getUserCountry as c4, getCountryData as c5, getCurrencyData as c6, adaptiveRound as c7, getSuggestedAmountsForCurrency as c8, HederaExtensionHelper as c9, isStellarIssuedToken as cA, getStellarHorizonApiUrl as cB, isValidIssuedAsset as cC, isValidHorizonAsset as cD, formatTransactionHistoryDate as cE, getAxelarExplorerTxUrl as cF, getSourceExplorerTxUrl as cG, getMainExplorerUrl as cH, formatDistance as cI, formatSeconds as cJ, formatSwapTxStatusResponseForStorage as cK, simplifyRouteAction as cL, fetchSwapTransactionStatus as cM, compareTransactionIds as cN, isCoralBridgeAction as cO, isActionCompletedOnSourceTx as cP, sleep as cQ, isChainflipDepositRoute as cR, isChainflipBridgeTransaction as cS, isOnChainTxData as cT, isDepositAddressDirectTransferRoute as cU, getHistoryTransactionId as cV, getStepStatuses as cW, getHalfSuccessState as cX, getStepsInfos as cY, getSwapTxStatusRefetchInterval as cZ, getSendTxStatusRefetchInterval as c_, convertHederaAccountIdToEvmAddress as ca, convertEvmAddressToHederaAccountId as cb, scaleHbarToWei as cc, scaleWeiToHbar as cd, parseToBigInt as ce, roundNumericValue as cf, formatUnitsRounded as cg, formatTokenAmount as ch, formatUsdAmount as ci, trimExtraDecimals as cj, getNumericValue as ck, cleanAmount as cl, convertTokenAmountToUSD as cm, convertUSDToTokenAmount as cn, calculateTotal24hChange as co, getRouteExpiry as cp, searchTokens as cq, filterSolanaWallets as cr, isSolanaAddressValid as cs, executeSolanaSwap as ct, executeSolanaTransfer as cu, isStellarAddressValid as cv, getStellarNetwork as cw, stellarAddressToScVal as cx, getStellarTrustLineAsset as cy, isStellarToken as cz, definedInWindow as d, getBridgeType as d0, getTransactionStatus as d1, getTransactionEndStatus as d2, isHistoryTransactionPending as d3, isHistoryTransactionFailed as d4, isHistoryTransactionWarning as d5, isHistoryTransactionEnded as d6, formatHash as d7, isWalletAddressValid as d8, redirectToExtensionsStore as d9, populateWallets as da, buildFallbackWallets as db, getDefaultChain as dc, sortWallets as dd, areSameAddress as de, sortAddressBook as df, calculateTotalUsdBalanceUSD as dg, addTokenToWallet as dh, isEvmChainNotSupportedError as di, getWalletSupportedChainTypes as dj, getConnectorForChainType as dk, walletSupportsChainType as dl, connectWallet as dm, cancelConnectWallet as dn, isProblematicConnector as dp, mergeWallets as dq, isXionSmartContractAddress as dr, isXrplAddressValid as ds, buildXrplTrustSetTx as dt, getXrplNetwork as du, parseXrplPaymentTx as dv, parseXrplTokenAddress as dw, er as e, formatBNToReadable as f, chainTypeToZeroAddressMap as g, destinationAddressResetValue as h, fallbackAddressResetValue as i, nativeCantonTokenAddress as j, nativeCosmosTokenAddress as k, nativeEvmTokenAddress as l, nativeSolanaTokenAddress as m, nativeBitcoinTokenAddress as n, nativeStellarTokenAddress as o, nativeSuiTokenAddress as p, nativeXrplTokenAddress as q, CosmosProvider as r, SendTransactionStatus as s, TransactionStatus as t, useCosmosContext as u, useTrackSearchEmpty as v, walletIconBaseUrl as w, useSquidChains as x, useClient as y, useCosmosForChain as z };
39177
- //# sourceMappingURL=index-C3owE9lb.js.map
39469
+ export { useWalletStore as $, AxelarStatusResponseType as A, useHederaAccountActivation as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useHederaTokenAssociations as E, useKeyboardNavigation as F, useSquidQueryClient as G, HistoryTxType as H, useSquid as I, useStellarAccountActivation as J, useStellarTrustLine as K, useAddressBookStore as L, useAssetsColorsStore as M, Nr as N, useFavoriteTokensStore as O, useHistoryStore as P, QueryKeys as Q, useSendTransactionStore as R, SquidStatusErrorType as S, TransactionErrorType as T, useConfigStore as U, useSquidStore as V, Wo as W, XamanXrplNetwork as X, useSwapRoutePersistStore as Y, useTransactionStore as Z, ConnectingWalletStatus as _, WindowWalletFlag as a, useAvailableQuotes as a$, useDepositAddress as a0, useSwap as a1, buildUrlSearchParamsFromSwapEvent as a2, parseInitialAssetsFromUrl as a3, useUrlSwapParams as a4, useAllConnectedWalletBalances as a5, useAllTokensWithBalanceForChainType as a6, useCosmosBalance as a7, useEvmBalance as a8, useMultiChainBalance as a9, useRouteWarnings as aA, useSendTransactionStatus as aB, useSwapTransactionStatus as aC, useAvatar as aD, useHistory as aE, useDebouncedValue as aF, useAddToken as aG, useAutoConnect as aH, useEnsDataForAddress as aI, useEnsSearch as aJ, useGnosisContext as aK, useIsSameAddressAndGnosisContext as aL, useIntegratorContext as aM, useMultiChainWallet as aN, useSigner as aO, useWallet as aP, useWallets as aQ, useXrplTrustLine as aR, TX_STATUS_CONSTANTS as aS, FINAL_TRANSACTION_STATUSES as aT, useGetFiatQuote as aU, useGetOnRampConfig as aV, useExecuteFiatQuote as aW, useFiatOnRampTxStatus as aX, useFiatTransactions as aY, useCurrencyDetails as aZ, useCountryDetails as a_, useMultipleTokenPrices as aa, useBitcoinNativeBalance as ab, useCosmosNativeBalance as ac, useEvmNativeBalance as ad, useNativeBalance as ae, useSolanaNativeBalance as af, useStellarNativeBalance as ag, useSuiNativeBalance as ah, useXrplNativeBalance as ai, useNativeTokenForChain as aj, useSingleTokenPrice as ak, useSourceChainGasToken as al, useSquidTokens as am, useHistoricalData as an, useTokensData as ao, useEstimateSendTransaction as ap, useSendTransaction as aq, useSendTransactionGas as ar, useAllTransactionsStatus as as, useApproval as at, useDepositTransactionStatus as au, useEstimate as av, useEstimatePriceImpact as aw, useExecuteTransaction as ax, useGetRoute as ay, useGetRouteWrapper as az, DEFAULT_ROUTE_REFETCH_INTERVAL as b, WidgetEvents as b$, useRecommendedQuote as b0, useGetOnrampPaymentTypes as b1, useSuggestedFiatAmounts as b2, SquidProvider as b3, EnsService as b4, getXummClient as b5, isXamanXAppContext as b6, getQueryHeaders as b7, getStatusCode as b8, is404Error as b9, getConfigWithDefaults as bA, randomIntFromInterval as bB, getTokensForChain as bC, getFirstAvailableChainId as bD, fetchHighestBalanceToken as bE, getTokenAddressForSelection as bF, getInitialOrDefaultTokenAddressForChain as bG, getInitialTokenAddressForChain as bH, filterTokensForDestination as bI, getInitialChainIdFromConfig as bJ, getCosmosKey as bK, getKeysSettled as bL, getAllKeysForSupportedCosmosChains as bM, isCosmosAddressValid as bN, getCosmosSigningClient as bO, getCosmosChainInfosObject as bP, connectCosmosWallet as bQ, isFallbackAddressNeeded as bR, suggestChainOrThrow as bS, normalizeError as bT, transactionErrorCode as bU, isUserRejectionError as bV, getTransactionError as bW, handleTransactionErrorEvents as bX, isSwapRouteError as bY, isStatusError as bZ, createQuoteRequestParamsHash as b_, assetsBaseUrl as ba, shareSubgraphId as bb, sortTokensBySharedSubgraphIds as bc, getSupportedChainIdsForDirection as bd, filterChains as be, filterTokens as bf, getTokenImage as bg, normalizeSwapParamsForSelection as bh, getNewSwapParamsFromInput as bi, sortAllTokens as bj, findToken as bk, findNativeToken as bl, normalizeIbcAddress as bm, groupTokensBySymbol as bn, groupTokensByChainId as bo, filterViewableTokens as bp, getSecretNetworkBalances as bq, getTokenAssetsKey as br, fetchAssetsColors as bs, isSupportedChainType as bt, initializeSquidData as bu, isEmptyObject as bv, normalizeTokenSymbol as bw, areTokenSymbolsCompatible as bx, isEvmosChain as by, resolveChainIdFromAsset as bz, chainTypeToNativeTokenAddressMap as c, getSwapTxStatusRefetchInterval as c$, EvmNetworkNotSupportedErrorCode as c0, addEthereumChain as c1, parseEvmAddress as c2, formatEvmWallet as c3, filterWagmiConnector as c4, waitForReceiptWithRetry as c5, getUserCountry as c6, getCountryData as c7, getCurrencyData as c8, adaptiveRound as c9, getStellarTrustLineAsset as cA, isStellarToken as cB, isStellarIssuedToken as cC, getStellarHorizonApiUrl as cD, isValidIssuedAsset as cE, isValidHorizonAsset as cF, formatTransactionHistoryDate as cG, getAxelarExplorerTxUrl as cH, getSourceExplorerTxUrl as cI, getMainExplorerUrl as cJ, formatDistance as cK, formatSeconds as cL, formatSwapTxStatusResponseForStorage as cM, simplifyRouteAction as cN, fetchSwapTransactionStatus as cO, compareTransactionIds as cP, isCoralBridgeAction as cQ, isActionCompletedOnSourceTx as cR, sleep as cS, isChainflipDepositRoute as cT, isChainflipBridgeTransaction as cU, isOnChainTxData as cV, isDepositAddressDirectTransferRoute as cW, getHistoryTransactionId as cX, getStepStatuses as cY, getHalfSuccessState as cZ, getStepsInfos as c_, getSuggestedAmountsForCurrency as ca, HederaExtensionHelper as cb, convertHederaAccountIdToEvmAddress as cc, convertEvmAddressToHederaAccountId as cd, scaleHbarToWei as ce, scaleWeiToHbar as cf, parseToBigInt as cg, roundNumericValue as ch, formatUnitsRounded as ci, formatTokenAmount as cj, formatUsdAmount as ck, trimExtraDecimals as cl, getNumericValue as cm, cleanAmount as cn, convertTokenAmountToUSD as co, convertUSDToTokenAmount as cp, calculateTotal24hChange as cq, getRouteExpiry as cr, searchTokens as cs, filterSolanaWallets as ct, isSolanaAddressValid as cu, executeSolanaSwap as cv, executeSolanaTransfer as cw, isStellarAddressValid as cx, getStellarNetwork as cy, stellarAddressToScVal as cz, definedInWindow as d, getSendTxStatusRefetchInterval as d0, chainflipMultihopBridgeType as d1, getBridgeType as d2, getTransactionStatus as d3, getTransactionEndStatus as d4, isHistoryTransactionPending as d5, isHistoryTransactionFailed as d6, isHistoryTransactionWarning as d7, isHistoryTransactionEnded as d8, formatHash as d9, isWalletAddressValid as da, redirectToExtensionsStore as db, populateWallets as dc, buildFallbackWallets as dd, getDefaultChain as de, sortWallets as df, areSameAddress as dg, sortAddressBook as dh, calculateTotalUsdBalanceUSD as di, addTokenToWallet as dj, isEvmChainNotSupportedError as dk, getWalletSupportedChainTypes as dl, getConnectorForChainType as dm, walletSupportsChainType as dn, connectWallet as dp, cancelConnectWallet as dq, isProblematicConnector as dr, mergeWallets as ds, isXionSmartContractAddress as dt, isXrplAddressValid as du, buildXrplTrustSetTx as dv, getXrplNetwork as dw, parseXrplPaymentTx as dx, parseXrplTokenAddress as dy, er as e, formatBNToReadable as f, chainTypeToZeroAddressMap as g, destinationAddressResetValue as h, fallbackAddressResetValue as i, nativeCantonTokenAddress as j, nativeCosmosTokenAddress as k, nativeEvmTokenAddress as l, nativeSolanaTokenAddress as m, nativeBitcoinTokenAddress as n, nativeStellarTokenAddress as o, nativeSuiTokenAddress as p, nativeXrplTokenAddress as q, CosmosProvider as r, SendTransactionStatus as s, TransactionStatus as t, useCosmosContext as u, useTrackSearchEmpty as v, walletIconBaseUrl as w, useSquidChains as x, useClient as y, useCosmosForChain as z };
39470
+ //# sourceMappingURL=index-CLzjMzS_.js.map