@0xsquid/react-hooks 8.8.1-beta-canton.4 → 8.9.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/core/client/index.d.ts +0 -1
- package/dist/core/constants.d.ts +0 -2
- package/dist/core/types/wallet.d.ts +6 -9
- package/dist/hooks/chains/useSquidChains.d.ts +0 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/store/useDepositAddressStore.d.ts +5 -23
- package/dist/hooks/swap/useDepositAddress.d.ts +7 -6
- package/dist/hooks/tokens/useSquidTokens.d.ts +0 -1
- package/dist/hooks/wallet/useMultiChainWallet.d.ts +15 -41
- package/dist/hooks/wallet/useWallet.d.ts +15 -45
- package/dist/{index-D5QOR7JT.js → index-BL_AUWQg.js} +217 -394
- package/dist/index-BL_AUWQg.js.map +1 -0
- package/dist/{index-mgE1SeE-.js → index-DcBFug8t.js} +216 -396
- package/dist/index-DcBFug8t.js.map +1 -0
- package/dist/{index.es-3JPbTFKq.js → index.es-1XEAWjab.js} +2 -2
- package/dist/{index.es-3JPbTFKq.js.map → index.es-1XEAWjab.js.map} +1 -1
- package/dist/{index.es-Cq4mUT_n.js → index.es-DSQHpime.js} +2 -2
- package/dist/{index.es-Cq4mUT_n.js.map → index.es-DSQHpime.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/dist/{secretService-DWq78rM5.js → secretService-B1SDXLS1.js} +2 -2
- package/dist/{secretService-DWq78rM5.js.map → secretService-B1SDXLS1.js.map} +1 -1
- package/dist/{secretService-DOOg6zVn.js → secretService-DxQ78j5I.js} +2 -2
- package/dist/{secretService-DOOg6zVn.js.map → secretService-DxQ78j5I.js.map} +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.esm.js +1 -8
- package/dist/server.esm.js.map +1 -1
- package/dist/server.js +0 -8
- package/dist/server.js.map +1 -1
- package/dist/services/internal/assetsService.d.ts +1 -10
- package/dist/services/internal/solanaTokenProgramService.d.ts +9 -0
- package/dist/services/internal/transactionService.d.ts +1 -5
- package/dist/{stellarService.client-DBROJ4yf.js → stellarService.client-C4TLBEpm.js} +2 -2
- package/dist/{stellarService.client-DBROJ4yf.js.map → stellarService.client-C4TLBEpm.js.map} +1 -1
- package/dist/{stellarService.client-C-pOt34O.js → stellarService.client-CkP5ng2n.js} +2 -2
- package/dist/{stellarService.client-C-pOt34O.js.map → stellarService.client-CkP5ng2n.js.map} +1 -1
- package/dist/tests/rpcServiceSolana.test.d.ts +1 -0
- package/dist/tests/solanaTokenProgramService.test.d.ts +1 -0
- package/package.json +2 -2
- package/dist/core/types/canton.d.ts +0 -2
- package/dist/core/types/cosmos.d.ts +0 -5
- package/dist/hooks/transaction/useDepositTransactionStatus.d.ts +0 -25
- package/dist/hooks/transaction/useSwapStatusQuery.d.ts +0 -26
- package/dist/index-D5QOR7JT.js.map +0 -1
- package/dist/index-mgE1SeE-.js.map +0 -1
- package/dist/services/internal/cantonService.d.ts +0 -2
|
@@ -10,9 +10,9 @@ import axios, { AxiosError } from 'axios';
|
|
|
10
10
|
import { WalletConnectModal } from '@walletconnect/modal';
|
|
11
11
|
import UniversalProvider from '@walletconnect/universal-provider';
|
|
12
12
|
import { isValidXAddress, isValidClassicAddress } from 'ripple-address-codec';
|
|
13
|
-
import { getAssociatedTokenAddress, createAssociatedTokenAccountInstruction, createTransferInstruction } from '@solana/spl-token';
|
|
13
|
+
import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, getAssociatedTokenAddress, createAssociatedTokenAccountInstruction, createTransferInstruction } from '@solana/spl-token';
|
|
14
14
|
import { StandardWalletAdapter } from '@solana/wallet-standard-wallet-adapter-base';
|
|
15
|
-
import { PublicKey,
|
|
15
|
+
import { PublicKey, Transaction, SystemProgram, VersionedTransaction, Connection } from '@solana/web3.js';
|
|
16
16
|
import { StrKey, Networks, nativeToScVal, Address, rpc, TransactionBuilder, BASE_FEE, Contract, TimeoutInfinite, scValToNative, Asset, Operation, Transaction as Transaction$1, xdr } from '@stellar/stellar-sdk';
|
|
17
17
|
import { SUI_TESTNET_CHAIN, SUI_MAINNET_CHAIN } from '@mysten/wallet-standard';
|
|
18
18
|
import { CloudflareProvider, JsonRpcProvider, ethers, Interface, BrowserProvider, JsonRpcSigner, Contract as Contract$1, isError } from 'ethers';
|
|
@@ -57,8 +57,6 @@ const solanaZeroAddress = "11111111111111111111111111111111";
|
|
|
57
57
|
const suiZeroAddress = "0x0000000000000000000000000000000000000000";
|
|
58
58
|
const xrplZeroAddress = "rrrrrrrrrrrrrrrrrrrrrhoLvTp";
|
|
59
59
|
const stellarZeroAddress = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
|
|
60
|
-
// TODO: check
|
|
61
|
-
const cantonZeroAddress = "none::12200000000000000000000000000000000000000000000000000000000000000000";
|
|
62
60
|
const chainTypeToZeroAddressMap = {
|
|
63
61
|
[ChainType.EVM]: zeroAddress$1,
|
|
64
62
|
[ChainType.COSMOS]: cosmosZeroAddress,
|
|
@@ -67,7 +65,6 @@ const chainTypeToZeroAddressMap = {
|
|
|
67
65
|
[ChainType.SUI]: suiZeroAddress,
|
|
68
66
|
[ChainType.XRPL]: xrplZeroAddress,
|
|
69
67
|
[ChainType.STELLAR]: stellarZeroAddress,
|
|
70
|
-
[ChainType.CANTON]: cantonZeroAddress,
|
|
71
68
|
};
|
|
72
69
|
const nativeEvmTokenAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
73
70
|
const nativeCosmosTokenAddress = "uosmo";
|
|
@@ -76,7 +73,6 @@ const nativeBitcoinTokenAddress = "satoshi";
|
|
|
76
73
|
const nativeSuiTokenAddress = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
77
74
|
const nativeXrplTokenAddress = "xrp";
|
|
78
75
|
const nativeStellarTokenAddress = "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA";
|
|
79
|
-
const nativeCantonTokenAddress = "DSO::1220b1431ef217342db44d516bb9befde802be7d8899637d290895fa58880f19accc";
|
|
80
76
|
// by setting slippage to undefined, it's set to "auto"
|
|
81
77
|
const defaultSlippage = undefined;
|
|
82
78
|
const destinationAddressResetValue = "null";
|
|
@@ -140,7 +136,6 @@ const CHAIN_IDS = {
|
|
|
140
136
|
XRPL_TESTNET: "xrpl-testnet",
|
|
141
137
|
STELLAR: "stellar-mainnet",
|
|
142
138
|
STELLAR_TESTNET: "stellar-testnet",
|
|
143
|
-
CANTON: "canton",
|
|
144
139
|
};
|
|
145
140
|
const chainTypeToDefaultChainIdMap = {
|
|
146
141
|
[ChainType.EVM]: CHAIN_IDS.ETHEREUM,
|
|
@@ -150,7 +145,6 @@ const chainTypeToDefaultChainIdMap = {
|
|
|
150
145
|
[ChainType.SUI]: CHAIN_IDS.SUI,
|
|
151
146
|
[ChainType.XRPL]: CHAIN_IDS.XRPL,
|
|
152
147
|
[ChainType.STELLAR]: CHAIN_IDS.STELLAR,
|
|
153
|
-
[ChainType.CANTON]: CHAIN_IDS.CANTON,
|
|
154
148
|
};
|
|
155
149
|
const chainTypeToNativeTokenAddressMap = {
|
|
156
150
|
[ChainType.EVM]: nativeEvmTokenAddress,
|
|
@@ -160,7 +154,6 @@ const chainTypeToNativeTokenAddressMap = {
|
|
|
160
154
|
[ChainType.SUI]: nativeSuiTokenAddress,
|
|
161
155
|
[ChainType.XRPL]: nativeXrplTokenAddress,
|
|
162
156
|
[ChainType.STELLAR]: nativeStellarTokenAddress,
|
|
163
|
-
[ChainType.CANTON]: nativeCantonTokenAddress,
|
|
164
157
|
};
|
|
165
158
|
const defaultConfigValues = {
|
|
166
159
|
integratorId: INTEGRATOR_ID,
|
|
@@ -20858,17 +20851,31 @@ const isBitcoinAddressValid = (address$1) => {
|
|
|
20858
20851
|
}
|
|
20859
20852
|
};
|
|
20860
20853
|
|
|
20861
|
-
|
|
20862
|
-
|
|
20863
|
-
|
|
20864
|
-
|
|
20865
|
-
|
|
20866
|
-
|
|
20867
|
-
if (
|
|
20868
|
-
return
|
|
20869
|
-
|
|
20870
|
-
|
|
20871
|
-
}
|
|
20854
|
+
const solanaTokenProgramIdByAddress = {
|
|
20855
|
+
[TOKEN_PROGRAM_ID.toBase58()]: TOKEN_PROGRAM_ID,
|
|
20856
|
+
[TOKEN_2022_PROGRAM_ID.toBase58()]: TOKEN_2022_PROGRAM_ID,
|
|
20857
|
+
};
|
|
20858
|
+
const isSupportedSolanaTokenProgramId = (programId) => programId.toBase58() in solanaTokenProgramIdByAddress;
|
|
20859
|
+
const getSupportedSolanaTokenProgramId = (tokenProgramId) => {
|
|
20860
|
+
if (!tokenProgramId)
|
|
20861
|
+
return undefined;
|
|
20862
|
+
return solanaTokenProgramIdByAddress[tokenProgramId];
|
|
20863
|
+
};
|
|
20864
|
+
const resolveSolanaTokenProgramId = async ({ connection, token, }) => {
|
|
20865
|
+
const tokenProgramId = getSupportedSolanaTokenProgramId(token.tokenProgramId);
|
|
20866
|
+
if (tokenProgramId) {
|
|
20867
|
+
return tokenProgramId;
|
|
20868
|
+
}
|
|
20869
|
+
const mint = new PublicKey(token.address);
|
|
20870
|
+
const mintAccount = await connection.getAccountInfo(mint);
|
|
20871
|
+
if (!mintAccount) {
|
|
20872
|
+
throw new Error(`Solana mint account not found: ${token.address}`);
|
|
20873
|
+
}
|
|
20874
|
+
if (!isSupportedSolanaTokenProgramId(mintAccount.owner)) {
|
|
20875
|
+
throw new Error(`Unsupported Solana token program for mint ${token.address}: ${mintAccount.owner.toBase58()}`);
|
|
20876
|
+
}
|
|
20877
|
+
return mintAccount.owner;
|
|
20878
|
+
};
|
|
20872
20879
|
|
|
20873
20880
|
var HistoryTxType;
|
|
20874
20881
|
(function (HistoryTxType) {
|
|
@@ -20983,7 +20990,6 @@ const getSourceExplorerTxUrl = (chain, txID) => {
|
|
|
20983
20990
|
case CHAIN_IDS.AGORIC:
|
|
20984
20991
|
case CHAIN_IDS.XRPL:
|
|
20985
20992
|
case CHAIN_IDS.XRPL_TESTNET:
|
|
20986
|
-
case CHAIN_IDS.CANTON:
|
|
20987
20993
|
txSuffix = "/transactions/";
|
|
20988
20994
|
break;
|
|
20989
20995
|
case CHAIN_IDS.HEDERA:
|
|
@@ -21093,16 +21099,10 @@ const simplifyRouteAction = (action) => {
|
|
|
21093
21099
|
};
|
|
21094
21100
|
const fetchSwapTransactionStatus = async ({ transaction, integratorId, apiUrl, }) => {
|
|
21095
21101
|
const statusEndpoint = `${apiUrl}/v2/status`;
|
|
21096
|
-
const isCanton = transaction?.fromChain === CHAIN_IDS.CANTON;
|
|
21097
|
-
// For Canton, the backend handles all tx detection/submission from the quoteId
|
|
21098
|
-
// alone, so no transactionId is sent — only the quoteId param below.
|
|
21099
|
-
const transactionId = isCanton
|
|
21100
|
-
? undefined
|
|
21101
|
-
: transaction?.transactionIdForStatus ?? transaction?.transactionId;
|
|
21102
21102
|
try {
|
|
21103
21103
|
const response = await axios.get(statusEndpoint, {
|
|
21104
21104
|
params: {
|
|
21105
|
-
transactionId,
|
|
21105
|
+
transactionId: transaction?.transactionIdForStatus ?? transaction?.transactionId,
|
|
21106
21106
|
fromChainId: transaction?.fromChain,
|
|
21107
21107
|
toChainId: transaction?.toChain,
|
|
21108
21108
|
bridgeType: transaction?.bridgeType,
|
|
@@ -21149,7 +21149,7 @@ function isActionCompletedOnSourceTx(action, fromChainId) {
|
|
|
21149
21149
|
function sleep(ms) {
|
|
21150
21150
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21151
21151
|
}
|
|
21152
|
-
const
|
|
21152
|
+
const isDepositRoute = (route) => {
|
|
21153
21153
|
return (!!route &&
|
|
21154
21154
|
route.transactionRequest?.type === SquidDataType.ChainflipDepositAddress);
|
|
21155
21155
|
};
|
|
@@ -21174,12 +21174,6 @@ function isOnChainTxData(squidData) {
|
|
|
21174
21174
|
SquidDataType.DepositAddressWithMemo,
|
|
21175
21175
|
].includes(squidData.type);
|
|
21176
21176
|
}
|
|
21177
|
-
/**
|
|
21178
|
-
* Checks if a route is of type DepositAddressDirectTransfer
|
|
21179
|
-
*/
|
|
21180
|
-
function isDepositAddressDirectTransferRoute(squidData) {
|
|
21181
|
-
return (squidData.type === SquidDataType.DepositAddressDirectTransfer);
|
|
21182
|
-
}
|
|
21183
21177
|
function getHistoryTransactionId(tx) {
|
|
21184
21178
|
switch (tx.txType) {
|
|
21185
21179
|
case HistoryTxType.SWAP:
|
|
@@ -21362,6 +21356,16 @@ const isSolanaAddressValid = (address) => {
|
|
|
21362
21356
|
return false;
|
|
21363
21357
|
}
|
|
21364
21358
|
};
|
|
21359
|
+
const deserializeSolanaTransaction = (transactionBuffer) => {
|
|
21360
|
+
// Squid can return legacy Solana transactions (ITS) or versioned transactions
|
|
21361
|
+
// (Jupiter/Chainflip). Deserialize once to detect the payload type. Legacy
|
|
21362
|
+
// transactions need to be converted to Transaction because their blockhash is
|
|
21363
|
+
// mutable and must be refreshed before signing.
|
|
21364
|
+
const versionedTransaction = VersionedTransaction.deserialize(transactionBuffer);
|
|
21365
|
+
return versionedTransaction.version === "legacy"
|
|
21366
|
+
? Transaction.from(transactionBuffer)
|
|
21367
|
+
: versionedTransaction;
|
|
21368
|
+
};
|
|
21365
21369
|
/**
|
|
21366
21370
|
* Execute a Solana swap transaction
|
|
21367
21371
|
* This will be used for the swap flow - Using Jupiter Dex under the hood
|
|
@@ -21372,13 +21376,16 @@ const executeSolanaSwap = async ({ route, signer, connection, onSigned, }) => {
|
|
|
21372
21376
|
}
|
|
21373
21377
|
const swapRequest = route.transactionRequest.data;
|
|
21374
21378
|
const swapTransactionBuf = Buffer.from(swapRequest, "base64");
|
|
21375
|
-
|
|
21376
|
-
// const transaction = VersionedTransaction.deserialize(
|
|
21377
|
-
// Uint8Array.from(swapTransactionBuf)
|
|
21378
|
-
// );
|
|
21379
|
-
const transaction = VersionedTransaction.deserialize(swapTransactionBuf);
|
|
21379
|
+
const transaction = deserializeSolanaTransaction(swapTransactionBuf);
|
|
21380
21380
|
try {
|
|
21381
21381
|
const latestBlockhash = await connection.getLatestBlockhash();
|
|
21382
|
+
if (transaction instanceof Transaction) {
|
|
21383
|
+
// ITS legacy transactions arrive with the placeholder blockhash
|
|
21384
|
+
// 11111111111111111111111111111111.
|
|
21385
|
+
// Refresh it right before signing so the submitted transaction
|
|
21386
|
+
// uses a valid blockhash. Versioned transactions are not mutable here.
|
|
21387
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
21388
|
+
}
|
|
21382
21389
|
const signature = await signer.sendTransaction(transaction, connection);
|
|
21383
21390
|
onSigned?.(signature);
|
|
21384
21391
|
await connection.confirmTransaction({
|
|
@@ -21427,16 +21434,20 @@ const executeSolanaTransfer = async ({ amount, target, signer, connection, sourc
|
|
|
21427
21434
|
else {
|
|
21428
21435
|
// Handle SPL token transfer
|
|
21429
21436
|
const mint = new PublicKey(sourceToken.address);
|
|
21437
|
+
const tokenProgramId = await resolveSolanaTokenProgramId({
|
|
21438
|
+
connection,
|
|
21439
|
+
token: sourceToken,
|
|
21440
|
+
});
|
|
21430
21441
|
// Get Associated Token Accounts (ATAs) for both source and target
|
|
21431
|
-
const sourceATA = await getAssociatedTokenAddress(mint, signer.publicKey, true);
|
|
21432
|
-
const targetATA = await getAssociatedTokenAddress(mint, targetPubKey, true);
|
|
21442
|
+
const sourceATA = await getAssociatedTokenAddress(mint, signer.publicKey, true, tokenProgramId);
|
|
21443
|
+
const targetATA = await getAssociatedTokenAddress(mint, targetPubKey, true, tokenProgramId);
|
|
21433
21444
|
// Check if target ATA exists and create if needed
|
|
21434
21445
|
const targetAccount = await connection.getAccountInfo(targetATA);
|
|
21435
21446
|
if (!targetAccount) {
|
|
21436
|
-
transaction.add(createAssociatedTokenAccountInstruction(signer.publicKey, targetATA, targetPubKey, mint));
|
|
21447
|
+
transaction.add(createAssociatedTokenAccountInstruction(signer.publicKey, targetATA, targetPubKey, mint, tokenProgramId));
|
|
21437
21448
|
}
|
|
21438
21449
|
// Add the token transfer instruction
|
|
21439
|
-
transaction.add(createTransferInstruction(sourceATA, targetATA, signer.publicKey, amount));
|
|
21450
|
+
transaction.add(createTransferInstruction(sourceATA, targetATA, signer.publicKey, amount, [], tokenProgramId));
|
|
21440
21451
|
}
|
|
21441
21452
|
// Get latest blockhash and sign transaction
|
|
21442
21453
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
@@ -21682,17 +21693,7 @@ const chainTypeToTrimLength = {
|
|
|
21682
21693
|
start: 4,
|
|
21683
21694
|
end: 4,
|
|
21684
21695
|
},
|
|
21685
|
-
// abc...123::abc...123
|
|
21686
|
-
[ChainType.CANTON]: {
|
|
21687
|
-
start: 3,
|
|
21688
|
-
end: 3,
|
|
21689
|
-
},
|
|
21690
21696
|
};
|
|
21691
|
-
const truncateWithEllipsis = (value, startLength, endLength) => value.length <= startLength + endLength
|
|
21692
|
-
? value
|
|
21693
|
-
: value.slice(0, startLength) +
|
|
21694
|
-
"..." +
|
|
21695
|
-
value.slice(value.length - endLength);
|
|
21696
21697
|
const formatHash = ({ chainType, hash }) => {
|
|
21697
21698
|
if (!hash)
|
|
21698
21699
|
return "";
|
|
@@ -21705,15 +21706,14 @@ const formatHash = ({ chainType, hash }) => {
|
|
|
21705
21706
|
chainTypeFormat = ChainType.COSMOS;
|
|
21706
21707
|
}
|
|
21707
21708
|
}
|
|
21708
|
-
const
|
|
21709
|
-
|
|
21710
|
-
|
|
21711
|
-
|
|
21712
|
-
return
|
|
21713
|
-
|
|
21714
|
-
|
|
21715
|
-
|
|
21716
|
-
return truncateWithEllipsis(hash, start, end);
|
|
21709
|
+
const trimLengthStart = chainTypeToTrimLength[chainTypeFormat].start;
|
|
21710
|
+
const trimLengthEnd = chainTypeToTrimLength[chainTypeFormat].end;
|
|
21711
|
+
// return the same hash if its length is less than the trim length
|
|
21712
|
+
if (hash.length <= trimLengthStart + trimLengthEnd)
|
|
21713
|
+
return hash;
|
|
21714
|
+
return (hash.slice(0, trimLengthStart) +
|
|
21715
|
+
"..." +
|
|
21716
|
+
hash.slice(hash.length - trimLengthEnd, hash.length));
|
|
21717
21717
|
};
|
|
21718
21718
|
const isWalletAddressValid = (chainData, address) => {
|
|
21719
21719
|
if (!address || !chainData?.chainType)
|
|
@@ -21733,8 +21733,6 @@ const isWalletAddressValid = (chainData, address) => {
|
|
|
21733
21733
|
return isXrplAddressValid(address);
|
|
21734
21734
|
case ChainType.STELLAR:
|
|
21735
21735
|
return isStellarAddressValid(address);
|
|
21736
|
-
case ChainType.CANTON:
|
|
21737
|
-
return isCantonAddressValid(address);
|
|
21738
21736
|
}
|
|
21739
21737
|
};
|
|
21740
21738
|
const redirectToExtensionsStore = (wallet) => {
|
|
@@ -21996,8 +21994,6 @@ const connectByChainType = async (chainType, wallet, defaultChain, params) => {
|
|
|
21996
21994
|
connector,
|
|
21997
21995
|
},
|
|
21998
21996
|
});
|
|
21999
|
-
case ChainType.CANTON:
|
|
22000
|
-
return null;
|
|
22001
21997
|
}
|
|
22002
21998
|
};
|
|
22003
21999
|
const getChainTypesToConnect = (selectedChainTypes, defaultChain, supportedChains) => {
|
|
@@ -23072,10 +23068,7 @@ const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute, tokens, chai
|
|
|
23072
23068
|
else {
|
|
23073
23069
|
newFallbackAddress = fallbackAddress ?? initialSwapRoute?.fallbackAddress;
|
|
23074
23070
|
}
|
|
23075
|
-
const
|
|
23076
|
-
const newDepositRefundAddress = sourceChainChanged
|
|
23077
|
-
? undefined
|
|
23078
|
-
: depositRefundAddress || initialSwapRoute?.depositRefundAddress;
|
|
23071
|
+
const newDepositRefundAddress = depositRefundAddress || initialSwapRoute?.depositRefundAddress;
|
|
23079
23072
|
return {
|
|
23080
23073
|
fromChainId: srcChainId,
|
|
23081
23074
|
fromTokenAddress: sourceTokenAddress,
|
|
@@ -23354,7 +23347,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23354
23347
|
};
|
|
23355
23348
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23356
23349
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23357
|
-
const { fetchAllSecretBalances } = await import('./secretService-
|
|
23350
|
+
const { fetchAllSecretBalances } = await import('./secretService-DxQ78j5I.js');
|
|
23358
23351
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23359
23352
|
};
|
|
23360
23353
|
function getTokenAssetsKey(token) {
|
|
@@ -23381,29 +23374,9 @@ async function fetchAssetsColors() {
|
|
|
23381
23374
|
};
|
|
23382
23375
|
}
|
|
23383
23376
|
}
|
|
23384
|
-
|
|
23385
|
-
|
|
23386
|
-
|
|
23387
|
-
}
|
|
23388
|
-
/**
|
|
23389
|
-
* Normalizes SDK data after each init/refetch before the rest of hooks consumes it.
|
|
23390
|
-
*
|
|
23391
|
-
* - Removes chains whose chainType is not supported by the local package.
|
|
23392
|
-
* - Drops tokens for those removed chains.
|
|
23393
|
-
* - Converts Evmos chains/tokens to EVM.
|
|
23394
|
-
* - Applies optional asset colors.
|
|
23395
|
-
*/
|
|
23396
|
-
function initializeSquidData(squid, assetsColors = {
|
|
23397
|
-
chains: {},
|
|
23398
|
-
tokens: {},
|
|
23399
|
-
}) {
|
|
23400
|
-
const supportedChains = squid.chains.filter((chain) => isSupportedChainType(chain.chainType));
|
|
23401
|
-
const supportedChainIds = new Set(supportedChains.map((chain) => chain.chainId));
|
|
23402
|
-
const evmosChainIds = supportedChains
|
|
23403
|
-
.filter(isEvmosChain)
|
|
23404
|
-
.map((c) => c.chainId);
|
|
23405
|
-
const supportedTokens = squid.tokens.filter((token) => supportedChainIds.has(token.chainId));
|
|
23406
|
-
squid.tokens = supportedTokens.map((token) => {
|
|
23377
|
+
function initializeSquidWithAssetsColors(squid, assetsColors) {
|
|
23378
|
+
const evmosChainIds = squid.chains.filter(isEvmosChain).map((c) => c.chainId);
|
|
23379
|
+
squid.tokens = squid.tokens.map((token) => {
|
|
23407
23380
|
const isEvmosToken = evmosChainIds.includes(token.chainId);
|
|
23408
23381
|
return {
|
|
23409
23382
|
...token,
|
|
@@ -23412,7 +23385,7 @@ function initializeSquidData(squid, assetsColors = {
|
|
|
23412
23385
|
textColor: assetsColors.tokens[getTokenAssetsKey(token)]?.textColor,
|
|
23413
23386
|
};
|
|
23414
23387
|
});
|
|
23415
|
-
squid.chains =
|
|
23388
|
+
squid.chains = squid.chains.map((chain) => {
|
|
23416
23389
|
const bgColor = assetsColors.chains[chain.chainId]?.bgColor;
|
|
23417
23390
|
// convert evmos cosmos chains to evm chains
|
|
23418
23391
|
// TODO: this will be fixed in the backend
|
|
@@ -25289,7 +25262,7 @@ const useSquid = () => {
|
|
|
25289
25262
|
queryFn: async () => {
|
|
25290
25263
|
if (squid) {
|
|
25291
25264
|
await squid?.init();
|
|
25292
|
-
|
|
25265
|
+
initializeSquidWithAssetsColors(squid, assetsColors);
|
|
25293
25266
|
return squid;
|
|
25294
25267
|
}
|
|
25295
25268
|
return null;
|
|
@@ -25348,7 +25321,7 @@ const useSquidTokens = (direction) => {
|
|
|
25348
25321
|
config.availableChains,
|
|
25349
25322
|
direction,
|
|
25350
25323
|
]);
|
|
25351
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens,
|
|
25324
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useMemo(() => {
|
|
25352
25325
|
return tokens?.reduce((acc, token) => {
|
|
25353
25326
|
switch (token.type) {
|
|
25354
25327
|
case ChainType.EVM:
|
|
@@ -25372,9 +25345,6 @@ const useSquidTokens = (direction) => {
|
|
|
25372
25345
|
case ChainType.STELLAR:
|
|
25373
25346
|
acc.stellarTokens.push(token);
|
|
25374
25347
|
break;
|
|
25375
|
-
case ChainType.CANTON:
|
|
25376
|
-
acc.cantonTokens.push(token);
|
|
25377
|
-
break;
|
|
25378
25348
|
}
|
|
25379
25349
|
return acc;
|
|
25380
25350
|
}, {
|
|
@@ -25385,7 +25355,6 @@ const useSquidTokens = (direction) => {
|
|
|
25385
25355
|
suiTokens: [],
|
|
25386
25356
|
xrplTokens: [],
|
|
25387
25357
|
stellarTokens: [],
|
|
25388
|
-
cantonTokens: [],
|
|
25389
25358
|
});
|
|
25390
25359
|
}, [tokens]);
|
|
25391
25360
|
const findToken = useCallback((address, chainId) => {
|
|
@@ -25403,7 +25372,6 @@ const useSquidTokens = (direction) => {
|
|
|
25403
25372
|
suiTokens,
|
|
25404
25373
|
xrplTokens,
|
|
25405
25374
|
stellarTokens,
|
|
25406
|
-
cantonTokens,
|
|
25407
25375
|
};
|
|
25408
25376
|
};
|
|
25409
25377
|
|
|
@@ -25941,7 +25909,6 @@ const chainTypeToRefetchInterval = {
|
|
|
25941
25909
|
[ChainType.SUI]: 1_000,
|
|
25942
25910
|
[ChainType.XRPL]: 1_000,
|
|
25943
25911
|
[ChainType.STELLAR]: 1_000,
|
|
25944
|
-
[ChainType.CANTON]: 1_000,
|
|
25945
25912
|
};
|
|
25946
25913
|
/**
|
|
25947
25914
|
* Returns the status refetch interval of a Send transaction
|
|
@@ -26208,7 +26175,7 @@ const useSquidChains = (direction) => {
|
|
|
26208
26175
|
const chain = findChain(chainId);
|
|
26209
26176
|
return chain?.chainType;
|
|
26210
26177
|
}, [findChain]);
|
|
26211
|
-
const { evmChains, cosmosChains, suiChains, stellarChains, xrplChains
|
|
26178
|
+
const { evmChains, cosmosChains, suiChains, stellarChains, xrplChains } = useMemo(() => {
|
|
26212
26179
|
return chains.reduce((acc, chain) => {
|
|
26213
26180
|
switch (chain.chainType) {
|
|
26214
26181
|
case ChainType.EVM:
|
|
@@ -26226,9 +26193,6 @@ const useSquidChains = (direction) => {
|
|
|
26226
26193
|
case ChainType.STELLAR:
|
|
26227
26194
|
acc.stellarChains.push(chain);
|
|
26228
26195
|
break;
|
|
26229
|
-
case ChainType.CANTON:
|
|
26230
|
-
acc.cantonChains.push(chain);
|
|
26231
|
-
break;
|
|
26232
26196
|
}
|
|
26233
26197
|
return acc;
|
|
26234
26198
|
}, {
|
|
@@ -26237,7 +26201,6 @@ const useSquidChains = (direction) => {
|
|
|
26237
26201
|
suiChains: [],
|
|
26238
26202
|
xrplChains: [],
|
|
26239
26203
|
stellarChains: [],
|
|
26240
|
-
cantonChains: [],
|
|
26241
26204
|
});
|
|
26242
26205
|
}, [chains]);
|
|
26243
26206
|
const { supportedSourceChains, supportedDestinationChains } = useMemo(() => {
|
|
@@ -26258,7 +26221,6 @@ const useSquidChains = (direction) => {
|
|
|
26258
26221
|
suiChains,
|
|
26259
26222
|
xrplChains,
|
|
26260
26223
|
stellarChains,
|
|
26261
|
-
cantonChains,
|
|
26262
26224
|
getChainType,
|
|
26263
26225
|
findChain,
|
|
26264
26226
|
};
|
|
@@ -26783,7 +26745,7 @@ function useStellarWallets() {
|
|
|
26783
26745
|
try {
|
|
26784
26746
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26785
26747
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
26786
|
-
const { formatStellarWallet } = await import('./stellarService.client-
|
|
26748
|
+
const { formatStellarWallet } = await import('./stellarService.client-CkP5ng2n.js');
|
|
26787
26749
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26788
26750
|
const promises = modules.map(async (module) => {
|
|
26789
26751
|
const isAvailable = await module.isAvailable();
|
|
@@ -27482,7 +27444,6 @@ const useMultiChainWallet = (chain) => {
|
|
|
27482
27444
|
const suiAddress = connectedAddresses[ChainType.SUI];
|
|
27483
27445
|
const xrplAddress = connectedAddresses[ChainType.XRPL];
|
|
27484
27446
|
const stellarAddress = connectedAddresses[ChainType.STELLAR];
|
|
27485
|
-
const cantonAddress = connectedAddresses[ChainType.CANTON];
|
|
27486
27447
|
// Cosmos is a special case because the address changes on every chain
|
|
27487
27448
|
// so we can't use the default cosmos connected address
|
|
27488
27449
|
const { data: cosmosAddress } = useCosmosForChain(chain);
|
|
@@ -27570,16 +27531,6 @@ const useMultiChainWallet = (chain) => {
|
|
|
27570
27531
|
chainType: chain.chainType,
|
|
27571
27532
|
}),
|
|
27572
27533
|
};
|
|
27573
|
-
case ChainType.CANTON:
|
|
27574
|
-
if (!cantonAddress)
|
|
27575
|
-
return {};
|
|
27576
|
-
return {
|
|
27577
|
-
address: cantonAddress,
|
|
27578
|
-
formatted: formatHash({
|
|
27579
|
-
hash: cantonAddress,
|
|
27580
|
-
chainType: chain.chainType,
|
|
27581
|
-
}),
|
|
27582
|
-
};
|
|
27583
27534
|
}
|
|
27584
27535
|
}, [
|
|
27585
27536
|
chain?.chainType,
|
|
@@ -27591,7 +27542,6 @@ const useMultiChainWallet = (chain) => {
|
|
|
27591
27542
|
suiAddress,
|
|
27592
27543
|
xrplAddress,
|
|
27593
27544
|
stellarAddress,
|
|
27594
|
-
cantonAddress,
|
|
27595
27545
|
]);
|
|
27596
27546
|
/**
|
|
27597
27547
|
* Change current network for desired chain
|
|
@@ -28416,8 +28366,6 @@ async function createClient(chain) {
|
|
|
28416
28366
|
return new XrplRpcClient(chain.rpc);
|
|
28417
28367
|
case ChainType.STELLAR:
|
|
28418
28368
|
return new StellarRpcClient(chain.rpc);
|
|
28419
|
-
case ChainType.CANTON:
|
|
28420
|
-
return null;
|
|
28421
28369
|
}
|
|
28422
28370
|
}
|
|
28423
28371
|
|
|
@@ -29254,6 +29202,10 @@ const getSolanaTokenBalance = async (userAddress, tokenAddress) => {
|
|
|
29254
29202
|
if (tokenAddress.toLowerCase() === nativeSolanaTokenAddress.toLowerCase()) {
|
|
29255
29203
|
return getSolanaNativeBalance(userAddress);
|
|
29256
29204
|
}
|
|
29205
|
+
const balances = await getSolanaTokensBalance(userAddress, [tokenAddress]);
|
|
29206
|
+
return balances[tokenAddress] || BigInt(0);
|
|
29207
|
+
};
|
|
29208
|
+
const getSolanaTokenAccountsByProgram = async (userAddress, programId) => {
|
|
29257
29209
|
const response = await fetch(SOLANA_RPC_URL, {
|
|
29258
29210
|
method: "POST",
|
|
29259
29211
|
headers: { "Content-Type": "application/json" },
|
|
@@ -29263,43 +29215,45 @@ const getSolanaTokenBalance = async (userAddress, tokenAddress) => {
|
|
|
29263
29215
|
method: "getTokenAccountsByOwner",
|
|
29264
29216
|
params: [
|
|
29265
29217
|
userAddress,
|
|
29266
|
-
{ programId
|
|
29218
|
+
{ programId },
|
|
29267
29219
|
{ encoding: "jsonParsed" },
|
|
29268
29220
|
],
|
|
29269
29221
|
}),
|
|
29270
29222
|
});
|
|
29271
29223
|
const data = await response.json();
|
|
29272
|
-
|
|
29273
|
-
|
|
29274
|
-
|
|
29224
|
+
if (data.error) {
|
|
29225
|
+
throw new Error(data.error.message || "Failed to fetch Solana balances");
|
|
29226
|
+
}
|
|
29227
|
+
return data.result?.value || [];
|
|
29275
29228
|
};
|
|
29276
29229
|
const getSolanaTokensBalance = async (userAddress, tokenAddresses) => {
|
|
29277
|
-
const
|
|
29278
|
-
|
|
29279
|
-
headers: { "Content-Type": "application/json" },
|
|
29280
|
-
body: JSON.stringify({
|
|
29281
|
-
jsonrpc: "2.0",
|
|
29282
|
-
id: 1,
|
|
29283
|
-
method: "getTokenAccountsByOwner",
|
|
29284
|
-
params: [
|
|
29285
|
-
userAddress,
|
|
29286
|
-
{ programId: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" },
|
|
29287
|
-
{ encoding: "jsonParsed" },
|
|
29288
|
-
],
|
|
29289
|
-
}),
|
|
29290
|
-
});
|
|
29291
|
-
const data = await response.json();
|
|
29292
|
-
return tokenAddresses.reduce((acc, address) => {
|
|
29293
|
-
const tokenAccount = data.result?.value?.find((accountInfo) => accountInfo.account.data.parsed.info.mint.toLowerCase() ===
|
|
29294
|
-
address.toLowerCase());
|
|
29295
|
-
acc[address] = BigInt(tokenAccount?.account.data.parsed.info.tokenAmount.amount || 0);
|
|
29230
|
+
const balancesByAddress = tokenAddresses.reduce((acc, address) => {
|
|
29231
|
+
acc[address] = BigInt(0);
|
|
29296
29232
|
return acc;
|
|
29297
29233
|
}, {});
|
|
29234
|
+
if (tokenAddresses.length === 0) {
|
|
29235
|
+
return balancesByAddress;
|
|
29236
|
+
}
|
|
29237
|
+
const addressByLowercase = tokenAddresses.reduce((acc, address) => {
|
|
29238
|
+
acc[address.toLowerCase()] = address;
|
|
29239
|
+
return acc;
|
|
29240
|
+
}, {});
|
|
29241
|
+
const tokenAccountsByProgram = await Promise.all([TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID].map((programId) => getSolanaTokenAccountsByProgram(userAddress, programId.toBase58())));
|
|
29242
|
+
tokenAccountsByProgram.flat().forEach((tokenAccount) => {
|
|
29243
|
+
const tokenInfo = tokenAccount.account?.data?.parsed?.info;
|
|
29244
|
+
const address = tokenInfo?.mint
|
|
29245
|
+
? addressByLowercase[tokenInfo.mint.toLowerCase()]
|
|
29246
|
+
: undefined;
|
|
29247
|
+
if (!address)
|
|
29248
|
+
return;
|
|
29249
|
+
balancesByAddress[address] += BigInt(tokenInfo?.tokenAmount?.amount || 0);
|
|
29250
|
+
});
|
|
29251
|
+
return balancesByAddress;
|
|
29298
29252
|
};
|
|
29299
29253
|
const getAllSolanaTokensBalance = async (solanaTokens, userAddress) => {
|
|
29300
29254
|
try {
|
|
29301
|
-
const nativeToken = solanaTokens.find((t) => t.address ===
|
|
29302
|
-
const otherTokens = solanaTokens.filter((t) => t.address !==
|
|
29255
|
+
const nativeToken = solanaTokens.find((t) => t.address.toLowerCase() === nativeSolanaTokenAddress.toLowerCase());
|
|
29256
|
+
const otherTokens = solanaTokens.filter((t) => t.address.toLowerCase() !== nativeSolanaTokenAddress.toLowerCase());
|
|
29303
29257
|
const [nativeBalance, tokenBalances] = await Promise.all([
|
|
29304
29258
|
nativeToken
|
|
29305
29259
|
? getSolanaNativeBalance(userAddress)
|
|
@@ -29308,7 +29262,7 @@ const getAllSolanaTokensBalance = async (solanaTokens, userAddress) => {
|
|
|
29308
29262
|
]);
|
|
29309
29263
|
return solanaTokens.map((token) => ({
|
|
29310
29264
|
...token,
|
|
29311
|
-
balance: token.address ===
|
|
29265
|
+
balance: token.address.toLowerCase() === nativeSolanaTokenAddress.toLowerCase()
|
|
29312
29266
|
? formatBNToReadable(nativeBalance, token.decimals)
|
|
29313
29267
|
: formatBNToReadable(tokenBalances[token.address], token.decimals),
|
|
29314
29268
|
}));
|
|
@@ -29610,7 +29564,7 @@ const useStellarBalance = ({ userAddress, chain, enabled, token, refreshInterval
|
|
|
29610
29564
|
};
|
|
29611
29565
|
|
|
29612
29566
|
function useNativeTokenForChain(chain) {
|
|
29613
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens,
|
|
29567
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens();
|
|
29614
29568
|
const getTokensForChainType = () => {
|
|
29615
29569
|
if (!chain?.chainType)
|
|
29616
29570
|
return [];
|
|
@@ -29629,8 +29583,6 @@ function useNativeTokenForChain(chain) {
|
|
|
29629
29583
|
return xrplTokens;
|
|
29630
29584
|
case ChainType.STELLAR:
|
|
29631
29585
|
return stellarTokens;
|
|
29632
|
-
case ChainType.CANTON:
|
|
29633
|
-
return cantonTokens;
|
|
29634
29586
|
}
|
|
29635
29587
|
};
|
|
29636
29588
|
const nativeTokenForChainType = useMemo(() => {
|
|
@@ -29865,11 +29817,6 @@ const useNativeBalance = (chain) => {
|
|
|
29865
29817
|
break;
|
|
29866
29818
|
case ChainType.STELLAR:
|
|
29867
29819
|
balance = nativeStellarBalance;
|
|
29868
|
-
break;
|
|
29869
|
-
case ChainType.CANTON:
|
|
29870
|
-
// TODO: implement canton balance fetching
|
|
29871
|
-
balance = undefined;
|
|
29872
|
-
break;
|
|
29873
29820
|
}
|
|
29874
29821
|
const balanceFormatted = !!balance
|
|
29875
29822
|
? formatBNToReadable(balance.value, balance.decimals)
|
|
@@ -29906,9 +29853,6 @@ const useNativeBalance = (chain) => {
|
|
|
29906
29853
|
return isXrpLoading;
|
|
29907
29854
|
case ChainType.STELLAR:
|
|
29908
29855
|
return isStellarLoading;
|
|
29909
|
-
case ChainType.CANTON:
|
|
29910
|
-
// TODO: implement canton balance fetching
|
|
29911
|
-
return false;
|
|
29912
29856
|
}
|
|
29913
29857
|
}, [
|
|
29914
29858
|
chain?.chainType,
|
|
@@ -30133,7 +30077,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30133
30077
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30134
30078
|
if (!optionalChains.length)
|
|
30135
30079
|
return;
|
|
30136
|
-
const { EthereumProvider } = await import('./index.es-
|
|
30080
|
+
const { EthereumProvider } = await import('./index.es-DSQHpime.js');
|
|
30137
30081
|
const rawProvider = await EthereumProvider.init({
|
|
30138
30082
|
...restParameters,
|
|
30139
30083
|
disableProviderPing: true,
|
|
@@ -30363,8 +30307,6 @@ const useSigner = ({ chain }) => {
|
|
|
30363
30307
|
return isXrplSignerReady;
|
|
30364
30308
|
case ChainType.STELLAR:
|
|
30365
30309
|
return isStellarSignerReady;
|
|
30366
|
-
case ChainType.CANTON:
|
|
30367
|
-
return false;
|
|
30368
30310
|
}
|
|
30369
30311
|
}, [
|
|
30370
30312
|
chain?.chainType,
|
|
@@ -30814,21 +30756,21 @@ const useSendTransactionStore = create((set, get) => ({
|
|
|
30814
30756
|
|
|
30815
30757
|
const useDepositAddressStore = create((set) => ({
|
|
30816
30758
|
deposit: null,
|
|
30817
|
-
|
|
30759
|
+
isEnabled: false,
|
|
30818
30760
|
setDeposit: (data) => {
|
|
30819
30761
|
set({ deposit: data });
|
|
30820
30762
|
},
|
|
30821
|
-
|
|
30822
|
-
set({
|
|
30763
|
+
toggleDepositFlow: (enabled) => {
|
|
30764
|
+
set({ isEnabled: enabled });
|
|
30823
30765
|
},
|
|
30824
30766
|
}));
|
|
30825
30767
|
|
|
30826
30768
|
function useDepositAddress(squidRoute) {
|
|
30827
|
-
const {
|
|
30828
|
-
|
|
30769
|
+
const { isEnabled, depositAddress } = useDepositAddressStore((state) => ({
|
|
30770
|
+
isEnabled: state.isEnabled,
|
|
30829
30771
|
depositAddress: state.deposit?.depositAddress,
|
|
30830
30772
|
}));
|
|
30831
|
-
const { setDeposit,
|
|
30773
|
+
const { setDeposit, toggleDepositFlow, deposit } = useDepositAddressStore();
|
|
30832
30774
|
const { squid } = useSquidStore();
|
|
30833
30775
|
const { fromChain } = useSwap();
|
|
30834
30776
|
const isAvailableAsPaymentMethod = useMemo(() => {
|
|
@@ -30837,7 +30779,6 @@ function useDepositAddress(squidRoute) {
|
|
|
30837
30779
|
const chainsSupportingDepositAddress = [
|
|
30838
30780
|
CHAIN_IDS.BITCOIN,
|
|
30839
30781
|
CHAIN_IDS.SOLANA,
|
|
30840
|
-
CHAIN_IDS.CANTON,
|
|
30841
30782
|
];
|
|
30842
30783
|
return chainsSupportingDepositAddress.includes(fromChain.chainId);
|
|
30843
30784
|
}, [fromChain?.chainId]);
|
|
@@ -30845,50 +30786,34 @@ function useDepositAddress(squidRoute) {
|
|
|
30845
30786
|
return (squidRoute?.transactionRequest?.type ===
|
|
30846
30787
|
SquidDataType.ChainflipDepositAddress);
|
|
30847
30788
|
}, [squidRoute?.transactionRequest?.type]);
|
|
30848
|
-
|
|
30849
|
-
|
|
30850
|
-
|
|
30851
|
-
|
|
30852
|
-
|
|
30853
|
-
|
|
30854
|
-
: "connectedWallet";
|
|
30855
|
-
const isDepositAddressActive = paymentMethod === "depositAddress";
|
|
30789
|
+
const enable = useCallback(() => {
|
|
30790
|
+
toggleDepositFlow(true);
|
|
30791
|
+
}, [toggleDepositFlow]);
|
|
30792
|
+
const disable = useCallback(() => {
|
|
30793
|
+
toggleDepositFlow(false);
|
|
30794
|
+
}, [toggleDepositFlow]);
|
|
30856
30795
|
const closeDepositChannel = useCallback(() => {
|
|
30796
|
+
toggleDepositFlow(false);
|
|
30857
30797
|
setDeposit(null);
|
|
30858
|
-
}, [setDeposit]);
|
|
30798
|
+
}, [toggleDepositFlow, setDeposit]);
|
|
30859
30799
|
const getRouteWithDeposit = useMutation(async ({ route }) => {
|
|
30860
|
-
if (!squid
|
|
30861
|
-
throw new Error("
|
|
30862
|
-
|
|
30863
|
-
|
|
30864
|
-
|
|
30865
|
-
|
|
30866
|
-
|
|
30867
|
-
|
|
30868
|
-
|
|
30869
|
-
|
|
30870
|
-
statusTrackingId: depositAddressResponse.chainflipStatusTrackingId,
|
|
30871
|
-
});
|
|
30872
|
-
return;
|
|
30873
|
-
}
|
|
30874
|
-
else if (isDepositAddressDirectTransferRoute(route.transactionRequest)) {
|
|
30875
|
-
const orderHash = route.transactionRequest.data;
|
|
30876
|
-
setDeposit({
|
|
30877
|
-
amount: route.params.fromAmount ?? "",
|
|
30878
|
-
depositAddress: route.transactionRequest.target,
|
|
30879
|
-
// Squid Scan indexes the Canton tx by the orderHash
|
|
30880
|
-
statusTrackingId: orderHash,
|
|
30881
|
-
memo: orderHash,
|
|
30882
|
-
});
|
|
30883
|
-
return;
|
|
30884
|
-
}
|
|
30800
|
+
if (!squid)
|
|
30801
|
+
throw new Error("Squid SDK not initialized");
|
|
30802
|
+
const depositAddressResponse = (await squid.executeRoute({
|
|
30803
|
+
signer: {},
|
|
30804
|
+
route,
|
|
30805
|
+
}));
|
|
30806
|
+
setDeposit(depositAddressResponse);
|
|
30807
|
+
return {
|
|
30808
|
+
depositAddress: depositAddressResponse,
|
|
30809
|
+
};
|
|
30885
30810
|
});
|
|
30886
30811
|
return {
|
|
30887
|
-
|
|
30888
|
-
isDepositAddressActive,
|
|
30812
|
+
isEnabled,
|
|
30889
30813
|
isAvailableAsPaymentMethod,
|
|
30890
30814
|
swapWillGenerateDepositAddress,
|
|
30891
|
-
|
|
30815
|
+
enable,
|
|
30816
|
+
disable,
|
|
30892
30817
|
getRouteWithDeposit,
|
|
30893
30818
|
depositAddress,
|
|
30894
30819
|
closeDepositChannel,
|
|
@@ -30920,7 +30845,7 @@ const useUrlSwapParams = () => {
|
|
|
30920
30845
|
|
|
30921
30846
|
const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, queryOptions, }) => {
|
|
30922
30847
|
const { evmChains, cosmosChains, suiChains, xrplChains, stellarChains } = useSquidChains(direction);
|
|
30923
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens,
|
|
30848
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens(direction);
|
|
30924
30849
|
const { keplrTypeWallet } = useCosmosContext();
|
|
30925
30850
|
const placeholderData = useMemo(() => {
|
|
30926
30851
|
const tokens = {
|
|
@@ -30931,7 +30856,6 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30931
30856
|
[ChainType.SUI]: suiTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30932
30857
|
[ChainType.XRPL]: xrplTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30933
30858
|
[ChainType.STELLAR]: stellarTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30934
|
-
[ChainType.CANTON]: cantonTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30935
30859
|
};
|
|
30936
30860
|
if (!chainType) {
|
|
30937
30861
|
// Return all tokens with zero balance
|
|
@@ -30953,7 +30877,6 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30953
30877
|
suiTokens,
|
|
30954
30878
|
xrplTokens,
|
|
30955
30879
|
stellarTokens,
|
|
30956
|
-
cantonTokens,
|
|
30957
30880
|
]);
|
|
30958
30881
|
const isQueryEnabled = useMemo(() => {
|
|
30959
30882
|
// Respect the queryOptions.enabled override if provided
|
|
@@ -30976,8 +30899,6 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30976
30899
|
return xrplTokens.length > 0;
|
|
30977
30900
|
case ChainType.STELLAR:
|
|
30978
30901
|
return stellarTokens.length > 0;
|
|
30979
|
-
case ChainType.CANTON:
|
|
30980
|
-
return cantonTokens.length > 0;
|
|
30981
30902
|
}
|
|
30982
30903
|
}, [
|
|
30983
30904
|
chainType,
|
|
@@ -30990,7 +30911,6 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30990
30911
|
suiTokens.length,
|
|
30991
30912
|
xrplTokens.length,
|
|
30992
30913
|
stellarTokens.length,
|
|
30993
|
-
cantonTokens.length,
|
|
30994
30914
|
]);
|
|
30995
30915
|
const query = useQuery(keys().allTokensBalance(address, chainType, direction), async () => {
|
|
30996
30916
|
// Return zero balances if no address
|
|
@@ -31100,12 +31020,6 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
31100
31020
|
direction,
|
|
31101
31021
|
queryOptions,
|
|
31102
31022
|
});
|
|
31103
|
-
const cantonBalancesQuery = useAllTokensWithBalanceForChainType({
|
|
31104
|
-
chainType: ChainType.CANTON,
|
|
31105
|
-
address: connectedAddresses?.[ChainType.CANTON],
|
|
31106
|
-
direction,
|
|
31107
|
-
queryOptions,
|
|
31108
|
-
});
|
|
31109
31023
|
// Create a map of chain type to balance query results
|
|
31110
31024
|
const balanceQueries = useMemo(() => ({
|
|
31111
31025
|
[ChainType.EVM]: evmBalancesQuery,
|
|
@@ -31115,7 +31029,6 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
31115
31029
|
[ChainType.SUI]: suiBalancesQuery,
|
|
31116
31030
|
[ChainType.XRPL]: xrplBalancesQuery,
|
|
31117
31031
|
[ChainType.STELLAR]: stellarBalancesQuery,
|
|
31118
|
-
[ChainType.CANTON]: cantonBalancesQuery,
|
|
31119
31032
|
}), [
|
|
31120
31033
|
evmBalancesQuery,
|
|
31121
31034
|
cosmosBalancesQuery,
|
|
@@ -31124,7 +31037,6 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
31124
31037
|
suiBalancesQuery,
|
|
31125
31038
|
xrplBalancesQuery,
|
|
31126
31039
|
stellarBalancesQuery,
|
|
31127
|
-
cantonBalancesQuery,
|
|
31128
31040
|
]);
|
|
31129
31041
|
// Combine all tokens from different chains
|
|
31130
31042
|
const allTokens = useMemo(() => Object.values(balanceQueries).flatMap((query) => query.data?.tokens ?? []), [balanceQueries]);
|
|
@@ -31224,9 +31136,6 @@ const useMultiChainBalance = ({ chain, token, userAddress, enabled = true, }) =>
|
|
|
31224
31136
|
return xrplBalance;
|
|
31225
31137
|
case ChainType.STELLAR:
|
|
31226
31138
|
return stellarBalance;
|
|
31227
|
-
case ChainType.CANTON:
|
|
31228
|
-
// TODO: implement canton balance fetching
|
|
31229
|
-
return "0";
|
|
31230
31139
|
}
|
|
31231
31140
|
}, [
|
|
31232
31141
|
chain?.chainType,
|
|
@@ -32335,9 +32244,6 @@ function useSendTransaction({ to, amount, token, chain, }) {
|
|
|
32335
32244
|
chain,
|
|
32336
32245
|
});
|
|
32337
32246
|
break;
|
|
32338
|
-
case ChainType.CANTON: {
|
|
32339
|
-
throw new Error("Not implemented");
|
|
32340
|
-
}
|
|
32341
32247
|
}
|
|
32342
32248
|
return {
|
|
32343
32249
|
amount,
|
|
@@ -32541,8 +32447,6 @@ async function getSendTransactionStatus({ chain, txHash, }) {
|
|
|
32541
32447
|
txHash,
|
|
32542
32448
|
chain,
|
|
32543
32449
|
});
|
|
32544
|
-
case ChainType.CANTON:
|
|
32545
|
-
throw new Error("Not implemented");
|
|
32546
32450
|
}
|
|
32547
32451
|
}
|
|
32548
32452
|
|
|
@@ -32566,7 +32470,7 @@ const useHistory = (txType) => {
|
|
|
32566
32470
|
fromChain: tx.params.fromChain,
|
|
32567
32471
|
fromToken: tx.params.fromToken,
|
|
32568
32472
|
fromAddress: tx.params.fromAddress,
|
|
32569
|
-
fromAmount: tx.params.fromAmount
|
|
32473
|
+
fromAmount: tx.params.fromAmount,
|
|
32570
32474
|
toChain: tx.params.toChain,
|
|
32571
32475
|
toToken: tx.params.toToken,
|
|
32572
32476
|
toAddress: tx.params.toAddress,
|
|
@@ -32994,129 +32898,6 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32994
32898
|
};
|
|
32995
32899
|
};
|
|
32996
32900
|
|
|
32997
|
-
const useSwapStatusQuery = ({ transaction, retry = 25, refetchOnWindowFocus = "always", enabled = true, onStatus, onEndStatus, onNotFound, onError, }) => {
|
|
32998
|
-
const config = useConfigStore((state) => state.config);
|
|
32999
|
-
const isInitialized = useConfigStore((state) => state.isInitialized);
|
|
33000
|
-
const [isTransactionComplete, setIsTransactionComplete] = useState(false);
|
|
33001
|
-
const [refetchInterval, setRefetchInterval] = useState(getSwapTxStatusRefetchInterval(transaction));
|
|
33002
|
-
const { getChainType } = useSquidChains();
|
|
33003
|
-
const fetchTransactionStatusWithLatestConfig = useCallback(async () => {
|
|
33004
|
-
const latestConfig = useConfigStore.getState().config;
|
|
33005
|
-
return fetchSwapTransactionStatus({
|
|
33006
|
-
transaction,
|
|
33007
|
-
integratorId: latestConfig.integratorId,
|
|
33008
|
-
apiUrl: latestConfig.apiUrl,
|
|
33009
|
-
});
|
|
33010
|
-
}, [transaction]);
|
|
33011
|
-
const transactionStatusQuery = useQuery(keys().swapTransactionStatus(transaction?.transactionId), fetchTransactionStatusWithLatestConfig, {
|
|
33012
|
-
enabled: enabled &&
|
|
33013
|
-
transaction?.transactionId !== "0" &&
|
|
33014
|
-
!!transaction?.transactionId &&
|
|
33015
|
-
!!transaction.fromAddress &&
|
|
33016
|
-
!!config.apiUrl &&
|
|
33017
|
-
transaction !== undefined &&
|
|
33018
|
-
!isTransactionComplete &&
|
|
33019
|
-
isInitialized,
|
|
33020
|
-
refetchInterval(statusResponse) {
|
|
33021
|
-
if (statusResponse &&
|
|
33022
|
-
transactionEndStatuses.includes(getTransactionStatus(statusResponse) ?? "")) {
|
|
33023
|
-
return false;
|
|
33024
|
-
}
|
|
33025
|
-
return refetchInterval;
|
|
33026
|
-
},
|
|
33027
|
-
retryDelay: getChainType(transaction?.fromChain) === ChainType.COSMOS ? 5000 : 3000,
|
|
33028
|
-
retry: getChainType(transaction?.fromChain) === ChainType.COSMOS ? 6 : retry,
|
|
33029
|
-
refetchOnWindowFocus,
|
|
33030
|
-
onSuccess: (statusResponse) => {
|
|
33031
|
-
WidgetEvents.getInstance().dispatchSwapStatus(statusResponse.squidTransactionStatus ?? "");
|
|
33032
|
-
onStatus?.({
|
|
33033
|
-
status: getTransactionStatus(statusResponse) ?? "",
|
|
33034
|
-
statusResponse,
|
|
33035
|
-
});
|
|
33036
|
-
const endStatus = getTransactionEndStatus({ statusResponse });
|
|
33037
|
-
if (endStatus) {
|
|
33038
|
-
setIsTransactionComplete(true);
|
|
33039
|
-
onEndStatus?.({ status: endStatus, statusResponse });
|
|
33040
|
-
}
|
|
33041
|
-
},
|
|
33042
|
-
onError: (error) => {
|
|
33043
|
-
if (is404Error(error.cause)) {
|
|
33044
|
-
onNotFound?.();
|
|
33045
|
-
return;
|
|
33046
|
-
}
|
|
33047
|
-
setRefetchInterval(-1);
|
|
33048
|
-
setIsTransactionComplete(true);
|
|
33049
|
-
onError?.();
|
|
33050
|
-
},
|
|
33051
|
-
});
|
|
33052
|
-
return {
|
|
33053
|
-
transactionStatusQuery,
|
|
33054
|
-
};
|
|
33055
|
-
};
|
|
33056
|
-
|
|
33057
|
-
// Statuses that indicate the source deposit has been received and the swap is
|
|
33058
|
-
// now progressing — the point at which it becomes a history-backed transaction.
|
|
33059
|
-
const sourceReceivedStatuses = [
|
|
33060
|
-
// Chainflip
|
|
33061
|
-
"DEPOSIT_RECEIVED",
|
|
33062
|
-
"BROADCAST_REQUESTED",
|
|
33063
|
-
"COMPLETE",
|
|
33064
|
-
// Canton (Squid Intents)
|
|
33065
|
-
"awaiting",
|
|
33066
|
-
"success",
|
|
33067
|
-
];
|
|
33068
|
-
/**
|
|
33069
|
-
* Tracks a generated deposit address before it becomes a persisted swap history item.
|
|
33070
|
-
*
|
|
33071
|
-
* Mirrors the hooks-first pattern of `useExecuteTransaction`: once the source deposit
|
|
33072
|
-
* is received, it registers the transaction in the transaction + history stores, then
|
|
33073
|
-
* signals the view (via `onReceived`) to navigate. The view never writes to the stores.
|
|
33074
|
-
*/
|
|
33075
|
-
const useDepositTransactionStatus = ({ transaction, route, retry = 25, refetchOnWindowFocus = "always", enabled = true, onReceived, }) => {
|
|
33076
|
-
const { fromChain, toChain } = useSwap();
|
|
33077
|
-
const { addSwapTransaction } = useHistory();
|
|
33078
|
-
const getTransaction = useTransactionStore((state) => state.getTransaction);
|
|
33079
|
-
const setTransactionStoreState = useTransactionStore((state) => state.setTransactionState);
|
|
33080
|
-
return useSwapStatusQuery({
|
|
33081
|
-
transaction,
|
|
33082
|
-
retry,
|
|
33083
|
-
refetchOnWindowFocus,
|
|
33084
|
-
enabled,
|
|
33085
|
-
onStatus: ({ status }) => {
|
|
33086
|
-
if (!sourceReceivedStatuses.includes(status))
|
|
33087
|
-
return;
|
|
33088
|
-
if (!transaction?.transactionId || !route?.transactionRequest)
|
|
33089
|
-
return;
|
|
33090
|
-
const txLocalId = transaction.transactionId;
|
|
33091
|
-
if (getTransaction(txLocalId))
|
|
33092
|
-
return;
|
|
33093
|
-
useTransactionStore.setState({
|
|
33094
|
-
txLocalId,
|
|
33095
|
-
currentTransaction: undefined,
|
|
33096
|
-
});
|
|
33097
|
-
const tx = {
|
|
33098
|
-
routeType: route.transactionRequest.type,
|
|
33099
|
-
fromChain,
|
|
33100
|
-
toChain,
|
|
33101
|
-
fromAddress: transaction.fromAddress,
|
|
33102
|
-
transactionId: txLocalId,
|
|
33103
|
-
transactionIdForStatus: transaction.transactionIdForStatus,
|
|
33104
|
-
quoteId: transaction.quoteId ?? "",
|
|
33105
|
-
status: TransactionStatus.ONGOING,
|
|
33106
|
-
sourceStatus: TransactionStatus.SUCCESS,
|
|
33107
|
-
timestamp: Date.now(),
|
|
33108
|
-
};
|
|
33109
|
-
setTransactionStoreState(txLocalId, tx);
|
|
33110
|
-
addSwapTransaction({
|
|
33111
|
-
...tx,
|
|
33112
|
-
params: route.params,
|
|
33113
|
-
estimate: route.estimate,
|
|
33114
|
-
});
|
|
33115
|
-
onReceived?.();
|
|
33116
|
-
},
|
|
33117
|
-
});
|
|
33118
|
-
};
|
|
33119
|
-
|
|
33120
32901
|
const DEFAULT_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/providers/squid.webp";
|
|
33121
32902
|
const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/providers/axelar.webp";
|
|
33122
32903
|
const useEstimate = (squidRoute) => {
|
|
@@ -36435,7 +36216,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36435
36216
|
if (!route.params.fromAddress || !route.params.toAddress) {
|
|
36436
36217
|
throw new Error("From or to address is required");
|
|
36437
36218
|
}
|
|
36438
|
-
const isDirectTransfer =
|
|
36219
|
+
const isDirectTransfer = isDepositRoute(route);
|
|
36439
36220
|
// Means it's a transfer to a deposit address
|
|
36440
36221
|
// Instead of a Swap/Contract call using a DEX like Jupiter
|
|
36441
36222
|
if (isDirectTransfer) {
|
|
@@ -36446,7 +36227,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36446
36227
|
throw new Error("Deposit address is required");
|
|
36447
36228
|
}
|
|
36448
36229
|
const signature = await executeSolanaTransfer({
|
|
36449
|
-
amount: BigInt(route.params.fromAmount
|
|
36230
|
+
amount: BigInt(route.params.fromAmount),
|
|
36450
36231
|
target: depositData.depositAddress,
|
|
36451
36232
|
signer: solanaSigner,
|
|
36452
36233
|
connection: solanaConnection,
|
|
@@ -36456,7 +36237,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36456
36237
|
const txParams = setTransactionState({
|
|
36457
36238
|
route,
|
|
36458
36239
|
txHash,
|
|
36459
|
-
transactionIdForStatus: depositData.
|
|
36240
|
+
transactionIdForStatus: depositData.chainflipStatusTrackingId,
|
|
36460
36241
|
userAddress: sourceUserAddress,
|
|
36461
36242
|
status: TransactionStatus.INITIAL_LOADING,
|
|
36462
36243
|
sourceStatus: TransactionStatus.ONGOING,
|
|
@@ -36507,7 +36288,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36507
36288
|
}
|
|
36508
36289
|
});
|
|
36509
36290
|
const swapMutationBitcoin = useMutation(async ({ id, route }) => {
|
|
36510
|
-
const { depositAddress, amount: sendAmount,
|
|
36291
|
+
const { depositAddress, amount: sendAmount, chainflipStatusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
|
|
36511
36292
|
if (!depositAddress) {
|
|
36512
36293
|
throw new Error(`Invalid deposit address: ${depositAddress}`);
|
|
36513
36294
|
}
|
|
@@ -36530,7 +36311,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36530
36311
|
txHash,
|
|
36531
36312
|
// When bridging from Bitcoin we need to send the chainflipId to the status endpoint
|
|
36532
36313
|
// instead of the Bitcoin transaction hash
|
|
36533
|
-
transactionIdForStatus:
|
|
36314
|
+
transactionIdForStatus: chainflipStatusTrackingId,
|
|
36534
36315
|
userAddress: sourceUserAddress,
|
|
36535
36316
|
status: TransactionStatus.INITIAL_LOADING,
|
|
36536
36317
|
sourceStatus: TransactionStatus.ONGOING,
|
|
@@ -36978,7 +36759,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36978
36759
|
const squid = useSquidStore((state) => state.squid);
|
|
36979
36760
|
const fallbackAddress = useSwapRoutePersistStore((store) => store.swapRoute?.fallbackAddress);
|
|
36980
36761
|
const depositRefundAddress = useSwapRoutePersistStore((store) => store.swapRoute?.depositRefundAddress);
|
|
36981
|
-
const {
|
|
36762
|
+
const { isAvailableAsPaymentMethod, isEnabled: isDepositAddressEnabled } = useDepositAddress();
|
|
36982
36763
|
const getRouteMutation = useGetRoute();
|
|
36983
36764
|
const { fromChain, toChain, fromPrice, destinationAddress: { address: destinationAddress } = {}, fromToken, toToken, } = useSwap();
|
|
36984
36765
|
const { connectedAddress: { address: sourceConnectedAddress }, } = useMultiChainWallet(fromChain);
|
|
@@ -36986,7 +36767,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36986
36767
|
// Tokens will be sent to this address in case of swap failure
|
|
36987
36768
|
//
|
|
36988
36769
|
// If deposit address is not selected, we use the connected address as the source address instead
|
|
36989
|
-
const sourceUserAddress =
|
|
36770
|
+
const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
|
|
36990
36771
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
36991
36772
|
: sourceConnectedAddress;
|
|
36992
36773
|
const squidRouteQueryKeys = useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromPrice, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChain?.chainType, config.preHook, config.postHook, config.overrideGasRefundAddress), [
|
|
@@ -37131,50 +36912,94 @@ function useSendTransactionStatus({ chain, txHash, }) {
|
|
|
37131
36912
|
* Fetch status of a Swap transaction
|
|
37132
36913
|
*/
|
|
37133
36914
|
const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocus = "always", enabled = true, }) => {
|
|
36915
|
+
const config = useConfigStore((state) => state.config);
|
|
36916
|
+
const isInitialized = useConfigStore((state) => state.isInitialized);
|
|
37134
36917
|
const { replaceSwapTransactionStatus } = useHistory();
|
|
37135
36918
|
const findTransaction = useHistoryStore((state) => state.findTransaction);
|
|
36919
|
+
const [isTransactionComplete, setIsTransactionComplete] = useState(false);
|
|
36920
|
+
const [refetchInterval, setRefetchInterval] = useState(getSwapTxStatusRefetchInterval(transaction));
|
|
36921
|
+
const { getChainType } = useSquidChains();
|
|
37136
36922
|
const currentHistoryItem = useMemo(() => findTransaction({
|
|
37137
36923
|
transactionId: transaction?.transactionId,
|
|
37138
36924
|
txType: HistoryTxType.SWAP,
|
|
37139
36925
|
}), [findTransaction, transaction?.transactionId]);
|
|
37140
|
-
|
|
37141
|
-
|
|
37142
|
-
|
|
37143
|
-
|
|
36926
|
+
/**
|
|
36927
|
+
* Transaction status endpoint
|
|
36928
|
+
* Squid api is using axelar endpoint and parsing the response
|
|
36929
|
+
* @returns {StatusResponse} Status response
|
|
36930
|
+
*/
|
|
36931
|
+
const fetchTransactionStatusWithLatestConfig = useCallback(async () => {
|
|
36932
|
+
const latestConfig = useConfigStore.getState().config;
|
|
36933
|
+
return fetchSwapTransactionStatus({
|
|
36934
|
+
transaction,
|
|
36935
|
+
integratorId: latestConfig.integratorId,
|
|
36936
|
+
apiUrl: latestConfig.apiUrl,
|
|
36937
|
+
});
|
|
36938
|
+
}, [transaction]);
|
|
36939
|
+
const transactionStatusQuery = useQuery(keys().swapTransactionStatus(transaction?.transactionId), fetchTransactionStatusWithLatestConfig, {
|
|
37144
36940
|
enabled: enabled &&
|
|
36941
|
+
transaction?.transactionId !== "0" &&
|
|
36942
|
+
!!transaction?.transactionId &&
|
|
36943
|
+
!!transaction.fromAddress &&
|
|
36944
|
+
!!config.apiUrl &&
|
|
36945
|
+
transaction !== undefined &&
|
|
36946
|
+
!isTransactionComplete &&
|
|
36947
|
+
isInitialized &&
|
|
37145
36948
|
!!currentHistoryItem &&
|
|
37146
36949
|
!isHistoryTransactionEnded({
|
|
37147
36950
|
data: currentHistoryItem?.data,
|
|
37148
36951
|
txType: HistoryTxType.SWAP,
|
|
37149
36952
|
}),
|
|
37150
|
-
|
|
37151
|
-
|
|
37152
|
-
|
|
37153
|
-
|
|
37154
|
-
|
|
37155
|
-
statusResponse
|
|
37156
|
-
|
|
37157
|
-
}
|
|
36953
|
+
refetchInterval(statusResponse) {
|
|
36954
|
+
// If the status response is something telling that the transaction
|
|
36955
|
+
// is finished, then store transaction history state if success
|
|
36956
|
+
// And return false to indicate refetcher to stop
|
|
36957
|
+
if (statusResponse &&
|
|
36958
|
+
transactionEndStatuses.includes(getTransactionStatus(statusResponse) ?? "")) {
|
|
36959
|
+
return false;
|
|
36960
|
+
}
|
|
36961
|
+
return refetchInterval; // Had to handle a variable here because after onError, we want the interval to stop
|
|
37158
36962
|
},
|
|
37159
|
-
|
|
37160
|
-
|
|
37161
|
-
|
|
37162
|
-
|
|
37163
|
-
|
|
37164
|
-
|
|
37165
|
-
|
|
37166
|
-
});
|
|
36963
|
+
// At the moment Cosmos indexing takes more time, so need more time between retries
|
|
36964
|
+
retryDelay: getChainType(transaction?.fromChain) === ChainType.COSMOS ? 5000 : 3000,
|
|
36965
|
+
retry: getChainType(transaction?.fromChain) === ChainType.COSMOS ? 6 : retry,
|
|
36966
|
+
refetchOnWindowFocus,
|
|
36967
|
+
onSuccess: (statusResponse) => {
|
|
36968
|
+
// Dispatch event
|
|
36969
|
+
WidgetEvents.getInstance().dispatchSwapStatus(statusResponse.squidTransactionStatus ?? "");
|
|
36970
|
+
const endStatus = getTransactionEndStatus({ statusResponse });
|
|
36971
|
+
if (endStatus && transaction?.transactionId) {
|
|
36972
|
+
setIsTransactionComplete(true);
|
|
36973
|
+
replaceSwapTransactionStatus({
|
|
36974
|
+
transactionId: transaction.transactionId,
|
|
36975
|
+
statusResponse,
|
|
36976
|
+
status: endStatus,
|
|
36977
|
+
});
|
|
36978
|
+
}
|
|
37167
36979
|
},
|
|
37168
|
-
onError: () => {
|
|
36980
|
+
onError: (error) => {
|
|
36981
|
+
// `fetchTransactionStatus` throws an error with a cause being an AxiosError
|
|
36982
|
+
const is404 = is404Error(error.cause);
|
|
37169
36983
|
if (!transaction?.transactionId)
|
|
37170
36984
|
return;
|
|
37171
|
-
|
|
37172
|
-
|
|
37173
|
-
|
|
37174
|
-
|
|
37175
|
-
|
|
36985
|
+
if (is404) {
|
|
36986
|
+
replaceSwapTransactionStatus({
|
|
36987
|
+
transactionId: transaction.transactionId,
|
|
36988
|
+
statusResponse: undefined,
|
|
36989
|
+
status: TransactionStatus.NOT_FOUND,
|
|
36990
|
+
});
|
|
36991
|
+
}
|
|
36992
|
+
else {
|
|
36993
|
+
setRefetchInterval(-1);
|
|
36994
|
+
setIsTransactionComplete(true);
|
|
36995
|
+
replaceSwapTransactionStatus({
|
|
36996
|
+
transactionId: transaction.transactionId,
|
|
36997
|
+
statusResponse: undefined,
|
|
36998
|
+
status: TransactionStatus.ERROR,
|
|
36999
|
+
});
|
|
37000
|
+
}
|
|
37176
37001
|
},
|
|
37177
|
-
})
|
|
37002
|
+
});
|
|
37178
37003
|
return {
|
|
37179
37004
|
transactionStatusQuery,
|
|
37180
37005
|
latestStatus: transactionStatusQuery.data
|
|
@@ -37573,10 +37398,8 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37573
37398
|
}
|
|
37574
37399
|
if (assetsColorsResponse.status === "fulfilled") {
|
|
37575
37400
|
useAssetsColorsStore.setState(assetsColorsResponse.value);
|
|
37401
|
+
initializeSquidWithAssetsColors(squid, assetsColorsResponse.value);
|
|
37576
37402
|
}
|
|
37577
|
-
initializeSquidData(squid, assetsColorsResponse.status === "fulfilled"
|
|
37578
|
-
? assetsColorsResponse.value
|
|
37579
|
-
: undefined);
|
|
37580
37403
|
const shouldResetSwapRouteStore =
|
|
37581
37404
|
// reset swap route if specified in config
|
|
37582
37405
|
!config?.loadPreviousStateFromLocalStorage ||
|
|
@@ -37653,5 +37476,5 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37653
37476
|
React.createElement(CosmosProvider, null, children)))))))))) : (placeholder);
|
|
37654
37477
|
};
|
|
37655
37478
|
|
|
37656
|
-
export { useDepositAddress as $, AxelarStatusResponseType as A, useHederaTokenAssociations as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useKeyboardNavigation as E, useSquidQueryClient as F, useSquid as G, HistoryTxType as H, useStellarAccountActivation as I, useStellarTrustLine as J, useAddressBookStore as K, useAssetsColorsStore as L, useFavoriteTokensStore as M, Nr as N, useHistoryStore as O, useSendTransactionStore as P, QueryKeys as Q, useConfigStore as R, SquidStatusErrorType as S, TransactionErrorType as T, useSquidStore as U, useSwapRoutePersistStore as V, Wo as W, XamanXrplNetwork as X, useTransactionStore as Y, ConnectingWalletStatus as Z, useWalletStore as _, WindowWalletFlag as a,
|
|
37657
|
-
//# sourceMappingURL=index-
|
|
37479
|
+
export { useDepositAddress as $, AxelarStatusResponseType as A, useHederaTokenAssociations as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useKeyboardNavigation as E, useSquidQueryClient as F, useSquid as G, HistoryTxType as H, useStellarAccountActivation as I, useStellarTrustLine as J, useAddressBookStore as K, useAssetsColorsStore as L, useFavoriteTokensStore as M, Nr as N, useHistoryStore as O, useSendTransactionStore as P, QueryKeys as Q, useConfigStore as R, SquidStatusErrorType as S, TransactionErrorType as T, useSquidStore as U, useSwapRoutePersistStore as V, Wo as W, XamanXrplNetwork as X, useTransactionStore as Y, ConnectingWalletStatus as Z, useWalletStore as _, WindowWalletFlag as a, useGetOnrampPaymentTypes as a$, useSwap as a0, buildUrlSearchParamsFromSwapEvent as a1, parseInitialAssetsFromUrl as a2, useUrlSwapParams as a3, useAllConnectedWalletBalances as a4, useAllTokensWithBalanceForChainType as a5, useCosmosBalance as a6, useEvmBalance as a7, useMultiChainBalance as a8, useMultipleTokenPrices as a9, useSwapTransactionStatus as aA, useAvatar as aB, useHistory as aC, useDebouncedValue as aD, useAddToken as aE, useAutoConnect as aF, useEnsDataForAddress as aG, useEnsSearch as aH, useGnosisContext as aI, useIsSameAddressAndGnosisContext as aJ, useIntegratorContext as aK, useMultiChainWallet as aL, useSigner as aM, useWallet as aN, useWallets as aO, useXrplTrustLine as aP, TX_STATUS_CONSTANTS as aQ, FINAL_TRANSACTION_STATUSES as aR, useGetFiatQuote as aS, useGetOnRampConfig as aT, useExecuteFiatQuote as aU, useFiatOnRampTxStatus as aV, useFiatTransactions as aW, useCurrencyDetails as aX, useCountryDetails as aY, useAvailableQuotes as aZ, useRecommendedQuote as a_, useBitcoinNativeBalance as aa, useCosmosNativeBalance as ab, useEvmNativeBalance as ac, useNativeBalance as ad, useSolanaNativeBalance as ae, useStellarNativeBalance as af, useSuiNativeBalance as ag, useXrplNativeBalance as ah, useNativeTokenForChain as ai, useSingleTokenPrice as aj, useSourceChainGasToken as ak, useSquidTokens as al, useHistoricalData as am, useTokensData as an, useEstimateSendTransaction as ao, useSendTransaction as ap, useSendTransactionGas as aq, useAllTransactionsStatus as ar, useApproval as as, useEstimate as at, useEstimatePriceImpact as au, useExecuteTransaction as av, useGetRoute as aw, useGetRouteWrapper as ax, useRouteWarnings as ay, useSendTransactionStatus as az, chainTypeToZeroAddressMap as b, filterWagmiConnector as b$, useSuggestedFiatAmounts as b0, SquidProvider as b1, EnsService as b2, getXummClient as b3, isXamanXAppContext as b4, getQueryHeaders as b5, getStatusCode as b6, is404Error as b7, assetsBaseUrl as b8, shareSubgraphId as b9, fetchHighestBalanceToken as bA, getInitialOrDefaultTokenAddressForChain as bB, getInitialTokenAddressForChain as bC, filterTokensForDestination as bD, getInitialChainIdFromConfig as bE, getCosmosKey as bF, getKeysSettled as bG, getAllKeysForSupportedCosmosChains as bH, isCosmosAddressValid as bI, getCosmosSigningClient as bJ, getCosmosChainInfosObject as bK, connectCosmosWallet as bL, isFallbackAddressNeeded as bM, suggestChainOrThrow as bN, normalizeError as bO, transactionErrorCode as bP, isUserRejectionError as bQ, getTransactionError as bR, handleTransactionErrorEvents as bS, isSwapRouteError as bT, isStatusError as bU, createQuoteRequestParamsHash as bV, WidgetEvents as bW, EvmNetworkNotSupportedErrorCode as bX, addEthereumChain as bY, parseEvmAddress as bZ, formatEvmWallet as b_, sortTokensBySharedSubgraphIds as ba, getSupportedChainIdsForDirection as bb, filterChains as bc, filterTokens as bd, getTokenImage as be, getNewSwapParamsFromInput as bf, sortAllTokens as bg, findToken as bh, findNativeToken as bi, normalizeIbcAddress as bj, groupTokensBySymbol as bk, groupTokensByChainId as bl, filterViewableTokens as bm, getSecretNetworkBalances as bn, getTokenAssetsKey as bo, fetchAssetsColors as bp, initializeSquidWithAssetsColors as bq, isEmptyObject as br, normalizeTokenSymbol as bs, areTokenSymbolsCompatible as bt, isEvmosChain as bu, resolveChainIdFromAsset as bv, getConfigWithDefaults as bw, randomIntFromInterval as bx, getTokensForChain as by, getFirstAvailableChainId as bz, chainTypeToNativeTokenAddressMap as c, isHistoryTransactionPending as c$, waitForReceiptWithRetry as c0, getUserCountry as c1, getCountryData as c2, getCurrencyData as c3, adaptiveRound as c4, getSuggestedAmountsForCurrency as c5, HederaExtensionHelper as c6, convertHederaAccountIdToEvmAddress as c7, convertEvmAddressToHederaAccountId as c8, scaleHbarToWei as c9, isValidHorizonAsset as cA, formatTransactionHistoryDate as cB, getAxelarExplorerTxUrl as cC, getSourceExplorerTxUrl as cD, getMainExplorerUrl as cE, formatDistance as cF, formatSeconds as cG, formatSwapTxStatusResponseForStorage as cH, simplifyRouteAction as cI, fetchSwapTransactionStatus as cJ, compareTransactionIds as cK, isCoralBridgeAction as cL, isActionCompletedOnSourceTx as cM, sleep as cN, isDepositRoute as cO, isChainflipBridgeTransaction as cP, isOnChainTxData as cQ, getHistoryTransactionId as cR, getStepStatuses as cS, getHalfSuccessState as cT, getStepsInfos as cU, getSwapTxStatusRefetchInterval as cV, getSendTxStatusRefetchInterval as cW, chainflipMultihopBridgeType as cX, getBridgeType as cY, getTransactionStatus as cZ, getTransactionEndStatus as c_, scaleWeiToHbar as ca, parseToBigInt as cb, roundNumericValue as cc, formatUnitsRounded as cd, formatTokenAmount as ce, formatUsdAmount as cf, trimExtraDecimals as cg, getNumericValue as ch, cleanAmount as ci, convertTokenAmountToUSD as cj, convertUSDToTokenAmount as ck, calculateTotal24hChange as cl, getRouteExpiry as cm, searchTokens as cn, filterSolanaWallets as co, isSolanaAddressValid as cp, executeSolanaSwap as cq, executeSolanaTransfer as cr, isStellarAddressValid as cs, getStellarNetwork as ct, stellarAddressToScVal as cu, getStellarTrustLineAsset as cv, isStellarToken as cw, isStellarIssuedToken as cx, getStellarHorizonApiUrl as cy, isValidIssuedAsset as cz, definedInWindow as d, isHistoryTransactionFailed as d0, isHistoryTransactionWarning as d1, isHistoryTransactionEnded as d2, formatHash as d3, isWalletAddressValid as d4, redirectToExtensionsStore as d5, accessProperty as d6, populateWallets as d7, getDefaultChain as d8, sortWallets as d9, areSameAddress as da, sortAddressBook as db, calculateTotalUsdBalanceUSD as dc, addTokenToWallet as dd, isEvmChainNotSupportedError as de, getWalletSupportedChainTypes as df, getConnectorForChainType as dg, walletSupportsChainType as dh, connectWallet as di, cancelConnectWallet as dj, isProblematicConnector as dk, mergeWallets as dl, isXionSmartContractAddress as dm, isXrplAddressValid as dn, buildXrplTrustSetTx as dp, getXrplNetwork as dq, parseXrplPaymentTx as dr, parseXrplTokenAddress as ds, er as e, formatBNToReadable as f, DEFAULT_ROUTE_REFETCH_INTERVAL as g, destinationAddressResetValue as h, fallbackAddressResetValue as i, nativeCosmosTokenAddress as j, nativeEvmTokenAddress as k, nativeSolanaTokenAddress as l, nativeStellarTokenAddress as m, nativeBitcoinTokenAddress as n, nativeSuiTokenAddress as o, nativeXrplTokenAddress as p, CosmosProvider as q, SendTransactionStatus as r, TransactionStatus as s, useTrackSearchEmpty as t, useCosmosContext as u, useSquidChains as v, walletIconBaseUrl as w, useClient as x, useCosmosForChain as y, useHederaAccountActivation as z };
|
|
37480
|
+
//# sourceMappingURL=index-BL_AUWQg.js.map
|