@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
|
@@ -57,6 +57,8 @@ 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";
|
|
60
62
|
const chainTypeToZeroAddressMap = {
|
|
61
63
|
[ChainType.EVM]: zeroAddress$1,
|
|
62
64
|
[ChainType.COSMOS]: cosmosZeroAddress,
|
|
@@ -65,6 +67,7 @@ const chainTypeToZeroAddressMap = {
|
|
|
65
67
|
[ChainType.SUI]: suiZeroAddress,
|
|
66
68
|
[ChainType.XRPL]: xrplZeroAddress,
|
|
67
69
|
[ChainType.STELLAR]: stellarZeroAddress,
|
|
70
|
+
[ChainType.CANTON]: cantonZeroAddress,
|
|
68
71
|
};
|
|
69
72
|
const nativeEvmTokenAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
70
73
|
const nativeCosmosTokenAddress = "uosmo";
|
|
@@ -73,6 +76,7 @@ const nativeBitcoinTokenAddress = "satoshi";
|
|
|
73
76
|
const nativeSuiTokenAddress = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
74
77
|
const nativeXrplTokenAddress = "xrp";
|
|
75
78
|
const nativeStellarTokenAddress = "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA";
|
|
79
|
+
const nativeCantonTokenAddress = "DSO::1220b1431ef217342db44d516bb9befde802be7d8899637d290895fa58880f19accc";
|
|
76
80
|
// by setting slippage to undefined, it's set to "auto"
|
|
77
81
|
const defaultSlippage = undefined;
|
|
78
82
|
const destinationAddressResetValue = "null";
|
|
@@ -136,6 +140,7 @@ const CHAIN_IDS = {
|
|
|
136
140
|
XRPL_TESTNET: "xrpl-testnet",
|
|
137
141
|
STELLAR: "stellar-mainnet",
|
|
138
142
|
STELLAR_TESTNET: "stellar-testnet",
|
|
143
|
+
CANTON: "canton",
|
|
139
144
|
};
|
|
140
145
|
const chainTypeToDefaultChainIdMap = {
|
|
141
146
|
[ChainType.EVM]: CHAIN_IDS.ETHEREUM,
|
|
@@ -145,6 +150,7 @@ const chainTypeToDefaultChainIdMap = {
|
|
|
145
150
|
[ChainType.SUI]: CHAIN_IDS.SUI,
|
|
146
151
|
[ChainType.XRPL]: CHAIN_IDS.XRPL,
|
|
147
152
|
[ChainType.STELLAR]: CHAIN_IDS.STELLAR,
|
|
153
|
+
[ChainType.CANTON]: CHAIN_IDS.CANTON,
|
|
148
154
|
};
|
|
149
155
|
const chainTypeToNativeTokenAddressMap = {
|
|
150
156
|
[ChainType.EVM]: nativeEvmTokenAddress,
|
|
@@ -154,6 +160,7 @@ const chainTypeToNativeTokenAddressMap = {
|
|
|
154
160
|
[ChainType.SUI]: nativeSuiTokenAddress,
|
|
155
161
|
[ChainType.XRPL]: nativeXrplTokenAddress,
|
|
156
162
|
[ChainType.STELLAR]: nativeStellarTokenAddress,
|
|
163
|
+
[ChainType.CANTON]: nativeCantonTokenAddress,
|
|
157
164
|
};
|
|
158
165
|
const defaultConfigValues = {
|
|
159
166
|
integratorId: INTEGRATOR_ID,
|
|
@@ -20851,6 +20858,18 @@ const isBitcoinAddressValid = (address$1) => {
|
|
|
20851
20858
|
}
|
|
20852
20859
|
};
|
|
20853
20860
|
|
|
20861
|
+
// Canton PartyID = address
|
|
20862
|
+
const CANTON_PARTY_ID_SEPARATOR = "::";
|
|
20863
|
+
function isCantonAddressValid(address) {
|
|
20864
|
+
// Canton address format: `name::fingerprint`, where name is an arbitrary string
|
|
20865
|
+
// and fingerprint is a 64-character hex string with a 1220 prefix (SHA-256 hash of the public key)
|
|
20866
|
+
const parts = address.split(CANTON_PARTY_ID_SEPARATOR);
|
|
20867
|
+
if (parts.length !== 2)
|
|
20868
|
+
return false;
|
|
20869
|
+
const [name, fingerprint] = parts;
|
|
20870
|
+
return name.length > 0 && /^1220[0-9a-f]{64}$/.test(fingerprint);
|
|
20871
|
+
}
|
|
20872
|
+
|
|
20854
20873
|
var HistoryTxType;
|
|
20855
20874
|
(function (HistoryTxType) {
|
|
20856
20875
|
HistoryTxType[HistoryTxType["SWAP"] = 0] = "SWAP";
|
|
@@ -21123,7 +21142,7 @@ function isActionCompletedOnSourceTx(action, fromChainId) {
|
|
|
21123
21142
|
function sleep(ms) {
|
|
21124
21143
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21125
21144
|
}
|
|
21126
|
-
const
|
|
21145
|
+
const isChainflipDepositRoute = (route) => {
|
|
21127
21146
|
return (!!route &&
|
|
21128
21147
|
route.transactionRequest?.type === SquidDataType.ChainflipDepositAddress);
|
|
21129
21148
|
};
|
|
@@ -21148,6 +21167,12 @@ function isOnChainTxData(squidData) {
|
|
|
21148
21167
|
SquidDataType.DepositAddressWithMemo,
|
|
21149
21168
|
].includes(squidData.type);
|
|
21150
21169
|
}
|
|
21170
|
+
/**
|
|
21171
|
+
* Checks if a route is of type DepositAddressDirectTransfer
|
|
21172
|
+
*/
|
|
21173
|
+
function isDepositAddressDirectTransferRoute(squidData) {
|
|
21174
|
+
return (squidData.type === SquidDataType.DepositAddressDirectTransfer);
|
|
21175
|
+
}
|
|
21151
21176
|
function getHistoryTransactionId(tx) {
|
|
21152
21177
|
switch (tx.txType) {
|
|
21153
21178
|
case HistoryTxType.SWAP:
|
|
@@ -21650,7 +21675,17 @@ const chainTypeToTrimLength = {
|
|
|
21650
21675
|
start: 4,
|
|
21651
21676
|
end: 4,
|
|
21652
21677
|
},
|
|
21678
|
+
// abc...123::abc...123
|
|
21679
|
+
[ChainType.CANTON]: {
|
|
21680
|
+
start: 3,
|
|
21681
|
+
end: 3,
|
|
21682
|
+
},
|
|
21653
21683
|
};
|
|
21684
|
+
const truncateWithEllipsis = (value, startLength, endLength) => value.length <= startLength + endLength
|
|
21685
|
+
? value
|
|
21686
|
+
: value.slice(0, startLength) +
|
|
21687
|
+
"..." +
|
|
21688
|
+
value.slice(value.length - endLength);
|
|
21654
21689
|
const formatHash = ({ chainType, hash }) => {
|
|
21655
21690
|
if (!hash)
|
|
21656
21691
|
return "";
|
|
@@ -21663,14 +21698,15 @@ const formatHash = ({ chainType, hash }) => {
|
|
|
21663
21698
|
chainTypeFormat = ChainType.COSMOS;
|
|
21664
21699
|
}
|
|
21665
21700
|
}
|
|
21666
|
-
const
|
|
21667
|
-
|
|
21668
|
-
|
|
21669
|
-
|
|
21670
|
-
return
|
|
21671
|
-
|
|
21672
|
-
|
|
21673
|
-
|
|
21701
|
+
const { start, end } = chainTypeToTrimLength[chainTypeFormat];
|
|
21702
|
+
if (chainTypeFormat === ChainType.CANTON &&
|
|
21703
|
+
hash.includes(CANTON_PARTY_ID_SEPARATOR)) {
|
|
21704
|
+
const [namespace, identifier] = hash.split(CANTON_PARTY_ID_SEPARATOR);
|
|
21705
|
+
return (truncateWithEllipsis(namespace, start, end) +
|
|
21706
|
+
CANTON_PARTY_ID_SEPARATOR +
|
|
21707
|
+
truncateWithEllipsis(identifier, start, end));
|
|
21708
|
+
}
|
|
21709
|
+
return truncateWithEllipsis(hash, start, end);
|
|
21674
21710
|
};
|
|
21675
21711
|
const isWalletAddressValid = (chainData, address) => {
|
|
21676
21712
|
if (!address || !chainData?.chainType)
|
|
@@ -21690,6 +21726,8 @@ const isWalletAddressValid = (chainData, address) => {
|
|
|
21690
21726
|
return isXrplAddressValid(address);
|
|
21691
21727
|
case ChainType.STELLAR:
|
|
21692
21728
|
return isStellarAddressValid(address);
|
|
21729
|
+
case ChainType.CANTON:
|
|
21730
|
+
return isCantonAddressValid(address);
|
|
21693
21731
|
}
|
|
21694
21732
|
};
|
|
21695
21733
|
const redirectToExtensionsStore = (wallet) => {
|
|
@@ -21951,6 +21989,8 @@ const connectByChainType = async (chainType, wallet, defaultChain, params) => {
|
|
|
21951
21989
|
connector,
|
|
21952
21990
|
},
|
|
21953
21991
|
});
|
|
21992
|
+
case ChainType.CANTON:
|
|
21993
|
+
return null;
|
|
21954
21994
|
}
|
|
21955
21995
|
};
|
|
21956
21996
|
const getChainTypesToConnect = (selectedChainTypes, defaultChain, supportedChains) => {
|
|
@@ -23025,7 +23065,10 @@ const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute, tokens, chai
|
|
|
23025
23065
|
else {
|
|
23026
23066
|
newFallbackAddress = fallbackAddress ?? initialSwapRoute?.fallbackAddress;
|
|
23027
23067
|
}
|
|
23028
|
-
const
|
|
23068
|
+
const sourceChainChanged = fromChainId !== undefined && fromChainId !== initialSwapRoute?.fromChainId;
|
|
23069
|
+
const newDepositRefundAddress = sourceChainChanged
|
|
23070
|
+
? undefined
|
|
23071
|
+
: depositRefundAddress || initialSwapRoute?.depositRefundAddress;
|
|
23029
23072
|
return {
|
|
23030
23073
|
fromChainId: srcChainId,
|
|
23031
23074
|
fromTokenAddress: sourceTokenAddress,
|
|
@@ -23304,7 +23347,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23304
23347
|
};
|
|
23305
23348
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23306
23349
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23307
|
-
const { fetchAllSecretBalances } = await import('./secretService-
|
|
23350
|
+
const { fetchAllSecretBalances } = await import('./secretService-BJNdJc-J.js');
|
|
23308
23351
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23309
23352
|
};
|
|
23310
23353
|
function getTokenAssetsKey(token) {
|
|
@@ -25278,7 +25321,7 @@ const useSquidTokens = (direction) => {
|
|
|
25278
25321
|
config.availableChains,
|
|
25279
25322
|
direction,
|
|
25280
25323
|
]);
|
|
25281
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useMemo(() => {
|
|
25324
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, cantonTokens, } = useMemo(() => {
|
|
25282
25325
|
return tokens?.reduce((acc, token) => {
|
|
25283
25326
|
switch (token.type) {
|
|
25284
25327
|
case ChainType.EVM:
|
|
@@ -25302,6 +25345,9 @@ const useSquidTokens = (direction) => {
|
|
|
25302
25345
|
case ChainType.STELLAR:
|
|
25303
25346
|
acc.stellarTokens.push(token);
|
|
25304
25347
|
break;
|
|
25348
|
+
case ChainType.CANTON:
|
|
25349
|
+
acc.cantonTokens.push(token);
|
|
25350
|
+
break;
|
|
25305
25351
|
}
|
|
25306
25352
|
return acc;
|
|
25307
25353
|
}, {
|
|
@@ -25312,6 +25358,7 @@ const useSquidTokens = (direction) => {
|
|
|
25312
25358
|
suiTokens: [],
|
|
25313
25359
|
xrplTokens: [],
|
|
25314
25360
|
stellarTokens: [],
|
|
25361
|
+
cantonTokens: [],
|
|
25315
25362
|
});
|
|
25316
25363
|
}, [tokens]);
|
|
25317
25364
|
const findToken = useCallback((address, chainId) => {
|
|
@@ -25329,6 +25376,7 @@ const useSquidTokens = (direction) => {
|
|
|
25329
25376
|
suiTokens,
|
|
25330
25377
|
xrplTokens,
|
|
25331
25378
|
stellarTokens,
|
|
25379
|
+
cantonTokens,
|
|
25332
25380
|
};
|
|
25333
25381
|
};
|
|
25334
25382
|
|
|
@@ -25866,6 +25914,7 @@ const chainTypeToRefetchInterval = {
|
|
|
25866
25914
|
[ChainType.SUI]: 1_000,
|
|
25867
25915
|
[ChainType.XRPL]: 1_000,
|
|
25868
25916
|
[ChainType.STELLAR]: 1_000,
|
|
25917
|
+
[ChainType.CANTON]: 1_000,
|
|
25869
25918
|
};
|
|
25870
25919
|
/**
|
|
25871
25920
|
* Returns the status refetch interval of a Send transaction
|
|
@@ -26132,7 +26181,7 @@ const useSquidChains = (direction) => {
|
|
|
26132
26181
|
const chain = findChain(chainId);
|
|
26133
26182
|
return chain?.chainType;
|
|
26134
26183
|
}, [findChain]);
|
|
26135
|
-
const { evmChains, cosmosChains, suiChains, stellarChains, xrplChains } = useMemo(() => {
|
|
26184
|
+
const { evmChains, cosmosChains, suiChains, stellarChains, xrplChains, cantonChains, } = useMemo(() => {
|
|
26136
26185
|
return chains.reduce((acc, chain) => {
|
|
26137
26186
|
switch (chain.chainType) {
|
|
26138
26187
|
case ChainType.EVM:
|
|
@@ -26150,6 +26199,9 @@ const useSquidChains = (direction) => {
|
|
|
26150
26199
|
case ChainType.STELLAR:
|
|
26151
26200
|
acc.stellarChains.push(chain);
|
|
26152
26201
|
break;
|
|
26202
|
+
case ChainType.CANTON:
|
|
26203
|
+
acc.cantonChains.push(chain);
|
|
26204
|
+
break;
|
|
26153
26205
|
}
|
|
26154
26206
|
return acc;
|
|
26155
26207
|
}, {
|
|
@@ -26158,6 +26210,7 @@ const useSquidChains = (direction) => {
|
|
|
26158
26210
|
suiChains: [],
|
|
26159
26211
|
xrplChains: [],
|
|
26160
26212
|
stellarChains: [],
|
|
26213
|
+
cantonChains: [],
|
|
26161
26214
|
});
|
|
26162
26215
|
}, [chains]);
|
|
26163
26216
|
const { supportedSourceChains, supportedDestinationChains } = useMemo(() => {
|
|
@@ -26178,6 +26231,7 @@ const useSquidChains = (direction) => {
|
|
|
26178
26231
|
suiChains,
|
|
26179
26232
|
xrplChains,
|
|
26180
26233
|
stellarChains,
|
|
26234
|
+
cantonChains,
|
|
26181
26235
|
getChainType,
|
|
26182
26236
|
findChain,
|
|
26183
26237
|
};
|
|
@@ -26702,7 +26756,7 @@ function useStellarWallets() {
|
|
|
26702
26756
|
try {
|
|
26703
26757
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26704
26758
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
26705
|
-
const { formatStellarWallet } = await import('./stellarService.client-
|
|
26759
|
+
const { formatStellarWallet } = await import('./stellarService.client-B9xCCNV0.js');
|
|
26706
26760
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26707
26761
|
const promises = modules.map(async (module) => {
|
|
26708
26762
|
const isAvailable = await module.isAvailable();
|
|
@@ -27401,6 +27455,7 @@ const useMultiChainWallet = (chain) => {
|
|
|
27401
27455
|
const suiAddress = connectedAddresses[ChainType.SUI];
|
|
27402
27456
|
const xrplAddress = connectedAddresses[ChainType.XRPL];
|
|
27403
27457
|
const stellarAddress = connectedAddresses[ChainType.STELLAR];
|
|
27458
|
+
const cantonAddress = connectedAddresses[ChainType.CANTON];
|
|
27404
27459
|
// Cosmos is a special case because the address changes on every chain
|
|
27405
27460
|
// so we can't use the default cosmos connected address
|
|
27406
27461
|
const { data: cosmosAddress } = useCosmosForChain(chain);
|
|
@@ -27488,6 +27543,16 @@ const useMultiChainWallet = (chain) => {
|
|
|
27488
27543
|
chainType: chain.chainType,
|
|
27489
27544
|
}),
|
|
27490
27545
|
};
|
|
27546
|
+
case ChainType.CANTON:
|
|
27547
|
+
if (!cantonAddress)
|
|
27548
|
+
return {};
|
|
27549
|
+
return {
|
|
27550
|
+
address: cantonAddress,
|
|
27551
|
+
formatted: formatHash({
|
|
27552
|
+
hash: cantonAddress,
|
|
27553
|
+
chainType: chain.chainType,
|
|
27554
|
+
}),
|
|
27555
|
+
};
|
|
27491
27556
|
}
|
|
27492
27557
|
}, [
|
|
27493
27558
|
chain?.chainType,
|
|
@@ -27499,6 +27564,7 @@ const useMultiChainWallet = (chain) => {
|
|
|
27499
27564
|
suiAddress,
|
|
27500
27565
|
xrplAddress,
|
|
27501
27566
|
stellarAddress,
|
|
27567
|
+
cantonAddress,
|
|
27502
27568
|
]);
|
|
27503
27569
|
/**
|
|
27504
27570
|
* Change current network for desired chain
|
|
@@ -28323,6 +28389,8 @@ async function createClient(chain) {
|
|
|
28323
28389
|
return new XrplRpcClient(chain.rpc);
|
|
28324
28390
|
case ChainType.STELLAR:
|
|
28325
28391
|
return new StellarRpcClient(chain.rpc);
|
|
28392
|
+
case ChainType.CANTON:
|
|
28393
|
+
return null;
|
|
28326
28394
|
}
|
|
28327
28395
|
}
|
|
28328
28396
|
|
|
@@ -29515,7 +29583,7 @@ const useStellarBalance = ({ userAddress, chain, enabled, token, refreshInterval
|
|
|
29515
29583
|
};
|
|
29516
29584
|
|
|
29517
29585
|
function useNativeTokenForChain(chain) {
|
|
29518
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens();
|
|
29586
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, cantonTokens, } = useSquidTokens();
|
|
29519
29587
|
const getTokensForChainType = () => {
|
|
29520
29588
|
if (!chain?.chainType)
|
|
29521
29589
|
return [];
|
|
@@ -29534,6 +29602,8 @@ function useNativeTokenForChain(chain) {
|
|
|
29534
29602
|
return xrplTokens;
|
|
29535
29603
|
case ChainType.STELLAR:
|
|
29536
29604
|
return stellarTokens;
|
|
29605
|
+
case ChainType.CANTON:
|
|
29606
|
+
return cantonTokens;
|
|
29537
29607
|
}
|
|
29538
29608
|
};
|
|
29539
29609
|
const nativeTokenForChainType = useMemo(() => {
|
|
@@ -29768,6 +29838,11 @@ const useNativeBalance = (chain) => {
|
|
|
29768
29838
|
break;
|
|
29769
29839
|
case ChainType.STELLAR:
|
|
29770
29840
|
balance = nativeStellarBalance;
|
|
29841
|
+
break;
|
|
29842
|
+
case ChainType.CANTON:
|
|
29843
|
+
// TODO: implement canton balance fetching
|
|
29844
|
+
balance = undefined;
|
|
29845
|
+
break;
|
|
29771
29846
|
}
|
|
29772
29847
|
const balanceFormatted = !!balance
|
|
29773
29848
|
? formatBNToReadable(balance.value, balance.decimals)
|
|
@@ -29804,6 +29879,9 @@ const useNativeBalance = (chain) => {
|
|
|
29804
29879
|
return isXrpLoading;
|
|
29805
29880
|
case ChainType.STELLAR:
|
|
29806
29881
|
return isStellarLoading;
|
|
29882
|
+
case ChainType.CANTON:
|
|
29883
|
+
// TODO: implement canton balance fetching
|
|
29884
|
+
return false;
|
|
29807
29885
|
}
|
|
29808
29886
|
}, [
|
|
29809
29887
|
chain?.chainType,
|
|
@@ -30028,7 +30106,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30028
30106
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30029
30107
|
if (!optionalChains.length)
|
|
30030
30108
|
return;
|
|
30031
|
-
const { EthereumProvider } = await import('./index.es-
|
|
30109
|
+
const { EthereumProvider } = await import('./index.es-DFjaMQJG.js');
|
|
30032
30110
|
const rawProvider = await EthereumProvider.init({
|
|
30033
30111
|
...restParameters,
|
|
30034
30112
|
disableProviderPing: true,
|
|
@@ -30258,6 +30336,8 @@ const useSigner = ({ chain }) => {
|
|
|
30258
30336
|
return isXrplSignerReady;
|
|
30259
30337
|
case ChainType.STELLAR:
|
|
30260
30338
|
return isStellarSignerReady;
|
|
30339
|
+
case ChainType.CANTON:
|
|
30340
|
+
return false;
|
|
30261
30341
|
}
|
|
30262
30342
|
}, [
|
|
30263
30343
|
chain?.chainType,
|
|
@@ -30730,6 +30810,7 @@ function useDepositAddress(squidRoute) {
|
|
|
30730
30810
|
const chainsSupportingDepositAddress = [
|
|
30731
30811
|
CHAIN_IDS.BITCOIN,
|
|
30732
30812
|
CHAIN_IDS.SOLANA,
|
|
30813
|
+
CHAIN_IDS.CANTON,
|
|
30733
30814
|
];
|
|
30734
30815
|
return chainsSupportingDepositAddress.includes(fromChain.chainId);
|
|
30735
30816
|
}, [fromChain?.chainId]);
|
|
@@ -30744,20 +30825,33 @@ function useDepositAddress(squidRoute) {
|
|
|
30744
30825
|
toggleDepositFlow(false);
|
|
30745
30826
|
}, [toggleDepositFlow]);
|
|
30746
30827
|
const closeDepositChannel = useCallback(() => {
|
|
30747
|
-
toggleDepositFlow(false);
|
|
30748
30828
|
setDeposit(null);
|
|
30749
|
-
}, [
|
|
30829
|
+
}, [setDeposit]);
|
|
30750
30830
|
const getRouteWithDeposit = useMutation(async ({ route }) => {
|
|
30751
|
-
if (!squid)
|
|
30752
|
-
throw new Error("
|
|
30753
|
-
|
|
30754
|
-
|
|
30755
|
-
|
|
30756
|
-
|
|
30757
|
-
|
|
30758
|
-
|
|
30759
|
-
|
|
30760
|
-
|
|
30831
|
+
if (!squid || !route.transactionRequest)
|
|
30832
|
+
throw new Error("Missing required params");
|
|
30833
|
+
if (isChainflipDepositRoute(route)) {
|
|
30834
|
+
const depositAddressResponse = (await squid.executeRoute({
|
|
30835
|
+
signer: {},
|
|
30836
|
+
route,
|
|
30837
|
+
}));
|
|
30838
|
+
setDeposit({
|
|
30839
|
+
amount: depositAddressResponse.amount,
|
|
30840
|
+
depositAddress: depositAddressResponse.depositAddress,
|
|
30841
|
+
statusTrackingId: depositAddressResponse.chainflipStatusTrackingId,
|
|
30842
|
+
});
|
|
30843
|
+
return;
|
|
30844
|
+
}
|
|
30845
|
+
else if (isDepositAddressDirectTransferRoute(route.transactionRequest)) {
|
|
30846
|
+
const orderHash = route.transactionRequest.data;
|
|
30847
|
+
setDeposit({
|
|
30848
|
+
amount: route.params.fromAmount ?? "",
|
|
30849
|
+
depositAddress: route.transactionRequest.target,
|
|
30850
|
+
statusTrackingId: orderHash,
|
|
30851
|
+
memo: orderHash,
|
|
30852
|
+
});
|
|
30853
|
+
return;
|
|
30854
|
+
}
|
|
30761
30855
|
});
|
|
30762
30856
|
return {
|
|
30763
30857
|
isEnabled,
|
|
@@ -30796,7 +30890,7 @@ const useUrlSwapParams = () => {
|
|
|
30796
30890
|
|
|
30797
30891
|
const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, queryOptions, }) => {
|
|
30798
30892
|
const { evmChains, cosmosChains, suiChains, xrplChains, stellarChains } = useSquidChains(direction);
|
|
30799
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens(direction);
|
|
30893
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, cantonTokens, } = useSquidTokens(direction);
|
|
30800
30894
|
const { keplrTypeWallet } = useCosmosContext();
|
|
30801
30895
|
const placeholderData = useMemo(() => {
|
|
30802
30896
|
const tokens = {
|
|
@@ -30807,6 +30901,7 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30807
30901
|
[ChainType.SUI]: suiTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30808
30902
|
[ChainType.XRPL]: xrplTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30809
30903
|
[ChainType.STELLAR]: stellarTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30904
|
+
[ChainType.CANTON]: cantonTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30810
30905
|
};
|
|
30811
30906
|
if (!chainType) {
|
|
30812
30907
|
// Return all tokens with zero balance
|
|
@@ -30828,6 +30923,7 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30828
30923
|
suiTokens,
|
|
30829
30924
|
xrplTokens,
|
|
30830
30925
|
stellarTokens,
|
|
30926
|
+
cantonTokens,
|
|
30831
30927
|
]);
|
|
30832
30928
|
const isQueryEnabled = useMemo(() => {
|
|
30833
30929
|
// Respect the queryOptions.enabled override if provided
|
|
@@ -30850,6 +30946,8 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30850
30946
|
return xrplTokens.length > 0;
|
|
30851
30947
|
case ChainType.STELLAR:
|
|
30852
30948
|
return stellarTokens.length > 0;
|
|
30949
|
+
case ChainType.CANTON:
|
|
30950
|
+
return cantonTokens.length > 0;
|
|
30853
30951
|
}
|
|
30854
30952
|
}, [
|
|
30855
30953
|
chainType,
|
|
@@ -30862,6 +30960,7 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30862
30960
|
suiTokens.length,
|
|
30863
30961
|
xrplTokens.length,
|
|
30864
30962
|
stellarTokens.length,
|
|
30963
|
+
cantonTokens.length,
|
|
30865
30964
|
]);
|
|
30866
30965
|
const query = useQuery(keys().allTokensBalance(address, chainType, direction), async () => {
|
|
30867
30966
|
// Return zero balances if no address
|
|
@@ -30971,6 +31070,12 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
30971
31070
|
direction,
|
|
30972
31071
|
queryOptions,
|
|
30973
31072
|
});
|
|
31073
|
+
const cantonBalancesQuery = useAllTokensWithBalanceForChainType({
|
|
31074
|
+
chainType: ChainType.CANTON,
|
|
31075
|
+
address: connectedAddresses?.[ChainType.CANTON],
|
|
31076
|
+
direction,
|
|
31077
|
+
queryOptions,
|
|
31078
|
+
});
|
|
30974
31079
|
// Create a map of chain type to balance query results
|
|
30975
31080
|
const balanceQueries = useMemo(() => ({
|
|
30976
31081
|
[ChainType.EVM]: evmBalancesQuery,
|
|
@@ -30980,6 +31085,7 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
30980
31085
|
[ChainType.SUI]: suiBalancesQuery,
|
|
30981
31086
|
[ChainType.XRPL]: xrplBalancesQuery,
|
|
30982
31087
|
[ChainType.STELLAR]: stellarBalancesQuery,
|
|
31088
|
+
[ChainType.CANTON]: cantonBalancesQuery,
|
|
30983
31089
|
}), [
|
|
30984
31090
|
evmBalancesQuery,
|
|
30985
31091
|
cosmosBalancesQuery,
|
|
@@ -30988,6 +31094,7 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
30988
31094
|
suiBalancesQuery,
|
|
30989
31095
|
xrplBalancesQuery,
|
|
30990
31096
|
stellarBalancesQuery,
|
|
31097
|
+
cantonBalancesQuery,
|
|
30991
31098
|
]);
|
|
30992
31099
|
// Combine all tokens from different chains
|
|
30993
31100
|
const allTokens = useMemo(() => Object.values(balanceQueries).flatMap((query) => query.data?.tokens ?? []), [balanceQueries]);
|
|
@@ -31087,6 +31194,9 @@ const useMultiChainBalance = ({ chain, token, userAddress, enabled = true, }) =>
|
|
|
31087
31194
|
return xrplBalance;
|
|
31088
31195
|
case ChainType.STELLAR:
|
|
31089
31196
|
return stellarBalance;
|
|
31197
|
+
case ChainType.CANTON:
|
|
31198
|
+
// TODO: implement canton balance fetching
|
|
31199
|
+
return "0";
|
|
31090
31200
|
}
|
|
31091
31201
|
}, [
|
|
31092
31202
|
chain?.chainType,
|
|
@@ -32195,6 +32305,9 @@ function useSendTransaction({ to, amount, token, chain, }) {
|
|
|
32195
32305
|
chain,
|
|
32196
32306
|
});
|
|
32197
32307
|
break;
|
|
32308
|
+
case ChainType.CANTON: {
|
|
32309
|
+
throw new Error("Not implemented");
|
|
32310
|
+
}
|
|
32198
32311
|
}
|
|
32199
32312
|
return {
|
|
32200
32313
|
amount,
|
|
@@ -32398,6 +32511,8 @@ async function getSendTransactionStatus({ chain, txHash, }) {
|
|
|
32398
32511
|
txHash,
|
|
32399
32512
|
chain,
|
|
32400
32513
|
});
|
|
32514
|
+
case ChainType.CANTON:
|
|
32515
|
+
throw new Error("Not implemented");
|
|
32401
32516
|
}
|
|
32402
32517
|
}
|
|
32403
32518
|
|
|
@@ -32421,7 +32536,7 @@ const useHistory = (txType) => {
|
|
|
32421
32536
|
fromChain: tx.params.fromChain,
|
|
32422
32537
|
fromToken: tx.params.fromToken,
|
|
32423
32538
|
fromAddress: tx.params.fromAddress,
|
|
32424
|
-
fromAmount: tx.params.fromAmount,
|
|
32539
|
+
fromAmount: tx.params.fromAmount ?? "",
|
|
32425
32540
|
toChain: tx.params.toChain,
|
|
32426
32541
|
toToken: tx.params.toToken,
|
|
32427
32542
|
toAddress: tx.params.toAddress,
|
|
@@ -32849,6 +32964,125 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32849
32964
|
};
|
|
32850
32965
|
};
|
|
32851
32966
|
|
|
32967
|
+
const useSwapStatusQuery = ({ transaction, retry = 25, refetchOnWindowFocus = "always", enabled = true, onStatus, onEndStatus, onNotFound, onError, }) => {
|
|
32968
|
+
const config = useConfigStore((state) => state.config);
|
|
32969
|
+
const isInitialized = useConfigStore((state) => state.isInitialized);
|
|
32970
|
+
const [isTransactionComplete, setIsTransactionComplete] = useState(false);
|
|
32971
|
+
const [refetchInterval, setRefetchInterval] = useState(getSwapTxStatusRefetchInterval(transaction));
|
|
32972
|
+
const { getChainType } = useSquidChains();
|
|
32973
|
+
const fetchTransactionStatusWithLatestConfig = useCallback(async () => {
|
|
32974
|
+
const latestConfig = useConfigStore.getState().config;
|
|
32975
|
+
return fetchSwapTransactionStatus({
|
|
32976
|
+
transaction,
|
|
32977
|
+
integratorId: latestConfig.integratorId,
|
|
32978
|
+
apiUrl: latestConfig.apiUrl,
|
|
32979
|
+
});
|
|
32980
|
+
}, [transaction]);
|
|
32981
|
+
const transactionStatusQuery = useQuery(keys().swapTransactionStatus(transaction?.transactionId), fetchTransactionStatusWithLatestConfig, {
|
|
32982
|
+
enabled: enabled &&
|
|
32983
|
+
transaction?.transactionId !== "0" &&
|
|
32984
|
+
!!transaction?.transactionId &&
|
|
32985
|
+
!!transaction.fromAddress &&
|
|
32986
|
+
!!config.apiUrl &&
|
|
32987
|
+
transaction !== undefined &&
|
|
32988
|
+
!isTransactionComplete &&
|
|
32989
|
+
isInitialized,
|
|
32990
|
+
refetchInterval(statusResponse) {
|
|
32991
|
+
if (statusResponse &&
|
|
32992
|
+
transactionEndStatuses.includes(getTransactionStatus(statusResponse) ?? "")) {
|
|
32993
|
+
return false;
|
|
32994
|
+
}
|
|
32995
|
+
return refetchInterval;
|
|
32996
|
+
},
|
|
32997
|
+
retryDelay: getChainType(transaction?.fromChain) === ChainType.COSMOS ? 5000 : 3000,
|
|
32998
|
+
retry: getChainType(transaction?.fromChain) === ChainType.COSMOS ? 6 : retry,
|
|
32999
|
+
refetchOnWindowFocus,
|
|
33000
|
+
onSuccess: (statusResponse) => {
|
|
33001
|
+
WidgetEvents.getInstance().dispatchSwapStatus(statusResponse.squidTransactionStatus ?? "");
|
|
33002
|
+
onStatus?.({
|
|
33003
|
+
status: getTransactionStatus(statusResponse) ?? "",
|
|
33004
|
+
statusResponse,
|
|
33005
|
+
});
|
|
33006
|
+
const endStatus = getTransactionEndStatus({ statusResponse });
|
|
33007
|
+
if (endStatus) {
|
|
33008
|
+
setIsTransactionComplete(true);
|
|
33009
|
+
onEndStatus?.({ status: endStatus, statusResponse });
|
|
33010
|
+
}
|
|
33011
|
+
},
|
|
33012
|
+
onError: (error) => {
|
|
33013
|
+
if (is404Error(error.cause)) {
|
|
33014
|
+
onNotFound?.();
|
|
33015
|
+
return;
|
|
33016
|
+
}
|
|
33017
|
+
setRefetchInterval(-1);
|
|
33018
|
+
setIsTransactionComplete(true);
|
|
33019
|
+
onError?.();
|
|
33020
|
+
},
|
|
33021
|
+
});
|
|
33022
|
+
return {
|
|
33023
|
+
transactionStatusQuery,
|
|
33024
|
+
};
|
|
33025
|
+
};
|
|
33026
|
+
|
|
33027
|
+
// Statuses that indicate the source deposit has been received and the swap is
|
|
33028
|
+
// now progressing — the point at which it becomes a history-backed transaction.
|
|
33029
|
+
const sourceReceivedStatuses = [
|
|
33030
|
+
"DEPOSIT_RECEIVED",
|
|
33031
|
+
"BROADCAST_REQUESTED",
|
|
33032
|
+
"COMPLETE",
|
|
33033
|
+
];
|
|
33034
|
+
/**
|
|
33035
|
+
* Tracks a generated deposit address before it becomes a persisted swap history item.
|
|
33036
|
+
*
|
|
33037
|
+
* Mirrors the hooks-first pattern of `useExecuteTransaction`: once the source deposit
|
|
33038
|
+
* is received, it registers the transaction in the transaction + history stores, then
|
|
33039
|
+
* signals the view (via `onReceived`) to navigate. The view never writes to the stores.
|
|
33040
|
+
*/
|
|
33041
|
+
const useDepositTransactionStatus = ({ transaction, route, retry = 25, refetchOnWindowFocus = "always", enabled = true, onReceived, }) => {
|
|
33042
|
+
const { fromChain, toChain } = useSwap();
|
|
33043
|
+
const { addSwapTransaction } = useHistory();
|
|
33044
|
+
const getTransaction = useTransactionStore((state) => state.getTransaction);
|
|
33045
|
+
const setTransactionStoreState = useTransactionStore((state) => state.setTransactionState);
|
|
33046
|
+
return useSwapStatusQuery({
|
|
33047
|
+
transaction,
|
|
33048
|
+
retry,
|
|
33049
|
+
refetchOnWindowFocus,
|
|
33050
|
+
enabled,
|
|
33051
|
+
onStatus: ({ status }) => {
|
|
33052
|
+
if (!sourceReceivedStatuses.includes(status))
|
|
33053
|
+
return;
|
|
33054
|
+
if (!transaction?.transactionId || !route?.transactionRequest)
|
|
33055
|
+
return;
|
|
33056
|
+
const txLocalId = transaction.transactionId;
|
|
33057
|
+
if (getTransaction(txLocalId))
|
|
33058
|
+
return;
|
|
33059
|
+
useTransactionStore.setState({
|
|
33060
|
+
txLocalId,
|
|
33061
|
+
currentTransaction: undefined,
|
|
33062
|
+
});
|
|
33063
|
+
const tx = {
|
|
33064
|
+
routeType: route.transactionRequest.type,
|
|
33065
|
+
fromChain,
|
|
33066
|
+
toChain,
|
|
33067
|
+
fromAddress: transaction.fromAddress,
|
|
33068
|
+
transactionId: txLocalId,
|
|
33069
|
+
transactionIdForStatus: transaction.transactionIdForStatus,
|
|
33070
|
+
quoteId: route.quoteId,
|
|
33071
|
+
status: TransactionStatus.ONGOING,
|
|
33072
|
+
sourceStatus: TransactionStatus.SUCCESS,
|
|
33073
|
+
timestamp: Date.now(),
|
|
33074
|
+
};
|
|
33075
|
+
setTransactionStoreState(txLocalId, tx);
|
|
33076
|
+
addSwapTransaction({
|
|
33077
|
+
...tx,
|
|
33078
|
+
params: route.params,
|
|
33079
|
+
estimate: route.estimate,
|
|
33080
|
+
});
|
|
33081
|
+
onReceived?.();
|
|
33082
|
+
},
|
|
33083
|
+
});
|
|
33084
|
+
};
|
|
33085
|
+
|
|
32852
33086
|
const DEFAULT_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/providers/squid.webp";
|
|
32853
33087
|
const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/providers/axelar.webp";
|
|
32854
33088
|
const useEstimate = (squidRoute) => {
|
|
@@ -36167,7 +36401,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36167
36401
|
if (!route.params.fromAddress || !route.params.toAddress) {
|
|
36168
36402
|
throw new Error("From or to address is required");
|
|
36169
36403
|
}
|
|
36170
|
-
const isDirectTransfer =
|
|
36404
|
+
const isDirectTransfer = isChainflipDepositRoute(route);
|
|
36171
36405
|
// Means it's a transfer to a deposit address
|
|
36172
36406
|
// Instead of a Swap/Contract call using a DEX like Jupiter
|
|
36173
36407
|
if (isDirectTransfer) {
|
|
@@ -36178,7 +36412,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36178
36412
|
throw new Error("Deposit address is required");
|
|
36179
36413
|
}
|
|
36180
36414
|
const signature = await executeSolanaTransfer({
|
|
36181
|
-
amount: BigInt(route.params.fromAmount),
|
|
36415
|
+
amount: BigInt(route.params.fromAmount ?? ""),
|
|
36182
36416
|
target: depositData.depositAddress,
|
|
36183
36417
|
signer: solanaSigner,
|
|
36184
36418
|
connection: solanaConnection,
|
|
@@ -36188,7 +36422,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36188
36422
|
const txParams = setTransactionState({
|
|
36189
36423
|
route,
|
|
36190
36424
|
txHash,
|
|
36191
|
-
transactionIdForStatus: depositData.
|
|
36425
|
+
transactionIdForStatus: depositData.statusTrackingId,
|
|
36192
36426
|
userAddress: sourceUserAddress,
|
|
36193
36427
|
status: TransactionStatus.INITIAL_LOADING,
|
|
36194
36428
|
sourceStatus: TransactionStatus.ONGOING,
|
|
@@ -36239,7 +36473,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36239
36473
|
}
|
|
36240
36474
|
});
|
|
36241
36475
|
const swapMutationBitcoin = useMutation(async ({ id, route }) => {
|
|
36242
|
-
const { depositAddress, amount: sendAmount,
|
|
36476
|
+
const { depositAddress, amount: sendAmount, statusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
|
|
36243
36477
|
if (!depositAddress) {
|
|
36244
36478
|
throw new Error(`Invalid deposit address: ${depositAddress}`);
|
|
36245
36479
|
}
|
|
@@ -36262,7 +36496,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36262
36496
|
txHash,
|
|
36263
36497
|
// When bridging from Bitcoin we need to send the chainflipId to the status endpoint
|
|
36264
36498
|
// instead of the Bitcoin transaction hash
|
|
36265
|
-
transactionIdForStatus:
|
|
36499
|
+
transactionIdForStatus: statusTrackingId,
|
|
36266
36500
|
userAddress: sourceUserAddress,
|
|
36267
36501
|
status: TransactionStatus.INITIAL_LOADING,
|
|
36268
36502
|
sourceStatus: TransactionStatus.ONGOING,
|
|
@@ -36863,94 +37097,50 @@ function useSendTransactionStatus({ chain, txHash, }) {
|
|
|
36863
37097
|
* Fetch status of a Swap transaction
|
|
36864
37098
|
*/
|
|
36865
37099
|
const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocus = "always", enabled = true, }) => {
|
|
36866
|
-
const config = useConfigStore((state) => state.config);
|
|
36867
|
-
const isInitialized = useConfigStore((state) => state.isInitialized);
|
|
36868
37100
|
const { replaceSwapTransactionStatus } = useHistory();
|
|
36869
37101
|
const findTransaction = useHistoryStore((state) => state.findTransaction);
|
|
36870
|
-
const [isTransactionComplete, setIsTransactionComplete] = useState(false);
|
|
36871
|
-
const [refetchInterval, setRefetchInterval] = useState(getSwapTxStatusRefetchInterval(transaction));
|
|
36872
|
-
const { getChainType } = useSquidChains();
|
|
36873
37102
|
const currentHistoryItem = useMemo(() => findTransaction({
|
|
36874
37103
|
transactionId: transaction?.transactionId,
|
|
36875
37104
|
txType: HistoryTxType.SWAP,
|
|
36876
37105
|
}), [findTransaction, transaction?.transactionId]);
|
|
36877
|
-
|
|
36878
|
-
|
|
36879
|
-
|
|
36880
|
-
|
|
36881
|
-
*/
|
|
36882
|
-
const fetchTransactionStatusWithLatestConfig = useCallback(async () => {
|
|
36883
|
-
const latestConfig = useConfigStore.getState().config;
|
|
36884
|
-
return fetchSwapTransactionStatus({
|
|
36885
|
-
transaction,
|
|
36886
|
-
integratorId: latestConfig.integratorId,
|
|
36887
|
-
apiUrl: latestConfig.apiUrl,
|
|
36888
|
-
});
|
|
36889
|
-
}, [transaction]);
|
|
36890
|
-
const transactionStatusQuery = useQuery(keys().swapTransactionStatus(transaction?.transactionId), fetchTransactionStatusWithLatestConfig, {
|
|
37106
|
+
const transactionStatusQuery = useSwapStatusQuery({
|
|
37107
|
+
transaction,
|
|
37108
|
+
retry,
|
|
37109
|
+
refetchOnWindowFocus,
|
|
36891
37110
|
enabled: enabled &&
|
|
36892
|
-
transaction?.transactionId !== "0" &&
|
|
36893
|
-
!!transaction?.transactionId &&
|
|
36894
|
-
!!transaction.fromAddress &&
|
|
36895
|
-
!!config.apiUrl &&
|
|
36896
|
-
transaction !== undefined &&
|
|
36897
|
-
!isTransactionComplete &&
|
|
36898
|
-
isInitialized &&
|
|
36899
37111
|
!!currentHistoryItem &&
|
|
36900
37112
|
!isHistoryTransactionEnded({
|
|
36901
37113
|
data: currentHistoryItem?.data,
|
|
36902
37114
|
txType: HistoryTxType.SWAP,
|
|
36903
37115
|
}),
|
|
36904
|
-
|
|
36905
|
-
|
|
36906
|
-
|
|
36907
|
-
|
|
36908
|
-
|
|
36909
|
-
|
|
36910
|
-
|
|
36911
|
-
}
|
|
36912
|
-
return refetchInterval; // Had to handle a variable here because after onError, we want the interval to stop
|
|
37116
|
+
onEndStatus: ({ status, statusResponse }) => {
|
|
37117
|
+
if (!transaction?.transactionId)
|
|
37118
|
+
return;
|
|
37119
|
+
replaceSwapTransactionStatus({
|
|
37120
|
+
transactionId: transaction.transactionId,
|
|
37121
|
+
statusResponse,
|
|
37122
|
+
status,
|
|
37123
|
+
});
|
|
36913
37124
|
},
|
|
36914
|
-
|
|
36915
|
-
|
|
36916
|
-
|
|
36917
|
-
|
|
36918
|
-
|
|
36919
|
-
|
|
36920
|
-
|
|
36921
|
-
|
|
36922
|
-
if (endStatus && transaction?.transactionId) {
|
|
36923
|
-
setIsTransactionComplete(true);
|
|
36924
|
-
replaceSwapTransactionStatus({
|
|
36925
|
-
transactionId: transaction.transactionId,
|
|
36926
|
-
statusResponse,
|
|
36927
|
-
status: endStatus,
|
|
36928
|
-
});
|
|
36929
|
-
}
|
|
37125
|
+
onNotFound: () => {
|
|
37126
|
+
if (!transaction?.transactionId)
|
|
37127
|
+
return;
|
|
37128
|
+
replaceSwapTransactionStatus({
|
|
37129
|
+
transactionId: transaction.transactionId,
|
|
37130
|
+
statusResponse: undefined,
|
|
37131
|
+
status: TransactionStatus.NOT_FOUND,
|
|
37132
|
+
});
|
|
36930
37133
|
},
|
|
36931
|
-
onError: (
|
|
36932
|
-
// `fetchTransactionStatus` throws an error with a cause being an AxiosError
|
|
36933
|
-
const is404 = is404Error(error.cause);
|
|
37134
|
+
onError: () => {
|
|
36934
37135
|
if (!transaction?.transactionId)
|
|
36935
37136
|
return;
|
|
36936
|
-
|
|
36937
|
-
|
|
36938
|
-
|
|
36939
|
-
|
|
36940
|
-
|
|
36941
|
-
});
|
|
36942
|
-
}
|
|
36943
|
-
else {
|
|
36944
|
-
setRefetchInterval(-1);
|
|
36945
|
-
setIsTransactionComplete(true);
|
|
36946
|
-
replaceSwapTransactionStatus({
|
|
36947
|
-
transactionId: transaction.transactionId,
|
|
36948
|
-
statusResponse: undefined,
|
|
36949
|
-
status: TransactionStatus.ERROR,
|
|
36950
|
-
});
|
|
36951
|
-
}
|
|
37137
|
+
replaceSwapTransactionStatus({
|
|
37138
|
+
transactionId: transaction.transactionId,
|
|
37139
|
+
statusResponse: undefined,
|
|
37140
|
+
status: TransactionStatus.ERROR,
|
|
37141
|
+
});
|
|
36952
37142
|
},
|
|
36953
|
-
});
|
|
37143
|
+
}).transactionStatusQuery;
|
|
36954
37144
|
return {
|
|
36955
37145
|
transactionStatusQuery,
|
|
36956
37146
|
latestStatus: transactionStatusQuery.data
|
|
@@ -37427,5 +37617,5 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37427
37617
|
React.createElement(CosmosProvider, null, children)))))))))) : (placeholder);
|
|
37428
37618
|
};
|
|
37429
37619
|
|
|
37430
|
-
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,
|
|
37431
|
-
//# sourceMappingURL=index-
|
|
37620
|
+
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, useRecommendedQuote 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, useSendTransactionStatus as aA, useSwapTransactionStatus as aB, useAvatar as aC, useHistory as aD, useDebouncedValue as aE, useAddToken as aF, useAutoConnect as aG, useEnsDataForAddress as aH, useEnsSearch as aI, useGnosisContext as aJ, useIsSameAddressAndGnosisContext as aK, useIntegratorContext as aL, useMultiChainWallet as aM, useSigner as aN, useWallet as aO, useWallets as aP, useXrplTrustLine as aQ, TX_STATUS_CONSTANTS as aR, FINAL_TRANSACTION_STATUSES as aS, useGetFiatQuote as aT, useGetOnRampConfig as aU, useExecuteFiatQuote as aV, useFiatOnRampTxStatus as aW, useFiatTransactions as aX, useCurrencyDetails as aY, useCountryDetails as aZ, useAvailableQuotes 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, useDepositTransactionStatus as at, useEstimate as au, useEstimatePriceImpact as av, useExecuteTransaction as aw, useGetRoute as ax, useGetRouteWrapper as ay, useRouteWarnings as az, chainTypeToZeroAddressMap as b, formatEvmWallet as b$, useGetOnrampPaymentTypes as b0, useSuggestedFiatAmounts as b1, SquidProvider as b2, EnsService as b3, getXummClient as b4, isXamanXAppContext as b5, getQueryHeaders as b6, getStatusCode as b7, is404Error as b8, assetsBaseUrl as b9, getFirstAvailableChainId as bA, fetchHighestBalanceToken as bB, getInitialOrDefaultTokenAddressForChain as bC, getInitialTokenAddressForChain as bD, filterTokensForDestination as bE, getInitialChainIdFromConfig as bF, getCosmosKey as bG, getKeysSettled as bH, getAllKeysForSupportedCosmosChains as bI, isCosmosAddressValid as bJ, getCosmosSigningClient as bK, getCosmosChainInfosObject as bL, connectCosmosWallet as bM, isFallbackAddressNeeded as bN, suggestChainOrThrow as bO, normalizeError as bP, transactionErrorCode as bQ, isUserRejectionError as bR, getTransactionError as bS, handleTransactionErrorEvents as bT, isSwapRouteError as bU, isStatusError as bV, createQuoteRequestParamsHash as bW, WidgetEvents as bX, EvmNetworkNotSupportedErrorCode as bY, addEthereumChain as bZ, parseEvmAddress as b_, shareSubgraphId as ba, sortTokensBySharedSubgraphIds as bb, getSupportedChainIdsForDirection as bc, filterChains as bd, filterTokens as be, getTokenImage as bf, getNewSwapParamsFromInput as bg, sortAllTokens as bh, findToken as bi, findNativeToken as bj, normalizeIbcAddress as bk, groupTokensBySymbol as bl, groupTokensByChainId as bm, filterViewableTokens as bn, getSecretNetworkBalances as bo, getTokenAssetsKey as bp, fetchAssetsColors as bq, initializeSquidWithAssetsColors as br, isEmptyObject as bs, normalizeTokenSymbol as bt, areTokenSymbolsCompatible as bu, isEvmosChain as bv, resolveChainIdFromAsset as bw, getConfigWithDefaults as bx, randomIntFromInterval as by, getTokensForChain as bz, chainTypeToNativeTokenAddressMap as c, getTransactionStatus as c$, filterWagmiConnector as c0, waitForReceiptWithRetry as c1, getUserCountry as c2, getCountryData as c3, getCurrencyData as c4, adaptiveRound as c5, getSuggestedAmountsForCurrency as c6, HederaExtensionHelper as c7, convertHederaAccountIdToEvmAddress as c8, convertEvmAddressToHederaAccountId as c9, isValidIssuedAsset as cA, isValidHorizonAsset as cB, formatTransactionHistoryDate as cC, getAxelarExplorerTxUrl as cD, getSourceExplorerTxUrl as cE, getMainExplorerUrl as cF, formatDistance as cG, formatSeconds as cH, formatSwapTxStatusResponseForStorage as cI, simplifyRouteAction as cJ, fetchSwapTransactionStatus as cK, compareTransactionIds as cL, isCoralBridgeAction as cM, isActionCompletedOnSourceTx as cN, sleep as cO, isChainflipDepositRoute as cP, isChainflipBridgeTransaction as cQ, isOnChainTxData as cR, isDepositAddressDirectTransferRoute as cS, getHistoryTransactionId as cT, getStepStatuses as cU, getHalfSuccessState as cV, getStepsInfos as cW, getSwapTxStatusRefetchInterval as cX, getSendTxStatusRefetchInterval as cY, chainflipMultihopBridgeType as cZ, getBridgeType as c_, scaleHbarToWei as ca, scaleWeiToHbar as cb, parseToBigInt as cc, roundNumericValue as cd, formatUnitsRounded as ce, formatTokenAmount as cf, formatUsdAmount as cg, trimExtraDecimals as ch, getNumericValue as ci, cleanAmount as cj, convertTokenAmountToUSD as ck, convertUSDToTokenAmount as cl, calculateTotal24hChange as cm, getRouteExpiry as cn, searchTokens as co, filterSolanaWallets as cp, isSolanaAddressValid as cq, executeSolanaSwap as cr, executeSolanaTransfer as cs, isStellarAddressValid as ct, getStellarNetwork as cu, stellarAddressToScVal as cv, getStellarTrustLineAsset as cw, isStellarToken as cx, isStellarIssuedToken as cy, getStellarHorizonApiUrl as cz, definedInWindow as d, getTransactionEndStatus as d0, isHistoryTransactionPending as d1, isHistoryTransactionFailed as d2, isHistoryTransactionWarning as d3, isHistoryTransactionEnded as d4, formatHash as d5, isWalletAddressValid as d6, redirectToExtensionsStore as d7, accessProperty as d8, populateWallets as d9, getDefaultChain as da, sortWallets as db, areSameAddress as dc, sortAddressBook as dd, calculateTotalUsdBalanceUSD as de, addTokenToWallet as df, isEvmChainNotSupportedError as dg, getWalletSupportedChainTypes as dh, getConnectorForChainType as di, walletSupportsChainType as dj, connectWallet as dk, cancelConnectWallet as dl, isProblematicConnector as dm, mergeWallets as dn, isXionSmartContractAddress as dp, isXrplAddressValid as dq, buildXrplTrustSetTx as dr, getXrplNetwork as ds, parseXrplPaymentTx as dt, parseXrplTokenAddress as du, 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 };
|
|
37621
|
+
//# sourceMappingURL=index-CtTVUC-R.js.map
|