@0xsquid/react-hooks 8.7.2-beta-fav-chains.0 → 8.7.2-beta-interactive-to-amount.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/queries/queries-keys.d.ts +1 -1
- package/dist/core/types/config.d.ts +2 -1
- package/dist/core/types/event.d.ts +1 -2
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/store/useSquidStore.d.ts +2 -1
- package/dist/hooks/swap/useSwap.d.ts +4 -2
- package/dist/hooks/transaction/useGetRoute.d.ts +9 -8
- package/dist/{index-DYs5b-an.js → index-BhIaRT6b.js} +97 -60
- package/dist/index-BhIaRT6b.js.map +1 -0
- package/dist/{index-0fyTkU8o.js → index-cWo0aVvt.js} +99 -60
- package/dist/index-cWo0aVvt.js.map +1 -0
- package/dist/{index.es-Bxk-BRsk.js → index.es-DDv7Krv1.js} +2 -2
- package/dist/{index.es-Bxk-BRsk.js.map → index.es-DDv7Krv1.js.map} +1 -1
- package/dist/{index.es-X0Xkh3ET.js → index.es-DjscAACC.js} +2 -2
- package/dist/{index.es-X0Xkh3ET.js.map → index.es-DjscAACC.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/{secretService-BExN6uOo.js → secretService-XZVHxElk.js} +2 -2
- package/dist/{secretService-BExN6uOo.js.map → secretService-XZVHxElk.js.map} +1 -1
- package/dist/{secretService-CJJobQlZ.js → secretService-cYEbiXXP.js} +2 -2
- package/dist/{secretService-CJJobQlZ.js.map → secretService-cYEbiXXP.js.map} +1 -1
- package/dist/services/internal/errorService.d.ts +9 -0
- package/dist/services/internal/eventService.d.ts +1 -2
- package/dist/services/internal/numberService.d.ts +1 -0
- package/dist/{stellarService.client-eIqTLitu.js → stellarService.client-B5B1XaV_.js} +2 -2
- package/dist/{stellarService.client-eIqTLitu.js.map → stellarService.client-B5B1XaV_.js.map} +1 -1
- package/dist/{stellarService.client-yODv6HFL.js → stellarService.client-CBqIkpcb.js} +2 -2
- package/dist/{stellarService.client-yODv6HFL.js.map → stellarService.client-CBqIkpcb.js.map} +1 -1
- package/package.json +3 -3
- package/dist/core/types/route.d.ts +0 -4
- package/dist/hooks/store/useFavoriteChainsStore.d.ts +0 -20
- package/dist/index-0fyTkU8o.js.map +0 -1
- package/dist/index-DYs5b-an.js.map +0 -1
|
@@ -3971,6 +3971,9 @@ 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
|
+
}
|
|
3974
3977
|
|
|
3975
3978
|
/**
|
|
3976
3979
|
* Creates a hash string from quote request parameters to track changes
|
|
@@ -4422,6 +4425,35 @@ const isSwapRouteError = (error) => {
|
|
|
4422
4425
|
const isStatusError = (error) => {
|
|
4423
4426
|
return error && typeof error.errorType === "string";
|
|
4424
4427
|
};
|
|
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
|
+
};
|
|
4425
4457
|
|
|
4426
4458
|
// Xion has a way to create smart contract accounts (with social logins) these are 63 characters long
|
|
4427
4459
|
// 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
|
|
@@ -22413,14 +22445,15 @@ const keys = () => ({
|
|
|
22413
22445
|
// ============
|
|
22414
22446
|
// Transactions
|
|
22415
22447
|
// ============
|
|
22416
|
-
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress,
|
|
22448
|
+
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, fromAmount, toAmount, slippage, sourceUserAddress, degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChainType, preHook, postHook, overrideGasRefundAddress, prefer) => [
|
|
22417
22449
|
...keys().transactions(),
|
|
22418
22450
|
exports.QueryKeys.Transaction,
|
|
22419
22451
|
fromChainId,
|
|
22420
22452
|
toChainId,
|
|
22421
22453
|
toTokenAddress,
|
|
22422
22454
|
fromTokenAddress,
|
|
22423
|
-
|
|
22455
|
+
fromAmount,
|
|
22456
|
+
toAmount,
|
|
22424
22457
|
slippage,
|
|
22425
22458
|
sourceUserAddress,
|
|
22426
22459
|
degenMode,
|
|
@@ -22431,6 +22464,7 @@ const keys = () => ({
|
|
|
22431
22464
|
preHook,
|
|
22432
22465
|
postHook,
|
|
22433
22466
|
overrideGasRefundAddress,
|
|
22467
|
+
prefer,
|
|
22434
22468
|
],
|
|
22435
22469
|
swapTransactionStatus: (transactionId) => [
|
|
22436
22470
|
...keys().transactions(),
|
|
@@ -22622,6 +22656,7 @@ const getConfigWithDefaults = (config) => {
|
|
|
22622
22656
|
preHook: get$2(config, "preHook", defaultConfigValues.preHook),
|
|
22623
22657
|
postHook: get$2(config, "postHook", defaultConfigValues.postHook),
|
|
22624
22658
|
overrideGasRefundAddress: get$2(config, "overrideGasRefundAddress", defaultConfigValues.overrideGasRefundAddress),
|
|
22659
|
+
prefer: get$2(config, "prefer", defaultConfigValues.prefer),
|
|
22625
22660
|
};
|
|
22626
22661
|
};
|
|
22627
22662
|
const randomIntFromInterval = (min, max) => {
|
|
@@ -23315,7 +23350,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23315
23350
|
};
|
|
23316
23351
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23317
23352
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23318
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23353
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-XZVHxElk.js'); });
|
|
23319
23354
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23320
23355
|
};
|
|
23321
23356
|
function getTokenAssetsKey(token) {
|
|
@@ -25172,10 +25207,7 @@ const useConfigStore = zustand.create(() => ({
|
|
|
25172
25207
|
isInitialized: false,
|
|
25173
25208
|
}));
|
|
25174
25209
|
const useTransactionStore = zustand.create((set, get) => ({
|
|
25175
|
-
fromPrice: undefined,
|
|
25176
|
-
txLocalId: undefined,
|
|
25177
25210
|
transactions: {},
|
|
25178
|
-
currentTransaction: undefined,
|
|
25179
25211
|
setTransactionState(txId, tx) {
|
|
25180
25212
|
if (!txId)
|
|
25181
25213
|
return;
|
|
@@ -26713,7 +26745,7 @@ function useStellarWallets() {
|
|
|
26713
26745
|
try {
|
|
26714
26746
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26715
26747
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
26716
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
26748
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-CBqIkpcb.js'); });
|
|
26717
26749
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26718
26750
|
const promises = modules.map(async (module) => {
|
|
26719
26751
|
const isAvailable = await module.isAvailable();
|
|
@@ -27612,7 +27644,8 @@ const useMultiChainWallet = (chain) => {
|
|
|
27612
27644
|
|
|
27613
27645
|
const useSwap = () => {
|
|
27614
27646
|
const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, } = useConfigStore((state) => state.config);
|
|
27615
|
-
const
|
|
27647
|
+
const fromAmount = useTransactionStore((state) => state.fromAmount);
|
|
27648
|
+
const toAmount = useTransactionStore((state) => state.toAmount);
|
|
27616
27649
|
const { swapRoute } = useSwapRoutePersistStore();
|
|
27617
27650
|
const { tokens } = useSquidTokens();
|
|
27618
27651
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -27664,8 +27697,17 @@ const useSwap = () => {
|
|
|
27664
27697
|
}),
|
|
27665
27698
|
};
|
|
27666
27699
|
}, [destAddressData, destAddressEnsData.data, toChain?.chainType]);
|
|
27667
|
-
const
|
|
27668
|
-
useTransactionStore.setState({
|
|
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
|
+
});
|
|
27669
27711
|
}, []);
|
|
27670
27712
|
/**
|
|
27671
27713
|
* When user changes something from the SwapView
|
|
@@ -27825,8 +27867,10 @@ const useSwap = () => {
|
|
|
27825
27867
|
tokenItems,
|
|
27826
27868
|
onSwapChange,
|
|
27827
27869
|
invertSwaps,
|
|
27828
|
-
|
|
27829
|
-
|
|
27870
|
+
fromAmount,
|
|
27871
|
+
toAmount,
|
|
27872
|
+
fromAmountChanged,
|
|
27873
|
+
toAmountChanged,
|
|
27830
27874
|
toToken,
|
|
27831
27875
|
fromToken,
|
|
27832
27876
|
fromChain,
|
|
@@ -30033,7 +30077,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30033
30077
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30034
30078
|
if (!optionalChains.length)
|
|
30035
30079
|
return;
|
|
30036
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
30080
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-DjscAACC.js'); });
|
|
30037
30081
|
const rawProvider = await EthereumProvider.init({
|
|
30038
30082
|
...restParameters,
|
|
30039
30083
|
disableProviderPing: true,
|
|
@@ -30664,32 +30708,6 @@ const useAddressBookStore = zustand.create(middleware.persist((set) => ({
|
|
|
30664
30708
|
name: "squid.addressbook.store",
|
|
30665
30709
|
}));
|
|
30666
30710
|
|
|
30667
|
-
const useFavoriteChainsStore = zustand.create(middleware.persist((set, get) => ({
|
|
30668
|
-
favoriteChains: [],
|
|
30669
|
-
addFavoriteChain(chain) {
|
|
30670
|
-
set((state) => ({
|
|
30671
|
-
favoriteChains: [...state.favoriteChains, chain],
|
|
30672
|
-
}));
|
|
30673
|
-
},
|
|
30674
|
-
removeFavoriteChain(chain) {
|
|
30675
|
-
set((state) => ({
|
|
30676
|
-
favoriteChains: state.favoriteChains.filter((c) => c.chainId !== chain.chainId),
|
|
30677
|
-
}));
|
|
30678
|
-
},
|
|
30679
|
-
toggleFavoriteChain(chain) {
|
|
30680
|
-
const isFavorite = get().favoriteChains.some((c) => c.chainId === chain.chainId);
|
|
30681
|
-
if (isFavorite) {
|
|
30682
|
-
get().removeFavoriteChain(chain);
|
|
30683
|
-
}
|
|
30684
|
-
else {
|
|
30685
|
-
get().addFavoriteChain(chain);
|
|
30686
|
-
}
|
|
30687
|
-
},
|
|
30688
|
-
}), {
|
|
30689
|
-
name: "squid.favorite.chains.store",
|
|
30690
|
-
version: 1,
|
|
30691
|
-
}));
|
|
30692
|
-
|
|
30693
30711
|
const useFavoriteTokensStore = zustand.create(middleware.persist((set, get) => ({
|
|
30694
30712
|
favoriteTokens: [],
|
|
30695
30713
|
addFavoriteToken(token) {
|
|
@@ -32465,7 +32483,7 @@ const useHistory = (txType) => {
|
|
|
32465
32483
|
fromChain: tx.params.fromChain,
|
|
32466
32484
|
fromToken: tx.params.fromToken,
|
|
32467
32485
|
fromAddress: tx.params.fromAddress,
|
|
32468
|
-
fromAmount: tx.params.fromAmount,
|
|
32486
|
+
fromAmount: tx.params.fromAmount || tx.estimate.fromAmount,
|
|
32469
32487
|
toChain: tx.params.toChain,
|
|
32470
32488
|
toToken: tx.params.toToken,
|
|
32471
32489
|
toAddress: tx.params.toAddress,
|
|
@@ -32706,7 +32724,7 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32706
32724
|
const publicClient = wagmi.usePublicClient();
|
|
32707
32725
|
const queryClient = reactQuery.useQueryClient();
|
|
32708
32726
|
const squid = useSquidStore((state) => state.squid);
|
|
32709
|
-
const { fromChain, fromToken,
|
|
32727
|
+
const { fromChain, fromToken, fromAmount, toAmount, isSameChain } = useSwap();
|
|
32710
32728
|
const { evmSigner } = useSigner({ chain: fromChain });
|
|
32711
32729
|
const { connector: activeConnector } = wagmi.useAccount();
|
|
32712
32730
|
const { getChainType } = useSquidChains();
|
|
@@ -32879,9 +32897,9 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32879
32897
|
// This is to ensure we're using the latest expiry timestamp
|
|
32880
32898
|
if (squidRoute) {
|
|
32881
32899
|
queryClient.refetchQueries({
|
|
32882
|
-
queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken,
|
|
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,
|
|
32883
32901
|
// TODO: update types
|
|
32884
|
-
squidRoute.params?.overrideGasRefundAddress),
|
|
32902
|
+
squidRoute.params?.overrideGasRefundAddress, squidRoute.params?.prefer),
|
|
32885
32903
|
});
|
|
32886
32904
|
}
|
|
32887
32905
|
},
|
|
@@ -32898,7 +32916,7 @@ const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/ass
|
|
|
32898
32916
|
const useEstimate = (squidRoute) => {
|
|
32899
32917
|
const collectFees = useConfigStore((state) => state.config.collectFees);
|
|
32900
32918
|
const { tokens } = useSquidTokens();
|
|
32901
|
-
const { fromChain, toChain,
|
|
32919
|
+
const { fromChain, toChain, fromAmount } = useSwap();
|
|
32902
32920
|
const fromToken = React.useMemo(() => findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken), [tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken]);
|
|
32903
32921
|
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
32904
32922
|
fromChain,
|
|
@@ -32994,9 +33012,9 @@ const useEstimate = (squidRoute) => {
|
|
|
32994
33012
|
const slippageFormatted = Number(squidRoute?.estimate?.aggregateSlippage ?? 0).toFixed(2) + "%";
|
|
32995
33013
|
const fromBalanceEnoughToSwap = React.useMemo(() => {
|
|
32996
33014
|
const fromBalanceNum = Number(fromBalanceFormatted ?? 0);
|
|
32997
|
-
const
|
|
32998
|
-
return fromBalanceNum >=
|
|
32999
|
-
}, [fromBalanceFormatted,
|
|
33015
|
+
const fromAmountNum = Number(fromAmount ?? 0);
|
|
33016
|
+
return fromBalanceNum >= fromAmountNum;
|
|
33017
|
+
}, [fromBalanceFormatted, fromAmount]);
|
|
33000
33018
|
return {
|
|
33001
33019
|
...estimateResults,
|
|
33002
33020
|
fromBalanceFormatted,
|
|
@@ -36215,8 +36233,12 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36215
36233
|
if (!depositData?.depositAddress) {
|
|
36216
36234
|
throw new Error("Deposit address is required");
|
|
36217
36235
|
}
|
|
36236
|
+
const fromAmount = route.params.fromAmount || route.estimate.fromAmount;
|
|
36237
|
+
if (isZeroAmount(fromAmount)) {
|
|
36238
|
+
throw new Error("fromAmount is required for Solana transfer");
|
|
36239
|
+
}
|
|
36218
36240
|
const signature = await executeSolanaTransfer({
|
|
36219
|
-
amount: BigInt(
|
|
36241
|
+
amount: BigInt(fromAmount),
|
|
36220
36242
|
target: depositData.depositAddress,
|
|
36221
36243
|
signer: solanaSigner,
|
|
36222
36244
|
connection: solanaConnection,
|
|
@@ -36726,8 +36748,12 @@ const useGetRoute = () => {
|
|
|
36726
36748
|
* These data will be used to trigger the transaction
|
|
36727
36749
|
* @returns {Route} Route data
|
|
36728
36750
|
*/
|
|
36729
|
-
return reactQuery.useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice, bypassGuardrails, quoteOnly, fromChainType, postHook, preHook, overrideGasRefundAddress, }) => {
|
|
36730
|
-
if (!fromChain ||
|
|
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)) {
|
|
36731
36757
|
return undefined;
|
|
36732
36758
|
}
|
|
36733
36759
|
// Dispatch requestQuote event
|
|
@@ -36737,6 +36763,7 @@ const useGetRoute = () => {
|
|
|
36737
36763
|
fromToken: fromToken.address,
|
|
36738
36764
|
toToken: toToken.address,
|
|
36739
36765
|
fromAmount: fromPrice,
|
|
36766
|
+
toAmount: toPrice,
|
|
36740
36767
|
fromAddress: sourceUserAddress,
|
|
36741
36768
|
toAddress: destinationAddress,
|
|
36742
36769
|
});
|
|
@@ -36745,13 +36772,13 @@ const useGetRoute = () => {
|
|
|
36745
36772
|
const fromTokenAddress = fromToken.address;
|
|
36746
36773
|
const toTokenAddress = toToken.address;
|
|
36747
36774
|
const fromAmount = parseToBigInt(fromPrice?.toString() ?? "0", fromToken?.decimals).toString();
|
|
36775
|
+
const toAmount = parseToBigInt(toPrice?.toString() ?? "0", toToken?.decimals).toString();
|
|
36748
36776
|
const fromAddress = sourceUserAddress ??
|
|
36749
36777
|
chainTypeToZeroAddressMap[fromChainType ?? squidTypes.ChainType.EVM];
|
|
36750
36778
|
const params = {
|
|
36751
36779
|
fromChain,
|
|
36752
36780
|
fromToken: fromTokenAddress,
|
|
36753
36781
|
fromAddress,
|
|
36754
|
-
fromAmount,
|
|
36755
36782
|
toChain,
|
|
36756
36783
|
toToken: toTokenAddress,
|
|
36757
36784
|
toAddress: destinationAddress ?? "",
|
|
@@ -36768,12 +36795,19 @@ const useGetRoute = () => {
|
|
|
36768
36795
|
cosmosFallbackAddresses[0].address) {
|
|
36769
36796
|
params.fallbackAddresses = cosmosFallbackAddresses;
|
|
36770
36797
|
}
|
|
36798
|
+
if (!isZeroAmount(fromAmount)) {
|
|
36799
|
+
params.fromAmount = fromAmount;
|
|
36800
|
+
}
|
|
36801
|
+
else if (!isZeroAmount(toAmount)) {
|
|
36802
|
+
params.toAmount = toAmount;
|
|
36803
|
+
}
|
|
36771
36804
|
const { route } = await squid.getRoute({
|
|
36772
36805
|
...params,
|
|
36806
|
+
...(prefer ? { prefer } : {}),
|
|
36773
36807
|
});
|
|
36774
36808
|
// Cache the route data
|
|
36775
36809
|
// Useful when the getRoute mutation is called from another hook
|
|
36776
|
-
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);
|
|
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);
|
|
36777
36811
|
return route;
|
|
36778
36812
|
});
|
|
36779
36813
|
};
|
|
@@ -36787,7 +36821,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36787
36821
|
const depositRefundAddress = useSwapRoutePersistStore((store) => store.swapRoute?.depositRefundAddress);
|
|
36788
36822
|
const { isAvailableAsPaymentMethod, isEnabled: isDepositAddressEnabled } = useDepositAddress();
|
|
36789
36823
|
const getRouteMutation = useGetRoute();
|
|
36790
|
-
const { fromChain, toChain,
|
|
36824
|
+
const { fromChain, toChain, fromAmount, toAmount, destinationAddress: { address: destinationAddress } = {}, fromToken, toToken, } = useSwap();
|
|
36791
36825
|
const { connectedAddress: { address: sourceConnectedAddress }, } = useMultiChainWallet(fromChain);
|
|
36792
36826
|
// When the payment method is deposit address, users can specify a refund address on the source chain
|
|
36793
36827
|
// Tokens will be sent to this address in case of swap failure
|
|
@@ -36796,12 +36830,13 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36796
36830
|
const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
|
|
36797
36831
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
36798
36832
|
: sourceConnectedAddress;
|
|
36799
|
-
const squidRouteQueryKeys = React.useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address,
|
|
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), [
|
|
36800
36834
|
fromChain?.chainId,
|
|
36801
36835
|
toChain?.chainId,
|
|
36802
36836
|
toToken?.address,
|
|
36803
36837
|
fromToken?.address,
|
|
36804
|
-
|
|
36838
|
+
fromAmount,
|
|
36839
|
+
toAmount,
|
|
36805
36840
|
config.slippage,
|
|
36806
36841
|
sourceUserAddress,
|
|
36807
36842
|
config.degenMode,
|
|
@@ -36812,12 +36847,12 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36812
36847
|
config.preHook,
|
|
36813
36848
|
config.postHook,
|
|
36814
36849
|
config.overrideGasRefundAddress,
|
|
36850
|
+
config.prefer,
|
|
36815
36851
|
]);
|
|
36816
36852
|
const queryEnabled = enabled != undefined
|
|
36817
36853
|
? enabled
|
|
36818
36854
|
: squid !== undefined &&
|
|
36819
|
-
|
|
36820
|
-
fromPrice !== "0" &&
|
|
36855
|
+
(!isZeroAmount(fromAmount) || !isZeroAmount(toAmount)) &&
|
|
36821
36856
|
toChain?.chainId !== undefined &&
|
|
36822
36857
|
toToken?.address !== undefined;
|
|
36823
36858
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -36835,13 +36870,15 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36835
36870
|
toToken,
|
|
36836
36871
|
sourceUserAddress,
|
|
36837
36872
|
destinationAddress,
|
|
36838
|
-
fromPrice,
|
|
36873
|
+
fromPrice: fromAmount,
|
|
36874
|
+
toPrice: toAmount,
|
|
36839
36875
|
bypassGuardrails: config.degenMode,
|
|
36840
36876
|
quoteOnly,
|
|
36841
36877
|
fromChainType: fromChain?.chainType,
|
|
36842
36878
|
postHook: config.postHook,
|
|
36843
36879
|
preHook: config.preHook,
|
|
36844
36880
|
overrideGasRefundAddress: config.overrideGasRefundAddress,
|
|
36881
|
+
prefer: config.prefer,
|
|
36845
36882
|
});
|
|
36846
36883
|
return route;
|
|
36847
36884
|
}, {
|
|
@@ -37509,6 +37546,7 @@ exports.DEFAULT_ROUTE_REFETCH_INTERVAL = DEFAULT_ROUTE_REFETCH_INTERVAL;
|
|
|
37509
37546
|
exports.EnsService = EnsService;
|
|
37510
37547
|
exports.EvmNetworkNotSupportedErrorCode = EvmNetworkNotSupportedErrorCode;
|
|
37511
37548
|
exports.FINAL_TRANSACTION_STATUSES = FINAL_TRANSACTION_STATUSES;
|
|
37549
|
+
exports.GENERIC_ROUTE_ERROR_MESSAGE = GENERIC_ROUTE_ERROR_MESSAGE;
|
|
37512
37550
|
exports.HederaExtensionHelper = HederaExtensionHelper;
|
|
37513
37551
|
exports.Nr = Nr;
|
|
37514
37552
|
exports.SquidProvider = SquidProvider;
|
|
@@ -37592,6 +37630,7 @@ exports.getRouteExpiry = getRouteExpiry;
|
|
|
37592
37630
|
exports.getSecretNetworkBalances = getSecretNetworkBalances;
|
|
37593
37631
|
exports.getSendTxStatusRefetchInterval = getSendTxStatusRefetchInterval;
|
|
37594
37632
|
exports.getSourceExplorerTxUrl = getSourceExplorerTxUrl;
|
|
37633
|
+
exports.getSquidRouteErrorMessage = getSquidRouteErrorMessage;
|
|
37595
37634
|
exports.getStatusCode = getStatusCode;
|
|
37596
37635
|
exports.getStellarHorizonApiUrl = getStellarHorizonApiUrl;
|
|
37597
37636
|
exports.getStellarNetwork = getStellarNetwork;
|
|
@@ -37643,6 +37682,7 @@ exports.isWalletAddressValid = isWalletAddressValid;
|
|
|
37643
37682
|
exports.isXamanXAppContext = isXamanXAppContext;
|
|
37644
37683
|
exports.isXionSmartContractAddress = isXionSmartContractAddress;
|
|
37645
37684
|
exports.isXrplAddressValid = isXrplAddressValid;
|
|
37685
|
+
exports.isZeroAmount = isZeroAmount;
|
|
37646
37686
|
exports.mergeWallets = mergeWallets;
|
|
37647
37687
|
exports.nativeBitcoinTokenAddress = nativeBitcoinTokenAddress;
|
|
37648
37688
|
exports.nativeCosmosTokenAddress = nativeCosmosTokenAddress;
|
|
@@ -37708,7 +37748,6 @@ exports.useEvmBalance = useEvmBalance;
|
|
|
37708
37748
|
exports.useEvmNativeBalance = useEvmNativeBalance;
|
|
37709
37749
|
exports.useExecuteFiatQuote = useExecuteFiatQuote;
|
|
37710
37750
|
exports.useExecuteTransaction = useExecuteTransaction;
|
|
37711
|
-
exports.useFavoriteChainsStore = useFavoriteChainsStore;
|
|
37712
37751
|
exports.useFavoriteTokensStore = useFavoriteTokensStore;
|
|
37713
37752
|
exports.useFiatOnRampTxStatus = useFiatOnRampTxStatus;
|
|
37714
37753
|
exports.useFiatTransactions = useFiatTransactions;
|
|
@@ -37766,4 +37805,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
37766
37805
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37767
37806
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37768
37807
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37769
|
-
//# sourceMappingURL=index-
|
|
37808
|
+
//# sourceMappingURL=index-cWo0aVvt.js.map
|