@0xsquid/react-hooks 8.7.2-beta-interactive-to-amount.2 → 8.8.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 (35) hide show
  1. package/dist/core/queries/queries-keys.d.ts +1 -1
  2. package/dist/core/types/config.d.ts +1 -2
  3. package/dist/core/types/event.d.ts +2 -1
  4. package/dist/core/types/route.d.ts +4 -0
  5. package/dist/hooks/store/useSquidStore.d.ts +1 -2
  6. package/dist/hooks/swap/useSwap.d.ts +2 -4
  7. package/dist/hooks/transaction/useGetRoute.d.ts +8 -9
  8. package/dist/{index-BhIaRT6b.js → index-CHdL63Y4.js} +67 -158
  9. package/dist/index-CHdL63Y4.js.map +1 -0
  10. package/dist/{index-cWo0aVvt.js → index-IxCpRlyV.js} +67 -160
  11. package/dist/index-IxCpRlyV.js.map +1 -0
  12. package/dist/{index.es-DDv7Krv1.js → index.es-B_4aEeiW.js} +2 -2
  13. package/dist/{index.es-DDv7Krv1.js.map → index.es-B_4aEeiW.js.map} +1 -1
  14. package/dist/{index.es-DjscAACC.js → index.es-C1qztDII.js} +2 -2
  15. package/dist/{index.es-DjscAACC.js.map → index.es-C1qztDII.js.map} +1 -1
  16. package/dist/index.esm.js +1 -1
  17. package/dist/index.js +2 -4
  18. package/dist/index.js.map +1 -1
  19. package/dist/{secretService-XZVHxElk.js → secretService-D0p2T9tf.js} +2 -2
  20. package/dist/{secretService-XZVHxElk.js.map → secretService-D0p2T9tf.js.map} +1 -1
  21. package/dist/{secretService-cYEbiXXP.js → secretService-vD8qpukk.js} +2 -2
  22. package/dist/{secretService-cYEbiXXP.js.map → secretService-vD8qpukk.js.map} +1 -1
  23. package/dist/services/internal/assetsService.d.ts +1 -1
  24. package/dist/services/internal/errorService.d.ts +0 -9
  25. package/dist/services/internal/estimateService.d.ts +18 -8
  26. package/dist/services/internal/eventService.d.ts +2 -1
  27. package/dist/services/internal/numberService.d.ts +0 -1
  28. package/dist/services/internal/transactionService.d.ts +7 -1
  29. package/dist/{stellarService.client-CBqIkpcb.js → stellarService.client-Cia5YJMU.js} +2 -2
  30. package/dist/{stellarService.client-CBqIkpcb.js.map → stellarService.client-Cia5YJMU.js.map} +1 -1
  31. package/dist/{stellarService.client-B5B1XaV_.js → stellarService.client-DKQ8QpMf.js} +2 -2
  32. package/dist/{stellarService.client-B5B1XaV_.js.map → stellarService.client-DKQ8QpMf.js.map} +1 -1
  33. package/package.json +3 -3
  34. package/dist/index-BhIaRT6b.js.map +0 -1
  35. package/dist/index-cWo0aVvt.js.map +0 -1
