@0xsquid/react-hooks 8.8.0 → 8.8.1-beta-canton.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 +1 -0
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/types/canton.d.ts +2 -0
- package/dist/core/types/cosmos.d.ts +5 -0
- package/dist/core/types/wallet.d.ts +9 -6
- package/dist/hooks/chains/useSquidChains.d.ts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/store/useDepositAddressStore.d.ts +15 -3
- package/dist/hooks/swap/useDepositAddress.d.ts +2 -4
- package/dist/hooks/tokens/useSquidTokens.d.ts +1 -0
- package/dist/hooks/transaction/useDepositTransactionStatus.d.ts +25 -0
- package/dist/hooks/transaction/useSwapStatusQuery.d.ts +26 -0
- package/dist/hooks/wallet/useMultiChainWallet.d.ts +41 -15
- package/dist/hooks/wallet/useWallet.d.ts +45 -15
- package/dist/{index-CHdL63Y4.js → index-CtTVUC-R.js} +298 -108
- package/dist/index-CtTVUC-R.js.map +1 -0
- package/dist/{index-IxCpRlyV.js → index-D1udDcRZ.js} +300 -108
- package/dist/index-D1udDcRZ.js.map +1 -0
- package/dist/{index.es-B_4aEeiW.js → index.es-DFjaMQJG.js} +2 -2
- package/dist/{index.es-B_4aEeiW.js.map → index.es-DFjaMQJG.js.map} +1 -1
- package/dist/{index.es-C1qztDII.js → index.es-Q71H7cJa.js} +2 -2
- package/dist/{index.es-C1qztDII.js.map → index.es-Q71H7cJa.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/{secretService-vD8qpukk.js → secretService-BJNdJc-J.js} +2 -2
- package/dist/{secretService-vD8qpukk.js.map → secretService-BJNdJc-J.js.map} +1 -1
- package/dist/{secretService-D0p2T9tf.js → secretService-Dg5_VwtW.js} +2 -2
- package/dist/{secretService-D0p2T9tf.js.map → secretService-Dg5_VwtW.js.map} +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.esm.js +8 -1
- package/dist/server.esm.js.map +1 -1
- package/dist/server.js +8 -0
- package/dist/server.js.map +1 -1
- package/dist/services/internal/cantonService.d.ts +2 -0
- package/dist/services/internal/transactionService.d.ts +5 -1
- package/dist/{stellarService.client-DKQ8QpMf.js → stellarService.client-B9xCCNV0.js} +2 -2
- package/dist/{stellarService.client-DKQ8QpMf.js.map → stellarService.client-B9xCCNV0.js.map} +1 -1
- package/dist/{stellarService.client-Cia5YJMU.js → stellarService.client-BFUfF3-j.js} +2 -2
- package/dist/{stellarService.client-Cia5YJMU.js.map → stellarService.client-BFUfF3-j.js.map} +1 -1
- package/package.json +2 -2
- package/dist/index-CHdL63Y4.js.map +0 -1
- package/dist/index-IxCpRlyV.js.map +0 -1
|
@@ -78,6 +78,8 @@ const solanaZeroAddress = "11111111111111111111111111111111";
|
|
|
78
78
|
const suiZeroAddress = "0x0000000000000000000000000000000000000000";
|
|
79
79
|
const xrplZeroAddress = "rrrrrrrrrrrrrrrrrrrrrhoLvTp";
|
|
80
80
|
const stellarZeroAddress = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
|
|
81
|
+
// TODO: check
|
|
82
|
+
const cantonZeroAddress = "none::12200000000000000000000000000000000000000000000000000000000000000000";
|
|
81
83
|
const chainTypeToZeroAddressMap = {
|
|
82
84
|
[squidTypes.ChainType.EVM]: viem.zeroAddress,
|
|
83
85
|
[squidTypes.ChainType.COSMOS]: cosmosZeroAddress,
|
|
@@ -86,6 +88,7 @@ const chainTypeToZeroAddressMap = {
|
|
|
86
88
|
[squidTypes.ChainType.SUI]: suiZeroAddress,
|
|
87
89
|
[squidTypes.ChainType.XRPL]: xrplZeroAddress,
|
|
88
90
|
[squidTypes.ChainType.STELLAR]: stellarZeroAddress,
|
|
91
|
+
[squidTypes.ChainType.CANTON]: cantonZeroAddress,
|
|
89
92
|
};
|
|
90
93
|
const nativeEvmTokenAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
91
94
|
const nativeCosmosTokenAddress = "uosmo";
|
|
@@ -94,6 +97,7 @@ const nativeBitcoinTokenAddress = "satoshi";
|
|
|
94
97
|
const nativeSuiTokenAddress = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
95
98
|
const nativeXrplTokenAddress = "xrp";
|
|
96
99
|
const nativeStellarTokenAddress = "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA";
|
|
100
|
+
const nativeCantonTokenAddress = "DSO::1220b1431ef217342db44d516bb9befde802be7d8899637d290895fa58880f19accc";
|
|
97
101
|
// by setting slippage to undefined, it's set to "auto"
|
|
98
102
|
const defaultSlippage = undefined;
|
|
99
103
|
const destinationAddressResetValue = "null";
|
|
@@ -157,6 +161,7 @@ const CHAIN_IDS = {
|
|
|
157
161
|
XRPL_TESTNET: "xrpl-testnet",
|
|
158
162
|
STELLAR: "stellar-mainnet",
|
|
159
163
|
STELLAR_TESTNET: "stellar-testnet",
|
|
164
|
+
CANTON: "canton",
|
|
160
165
|
};
|
|
161
166
|
const chainTypeToDefaultChainIdMap = {
|
|
162
167
|
[squidTypes.ChainType.EVM]: CHAIN_IDS.ETHEREUM,
|
|
@@ -166,6 +171,7 @@ const chainTypeToDefaultChainIdMap = {
|
|
|
166
171
|
[squidTypes.ChainType.SUI]: CHAIN_IDS.SUI,
|
|
167
172
|
[squidTypes.ChainType.XRPL]: CHAIN_IDS.XRPL,
|
|
168
173
|
[squidTypes.ChainType.STELLAR]: CHAIN_IDS.STELLAR,
|
|
174
|
+
[squidTypes.ChainType.CANTON]: CHAIN_IDS.CANTON,
|
|
169
175
|
};
|
|
170
176
|
const chainTypeToNativeTokenAddressMap = {
|
|
171
177
|
[squidTypes.ChainType.EVM]: nativeEvmTokenAddress,
|
|
@@ -175,6 +181,7 @@ const chainTypeToNativeTokenAddressMap = {
|
|
|
175
181
|
[squidTypes.ChainType.SUI]: nativeSuiTokenAddress,
|
|
176
182
|
[squidTypes.ChainType.XRPL]: nativeXrplTokenAddress,
|
|
177
183
|
[squidTypes.ChainType.STELLAR]: nativeStellarTokenAddress,
|
|
184
|
+
[squidTypes.ChainType.CANTON]: nativeCantonTokenAddress,
|
|
178
185
|
};
|
|
179
186
|
const defaultConfigValues = {
|
|
180
187
|
integratorId: INTEGRATOR_ID,
|
|
@@ -20872,6 +20879,18 @@ const isBitcoinAddressValid = (address) => {
|
|
|
20872
20879
|
}
|
|
20873
20880
|
};
|
|
20874
20881
|
|
|
20882
|
+
// Canton PartyID = address
|
|
20883
|
+
const CANTON_PARTY_ID_SEPARATOR = "::";
|
|
20884
|
+
function isCantonAddressValid(address) {
|
|
20885
|
+
// Canton address format: `name::fingerprint`, where name is an arbitrary string
|
|
20886
|
+
// and fingerprint is a 64-character hex string with a 1220 prefix (SHA-256 hash of the public key)
|
|
20887
|
+
const parts = address.split(CANTON_PARTY_ID_SEPARATOR);
|
|
20888
|
+
if (parts.length !== 2)
|
|
20889
|
+
return false;
|
|
20890
|
+
const [name, fingerprint] = parts;
|
|
20891
|
+
return name.length > 0 && /^1220[0-9a-f]{64}$/.test(fingerprint);
|
|
20892
|
+
}
|
|
20893
|
+
|
|
20875
20894
|
exports.HistoryTxType = void 0;
|
|
20876
20895
|
(function (HistoryTxType) {
|
|
20877
20896
|
HistoryTxType[HistoryTxType["SWAP"] = 0] = "SWAP";
|
|
@@ -21144,7 +21163,7 @@ function isActionCompletedOnSourceTx(action, fromChainId) {
|
|
|
21144
21163
|
function sleep(ms) {
|
|
21145
21164
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21146
21165
|
}
|
|
21147
|
-
const
|
|
21166
|
+
const isChainflipDepositRoute = (route) => {
|
|
21148
21167
|
return (!!route &&
|
|
21149
21168
|
route.transactionRequest?.type === squidTypes.SquidDataType.ChainflipDepositAddress);
|
|
21150
21169
|
};
|
|
@@ -21169,6 +21188,12 @@ function isOnChainTxData(squidData) {
|
|
|
21169
21188
|
squidTypes.SquidDataType.DepositAddressWithMemo,
|
|
21170
21189
|
].includes(squidData.type);
|
|
21171
21190
|
}
|
|
21191
|
+
/**
|
|
21192
|
+
* Checks if a route is of type DepositAddressDirectTransfer
|
|
21193
|
+
*/
|
|
21194
|
+
function isDepositAddressDirectTransferRoute(squidData) {
|
|
21195
|
+
return (squidData.type === squidTypes.SquidDataType.DepositAddressDirectTransfer);
|
|
21196
|
+
}
|
|
21172
21197
|
function getHistoryTransactionId(tx) {
|
|
21173
21198
|
switch (tx.txType) {
|
|
21174
21199
|
case exports.HistoryTxType.SWAP:
|
|
@@ -21671,7 +21696,17 @@ const chainTypeToTrimLength = {
|
|
|
21671
21696
|
start: 4,
|
|
21672
21697
|
end: 4,
|
|
21673
21698
|
},
|
|
21699
|
+
// abc...123::abc...123
|
|
21700
|
+
[squidTypes.ChainType.CANTON]: {
|
|
21701
|
+
start: 3,
|
|
21702
|
+
end: 3,
|
|
21703
|
+
},
|
|
21674
21704
|
};
|
|
21705
|
+
const truncateWithEllipsis = (value, startLength, endLength) => value.length <= startLength + endLength
|
|
21706
|
+
? value
|
|
21707
|
+
: value.slice(0, startLength) +
|
|
21708
|
+
"..." +
|
|
21709
|
+
value.slice(value.length - endLength);
|
|
21675
21710
|
const formatHash = ({ chainType, hash }) => {
|
|
21676
21711
|
if (!hash)
|
|
21677
21712
|
return "";
|
|
@@ -21684,14 +21719,15 @@ const formatHash = ({ chainType, hash }) => {
|
|
|
21684
21719
|
chainTypeFormat = squidTypes.ChainType.COSMOS;
|
|
21685
21720
|
}
|
|
21686
21721
|
}
|
|
21687
|
-
const
|
|
21688
|
-
|
|
21689
|
-
|
|
21690
|
-
|
|
21691
|
-
return
|
|
21692
|
-
|
|
21693
|
-
|
|
21694
|
-
|
|
21722
|
+
const { start, end } = chainTypeToTrimLength[chainTypeFormat];
|
|
21723
|
+
if (chainTypeFormat === squidTypes.ChainType.CANTON &&
|
|
21724
|
+
hash.includes(CANTON_PARTY_ID_SEPARATOR)) {
|
|
21725
|
+
const [namespace, identifier] = hash.split(CANTON_PARTY_ID_SEPARATOR);
|
|
21726
|
+
return (truncateWithEllipsis(namespace, start, end) +
|
|
21727
|
+
CANTON_PARTY_ID_SEPARATOR +
|
|
21728
|
+
truncateWithEllipsis(identifier, start, end));
|
|
21729
|
+
}
|
|
21730
|
+
return truncateWithEllipsis(hash, start, end);
|
|
21695
21731
|
};
|
|
21696
21732
|
const isWalletAddressValid = (chainData, address) => {
|
|
21697
21733
|
if (!address || !chainData?.chainType)
|
|
@@ -21711,6 +21747,8 @@ const isWalletAddressValid = (chainData, address) => {
|
|
|
21711
21747
|
return isXrplAddressValid(address);
|
|
21712
21748
|
case squidTypes.ChainType.STELLAR:
|
|
21713
21749
|
return isStellarAddressValid(address);
|
|
21750
|
+
case squidTypes.ChainType.CANTON:
|
|
21751
|
+
return isCantonAddressValid(address);
|
|
21714
21752
|
}
|
|
21715
21753
|
};
|
|
21716
21754
|
const redirectToExtensionsStore = (wallet) => {
|
|
@@ -21972,6 +22010,8 @@ const connectByChainType = async (chainType, wallet, defaultChain, params) => {
|
|
|
21972
22010
|
connector,
|
|
21973
22011
|
},
|
|
21974
22012
|
});
|
|
22013
|
+
case squidTypes.ChainType.CANTON:
|
|
22014
|
+
return null;
|
|
21975
22015
|
}
|
|
21976
22016
|
};
|
|
21977
22017
|
const getChainTypesToConnect = (selectedChainTypes, defaultChain, supportedChains) => {
|
|
@@ -23046,7 +23086,10 @@ const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute, tokens, chai
|
|
|
23046
23086
|
else {
|
|
23047
23087
|
newFallbackAddress = fallbackAddress ?? initialSwapRoute?.fallbackAddress;
|
|
23048
23088
|
}
|
|
23049
|
-
const
|
|
23089
|
+
const sourceChainChanged = fromChainId !== undefined && fromChainId !== initialSwapRoute?.fromChainId;
|
|
23090
|
+
const newDepositRefundAddress = sourceChainChanged
|
|
23091
|
+
? undefined
|
|
23092
|
+
: depositRefundAddress || initialSwapRoute?.depositRefundAddress;
|
|
23050
23093
|
return {
|
|
23051
23094
|
fromChainId: srcChainId,
|
|
23052
23095
|
fromTokenAddress: sourceTokenAddress,
|
|
@@ -23325,7 +23368,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23325
23368
|
};
|
|
23326
23369
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23327
23370
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23328
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23371
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-Dg5_VwtW.js'); });
|
|
23329
23372
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23330
23373
|
};
|
|
23331
23374
|
function getTokenAssetsKey(token) {
|
|
@@ -25299,7 +25342,7 @@ const useSquidTokens = (direction) => {
|
|
|
25299
25342
|
config.availableChains,
|
|
25300
25343
|
direction,
|
|
25301
25344
|
]);
|
|
25302
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = React.useMemo(() => {
|
|
25345
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, cantonTokens, } = React.useMemo(() => {
|
|
25303
25346
|
return tokens?.reduce((acc, token) => {
|
|
25304
25347
|
switch (token.type) {
|
|
25305
25348
|
case squidTypes.ChainType.EVM:
|
|
@@ -25323,6 +25366,9 @@ const useSquidTokens = (direction) => {
|
|
|
25323
25366
|
case squidTypes.ChainType.STELLAR:
|
|
25324
25367
|
acc.stellarTokens.push(token);
|
|
25325
25368
|
break;
|
|
25369
|
+
case squidTypes.ChainType.CANTON:
|
|
25370
|
+
acc.cantonTokens.push(token);
|
|
25371
|
+
break;
|
|
25326
25372
|
}
|
|
25327
25373
|
return acc;
|
|
25328
25374
|
}, {
|
|
@@ -25333,6 +25379,7 @@ const useSquidTokens = (direction) => {
|
|
|
25333
25379
|
suiTokens: [],
|
|
25334
25380
|
xrplTokens: [],
|
|
25335
25381
|
stellarTokens: [],
|
|
25382
|
+
cantonTokens: [],
|
|
25336
25383
|
});
|
|
25337
25384
|
}, [tokens]);
|
|
25338
25385
|
const findToken = React.useCallback((address, chainId) => {
|
|
@@ -25350,6 +25397,7 @@ const useSquidTokens = (direction) => {
|
|
|
25350
25397
|
suiTokens,
|
|
25351
25398
|
xrplTokens,
|
|
25352
25399
|
stellarTokens,
|
|
25400
|
+
cantonTokens,
|
|
25353
25401
|
};
|
|
25354
25402
|
};
|
|
25355
25403
|
|
|
@@ -25887,6 +25935,7 @@ const chainTypeToRefetchInterval = {
|
|
|
25887
25935
|
[squidTypes.ChainType.SUI]: 1_000,
|
|
25888
25936
|
[squidTypes.ChainType.XRPL]: 1_000,
|
|
25889
25937
|
[squidTypes.ChainType.STELLAR]: 1_000,
|
|
25938
|
+
[squidTypes.ChainType.CANTON]: 1_000,
|
|
25890
25939
|
};
|
|
25891
25940
|
/**
|
|
25892
25941
|
* Returns the status refetch interval of a Send transaction
|
|
@@ -26153,7 +26202,7 @@ const useSquidChains = (direction) => {
|
|
|
26153
26202
|
const chain = findChain(chainId);
|
|
26154
26203
|
return chain?.chainType;
|
|
26155
26204
|
}, [findChain]);
|
|
26156
|
-
const { evmChains, cosmosChains, suiChains, stellarChains, xrplChains } = React.useMemo(() => {
|
|
26205
|
+
const { evmChains, cosmosChains, suiChains, stellarChains, xrplChains, cantonChains, } = React.useMemo(() => {
|
|
26157
26206
|
return chains.reduce((acc, chain) => {
|
|
26158
26207
|
switch (chain.chainType) {
|
|
26159
26208
|
case squidTypes.ChainType.EVM:
|
|
@@ -26171,6 +26220,9 @@ const useSquidChains = (direction) => {
|
|
|
26171
26220
|
case squidTypes.ChainType.STELLAR:
|
|
26172
26221
|
acc.stellarChains.push(chain);
|
|
26173
26222
|
break;
|
|
26223
|
+
case squidTypes.ChainType.CANTON:
|
|
26224
|
+
acc.cantonChains.push(chain);
|
|
26225
|
+
break;
|
|
26174
26226
|
}
|
|
26175
26227
|
return acc;
|
|
26176
26228
|
}, {
|
|
@@ -26179,6 +26231,7 @@ const useSquidChains = (direction) => {
|
|
|
26179
26231
|
suiChains: [],
|
|
26180
26232
|
xrplChains: [],
|
|
26181
26233
|
stellarChains: [],
|
|
26234
|
+
cantonChains: [],
|
|
26182
26235
|
});
|
|
26183
26236
|
}, [chains]);
|
|
26184
26237
|
const { supportedSourceChains, supportedDestinationChains } = React.useMemo(() => {
|
|
@@ -26199,6 +26252,7 @@ const useSquidChains = (direction) => {
|
|
|
26199
26252
|
suiChains,
|
|
26200
26253
|
xrplChains,
|
|
26201
26254
|
stellarChains,
|
|
26255
|
+
cantonChains,
|
|
26202
26256
|
getChainType,
|
|
26203
26257
|
findChain,
|
|
26204
26258
|
};
|
|
@@ -26723,7 +26777,7 @@ function useStellarWallets() {
|
|
|
26723
26777
|
try {
|
|
26724
26778
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26725
26779
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
26726
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
26780
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-BFUfF3-j.js'); });
|
|
26727
26781
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26728
26782
|
const promises = modules.map(async (module) => {
|
|
26729
26783
|
const isAvailable = await module.isAvailable();
|
|
@@ -27422,6 +27476,7 @@ const useMultiChainWallet = (chain) => {
|
|
|
27422
27476
|
const suiAddress = connectedAddresses[squidTypes.ChainType.SUI];
|
|
27423
27477
|
const xrplAddress = connectedAddresses[squidTypes.ChainType.XRPL];
|
|
27424
27478
|
const stellarAddress = connectedAddresses[squidTypes.ChainType.STELLAR];
|
|
27479
|
+
const cantonAddress = connectedAddresses[squidTypes.ChainType.CANTON];
|
|
27425
27480
|
// Cosmos is a special case because the address changes on every chain
|
|
27426
27481
|
// so we can't use the default cosmos connected address
|
|
27427
27482
|
const { data: cosmosAddress } = useCosmosForChain(chain);
|
|
@@ -27509,6 +27564,16 @@ const useMultiChainWallet = (chain) => {
|
|
|
27509
27564
|
chainType: chain.chainType,
|
|
27510
27565
|
}),
|
|
27511
27566
|
};
|
|
27567
|
+
case squidTypes.ChainType.CANTON:
|
|
27568
|
+
if (!cantonAddress)
|
|
27569
|
+
return {};
|
|
27570
|
+
return {
|
|
27571
|
+
address: cantonAddress,
|
|
27572
|
+
formatted: formatHash({
|
|
27573
|
+
hash: cantonAddress,
|
|
27574
|
+
chainType: chain.chainType,
|
|
27575
|
+
}),
|
|
27576
|
+
};
|
|
27512
27577
|
}
|
|
27513
27578
|
}, [
|
|
27514
27579
|
chain?.chainType,
|
|
@@ -27520,6 +27585,7 @@ const useMultiChainWallet = (chain) => {
|
|
|
27520
27585
|
suiAddress,
|
|
27521
27586
|
xrplAddress,
|
|
27522
27587
|
stellarAddress,
|
|
27588
|
+
cantonAddress,
|
|
27523
27589
|
]);
|
|
27524
27590
|
/**
|
|
27525
27591
|
* Change current network for desired chain
|
|
@@ -28344,6 +28410,8 @@ async function createClient(chain) {
|
|
|
28344
28410
|
return new XrplRpcClient(chain.rpc);
|
|
28345
28411
|
case squidTypes.ChainType.STELLAR:
|
|
28346
28412
|
return new StellarRpcClient(chain.rpc);
|
|
28413
|
+
case squidTypes.ChainType.CANTON:
|
|
28414
|
+
return null;
|
|
28347
28415
|
}
|
|
28348
28416
|
}
|
|
28349
28417
|
|
|
@@ -29536,7 +29604,7 @@ const useStellarBalance = ({ userAddress, chain, enabled, token, refreshInterval
|
|
|
29536
29604
|
};
|
|
29537
29605
|
|
|
29538
29606
|
function useNativeTokenForChain(chain) {
|
|
29539
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens();
|
|
29607
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, cantonTokens, } = useSquidTokens();
|
|
29540
29608
|
const getTokensForChainType = () => {
|
|
29541
29609
|
if (!chain?.chainType)
|
|
29542
29610
|
return [];
|
|
@@ -29555,6 +29623,8 @@ function useNativeTokenForChain(chain) {
|
|
|
29555
29623
|
return xrplTokens;
|
|
29556
29624
|
case squidTypes.ChainType.STELLAR:
|
|
29557
29625
|
return stellarTokens;
|
|
29626
|
+
case squidTypes.ChainType.CANTON:
|
|
29627
|
+
return cantonTokens;
|
|
29558
29628
|
}
|
|
29559
29629
|
};
|
|
29560
29630
|
const nativeTokenForChainType = React.useMemo(() => {
|
|
@@ -29789,6 +29859,11 @@ const useNativeBalance = (chain) => {
|
|
|
29789
29859
|
break;
|
|
29790
29860
|
case squidTypes.ChainType.STELLAR:
|
|
29791
29861
|
balance = nativeStellarBalance;
|
|
29862
|
+
break;
|
|
29863
|
+
case squidTypes.ChainType.CANTON:
|
|
29864
|
+
// TODO: implement canton balance fetching
|
|
29865
|
+
balance = undefined;
|
|
29866
|
+
break;
|
|
29792
29867
|
}
|
|
29793
29868
|
const balanceFormatted = !!balance
|
|
29794
29869
|
? formatBNToReadable(balance.value, balance.decimals)
|
|
@@ -29825,6 +29900,9 @@ const useNativeBalance = (chain) => {
|
|
|
29825
29900
|
return isXrpLoading;
|
|
29826
29901
|
case squidTypes.ChainType.STELLAR:
|
|
29827
29902
|
return isStellarLoading;
|
|
29903
|
+
case squidTypes.ChainType.CANTON:
|
|
29904
|
+
// TODO: implement canton balance fetching
|
|
29905
|
+
return false;
|
|
29828
29906
|
}
|
|
29829
29907
|
}, [
|
|
29830
29908
|
chain?.chainType,
|
|
@@ -30049,7 +30127,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30049
30127
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30050
30128
|
if (!optionalChains.length)
|
|
30051
30129
|
return;
|
|
30052
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
30130
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-Q71H7cJa.js'); });
|
|
30053
30131
|
const rawProvider = await EthereumProvider.init({
|
|
30054
30132
|
...restParameters,
|
|
30055
30133
|
disableProviderPing: true,
|
|
@@ -30279,6 +30357,8 @@ const useSigner = ({ chain }) => {
|
|
|
30279
30357
|
return isXrplSignerReady;
|
|
30280
30358
|
case squidTypes.ChainType.STELLAR:
|
|
30281
30359
|
return isStellarSignerReady;
|
|
30360
|
+
case squidTypes.ChainType.CANTON:
|
|
30361
|
+
return false;
|
|
30282
30362
|
}
|
|
30283
30363
|
}, [
|
|
30284
30364
|
chain?.chainType,
|
|
@@ -30751,6 +30831,7 @@ function useDepositAddress(squidRoute) {
|
|
|
30751
30831
|
const chainsSupportingDepositAddress = [
|
|
30752
30832
|
CHAIN_IDS.BITCOIN,
|
|
30753
30833
|
CHAIN_IDS.SOLANA,
|
|
30834
|
+
CHAIN_IDS.CANTON,
|
|
30754
30835
|
];
|
|
30755
30836
|
return chainsSupportingDepositAddress.includes(fromChain.chainId);
|
|
30756
30837
|
}, [fromChain?.chainId]);
|
|
@@ -30765,20 +30846,33 @@ function useDepositAddress(squidRoute) {
|
|
|
30765
30846
|
toggleDepositFlow(false);
|
|
30766
30847
|
}, [toggleDepositFlow]);
|
|
30767
30848
|
const closeDepositChannel = React.useCallback(() => {
|
|
30768
|
-
toggleDepositFlow(false);
|
|
30769
30849
|
setDeposit(null);
|
|
30770
|
-
}, [
|
|
30850
|
+
}, [setDeposit]);
|
|
30771
30851
|
const getRouteWithDeposit = reactQuery.useMutation(async ({ route }) => {
|
|
30772
|
-
if (!squid)
|
|
30773
|
-
throw new Error("
|
|
30774
|
-
|
|
30775
|
-
|
|
30776
|
-
|
|
30777
|
-
|
|
30778
|
-
|
|
30779
|
-
|
|
30780
|
-
|
|
30781
|
-
|
|
30852
|
+
if (!squid || !route.transactionRequest)
|
|
30853
|
+
throw new Error("Missing required params");
|
|
30854
|
+
if (isChainflipDepositRoute(route)) {
|
|
30855
|
+
const depositAddressResponse = (await squid.executeRoute({
|
|
30856
|
+
signer: {},
|
|
30857
|
+
route,
|
|
30858
|
+
}));
|
|
30859
|
+
setDeposit({
|
|
30860
|
+
amount: depositAddressResponse.amount,
|
|
30861
|
+
depositAddress: depositAddressResponse.depositAddress,
|
|
30862
|
+
statusTrackingId: depositAddressResponse.chainflipStatusTrackingId,
|
|
30863
|
+
});
|
|
30864
|
+
return;
|
|
30865
|
+
}
|
|
30866
|
+
else if (isDepositAddressDirectTransferRoute(route.transactionRequest)) {
|
|
30867
|
+
const orderHash = route.transactionRequest.data;
|
|
30868
|
+
setDeposit({
|
|
30869
|
+
amount: route.params.fromAmount ?? "",
|
|
30870
|
+
depositAddress: route.transactionRequest.target,
|
|
30871
|
+
statusTrackingId: orderHash,
|
|
30872
|
+
memo: orderHash,
|
|
30873
|
+
});
|
|
30874
|
+
return;
|
|
30875
|
+
}
|
|
30782
30876
|
});
|
|
30783
30877
|
return {
|
|
30784
30878
|
isEnabled,
|
|
@@ -30817,7 +30911,7 @@ const useUrlSwapParams = () => {
|
|
|
30817
30911
|
|
|
30818
30912
|
const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, queryOptions, }) => {
|
|
30819
30913
|
const { evmChains, cosmosChains, suiChains, xrplChains, stellarChains } = useSquidChains(direction);
|
|
30820
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens(direction);
|
|
30914
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, cantonTokens, } = useSquidTokens(direction);
|
|
30821
30915
|
const { keplrTypeWallet } = useCosmosContext();
|
|
30822
30916
|
const placeholderData = React.useMemo(() => {
|
|
30823
30917
|
const tokens = {
|
|
@@ -30828,6 +30922,7 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30828
30922
|
[squidTypes.ChainType.SUI]: suiTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30829
30923
|
[squidTypes.ChainType.XRPL]: xrplTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30830
30924
|
[squidTypes.ChainType.STELLAR]: stellarTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30925
|
+
[squidTypes.ChainType.CANTON]: cantonTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30831
30926
|
};
|
|
30832
30927
|
if (!chainType) {
|
|
30833
30928
|
// Return all tokens with zero balance
|
|
@@ -30849,6 +30944,7 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30849
30944
|
suiTokens,
|
|
30850
30945
|
xrplTokens,
|
|
30851
30946
|
stellarTokens,
|
|
30947
|
+
cantonTokens,
|
|
30852
30948
|
]);
|
|
30853
30949
|
const isQueryEnabled = React.useMemo(() => {
|
|
30854
30950
|
// Respect the queryOptions.enabled override if provided
|
|
@@ -30871,6 +30967,8 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30871
30967
|
return xrplTokens.length > 0;
|
|
30872
30968
|
case squidTypes.ChainType.STELLAR:
|
|
30873
30969
|
return stellarTokens.length > 0;
|
|
30970
|
+
case squidTypes.ChainType.CANTON:
|
|
30971
|
+
return cantonTokens.length > 0;
|
|
30874
30972
|
}
|
|
30875
30973
|
}, [
|
|
30876
30974
|
chainType,
|
|
@@ -30883,6 +30981,7 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30883
30981
|
suiTokens.length,
|
|
30884
30982
|
xrplTokens.length,
|
|
30885
30983
|
stellarTokens.length,
|
|
30984
|
+
cantonTokens.length,
|
|
30886
30985
|
]);
|
|
30887
30986
|
const query = reactQuery.useQuery(keys().allTokensBalance(address, chainType, direction), async () => {
|
|
30888
30987
|
// Return zero balances if no address
|
|
@@ -30992,6 +31091,12 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
30992
31091
|
direction,
|
|
30993
31092
|
queryOptions,
|
|
30994
31093
|
});
|
|
31094
|
+
const cantonBalancesQuery = useAllTokensWithBalanceForChainType({
|
|
31095
|
+
chainType: squidTypes.ChainType.CANTON,
|
|
31096
|
+
address: connectedAddresses?.[squidTypes.ChainType.CANTON],
|
|
31097
|
+
direction,
|
|
31098
|
+
queryOptions,
|
|
31099
|
+
});
|
|
30995
31100
|
// Create a map of chain type to balance query results
|
|
30996
31101
|
const balanceQueries = React.useMemo(() => ({
|
|
30997
31102
|
[squidTypes.ChainType.EVM]: evmBalancesQuery,
|
|
@@ -31001,6 +31106,7 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
31001
31106
|
[squidTypes.ChainType.SUI]: suiBalancesQuery,
|
|
31002
31107
|
[squidTypes.ChainType.XRPL]: xrplBalancesQuery,
|
|
31003
31108
|
[squidTypes.ChainType.STELLAR]: stellarBalancesQuery,
|
|
31109
|
+
[squidTypes.ChainType.CANTON]: cantonBalancesQuery,
|
|
31004
31110
|
}), [
|
|
31005
31111
|
evmBalancesQuery,
|
|
31006
31112
|
cosmosBalancesQuery,
|
|
@@ -31009,6 +31115,7 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
31009
31115
|
suiBalancesQuery,
|
|
31010
31116
|
xrplBalancesQuery,
|
|
31011
31117
|
stellarBalancesQuery,
|
|
31118
|
+
cantonBalancesQuery,
|
|
31012
31119
|
]);
|
|
31013
31120
|
// Combine all tokens from different chains
|
|
31014
31121
|
const allTokens = React.useMemo(() => Object.values(balanceQueries).flatMap((query) => query.data?.tokens ?? []), [balanceQueries]);
|
|
@@ -31108,6 +31215,9 @@ const useMultiChainBalance = ({ chain, token, userAddress, enabled = true, }) =>
|
|
|
31108
31215
|
return xrplBalance;
|
|
31109
31216
|
case squidTypes.ChainType.STELLAR:
|
|
31110
31217
|
return stellarBalance;
|
|
31218
|
+
case squidTypes.ChainType.CANTON:
|
|
31219
|
+
// TODO: implement canton balance fetching
|
|
31220
|
+
return "0";
|
|
31111
31221
|
}
|
|
31112
31222
|
}, [
|
|
31113
31223
|
chain?.chainType,
|
|
@@ -32216,6 +32326,9 @@ function useSendTransaction({ to, amount, token, chain, }) {
|
|
|
32216
32326
|
chain,
|
|
32217
32327
|
});
|
|
32218
32328
|
break;
|
|
32329
|
+
case squidTypes.ChainType.CANTON: {
|
|
32330
|
+
throw new Error("Not implemented");
|
|
32331
|
+
}
|
|
32219
32332
|
}
|
|
32220
32333
|
return {
|
|
32221
32334
|
amount,
|
|
@@ -32419,6 +32532,8 @@ async function getSendTransactionStatus({ chain, txHash, }) {
|
|
|
32419
32532
|
txHash,
|
|
32420
32533
|
chain,
|
|
32421
32534
|
});
|
|
32535
|
+
case squidTypes.ChainType.CANTON:
|
|
32536
|
+
throw new Error("Not implemented");
|
|
32422
32537
|
}
|
|
32423
32538
|
}
|
|
32424
32539
|
|
|
@@ -32442,7 +32557,7 @@ const useHistory = (txType) => {
|
|
|
32442
32557
|
fromChain: tx.params.fromChain,
|
|
32443
32558
|
fromToken: tx.params.fromToken,
|
|
32444
32559
|
fromAddress: tx.params.fromAddress,
|
|
32445
|
-
fromAmount: tx.params.fromAmount,
|
|
32560
|
+
fromAmount: tx.params.fromAmount ?? "",
|
|
32446
32561
|
toChain: tx.params.toChain,
|
|
32447
32562
|
toToken: tx.params.toToken,
|
|
32448
32563
|
toAddress: tx.params.toAddress,
|
|
@@ -32870,6 +32985,125 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32870
32985
|
};
|
|
32871
32986
|
};
|
|
32872
32987
|
|
|
32988
|
+
const useSwapStatusQuery = ({ transaction, retry = 25, refetchOnWindowFocus = "always", enabled = true, onStatus, onEndStatus, onNotFound, onError, }) => {
|
|
32989
|
+
const config = useConfigStore((state) => state.config);
|
|
32990
|
+
const isInitialized = useConfigStore((state) => state.isInitialized);
|
|
32991
|
+
const [isTransactionComplete, setIsTransactionComplete] = React.useState(false);
|
|
32992
|
+
const [refetchInterval, setRefetchInterval] = React.useState(getSwapTxStatusRefetchInterval(transaction));
|
|
32993
|
+
const { getChainType } = useSquidChains();
|
|
32994
|
+
const fetchTransactionStatusWithLatestConfig = React.useCallback(async () => {
|
|
32995
|
+
const latestConfig = useConfigStore.getState().config;
|
|
32996
|
+
return fetchSwapTransactionStatus({
|
|
32997
|
+
transaction,
|
|
32998
|
+
integratorId: latestConfig.integratorId,
|
|
32999
|
+
apiUrl: latestConfig.apiUrl,
|
|
33000
|
+
});
|
|
33001
|
+
}, [transaction]);
|
|
33002
|
+
const transactionStatusQuery = reactQuery.useQuery(keys().swapTransactionStatus(transaction?.transactionId), fetchTransactionStatusWithLatestConfig, {
|
|
33003
|
+
enabled: enabled &&
|
|
33004
|
+
transaction?.transactionId !== "0" &&
|
|
33005
|
+
!!transaction?.transactionId &&
|
|
33006
|
+
!!transaction.fromAddress &&
|
|
33007
|
+
!!config.apiUrl &&
|
|
33008
|
+
transaction !== undefined &&
|
|
33009
|
+
!isTransactionComplete &&
|
|
33010
|
+
isInitialized,
|
|
33011
|
+
refetchInterval(statusResponse) {
|
|
33012
|
+
if (statusResponse &&
|
|
33013
|
+
transactionEndStatuses.includes(getTransactionStatus(statusResponse) ?? "")) {
|
|
33014
|
+
return false;
|
|
33015
|
+
}
|
|
33016
|
+
return refetchInterval;
|
|
33017
|
+
},
|
|
33018
|
+
retryDelay: getChainType(transaction?.fromChain) === squidTypes.ChainType.COSMOS ? 5000 : 3000,
|
|
33019
|
+
retry: getChainType(transaction?.fromChain) === squidTypes.ChainType.COSMOS ? 6 : retry,
|
|
33020
|
+
refetchOnWindowFocus,
|
|
33021
|
+
onSuccess: (statusResponse) => {
|
|
33022
|
+
WidgetEvents.getInstance().dispatchSwapStatus(statusResponse.squidTransactionStatus ?? "");
|
|
33023
|
+
onStatus?.({
|
|
33024
|
+
status: getTransactionStatus(statusResponse) ?? "",
|
|
33025
|
+
statusResponse,
|
|
33026
|
+
});
|
|
33027
|
+
const endStatus = getTransactionEndStatus({ statusResponse });
|
|
33028
|
+
if (endStatus) {
|
|
33029
|
+
setIsTransactionComplete(true);
|
|
33030
|
+
onEndStatus?.({ status: endStatus, statusResponse });
|
|
33031
|
+
}
|
|
33032
|
+
},
|
|
33033
|
+
onError: (error) => {
|
|
33034
|
+
if (is404Error(error.cause)) {
|
|
33035
|
+
onNotFound?.();
|
|
33036
|
+
return;
|
|
33037
|
+
}
|
|
33038
|
+
setRefetchInterval(-1);
|
|
33039
|
+
setIsTransactionComplete(true);
|
|
33040
|
+
onError?.();
|
|
33041
|
+
},
|
|
33042
|
+
});
|
|
33043
|
+
return {
|
|
33044
|
+
transactionStatusQuery,
|
|
33045
|
+
};
|
|
33046
|
+
};
|
|
33047
|
+
|
|
33048
|
+
// Statuses that indicate the source deposit has been received and the swap is
|
|
33049
|
+
// now progressing — the point at which it becomes a history-backed transaction.
|
|
33050
|
+
const sourceReceivedStatuses = [
|
|
33051
|
+
"DEPOSIT_RECEIVED",
|
|
33052
|
+
"BROADCAST_REQUESTED",
|
|
33053
|
+
"COMPLETE",
|
|
33054
|
+
];
|
|
33055
|
+
/**
|
|
33056
|
+
* Tracks a generated deposit address before it becomes a persisted swap history item.
|
|
33057
|
+
*
|
|
33058
|
+
* Mirrors the hooks-first pattern of `useExecuteTransaction`: once the source deposit
|
|
33059
|
+
* is received, it registers the transaction in the transaction + history stores, then
|
|
33060
|
+
* signals the view (via `onReceived`) to navigate. The view never writes to the stores.
|
|
33061
|
+
*/
|
|
33062
|
+
const useDepositTransactionStatus = ({ transaction, route, retry = 25, refetchOnWindowFocus = "always", enabled = true, onReceived, }) => {
|
|
33063
|
+
const { fromChain, toChain } = useSwap();
|
|
33064
|
+
const { addSwapTransaction } = useHistory();
|
|
33065
|
+
const getTransaction = useTransactionStore((state) => state.getTransaction);
|
|
33066
|
+
const setTransactionStoreState = useTransactionStore((state) => state.setTransactionState);
|
|
33067
|
+
return useSwapStatusQuery({
|
|
33068
|
+
transaction,
|
|
33069
|
+
retry,
|
|
33070
|
+
refetchOnWindowFocus,
|
|
33071
|
+
enabled,
|
|
33072
|
+
onStatus: ({ status }) => {
|
|
33073
|
+
if (!sourceReceivedStatuses.includes(status))
|
|
33074
|
+
return;
|
|
33075
|
+
if (!transaction?.transactionId || !route?.transactionRequest)
|
|
33076
|
+
return;
|
|
33077
|
+
const txLocalId = transaction.transactionId;
|
|
33078
|
+
if (getTransaction(txLocalId))
|
|
33079
|
+
return;
|
|
33080
|
+
useTransactionStore.setState({
|
|
33081
|
+
txLocalId,
|
|
33082
|
+
currentTransaction: undefined,
|
|
33083
|
+
});
|
|
33084
|
+
const tx = {
|
|
33085
|
+
routeType: route.transactionRequest.type,
|
|
33086
|
+
fromChain,
|
|
33087
|
+
toChain,
|
|
33088
|
+
fromAddress: transaction.fromAddress,
|
|
33089
|
+
transactionId: txLocalId,
|
|
33090
|
+
transactionIdForStatus: transaction.transactionIdForStatus,
|
|
33091
|
+
quoteId: route.quoteId,
|
|
33092
|
+
status: exports.TransactionStatus.ONGOING,
|
|
33093
|
+
sourceStatus: exports.TransactionStatus.SUCCESS,
|
|
33094
|
+
timestamp: Date.now(),
|
|
33095
|
+
};
|
|
33096
|
+
setTransactionStoreState(txLocalId, tx);
|
|
33097
|
+
addSwapTransaction({
|
|
33098
|
+
...tx,
|
|
33099
|
+
params: route.params,
|
|
33100
|
+
estimate: route.estimate,
|
|
33101
|
+
});
|
|
33102
|
+
onReceived?.();
|
|
33103
|
+
},
|
|
33104
|
+
});
|
|
33105
|
+
};
|
|
33106
|
+
|
|
32873
33107
|
const DEFAULT_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/providers/squid.webp";
|
|
32874
33108
|
const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/providers/axelar.webp";
|
|
32875
33109
|
const useEstimate = (squidRoute) => {
|
|
@@ -36188,7 +36422,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36188
36422
|
if (!route.params.fromAddress || !route.params.toAddress) {
|
|
36189
36423
|
throw new Error("From or to address is required");
|
|
36190
36424
|
}
|
|
36191
|
-
const isDirectTransfer =
|
|
36425
|
+
const isDirectTransfer = isChainflipDepositRoute(route);
|
|
36192
36426
|
// Means it's a transfer to a deposit address
|
|
36193
36427
|
// Instead of a Swap/Contract call using a DEX like Jupiter
|
|
36194
36428
|
if (isDirectTransfer) {
|
|
@@ -36199,7 +36433,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36199
36433
|
throw new Error("Deposit address is required");
|
|
36200
36434
|
}
|
|
36201
36435
|
const signature = await executeSolanaTransfer({
|
|
36202
|
-
amount: BigInt(route.params.fromAmount),
|
|
36436
|
+
amount: BigInt(route.params.fromAmount ?? ""),
|
|
36203
36437
|
target: depositData.depositAddress,
|
|
36204
36438
|
signer: solanaSigner,
|
|
36205
36439
|
connection: solanaConnection,
|
|
@@ -36209,7 +36443,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36209
36443
|
const txParams = setTransactionState({
|
|
36210
36444
|
route,
|
|
36211
36445
|
txHash,
|
|
36212
|
-
transactionIdForStatus: depositData.
|
|
36446
|
+
transactionIdForStatus: depositData.statusTrackingId,
|
|
36213
36447
|
userAddress: sourceUserAddress,
|
|
36214
36448
|
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
36215
36449
|
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
@@ -36260,7 +36494,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36260
36494
|
}
|
|
36261
36495
|
});
|
|
36262
36496
|
const swapMutationBitcoin = reactQuery.useMutation(async ({ id, route }) => {
|
|
36263
|
-
const { depositAddress, amount: sendAmount,
|
|
36497
|
+
const { depositAddress, amount: sendAmount, statusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
|
|
36264
36498
|
if (!depositAddress) {
|
|
36265
36499
|
throw new Error(`Invalid deposit address: ${depositAddress}`);
|
|
36266
36500
|
}
|
|
@@ -36283,7 +36517,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36283
36517
|
txHash,
|
|
36284
36518
|
// When bridging from Bitcoin we need to send the chainflipId to the status endpoint
|
|
36285
36519
|
// instead of the Bitcoin transaction hash
|
|
36286
|
-
transactionIdForStatus:
|
|
36520
|
+
transactionIdForStatus: statusTrackingId,
|
|
36287
36521
|
userAddress: sourceUserAddress,
|
|
36288
36522
|
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
36289
36523
|
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
@@ -36884,94 +37118,50 @@ function useSendTransactionStatus({ chain, txHash, }) {
|
|
|
36884
37118
|
* Fetch status of a Swap transaction
|
|
36885
37119
|
*/
|
|
36886
37120
|
const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocus = "always", enabled = true, }) => {
|
|
36887
|
-
const config = useConfigStore((state) => state.config);
|
|
36888
|
-
const isInitialized = useConfigStore((state) => state.isInitialized);
|
|
36889
37121
|
const { replaceSwapTransactionStatus } = useHistory();
|
|
36890
37122
|
const findTransaction = useHistoryStore((state) => state.findTransaction);
|
|
36891
|
-
const [isTransactionComplete, setIsTransactionComplete] = React.useState(false);
|
|
36892
|
-
const [refetchInterval, setRefetchInterval] = React.useState(getSwapTxStatusRefetchInterval(transaction));
|
|
36893
|
-
const { getChainType } = useSquidChains();
|
|
36894
37123
|
const currentHistoryItem = React.useMemo(() => findTransaction({
|
|
36895
37124
|
transactionId: transaction?.transactionId,
|
|
36896
37125
|
txType: exports.HistoryTxType.SWAP,
|
|
36897
37126
|
}), [findTransaction, transaction?.transactionId]);
|
|
36898
|
-
|
|
36899
|
-
|
|
36900
|
-
|
|
36901
|
-
|
|
36902
|
-
*/
|
|
36903
|
-
const fetchTransactionStatusWithLatestConfig = React.useCallback(async () => {
|
|
36904
|
-
const latestConfig = useConfigStore.getState().config;
|
|
36905
|
-
return fetchSwapTransactionStatus({
|
|
36906
|
-
transaction,
|
|
36907
|
-
integratorId: latestConfig.integratorId,
|
|
36908
|
-
apiUrl: latestConfig.apiUrl,
|
|
36909
|
-
});
|
|
36910
|
-
}, [transaction]);
|
|
36911
|
-
const transactionStatusQuery = reactQuery.useQuery(keys().swapTransactionStatus(transaction?.transactionId), fetchTransactionStatusWithLatestConfig, {
|
|
37127
|
+
const transactionStatusQuery = useSwapStatusQuery({
|
|
37128
|
+
transaction,
|
|
37129
|
+
retry,
|
|
37130
|
+
refetchOnWindowFocus,
|
|
36912
37131
|
enabled: enabled &&
|
|
36913
|
-
transaction?.transactionId !== "0" &&
|
|
36914
|
-
!!transaction?.transactionId &&
|
|
36915
|
-
!!transaction.fromAddress &&
|
|
36916
|
-
!!config.apiUrl &&
|
|
36917
|
-
transaction !== undefined &&
|
|
36918
|
-
!isTransactionComplete &&
|
|
36919
|
-
isInitialized &&
|
|
36920
37132
|
!!currentHistoryItem &&
|
|
36921
37133
|
!isHistoryTransactionEnded({
|
|
36922
37134
|
data: currentHistoryItem?.data,
|
|
36923
37135
|
txType: exports.HistoryTxType.SWAP,
|
|
36924
37136
|
}),
|
|
36925
|
-
|
|
36926
|
-
|
|
36927
|
-
|
|
36928
|
-
|
|
36929
|
-
|
|
36930
|
-
|
|
36931
|
-
|
|
36932
|
-
}
|
|
36933
|
-
return refetchInterval; // Had to handle a variable here because after onError, we want the interval to stop
|
|
37137
|
+
onEndStatus: ({ status, statusResponse }) => {
|
|
37138
|
+
if (!transaction?.transactionId)
|
|
37139
|
+
return;
|
|
37140
|
+
replaceSwapTransactionStatus({
|
|
37141
|
+
transactionId: transaction.transactionId,
|
|
37142
|
+
statusResponse,
|
|
37143
|
+
status,
|
|
37144
|
+
});
|
|
36934
37145
|
},
|
|
36935
|
-
|
|
36936
|
-
|
|
36937
|
-
|
|
36938
|
-
|
|
36939
|
-
|
|
36940
|
-
|
|
36941
|
-
|
|
36942
|
-
|
|
36943
|
-
if (endStatus && transaction?.transactionId) {
|
|
36944
|
-
setIsTransactionComplete(true);
|
|
36945
|
-
replaceSwapTransactionStatus({
|
|
36946
|
-
transactionId: transaction.transactionId,
|
|
36947
|
-
statusResponse,
|
|
36948
|
-
status: endStatus,
|
|
36949
|
-
});
|
|
36950
|
-
}
|
|
37146
|
+
onNotFound: () => {
|
|
37147
|
+
if (!transaction?.transactionId)
|
|
37148
|
+
return;
|
|
37149
|
+
replaceSwapTransactionStatus({
|
|
37150
|
+
transactionId: transaction.transactionId,
|
|
37151
|
+
statusResponse: undefined,
|
|
37152
|
+
status: exports.TransactionStatus.NOT_FOUND,
|
|
37153
|
+
});
|
|
36951
37154
|
},
|
|
36952
|
-
onError: (
|
|
36953
|
-
// `fetchTransactionStatus` throws an error with a cause being an AxiosError
|
|
36954
|
-
const is404 = is404Error(error.cause);
|
|
37155
|
+
onError: () => {
|
|
36955
37156
|
if (!transaction?.transactionId)
|
|
36956
37157
|
return;
|
|
36957
|
-
|
|
36958
|
-
|
|
36959
|
-
|
|
36960
|
-
|
|
36961
|
-
|
|
36962
|
-
});
|
|
36963
|
-
}
|
|
36964
|
-
else {
|
|
36965
|
-
setRefetchInterval(-1);
|
|
36966
|
-
setIsTransactionComplete(true);
|
|
36967
|
-
replaceSwapTransactionStatus({
|
|
36968
|
-
transactionId: transaction.transactionId,
|
|
36969
|
-
statusResponse: undefined,
|
|
36970
|
-
status: exports.TransactionStatus.ERROR,
|
|
36971
|
-
});
|
|
36972
|
-
}
|
|
37158
|
+
replaceSwapTransactionStatus({
|
|
37159
|
+
transactionId: transaction.transactionId,
|
|
37160
|
+
statusResponse: undefined,
|
|
37161
|
+
status: exports.TransactionStatus.ERROR,
|
|
37162
|
+
});
|
|
36973
37163
|
},
|
|
36974
|
-
});
|
|
37164
|
+
}).transactionStatusQuery;
|
|
36975
37165
|
return {
|
|
36976
37166
|
transactionStatusQuery,
|
|
36977
37167
|
latestStatus: transactionStatusQuery.data
|
|
@@ -37564,9 +37754,10 @@ exports.initializeSquidWithAssetsColors = initializeSquidWithAssetsColors;
|
|
|
37564
37754
|
exports.is404Error = is404Error;
|
|
37565
37755
|
exports.isActionCompletedOnSourceTx = isActionCompletedOnSourceTx;
|
|
37566
37756
|
exports.isChainflipBridgeTransaction = isChainflipBridgeTransaction;
|
|
37757
|
+
exports.isChainflipDepositRoute = isChainflipDepositRoute;
|
|
37567
37758
|
exports.isCoralBridgeAction = isCoralBridgeAction;
|
|
37568
37759
|
exports.isCosmosAddressValid = isCosmosAddressValid;
|
|
37569
|
-
exports.
|
|
37760
|
+
exports.isDepositAddressDirectTransferRoute = isDepositAddressDirectTransferRoute;
|
|
37570
37761
|
exports.isEmptyObject = isEmptyObject;
|
|
37571
37762
|
exports.isEvmChainNotSupportedError = isEvmChainNotSupportedError;
|
|
37572
37763
|
exports.isEvmosChain = isEvmosChain;
|
|
@@ -37646,6 +37837,7 @@ exports.useCountryDetails = useCountryDetails;
|
|
|
37646
37837
|
exports.useCurrencyDetails = useCurrencyDetails;
|
|
37647
37838
|
exports.useDebouncedValue = useDebouncedValue;
|
|
37648
37839
|
exports.useDepositAddress = useDepositAddress;
|
|
37840
|
+
exports.useDepositTransactionStatus = useDepositTransactionStatus;
|
|
37649
37841
|
exports.useEnsDataForAddress = useEnsDataForAddress;
|
|
37650
37842
|
exports.useEnsSearch = useEnsSearch;
|
|
37651
37843
|
exports.useEstimate = useEstimate;
|
|
@@ -37712,4 +37904,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
37712
37904
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37713
37905
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37714
37906
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37715
|
-
//# sourceMappingURL=index-
|
|
37907
|
+
//# sourceMappingURL=index-D1udDcRZ.js.map
|