@0xsquid/react-hooks 8.7.2 → 8.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-DaYYG81O.js → index-CHdL63Y4.js} +38 -66
- package/dist/index-CHdL63Y4.js.map +1 -0
- package/dist/{index-D3bbd13Z.js → index-IxCpRlyV.js} +38 -65
- package/dist/index-IxCpRlyV.js.map +1 -0
- package/dist/{index.es-Bn83pLT9.js → index.es-B_4aEeiW.js} +2 -2
- package/dist/{index.es-Bn83pLT9.js.map → index.es-B_4aEeiW.js.map} +1 -1
- package/dist/{index.es-Ds1lt_e4.js → index.es-C1qztDII.js} +2 -2
- package/dist/{index.es-Ds1lt_e4.js.map → index.es-C1qztDII.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/{secretService-CKReaNYo.js → secretService-D0p2T9tf.js} +2 -2
- package/dist/{secretService-CKReaNYo.js.map → secretService-D0p2T9tf.js.map} +1 -1
- package/dist/{secretService-CM6noWhX.js → secretService-vD8qpukk.js} +2 -2
- package/dist/{secretService-CM6noWhX.js.map → secretService-vD8qpukk.js.map} +1 -1
- package/dist/services/internal/assetsService.d.ts +1 -1
- package/dist/services/internal/estimateService.d.ts +18 -8
- package/dist/services/internal/transactionService.d.ts +7 -1
- package/dist/{stellarService.client-0dfuo3PJ.js → stellarService.client-Cia5YJMU.js} +2 -2
- package/dist/{stellarService.client-0dfuo3PJ.js.map → stellarService.client-Cia5YJMU.js.map} +1 -1
- package/dist/{stellarService.client-Ko2roGXL.js → stellarService.client-DKQ8QpMf.js} +2 -2
- package/dist/{stellarService.client-Ko2roGXL.js.map → stellarService.client-DKQ8QpMf.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-D3bbd13Z.js.map +0 -1
- package/dist/index-DaYYG81O.js.map +0 -1
|
@@ -21128,8 +21128,18 @@ const compareTransactionIds = (idA, idB) => {
|
|
|
21128
21128
|
*/
|
|
21129
21129
|
function isCoralBridgeAction(action) {
|
|
21130
21130
|
return (action.type === squidTypes.ActionType.RFQ &&
|
|
21131
|
-
// TODO: update types
|
|
21132
|
-
action.provider
|
|
21131
|
+
// TODO: update types to use enum
|
|
21132
|
+
action.provider === "Squid Intents");
|
|
21133
|
+
}
|
|
21134
|
+
/**
|
|
21135
|
+
* Determines if a given action completes as part of the user's source transaction.
|
|
21136
|
+
* Action types like RFQ are fulfilled by a solver in a separate transaction,
|
|
21137
|
+
* so they are NOT completed on source even if they share the same chain.
|
|
21138
|
+
*/
|
|
21139
|
+
function isActionCompletedOnSourceTx(action, fromChainId) {
|
|
21140
|
+
if (action.type === squidTypes.ActionType.RFQ)
|
|
21141
|
+
return false;
|
|
21142
|
+
return action.fromChain === fromChainId && action.toChain === fromChainId;
|
|
21133
21143
|
}
|
|
21134
21144
|
function sleep(ms) {
|
|
21135
21145
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -23315,7 +23325,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23315
23325
|
};
|
|
23316
23326
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23317
23327
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23318
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23328
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-D0p2T9tf.js'); });
|
|
23319
23329
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23320
23330
|
};
|
|
23321
23331
|
function getTokenAssetsKey(token) {
|
|
@@ -26713,7 +26723,7 @@ function useStellarWallets() {
|
|
|
26713
26723
|
try {
|
|
26714
26724
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26715
26725
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
26716
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
26726
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-Cia5YJMU.js'); });
|
|
26717
26727
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26718
26728
|
const promises = modules.map(async (module) => {
|
|
26719
26729
|
const isAvailable = await module.isAvailable();
|
|
@@ -29569,14 +29579,20 @@ const useEvmNativeBalance = ({ address, chain, }) => {
|
|
|
29569
29579
|
},
|
|
29570
29580
|
});
|
|
29571
29581
|
const balance = React.useMemo(() => {
|
|
29572
|
-
if (nativeEvmBalance?.decimals && nativeEvmBalance?.value) {
|
|
29582
|
+
if (nativeEvmBalance?.decimals != null && nativeEvmBalance?.value != null) {
|
|
29583
|
+
if (chain?.chainId === CHAIN_IDS.HEDERA) {
|
|
29584
|
+
return {
|
|
29585
|
+
decimals: 8,
|
|
29586
|
+
value: scaleWeiToHbar(nativeEvmBalance.value),
|
|
29587
|
+
};
|
|
29588
|
+
}
|
|
29573
29589
|
return {
|
|
29574
29590
|
decimals: nativeEvmBalance.decimals,
|
|
29575
29591
|
value: nativeEvmBalance.value,
|
|
29576
29592
|
};
|
|
29577
29593
|
}
|
|
29578
29594
|
return;
|
|
29579
|
-
}, [nativeEvmBalance?.decimals, nativeEvmBalance?.value]);
|
|
29595
|
+
}, [nativeEvmBalance?.decimals, nativeEvmBalance?.value, chain?.chainId]);
|
|
29580
29596
|
return {
|
|
29581
29597
|
balance,
|
|
29582
29598
|
isLoading,
|
|
@@ -30033,7 +30049,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30033
30049
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30034
30050
|
if (!optionalChains.length)
|
|
30035
30051
|
return;
|
|
30036
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
30052
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-C1qztDII.js'); });
|
|
30037
30053
|
const rawProvider = await EthereumProvider.init({
|
|
30038
30054
|
...restParameters,
|
|
30039
30055
|
disableProviderPing: true,
|
|
@@ -31524,19 +31540,6 @@ const formatEstimatedRouteDuration = ({ estimatedRouteDuration, isSingleChainRou
|
|
|
31524
31540
|
format: (sTemplate, mTemplate, hTemplate) => formatSeconds(durationInSeconds, sTemplate, mTemplate, hTemplate),
|
|
31525
31541
|
};
|
|
31526
31542
|
};
|
|
31527
|
-
/**
|
|
31528
|
-
* Calculates and formats various estimate results based on the provided Squid route and additional parameters.
|
|
31529
|
-
*
|
|
31530
|
-
* @param {RouteResponse["route"]} squidRoute - The Squid route containing estimate information.
|
|
31531
|
-
* @param {Token[]} tokens - An array of token objects.
|
|
31532
|
-
* @param {ChainData} fromChain - The source chain object.
|
|
31533
|
-
* @param {ChainData} toChain - The destination chain object.
|
|
31534
|
-
* @param {boolean} collectFees - Flag indicating whether to collect fees.
|
|
31535
|
-
* @param {string} nativeTokenBalanceFromChain - The native token balance on the source chain.
|
|
31536
|
-
* @param {boolean} expressActivatedUI - Flag indicating whether express mode is activated in the UI.
|
|
31537
|
-
* @returns {Object} An object containing various estimate results and calculations, including token information,
|
|
31538
|
-
* amounts, fees, gas costs, and other relevant data for the transaction.
|
|
31539
|
-
*/
|
|
31540
31543
|
const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees, chainFeeParams, gasToken, }) => {
|
|
31541
31544
|
const fromToken = findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken);
|
|
31542
31545
|
const fromAmount = squidRoute?.estimate?.fromAmount;
|
|
@@ -31555,7 +31558,7 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31555
31558
|
const integratorFeeCost = allFeeCosts.length > 0 && collectFees
|
|
31556
31559
|
? allFeeCosts.find((f) => f.name === "Integrator fee")
|
|
31557
31560
|
: undefined;
|
|
31558
|
-
const expectedGasRefundCost = calculateExpectedGasRefundCost(firstFeeCost, fromChain?.chainType, estimate?.actions
|
|
31561
|
+
const expectedGasRefundCost = calculateExpectedGasRefundCost(firstFeeCost, fromChain?.chainType, estimate?.actions?.map(simplifyRouteAction));
|
|
31559
31562
|
const expectedGasRefundCostUSD = convertTokenAmountToUSD(formatBNToReadable(expectedGasRefundCost, firstFeeCost?.token.decimals ?? 18), firstFeeCost?.token.usdPrice ?? "0");
|
|
31560
31563
|
const sameTokenBetweenFees = firstFeeCost?.token.address === firstGasCost?.token.address &&
|
|
31561
31564
|
firstFeeCost?.token.chainId === firstGasCost?.token.chainId;
|
|
@@ -35915,6 +35918,12 @@ coin.DecProto = {
|
|
|
35915
35918
|
|
|
35916
35919
|
const useExecuteTransaction = (squidRoute) => {
|
|
35917
35920
|
const { fromChain, toChain, fromToken, toToken, isSameChain } = useSwap();
|
|
35921
|
+
// A route completes on source tx only if it's same-chain AND
|
|
35922
|
+
// every action is fulfilled in the user's source transaction
|
|
35923
|
+
const isCompletedOnSourceTx = isSameChain &&
|
|
35924
|
+
!!fromChain &&
|
|
35925
|
+
!!squidRoute &&
|
|
35926
|
+
squidRoute.estimate.actions.every((a) => isActionCompletedOnSourceTx(a, fromChain.chainId));
|
|
35918
35927
|
const { evmSigner, cosmosSigner, solanaSigner, bitcoinSigner, suiSigner, xrplSigner, stellarSigner, } = useSigner({
|
|
35919
35928
|
chain: fromChain,
|
|
35920
35929
|
});
|
|
@@ -35949,7 +35958,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
35949
35958
|
routeType: route.transactionRequest.type,
|
|
35950
35959
|
nonce,
|
|
35951
35960
|
transactionId: txHash,
|
|
35952
|
-
transactionIdForStatus
|
|
35961
|
+
transactionIdForStatus,
|
|
35953
35962
|
quoteId,
|
|
35954
35963
|
status,
|
|
35955
35964
|
sourceStatus,
|
|
@@ -36249,43 +36258,6 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36249
36258
|
? error
|
|
36250
36259
|
: new Error("Failed to execute Solana transaction");
|
|
36251
36260
|
}
|
|
36252
|
-
}, {
|
|
36253
|
-
onError: (error, variables) => {
|
|
36254
|
-
const currentTx = getTransaction(variables.id);
|
|
36255
|
-
const errorObject = getTransactionError(error);
|
|
36256
|
-
setTransactionStoreState(variables.id, {
|
|
36257
|
-
...currentTx,
|
|
36258
|
-
status: exports.TransactionStatus.ERROR,
|
|
36259
|
-
sourceStatus: exports.TransactionStatus.ERROR,
|
|
36260
|
-
error: errorObject,
|
|
36261
|
-
});
|
|
36262
|
-
if (currentTx?.transactionId &&
|
|
36263
|
-
errorObject.type === exports.TransactionErrorType.CALL_EXCEPTION) {
|
|
36264
|
-
replaceSwapTransactionStatus({
|
|
36265
|
-
transactionId: currentTx.transactionId,
|
|
36266
|
-
statusResponse: currentTx.statusResponse,
|
|
36267
|
-
status: exports.TransactionStatus.ERROR,
|
|
36268
|
-
});
|
|
36269
|
-
}
|
|
36270
|
-
},
|
|
36271
|
-
onSuccess: (_data, variables) => {
|
|
36272
|
-
const currentTx = getTransaction(variables.id);
|
|
36273
|
-
queryClient.invalidateQueries(getPrefixKey(exports.QueryKeys.Balances));
|
|
36274
|
-
if (isSameChain && currentTx?.transactionId) {
|
|
36275
|
-
replaceSwapTransactionStatus({
|
|
36276
|
-
transactionId: currentTx.transactionId,
|
|
36277
|
-
statusResponse: currentTx.statusResponse,
|
|
36278
|
-
status: exports.TransactionStatus.SUCCESS,
|
|
36279
|
-
});
|
|
36280
|
-
}
|
|
36281
|
-
setTransactionStoreState(variables.id, {
|
|
36282
|
-
...currentTx,
|
|
36283
|
-
sourceStatus: exports.TransactionStatus.SUCCESS,
|
|
36284
|
-
status: isSameChain
|
|
36285
|
-
? exports.TransactionStatus.SUCCESS
|
|
36286
|
-
: exports.TransactionStatus.ONGOING,
|
|
36287
|
-
});
|
|
36288
|
-
},
|
|
36289
36261
|
});
|
|
36290
36262
|
const swapMutationBitcoin = reactQuery.useMutation(async ({ id, route }) => {
|
|
36291
36263
|
const { depositAddress, amount: sendAmount, chainflipStatusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
|
|
@@ -36506,7 +36478,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36506
36478
|
const handleTransactionSuccess = React.useCallback((id) => {
|
|
36507
36479
|
const currentTx = getTransaction(id);
|
|
36508
36480
|
queryClient.invalidateQueries(getPrefixKey(exports.QueryKeys.Balances));
|
|
36509
|
-
if (
|
|
36481
|
+
if (isCompletedOnSourceTx && currentTx?.transactionId) {
|
|
36510
36482
|
replaceSwapTransactionStatus({
|
|
36511
36483
|
transactionId: currentTx.transactionId,
|
|
36512
36484
|
statusResponse: currentTx.statusResponse,
|
|
@@ -36516,13 +36488,13 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36516
36488
|
setTransactionStoreState(id, {
|
|
36517
36489
|
...currentTx,
|
|
36518
36490
|
sourceStatus: exports.TransactionStatus.SUCCESS,
|
|
36519
|
-
status:
|
|
36491
|
+
status: isCompletedOnSourceTx
|
|
36520
36492
|
? exports.TransactionStatus.SUCCESS
|
|
36521
36493
|
: exports.TransactionStatus.ONGOING,
|
|
36522
36494
|
});
|
|
36523
36495
|
}, [
|
|
36524
36496
|
getTransaction,
|
|
36525
|
-
|
|
36497
|
+
isCompletedOnSourceTx,
|
|
36526
36498
|
queryClient,
|
|
36527
36499
|
replaceSwapTransactionStatus,
|
|
36528
36500
|
setTransactionStoreState,
|
|
@@ -36545,8 +36517,8 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36545
36517
|
if (currentTx?.transactionId &&
|
|
36546
36518
|
errorObject.type === exports.TransactionErrorType.CALL_EXCEPTION) {
|
|
36547
36519
|
replaceSwapTransactionStatus({
|
|
36548
|
-
transactionId: currentTx
|
|
36549
|
-
statusResponse: currentTx
|
|
36520
|
+
transactionId: currentTx.transactionId,
|
|
36521
|
+
statusResponse: currentTx.statusResponse,
|
|
36550
36522
|
status: exports.TransactionStatus.ERROR,
|
|
36551
36523
|
});
|
|
36552
36524
|
}
|
|
@@ -37590,6 +37562,7 @@ exports.groupTokensBySymbol = groupTokensBySymbol;
|
|
|
37590
37562
|
exports.handleTransactionErrorEvents = handleTransactionErrorEvents;
|
|
37591
37563
|
exports.initializeSquidWithAssetsColors = initializeSquidWithAssetsColors;
|
|
37592
37564
|
exports.is404Error = is404Error;
|
|
37565
|
+
exports.isActionCompletedOnSourceTx = isActionCompletedOnSourceTx;
|
|
37593
37566
|
exports.isChainflipBridgeTransaction = isChainflipBridgeTransaction;
|
|
37594
37567
|
exports.isCoralBridgeAction = isCoralBridgeAction;
|
|
37595
37568
|
exports.isCosmosAddressValid = isCosmosAddressValid;
|
|
@@ -37739,4 +37712,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
37739
37712
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37740
37713
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37741
37714
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37742
|
-
//# sourceMappingURL=index-
|
|
37715
|
+
//# sourceMappingURL=index-IxCpRlyV.js.map
|