@@ -3971,9 +3971,6 @@ const getNumericValue = ({ value, precision, useComaEvery3Digits = true, hideIfZ
3971
3971
  const finalValue = `${isNegative ? "-" : ""}${prefix}${formattedIfVerySmall}${suffix ? ` ${suffix}` : ""}`;
3972
3972
  return wrapInParens ? `(${finalValue})` : finalValue;
3973
3973
  };
3974
- function isZeroAmount(amount) {
3975
- return !amount || amount === "0";
3976
- }
3977
3974
 
3978
3975
  /**
3979
3976
  * Creates a hash string from quote request parameters to track changes
@@ -4425,35 +4422,6 @@ const isSwapRouteError = (error) => {
4425
4422
  const isStatusError = (error) => {
4426
4423
  return error && typeof error.errorType === "string";
4427
4424
  };
4428
- // --------------------
4429
- // SQUID ROUTE ERROR MESSAGES
4430
- // --------------------
4431
- const GENERIC_ROUTE_ERROR_MESSAGE = "Oops! something went wrong. Try again later";
4432
- const squidRouteErrorMapping = {
4433
- Unknown: GENERIC_ROUTE_ERROR_MESSAGE,
4434
- UnknownError: GENERIC_ROUTE_ERROR_MESSAGE,
4435
- SquidServiceError: GENERIC_ROUTE_ERROR_MESSAGE,
4436
- BAD_REQUEST: GENERIC_ROUTE_ERROR_MESSAGE,
4437
- };
4438
- /**
4439
- * Extract a human-readable message from a Squid route error.
4440
- *
4441
- * Accepts either a raw `SquidRouteError` or an axios-shaped error with the
4442
- * route error nested in `response.data`, so callers don't have to unwrap.
4443
- * Falls back to a generic message when no usable string is available.
4444
- */
4445
- const getSquidRouteErrorMessage = (error) => {
4446
- const candidate = (error?.response?.data ?? error);
4447
- if (typeof candidate?.message === "string" && candidate.message.length > 0) {
4448
- return candidate.message;
4449
- }
4450
- if (typeof candidate?.type === "string") {
4451
- const mapped = squidRouteErrorMapping[candidate.type];
4452
- if (mapped)
4453
- return mapped;
4454
- }
4455
- return GENERIC_ROUTE_ERROR_MESSAGE;
4456
- };
4457
4425
 
4458
4426
  // Xion has a way to create smart contract accounts (with social logins) these are 63 characters long
4459
4427
  // And the particularity is that we can't derive the osmosis fallback address from these because they don't have a way to access funds in other networks
@@ -21160,8 +21128,18 @@ const compareTransactionIds = (idA, idB) => {
21160
21128
  */
21161
21129
  function isCoralBridgeAction(action) {
21162
21130
  return (action.type === squidTypes.ActionType.RFQ &&
21163
- // TODO: update types
21164
- action.provider?.toLowerCase() === "coral");
21131
+ // TODO: update types to use enum
21132
+ action.provider === "Squid Intents");
21133
+ }
21134
+ /**
21135
+ * Determines if a given action completes as part of the user's source transaction.
21136
+ * Action types like RFQ are fulfilled by a solver in a separate transaction,
21137
+ * so they are NOT completed on source even if they share the same chain.
21138
+ */
21139
+ function isActionCompletedOnSourceTx(action, fromChainId) {
21140
+ if (action.type === squidTypes.ActionType.RFQ)
21141
+ return false;
21142
+ return action.fromChain === fromChainId && action.toChain === fromChainId;
21165
21143
  }
21166
21144
  function sleep(ms) {
21167
21145
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -22445,15 +22423,14 @@ const keys = () => ({
22445
22423
  // ============
22446
22424
  // Transactions
22447
22425
  // ============
22448
- transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, fromAmount, toAmount, slippage, sourceUserAddress, degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChainType, preHook, postHook, overrideGasRefundAddress, prefer) => [
22426
+ transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, price, slippage, sourceUserAddress, degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChainType, preHook, postHook, overrideGasRefundAddress) => [
22449
22427
  ...keys().transactions(),
22450
22428
  exports.QueryKeys.Transaction,
22451
22429
  fromChainId,
22452
22430
  toChainId,
22453
22431
  toTokenAddress,
22454
22432
  fromTokenAddress,
22455
- fromAmount,
22456
- toAmount,
22433
+ price,
22457
22434
  slippage,
22458
22435
  sourceUserAddress,
22459
22436
  degenMode,
@@ -22464,7 +22441,6 @@ const keys = () => ({
22464
22441
  preHook,
22465
22442
  postHook,
22466
22443
  overrideGasRefundAddress,
22467
- prefer,
22468
22444
  ],
22469
22445
  swapTransactionStatus: (transactionId) => [
22470
22446
  ...keys().transactions(),
@@ -22656,7 +22632,6 @@ const getConfigWithDefaults = (config) => {
22656
22632
  preHook: get$2(config, "preHook", defaultConfigValues.preHook),
22657
22633
  postHook: get$2(config, "postHook", defaultConfigValues.postHook),
22658
22634
  overrideGasRefundAddress: get$2(config, "overrideGasRefundAddress", defaultConfigValues.overrideGasRefundAddress),
22659
- prefer: get$2(config, "prefer", defaultConfigValues.prefer),
22660
22635
  };
22661
22636
  };
22662
22637
  const randomIntFromInterval = (min, max) => {
@@ -23350,7 +23325,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23350
23325
  };
23351
23326
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
23352
23327
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
23353
- const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-XZVHxElk.js'); });
23328
+ const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-D0p2T9tf.js'); });
23354
23329
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
23355
23330
  };
23356
23331
  function getTokenAssetsKey(token) {
@@ -25207,7 +25182,10 @@ const useConfigStore = zustand.create(() => ({
25207
25182
  isInitialized: false,
25208
25183
  }));
25209
25184
  const useTransactionStore = zustand.create((set, get) => ({
25185
+ fromPrice: undefined,
25186
+ txLocalId: undefined,
25210
25187
  transactions: {},
25188
+ currentTransaction: undefined,
25211
25189
  setTransactionState(txId, tx) {
25212
25190
  if (!txId)
25213
25191
  return;
@@ -26745,7 +26723,7 @@ function useStellarWallets() {
26745
26723
  try {
26746
26724
  const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
26747
26725
  const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
26748
- const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-CBqIkpcb.js'); });
26726
+ const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-Cia5YJMU.js'); });
26749
26727
  const modules = [...initializeAllModules(), new LedgerModule()];
26750
26728
  const promises = modules.map(async (module) => {
26751
26729
  const isAvailable = await module.isAvailable();
@@ -27644,8 +27622,7 @@ const useMultiChainWallet = (chain) => {
27644
27622
 
27645
27623
  const useSwap = () => {
27646
27624
  const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, } = useConfigStore((state) => state.config);
27647
- const fromAmount = useTransactionStore((state) => state.fromAmount);
27648
- const toAmount = useTransactionStore((state) => state.toAmount);
27625
+ const fromPrice = useTransactionStore((state) => state.fromPrice);
27649
27626
  const { swapRoute } = useSwapRoutePersistStore();
27650
27627
  const { tokens } = useSquidTokens();
27651
27628
  const queryClient = reactQuery.useQueryClient();
@@ -27697,17 +27674,8 @@ const useSwap = () => {
27697
27674
  }),
27698
27675
  };
27699
27676
  }, [destAddressData, destAddressEnsData.data, toChain?.chainType]);
27700
- const fromAmountChanged = React.useCallback((amount) => {
27701
- useTransactionStore.setState({
27702
- fromAmount: amount || undefined,
27703
- toAmount: undefined,
27704
- });
27705
- }, []);
27706
- const toAmountChanged = React.useCallback((amount) => {
27707
- useTransactionStore.setState({
27708
- toAmount: amount || undefined,
27709
- fromAmount: undefined,
27710
- });
27677
+ const fromPriceChanged = React.useCallback((price) => {
27678
+ useTransactionStore.setState({ fromPrice: price || undefined });
27711
27679
  }, []);
27712
27680
  /**
27713
27681
  * When user changes something from the SwapView
@@ -27867,10 +27835,8 @@ const useSwap = () => {
27867
27835
  tokenItems,
27868
27836
  onSwapChange,
27869
27837
  invertSwaps,
27870
- fromAmount,
27871
- toAmount,
27872
- fromAmountChanged,
27873
- toAmountChanged,
27838
+ fromPrice,
27839
+ fromPriceChanged,
27874
27840
  toToken,
27875
27841
  fromToken,
27876
27842
  fromChain,
@@ -29613,14 +29579,20 @@ const useEvmNativeBalance = ({ address, chain, }) => {
29613
29579
  },
29614
29580
  });
29615
29581
  const balance = React.useMemo(() => {
29616
- if (nativeEvmBalance?.decimals && nativeEvmBalance?.value) {
29582
+ if (nativeEvmBalance?.decimals != null && nativeEvmBalance?.value != null) {
29583
+ if (chain?.chainId === CHAIN_IDS.HEDERA) {
29584
+ return {
29585
+ decimals: 8,
29586
+ value: scaleWeiToHbar(nativeEvmBalance.value),
29587
+ };
29588
+ }
29617
29589
  return {
29618
29590
  decimals: nativeEvmBalance.decimals,
29619
29591
  value: nativeEvmBalance.value,
29620
29592
  };
29621
29593
  }
29622
29594
  return;
29623
- }, [nativeEvmBalance?.decimals, nativeEvmBalance?.value]);
29595
+ }, [nativeEvmBalance?.decimals, nativeEvmBalance?.value, chain?.chainId]);
29624
29596
  return {
29625
29597
  balance,
29626
29598
  isLoading,
@@ -30077,7 +30049,7 @@ function hederaWalletConnect(parameters) {
30077
30049
  const optionalChains = config.chains.map((x) => x.id);
30078
30050
  if (!optionalChains.length)
30079
30051
  return;
30080
- const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-DjscAACC.js'); });
30052
+ const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-C1qztDII.js'); });
30081
30053
  const rawProvider = await EthereumProvider.init({
30082
30054
  ...restParameters,
30083
30055
  disableProviderPing: true,
@@ -31568,19 +31540,6 @@ const formatEstimatedRouteDuration = ({ estimatedRouteDuration, isSingleChainRou
31568
31540
  format: (sTemplate, mTemplate, hTemplate) => formatSeconds(durationInSeconds, sTemplate, mTemplate, hTemplate),
31569
31541
  };
31570
31542
  };
31571
- /**
31572
- * Calculates and formats various estimate results based on the provided Squid route and additional parameters.
31573
- *
31574
- * @param {RouteResponse["route"]} squidRoute - The Squid route containing estimate information.
31575
- * @param {Token[]} tokens - An array of token objects.
31576
- * @param {ChainData} fromChain - The source chain object.
31577
- * @param {ChainData} toChain - The destination chain object.
31578
- * @param {boolean} collectFees - Flag indicating whether to collect fees.
31579
- * @param {string} nativeTokenBalanceFromChain - The native token balance on the source chain.
31580
- * @param {boolean} expressActivatedUI - Flag indicating whether express mode is activated in the UI.
31581
- * @returns {Object} An object containing various estimate results and calculations, including token information,
31582
- * amounts, fees, gas costs, and other relevant data for the transaction.
31583
- */
31584
31543
  const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees, chainFeeParams, gasToken, }) => {
31585
31544
  const fromToken = findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken);
31586
31545
  const fromAmount = squidRoute?.estimate?.fromAmount;
@@ -31599,7 +31558,7 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
31599
31558
  const integratorFeeCost = allFeeCosts.length > 0 && collectFees
31600
31559
  ? allFeeCosts.find((f) => f.name === "Integrator fee")
31601
31560
  : undefined;
31602
- const expectedGasRefundCost = calculateExpectedGasRefundCost(firstFeeCost, fromChain?.chainType, estimate?.actions.map(simplifyRouteAction));
31561
+ const expectedGasRefundCost = calculateExpectedGasRefundCost(firstFeeCost, fromChain?.chainType, estimate?.actions?.map(simplifyRouteAction));
31603
31562
  const expectedGasRefundCostUSD = convertTokenAmountToUSD(formatBNToReadable(expectedGasRefundCost, firstFeeCost?.token.decimals ?? 18), firstFeeCost?.token.usdPrice ?? "0");
31604
31563
  const sameTokenBetweenFees = firstFeeCost?.token.address === firstGasCost?.token.address &&
31605
31564
  firstFeeCost?.token.chainId === firstGasCost?.token.chainId;
@@ -32483,7 +32442,7 @@ const useHistory = (txType) => {
32483
32442
  fromChain: tx.params.fromChain,
32484
32443
  fromToken: tx.params.fromToken,
32485
32444
  fromAddress: tx.params.fromAddress,
32486
- fromAmount: tx.params.fromAmount || tx.estimate.fromAmount,
32445
+ fromAmount: tx.params.fromAmount,
32487
32446
  toChain: tx.params.toChain,
32488
32447
  toToken: tx.params.toToken,
32489
32448
  toAddress: tx.params.toAddress,
@@ -32724,7 +32683,7 @@ const useApproval = ({ squidRoute, }) => {
32724
32683
  const publicClient = wagmi.usePublicClient();
32725
32684
  const queryClient = reactQuery.useQueryClient();
32726
32685
  const squid = useSquidStore((state) => state.squid);
32727
- const { fromChain, fromToken, fromAmount, toAmount, isSameChain } = useSwap();
32686
+ const { fromChain, fromToken, fromPrice, isSameChain } = useSwap();
32728
32687
  const { evmSigner } = useSigner({ chain: fromChain });
32729
32688
  const { connector: activeConnector } = wagmi.useAccount();
32730
32689
  const { getChainType } = useSquidChains();
@@ -32897,9 +32856,9 @@ const useApproval = ({ squidRoute, }) => {
32897
32856
  // This is to ensure we're using the latest expiry timestamp
32898
32857
  if (squidRoute) {
32899
32858
  queryClient.refetchQueries({
32900
- queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken, fromAmount, toAmount, 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,
32859
+ 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,
32901
32860
  // TODO: update types
32902
- squidRoute.params?.overrideGasRefundAddress, squidRoute.params?.prefer),
32861
+ squidRoute.params?.overrideGasRefundAddress),
32903
32862
  });
32904
32863
  }
32905
32864
  },
@@ -32916,7 +32875,7 @@ const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/ass
32916
32875
  const useEstimate = (squidRoute) => {
32917
32876
  const collectFees = useConfigStore((state) => state.config.collectFees);
32918
32877
  const { tokens } = useSquidTokens();
32919
- const { fromChain, toChain, fromAmount } = useSwap();
32878
+ const { fromChain, toChain, fromPrice } = useSwap();
32920
32879
  const fromToken = React.useMemo(() => findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken), [tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken]);
32921
32880
  const { chainFeeParams, gasToken } = useSourceChainGasToken({
32922
32881
  fromChain,
@@ -33012,9 +32971,9 @@ const useEstimate = (squidRoute) => {
33012
32971
  const slippageFormatted = Number(squidRoute?.estimate?.aggregateSlippage ?? 0).toFixed(2) + "%";
33013
32972
  const fromBalanceEnoughToSwap = React.useMemo(() => {
33014
32973
  const fromBalanceNum = Number(fromBalanceFormatted ?? 0);
33015
- const fromAmountNum = Number(fromAmount ?? 0);
33016
- return fromBalanceNum >= fromAmountNum;
33017
- }, [fromBalanceFormatted, fromAmount]);
32974
+ const fromPriceNum = Number(fromPrice ?? 0);
32975
+ return fromBalanceNum >= fromPriceNum;
32976
+ }, [fromBalanceFormatted, fromPrice]);
33018
32977
  return {
33019
32978
  ...estimateResults,
33020
32979
  fromBalanceFormatted,
@@ -35959,6 +35918,12 @@ coin.DecProto = {
35959
35918
 
35960
35919
  const useExecuteTransaction = (squidRoute) => {
35961
35920
  const { fromChain, toChain, fromToken, toToken, isSameChain } = useSwap();
35921
+ // A route completes on source tx only if it's same-chain AND
35922
+ // every action is fulfilled in the user's source transaction
35923
+ const isCompletedOnSourceTx = isSameChain &&
35924
+ !!fromChain &&
35925
+ !!squidRoute &&
35926
+ squidRoute.estimate.actions.every((a) => isActionCompletedOnSourceTx(a, fromChain.chainId));
35962
35927
  const { evmSigner, cosmosSigner, solanaSigner, bitcoinSigner, suiSigner, xrplSigner, stellarSigner, } = useSigner({
35963
35928
  chain: fromChain,
35964
35929
  });
@@ -35993,7 +35958,7 @@ const useExecuteTransaction = (squidRoute) => {
35993
35958
  routeType: route.transactionRequest.type,
35994
35959
  nonce,
35995
35960
  transactionId: txHash,
35996
- transactionIdForStatus: transactionIdForStatus ?? txHash,
35961
+ transactionIdForStatus,
35997
35962
  quoteId,
35998
35963
  status,
35999
35964
  sourceStatus,
@@ -36233,12 +36198,8 @@ const useExecuteTransaction = (squidRoute) => {
36233
36198
  if (!depositData?.depositAddress) {
36234
36199
  throw new Error("Deposit address is required");
36235
36200
  }
36236
- const fromAmount = route.params.fromAmount || route.estimate.fromAmount;
36237
- if (isZeroAmount(fromAmount)) {
36238
- throw new Error("fromAmount is required for Solana transfer");
36239
- }
36240
36201
  const signature = await executeSolanaTransfer({
36241
- amount: BigInt(fromAmount),
36202
+ amount: BigInt(route.params.fromAmount),
36242
36203
  target: depositData.depositAddress,
36243
36204
  signer: solanaSigner,
36244
36205
  connection: solanaConnection,
@@ -36297,43 +36258,6 @@ const useExecuteTransaction = (squidRoute) => {
36297
36258
  ? error
36298
36259
  : new Error("Failed to execute Solana transaction");
36299
36260
  }
36300
- }, {
36301
- onError: (error, variables) => {
36302
- const currentTx = getTransaction(variables.id);
36303
- const errorObject = getTransactionError(error);
36304
- setTransactionStoreState(variables.id, {
36305
- ...currentTx,
36306
- status: exports.TransactionStatus.ERROR,
36307
- sourceStatus: exports.TransactionStatus.ERROR,
36308
- error: errorObject,
36309
- });
36310
- if (currentTx?.transactionId &&
36311
- errorObject.type === exports.TransactionErrorType.CALL_EXCEPTION) {
36312
- replaceSwapTransactionStatus({
36313
- transactionId: currentTx.transactionId,
36314
- statusResponse: currentTx.statusResponse,
36315
- status: exports.TransactionStatus.ERROR,
36316
- });
36317
- }
36318
- },
36319
- onSuccess: (_data, variables) => {
36320
- const currentTx = getTransaction(variables.id);
36321
- queryClient.invalidateQueries(getPrefixKey(exports.QueryKeys.Balances));
36322
- if (isSameChain && currentTx?.transactionId) {
36323
- replaceSwapTransactionStatus({
36324
- transactionId: currentTx.transactionId,
36325
- statusResponse: currentTx.statusResponse,
36326
- status: exports.TransactionStatus.SUCCESS,
36327
- });
36328
- }
36329
- setTransactionStoreState(variables.id, {
36330
- ...currentTx,
36331
- sourceStatus: exports.TransactionStatus.SUCCESS,
36332
- status: isSameChain
36333
- ? exports.TransactionStatus.SUCCESS
36334
- : exports.TransactionStatus.ONGOING,
36335
- });
36336
- },
36337
36261
  });
36338
36262
  const swapMutationBitcoin = reactQuery.useMutation(async ({ id, route }) => {
36339
36263
  const { depositAddress, amount: sendAmount, chainflipStatusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
@@ -36554,7 +36478,7 @@ const useExecuteTransaction = (squidRoute) => {
36554
36478
  const handleTransactionSuccess = React.useCallback((id) => {
36555
36479
  const currentTx = getTransaction(id);
36556
36480
  queryClient.invalidateQueries(getPrefixKey(exports.QueryKeys.Balances));
36557
- if (isSameChain && currentTx?.transactionId) {
36481
+ if (isCompletedOnSourceTx && currentTx?.transactionId) {
36558
36482
  replaceSwapTransactionStatus({
36559
36483
  transactionId: currentTx.transactionId,
36560
36484
  statusResponse: currentTx.statusResponse,
@@ -36564,13 +36488,13 @@ const useExecuteTransaction = (squidRoute) => {
36564
36488
  setTransactionStoreState(id, {
36565
36489
  ...currentTx,
36566
36490
  sourceStatus: exports.TransactionStatus.SUCCESS,
36567
- status: isSameChain
36491
+ status: isCompletedOnSourceTx
36568
36492
  ? exports.TransactionStatus.SUCCESS
36569
36493
  : exports.TransactionStatus.ONGOING,
36570
36494
  });
36571
36495
  }, [
36572
36496
  getTransaction,
36573
- isSameChain,
36497
+ isCompletedOnSourceTx,
36574
36498
  queryClient,
36575
36499
  replaceSwapTransactionStatus,
36576
36500
  setTransactionStoreState,
@@ -36593,8 +36517,8 @@ const useExecuteTransaction = (squidRoute) => {
36593
36517
  if (currentTx?.transactionId &&
36594
36518
  errorObject.type === exports.TransactionErrorType.CALL_EXCEPTION) {
36595
36519
  replaceSwapTransactionStatus({
36596
- transactionId: currentTx?.transactionId,
36597
- statusResponse: currentTx?.statusResponse,
36520
+ transactionId: currentTx.transactionId,
36521
+ statusResponse: currentTx.statusResponse,
36598
36522
  status: exports.TransactionStatus.ERROR,
36599
36523
  });
36600
36524
  }
@@ -36748,12 +36672,8 @@ const useGetRoute = () => {
36748
36672
  * These data will be used to trigger the transaction
36749
36673
  * @returns {Route} Route data
36750
36674
  */
36751
- return reactQuery.useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice = "", toPrice = "", bypassGuardrails, quoteOnly, fromChainType, postHook, preHook, overrideGasRefundAddress, prefer, }) => {
36752
- if (!fromChain ||
36753
- !toChain ||
36754
- !fromToken ||
36755
- !toToken ||
36756
- (!fromPrice && !toPrice)) {
36675
+ return reactQuery.useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice, bypassGuardrails, quoteOnly, fromChainType, postHook, preHook, overrideGasRefundAddress, }) => {
36676
+ if (!fromChain || !toChain || !fromToken || !toToken || !fromPrice) {
36757
36677
  return undefined;
36758
36678
  }
36759
36679
  // Dispatch requestQuote event
@@ -36763,7 +36683,6 @@ const useGetRoute = () => {
36763
36683
  fromToken: fromToken.address,
36764
36684
  toToken: toToken.address,
36765
36685
  fromAmount: fromPrice,
36766
- toAmount: toPrice,
36767
36686
  fromAddress: sourceUserAddress,
36768
36687
  toAddress: destinationAddress,
36769
36688
  });
@@ -36772,13 +36691,13 @@ const useGetRoute = () => {
36772
36691
  const fromTokenAddress = fromToken.address;
36773
36692
  const toTokenAddress = toToken.address;
36774
36693
  const fromAmount = parseToBigInt(fromPrice?.toString() ?? "0", fromToken?.decimals).toString();
36775
- const toAmount = parseToBigInt(toPrice?.toString() ?? "0", toToken?.decimals).toString();
36776
36694
  const fromAddress = sourceUserAddress ??
36777
36695
  chainTypeToZeroAddressMap[fromChainType ?? squidTypes.ChainType.EVM];
36778
36696
  const params = {
36779
36697
  fromChain,
36780
36698
  fromToken: fromTokenAddress,
36781
36699
  fromAddress,
36700
+ fromAmount,
36782
36701
  toChain,
36783
36702
  toToken: toTokenAddress,
36784
36703
  toAddress: destinationAddress ?? "",
@@ -36795,19 +36714,12 @@ const useGetRoute = () => {
36795
36714
  cosmosFallbackAddresses[0].address) {
36796
36715
  params.fallbackAddresses = cosmosFallbackAddresses;
36797
36716
  }
36798
- if (!isZeroAmount(fromAmount)) {
36799
- params.fromAmount = fromAmount;
36800
- }
36801
- else if (!isZeroAmount(toAmount)) {
36802
- params.toAmount = toAmount;
36803
- }
36804
36717
  const { route } = await squid.getRoute({
36805
36718
  ...params,
36806
- ...(prefer ? { prefer } : {}),
36807
36719
  });
36808
36720
  // Cache the route data
36809
36721
  // Useful when the getRoute mutation is called from another hook
36810
- queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, toPrice, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, swapRoute?.fallbackAddress, quoteOnly, fromChainType, config.preHook, config.postHook, overrideGasRefundAddress, config.prefer), route);
36722
+ queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, swapRoute?.fallbackAddress, quoteOnly, fromChainType, config.preHook, config.postHook, overrideGasRefundAddress), route);
36811
36723
  return route;
36812
36724
  });
36813
36725
  };
@@ -36821,7 +36733,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
36821
36733
  const depositRefundAddress = useSwapRoutePersistStore((store) => store.swapRoute?.depositRefundAddress);
36822
36734
  const { isAvailableAsPaymentMethod, isEnabled: isDepositAddressEnabled } = useDepositAddress();
36823
36735
  const getRouteMutation = useGetRoute();
36824
- const { fromChain, toChain, fromAmount, toAmount, destinationAddress: { address: destinationAddress } = {}, fromToken, toToken, } = useSwap();
36736
+ const { fromChain, toChain, fromPrice, destinationAddress: { address: destinationAddress } = {}, fromToken, toToken, } = useSwap();
36825
36737
  const { connectedAddress: { address: sourceConnectedAddress }, } = useMultiChainWallet(fromChain);
36826
36738
  // When the payment method is deposit address, users can specify a refund address on the source chain
36827
36739
  // Tokens will be sent to this address in case of swap failure
@@ -36830,13 +36742,12 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
36830
36742
  const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
36831
36743
  ? depositRefundAddress ?? sourceConnectedAddress
36832
36744
  : sourceConnectedAddress;
36833
- const squidRouteQueryKeys = React.useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromAmount, toAmount, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChain?.chainType, config.preHook, config.postHook, config.overrideGasRefundAddress, config.prefer), [
36745
+ const squidRouteQueryKeys = React.useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromPrice, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChain?.chainType, config.preHook, config.postHook, config.overrideGasRefundAddress), [
36834
36746
  fromChain?.chainId,
36835
36747
  toChain?.chainId,
36836
36748
  toToken?.address,
36837
36749
  fromToken?.address,
36838
- fromAmount,
36839
- toAmount,
36750
+ fromPrice,
36840
36751
  config.slippage,
36841
36752
  sourceUserAddress,
36842
36753
  config.degenMode,
@@ -36847,12 +36758,12 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
36847
36758
  config.preHook,
36848
36759
  config.postHook,
36849
36760
  config.overrideGasRefundAddress,
36850
- config.prefer,
36851
36761
  ]);
36852
36762
  const queryEnabled = enabled != undefined
36853
36763
  ? enabled
36854
36764
  : squid !== undefined &&
36855
- (!isZeroAmount(fromAmount) || !isZeroAmount(toAmount)) &&
36765
+ fromPrice !== undefined &&
36766
+ fromPrice !== "0" &&
36856
36767
  toChain?.chainId !== undefined &&
36857
36768
  toToken?.address !== undefined;
36858
36769
  const queryClient = reactQuery.useQueryClient();
@@ -36870,15 +36781,13 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
36870
36781
  toToken,
36871
36782
  sourceUserAddress,
36872
36783
  destinationAddress,
36873
- fromPrice: fromAmount,
36874
- toPrice: toAmount,
36784
+ fromPrice,
36875
36785
  bypassGuardrails: config.degenMode,
36876
36786
  quoteOnly,
36877
36787
  fromChainType: fromChain?.chainType,
36878
36788
  postHook: config.postHook,
36879
36789
  preHook: config.preHook,
36880
36790
  overrideGasRefundAddress: config.overrideGasRefundAddress,
36881
- prefer: config.prefer,
36882
36791
  });
36883
36792
  return route;
36884
36793
  }, {
@@ -37546,7 +37455,6 @@ exports.DEFAULT_ROUTE_REFETCH_INTERVAL = DEFAULT_ROUTE_REFETCH_INTERVAL;
37546
37455
  exports.EnsService = EnsService;
37547
37456
  exports.EvmNetworkNotSupportedErrorCode = EvmNetworkNotSupportedErrorCode;
37548
37457
  exports.FINAL_TRANSACTION_STATUSES = FINAL_TRANSACTION_STATUSES;
37549
- exports.GENERIC_ROUTE_ERROR_MESSAGE = GENERIC_ROUTE_ERROR_MESSAGE;
37550
37458
  exports.HederaExtensionHelper = HederaExtensionHelper;
37551
37459
  exports.Nr = Nr;
37552
37460
  exports.SquidProvider = SquidProvider;
@@ -37630,7 +37538,6 @@ exports.getRouteExpiry = getRouteExpiry;
37630
37538
  exports.getSecretNetworkBalances = getSecretNetworkBalances;
37631
37539
  exports.getSendTxStatusRefetchInterval = getSendTxStatusRefetchInterval;
37632
37540
  exports.getSourceExplorerTxUrl = getSourceExplorerTxUrl;
37633
- exports.getSquidRouteErrorMessage = getSquidRouteErrorMessage;
37634
37541
  exports.getStatusCode = getStatusCode;
37635
37542
  exports.getStellarHorizonApiUrl = getStellarHorizonApiUrl;
37636
37543
  exports.getStellarNetwork = getStellarNetwork;
@@ -37655,6 +37562,7 @@ exports.groupTokensBySymbol = groupTokensBySymbol;
37655
37562
  exports.handleTransactionErrorEvents = handleTransactionErrorEvents;
37656
37563
  exports.initializeSquidWithAssetsColors = initializeSquidWithAssetsColors;
37657
37564
  exports.is404Error = is404Error;
37565
+ exports.isActionCompletedOnSourceTx = isActionCompletedOnSourceTx;
37658
37566
  exports.isChainflipBridgeTransaction = isChainflipBridgeTransaction;
37659
37567
  exports.isCoralBridgeAction = isCoralBridgeAction;
37660
37568
  exports.isCosmosAddressValid = isCosmosAddressValid;
@@ -37682,7 +37590,6 @@ exports.isWalletAddressValid = isWalletAddressValid;
37682
37590
  exports.isXamanXAppContext = isXamanXAppContext;
37683
37591
  exports.isXionSmartContractAddress = isXionSmartContractAddress;
37684
37592
  exports.isXrplAddressValid = isXrplAddressValid;
37685
- exports.isZeroAmount = isZeroAmount;
37686
37593
  exports.mergeWallets = mergeWallets;
37687
37594
  exports.nativeBitcoinTokenAddress = nativeBitcoinTokenAddress;
37688
37595
  exports.nativeCosmosTokenAddress = nativeCosmosTokenAddress;
@@ -37805,4 +37712,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
37805
37712
  exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
37806
37713
  exports.walletIconBaseUrl = walletIconBaseUrl;
37807
37714
  exports.walletSupportsChainType = walletSupportsChainType;
37808
- //# sourceMappingURL=index-cWo0aVvt.js.map
37715
+ //# sourceMappingURL=index-IxCpRlyV.js.map