@0xsquid/react-hooks 8.0.0-beta.8 → 8.0.1-tanstack-v5-beta.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.
- package/dist/hooks/onramp/useFiatToCrypto.d.ts +6 -28
- package/dist/hooks/squid/useSquid.d.ts +2 -2
- package/dist/hooks/swap/useDepositAddress.d.ts +2 -2
- package/dist/hooks/tokens/useAllConnectedWalletBalances.d.ts +5 -11
- package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.d.ts +1 -1
- package/dist/hooks/tokens/useBalance.d.ts +1 -1
- package/dist/hooks/tokens/useMultipleTokenPrices.d.ts +2 -2
- package/dist/hooks/tokens/useNativeBalance.d.ts +2 -2
- package/dist/hooks/tokens/useTokenHistoricalData.d.ts +4 -4
- package/dist/hooks/transaction/send/useEstimateSendTransactionGas.d.ts +1 -1
- package/dist/hooks/transaction/send/useSendTransactionGas.d.ts +1 -1
- package/dist/hooks/transaction/useAllTransactionsStatus.d.ts +3 -29
- package/dist/hooks/transaction/useApproval.d.ts +2 -2
- package/dist/hooks/transaction/useExecuteTransaction.d.ts +2 -2
- package/dist/hooks/transaction/useGetRoute.d.ts +7 -7
- package/dist/hooks/transaction/useSwapTransactionStatus.d.ts +1 -1
- package/dist/hooks/wallet/useAddToken.d.ts +1 -1
- package/dist/hooks/wallet/useEns.d.ts +2 -2
- package/dist/hooks/wallet/useMultiChainWallet.d.ts +1 -1
- package/dist/hooks/wallet/useWallet.d.ts +1 -1
- package/dist/hooks/xrpl/useXrplTrustLine.d.ts +5 -5
- package/dist/{index-_Qp4Ou3J.js → index-BA79s7uI.js} +948 -951
- package/dist/{index-_Qp4Ou3J.js.map → index-BA79s7uI.js.map} +1 -1
- package/dist/{index-BtOPNnH5.js → index-CS74WzWX.js} +946 -952
- package/dist/{index-BtOPNnH5.js.map → index-CS74WzWX.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/{secretService-CR2RaJtB.js → secretService-D3MB_TMv.js} +2 -2
- package/dist/{secretService-CR2RaJtB.js.map → secretService-D3MB_TMv.js.map} +1 -1
- package/dist/{secretService-DdVLwd-q.js → secretService-U8WiVPay.js} +2 -2
- package/dist/{secretService-DdVLwd-q.js.map → secretService-U8WiVPay.js.map} +1 -1
- package/dist/{stellarService.client-7rBIc_IW.js → stellarService.client-BUdrOP04.js} +2 -2
- package/dist/{stellarService.client-7rBIc_IW.js.map → stellarService.client-BUdrOP04.js.map} +1 -1
- package/dist/{stellarService.client-BvSwmxzo.js → stellarService.client-Dp4tvmUo.js} +2 -2
- package/dist/{stellarService.client-BvSwmxzo.js.map → stellarService.client-Dp4tvmUo.js.map} +1 -1
- package/package.json +12 -12
|
@@ -26816,7 +26816,9 @@ const fetchHighestBalanceToken = (fetchCachedBalance, chainId) => {
|
|
|
26816
26816
|
if (fetchCachedBalance) {
|
|
26817
26817
|
const queryCache = fetchCachedBalance?.queryClient?.getQueryCache();
|
|
26818
26818
|
// get cached balance from key
|
|
26819
|
-
const cache = queryCache?.find(
|
|
26819
|
+
const cache = queryCache?.find({
|
|
26820
|
+
queryKey: keys().allTokensBalance(fetchCachedBalance?.address, !isNaN(Number(chainId)) ? squidTypes.ChainType.EVM : squidTypes.ChainType.COSMOS),
|
|
26821
|
+
});
|
|
26820
26822
|
// Parse result to TokenWithBalance[]
|
|
26821
26823
|
const cacheResult = cache?.state.data ?? [];
|
|
26822
26824
|
if (cacheResult.length > 0) {
|
|
@@ -27472,7 +27474,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
27472
27474
|
};
|
|
27473
27475
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
27474
27476
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
27475
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
27477
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-U8WiVPay.js'); });
|
|
27476
27478
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
27477
27479
|
};
|
|
27478
27480
|
function getTokenAssetsKey(token) {
|
|
@@ -29231,13 +29233,16 @@ const useSquid = () => {
|
|
|
29231
29233
|
* Fetch squid info
|
|
29232
29234
|
* Will refetch every minute
|
|
29233
29235
|
*/
|
|
29234
|
-
const squidInfoQuery = reactQuery.useQuery(
|
|
29235
|
-
|
|
29236
|
-
|
|
29237
|
-
|
|
29238
|
-
|
|
29236
|
+
const squidInfoQuery = reactQuery.useQuery({
|
|
29237
|
+
queryKey: keys().squidInfo(),
|
|
29238
|
+
queryFn: async () => {
|
|
29239
|
+
if (squid) {
|
|
29240
|
+
await squid?.init();
|
|
29241
|
+
initializeSquidWithAssetsColors(squid, assetsColors);
|
|
29242
|
+
return squid;
|
|
29243
|
+
}
|
|
29244
|
+
return null;
|
|
29239
29245
|
}
|
|
29240
|
-
return null;
|
|
29241
29246
|
});
|
|
29242
29247
|
const tokens = React.useMemo(() => {
|
|
29243
29248
|
if ((squidInfoQuery?.data?.tokens ?? []).length > 0) {
|
|
@@ -29353,47 +29358,11 @@ const FINAL_TRANSACTION_STATUSES = [
|
|
|
29353
29358
|
"completed",
|
|
29354
29359
|
"failed",
|
|
29355
29360
|
];
|
|
29356
|
-
/**
|
|
29357
|
-
* Configuration for transaction status tracking
|
|
29358
|
-
*/
|
|
29359
|
-
const createTransactionStatusConfig = ({ transactionId, walletAddress, providerId, replaceTransactionStatus, }) => {
|
|
29360
|
-
return {
|
|
29361
|
-
queryKey: keys().fiatToCryptoStatus(transactionId),
|
|
29362
|
-
queryFn: () => new OnrampService().getTransactionStatus(transactionId, walletAddress, providerId),
|
|
29363
|
-
enabled: !!transactionId && !!walletAddress && !!providerId,
|
|
29364
|
-
retry: TX_STATUS_CONSTANTS.RETRY_COUNT,
|
|
29365
|
-
retryDelay: TX_STATUS_CONSTANTS.RETRY_DELAY,
|
|
29366
|
-
refetchInterval: (data) => {
|
|
29367
|
-
if (data?.status && FINAL_TRANSACTION_STATUSES.includes(data.status)) {
|
|
29368
|
-
return false;
|
|
29369
|
-
}
|
|
29370
|
-
return TX_STATUS_CONSTANTS.REFETCH_INTERVAL;
|
|
29371
|
-
},
|
|
29372
|
-
onSuccess: (data) => {
|
|
29373
|
-
if (data) {
|
|
29374
|
-
replaceTransactionStatus({
|
|
29375
|
-
txType: exports.HistoryTxType.BUY,
|
|
29376
|
-
orderId: transactionId,
|
|
29377
|
-
status: data.status,
|
|
29378
|
-
transactionHash: data.transactionHash,
|
|
29379
|
-
});
|
|
29380
|
-
}
|
|
29381
|
-
},
|
|
29382
|
-
onError: () => {
|
|
29383
|
-
replaceTransactionStatus({
|
|
29384
|
-
txType: exports.HistoryTxType.BUY,
|
|
29385
|
-
orderId: transactionId,
|
|
29386
|
-
status: "failed",
|
|
29387
|
-
transactionHash: undefined,
|
|
29388
|
-
});
|
|
29389
|
-
},
|
|
29390
|
-
};
|
|
29391
|
-
};
|
|
29392
29361
|
/**
|
|
29393
29362
|
* Fetches quotes for fiat to crypto conversion with provider details.
|
|
29394
29363
|
* Returns available rates, fees, and supported payment methods for the conversion.
|
|
29395
29364
|
*/
|
|
29396
|
-
const useGetFiatQuote = ({ fiatCurrency, cryptoCurrencyID, amount, region, paymentMethod, enabled = true,
|
|
29365
|
+
const useGetFiatQuote = ({ fiatCurrency, cryptoCurrencyID, amount, region, paymentMethod, enabled = true, }) => {
|
|
29397
29366
|
const service = React.useMemo(() => new OnrampService(), []);
|
|
29398
29367
|
const { data: config } = useGetOnRampConfig();
|
|
29399
29368
|
return reactQuery.useQuery({
|
|
@@ -29429,7 +29398,6 @@ const useGetFiatQuote = ({ fiatCurrency, cryptoCurrencyID, amount, region, payme
|
|
|
29429
29398
|
return quoteResponse;
|
|
29430
29399
|
},
|
|
29431
29400
|
enabled: enabled && !!fiatCurrency && !!cryptoCurrencyID && amount > 0,
|
|
29432
|
-
onSuccess,
|
|
29433
29401
|
});
|
|
29434
29402
|
};
|
|
29435
29403
|
/**
|
|
@@ -29446,7 +29414,7 @@ const useGetOnRampConfig = () => {
|
|
|
29446
29414
|
chains,
|
|
29447
29415
|
tokens,
|
|
29448
29416
|
}),
|
|
29449
|
-
|
|
29417
|
+
gcTime: 1000 * 60 * 60,
|
|
29450
29418
|
staleTime: 1000 * 60 * 30, // 30 minutes
|
|
29451
29419
|
});
|
|
29452
29420
|
};
|
|
@@ -29504,49 +29472,11 @@ const useExecuteFiatQuote = () => {
|
|
|
29504
29472
|
},
|
|
29505
29473
|
});
|
|
29506
29474
|
};
|
|
29507
|
-
/**
|
|
29508
|
-
* Tracks the status of a single fiat to crypto transaction.
|
|
29509
|
-
*/
|
|
29510
|
-
const useFiatOnRampTxStatus = (transactionId, walletAddress, providerId) => {
|
|
29511
|
-
const replaceTransactionStatus = useHistoryStore((state) => state.replaceTransactionStatus);
|
|
29512
|
-
return reactQuery.useQuery({
|
|
29513
|
-
...createTransactionStatusConfig({
|
|
29514
|
-
transactionId,
|
|
29515
|
-
walletAddress,
|
|
29516
|
-
providerId,
|
|
29517
|
-
replaceTransactionStatus,
|
|
29518
|
-
}),
|
|
29519
|
-
});
|
|
29520
|
-
};
|
|
29521
|
-
/**
|
|
29522
|
-
* Tracks all pending fiat transactions.
|
|
29523
|
-
*/
|
|
29524
|
-
const useFiatTransactions = () => {
|
|
29525
|
-
const transactions = useHistoryStore((state) => state.transactions.filter((tx) => tx.txType === exports.HistoryTxType.BUY));
|
|
29526
|
-
const replaceTransactionStatus = useHistoryStore((state) => state.replaceTransactionStatus);
|
|
29527
|
-
const pendingTransactions = React.useMemo(() => transactions?.filter((tx) => !FINAL_TRANSACTION_STATUSES.includes(tx.data.status)) ?? [], [transactions]);
|
|
29528
|
-
const queries = reactQuery.useQueries({
|
|
29529
|
-
queries: pendingTransactions.map((tx) => ({
|
|
29530
|
-
...createTransactionStatusConfig({
|
|
29531
|
-
transactionId: tx.data.orderId,
|
|
29532
|
-
walletAddress: tx.data.toAddress,
|
|
29533
|
-
providerId: tx.data.providerId,
|
|
29534
|
-
replaceTransactionStatus,
|
|
29535
|
-
}),
|
|
29536
|
-
})),
|
|
29537
|
-
});
|
|
29538
|
-
return {
|
|
29539
|
-
transactions: transactions.map((tx) => tx.data),
|
|
29540
|
-
isLoading: queries.some((q) => q.isLoading),
|
|
29541
|
-
isError: queries.some((q) => q.isError),
|
|
29542
|
-
};
|
|
29543
|
-
};
|
|
29544
29475
|
/**
|
|
29545
29476
|
* Gets currency details including symbol and limits.
|
|
29546
29477
|
* Example: USD → { symbol: "$", name: "US Dollar", ... }
|
|
29547
29478
|
*/
|
|
29548
29479
|
const useCurrencyDetails = (currencyCode) => {
|
|
29549
|
-
const { data: config } = useGetOnRampConfig();
|
|
29550
29480
|
return React.useMemo(() => {
|
|
29551
29481
|
if (!currencyCode)
|
|
29552
29482
|
return undefined;
|
|
@@ -29559,7 +29489,7 @@ const useCurrencyDetails = (currencyCode) => {
|
|
|
29559
29489
|
};
|
|
29560
29490
|
}
|
|
29561
29491
|
return undefined;
|
|
29562
|
-
}, [currencyCode
|
|
29492
|
+
}, [currencyCode]);
|
|
29563
29493
|
};
|
|
29564
29494
|
/**
|
|
29565
29495
|
* Gets country details with flag URL and localized name.
|
|
@@ -29586,23 +29516,6 @@ const useAvailableQuotes = (quotes) => {
|
|
|
29586
29516
|
return uniqueQuotes;
|
|
29587
29517
|
}, [quotes]);
|
|
29588
29518
|
};
|
|
29589
|
-
/**
|
|
29590
|
-
* Gets the recommended quote based on best rates or provider preferences.
|
|
29591
|
-
* Falls back to first available quote if no specific recommendation.
|
|
29592
|
-
*/
|
|
29593
|
-
const useRecommendedQuote = (quotes, recommendedQuote) => {
|
|
29594
|
-
const availableQuotes = useAvailableQuotes(quotes);
|
|
29595
|
-
return React.useMemo(() => {
|
|
29596
|
-
if (!availableQuotes.length)
|
|
29597
|
-
return undefined;
|
|
29598
|
-
if (!recommendedQuote)
|
|
29599
|
-
return availableQuotes[0];
|
|
29600
|
-
// Try to find the recommended quote among available quotes
|
|
29601
|
-
const recommendedAvailableQuote = availableQuotes.find((quote) => quote.onrampProviderId === recommendedQuote.onrampProviderId);
|
|
29602
|
-
// If recommended quote is not available, return first available quote
|
|
29603
|
-
return recommendedAvailableQuote ?? availableQuotes[0];
|
|
29604
|
-
}, [availableQuotes, recommendedQuote]);
|
|
29605
|
-
};
|
|
29606
29519
|
/**
|
|
29607
29520
|
* Fetches the available payment methods for a given fiat and crypto currency pair.
|
|
29608
29521
|
* The first item in the returned array is the most recommended.
|
|
@@ -29705,7 +29618,7 @@ const middleStepChecker = (statusResponse) => {
|
|
|
29705
29618
|
}
|
|
29706
29619
|
return exports.TransactionStatus.ERROR;
|
|
29707
29620
|
}
|
|
29708
|
-
if (statusResponse?.
|
|
29621
|
+
if (statusResponse?.isLoading) {
|
|
29709
29622
|
return exports.TransactionStatus.INITIAL_LOADING;
|
|
29710
29623
|
}
|
|
29711
29624
|
return exports.TransactionStatus.ONGOING;
|
|
@@ -30150,7 +30063,7 @@ const useClient = () => {
|
|
|
30150
30063
|
queryFn: getUserCountry,
|
|
30151
30064
|
enabled: isClient,
|
|
30152
30065
|
retry: false,
|
|
30153
|
-
|
|
30066
|
+
gcTime: CACHE_TIME,
|
|
30154
30067
|
staleTime: STALE_TIME,
|
|
30155
30068
|
});
|
|
30156
30069
|
const userCountry = countryData?.countryCode || DEFAULT_COUNTRY_CODE;
|
|
@@ -30251,11 +30164,13 @@ function useDebouncedValue(value, delay) {
|
|
|
30251
30164
|
* @returns the ENS data of the given address
|
|
30252
30165
|
*/
|
|
30253
30166
|
function useEnsDataForAddress({ address, options, }) {
|
|
30254
|
-
const ensQuery = reactQuery.useQuery(
|
|
30167
|
+
const ensQuery = reactQuery.useQuery({
|
|
30168
|
+
queryKey: keys().ensData(address?.toLowerCase()),
|
|
30169
|
+
queryFn: () => EnsService.getEnsDataFromAddress(address),
|
|
30255
30170
|
...options,
|
|
30256
30171
|
enabled: Boolean(address?.trim()) &&
|
|
30257
30172
|
(options?.enabled === undefined ? true : options.enabled),
|
|
30258
|
-
|
|
30173
|
+
gcTime: Infinity,
|
|
30259
30174
|
});
|
|
30260
30175
|
return ensQuery;
|
|
30261
30176
|
}
|
|
@@ -30271,14 +30186,16 @@ function useEnsDataForAddress({ address, options, }) {
|
|
|
30271
30186
|
*/
|
|
30272
30187
|
function useEnsSearch({ name, enabled = true, delayMs = 500, }) {
|
|
30273
30188
|
const debouncedName = useDebouncedValue(enabled ? name : undefined, delayMs);
|
|
30274
|
-
const ensSearchQuery = reactQuery.useQuery(
|
|
30275
|
-
|
|
30276
|
-
|
|
30277
|
-
|
|
30278
|
-
|
|
30279
|
-
|
|
30189
|
+
const ensSearchQuery = reactQuery.useQuery({
|
|
30190
|
+
queryKey: keys().ensSearch(debouncedName),
|
|
30191
|
+
queryFn: () => {
|
|
30192
|
+
const isExactEnsSearch = checkIsExactEns(debouncedName);
|
|
30193
|
+
return isExactEnsSearch
|
|
30194
|
+
? EnsService.getExactEns(debouncedName)
|
|
30195
|
+
: EnsService.searchEnsNames(debouncedName);
|
|
30196
|
+
},
|
|
30280
30197
|
enabled: Boolean(debouncedName?.trim()) && enabled,
|
|
30281
|
-
|
|
30198
|
+
gcTime: Infinity,
|
|
30282
30199
|
});
|
|
30283
30200
|
return ensSearchQuery;
|
|
30284
30201
|
}
|
|
@@ -30299,23 +30216,25 @@ function checkIsExactEns(name = "") {
|
|
|
30299
30216
|
|
|
30300
30217
|
const useCosmosForChain = (chain) => {
|
|
30301
30218
|
const { keplrTypeWallet } = useCosmosSigner({ chain });
|
|
30302
|
-
const cosmosAddressQuery = reactQuery.useQuery(
|
|
30303
|
-
|
|
30304
|
-
|
|
30305
|
-
|
|
30306
|
-
|
|
30307
|
-
|
|
30308
|
-
|
|
30309
|
-
|
|
30310
|
-
|
|
30311
|
-
|
|
30312
|
-
|
|
30313
|
-
|
|
30314
|
-
|
|
30315
|
-
|
|
30316
|
-
|
|
30317
|
-
|
|
30318
|
-
|
|
30219
|
+
const cosmosAddressQuery = reactQuery.useQuery({
|
|
30220
|
+
queryKey: keys().cosmosAddress(chain?.chainId),
|
|
30221
|
+
queryFn: async () => {
|
|
30222
|
+
if (!chain || !keplrTypeWallet)
|
|
30223
|
+
return "";
|
|
30224
|
+
try {
|
|
30225
|
+
const address = await getCosmosKey(chain.chainId, keplrTypeWallet);
|
|
30226
|
+
return address ?? "";
|
|
30227
|
+
}
|
|
30228
|
+
catch (error) {
|
|
30229
|
+
await suggestChainOrThrow({
|
|
30230
|
+
chain: chain,
|
|
30231
|
+
error,
|
|
30232
|
+
keplrTypeWallet,
|
|
30233
|
+
});
|
|
30234
|
+
const address = await getCosmosKey(chain.chainId, keplrTypeWallet);
|
|
30235
|
+
return address ?? "";
|
|
30236
|
+
}
|
|
30237
|
+
},
|
|
30319
30238
|
enabled: !!keplrTypeWallet && chain?.chainType === squidTypes.ChainType.COSMOS,
|
|
30320
30239
|
});
|
|
30321
30240
|
return cosmosAddressQuery;
|
|
@@ -30392,12 +30311,14 @@ const useIsSameAddressAndGnosisContext = () => {
|
|
|
30392
30311
|
|
|
30393
30312
|
function useBitcoin() {
|
|
30394
30313
|
const connectedBitcoinWallet = useWalletStore((store) => store.connectedWalletsByChainType[squidTypes.ChainType.BTC]);
|
|
30395
|
-
const connectBitcoin = reactQuery.useMutation(
|
|
30396
|
-
|
|
30397
|
-
|
|
30398
|
-
|
|
30399
|
-
|
|
30400
|
-
|
|
30314
|
+
const connectBitcoin = reactQuery.useMutation({
|
|
30315
|
+
mutationFn: async ({ wallet, }) => {
|
|
30316
|
+
const { address } = await wallet.connector.requestAccount();
|
|
30317
|
+
return {
|
|
30318
|
+
wallet,
|
|
30319
|
+
address,
|
|
30320
|
+
};
|
|
30321
|
+
}
|
|
30401
30322
|
});
|
|
30402
30323
|
return {
|
|
30403
30324
|
connectBitcoin,
|
|
@@ -30437,15 +30358,17 @@ function useEvm() {
|
|
|
30437
30358
|
const { wallets } = useEvmWallets();
|
|
30438
30359
|
const connectedEvmWallet = useWalletStore((store) => store.connectedWalletsByChainType[squidTypes.ChainType.EVM]);
|
|
30439
30360
|
const recentEvmWalletId = useWalletStore((store) => store.recentConnectorIds[squidTypes.ChainType.EVM]);
|
|
30440
|
-
const connectEvm = reactQuery.useMutation(
|
|
30441
|
-
|
|
30442
|
-
|
|
30443
|
-
|
|
30444
|
-
|
|
30445
|
-
|
|
30446
|
-
|
|
30447
|
-
|
|
30448
|
-
|
|
30361
|
+
const connectEvm = reactQuery.useMutation({
|
|
30362
|
+
mutationFn: async ({ wallet, }) => {
|
|
30363
|
+
const result = await connectAsync({
|
|
30364
|
+
connector: wallet.connector,
|
|
30365
|
+
});
|
|
30366
|
+
const [firstAddress] = result.accounts;
|
|
30367
|
+
return {
|
|
30368
|
+
wallet,
|
|
30369
|
+
address: firstAddress,
|
|
30370
|
+
};
|
|
30371
|
+
}
|
|
30449
30372
|
});
|
|
30450
30373
|
const disconnectEvm = React.useCallback(async () => {
|
|
30451
30374
|
disconnect({ connector: connectedEvmWallet.wallet?.connector });
|
|
@@ -30539,21 +30462,23 @@ function useSolana() {
|
|
|
30539
30462
|
const { wallets } = useSolanaWallets();
|
|
30540
30463
|
const connectedSolanaWallet = useWalletStore((store) => store.connectedWalletsByChainType[squidTypes.ChainType.SOLANA]);
|
|
30541
30464
|
const recentSolanaWalletId = useWalletStore((store) => store.recentConnectorIds[squidTypes.ChainType.SOLANA]);
|
|
30542
|
-
const connectSolana = reactQuery.useMutation(
|
|
30543
|
-
|
|
30544
|
-
|
|
30545
|
-
|
|
30546
|
-
|
|
30547
|
-
|
|
30548
|
-
|
|
30549
|
-
|
|
30550
|
-
|
|
30465
|
+
const connectSolana = reactQuery.useMutation({
|
|
30466
|
+
mutationFn: async ({ wallet, }) => {
|
|
30467
|
+
try {
|
|
30468
|
+
// try to connect silently first
|
|
30469
|
+
await wallet.connector.autoConnect();
|
|
30470
|
+
}
|
|
30471
|
+
catch {
|
|
30472
|
+
// if auto-connect fails (e.g. not authorized yet)
|
|
30473
|
+
// fallback to connect via popup
|
|
30474
|
+
await wallet.connector.connect();
|
|
30475
|
+
}
|
|
30476
|
+
const address = wallet.connector.wallet.accounts[0].address;
|
|
30477
|
+
return {
|
|
30478
|
+
wallet,
|
|
30479
|
+
address,
|
|
30480
|
+
};
|
|
30551
30481
|
}
|
|
30552
|
-
const address = wallet.connector.wallet.accounts[0].address;
|
|
30553
|
-
return {
|
|
30554
|
-
wallet,
|
|
30555
|
-
address,
|
|
30556
|
-
};
|
|
30557
30482
|
});
|
|
30558
30483
|
const disconnectSolana = React.useCallback(async () => {
|
|
30559
30484
|
await connectedSolanaWallet.wallet?.connector.disconnect();
|
|
@@ -30628,7 +30553,7 @@ function useStellarWallets() {
|
|
|
30628
30553
|
return;
|
|
30629
30554
|
try {
|
|
30630
30555
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
30631
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
30556
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-BUdrOP04.js'); });
|
|
30632
30557
|
const modules = initializeAllModules();
|
|
30633
30558
|
const promises = modules.map(async (module) => {
|
|
30634
30559
|
const isAvailable = await module.isAvailable();
|
|
@@ -30656,12 +30581,14 @@ function useStellarWallets() {
|
|
|
30656
30581
|
function useStellar() {
|
|
30657
30582
|
const { wallets } = useStellarWallets();
|
|
30658
30583
|
const connectedStellarWallet = useWalletStore((store) => store.connectedWalletsByChainType[squidTypes.ChainType.STELLAR]);
|
|
30659
|
-
const connectStellar = reactQuery.useMutation(
|
|
30660
|
-
|
|
30661
|
-
|
|
30662
|
-
|
|
30663
|
-
|
|
30664
|
-
|
|
30584
|
+
const connectStellar = reactQuery.useMutation({
|
|
30585
|
+
mutationFn: async ({ wallet, }) => {
|
|
30586
|
+
const { address } = await wallet.connector.getAddress();
|
|
30587
|
+
return {
|
|
30588
|
+
wallet,
|
|
30589
|
+
address,
|
|
30590
|
+
};
|
|
30591
|
+
}
|
|
30665
30592
|
});
|
|
30666
30593
|
const disconnectStellar = React.useCallback(async () => {
|
|
30667
30594
|
await connectedStellarWallet.wallet?.connector.disconnect?.();
|
|
@@ -30713,22 +30640,24 @@ function useSui() {
|
|
|
30713
30640
|
const recentSuiWalletId = useWalletStore((store) => store.recentConnectorIds[squidTypes.ChainType.SUI]);
|
|
30714
30641
|
const setConnectedWallet = useWalletStore((store) => store.setConnectedWallet);
|
|
30715
30642
|
const disconnectWallet = useWalletStore((store) => store.disconnectWallet);
|
|
30716
|
-
const connectSui = reactQuery.useMutation(
|
|
30717
|
-
|
|
30718
|
-
|
|
30719
|
-
|
|
30720
|
-
|
|
30721
|
-
|
|
30722
|
-
|
|
30723
|
-
|
|
30724
|
-
|
|
30725
|
-
|
|
30643
|
+
const connectSui = reactQuery.useMutation({
|
|
30644
|
+
mutationFn: async ({ wallet, }) => {
|
|
30645
|
+
let account;
|
|
30646
|
+
try {
|
|
30647
|
+
// try to connect silently first
|
|
30648
|
+
account = await wallet.connector.connect({ silent: true });
|
|
30649
|
+
}
|
|
30650
|
+
catch {
|
|
30651
|
+
// if auto-connect fails (e.g. not authorized yet)
|
|
30652
|
+
// fallback to connect via popup
|
|
30653
|
+
account = await wallet.connector.connect();
|
|
30654
|
+
}
|
|
30655
|
+
return {
|
|
30656
|
+
wallet,
|
|
30657
|
+
address: account.account.address,
|
|
30658
|
+
account: account.account,
|
|
30659
|
+
};
|
|
30726
30660
|
}
|
|
30727
|
-
return {
|
|
30728
|
-
wallet,
|
|
30729
|
-
address: account.account.address,
|
|
30730
|
-
account: account.account,
|
|
30731
|
-
};
|
|
30732
30661
|
});
|
|
30733
30662
|
const disconnectSui = React.useCallback(async () => {
|
|
30734
30663
|
await connectedSuiWallet.wallet?.connector.disconnect();
|
|
@@ -31037,12 +30966,14 @@ function useXrpl() {
|
|
|
31037
30966
|
const recentXrplWalletId = useWalletStore((store) => store.recentConnectorIds[squidTypes.ChainType.XRPL]);
|
|
31038
30967
|
const setConnectedWallet = useWalletStore((store) => store.setConnectedWallet);
|
|
31039
30968
|
const disconnectWallet = useWalletStore((store) => store.disconnectWallet);
|
|
31040
|
-
const connectXrpl = reactQuery.useMutation(
|
|
31041
|
-
|
|
31042
|
-
|
|
31043
|
-
|
|
31044
|
-
|
|
31045
|
-
|
|
30969
|
+
const connectXrpl = reactQuery.useMutation({
|
|
30970
|
+
mutationFn: async ({ wallet, }) => {
|
|
30971
|
+
const xrplConnectedAddress = await wallet.connector.connect();
|
|
30972
|
+
return {
|
|
30973
|
+
wallet,
|
|
30974
|
+
address: xrplConnectedAddress,
|
|
30975
|
+
};
|
|
30976
|
+
}
|
|
31046
30977
|
});
|
|
31047
30978
|
const disconnectXrpl = React.useCallback(async () => {
|
|
31048
30979
|
await connectedXrplWallet?.wallet?.connector.disconnect?.();
|
|
@@ -31429,18 +31360,19 @@ const useMultiChainWallet = (chain) => {
|
|
|
31429
31360
|
/**
|
|
31430
31361
|
* Change current network for desired chain
|
|
31431
31362
|
*/
|
|
31432
|
-
const changeNetworkIfNeeded = reactQuery.useMutation(
|
|
31433
|
-
|
|
31434
|
-
|
|
31435
|
-
|
|
31436
|
-
|
|
31437
|
-
|
|
31438
|
-
|
|
31439
|
-
|
|
31440
|
-
|
|
31441
|
-
|
|
31442
|
-
|
|
31443
|
-
|
|
31363
|
+
const changeNetworkIfNeeded = reactQuery.useMutation({
|
|
31364
|
+
mutationFn: async () => {
|
|
31365
|
+
const isNotOnDesiredChain = chain?.chainType === squidTypes.ChainType.EVM &&
|
|
31366
|
+
currentEvmChain?.id !== Number(chain.chainId);
|
|
31367
|
+
if (isNotOnDesiredChain) {
|
|
31368
|
+
await switchChainAsync({
|
|
31369
|
+
chainId: Number(chain.chainId),
|
|
31370
|
+
});
|
|
31371
|
+
}
|
|
31372
|
+
// Implement keplr change network
|
|
31373
|
+
// Looks like there are no method to do that at the moment
|
|
31374
|
+
return false;
|
|
31375
|
+
},
|
|
31444
31376
|
onError: async (error) => {
|
|
31445
31377
|
if (error instanceof viem.UserRejectedRequestError) {
|
|
31446
31378
|
return;
|
|
@@ -31452,7 +31384,7 @@ const useMultiChainWallet = (chain) => {
|
|
|
31452
31384
|
provider,
|
|
31453
31385
|
});
|
|
31454
31386
|
}
|
|
31455
|
-
}
|
|
31387
|
+
}
|
|
31456
31388
|
});
|
|
31457
31389
|
const isChainTypeConnected = React.useCallback((chainType) => {
|
|
31458
31390
|
if (isGnosisConnected && chainType === squidTypes.ChainType.EVM) {
|
|
@@ -31800,51 +31732,53 @@ const useCosmos = () => {
|
|
|
31800
31732
|
clientWindow?.removeEventListener("keplr_keystorechange", () => handleKeplrAccountChanged());
|
|
31801
31733
|
};
|
|
31802
31734
|
}, [handleKeplrAccountChanged, clientWindow]);
|
|
31803
|
-
const connectCosmos = reactQuery.useMutation(
|
|
31804
|
-
|
|
31805
|
-
|
|
31806
|
-
|
|
31807
|
-
|
|
31808
|
-
|
|
31809
|
-
|
|
31810
|
-
|
|
31811
|
-
|
|
31812
|
-
|
|
31813
|
-
|
|
31814
|
-
|
|
31815
|
-
|
|
31816
|
-
|
|
31817
|
-
|
|
31818
|
-
|
|
31735
|
+
const connectCosmos = reactQuery.useMutation({
|
|
31736
|
+
mutationFn: async ({ chain, wallet, approveAllChains = true, }) => {
|
|
31737
|
+
const chainInfos = getCosmosChainInfosObject(chain);
|
|
31738
|
+
const cosmosWalletObject = wallet.connector().provider;
|
|
31739
|
+
if (cosmosWalletObject) {
|
|
31740
|
+
setCosmosChainId(chainInfos.chainId.toString());
|
|
31741
|
+
try {
|
|
31742
|
+
if (approveAllChains &&
|
|
31743
|
+
typeof cosmosWalletObject.getChainInfosWithoutEndpoints ===
|
|
31744
|
+
"function") {
|
|
31745
|
+
try {
|
|
31746
|
+
const addedChains = await cosmosWalletObject.getChainInfosWithoutEndpoints();
|
|
31747
|
+
const addedChainIds = addedChains?.map((addedChain) => addedChain.chainId);
|
|
31748
|
+
const chainsToEnable = cosmosChains
|
|
31749
|
+
.filter((c) => addedChainIds?.includes(c.chainId.toString()))
|
|
31750
|
+
.map((c) => c.chainId.toString());
|
|
31751
|
+
await cosmosWalletObject.enable(chainsToEnable);
|
|
31752
|
+
}
|
|
31753
|
+
catch (error) {
|
|
31754
|
+
console.warn("Failed to get chain infos, falling back to single chain enable", error);
|
|
31755
|
+
await cosmosWalletObject.enable(chainInfos.chainId);
|
|
31756
|
+
}
|
|
31819
31757
|
}
|
|
31820
|
-
|
|
31821
|
-
console.warn("Failed to get chain infos, falling back to single chain enable", error);
|
|
31758
|
+
else {
|
|
31822
31759
|
await cosmosWalletObject.enable(chainInfos.chainId);
|
|
31823
31760
|
}
|
|
31761
|
+
const address = await getAddress({
|
|
31762
|
+
chainId: chain.chainId.toString(),
|
|
31763
|
+
cosmosWalletObject,
|
|
31764
|
+
wallet,
|
|
31765
|
+
});
|
|
31766
|
+
if (address) {
|
|
31767
|
+
updateWalletStore(wallet, cosmosWalletObject, address);
|
|
31768
|
+
return address;
|
|
31769
|
+
}
|
|
31824
31770
|
}
|
|
31825
|
-
|
|
31826
|
-
await
|
|
31827
|
-
|
|
31828
|
-
|
|
31829
|
-
|
|
31830
|
-
|
|
31831
|
-
wallet
|
|
31832
|
-
});
|
|
31833
|
-
if (address) {
|
|
31834
|
-
updateWalletStore(wallet, cosmosWalletObject, address);
|
|
31835
|
-
return address;
|
|
31771
|
+
catch (error) {
|
|
31772
|
+
await suggestChainOrThrow({
|
|
31773
|
+
chain,
|
|
31774
|
+
error,
|
|
31775
|
+
keplrTypeWallet: cosmosWalletObject,
|
|
31776
|
+
});
|
|
31777
|
+
return connectCosmos.mutateAsync({ chain, wallet });
|
|
31836
31778
|
}
|
|
31837
31779
|
}
|
|
31838
|
-
|
|
31839
|
-
await suggestChainOrThrow({
|
|
31840
|
-
chain,
|
|
31841
|
-
error,
|
|
31842
|
-
keplrTypeWallet: cosmosWalletObject,
|
|
31843
|
-
});
|
|
31844
|
-
return connectCosmos.mutateAsync({ chain, wallet });
|
|
31845
|
-
}
|
|
31780
|
+
return undefined;
|
|
31846
31781
|
}
|
|
31847
|
-
return undefined;
|
|
31848
31782
|
});
|
|
31849
31783
|
const clearData = () => {
|
|
31850
31784
|
disconnectWallet(squidTypes.ChainType.COSMOS);
|
|
@@ -31998,11 +31932,11 @@ const useSquidQueryClient = () => {
|
|
|
31998
31932
|
const queryClient = reactQuery.useQueryClient();
|
|
31999
31933
|
const invalidateQueries = (key) => {
|
|
32000
31934
|
const prefixKey = getPrefixKey(key);
|
|
32001
|
-
queryClient.invalidateQueries(prefixKey);
|
|
31935
|
+
queryClient.invalidateQueries({ queryKey: prefixKey });
|
|
32002
31936
|
};
|
|
32003
31937
|
const refetchQueries = (key) => {
|
|
32004
31938
|
const prefixKey = getPrefixKey(key);
|
|
32005
|
-
queryClient.refetchQueries(prefixKey);
|
|
31939
|
+
queryClient.refetchQueries({ queryKey: prefixKey });
|
|
32006
31940
|
};
|
|
32007
31941
|
const invalidateAndRefetchQueries = (key) => {
|
|
32008
31942
|
invalidateQueries(key);
|
|
@@ -33509,17 +33443,19 @@ function useDepositAddress(squidRoute) {
|
|
|
33509
33443
|
toggleDepositFlow(false);
|
|
33510
33444
|
setDeposit(null);
|
|
33511
33445
|
}, [toggleDepositFlow, setDeposit]);
|
|
33512
|
-
const getRouteWithDeposit = reactQuery.useMutation(
|
|
33513
|
-
|
|
33514
|
-
|
|
33515
|
-
|
|
33516
|
-
|
|
33517
|
-
|
|
33518
|
-
|
|
33519
|
-
|
|
33520
|
-
|
|
33521
|
-
|
|
33522
|
-
|
|
33446
|
+
const getRouteWithDeposit = reactQuery.useMutation({
|
|
33447
|
+
mutationFn: async ({ route }) => {
|
|
33448
|
+
if (!squid)
|
|
33449
|
+
throw new Error("Squid SDK not initialized");
|
|
33450
|
+
const depositAddressResponse = (await squid.executeRoute({
|
|
33451
|
+
signer: {},
|
|
33452
|
+
route,
|
|
33453
|
+
}));
|
|
33454
|
+
setDeposit(depositAddressResponse);
|
|
33455
|
+
return {
|
|
33456
|
+
depositAddress: depositAddressResponse,
|
|
33457
|
+
};
|
|
33458
|
+
}
|
|
33523
33459
|
});
|
|
33524
33460
|
return {
|
|
33525
33461
|
isEnabled,
|
|
@@ -33603,53 +33539,55 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
33603
33539
|
xrplTokens.length,
|
|
33604
33540
|
stellarTokens.length,
|
|
33605
33541
|
]);
|
|
33606
|
-
const query = reactQuery.useQuery(
|
|
33607
|
-
|
|
33608
|
-
|
|
33609
|
-
|
|
33542
|
+
const query = reactQuery.useQuery({
|
|
33543
|
+
queryKey: keys().allTokensBalance(address, chainType, direction),
|
|
33544
|
+
queryFn: async () => {
|
|
33545
|
+
// Return zero balances if no address
|
|
33546
|
+
if (!address) {
|
|
33547
|
+
const defaultTokens = placeholderData.tokens;
|
|
33548
|
+
return {
|
|
33549
|
+
tokens: defaultTokens,
|
|
33550
|
+
totalUsdBalance: calculateTotalUsdBalanceUSD(defaultTokens),
|
|
33551
|
+
};
|
|
33552
|
+
}
|
|
33553
|
+
let fetchedTokens = [];
|
|
33554
|
+
// Fetch tokens based on chain type
|
|
33555
|
+
switch (chainType) {
|
|
33556
|
+
case squidTypes.ChainType.EVM:
|
|
33557
|
+
fetchedTokens = await getAllEvmTokensBalance(evmTokens, address, evmChains);
|
|
33558
|
+
break;
|
|
33559
|
+
case squidTypes.ChainType.COSMOS:
|
|
33560
|
+
const addresses = await getAllKeysForSupportedCosmosChains(cosmosChains.map((c) => c.chainId), keplrTypeWallet);
|
|
33561
|
+
fetchedTokens = await getAllCosmosBalances({
|
|
33562
|
+
addresses,
|
|
33563
|
+
cosmosChains,
|
|
33564
|
+
cosmosTokens,
|
|
33565
|
+
});
|
|
33566
|
+
break;
|
|
33567
|
+
case squidTypes.ChainType.SOLANA:
|
|
33568
|
+
fetchedTokens = await getAllSolanaTokensBalance(solanaTokens, address);
|
|
33569
|
+
break;
|
|
33570
|
+
case squidTypes.ChainType.BTC:
|
|
33571
|
+
fetchedTokens = await getAllBitcoinTokensBalance(address, bitcoinTokens);
|
|
33572
|
+
break;
|
|
33573
|
+
case squidTypes.ChainType.SUI:
|
|
33574
|
+
fetchedTokens = await getAllSuiTokensBalance(address, suiTokens, suiChains);
|
|
33575
|
+
break;
|
|
33576
|
+
case squidTypes.ChainType.XRPL:
|
|
33577
|
+
fetchedTokens = await getAllXrplTokensBalance(address, xrplTokens, xrplChains);
|
|
33578
|
+
break;
|
|
33579
|
+
case squidTypes.ChainType.STELLAR:
|
|
33580
|
+
fetchedTokens = await getAllStellarTokensBalance(address, stellarTokens, stellarChains);
|
|
33581
|
+
break;
|
|
33582
|
+
default:
|
|
33583
|
+
fetchedTokens = placeholderData.tokens;
|
|
33584
|
+
break;
|
|
33585
|
+
}
|
|
33610
33586
|
return {
|
|
33611
|
-
tokens:
|
|
33612
|
-
totalUsdBalance: calculateTotalUsdBalanceUSD(
|
|
33587
|
+
tokens: fetchedTokens,
|
|
33588
|
+
totalUsdBalance: calculateTotalUsdBalanceUSD(fetchedTokens),
|
|
33613
33589
|
};
|
|
33614
|
-
}
|
|
33615
|
-
let fetchedTokens = [];
|
|
33616
|
-
// Fetch tokens based on chain type
|
|
33617
|
-
switch (chainType) {
|
|
33618
|
-
case squidTypes.ChainType.EVM:
|
|
33619
|
-
fetchedTokens = await getAllEvmTokensBalance(evmTokens, address, evmChains);
|
|
33620
|
-
break;
|
|
33621
|
-
case squidTypes.ChainType.COSMOS:
|
|
33622
|
-
const addresses = await getAllKeysForSupportedCosmosChains(cosmosChains.map((c) => c.chainId), keplrTypeWallet);
|
|
33623
|
-
fetchedTokens = await getAllCosmosBalances({
|
|
33624
|
-
addresses,
|
|
33625
|
-
cosmosChains,
|
|
33626
|
-
cosmosTokens,
|
|
33627
|
-
});
|
|
33628
|
-
break;
|
|
33629
|
-
case squidTypes.ChainType.SOLANA:
|
|
33630
|
-
fetchedTokens = await getAllSolanaTokensBalance(solanaTokens, address);
|
|
33631
|
-
break;
|
|
33632
|
-
case squidTypes.ChainType.BTC:
|
|
33633
|
-
fetchedTokens = await getAllBitcoinTokensBalance(address, bitcoinTokens);
|
|
33634
|
-
break;
|
|
33635
|
-
case squidTypes.ChainType.SUI:
|
|
33636
|
-
fetchedTokens = await getAllSuiTokensBalance(address, suiTokens, suiChains);
|
|
33637
|
-
break;
|
|
33638
|
-
case squidTypes.ChainType.XRPL:
|
|
33639
|
-
fetchedTokens = await getAllXrplTokensBalance(address, xrplTokens, xrplChains);
|
|
33640
|
-
break;
|
|
33641
|
-
case squidTypes.ChainType.STELLAR:
|
|
33642
|
-
fetchedTokens = await getAllStellarTokensBalance(address, stellarTokens, stellarChains);
|
|
33643
|
-
break;
|
|
33644
|
-
default:
|
|
33645
|
-
fetchedTokens = placeholderData.tokens;
|
|
33646
|
-
break;
|
|
33647
|
-
}
|
|
33648
|
-
return {
|
|
33649
|
-
tokens: fetchedTokens,
|
|
33650
|
-
totalUsdBalance: calculateTotalUsdBalanceUSD(fetchedTokens),
|
|
33651
|
-
};
|
|
33652
|
-
}, {
|
|
33590
|
+
},
|
|
33653
33591
|
...queryOptions,
|
|
33654
33592
|
enabled: isQueryEnabled,
|
|
33655
33593
|
});
|
|
@@ -33664,7 +33602,7 @@ const BALANCE_STALE_TIME = 60000; // 1 minute
|
|
|
33664
33602
|
const BALANCE_CACHE_TIME = 300000; // 5 minutes
|
|
33665
33603
|
const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
33666
33604
|
staleTime: BALANCE_STALE_TIME,
|
|
33667
|
-
|
|
33605
|
+
gcTime: BALANCE_CACHE_TIME,
|
|
33668
33606
|
refetchOnWindowFocus: true,
|
|
33669
33607
|
refetchOnMount: true,
|
|
33670
33608
|
}, } = {}) => {
|
|
@@ -33745,9 +33683,9 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
33745
33683
|
}, [balanceQueries]);
|
|
33746
33684
|
// Aggregate loading states
|
|
33747
33685
|
const queryStates = React.useMemo(() => ({
|
|
33748
|
-
isInitialLoading: Object.values(balanceQueries).some((q) => q.isInitialLoading),
|
|
33749
|
-
isFetching: Object.values(balanceQueries).some((q) => q.isFetching),
|
|
33750
33686
|
isLoading: Object.values(balanceQueries).some((q) => q.isLoading),
|
|
33687
|
+
isFetching: Object.values(balanceQueries).some((q) => q.isFetching),
|
|
33688
|
+
isPending: Object.values(balanceQueries).some((q) => q.isPending),
|
|
33751
33689
|
isRefetching: Object.values(balanceQueries).some((q) => q.isRefetching),
|
|
33752
33690
|
isError: Object.values(balanceQueries).some((q) => q.isError),
|
|
33753
33691
|
isSuccess: Object.values(balanceQueries).every((q) => q.isSuccess),
|
|
@@ -33789,7 +33727,7 @@ function useNativeTokenForChain(chain) {
|
|
|
33789
33727
|
|
|
33790
33728
|
const useEvmNativeBalance = ({ address, chain, }) => {
|
|
33791
33729
|
const { isChainTypeConnected } = useWallet();
|
|
33792
|
-
const { data: nativeEvmBalance,
|
|
33730
|
+
const { data: nativeEvmBalance, isPending } = wagmi.useBalance({
|
|
33793
33731
|
address: address,
|
|
33794
33732
|
chainId: Number(chain?.chainId),
|
|
33795
33733
|
query: {
|
|
@@ -33811,13 +33749,13 @@ const useEvmNativeBalance = ({ address, chain, }) => {
|
|
|
33811
33749
|
}, [nativeEvmBalance?.decimals, nativeEvmBalance?.value]);
|
|
33812
33750
|
return {
|
|
33813
33751
|
balance,
|
|
33814
|
-
|
|
33752
|
+
isPending,
|
|
33815
33753
|
};
|
|
33816
33754
|
};
|
|
33817
33755
|
const useCosmosNativeBalance = ({ address, chain, }) => {
|
|
33818
33756
|
const { isConnected: isCosmosConnected } = useCosmosContext();
|
|
33819
33757
|
const { nativeToken: nativeCosmosToken } = useNativeTokenForChain(chain);
|
|
33820
|
-
const { balance: rawBalance,
|
|
33758
|
+
const { balance: rawBalance, isPending } = useCosmosBalance({
|
|
33821
33759
|
chain,
|
|
33822
33760
|
token: nativeCosmosToken,
|
|
33823
33761
|
userAddress: address,
|
|
@@ -33832,16 +33770,18 @@ const useCosmosNativeBalance = ({ address, chain, }) => {
|
|
|
33832
33770
|
};
|
|
33833
33771
|
}
|
|
33834
33772
|
}, [nativeCosmosToken?.decimals, rawBalance]);
|
|
33835
|
-
return { balance,
|
|
33773
|
+
return { balance, isPending };
|
|
33836
33774
|
};
|
|
33837
33775
|
const useBitcoinNativeBalance = ({ chain, address, }) => {
|
|
33838
33776
|
const { nativeToken } = useNativeTokenForChain(chain);
|
|
33839
|
-
const { data: rawBalance = "0",
|
|
33840
|
-
|
|
33841
|
-
|
|
33842
|
-
|
|
33843
|
-
|
|
33844
|
-
|
|
33777
|
+
const { data: rawBalance = "0", isPending } = reactQuery.useQuery({
|
|
33778
|
+
queryKey: keys().balance(chain?.chainId, nativeToken?.address, address),
|
|
33779
|
+
queryFn: async () => {
|
|
33780
|
+
if (!address || !nativeToken)
|
|
33781
|
+
return "0";
|
|
33782
|
+
const balance = await getBitcoinNativeBalance(address);
|
|
33783
|
+
return formatBNToReadable(balance, nativeToken.decimals);
|
|
33784
|
+
},
|
|
33845
33785
|
enabled: chain?.chainType === squidTypes.ChainType.BTC &&
|
|
33846
33786
|
nativeToken?.decimals != null &&
|
|
33847
33787
|
isWalletAddressValid(chain, address),
|
|
@@ -33860,15 +33800,17 @@ const useBitcoinNativeBalance = ({ chain, address, }) => {
|
|
|
33860
33800
|
}, [nativeToken?.decimals, rawBalance]);
|
|
33861
33801
|
return {
|
|
33862
33802
|
balance,
|
|
33863
|
-
|
|
33803
|
+
isPending,
|
|
33864
33804
|
};
|
|
33865
33805
|
};
|
|
33866
33806
|
const useSolanaNativeBalance = ({ chain, address, }) => {
|
|
33867
33807
|
const { nativeToken } = useNativeTokenForChain(chain);
|
|
33868
|
-
const { data: rawBalance,
|
|
33869
|
-
|
|
33870
|
-
|
|
33871
|
-
|
|
33808
|
+
const { data: rawBalance, isPending } = reactQuery.useQuery({
|
|
33809
|
+
queryKey: keys().balance(chain?.chainId, nativeToken?.address, address),
|
|
33810
|
+
queryFn: async () => {
|
|
33811
|
+
const balance = await getSolanaNativeBalance(address);
|
|
33812
|
+
return formatBNToReadable(balance, nativeToken.decimals);
|
|
33813
|
+
},
|
|
33872
33814
|
enabled: !!address &&
|
|
33873
33815
|
nativeToken?.decimals != null &&
|
|
33874
33816
|
chain?.chainType === squidTypes.ChainType.SOLANA,
|
|
@@ -33887,12 +33829,12 @@ const useSolanaNativeBalance = ({ chain, address, }) => {
|
|
|
33887
33829
|
}, [nativeToken?.decimals, rawBalance]);
|
|
33888
33830
|
return {
|
|
33889
33831
|
balance,
|
|
33890
|
-
|
|
33832
|
+
isPending,
|
|
33891
33833
|
};
|
|
33892
33834
|
};
|
|
33893
33835
|
const useSuiNativeBalance = ({ address, chain, }) => {
|
|
33894
33836
|
const { nativeToken } = useNativeTokenForChain(chain);
|
|
33895
|
-
const { balance: rawBalance,
|
|
33837
|
+
const { balance: rawBalance, isPending } = useSuiBalance({
|
|
33896
33838
|
chain,
|
|
33897
33839
|
token: nativeToken,
|
|
33898
33840
|
userAddress: address,
|
|
@@ -33907,12 +33849,12 @@ const useSuiNativeBalance = ({ address, chain, }) => {
|
|
|
33907
33849
|
}, [nativeToken?.decimals, rawBalance]);
|
|
33908
33850
|
return {
|
|
33909
33851
|
balance,
|
|
33910
|
-
|
|
33852
|
+
isPending,
|
|
33911
33853
|
};
|
|
33912
33854
|
};
|
|
33913
33855
|
const useXrplNativeBalance = ({ address, chain, }) => {
|
|
33914
33856
|
const { nativeToken } = useNativeTokenForChain(chain);
|
|
33915
|
-
const { balance: rawBalance,
|
|
33857
|
+
const { balance: rawBalance, isPending } = useXrplBalance({
|
|
33916
33858
|
chain,
|
|
33917
33859
|
token: nativeToken,
|
|
33918
33860
|
userAddress: address,
|
|
@@ -33928,12 +33870,12 @@ const useXrplNativeBalance = ({ address, chain, }) => {
|
|
|
33928
33870
|
}, [nativeToken?.decimals, rawBalance]);
|
|
33929
33871
|
return {
|
|
33930
33872
|
balance,
|
|
33931
|
-
|
|
33873
|
+
isPending,
|
|
33932
33874
|
};
|
|
33933
33875
|
};
|
|
33934
33876
|
const useStellarNativeBalance = ({ address, chain, }) => {
|
|
33935
33877
|
const { nativeToken } = useNativeTokenForChain(chain);
|
|
33936
|
-
const { balance: rawBalance,
|
|
33878
|
+
const { balance: rawBalance, isPending } = useStellarBalance({
|
|
33937
33879
|
chain,
|
|
33938
33880
|
token: nativeToken,
|
|
33939
33881
|
userAddress: address,
|
|
@@ -33949,7 +33891,7 @@ const useStellarNativeBalance = ({ address, chain, }) => {
|
|
|
33949
33891
|
}, [nativeToken?.decimals, rawBalance]);
|
|
33950
33892
|
return {
|
|
33951
33893
|
balance,
|
|
33952
|
-
|
|
33894
|
+
isPending,
|
|
33953
33895
|
};
|
|
33954
33896
|
};
|
|
33955
33897
|
const useNativeBalance = (chain) => {
|
|
@@ -33957,28 +33899,28 @@ const useNativeBalance = (chain) => {
|
|
|
33957
33899
|
const { data: cosmosAddressForChain } = useCosmosForChain(chain);
|
|
33958
33900
|
// Cosmos is a special case because the address changes on every chain
|
|
33959
33901
|
// so we can't use the default cosmos connected address
|
|
33960
|
-
const { balance: nativeCosmosBalance,
|
|
33902
|
+
const { balance: nativeCosmosBalance, isPending: isCosmosPending } = useCosmosNativeBalance({
|
|
33961
33903
|
address: cosmosAddressForChain,
|
|
33962
33904
|
chain,
|
|
33963
33905
|
});
|
|
33964
|
-
const { balance: nativeEvmBalance,
|
|
33965
|
-
const { balance: nativeBitcoinBalance,
|
|
33906
|
+
const { balance: nativeEvmBalance, isPending: isEvmPending } = useEvmNativeBalance({ address: connectedAddresses[squidTypes.ChainType.EVM], chain });
|
|
33907
|
+
const { balance: nativeBitcoinBalance, isPending: isBitcoinPending } = useBitcoinNativeBalance({
|
|
33966
33908
|
address: connectedAddresses[squidTypes.ChainType.BTC],
|
|
33967
33909
|
chain,
|
|
33968
33910
|
});
|
|
33969
|
-
const { balance: nativeSolanaBalance,
|
|
33911
|
+
const { balance: nativeSolanaBalance, isPending: isSolanaPending } = useSolanaNativeBalance({
|
|
33970
33912
|
address: connectedAddresses[squidTypes.ChainType.SOLANA],
|
|
33971
33913
|
chain,
|
|
33972
33914
|
});
|
|
33973
|
-
const { balance: nativeSuiBalance,
|
|
33915
|
+
const { balance: nativeSuiBalance, isPending: isSuiPending } = useSuiNativeBalance({
|
|
33974
33916
|
address: connectedAddresses[squidTypes.ChainType.SUI],
|
|
33975
33917
|
chain,
|
|
33976
33918
|
});
|
|
33977
|
-
const { balance: nativeXrplBalance,
|
|
33919
|
+
const { balance: nativeXrplBalance, isPending: isXrplPending } = useXrplNativeBalance({
|
|
33978
33920
|
address: connectedAddresses[squidTypes.ChainType.XRPL],
|
|
33979
33921
|
chain,
|
|
33980
33922
|
});
|
|
33981
|
-
const { balance: nativeStellarBalance,
|
|
33923
|
+
const { balance: nativeStellarBalance, isPending: isStellarPending } = useStellarNativeBalance({
|
|
33982
33924
|
address: connectedAddresses[squidTypes.ChainType.STELLAR],
|
|
33983
33925
|
chain,
|
|
33984
33926
|
});
|
|
@@ -34023,36 +33965,36 @@ const useNativeBalance = (chain) => {
|
|
|
34023
33965
|
nativeXrplBalance,
|
|
34024
33966
|
nativeStellarBalance,
|
|
34025
33967
|
]);
|
|
34026
|
-
const
|
|
33968
|
+
const isPending = React.useMemo(() => {
|
|
34027
33969
|
if (!chain?.chainType)
|
|
34028
33970
|
return false;
|
|
34029
33971
|
switch (chain.chainType) {
|
|
34030
33972
|
case squidTypes.ChainType.EVM:
|
|
34031
|
-
return
|
|
33973
|
+
return isEvmPending;
|
|
34032
33974
|
case squidTypes.ChainType.COSMOS:
|
|
34033
|
-
return
|
|
33975
|
+
return isCosmosPending;
|
|
34034
33976
|
case squidTypes.ChainType.BTC:
|
|
34035
|
-
return
|
|
33977
|
+
return isBitcoinPending;
|
|
34036
33978
|
case squidTypes.ChainType.SOLANA:
|
|
34037
|
-
return
|
|
33979
|
+
return isSolanaPending;
|
|
34038
33980
|
case squidTypes.ChainType.SUI:
|
|
34039
|
-
return
|
|
33981
|
+
return isSuiPending;
|
|
34040
33982
|
case squidTypes.ChainType.XRPL:
|
|
34041
|
-
return
|
|
33983
|
+
return isXrplPending;
|
|
34042
33984
|
case squidTypes.ChainType.STELLAR:
|
|
34043
|
-
return
|
|
33985
|
+
return isStellarPending;
|
|
34044
33986
|
}
|
|
34045
33987
|
}, [
|
|
34046
33988
|
chain?.chainType,
|
|
34047
|
-
|
|
34048
|
-
|
|
34049
|
-
|
|
34050
|
-
|
|
34051
|
-
|
|
34052
|
-
|
|
34053
|
-
|
|
33989
|
+
isEvmPending,
|
|
33990
|
+
isCosmosPending,
|
|
33991
|
+
isBitcoinPending,
|
|
33992
|
+
isSolanaPending,
|
|
33993
|
+
isSuiPending,
|
|
33994
|
+
isXrplPending,
|
|
33995
|
+
isStellarPending,
|
|
34054
33996
|
]);
|
|
34055
|
-
return { nativeBalance, nativeBalanceFormatted,
|
|
33997
|
+
return { nativeBalance, nativeBalanceFormatted, isPending };
|
|
34056
33998
|
};
|
|
34057
33999
|
|
|
34058
34000
|
const DEFAULT_REFRESH_INTERVAL_MS = 15000;
|
|
@@ -34061,7 +34003,7 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
34061
34003
|
const isNativeToken = token?.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
34062
34004
|
const userAddressParsed = userAddress;
|
|
34063
34005
|
// Only fetch using useBalance if it's a native token
|
|
34064
|
-
const { data: nativeBalance,
|
|
34006
|
+
const { data: nativeBalance, isPending: isNativeTokenPending } = wagmi.useBalance({
|
|
34065
34007
|
address: userAddressParsed,
|
|
34066
34008
|
chainId: Number(chain?.chainId),
|
|
34067
34009
|
query: {
|
|
@@ -34077,7 +34019,7 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
34077
34019
|
});
|
|
34078
34020
|
// Only fetch using useReadContract if it's not a native token
|
|
34079
34021
|
// This is temporary, because of wagmi error: https://github.com/wevm/wagmi/issues/4353
|
|
34080
|
-
const { data: erc20Balance,
|
|
34022
|
+
const { data: erc20Balance, isPending: isErc20Pending } = wagmi.useReadContract({
|
|
34081
34023
|
address: token?.address,
|
|
34082
34024
|
abi: viem.erc20Abi,
|
|
34083
34025
|
functionName: "balanceOf",
|
|
@@ -34093,15 +34035,15 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
34093
34035
|
},
|
|
34094
34036
|
});
|
|
34095
34037
|
const balance = isNativeToken ? nativeBalance?.value : erc20Balance;
|
|
34096
|
-
const
|
|
34038
|
+
const isPending = isNativeToken ? isNativeTokenPending : isErc20Pending;
|
|
34097
34039
|
const formattedBalance = balance != null && token?.decimals != null
|
|
34098
34040
|
? formatBNToReadable(balance, token.decimals)
|
|
34099
34041
|
: "0";
|
|
34100
|
-
return { balance: formattedBalance,
|
|
34042
|
+
return { balance: formattedBalance, isPending };
|
|
34101
34043
|
};
|
|
34102
34044
|
const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
34103
34045
|
const { isConnected } = useCosmosContext();
|
|
34104
|
-
const { data: balance = "0",
|
|
34046
|
+
const { data: balance = "0", isPending } = reactQuery.useQuery({
|
|
34105
34047
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
34106
34048
|
queryFn: async () => {
|
|
34107
34049
|
if (!userAddress || !token || chain?.chainType !== squidTypes.ChainType.COSMOS) {
|
|
@@ -34121,10 +34063,10 @@ const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIn
|
|
|
34121
34063
|
refetchInterval: refreshIntervalMs,
|
|
34122
34064
|
retry: 2,
|
|
34123
34065
|
});
|
|
34124
|
-
return { balance,
|
|
34066
|
+
return { balance, isPending };
|
|
34125
34067
|
};
|
|
34126
34068
|
const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
34127
|
-
const { data: balance = "0",
|
|
34069
|
+
const { data: balance = "0", isPending } = reactQuery.useQuery({
|
|
34128
34070
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
34129
34071
|
queryFn: async () => {
|
|
34130
34072
|
if (!userAddress || !token)
|
|
@@ -34139,11 +34081,11 @@ const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIn
|
|
|
34139
34081
|
refetchInterval: refreshIntervalMs,
|
|
34140
34082
|
retry: 2,
|
|
34141
34083
|
});
|
|
34142
|
-
return { balance,
|
|
34084
|
+
return { balance, isPending };
|
|
34143
34085
|
};
|
|
34144
34086
|
// TODO: implement fetching balances for all bitcoin tokens
|
|
34145
34087
|
const useBitcoinBalance = ({ userAddress, chain, }) => {
|
|
34146
|
-
const { balance: balanceBn,
|
|
34088
|
+
const { balance: balanceBn, isPending } = useBitcoinNativeBalance({
|
|
34147
34089
|
address: userAddress,
|
|
34148
34090
|
chain,
|
|
34149
34091
|
});
|
|
@@ -34152,10 +34094,10 @@ const useBitcoinBalance = ({ userAddress, chain, }) => {
|
|
|
34152
34094
|
return "0";
|
|
34153
34095
|
return formatBNToReadable(balanceBn?.value, balanceBn?.decimals);
|
|
34154
34096
|
}, [balanceBn]);
|
|
34155
|
-
return { balance,
|
|
34097
|
+
return { balance, isPending };
|
|
34156
34098
|
};
|
|
34157
34099
|
const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
34158
|
-
const { data: balance = "0",
|
|
34100
|
+
const { data: balance = "0", isPending } = reactQuery.useQuery({
|
|
34159
34101
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
34160
34102
|
queryFn: async () => {
|
|
34161
34103
|
if (!userAddress ||
|
|
@@ -34175,10 +34117,10 @@ const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
34175
34117
|
refetchInterval: refreshIntervalMs,
|
|
34176
34118
|
retry: 2,
|
|
34177
34119
|
});
|
|
34178
|
-
return { balance,
|
|
34120
|
+
return { balance, isPending };
|
|
34179
34121
|
};
|
|
34180
34122
|
const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
34181
|
-
const { data: balance = "0",
|
|
34123
|
+
const { data: balance = "0", isPending } = reactQuery.useQuery({
|
|
34182
34124
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
34183
34125
|
queryFn: async () => {
|
|
34184
34126
|
if (!userAddress || !token || !chain)
|
|
@@ -34195,10 +34137,10 @@ const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs
|
|
|
34195
34137
|
refetchInterval: refreshIntervalMs,
|
|
34196
34138
|
retry: 2,
|
|
34197
34139
|
});
|
|
34198
|
-
return { balance,
|
|
34140
|
+
return { balance, isPending };
|
|
34199
34141
|
};
|
|
34200
34142
|
const useStellarBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
34201
|
-
const { data: balance = "0",
|
|
34143
|
+
const { data: balance = "0", isPending } = reactQuery.useQuery({
|
|
34202
34144
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
34203
34145
|
queryFn: async () => {
|
|
34204
34146
|
if (!userAddress || !token || !chain)
|
|
@@ -34215,7 +34157,7 @@ const useStellarBalance = ({ userAddress, chain, enabled, token, refreshInterval
|
|
|
34215
34157
|
refetchInterval: refreshIntervalMs,
|
|
34216
34158
|
retry: 2,
|
|
34217
34159
|
});
|
|
34218
|
-
return { balance,
|
|
34160
|
+
return { balance, isPending };
|
|
34219
34161
|
};
|
|
34220
34162
|
|
|
34221
34163
|
/**
|
|
@@ -34336,7 +34278,7 @@ const useMultipleTokenPrices = (tokens) => {
|
|
|
34336
34278
|
return {
|
|
34337
34279
|
tokenPrices,
|
|
34338
34280
|
getTokenPrice,
|
|
34339
|
-
|
|
34281
|
+
isPending: coinGeckoQuery.isPending,
|
|
34340
34282
|
isError: coinGeckoQuery.isError,
|
|
34341
34283
|
error: coinGeckoQuery.error,
|
|
34342
34284
|
refetch: coinGeckoQuery.refetch,
|
|
@@ -34485,13 +34427,17 @@ const fetchTokensData = async (tokens) => {
|
|
|
34485
34427
|
|
|
34486
34428
|
// Coingecko has a limit for some queries for multiple tokens, not sure what it is, but let's use 100 for now
|
|
34487
34429
|
const useHistoricalData = (coingeckoId, timeFrame) => {
|
|
34488
|
-
return reactQuery.useQuery(
|
|
34430
|
+
return reactQuery.useQuery({
|
|
34431
|
+
queryKey: keys().historicalData(coingeckoId, timeFrame),
|
|
34432
|
+
queryFn: () => fetchHistoricalData(coingeckoId, timeFrame),
|
|
34489
34433
|
staleTime: 5 * 60 * 1000,
|
|
34490
34434
|
enabled: !!coingeckoId,
|
|
34491
34435
|
});
|
|
34492
34436
|
};
|
|
34493
34437
|
const useTokensData = (tokens) => {
|
|
34494
|
-
return reactQuery.useQuery(
|
|
34438
|
+
return reactQuery.useQuery({
|
|
34439
|
+
queryKey: keys().tokensData(tokens),
|
|
34440
|
+
queryFn: () => fetchTokensData(tokens),
|
|
34495
34441
|
staleTime: 60 * 1000,
|
|
34496
34442
|
enabled: !!tokens && tokens.length > 0,
|
|
34497
34443
|
});
|
|
@@ -34796,7 +34742,7 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
34796
34742
|
}
|
|
34797
34743
|
|
|
34798
34744
|
function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
34799
|
-
const { data: estimatedGas = BigInt(0),
|
|
34745
|
+
const { data: estimatedGas = BigInt(0), isPending } = useSendTransactionGas({
|
|
34800
34746
|
chain,
|
|
34801
34747
|
token,
|
|
34802
34748
|
from,
|
|
@@ -34841,7 +34787,7 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
34841
34787
|
return {
|
|
34842
34788
|
estimatedGas,
|
|
34843
34789
|
isBalanceEnough,
|
|
34844
|
-
|
|
34790
|
+
isPending,
|
|
34845
34791
|
isNativeBalanceEnoughToPayGasFees,
|
|
34846
34792
|
minAmountValueWarnMsg,
|
|
34847
34793
|
};
|
|
@@ -35424,7 +35370,9 @@ function useSendTransaction({ to, amount, token, chain, }) {
|
|
|
35424
35370
|
});
|
|
35425
35371
|
},
|
|
35426
35372
|
onSuccess: (tx, variables) => {
|
|
35427
|
-
queryClient.invalidateQueries(
|
|
35373
|
+
queryClient.invalidateQueries({
|
|
35374
|
+
queryKey: getPrefixKey(QueryKeys.Balance),
|
|
35375
|
+
});
|
|
35428
35376
|
setTransactionState(variables.id, tx);
|
|
35429
35377
|
persistTransaction({
|
|
35430
35378
|
txType: exports.HistoryTxType.SEND,
|
|
@@ -35751,9 +35699,10 @@ const useAllTransactionsStatus = ({ enabled }) => {
|
|
|
35751
35699
|
queryKey: keys().fiatToCryptoStatus(data.orderId),
|
|
35752
35700
|
retry: TX_STATUS_CONSTANTS.RETRY_COUNT,
|
|
35753
35701
|
retryDelay: TX_STATUS_CONSTANTS.RETRY_DELAY,
|
|
35754
|
-
refetchInterval: (
|
|
35755
|
-
|
|
35756
|
-
|
|
35702
|
+
refetchInterval: (query) => {
|
|
35703
|
+
const { state } = query;
|
|
35704
|
+
if (state.data?.status &&
|
|
35705
|
+
FINAL_TRANSACTION_STATUSES.includes(state.data.status)) {
|
|
35757
35706
|
return false;
|
|
35758
35707
|
}
|
|
35759
35708
|
return TX_STATUS_CONSTANTS.REFETCH_INTERVAL;
|
|
@@ -35813,7 +35762,7 @@ const useAllTransactionsStatus = ({ enabled }) => {
|
|
|
35813
35762
|
queries: enabled && config.apiUrl ? statusQueries : [],
|
|
35814
35763
|
});
|
|
35815
35764
|
return {
|
|
35816
|
-
|
|
35765
|
+
isPending: queries.some((q) => q.isPending),
|
|
35817
35766
|
isError: queries.some((q) => q.isError),
|
|
35818
35767
|
data: queries.map((q) => q.data).filter(Boolean),
|
|
35819
35768
|
};
|
|
@@ -36072,16 +36021,18 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
36072
36021
|
* On Error: Showing the error message if any
|
|
36073
36022
|
* @returns {boolean} approved
|
|
36074
36023
|
*/
|
|
36075
|
-
const routeApproved = reactQuery.useQuery(
|
|
36076
|
-
|
|
36077
|
-
|
|
36078
|
-
|
|
36079
|
-
|
|
36080
|
-
|
|
36081
|
-
|
|
36024
|
+
const routeApproved = reactQuery.useQuery({
|
|
36025
|
+
queryKey: keys().routeApproved(squidRoute, allowanceInWei),
|
|
36026
|
+
queryFn: async () => {
|
|
36027
|
+
// Approval is only needed for EVM chains
|
|
36028
|
+
if (getChainType(squidRoute?.params.fromChain) === squidTypes.ChainType.EVM) {
|
|
36029
|
+
return hasAllowance;
|
|
36030
|
+
}
|
|
36031
|
+
return true;
|
|
36032
|
+
},
|
|
36082
36033
|
enabled: !!squidRoute &&
|
|
36083
36034
|
!!sourceUserAddress &&
|
|
36084
|
-
!allowanceQuery?.
|
|
36035
|
+
!allowanceQuery?.isPending &&
|
|
36085
36036
|
allowanceQuery?.isFetched,
|
|
36086
36037
|
});
|
|
36087
36038
|
// USDT has a very specific way of handling approvals
|
|
@@ -36170,81 +36121,84 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
36170
36121
|
/**
|
|
36171
36122
|
* Manually approve route if necessary
|
|
36172
36123
|
*/
|
|
36173
|
-
const approveRoute = reactQuery.useMutation(
|
|
36174
|
-
|
|
36175
|
-
|
|
36176
|
-
|
|
36177
|
-
|
|
36178
|
-
if (!!squidRoute && walletClient && fromToken && evmSigner && squid) {
|
|
36179
|
-
await approveSpecificTokenToZero(fromToken);
|
|
36180
|
-
try {
|
|
36181
|
-
// If needed, we can switch the chain here
|
|
36182
|
-
// If already on the correct chain, this will do nothing
|
|
36183
|
-
await switchChainAsync({ chainId: Number(fromChain?.chainId) });
|
|
36184
|
-
}
|
|
36185
|
-
catch (error) {
|
|
36186
|
-
console.error("Error switching network:", error);
|
|
36124
|
+
const approveRoute = reactQuery.useMutation({
|
|
36125
|
+
mutationFn: async () => {
|
|
36126
|
+
try {
|
|
36127
|
+
if (fromToken?.address === nativeEvmTokenAddress) {
|
|
36128
|
+
return true;
|
|
36187
36129
|
}
|
|
36188
|
-
|
|
36189
|
-
|
|
36190
|
-
|
|
36191
|
-
|
|
36192
|
-
|
|
36193
|
-
|
|
36194
|
-
|
|
36195
|
-
|
|
36196
|
-
|
|
36197
|
-
|
|
36198
|
-
|
|
36199
|
-
|
|
36200
|
-
|
|
36201
|
-
|
|
36202
|
-
|
|
36203
|
-
|
|
36204
|
-
|
|
36205
|
-
|
|
36206
|
-
|
|
36207
|
-
|
|
36130
|
+
if (!!squidRoute && walletClient && fromToken && evmSigner && squid) {
|
|
36131
|
+
await approveSpecificTokenToZero(fromToken);
|
|
36132
|
+
try {
|
|
36133
|
+
// If needed, we can switch the chain here
|
|
36134
|
+
// If already on the correct chain, this will do nothing
|
|
36135
|
+
await switchChainAsync({ chainId: Number(fromChain?.chainId) });
|
|
36136
|
+
}
|
|
36137
|
+
catch (error) {
|
|
36138
|
+
console.error("Error switching network:", error);
|
|
36139
|
+
}
|
|
36140
|
+
let approveTx;
|
|
36141
|
+
if (useIcs20) {
|
|
36142
|
+
const channel = squidRoute.estimate.actions[0].data
|
|
36143
|
+
.ibcChannel;
|
|
36144
|
+
const ics20Interface = new ethers.ethers.Interface(ics20Abi);
|
|
36145
|
+
const approveData = ics20Interface.encodeFunctionData("approve", [
|
|
36146
|
+
squidRoute.params.fromAddress,
|
|
36147
|
+
[
|
|
36148
|
+
{
|
|
36149
|
+
sourcePort: "transfer",
|
|
36150
|
+
sourceChannel: channel,
|
|
36151
|
+
spendLimit: [
|
|
36152
|
+
{
|
|
36153
|
+
denom: squidRoute.estimate.actions[0].fromToken
|
|
36154
|
+
.originalAddress,
|
|
36155
|
+
amount: squidRoute.params.fromAmount,
|
|
36156
|
+
},
|
|
36157
|
+
],
|
|
36158
|
+
allowList: [],
|
|
36159
|
+
allowedPacketData: ["*"],
|
|
36160
|
+
},
|
|
36161
|
+
],
|
|
36162
|
+
]);
|
|
36163
|
+
approveTx = await evmSigner.sendTransaction({
|
|
36164
|
+
to: squidRoute.transactionRequest.target,
|
|
36165
|
+
data: approveData,
|
|
36166
|
+
value: "0",
|
|
36167
|
+
gasLimit: squidRoute.transactionRequest
|
|
36168
|
+
.gasLimit,
|
|
36169
|
+
gasPrice: squidRoute.transactionRequest
|
|
36170
|
+
.gasPrice,
|
|
36171
|
+
});
|
|
36172
|
+
}
|
|
36173
|
+
else {
|
|
36174
|
+
approveTx = await squid.approveRoute({
|
|
36175
|
+
route: squidRoute,
|
|
36176
|
+
signer: evmSigner,
|
|
36177
|
+
// For security reasons, we don't want to allow infinite approvals in our frontends
|
|
36178
|
+
executionSettings: {
|
|
36179
|
+
infiniteApproval: false,
|
|
36208
36180
|
},
|
|
36209
|
-
|
|
36210
|
-
|
|
36211
|
-
|
|
36212
|
-
|
|
36213
|
-
|
|
36214
|
-
|
|
36215
|
-
|
|
36216
|
-
.gasLimit,
|
|
36217
|
-
gasPrice: squidRoute.transactionRequest
|
|
36218
|
-
.gasPrice,
|
|
36219
|
-
});
|
|
36181
|
+
});
|
|
36182
|
+
}
|
|
36183
|
+
if (isProblematicConnector(activeConnector)) {
|
|
36184
|
+
await sleep(3_000);
|
|
36185
|
+
}
|
|
36186
|
+
await approveTx?.wait();
|
|
36187
|
+
return true;
|
|
36220
36188
|
}
|
|
36221
|
-
|
|
36222
|
-
approveTx = await squid.approveRoute({
|
|
36223
|
-
route: squidRoute,
|
|
36224
|
-
signer: evmSigner,
|
|
36225
|
-
// For security reasons, we don't want to allow infinite approvals in our frontends
|
|
36226
|
-
executionSettings: {
|
|
36227
|
-
infiniteApproval: false,
|
|
36228
|
-
},
|
|
36229
|
-
});
|
|
36230
|
-
}
|
|
36231
|
-
if (isProblematicConnector(activeConnector)) {
|
|
36232
|
-
await sleep(3_000);
|
|
36233
|
-
}
|
|
36234
|
-
await approveTx?.wait();
|
|
36235
|
-
return true;
|
|
36189
|
+
return false;
|
|
36236
36190
|
}
|
|
36237
|
-
|
|
36238
|
-
|
|
36239
|
-
|
|
36240
|
-
|
|
36241
|
-
|
|
36242
|
-
|
|
36243
|
-
}
|
|
36244
|
-
}, {
|
|
36191
|
+
catch (error) {
|
|
36192
|
+
// Keep the error in the console to debug future issues
|
|
36193
|
+
console.error(error);
|
|
36194
|
+
return false;
|
|
36195
|
+
}
|
|
36196
|
+
},
|
|
36245
36197
|
onSuccess: async () => {
|
|
36246
36198
|
await allowanceQuery?.refetch();
|
|
36247
|
-
queryClient.invalidateQueries(
|
|
36199
|
+
queryClient.invalidateQueries({
|
|
36200
|
+
queryKey: getPrefixKey(QueryKeys.RouteApproved),
|
|
36201
|
+
});
|
|
36248
36202
|
// After an approval, we refetch the transaction query with all required parameters
|
|
36249
36203
|
// This is to ensure we're using the latest expiry timestamp
|
|
36250
36204
|
if (squidRoute) {
|
|
@@ -39364,8 +39318,10 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
39364
39318
|
}
|
|
39365
39319
|
}, [cosmosSigner, fromChain]);
|
|
39366
39320
|
const resetQueriesAfterTxSigned = () => {
|
|
39367
|
-
queryClient.refetchQueries(getPrefixKey(QueryKeys.Balance));
|
|
39368
|
-
queryClient.invalidateQueries(
|
|
39321
|
+
queryClient.refetchQueries({ queryKey: getPrefixKey(QueryKeys.Balance) });
|
|
39322
|
+
queryClient.invalidateQueries({
|
|
39323
|
+
queryKey: getPrefixKey(QueryKeys.Transaction),
|
|
39324
|
+
});
|
|
39369
39325
|
};
|
|
39370
39326
|
const dispatchSignatureRequestEvent = React.useCallback((route) => {
|
|
39371
39327
|
WidgetEvents.getInstance().dispatchSwapTxSignatureRequested({
|
|
@@ -39383,62 +39339,64 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
39383
39339
|
txHash,
|
|
39384
39340
|
}, findToken);
|
|
39385
39341
|
}, [findToken]);
|
|
39386
|
-
const swapMutationCosmos = reactQuery.useMutation(
|
|
39387
|
-
|
|
39388
|
-
|
|
39389
|
-
|
|
39390
|
-
|
|
39391
|
-
|
|
39392
|
-
|
|
39393
|
-
|
|
39394
|
-
|
|
39395
|
-
|
|
39396
|
-
|
|
39397
|
-
|
|
39398
|
-
|
|
39399
|
-
|
|
39400
|
-
|
|
39401
|
-
|
|
39402
|
-
|
|
39403
|
-
|
|
39404
|
-
|
|
39405
|
-
|
|
39406
|
-
|
|
39407
|
-
// broadcast the signed tx to get hash and listen to events
|
|
39408
|
-
const response = await signingClient.broadcastTx(tx.TxRaw.encode(tx$1).finish());
|
|
39409
|
-
const hash = response.transactionHash;
|
|
39410
|
-
if (hash) {
|
|
39411
|
-
resetQueriesAfterTxSigned();
|
|
39412
|
-
}
|
|
39413
|
-
// Dispatch event so it can be listened from outside the widget
|
|
39414
|
-
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, hash);
|
|
39415
|
-
const txParams = setTransactionState({
|
|
39416
|
-
route,
|
|
39417
|
-
txHash: hash,
|
|
39418
|
-
userAddress: sourceUserAddress,
|
|
39419
|
-
status: exports.TransactionStatus.ONGOING,
|
|
39420
|
-
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39421
|
-
axelarUrl: undefined,
|
|
39422
|
-
id,
|
|
39423
|
-
});
|
|
39424
|
-
if (txParams) {
|
|
39425
|
-
addSwapTransaction({
|
|
39426
|
-
...txParams,
|
|
39427
|
-
params: route.params,
|
|
39428
|
-
estimate: route.estimate,
|
|
39342
|
+
const swapMutationCosmos = reactQuery.useMutation({
|
|
39343
|
+
mutationFn: async ({ id, route }) => {
|
|
39344
|
+
const fromChainId = route?.params.fromChain;
|
|
39345
|
+
if (cosmosSigner && fromChainId) {
|
|
39346
|
+
try {
|
|
39347
|
+
const signingClient = await getCosmosSignerClient();
|
|
39348
|
+
const signerAddress = (await cosmosSigner.getAccounts())[0].address;
|
|
39349
|
+
if (signerAddress && signingClient && route) {
|
|
39350
|
+
dispatchSignatureRequestEvent(route);
|
|
39351
|
+
const tx$1 = (await squid?.executeRoute({
|
|
39352
|
+
signer: signingClient,
|
|
39353
|
+
signerAddress,
|
|
39354
|
+
route,
|
|
39355
|
+
}));
|
|
39356
|
+
// set the tx state to loading, as soon as user signed the tx
|
|
39357
|
+
setTransactionState({
|
|
39358
|
+
txHash: "",
|
|
39359
|
+
route,
|
|
39360
|
+
status: exports.TransactionStatus.ONGOING,
|
|
39361
|
+
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39362
|
+
id,
|
|
39429
39363
|
});
|
|
39364
|
+
// broadcast the signed tx to get hash and listen to events
|
|
39365
|
+
const response = await signingClient.broadcastTx(tx.TxRaw.encode(tx$1).finish());
|
|
39366
|
+
const hash = response.transactionHash;
|
|
39367
|
+
if (hash) {
|
|
39368
|
+
resetQueriesAfterTxSigned();
|
|
39369
|
+
}
|
|
39370
|
+
// Dispatch event so it can be listened from outside the widget
|
|
39371
|
+
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, hash);
|
|
39372
|
+
const txParams = setTransactionState({
|
|
39373
|
+
route,
|
|
39374
|
+
txHash: hash,
|
|
39375
|
+
userAddress: sourceUserAddress,
|
|
39376
|
+
status: exports.TransactionStatus.ONGOING,
|
|
39377
|
+
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39378
|
+
axelarUrl: undefined,
|
|
39379
|
+
id,
|
|
39380
|
+
});
|
|
39381
|
+
if (txParams) {
|
|
39382
|
+
addSwapTransaction({
|
|
39383
|
+
...txParams,
|
|
39384
|
+
params: route.params,
|
|
39385
|
+
estimate: route.estimate,
|
|
39386
|
+
});
|
|
39387
|
+
}
|
|
39388
|
+
return response.code === 0;
|
|
39430
39389
|
}
|
|
39431
|
-
return response.code === 0;
|
|
39432
39390
|
}
|
|
39433
|
-
|
|
39434
|
-
|
|
39435
|
-
|
|
39436
|
-
|
|
39437
|
-
|
|
39391
|
+
catch (error) {
|
|
39392
|
+
console.error("Error executing Cosmos transaction", error);
|
|
39393
|
+
if (isUserRejectionError(normalizeError(error))) {
|
|
39394
|
+
throw new Error("Request rejected");
|
|
39395
|
+
}
|
|
39438
39396
|
}
|
|
39439
39397
|
}
|
|
39440
|
-
|
|
39441
|
-
|
|
39398
|
+
throw new Error("Need all parameters");
|
|
39399
|
+
},
|
|
39442
39400
|
});
|
|
39443
39401
|
// If the transaction is replaced, we need to update the transaction hash
|
|
39444
39402
|
// Transaction replaced can mean that the user has speed up the transaction for example
|
|
@@ -39491,97 +39449,126 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
39491
39449
|
throw error;
|
|
39492
39450
|
}
|
|
39493
39451
|
}, [replaceSwapTransactionNonce, setTransactionState, sourceUserAddress]);
|
|
39494
|
-
const swapMutationEvm = reactQuery.useMutation(
|
|
39495
|
-
|
|
39496
|
-
|
|
39497
|
-
|
|
39498
|
-
|
|
39499
|
-
|
|
39500
|
-
|
|
39501
|
-
|
|
39502
|
-
|
|
39503
|
-
|
|
39504
|
-
}));
|
|
39505
|
-
let hash = txResponse.hash;
|
|
39506
|
-
if (activeConnector?.id === "safe") {
|
|
39507
|
-
hash = await getGnosisTransactionHash(txResponse.hash);
|
|
39508
|
-
}
|
|
39509
|
-
if (hash) {
|
|
39510
|
-
resetQueriesAfterTxSigned();
|
|
39511
|
-
}
|
|
39512
|
-
// Dispatch event so it can be listened from outside the widget
|
|
39513
|
-
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, hash);
|
|
39514
|
-
if (route.transactionRequest) {
|
|
39515
|
-
const txParams = setTransactionState({
|
|
39452
|
+
const swapMutationEvm = reactQuery.useMutation({
|
|
39453
|
+
mutationFn: async ({ id, route }) => {
|
|
39454
|
+
await changeNetworkIfNeeded.mutateAsync();
|
|
39455
|
+
if (!route || !squid || !evmSigner) {
|
|
39456
|
+
throw new Error("Need all parameters");
|
|
39457
|
+
}
|
|
39458
|
+
dispatchSignatureRequestEvent(route);
|
|
39459
|
+
const txResponse = (await squid.executeRoute({
|
|
39460
|
+
bypassBalanceChecks: true,
|
|
39461
|
+
signer: evmSigner,
|
|
39516
39462
|
route,
|
|
39517
|
-
|
|
39518
|
-
|
|
39519
|
-
|
|
39520
|
-
|
|
39521
|
-
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39522
|
-
axelarUrl: undefined,
|
|
39523
|
-
id,
|
|
39524
|
-
});
|
|
39525
|
-
if (txParams) {
|
|
39526
|
-
addSwapTransaction({
|
|
39527
|
-
...txParams,
|
|
39528
|
-
params: route.params,
|
|
39529
|
-
estimate: route.estimate,
|
|
39530
|
-
});
|
|
39463
|
+
}));
|
|
39464
|
+
let hash = txResponse.hash;
|
|
39465
|
+
if (activeConnector?.id === "safe") {
|
|
39466
|
+
hash = await getGnosisTransactionHash(txResponse.hash);
|
|
39531
39467
|
}
|
|
39532
|
-
|
|
39533
|
-
|
|
39534
|
-
if (isProblematicConnector(activeConnector)) {
|
|
39535
|
-
await sleep(3_000);
|
|
39468
|
+
if (hash) {
|
|
39469
|
+
resetQueriesAfterTxSigned();
|
|
39536
39470
|
}
|
|
39537
|
-
|
|
39538
|
-
|
|
39539
|
-
|
|
39540
|
-
|
|
39541
|
-
|
|
39542
|
-
|
|
39543
|
-
|
|
39544
|
-
|
|
39545
|
-
|
|
39546
|
-
|
|
39547
|
-
|
|
39548
|
-
|
|
39549
|
-
|
|
39550
|
-
|
|
39551
|
-
|
|
39552
|
-
|
|
39553
|
-
|
|
39554
|
-
|
|
39555
|
-
|
|
39471
|
+
// Dispatch event so it can be listened from outside the widget
|
|
39472
|
+
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, hash);
|
|
39473
|
+
if (route.transactionRequest) {
|
|
39474
|
+
const txParams = setTransactionState({
|
|
39475
|
+
route,
|
|
39476
|
+
txHash: hash,
|
|
39477
|
+
nonce: txResponse.nonce,
|
|
39478
|
+
userAddress: sourceUserAddress,
|
|
39479
|
+
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
39480
|
+
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39481
|
+
axelarUrl: undefined,
|
|
39482
|
+
id,
|
|
39483
|
+
});
|
|
39484
|
+
if (txParams) {
|
|
39485
|
+
addSwapTransaction({
|
|
39486
|
+
...txParams,
|
|
39487
|
+
params: route.params,
|
|
39488
|
+
estimate: route.estimate,
|
|
39489
|
+
});
|
|
39490
|
+
}
|
|
39556
39491
|
}
|
|
39557
|
-
|
|
39558
|
-
|
|
39492
|
+
try {
|
|
39493
|
+
if (isProblematicConnector(activeConnector)) {
|
|
39494
|
+
await sleep(3_000);
|
|
39495
|
+
}
|
|
39496
|
+
const response = await txResponse.wait();
|
|
39497
|
+
return response;
|
|
39559
39498
|
}
|
|
39560
|
-
|
|
39561
|
-
|
|
39499
|
+
catch (error) {
|
|
39500
|
+
return handleTransactionReplacementError({
|
|
39501
|
+
error,
|
|
39502
|
+
route,
|
|
39503
|
+
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
39504
|
+
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39505
|
+
userAddress: sourceUserAddress,
|
|
39506
|
+
axelarUrl: undefined,
|
|
39507
|
+
id,
|
|
39508
|
+
});
|
|
39562
39509
|
}
|
|
39563
|
-
|
|
39564
|
-
|
|
39565
|
-
|
|
39566
|
-
|
|
39567
|
-
|
|
39568
|
-
|
|
39569
|
-
|
|
39570
|
-
|
|
39571
|
-
|
|
39510
|
+
},
|
|
39511
|
+
});
|
|
39512
|
+
const swapMutationSolana = reactQuery.useMutation({
|
|
39513
|
+
mutationFn: async ({ id, route }) => {
|
|
39514
|
+
try {
|
|
39515
|
+
if (!route) {
|
|
39516
|
+
throw new Error("Route is required");
|
|
39517
|
+
}
|
|
39518
|
+
if (!solanaSigner) {
|
|
39519
|
+
throw new Error("Solana signer is required");
|
|
39520
|
+
}
|
|
39521
|
+
if (!route.params.fromAddress || !route.params.toAddress) {
|
|
39522
|
+
throw new Error("From or to address is required");
|
|
39523
|
+
}
|
|
39524
|
+
const isDirectTransfer = isDepositRoute(route);
|
|
39525
|
+
// Means it's a transfer to a deposit address
|
|
39526
|
+
// Instead of a Swap/Contract call using a DEX like Jupiter
|
|
39527
|
+
if (isDirectTransfer) {
|
|
39528
|
+
// Get the deposit address from the squidRoute
|
|
39529
|
+
const depositData = useDepositAddressStore.getState().deposit;
|
|
39530
|
+
// Validate params
|
|
39531
|
+
if (!depositData?.depositAddress) {
|
|
39532
|
+
throw new Error("Deposit address is required");
|
|
39533
|
+
}
|
|
39534
|
+
const signature = await executeSolanaTransfer({
|
|
39535
|
+
amount: BigInt(route.params.fromAmount),
|
|
39536
|
+
target: depositData.depositAddress,
|
|
39537
|
+
signer: solanaSigner,
|
|
39538
|
+
connection: solanaConnection,
|
|
39539
|
+
sourceToken: findToken(route.params.fromToken, route?.params?.fromChain),
|
|
39540
|
+
onSigned: (txHash) => {
|
|
39541
|
+
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
|
|
39542
|
+
const txParams = setTransactionState({
|
|
39543
|
+
route,
|
|
39544
|
+
txHash,
|
|
39545
|
+
transactionIdForStatus: depositData.chainflipStatusTrackingId,
|
|
39546
|
+
userAddress: sourceUserAddress,
|
|
39547
|
+
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
39548
|
+
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39549
|
+
id,
|
|
39550
|
+
});
|
|
39551
|
+
if (txParams) {
|
|
39552
|
+
addSwapTransaction({
|
|
39553
|
+
...txParams,
|
|
39554
|
+
params: route.params,
|
|
39555
|
+
estimate: route.estimate,
|
|
39556
|
+
});
|
|
39557
|
+
}
|
|
39558
|
+
},
|
|
39559
|
+
});
|
|
39560
|
+
return signature;
|
|
39572
39561
|
}
|
|
39573
|
-
const signature = await
|
|
39574
|
-
|
|
39575
|
-
target: depositData.depositAddress,
|
|
39562
|
+
const signature = await executeSolanaSwap({
|
|
39563
|
+
route,
|
|
39576
39564
|
signer: solanaSigner,
|
|
39577
39565
|
connection: solanaConnection,
|
|
39578
|
-
sourceToken: findToken(route.params.fromToken, route?.params?.fromChain),
|
|
39579
39566
|
onSigned: (txHash) => {
|
|
39580
39567
|
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
|
|
39581
39568
|
const txParams = setTransactionState({
|
|
39582
39569
|
route,
|
|
39583
39570
|
txHash,
|
|
39584
|
-
transactionIdForStatus:
|
|
39571
|
+
transactionIdForStatus: undefined,
|
|
39585
39572
|
userAddress: sourceUserAddress,
|
|
39586
39573
|
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
39587
39574
|
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
@@ -39598,39 +39585,13 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
39598
39585
|
});
|
|
39599
39586
|
return signature;
|
|
39600
39587
|
}
|
|
39601
|
-
|
|
39602
|
-
|
|
39603
|
-
|
|
39604
|
-
|
|
39605
|
-
|
|
39606
|
-
|
|
39607
|
-
|
|
39608
|
-
route,
|
|
39609
|
-
txHash,
|
|
39610
|
-
transactionIdForStatus: undefined,
|
|
39611
|
-
userAddress: sourceUserAddress,
|
|
39612
|
-
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
39613
|
-
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39614
|
-
id,
|
|
39615
|
-
});
|
|
39616
|
-
if (txParams) {
|
|
39617
|
-
addSwapTransaction({
|
|
39618
|
-
...txParams,
|
|
39619
|
-
params: route.params,
|
|
39620
|
-
estimate: route.estimate,
|
|
39621
|
-
});
|
|
39622
|
-
}
|
|
39623
|
-
},
|
|
39624
|
-
});
|
|
39625
|
-
return signature;
|
|
39626
|
-
}
|
|
39627
|
-
catch (error) {
|
|
39628
|
-
console.error("Solana transaction failed:", error);
|
|
39629
|
-
throw error instanceof Error
|
|
39630
|
-
? error
|
|
39631
|
-
: new Error("Failed to execute Solana transaction");
|
|
39632
|
-
}
|
|
39633
|
-
}, {
|
|
39588
|
+
catch (error) {
|
|
39589
|
+
console.error("Solana transaction failed:", error);
|
|
39590
|
+
throw error instanceof Error
|
|
39591
|
+
? error
|
|
39592
|
+
: new Error("Failed to execute Solana transaction");
|
|
39593
|
+
}
|
|
39594
|
+
},
|
|
39634
39595
|
onError: (error, variables) => {
|
|
39635
39596
|
const currentTx = getTransaction(variables.id);
|
|
39636
39597
|
const errorObject = getTransactionError(error);
|
|
@@ -39651,7 +39612,9 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
39651
39612
|
},
|
|
39652
39613
|
onSuccess: (_data, variables) => {
|
|
39653
39614
|
const currentTx = getTransaction(variables.id);
|
|
39654
|
-
queryClient.invalidateQueries(
|
|
39615
|
+
queryClient.invalidateQueries({
|
|
39616
|
+
queryKey: getPrefixKey(QueryKeys.Balances),
|
|
39617
|
+
});
|
|
39655
39618
|
if (isSameChain && currentTx?.transactionId) {
|
|
39656
39619
|
replaceSwapTransactionStatus({
|
|
39657
39620
|
transactionId: currentTx.transactionId,
|
|
@@ -39668,197 +39631,207 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
39668
39631
|
});
|
|
39669
39632
|
},
|
|
39670
39633
|
});
|
|
39671
|
-
const swapMutationBitcoin = reactQuery.useMutation(
|
|
39672
|
-
|
|
39673
|
-
|
|
39674
|
-
|
|
39675
|
-
|
|
39676
|
-
|
|
39677
|
-
|
|
39678
|
-
|
|
39679
|
-
|
|
39680
|
-
|
|
39681
|
-
|
|
39682
|
-
|
|
39683
|
-
|
|
39634
|
+
const swapMutationBitcoin = reactQuery.useMutation({
|
|
39635
|
+
mutationFn: async ({ id, route }) => {
|
|
39636
|
+
const { depositAddress, amount: sendAmount, chainflipStatusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
|
|
39637
|
+
if (!depositAddress) {
|
|
39638
|
+
throw new Error(`Invalid deposit address: ${depositAddress}`);
|
|
39639
|
+
}
|
|
39640
|
+
if (!sendAmount) {
|
|
39641
|
+
throw new Error(`Invalid send amount: ${sendAmount}`);
|
|
39642
|
+
}
|
|
39643
|
+
const allParamsValid = route && bitcoinSigner && depositAddress && sendAmount;
|
|
39644
|
+
await changeNetworkIfNeeded.mutateAsync();
|
|
39645
|
+
if (allParamsValid) {
|
|
39646
|
+
dispatchSignatureRequestEvent(route);
|
|
39647
|
+
const { txHash } = await bitcoinSigner.sendBTC(depositAddress, Number(sendAmount));
|
|
39648
|
+
if (txHash) {
|
|
39649
|
+
resetQueriesAfterTxSigned();
|
|
39650
|
+
}
|
|
39651
|
+
// Dispatch event so it can be listened from outside the widget
|
|
39652
|
+
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
|
|
39653
|
+
if (route.transactionRequest) {
|
|
39654
|
+
const txParams = setTransactionState({
|
|
39655
|
+
route,
|
|
39656
|
+
txHash,
|
|
39657
|
+
// When bridging from Bitcoin we need to send the chainflipId to the status endpoint
|
|
39658
|
+
// instead of the Bitcoin transaction hash
|
|
39659
|
+
transactionIdForStatus: chainflipStatusTrackingId,
|
|
39660
|
+
userAddress: sourceUserAddress,
|
|
39661
|
+
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
39662
|
+
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39663
|
+
axelarUrl: undefined,
|
|
39664
|
+
id,
|
|
39665
|
+
});
|
|
39666
|
+
if (txParams) {
|
|
39667
|
+
addSwapTransaction({
|
|
39668
|
+
...txParams,
|
|
39669
|
+
params: route.params,
|
|
39670
|
+
estimate: route.estimate,
|
|
39671
|
+
});
|
|
39672
|
+
}
|
|
39673
|
+
}
|
|
39674
|
+
}
|
|
39675
|
+
else {
|
|
39676
|
+
throw new Error("Need all parameters");
|
|
39677
|
+
}
|
|
39678
|
+
},
|
|
39679
|
+
});
|
|
39680
|
+
const swapMutationXrpl = reactQuery.useMutation({
|
|
39681
|
+
mutationFn: async ({ id, route }) => {
|
|
39682
|
+
if (!route?.transactionRequest || !xrplSigner) {
|
|
39683
|
+
throw new Error("Need all parameters");
|
|
39684
|
+
}
|
|
39685
|
+
if (route.transactionRequest.type !== squidTypes.SquidDataType.OnChainExecution) {
|
|
39686
|
+
throw new Error("Invalid route type");
|
|
39687
|
+
}
|
|
39688
|
+
const { data } = route.transactionRequest;
|
|
39689
|
+
const paymentTx = parseXrplPaymentTx(data);
|
|
39690
|
+
if (!paymentTx)
|
|
39691
|
+
throw new Error("Could not parse transaction");
|
|
39692
|
+
const fromChainId = route.params.fromChain;
|
|
39693
|
+
const xrplNetwork = getXrplNetwork(fromChainId);
|
|
39694
|
+
if (xrplNetwork == null) {
|
|
39695
|
+
throw new Error(`No XRPL network found for chainId '${fromChainId}'`);
|
|
39696
|
+
}
|
|
39697
|
+
const txRes = await xrplSigner.signAndSubmit({
|
|
39698
|
+
tx: paymentTx,
|
|
39699
|
+
network: xrplNetwork,
|
|
39700
|
+
});
|
|
39701
|
+
const txParams = setTransactionState({
|
|
39702
|
+
txHash: txRes.hash,
|
|
39703
|
+
id,
|
|
39704
|
+
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39705
|
+
status: exports.TransactionStatus.ONGOING,
|
|
39706
|
+
route: route,
|
|
39707
|
+
userAddress: sourceUserAddress,
|
|
39708
|
+
});
|
|
39709
|
+
if (txParams && route) {
|
|
39710
|
+
addSwapTransaction({
|
|
39711
|
+
...txParams,
|
|
39712
|
+
params: route.params,
|
|
39713
|
+
estimate: route.estimate,
|
|
39714
|
+
});
|
|
39715
|
+
}
|
|
39716
|
+
if (txRes.status !== XrplTxStatus.SUCCESS) {
|
|
39717
|
+
throw new Error(`Transaction failed with status: ${txRes.status}`);
|
|
39718
|
+
}
|
|
39719
|
+
},
|
|
39720
|
+
});
|
|
39721
|
+
const swapMutationSui = reactQuery.useMutation({
|
|
39722
|
+
mutationFn: async ({ id, route }) => {
|
|
39723
|
+
if (!route || !suiSigner || !fromChain) {
|
|
39724
|
+
throw new Error("Need all parameters");
|
|
39725
|
+
}
|
|
39726
|
+
if (route.transactionRequest?.type !== squidTypes.SquidDataType.OnChainExecution) {
|
|
39727
|
+
throw new Error("Invalid route type");
|
|
39728
|
+
}
|
|
39729
|
+
const suiWalletState = connectedWalletsByChainType[squidTypes.ChainType.SUI];
|
|
39730
|
+
if (!suiWalletState.account) {
|
|
39731
|
+
throw new Error("Sui wallet is missing account data");
|
|
39732
|
+
}
|
|
39733
|
+
const fromChainId = route.params.fromChain;
|
|
39734
|
+
const suiChain = getSuiChain(fromChainId);
|
|
39735
|
+
if (!suiChain) {
|
|
39736
|
+
throw new Error(`Source chain (${fromChainId}) does not match any Sui chain`);
|
|
39737
|
+
}
|
|
39738
|
+
const suiClient = await getClient(fromChain);
|
|
39739
|
+
const txJson = route.transactionRequest.data;
|
|
39740
|
+
const tx = transactions.Transaction.from(txJson);
|
|
39741
|
+
const signedTx = await suiSigner.signTransaction({
|
|
39742
|
+
transaction: tx,
|
|
39743
|
+
account: suiWalletState.account,
|
|
39744
|
+
chain: suiChain,
|
|
39745
|
+
});
|
|
39746
|
+
// execute transaction without waiting for confirmation
|
|
39747
|
+
const txResponse = await suiClient.executeTransactionBlock({
|
|
39748
|
+
signature: signedTx.signature,
|
|
39749
|
+
transactionBlock: signedTx.bytes,
|
|
39750
|
+
});
|
|
39751
|
+
const txHash = txResponse.digest;
|
|
39684
39752
|
if (txHash) {
|
|
39685
39753
|
resetQueriesAfterTxSigned();
|
|
39686
39754
|
}
|
|
39687
|
-
// Dispatch event so it can be listened from outside the widget
|
|
39688
39755
|
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
|
|
39689
|
-
|
|
39690
|
-
|
|
39691
|
-
|
|
39692
|
-
|
|
39693
|
-
|
|
39694
|
-
|
|
39695
|
-
|
|
39696
|
-
|
|
39697
|
-
|
|
39698
|
-
|
|
39699
|
-
|
|
39700
|
-
|
|
39756
|
+
const txParams = setTransactionState({
|
|
39757
|
+
route,
|
|
39758
|
+
txHash,
|
|
39759
|
+
userAddress: sourceUserAddress,
|
|
39760
|
+
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
39761
|
+
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39762
|
+
id,
|
|
39763
|
+
});
|
|
39764
|
+
if (txParams) {
|
|
39765
|
+
addSwapTransaction({
|
|
39766
|
+
...txParams,
|
|
39767
|
+
params: route.params,
|
|
39768
|
+
estimate: route.estimate,
|
|
39701
39769
|
});
|
|
39702
|
-
if (txParams) {
|
|
39703
|
-
addSwapTransaction({
|
|
39704
|
-
...txParams,
|
|
39705
|
-
params: route.params,
|
|
39706
|
-
estimate: route.estimate,
|
|
39707
|
-
});
|
|
39708
|
-
}
|
|
39709
39770
|
}
|
|
39710
|
-
|
|
39711
|
-
|
|
39712
|
-
|
|
39713
|
-
}
|
|
39714
|
-
});
|
|
39715
|
-
const swapMutationXrpl = reactQuery.useMutation(async ({ id, route }) => {
|
|
39716
|
-
if (!route?.transactionRequest || !xrplSigner) {
|
|
39717
|
-
throw new Error("Need all parameters");
|
|
39718
|
-
}
|
|
39719
|
-
if (route.transactionRequest.type !== squidTypes.SquidDataType.OnChainExecution) {
|
|
39720
|
-
throw new Error("Invalid route type");
|
|
39721
|
-
}
|
|
39722
|
-
const { data } = route.transactionRequest;
|
|
39723
|
-
const paymentTx = parseXrplPaymentTx(data);
|
|
39724
|
-
if (!paymentTx)
|
|
39725
|
-
throw new Error("Could not parse transaction");
|
|
39726
|
-
const fromChainId = route.params.fromChain;
|
|
39727
|
-
const xrplNetwork = getXrplNetwork(fromChainId);
|
|
39728
|
-
if (xrplNetwork == null) {
|
|
39729
|
-
throw new Error(`No XRPL network found for chainId '${fromChainId}'`);
|
|
39730
|
-
}
|
|
39731
|
-
const txRes = await xrplSigner.signAndSubmit({
|
|
39732
|
-
tx: paymentTx,
|
|
39733
|
-
network: xrplNetwork,
|
|
39734
|
-
});
|
|
39735
|
-
const txParams = setTransactionState({
|
|
39736
|
-
txHash: txRes.hash,
|
|
39737
|
-
id,
|
|
39738
|
-
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39739
|
-
status: exports.TransactionStatus.ONGOING,
|
|
39740
|
-
route: route,
|
|
39741
|
-
userAddress: sourceUserAddress,
|
|
39742
|
-
});
|
|
39743
|
-
if (txParams && route) {
|
|
39744
|
-
addSwapTransaction({
|
|
39745
|
-
...txParams,
|
|
39746
|
-
params: route.params,
|
|
39747
|
-
estimate: route.estimate,
|
|
39771
|
+
// wait for transaction confirmation
|
|
39772
|
+
await suiClient.waitForTransaction({
|
|
39773
|
+
digest: txHash,
|
|
39748
39774
|
});
|
|
39749
|
-
}
|
|
39750
|
-
|
|
39751
|
-
|
|
39752
|
-
}
|
|
39753
|
-
|
|
39754
|
-
|
|
39755
|
-
|
|
39756
|
-
|
|
39757
|
-
|
|
39758
|
-
|
|
39759
|
-
|
|
39760
|
-
|
|
39761
|
-
|
|
39762
|
-
|
|
39763
|
-
|
|
39764
|
-
|
|
39765
|
-
|
|
39766
|
-
|
|
39767
|
-
|
|
39768
|
-
|
|
39769
|
-
|
|
39770
|
-
|
|
39771
|
-
|
|
39772
|
-
|
|
39773
|
-
|
|
39774
|
-
|
|
39775
|
-
|
|
39776
|
-
chain: suiChain,
|
|
39777
|
-
});
|
|
39778
|
-
// execute transaction without waiting for confirmation
|
|
39779
|
-
const txResponse = await suiClient.executeTransactionBlock({
|
|
39780
|
-
signature: signedTx.signature,
|
|
39781
|
-
transactionBlock: signedTx.bytes,
|
|
39782
|
-
});
|
|
39783
|
-
const txHash = txResponse.digest;
|
|
39784
|
-
if (txHash) {
|
|
39785
|
-
resetQueriesAfterTxSigned();
|
|
39786
|
-
}
|
|
39787
|
-
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
|
|
39788
|
-
const txParams = setTransactionState({
|
|
39789
|
-
route,
|
|
39790
|
-
txHash,
|
|
39791
|
-
userAddress: sourceUserAddress,
|
|
39792
|
-
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
39793
|
-
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39794
|
-
id,
|
|
39795
|
-
});
|
|
39796
|
-
if (txParams) {
|
|
39797
|
-
addSwapTransaction({
|
|
39798
|
-
...txParams,
|
|
39799
|
-
params: route.params,
|
|
39800
|
-
estimate: route.estimate,
|
|
39775
|
+
},
|
|
39776
|
+
});
|
|
39777
|
+
const swapMutationStellar = reactQuery.useMutation({
|
|
39778
|
+
mutationFn: async ({ id, route }) => {
|
|
39779
|
+
if (!stellarSigner || !route || !squid || !fromChain) {
|
|
39780
|
+
throw new Error("Need all parameters");
|
|
39781
|
+
}
|
|
39782
|
+
const fromChainId = route.params.fromChain;
|
|
39783
|
+
const stellarNetwork = getStellarNetwork(fromChainId);
|
|
39784
|
+
if (stellarNetwork == null) {
|
|
39785
|
+
throw new Error(`No Stellar network found for chainId ${fromChainId}`);
|
|
39786
|
+
}
|
|
39787
|
+
const { data: xdrHex, gasPrice } = route.transactionRequest;
|
|
39788
|
+
const { address } = await stellarSigner.getAddress();
|
|
39789
|
+
const client = await getClient(fromChain);
|
|
39790
|
+
const account = await client.getAccount(address);
|
|
39791
|
+
const operation = stellarSdk.xdr.Operation.fromXDR(xdrHex, "hex");
|
|
39792
|
+
const builtTransaction = new stellarSdk.TransactionBuilder(account, {
|
|
39793
|
+
fee: gasPrice || (BigInt(stellarSdk.BASE_FEE) * BigInt(2)).toString(),
|
|
39794
|
+
networkPassphrase: stellarNetwork,
|
|
39795
|
+
})
|
|
39796
|
+
.addOperation(operation)
|
|
39797
|
+
.setTimeout(300)
|
|
39798
|
+
.build();
|
|
39799
|
+
const preparedTransaction = await client.prepareTransaction(builtTransaction);
|
|
39800
|
+
const { signedTxXdr } = await stellarSigner.signTransaction(preparedTransaction.toXDR(), {
|
|
39801
|
+
networkPassphrase: stellarNetwork,
|
|
39801
39802
|
});
|
|
39802
|
-
|
|
39803
|
-
|
|
39804
|
-
|
|
39805
|
-
|
|
39806
|
-
|
|
39807
|
-
|
|
39808
|
-
|
|
39809
|
-
|
|
39810
|
-
|
|
39811
|
-
|
|
39812
|
-
|
|
39813
|
-
|
|
39814
|
-
|
|
39815
|
-
|
|
39816
|
-
|
|
39817
|
-
const { data: xdrHex, gasPrice } = route.transactionRequest;
|
|
39818
|
-
const { address } = await stellarSigner.getAddress();
|
|
39819
|
-
const client = await getClient(fromChain);
|
|
39820
|
-
const account = await client.getAccount(address);
|
|
39821
|
-
const operation = stellarSdk.xdr.Operation.fromXDR(xdrHex, "hex");
|
|
39822
|
-
const builtTransaction = new stellarSdk.TransactionBuilder(account, {
|
|
39823
|
-
fee: gasPrice || (BigInt(stellarSdk.BASE_FEE) * BigInt(2)).toString(),
|
|
39824
|
-
networkPassphrase: stellarNetwork,
|
|
39825
|
-
})
|
|
39826
|
-
.addOperation(operation)
|
|
39827
|
-
.setTimeout(300)
|
|
39828
|
-
.build();
|
|
39829
|
-
const preparedTransaction = await client.prepareTransaction(builtTransaction);
|
|
39830
|
-
const { signedTxXdr } = await stellarSigner.signTransaction(preparedTransaction.toXDR(), {
|
|
39831
|
-
networkPassphrase: stellarNetwork,
|
|
39832
|
-
});
|
|
39833
|
-
const signedTransaction = new stellarSdk.Transaction(signedTxXdr, stellarNetwork);
|
|
39834
|
-
// get hash before submitting
|
|
39835
|
-
const hash = signedTransaction.hash().toString("hex");
|
|
39836
|
-
if (hash) {
|
|
39837
|
-
resetQueriesAfterTxSigned();
|
|
39838
|
-
}
|
|
39839
|
-
// Dispatch event so it can be listened from outside the widget
|
|
39840
|
-
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, hash);
|
|
39841
|
-
const txParams = setTransactionState({
|
|
39842
|
-
route,
|
|
39843
|
-
txHash: hash,
|
|
39844
|
-
userAddress: sourceUserAddress,
|
|
39845
|
-
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
39846
|
-
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39847
|
-
id,
|
|
39848
|
-
});
|
|
39849
|
-
if (txParams) {
|
|
39850
|
-
addSwapTransaction({
|
|
39851
|
-
...txParams,
|
|
39852
|
-
params: route.params,
|
|
39853
|
-
estimate: route.estimate,
|
|
39803
|
+
const signedTransaction = new stellarSdk.Transaction(signedTxXdr, stellarNetwork);
|
|
39804
|
+
// get hash before submitting
|
|
39805
|
+
const hash = signedTransaction.hash().toString("hex");
|
|
39806
|
+
if (hash) {
|
|
39807
|
+
resetQueriesAfterTxSigned();
|
|
39808
|
+
}
|
|
39809
|
+
// Dispatch event so it can be listened from outside the widget
|
|
39810
|
+
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, hash);
|
|
39811
|
+
const txParams = setTransactionState({
|
|
39812
|
+
route,
|
|
39813
|
+
txHash: hash,
|
|
39814
|
+
userAddress: sourceUserAddress,
|
|
39815
|
+
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
39816
|
+
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
39817
|
+
id,
|
|
39854
39818
|
});
|
|
39855
|
-
|
|
39856
|
-
|
|
39857
|
-
|
|
39858
|
-
|
|
39819
|
+
if (txParams) {
|
|
39820
|
+
addSwapTransaction({
|
|
39821
|
+
...txParams,
|
|
39822
|
+
params: route.params,
|
|
39823
|
+
estimate: route.estimate,
|
|
39824
|
+
});
|
|
39825
|
+
}
|
|
39826
|
+
const sentTransaction = await client.sendTransaction(signedTransaction);
|
|
39827
|
+
await client.waitForTransaction(sentTransaction.hash);
|
|
39828
|
+
},
|
|
39829
|
+
});
|
|
39859
39830
|
const handleTransactionSuccess = React.useCallback((id) => {
|
|
39860
39831
|
const currentTx = getTransaction(id);
|
|
39861
|
-
queryClient.invalidateQueries(
|
|
39832
|
+
queryClient.invalidateQueries({
|
|
39833
|
+
queryKey: getPrefixKey(QueryKeys.Balances),
|
|
39834
|
+
});
|
|
39862
39835
|
if (isSameChain && currentTx?.transactionId) {
|
|
39863
39836
|
replaceSwapTransactionStatus({
|
|
39864
39837
|
transactionId: currentTx.transactionId,
|
|
@@ -39910,38 +39883,39 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
39910
39883
|
setTransactionStoreState,
|
|
39911
39884
|
squidRoute,
|
|
39912
39885
|
]);
|
|
39913
|
-
const swapMutation = reactQuery.useMutation(
|
|
39914
|
-
|
|
39915
|
-
|
|
39916
|
-
|
|
39917
|
-
|
|
39918
|
-
|
|
39919
|
-
|
|
39920
|
-
|
|
39921
|
-
|
|
39922
|
-
|
|
39923
|
-
|
|
39924
|
-
|
|
39925
|
-
|
|
39926
|
-
|
|
39927
|
-
|
|
39928
|
-
|
|
39929
|
-
|
|
39930
|
-
|
|
39931
|
-
|
|
39932
|
-
|
|
39933
|
-
|
|
39934
|
-
|
|
39935
|
-
|
|
39936
|
-
|
|
39937
|
-
|
|
39938
|
-
|
|
39939
|
-
|
|
39886
|
+
const swapMutation = reactQuery.useMutation({
|
|
39887
|
+
mutationFn: async (mutationParams) => {
|
|
39888
|
+
if (!mutationParams.route)
|
|
39889
|
+
throw new Error("route is required");
|
|
39890
|
+
const sourceChain = findChain(mutationParams.route.params?.fromChain);
|
|
39891
|
+
if (!sourceChain)
|
|
39892
|
+
throw new Error("Could not find source chain");
|
|
39893
|
+
switch (sourceChain.chainType) {
|
|
39894
|
+
case squidTypes.ChainType.COSMOS: {
|
|
39895
|
+
return swapMutationCosmos.mutateAsync(mutationParams);
|
|
39896
|
+
}
|
|
39897
|
+
case squidTypes.ChainType.EVM: {
|
|
39898
|
+
return swapMutationEvm.mutateAsync(mutationParams);
|
|
39899
|
+
}
|
|
39900
|
+
case squidTypes.ChainType.BTC: {
|
|
39901
|
+
return swapMutationBitcoin.mutateAsync(mutationParams);
|
|
39902
|
+
}
|
|
39903
|
+
case squidTypes.ChainType.SOLANA: {
|
|
39904
|
+
return swapMutationSolana.mutateAsync(mutationParams);
|
|
39905
|
+
}
|
|
39906
|
+
case squidTypes.ChainType.SUI: {
|
|
39907
|
+
return swapMutationSui.mutateAsync(mutationParams);
|
|
39908
|
+
}
|
|
39909
|
+
case squidTypes.ChainType.XRPL: {
|
|
39910
|
+
return swapMutationXrpl.mutateAsync(mutationParams);
|
|
39911
|
+
}
|
|
39912
|
+
case squidTypes.ChainType.STELLAR: {
|
|
39913
|
+
return swapMutationStellar.mutateAsync(mutationParams);
|
|
39914
|
+
}
|
|
39915
|
+
default:
|
|
39916
|
+
throw new Error(`Swap mutation not implemented for chain type: ${sourceChain.chainType}`);
|
|
39940
39917
|
}
|
|
39941
|
-
|
|
39942
|
-
throw new Error(`Swap mutation not implemented for chain type: ${sourceChain.chainType}`);
|
|
39943
|
-
}
|
|
39944
|
-
}, {
|
|
39918
|
+
},
|
|
39945
39919
|
onMutate: (variables) => {
|
|
39946
39920
|
useTransactionStore.setState({
|
|
39947
39921
|
txLocalId: variables.id,
|
|
@@ -39990,7 +39964,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
39990
39964
|
toToken,
|
|
39991
39965
|
toChain,
|
|
39992
39966
|
fromChain,
|
|
39993
|
-
|
|
39967
|
+
isPending: swapMutation.isPending,
|
|
39994
39968
|
error: swapMutation.error,
|
|
39995
39969
|
};
|
|
39996
39970
|
};
|
|
@@ -40051,57 +40025,59 @@ const useGetRoute = () => {
|
|
|
40051
40025
|
* These data will be used to trigger the transaction
|
|
40052
40026
|
* @returns {Route} Route data
|
|
40053
40027
|
*/
|
|
40054
|
-
return reactQuery.useMutation(
|
|
40055
|
-
|
|
40056
|
-
|
|
40057
|
-
|
|
40058
|
-
|
|
40059
|
-
|
|
40060
|
-
|
|
40061
|
-
|
|
40062
|
-
|
|
40063
|
-
|
|
40064
|
-
|
|
40065
|
-
|
|
40066
|
-
|
|
40067
|
-
|
|
40068
|
-
|
|
40069
|
-
|
|
40070
|
-
|
|
40071
|
-
|
|
40072
|
-
|
|
40073
|
-
|
|
40074
|
-
|
|
40075
|
-
|
|
40076
|
-
|
|
40077
|
-
|
|
40078
|
-
|
|
40079
|
-
|
|
40080
|
-
|
|
40081
|
-
|
|
40082
|
-
|
|
40083
|
-
|
|
40084
|
-
|
|
40085
|
-
|
|
40086
|
-
|
|
40087
|
-
|
|
40088
|
-
|
|
40089
|
-
|
|
40090
|
-
|
|
40091
|
-
cosmosFallbackAddresses
|
|
40092
|
-
|
|
40093
|
-
|
|
40094
|
-
|
|
40095
|
-
|
|
40096
|
-
|
|
40097
|
-
|
|
40098
|
-
|
|
40099
|
-
|
|
40100
|
-
|
|
40101
|
-
|
|
40028
|
+
return reactQuery.useMutation({
|
|
40029
|
+
mutationFn: async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice, bypassGuardrails, quoteOnly, fromChainType, postHook, preHook, }) => {
|
|
40030
|
+
if (!fromChain || !toChain || !fromToken || !toToken || !fromPrice) {
|
|
40031
|
+
return undefined;
|
|
40032
|
+
}
|
|
40033
|
+
// Dispatch requestQuote event
|
|
40034
|
+
dispatchRequestQuoteEvent({
|
|
40035
|
+
fromChain,
|
|
40036
|
+
toChain,
|
|
40037
|
+
fromToken: fromToken.address,
|
|
40038
|
+
toToken: toToken.address,
|
|
40039
|
+
fromAmount: fromPrice,
|
|
40040
|
+
fromAddress: sourceUserAddress,
|
|
40041
|
+
toAddress: destinationAddress,
|
|
40042
|
+
});
|
|
40043
|
+
const isEvmSwap = Number(fromChain) > 0 && Number(toChain) > 0;
|
|
40044
|
+
const cosmosFallbackAddresses = quoteOnly || isEvmSwap ? undefined : await getCosmosFallbackAddresses();
|
|
40045
|
+
const fromTokenAddress = fromToken.address;
|
|
40046
|
+
const toTokenAddress = toToken.address;
|
|
40047
|
+
const fromAmount = parseToBigInt(fromPrice?.toString() ?? "0", fromToken?.decimals).toString();
|
|
40048
|
+
const fromAddress = sourceUserAddress ??
|
|
40049
|
+
chainTypeToZeroAddressMap[fromChainType ?? squidTypes.ChainType.EVM];
|
|
40050
|
+
const params = {
|
|
40051
|
+
fromChain,
|
|
40052
|
+
fromToken: fromTokenAddress,
|
|
40053
|
+
fromAddress,
|
|
40054
|
+
fromAmount,
|
|
40055
|
+
toChain,
|
|
40056
|
+
toToken: toTokenAddress,
|
|
40057
|
+
toAddress: destinationAddress ?? "",
|
|
40058
|
+
quoteOnly,
|
|
40059
|
+
slippage: config.slippage === 0 ? undefined : config.slippage,
|
|
40060
|
+
bypassGuardrails,
|
|
40061
|
+
preHook,
|
|
40062
|
+
postHook,
|
|
40063
|
+
};
|
|
40064
|
+
// If the swap is involving cosmos chains, we need to add the fallback addresses (if any)
|
|
40065
|
+
if (cosmosFallbackAddresses &&
|
|
40066
|
+
cosmosFallbackAddresses.length > 0 &&
|
|
40067
|
+
cosmosFallbackAddresses[0].address) {
|
|
40068
|
+
params.fallbackAddresses = cosmosFallbackAddresses;
|
|
40069
|
+
}
|
|
40070
|
+
const { route } = await squid.getRoute({
|
|
40071
|
+
...params,
|
|
40072
|
+
});
|
|
40073
|
+
// Cache the route data
|
|
40074
|
+
// Useful when the getRoute mutation is called from another hook
|
|
40075
|
+
queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, config.slippage, config.enableGetGasOnDestination, sourceUserAddress, config.degenMode, destinationAddress, swapRoute?.fallbackAddress, quoteOnly, fromChainType, config.preHook, config.postHook), route);
|
|
40076
|
+
return route;
|
|
40077
|
+
},
|
|
40102
40078
|
});
|
|
40103
40079
|
};
|
|
40104
|
-
const useGetRouteWrapper = ({ enabled,
|
|
40080
|
+
const useGetRouteWrapper = ({ enabled, gcTime = 5 * 60 * 1000, // 5 minutes
|
|
40105
40081
|
staleTime = 60 * 1000, // 1 minute
|
|
40106
40082
|
refetchOnWindowFocus = (query) => Date.now() - query.state.dataUpdatedAt > 30000, // Update if older than 30 seconds, when window is focused
|
|
40107
40083
|
refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true, }) => {
|
|
@@ -40151,25 +40127,27 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
40151
40127
|
* These data will be used to trigger the transaction
|
|
40152
40128
|
* @returns {Route} Route data
|
|
40153
40129
|
*/
|
|
40154
|
-
const squidRoute = reactQuery.useQuery(
|
|
40155
|
-
|
|
40156
|
-
|
|
40157
|
-
|
|
40158
|
-
|
|
40159
|
-
|
|
40160
|
-
|
|
40161
|
-
|
|
40162
|
-
|
|
40163
|
-
|
|
40164
|
-
|
|
40165
|
-
|
|
40166
|
-
|
|
40167
|
-
|
|
40168
|
-
|
|
40169
|
-
|
|
40170
|
-
|
|
40130
|
+
const squidRoute = reactQuery.useQuery({
|
|
40131
|
+
queryKey: squidRouteQueryKeys,
|
|
40132
|
+
queryFn: async () => {
|
|
40133
|
+
const route = await getRouteMutation.mutateAsync({
|
|
40134
|
+
fromChain: fromChain?.chainId,
|
|
40135
|
+
toChain: toChain?.chainId,
|
|
40136
|
+
fromToken,
|
|
40137
|
+
toToken,
|
|
40138
|
+
sourceUserAddress,
|
|
40139
|
+
destinationAddress,
|
|
40140
|
+
fromPrice,
|
|
40141
|
+
bypassGuardrails: config.degenMode,
|
|
40142
|
+
quoteOnly,
|
|
40143
|
+
fromChainType: fromChain?.chainType,
|
|
40144
|
+
postHook: config.postHook,
|
|
40145
|
+
preHook: config.preHook,
|
|
40146
|
+
});
|
|
40147
|
+
return route;
|
|
40148
|
+
},
|
|
40171
40149
|
enabled: queryEnabled,
|
|
40172
|
-
|
|
40150
|
+
gcTime,
|
|
40173
40151
|
staleTime,
|
|
40174
40152
|
refetchOnWindowFocus,
|
|
40175
40153
|
refetchIntervalInBackground,
|
|
@@ -40178,7 +40156,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
40178
40156
|
/**
|
|
40179
40157
|
* If last updated data is older than X seconds and the query is currently loading, show loading indicator
|
|
40180
40158
|
*/
|
|
40181
|
-
const showLoading =
|
|
40159
|
+
const showLoading = squidRoute.isFetching || squidRoute.isRefetching;
|
|
40182
40160
|
return {
|
|
40183
40161
|
squidRoute,
|
|
40184
40162
|
showLoading,
|
|
@@ -40210,7 +40188,7 @@ function useSendTransactionStatus({ chain, txHash, }) {
|
|
|
40210
40188
|
transactionId: txHash,
|
|
40211
40189
|
txType: exports.HistoryTxType.SEND,
|
|
40212
40190
|
});
|
|
40213
|
-
const { data: status } = reactQuery.useQuery({
|
|
40191
|
+
const { data: status, isSuccess, isError, } = reactQuery.useQuery({
|
|
40214
40192
|
queryKey: keys().sendTransactionStatus(txHash, chain?.chainId),
|
|
40215
40193
|
queryFn: async () => {
|
|
40216
40194
|
if (!chain || !txHash)
|
|
@@ -40220,17 +40198,30 @@ function useSendTransactionStatus({ chain, txHash, }) {
|
|
|
40220
40198
|
txHash,
|
|
40221
40199
|
});
|
|
40222
40200
|
},
|
|
40223
|
-
|
|
40224
|
-
|
|
40225
|
-
|
|
40201
|
+
refetchInterval: chain
|
|
40202
|
+
? getSendTxStatusRefetchInterval(chain.chainType)
|
|
40203
|
+
: false,
|
|
40204
|
+
enabled: !!chain &&
|
|
40205
|
+
!!txHash &&
|
|
40206
|
+
!isTransactionComplete &&
|
|
40207
|
+
!!currentHistoryItem &&
|
|
40208
|
+
!isHistoryTransactionEnded({
|
|
40209
|
+
data: currentHistoryItem?.data,
|
|
40210
|
+
txType: exports.HistoryTxType.SEND,
|
|
40211
|
+
}),
|
|
40212
|
+
});
|
|
40213
|
+
React.useEffect(() => {
|
|
40214
|
+
if (isSuccess) {
|
|
40215
|
+
setIsTransactionComplete(status !== exports.SendTransactionStatus.ONGOING);
|
|
40216
|
+
if (status != null && !!txHash) {
|
|
40226
40217
|
replaceTransactionStatus({
|
|
40227
40218
|
txType: exports.HistoryTxType.SEND,
|
|
40228
|
-
status:
|
|
40219
|
+
status: status,
|
|
40229
40220
|
hash: txHash,
|
|
40230
40221
|
});
|
|
40231
40222
|
}
|
|
40232
|
-
}
|
|
40233
|
-
|
|
40223
|
+
}
|
|
40224
|
+
if (isError) {
|
|
40234
40225
|
setIsTransactionComplete(true);
|
|
40235
40226
|
if (txHash) {
|
|
40236
40227
|
replaceTransactionStatus({
|
|
@@ -40239,19 +40230,8 @@ function useSendTransactionStatus({ chain, txHash, }) {
|
|
|
40239
40230
|
hash: txHash,
|
|
40240
40231
|
});
|
|
40241
40232
|
}
|
|
40242
|
-
}
|
|
40243
|
-
|
|
40244
|
-
? getSendTxStatusRefetchInterval(chain.chainType)
|
|
40245
|
-
: false,
|
|
40246
|
-
enabled: !!chain &&
|
|
40247
|
-
!!txHash &&
|
|
40248
|
-
!isTransactionComplete &&
|
|
40249
|
-
!!currentHistoryItem &&
|
|
40250
|
-
!isHistoryTransactionEnded({
|
|
40251
|
-
data: currentHistoryItem?.data,
|
|
40252
|
-
txType: exports.HistoryTxType.SEND,
|
|
40253
|
-
}),
|
|
40254
|
-
});
|
|
40233
|
+
}
|
|
40234
|
+
}, [isError, isSuccess, replaceTransactionStatus, status, txHash]);
|
|
40255
40235
|
return {
|
|
40256
40236
|
status: status ?? currentHistoryItem?.data?.status,
|
|
40257
40237
|
};
|
|
@@ -40285,7 +40265,9 @@ const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocu
|
|
|
40285
40265
|
apiUrl: latestConfig.apiUrl,
|
|
40286
40266
|
});
|
|
40287
40267
|
}, [transaction]);
|
|
40288
|
-
const transactionStatusQuery = reactQuery.useQuery(
|
|
40268
|
+
const transactionStatusQuery = reactQuery.useQuery({
|
|
40269
|
+
queryKey: keys().swapTransactionStatus(transaction?.transactionId),
|
|
40270
|
+
queryFn: fetchTransactionStatusWithLatestConfig,
|
|
40289
40271
|
enabled: enabled &&
|
|
40290
40272
|
transaction?.transactionId !== "0" &&
|
|
40291
40273
|
!!transaction?.transactionId &&
|
|
@@ -40299,12 +40281,12 @@ const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocu
|
|
|
40299
40281
|
data: currentHistoryItem?.data,
|
|
40300
40282
|
txType: exports.HistoryTxType.SWAP,
|
|
40301
40283
|
}),
|
|
40302
|
-
refetchInterval(
|
|
40284
|
+
refetchInterval({ state }) {
|
|
40303
40285
|
// If the status response is something telling that the transaction
|
|
40304
40286
|
// is finished, then store transaction history state if success
|
|
40305
40287
|
// And return false to indicate refetcher to stop
|
|
40306
|
-
if (
|
|
40307
|
-
transactionEndStatuses.includes(getTransactionStatus(
|
|
40288
|
+
if (state.data &&
|
|
40289
|
+
transactionEndStatuses.includes(getTransactionStatus(state.data) ?? "")) {
|
|
40308
40290
|
return false;
|
|
40309
40291
|
}
|
|
40310
40292
|
return refetchInterval; // Had to handle a variable here because after onError, we want the interval to stop
|
|
@@ -40313,7 +40295,10 @@ const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocu
|
|
|
40313
40295
|
retryDelay: getChainType(transaction?.fromChain) === squidTypes.ChainType.COSMOS ? 5000 : 3000,
|
|
40314
40296
|
retry: getChainType(transaction?.fromChain) === squidTypes.ChainType.COSMOS ? 6 : retry,
|
|
40315
40297
|
refetchOnWindowFocus,
|
|
40316
|
-
|
|
40298
|
+
});
|
|
40299
|
+
React.useEffect(() => {
|
|
40300
|
+
if (transactionStatusQuery.isSuccess && transactionStatusQuery.data) {
|
|
40301
|
+
const statusResponse = transactionStatusQuery.data;
|
|
40317
40302
|
// Dispatch event
|
|
40318
40303
|
WidgetEvents.getInstance().dispatchSwapStatus(statusResponse.squidTransactionStatus ?? "");
|
|
40319
40304
|
const endStatus = getTransactionEndStatus({ statusResponse });
|
|
@@ -40325,8 +40310,9 @@ const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocu
|
|
|
40325
40310
|
status: endStatus,
|
|
40326
40311
|
});
|
|
40327
40312
|
}
|
|
40328
|
-
}
|
|
40329
|
-
|
|
40313
|
+
}
|
|
40314
|
+
if (transactionStatusQuery.isError) {
|
|
40315
|
+
const error = transactionStatusQuery.error;
|
|
40330
40316
|
// `fetchTransactionStatus` throws an error with a cause being an AxiosError
|
|
40331
40317
|
const is404 = is404Error(error.cause);
|
|
40332
40318
|
if (!transaction?.transactionId)
|
|
@@ -40347,8 +40333,15 @@ const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocu
|
|
|
40347
40333
|
status: exports.TransactionStatus.ERROR,
|
|
40348
40334
|
});
|
|
40349
40335
|
}
|
|
40350
|
-
}
|
|
40351
|
-
}
|
|
40336
|
+
}
|
|
40337
|
+
}, [
|
|
40338
|
+
transactionStatusQuery.isSuccess,
|
|
40339
|
+
transactionStatusQuery.isError,
|
|
40340
|
+
transaction?.transactionId,
|
|
40341
|
+
transactionStatusQuery.error,
|
|
40342
|
+
replaceSwapTransactionStatus,
|
|
40343
|
+
transactionStatusQuery.data,
|
|
40344
|
+
]);
|
|
40352
40345
|
return {
|
|
40353
40346
|
transactionStatusQuery,
|
|
40354
40347
|
latestStatus: transactionStatusQuery.data
|
|
@@ -40391,7 +40384,7 @@ const useAvatar = (seed = zeroAddress) => {
|
|
|
40391
40384
|
},
|
|
40392
40385
|
// data is static, so no need to refetch
|
|
40393
40386
|
refetchOnWindowFocus: false,
|
|
40394
|
-
|
|
40387
|
+
gcTime: Infinity,
|
|
40395
40388
|
staleTime: Infinity,
|
|
40396
40389
|
});
|
|
40397
40390
|
return avatar || "";
|
|
@@ -40433,38 +40426,40 @@ const useAddToken = (chainToCompare, tokenToCompare) => {
|
|
|
40433
40426
|
/**
|
|
40434
40427
|
* Add token to wallet
|
|
40435
40428
|
*/
|
|
40436
|
-
const addToken = reactQuery.useMutation(
|
|
40437
|
-
|
|
40438
|
-
|
|
40439
|
-
|
|
40440
|
-
|
|
40441
|
-
|
|
40442
|
-
|
|
40443
|
-
|
|
40444
|
-
|
|
40445
|
-
chainId: +token.chainId,
|
|
40446
|
-
});
|
|
40447
|
-
}
|
|
40448
|
-
catch (error) {
|
|
40449
|
-
console.debug("Error switching network:", error);
|
|
40450
|
-
if (isEvmChainNotSupportedError(error)) {
|
|
40451
|
-
await addEthereumChain({
|
|
40452
|
-
chain,
|
|
40453
|
-
provider,
|
|
40454
|
-
});
|
|
40429
|
+
const addToken = reactQuery.useMutation({
|
|
40430
|
+
mutationFn: async ({ chain: _chain, token: _token, }) => {
|
|
40431
|
+
const token = _token ?? tokenToCompare;
|
|
40432
|
+
const chain = _chain ?? chainToCompare;
|
|
40433
|
+
if (token && chain?.chainType === squidTypes.ChainType.EVM) {
|
|
40434
|
+
const provider = await connector?.getProvider();
|
|
40435
|
+
// Switch network if needed
|
|
40436
|
+
if (currentEvmChain?.id.toString() !== token?.chainId) {
|
|
40437
|
+
try {
|
|
40455
40438
|
await switchChainAsync({
|
|
40456
40439
|
chainId: +token.chainId,
|
|
40457
40440
|
});
|
|
40458
40441
|
}
|
|
40442
|
+
catch (error) {
|
|
40443
|
+
console.debug("Error switching network:", error);
|
|
40444
|
+
if (isEvmChainNotSupportedError(error)) {
|
|
40445
|
+
await addEthereumChain({
|
|
40446
|
+
chain,
|
|
40447
|
+
provider,
|
|
40448
|
+
});
|
|
40449
|
+
await switchChainAsync({
|
|
40450
|
+
chainId: +token.chainId,
|
|
40451
|
+
});
|
|
40452
|
+
}
|
|
40453
|
+
}
|
|
40454
|
+
// Metamask is not popping the second modal if we don't wait a bit
|
|
40455
|
+
// eslint-disable-next-line no-promise-executor-return
|
|
40456
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
40459
40457
|
}
|
|
40460
|
-
|
|
40461
|
-
// eslint-disable-next-line no-promise-executor-return
|
|
40462
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
40458
|
+
await addTokenToWallet({ token, provider });
|
|
40463
40459
|
}
|
|
40464
|
-
|
|
40460
|
+
// TODO: Implement keplr add token
|
|
40461
|
+
return false;
|
|
40465
40462
|
}
|
|
40466
|
-
// TODO: Implement keplr add token
|
|
40467
|
-
return false;
|
|
40468
40463
|
});
|
|
40469
40464
|
return {
|
|
40470
40465
|
addToken,
|
|
@@ -40669,7 +40664,9 @@ function useXrplTrustLine({ address, chain, token, amount }) {
|
|
|
40669
40664
|
}
|
|
40670
40665
|
},
|
|
40671
40666
|
async onSuccess() {
|
|
40672
|
-
queryClient.invalidateQueries(
|
|
40667
|
+
queryClient.invalidateQueries({
|
|
40668
|
+
queryKey: getPrefixKey(QueryKeys.XrplTrustLine),
|
|
40669
|
+
});
|
|
40673
40670
|
},
|
|
40674
40671
|
});
|
|
40675
40672
|
/**
|
|
@@ -41027,8 +41024,6 @@ exports.useEvmBalance = useEvmBalance;
|
|
|
41027
41024
|
exports.useExecuteFiatQuote = useExecuteFiatQuote;
|
|
41028
41025
|
exports.useExecuteTransaction = useExecuteTransaction;
|
|
41029
41026
|
exports.useFavoriteTokensStore = useFavoriteTokensStore;
|
|
41030
|
-
exports.useFiatOnRampTxStatus = useFiatOnRampTxStatus;
|
|
41031
|
-
exports.useFiatTransactions = useFiatTransactions;
|
|
41032
41027
|
exports.useGetFiatQuote = useGetFiatQuote;
|
|
41033
41028
|
exports.useGetOnRampConfig = useGetOnRampConfig;
|
|
41034
41029
|
exports.useGetOnrampPaymentTypes = useGetOnrampPaymentTypes;
|
|
@@ -41046,7 +41041,6 @@ exports.useMultiChainWallet = useMultiChainWallet;
|
|
|
41046
41041
|
exports.useMultipleTokenPrices = useMultipleTokenPrices;
|
|
41047
41042
|
exports.useNativeBalance = useNativeBalance;
|
|
41048
41043
|
exports.useNativeTokenForChain = useNativeTokenForChain;
|
|
41049
|
-
exports.useRecommendedQuote = useRecommendedQuote;
|
|
41050
41044
|
exports.useRouteWarnings = useRouteWarnings;
|
|
41051
41045
|
exports.useSendTransaction = useSendTransaction;
|
|
41052
41046
|
exports.useSendTransactionGas = useSendTransactionGas;
|
|
@@ -41074,4 +41068,4 @@ exports.useWallets = useWallets;
|
|
|
41074
41068
|
exports.useXrplTrustLine = useXrplTrustLine;
|
|
41075
41069
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
41076
41070
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
41077
|
-
//# sourceMappingURL=index-
|
|
41071
|
+
//# sourceMappingURL=index-CS74WzWX.js.map
|