@0xsquid/react-hooks 8.8.0 → 8.8.1-beta-canton.1
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-IxCpRlyV.js → index-BOyZL5gB.js} +312 -109
- package/dist/index-BOyZL5gB.js.map +1 -0
- package/dist/{index-CHdL63Y4.js → index-C6O8biTF.js} +310 -109
- package/dist/index-C6O8biTF.js.map +1 -0
- package/dist/{index.es-C1qztDII.js → index.es-CjEZHrFG.js} +2 -2
- package/dist/{index.es-C1qztDII.js.map → index.es-CjEZHrFG.js.map} +1 -1
- package/dist/{index.es-B_4aEeiW.js → index.es-DXtULgAw.js} +2 -2
- package/dist/{index.es-B_4aEeiW.js.map → index.es-DXtULgAw.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-D0p2T9tf.js → secretService-DQhP5g0c.js} +2 -2
- package/dist/{secretService-D0p2T9tf.js.map → secretService-DQhP5g0c.js.map} +1 -1
- package/dist/{secretService-vD8qpukk.js → secretService-s34iHqOe.js} +2 -2
- package/dist/{secretService-vD8qpukk.js.map → secretService-s34iHqOe.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-Cia5YJMU.js → stellarService.client-BQrRZDwB.js} +2 -2
- package/dist/{stellarService.client-Cia5YJMU.js.map → stellarService.client-BQrRZDwB.js.map} +1 -1
- package/dist/{stellarService.client-DKQ8QpMf.js → stellarService.client-DlaL8w0o.js} +2 -2
- package/dist/{stellarService.client-DKQ8QpMf.js.map → stellarService.client-DlaL8w0o.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";
|
|
@@ -20964,6 +20983,7 @@ const getSourceExplorerTxUrl = (chain, txID) => {
|
|
|
20964
20983
|
case CHAIN_IDS.AGORIC:
|
|
20965
20984
|
case CHAIN_IDS.XRPL:
|
|
20966
20985
|
case CHAIN_IDS.XRPL_TESTNET:
|
|
20986
|
+
case CHAIN_IDS.CANTON:
|
|
20967
20987
|
txSuffix = "/transactions/";
|
|
20968
20988
|
break;
|
|
20969
20989
|
case CHAIN_IDS.HEDERA:
|
|
@@ -21073,10 +21093,16 @@ const simplifyRouteAction = (action) => {
|
|
|
21073
21093
|
};
|
|
21074
21094
|
const fetchSwapTransactionStatus = async ({ transaction, integratorId, apiUrl, }) => {
|
|
21075
21095
|
const statusEndpoint = `${apiUrl}/v2/status`;
|
|
21096
|
+
const isCanton = transaction?.fromChain === CHAIN_IDS.CANTON;
|
|
21097
|
+
// For Canton, the backend handles all tx detection/submission from the quoteId
|
|
21098
|
+
// alone, so no transactionId is sent — only the quoteId param below.
|
|
21099
|
+
const transactionId = isCanton
|
|
21100
|
+
? undefined
|
|
21101
|
+
: transaction?.transactionIdForStatus ?? transaction?.transactionId;
|
|
21076
21102
|
try {
|
|
21077
21103
|
const response = await axios.get(statusEndpoint, {
|
|
21078
21104
|
params: {
|
|
21079
|
-
transactionId
|
|
21105
|
+
transactionId,
|
|
21080
21106
|
fromChainId: transaction?.fromChain,
|
|
21081
21107
|
toChainId: transaction?.toChain,
|
|
21082
21108
|
bridgeType: transaction?.bridgeType,
|
|
@@ -21123,7 +21149,7 @@ function isActionCompletedOnSourceTx(action, fromChainId) {
|
|
|
21123
21149
|
function sleep(ms) {
|
|
21124
21150
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21125
21151
|
}
|
|
21126
|
-
const
|
|
21152
|
+
const isChainflipDepositRoute = (route) => {
|
|
21127
21153
|
return (!!route &&
|
|
21128
21154
|
route.transactionRequest?.type === SquidDataType.ChainflipDepositAddress);
|
|
21129
21155
|
};
|
|
@@ -21148,6 +21174,12 @@ function isOnChainTxData(squidData) {
|
|
|
21148
21174
|
SquidDataType.DepositAddressWithMemo,
|
|
21149
21175
|
].includes(squidData.type);
|
|
21150
21176
|
}
|
|
21177
|
+
/**
|
|
21178
|
+
* Checks if a route is of type DepositAddressDirectTransfer
|
|
21179
|
+
*/
|
|
21180
|
+
function isDepositAddressDirectTransferRoute(squidData) {
|
|
21181
|
+
return (squidData.type === SquidDataType.DepositAddressDirectTransfer);
|
|
21182
|
+
}
|
|
21151
21183
|
function getHistoryTransactionId(tx) {
|
|
21152
21184
|
switch (tx.txType) {
|
|
21153
21185
|
case HistoryTxType.SWAP:
|
|
@@ -21650,7 +21682,17 @@ const chainTypeToTrimLength = {
|
|
|
21650
21682
|
start: 4,
|
|
21651
21683
|
end: 4,
|
|
21652
21684
|
},
|
|
21685
|
+
// abc...123::abc...123
|
|
21686
|
+
[ChainType.CANTON]: {
|
|
21687
|
+
start: 3,
|
|
21688
|
+
end: 3,
|
|
21689
|
+
},
|
|
21653
21690
|
};
|
|
21691
|
+
const truncateWithEllipsis = (value, startLength, endLength) => value.length <= startLength + endLength
|
|
21692
|
+
? value
|
|
21693
|
+
: value.slice(0, startLength) +
|
|
21694
|
+
"..." +
|
|
21695
|
+
value.slice(value.length - endLength);
|
|
21654
21696
|
const formatHash = ({ chainType, hash }) => {
|
|
21655
21697
|
if (!hash)
|
|
21656
21698
|
return "";
|
|
@@ -21663,14 +21705,15 @@ const formatHash = ({ chainType, hash }) => {
|
|
|
21663
21705
|
chainTypeFormat = ChainType.COSMOS;
|
|
21664
21706
|
}
|
|
21665
21707
|
}
|
|
21666
|
-
const
|
|
21667
|
-
|
|
21668
|
-
|
|
21669
|
-
|
|
21670
|
-
return
|
|
21671
|
-
|
|
21672
|
-
|
|
21673
|
-
|
|
21708
|
+
const { start, end } = chainTypeToTrimLength[chainTypeFormat];
|
|
21709
|
+
if (chainTypeFormat === ChainType.CANTON &&
|
|
21710
|
+
hash.includes(CANTON_PARTY_ID_SEPARATOR)) {
|
|
21711
|
+
const [namespace, identifier] = hash.split(CANTON_PARTY_ID_SEPARATOR);
|
|
21712
|
+
return (truncateWithEllipsis(namespace, start, end) +
|
|
21713
|
+
CANTON_PARTY_ID_SEPARATOR +
|
|
21714
|
+
truncateWithEllipsis(identifier, start, end));
|
|
21715
|
+
}
|
|
21716
|
+
return truncateWithEllipsis(hash, start, end);
|
|
21674
21717
|
};
|
|
21675
21718
|
const isWalletAddressValid = (chainData, address) => {
|
|
21676
21719
|
if (!address || !chainData?.chainType)
|
|
@@ -21690,6 +21733,8 @@ const isWalletAddressValid = (chainData, address) => {
|
|
|
21690
21733
|
return isXrplAddressValid(address);
|
|
21691
21734
|
case ChainType.STELLAR:
|
|
21692
21735
|
return isStellarAddressValid(address);
|
|
21736
|
+
case ChainType.CANTON:
|
|
21737
|
+
return isCantonAddressValid(address);
|
|
21693
21738
|
}
|
|
21694
21739
|
};
|
|
21695
21740
|
const redirectToExtensionsStore = (wallet) => {
|
|
@@ -21951,6 +21996,8 @@ const connectByChainType = async (chainType, wallet, defaultChain, params) => {
|
|
|
21951
21996
|
connector,
|
|
21952
21997
|
},
|
|
21953
21998
|
});
|
|
21999
|
+
case ChainType.CANTON:
|
|
22000
|
+
return null;
|
|
21954
22001
|
}
|
|
21955
22002
|
};
|
|
21956
22003
|
const getChainTypesToConnect = (selectedChainTypes, defaultChain, supportedChains) => {
|
|
@@ -23025,7 +23072,10 @@ const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute, tokens, chai
|
|
|
23025
23072
|
else {
|
|
23026
23073
|
newFallbackAddress = fallbackAddress ?? initialSwapRoute?.fallbackAddress;
|
|
23027
23074
|
}
|
|
23028
|
-
const
|
|
23075
|
+
const sourceChainChanged = fromChainId !== undefined && fromChainId !== initialSwapRoute?.fromChainId;
|
|
23076
|
+
const newDepositRefundAddress = sourceChainChanged
|
|
23077
|
+
? undefined
|
|
23078
|
+
: depositRefundAddress || initialSwapRoute?.depositRefundAddress;
|
|
23029
23079
|
return {
|
|
23030
23080
|
fromChainId: srcChainId,
|
|
23031
23081
|
fromTokenAddress: sourceTokenAddress,
|
|
@@ -23304,7 +23354,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23304
23354
|
};
|
|
23305
23355
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23306
23356
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23307
|
-
const { fetchAllSecretBalances } = await import('./secretService-
|
|
23357
|
+
const { fetchAllSecretBalances } = await import('./secretService-s34iHqOe.js');
|
|
23308
23358
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23309
23359
|
};
|
|
23310
23360
|
function getTokenAssetsKey(token) {
|
|
@@ -25278,7 +25328,7 @@ const useSquidTokens = (direction) => {
|
|
|
25278
25328
|
config.availableChains,
|
|
25279
25329
|
direction,
|
|
25280
25330
|
]);
|
|
25281
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useMemo(() => {
|
|
25331
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, cantonTokens, } = useMemo(() => {
|
|
25282
25332
|
return tokens?.reduce((acc, token) => {
|
|
25283
25333
|
switch (token.type) {
|
|
25284
25334
|
case ChainType.EVM:
|
|
@@ -25302,6 +25352,9 @@ const useSquidTokens = (direction) => {
|
|
|
25302
25352
|
case ChainType.STELLAR:
|
|
25303
25353
|
acc.stellarTokens.push(token);
|
|
25304
25354
|
break;
|
|
25355
|
+
case ChainType.CANTON:
|
|
25356
|
+
acc.cantonTokens.push(token);
|
|
25357
|
+
break;
|
|
25305
25358
|
}
|
|
25306
25359
|
return acc;
|
|
25307
25360
|
}, {
|
|
@@ -25312,6 +25365,7 @@ const useSquidTokens = (direction) => {
|
|
|
25312
25365
|
suiTokens: [],
|
|
25313
25366
|
xrplTokens: [],
|
|
25314
25367
|
stellarTokens: [],
|
|
25368
|
+
cantonTokens: [],
|
|
25315
25369
|
});
|
|
25316
25370
|
}, [tokens]);
|
|
25317
25371
|
const findToken = useCallback((address, chainId) => {
|
|
@@ -25329,6 +25383,7 @@ const useSquidTokens = (direction) => {
|
|
|
25329
25383
|
suiTokens,
|
|
25330
25384
|
xrplTokens,
|
|
25331
25385
|
stellarTokens,
|
|
25386
|
+
cantonTokens,
|
|
25332
25387
|
};
|
|
25333
25388
|
};
|
|
25334
25389
|
|
|
@@ -25866,6 +25921,7 @@ const chainTypeToRefetchInterval = {
|
|
|
25866
25921
|
[ChainType.SUI]: 1_000,
|
|
25867
25922
|
[ChainType.XRPL]: 1_000,
|
|
25868
25923
|
[ChainType.STELLAR]: 1_000,
|
|
25924
|
+
[ChainType.CANTON]: 1_000,
|
|
25869
25925
|
};
|
|
25870
25926
|
/**
|
|
25871
25927
|
* Returns the status refetch interval of a Send transaction
|
|
@@ -26132,7 +26188,7 @@ const useSquidChains = (direction) => {
|
|
|
26132
26188
|
const chain = findChain(chainId);
|
|
26133
26189
|
return chain?.chainType;
|
|
26134
26190
|
}, [findChain]);
|
|
26135
|
-
const { evmChains, cosmosChains, suiChains, stellarChains, xrplChains } = useMemo(() => {
|
|
26191
|
+
const { evmChains, cosmosChains, suiChains, stellarChains, xrplChains, cantonChains, } = useMemo(() => {
|
|
26136
26192
|
return chains.reduce((acc, chain) => {
|
|
26137
26193
|
switch (chain.chainType) {
|
|
26138
26194
|
case ChainType.EVM:
|
|
@@ -26150,6 +26206,9 @@ const useSquidChains = (direction) => {
|
|
|
26150
26206
|
case ChainType.STELLAR:
|
|
26151
26207
|
acc.stellarChains.push(chain);
|
|
26152
26208
|
break;
|
|
26209
|
+
case ChainType.CANTON:
|
|
26210
|
+
acc.cantonChains.push(chain);
|
|
26211
|
+
break;
|
|
26153
26212
|
}
|
|
26154
26213
|
return acc;
|
|
26155
26214
|
}, {
|
|
@@ -26158,6 +26217,7 @@ const useSquidChains = (direction) => {
|
|
|
26158
26217
|
suiChains: [],
|
|
26159
26218
|
xrplChains: [],
|
|
26160
26219
|
stellarChains: [],
|
|
26220
|
+
cantonChains: [],
|
|
26161
26221
|
});
|
|
26162
26222
|
}, [chains]);
|
|
26163
26223
|
const { supportedSourceChains, supportedDestinationChains } = useMemo(() => {
|
|
@@ -26178,6 +26238,7 @@ const useSquidChains = (direction) => {
|
|
|
26178
26238
|
suiChains,
|
|
26179
26239
|
xrplChains,
|
|
26180
26240
|
stellarChains,
|
|
26241
|
+
cantonChains,
|
|
26181
26242
|
getChainType,
|
|
26182
26243
|
findChain,
|
|
26183
26244
|
};
|
|
@@ -26702,7 +26763,7 @@ function useStellarWallets() {
|
|
|
26702
26763
|
try {
|
|
26703
26764
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26704
26765
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
26705
|
-
const { formatStellarWallet } = await import('./stellarService.client-
|
|
26766
|
+
const { formatStellarWallet } = await import('./stellarService.client-DlaL8w0o.js');
|
|
26706
26767
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26707
26768
|
const promises = modules.map(async (module) => {
|
|
26708
26769
|
const isAvailable = await module.isAvailable();
|
|
@@ -27401,6 +27462,7 @@ const useMultiChainWallet = (chain) => {
|
|
|
27401
27462
|
const suiAddress = connectedAddresses[ChainType.SUI];
|
|
27402
27463
|
const xrplAddress = connectedAddresses[ChainType.XRPL];
|
|
27403
27464
|
const stellarAddress = connectedAddresses[ChainType.STELLAR];
|
|
27465
|
+
const cantonAddress = connectedAddresses[ChainType.CANTON];
|
|
27404
27466
|
// Cosmos is a special case because the address changes on every chain
|
|
27405
27467
|
// so we can't use the default cosmos connected address
|
|
27406
27468
|
const { data: cosmosAddress } = useCosmosForChain(chain);
|
|
@@ -27488,6 +27550,16 @@ const useMultiChainWallet = (chain) => {
|
|
|
27488
27550
|
chainType: chain.chainType,
|
|
27489
27551
|
}),
|
|
27490
27552
|
};
|
|
27553
|
+
case ChainType.CANTON:
|
|
27554
|
+
if (!cantonAddress)
|
|
27555
|
+
return {};
|
|
27556
|
+
return {
|
|
27557
|
+
address: cantonAddress,
|
|
27558
|
+
formatted: formatHash({
|
|
27559
|
+
hash: cantonAddress,
|
|
27560
|
+
chainType: chain.chainType,
|
|
27561
|
+
}),
|
|
27562
|
+
};
|
|
27491
27563
|
}
|
|
27492
27564
|
}, [
|
|
27493
27565
|
chain?.chainType,
|
|
@@ -27499,6 +27571,7 @@ const useMultiChainWallet = (chain) => {
|
|
|
27499
27571
|
suiAddress,
|
|
27500
27572
|
xrplAddress,
|
|
27501
27573
|
stellarAddress,
|
|
27574
|
+
cantonAddress,
|
|
27502
27575
|
]);
|
|
27503
27576
|
/**
|
|
27504
27577
|
* Change current network for desired chain
|
|
@@ -28323,6 +28396,8 @@ async function createClient(chain) {
|
|
|
28323
28396
|
return new XrplRpcClient(chain.rpc);
|
|
28324
28397
|
case ChainType.STELLAR:
|
|
28325
28398
|
return new StellarRpcClient(chain.rpc);
|
|
28399
|
+
case ChainType.CANTON:
|
|
28400
|
+
return null;
|
|
28326
28401
|
}
|
|
28327
28402
|
}
|
|
28328
28403
|
|
|
@@ -29515,7 +29590,7 @@ const useStellarBalance = ({ userAddress, chain, enabled, token, refreshInterval
|
|
|
29515
29590
|
};
|
|
29516
29591
|
|
|
29517
29592
|
function useNativeTokenForChain(chain) {
|
|
29518
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens();
|
|
29593
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, cantonTokens, } = useSquidTokens();
|
|
29519
29594
|
const getTokensForChainType = () => {
|
|
29520
29595
|
if (!chain?.chainType)
|
|
29521
29596
|
return [];
|
|
@@ -29534,6 +29609,8 @@ function useNativeTokenForChain(chain) {
|
|
|
29534
29609
|
return xrplTokens;
|
|
29535
29610
|
case ChainType.STELLAR:
|
|
29536
29611
|
return stellarTokens;
|
|
29612
|
+
case ChainType.CANTON:
|
|
29613
|
+
return cantonTokens;
|
|
29537
29614
|
}
|
|
29538
29615
|
};
|
|
29539
29616
|
const nativeTokenForChainType = useMemo(() => {
|
|
@@ -29768,6 +29845,11 @@ const useNativeBalance = (chain) => {
|
|
|
29768
29845
|
break;
|
|
29769
29846
|
case ChainType.STELLAR:
|
|
29770
29847
|
balance = nativeStellarBalance;
|
|
29848
|
+
break;
|
|
29849
|
+
case ChainType.CANTON:
|
|
29850
|
+
// TODO: implement canton balance fetching
|
|
29851
|
+
balance = undefined;
|
|
29852
|
+
break;
|
|
29771
29853
|
}
|
|
29772
29854
|
const balanceFormatted = !!balance
|
|
29773
29855
|
? formatBNToReadable(balance.value, balance.decimals)
|
|
@@ -29804,6 +29886,9 @@ const useNativeBalance = (chain) => {
|
|
|
29804
29886
|
return isXrpLoading;
|
|
29805
29887
|
case ChainType.STELLAR:
|
|
29806
29888
|
return isStellarLoading;
|
|
29889
|
+
case ChainType.CANTON:
|
|
29890
|
+
// TODO: implement canton balance fetching
|
|
29891
|
+
return false;
|
|
29807
29892
|
}
|
|
29808
29893
|
}, [
|
|
29809
29894
|
chain?.chainType,
|
|
@@ -30028,7 +30113,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30028
30113
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30029
30114
|
if (!optionalChains.length)
|
|
30030
30115
|
return;
|
|
30031
|
-
const { EthereumProvider } = await import('./index.es-
|
|
30116
|
+
const { EthereumProvider } = await import('./index.es-DXtULgAw.js');
|
|
30032
30117
|
const rawProvider = await EthereumProvider.init({
|
|
30033
30118
|
...restParameters,
|
|
30034
30119
|
disableProviderPing: true,
|
|
@@ -30258,6 +30343,8 @@ const useSigner = ({ chain }) => {
|
|
|
30258
30343
|
return isXrplSignerReady;
|
|
30259
30344
|
case ChainType.STELLAR:
|
|
30260
30345
|
return isStellarSignerReady;
|
|
30346
|
+
case ChainType.CANTON:
|
|
30347
|
+
return false;
|
|
30261
30348
|
}
|
|
30262
30349
|
}, [
|
|
30263
30350
|
chain?.chainType,
|
|
@@ -30730,6 +30817,7 @@ function useDepositAddress(squidRoute) {
|
|
|
30730
30817
|
const chainsSupportingDepositAddress = [
|
|
30731
30818
|
CHAIN_IDS.BITCOIN,
|
|
30732
30819
|
CHAIN_IDS.SOLANA,
|
|
30820
|
+
CHAIN_IDS.CANTON,
|
|
30733
30821
|
];
|
|
30734
30822
|
return chainsSupportingDepositAddress.includes(fromChain.chainId);
|
|
30735
30823
|
}, [fromChain?.chainId]);
|
|
@@ -30744,20 +30832,34 @@ function useDepositAddress(squidRoute) {
|
|
|
30744
30832
|
toggleDepositFlow(false);
|
|
30745
30833
|
}, [toggleDepositFlow]);
|
|
30746
30834
|
const closeDepositChannel = useCallback(() => {
|
|
30747
|
-
toggleDepositFlow(false);
|
|
30748
30835
|
setDeposit(null);
|
|
30749
|
-
}, [
|
|
30836
|
+
}, [setDeposit]);
|
|
30750
30837
|
const getRouteWithDeposit = useMutation(async ({ route }) => {
|
|
30751
|
-
if (!squid)
|
|
30752
|
-
throw new Error("
|
|
30753
|
-
|
|
30754
|
-
|
|
30755
|
-
|
|
30756
|
-
|
|
30757
|
-
|
|
30758
|
-
|
|
30759
|
-
|
|
30760
|
-
|
|
30838
|
+
if (!squid || !route.transactionRequest)
|
|
30839
|
+
throw new Error("Missing required params");
|
|
30840
|
+
if (isChainflipDepositRoute(route)) {
|
|
30841
|
+
const depositAddressResponse = (await squid.executeRoute({
|
|
30842
|
+
signer: {},
|
|
30843
|
+
route,
|
|
30844
|
+
}));
|
|
30845
|
+
setDeposit({
|
|
30846
|
+
amount: depositAddressResponse.amount,
|
|
30847
|
+
depositAddress: depositAddressResponse.depositAddress,
|
|
30848
|
+
statusTrackingId: depositAddressResponse.chainflipStatusTrackingId,
|
|
30849
|
+
});
|
|
30850
|
+
return;
|
|
30851
|
+
}
|
|
30852
|
+
else if (isDepositAddressDirectTransferRoute(route.transactionRequest)) {
|
|
30853
|
+
const orderHash = route.transactionRequest.data;
|
|
30854
|
+
setDeposit({
|
|
30855
|
+
amount: route.params.fromAmount ?? "",
|
|
30856
|
+
depositAddress: route.transactionRequest.target,
|
|
30857
|
+
// Squid Scan indexes the Canton tx by the orderHash
|
|
30858
|
+
statusTrackingId: orderHash,
|
|
30859
|
+
memo: orderHash,
|
|
30860
|
+
});
|
|
30861
|
+
return;
|
|
30862
|
+
}
|
|
30761
30863
|
});
|
|
30762
30864
|
return {
|
|
30763
30865
|
isEnabled,
|
|
@@ -30796,7 +30898,7 @@ const useUrlSwapParams = () => {
|
|
|
30796
30898
|
|
|
30797
30899
|
const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, queryOptions, }) => {
|
|
30798
30900
|
const { evmChains, cosmosChains, suiChains, xrplChains, stellarChains } = useSquidChains(direction);
|
|
30799
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens(direction);
|
|
30901
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, cantonTokens, } = useSquidTokens(direction);
|
|
30800
30902
|
const { keplrTypeWallet } = useCosmosContext();
|
|
30801
30903
|
const placeholderData = useMemo(() => {
|
|
30802
30904
|
const tokens = {
|
|
@@ -30807,6 +30909,7 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30807
30909
|
[ChainType.SUI]: suiTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30808
30910
|
[ChainType.XRPL]: xrplTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30809
30911
|
[ChainType.STELLAR]: stellarTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30912
|
+
[ChainType.CANTON]: cantonTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30810
30913
|
};
|
|
30811
30914
|
if (!chainType) {
|
|
30812
30915
|
// Return all tokens with zero balance
|
|
@@ -30828,6 +30931,7 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30828
30931
|
suiTokens,
|
|
30829
30932
|
xrplTokens,
|
|
30830
30933
|
stellarTokens,
|
|
30934
|
+
cantonTokens,
|
|
30831
30935
|
]);
|
|
30832
30936
|
const isQueryEnabled = useMemo(() => {
|
|
30833
30937
|
// Respect the queryOptions.enabled override if provided
|
|
@@ -30850,6 +30954,8 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30850
30954
|
return xrplTokens.length > 0;
|
|
30851
30955
|
case ChainType.STELLAR:
|
|
30852
30956
|
return stellarTokens.length > 0;
|
|
30957
|
+
case ChainType.CANTON:
|
|
30958
|
+
return cantonTokens.length > 0;
|
|
30853
30959
|
}
|
|
30854
30960
|
}, [
|
|
30855
30961
|
chainType,
|
|
@@ -30862,6 +30968,7 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30862
30968
|
suiTokens.length,
|
|
30863
30969
|
xrplTokens.length,
|
|
30864
30970
|
stellarTokens.length,
|
|
30971
|
+
cantonTokens.length,
|
|
30865
30972
|
]);
|
|
30866
30973
|
const query = useQuery(keys().allTokensBalance(address, chainType, direction), async () => {
|
|
30867
30974
|
// Return zero balances if no address
|
|
@@ -30971,6 +31078,12 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
30971
31078
|
direction,
|
|
30972
31079
|
queryOptions,
|
|
30973
31080
|
});
|
|
31081
|
+
const cantonBalancesQuery = useAllTokensWithBalanceForChainType({
|
|
31082
|
+
chainType: ChainType.CANTON,
|
|
31083
|
+
address: connectedAddresses?.[ChainType.CANTON],
|
|
31084
|
+
direction,
|
|
31085
|
+
queryOptions,
|
|
31086
|
+
});
|
|
30974
31087
|
// Create a map of chain type to balance query results
|
|
30975
31088
|
const balanceQueries = useMemo(() => ({
|
|
30976
31089
|
[ChainType.EVM]: evmBalancesQuery,
|
|
@@ -30980,6 +31093,7 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
30980
31093
|
[ChainType.SUI]: suiBalancesQuery,
|
|
30981
31094
|
[ChainType.XRPL]: xrplBalancesQuery,
|
|
30982
31095
|
[ChainType.STELLAR]: stellarBalancesQuery,
|
|
31096
|
+
[ChainType.CANTON]: cantonBalancesQuery,
|
|
30983
31097
|
}), [
|
|
30984
31098
|
evmBalancesQuery,
|
|
30985
31099
|
cosmosBalancesQuery,
|
|
@@ -30988,6 +31102,7 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
30988
31102
|
suiBalancesQuery,
|
|
30989
31103
|
xrplBalancesQuery,
|
|
30990
31104
|
stellarBalancesQuery,
|
|
31105
|
+
cantonBalancesQuery,
|
|
30991
31106
|
]);
|
|
30992
31107
|
// Combine all tokens from different chains
|
|
30993
31108
|
const allTokens = useMemo(() => Object.values(balanceQueries).flatMap((query) => query.data?.tokens ?? []), [balanceQueries]);
|
|
@@ -31087,6 +31202,9 @@ const useMultiChainBalance = ({ chain, token, userAddress, enabled = true, }) =>
|
|
|
31087
31202
|
return xrplBalance;
|
|
31088
31203
|
case ChainType.STELLAR:
|
|
31089
31204
|
return stellarBalance;
|
|
31205
|
+
case ChainType.CANTON:
|
|
31206
|
+
// TODO: implement canton balance fetching
|
|
31207
|
+
return "0";
|
|
31090
31208
|
}
|
|
31091
31209
|
}, [
|
|
31092
31210
|
chain?.chainType,
|
|
@@ -32195,6 +32313,9 @@ function useSendTransaction({ to, amount, token, chain, }) {
|
|
|
32195
32313
|
chain,
|
|
32196
32314
|
});
|
|
32197
32315
|
break;
|
|
32316
|
+
case ChainType.CANTON: {
|
|
32317
|
+
throw new Error("Not implemented");
|
|
32318
|
+
}
|
|
32198
32319
|
}
|
|
32199
32320
|
return {
|
|
32200
32321
|
amount,
|
|
@@ -32398,6 +32519,8 @@ async function getSendTransactionStatus({ chain, txHash, }) {
|
|
|
32398
32519
|
txHash,
|
|
32399
32520
|
chain,
|
|
32400
32521
|
});
|
|
32522
|
+
case ChainType.CANTON:
|
|
32523
|
+
throw new Error("Not implemented");
|
|
32401
32524
|
}
|
|
32402
32525
|
}
|
|
32403
32526
|
|
|
@@ -32421,7 +32544,7 @@ const useHistory = (txType) => {
|
|
|
32421
32544
|
fromChain: tx.params.fromChain,
|
|
32422
32545
|
fromToken: tx.params.fromToken,
|
|
32423
32546
|
fromAddress: tx.params.fromAddress,
|
|
32424
|
-
fromAmount: tx.params.fromAmount,
|
|
32547
|
+
fromAmount: tx.params.fromAmount ?? "",
|
|
32425
32548
|
toChain: tx.params.toChain,
|
|
32426
32549
|
toToken: tx.params.toToken,
|
|
32427
32550
|
toAddress: tx.params.toAddress,
|
|
@@ -32849,6 +32972,128 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32849
32972
|
};
|
|
32850
32973
|
};
|
|
32851
32974
|
|
|
32975
|
+
const useSwapStatusQuery = ({ transaction, retry = 25, refetchOnWindowFocus = "always", enabled = true, onStatus, onEndStatus, onNotFound, onError, }) => {
|
|
32976
|
+
const config = useConfigStore((state) => state.config);
|
|
32977
|
+
const isInitialized = useConfigStore((state) => state.isInitialized);
|
|
32978
|
+
const [isTransactionComplete, setIsTransactionComplete] = useState(false);
|
|
32979
|
+
const [refetchInterval, setRefetchInterval] = useState(getSwapTxStatusRefetchInterval(transaction));
|
|
32980
|
+
const { getChainType } = useSquidChains();
|
|
32981
|
+
const fetchTransactionStatusWithLatestConfig = useCallback(async () => {
|
|
32982
|
+
const latestConfig = useConfigStore.getState().config;
|
|
32983
|
+
return fetchSwapTransactionStatus({
|
|
32984
|
+
transaction,
|
|
32985
|
+
integratorId: latestConfig.integratorId,
|
|
32986
|
+
apiUrl: latestConfig.apiUrl,
|
|
32987
|
+
});
|
|
32988
|
+
}, [transaction]);
|
|
32989
|
+
const transactionStatusQuery = useQuery(keys().swapTransactionStatus(transaction?.transactionId), fetchTransactionStatusWithLatestConfig, {
|
|
32990
|
+
enabled: enabled &&
|
|
32991
|
+
transaction?.transactionId !== "0" &&
|
|
32992
|
+
!!transaction?.transactionId &&
|
|
32993
|
+
!!transaction.fromAddress &&
|
|
32994
|
+
!!config.apiUrl &&
|
|
32995
|
+
transaction !== undefined &&
|
|
32996
|
+
!isTransactionComplete &&
|
|
32997
|
+
isInitialized,
|
|
32998
|
+
refetchInterval(statusResponse) {
|
|
32999
|
+
if (statusResponse &&
|
|
33000
|
+
transactionEndStatuses.includes(getTransactionStatus(statusResponse) ?? "")) {
|
|
33001
|
+
return false;
|
|
33002
|
+
}
|
|
33003
|
+
return refetchInterval;
|
|
33004
|
+
},
|
|
33005
|
+
retryDelay: getChainType(transaction?.fromChain) === ChainType.COSMOS ? 5000 : 3000,
|
|
33006
|
+
retry: getChainType(transaction?.fromChain) === ChainType.COSMOS ? 6 : retry,
|
|
33007
|
+
refetchOnWindowFocus,
|
|
33008
|
+
onSuccess: (statusResponse) => {
|
|
33009
|
+
WidgetEvents.getInstance().dispatchSwapStatus(statusResponse.squidTransactionStatus ?? "");
|
|
33010
|
+
onStatus?.({
|
|
33011
|
+
status: getTransactionStatus(statusResponse) ?? "",
|
|
33012
|
+
statusResponse,
|
|
33013
|
+
});
|
|
33014
|
+
const endStatus = getTransactionEndStatus({ statusResponse });
|
|
33015
|
+
if (endStatus) {
|
|
33016
|
+
setIsTransactionComplete(true);
|
|
33017
|
+
onEndStatus?.({ status: endStatus, statusResponse });
|
|
33018
|
+
}
|
|
33019
|
+
},
|
|
33020
|
+
onError: (error) => {
|
|
33021
|
+
if (is404Error(error.cause)) {
|
|
33022
|
+
onNotFound?.();
|
|
33023
|
+
return;
|
|
33024
|
+
}
|
|
33025
|
+
setRefetchInterval(-1);
|
|
33026
|
+
setIsTransactionComplete(true);
|
|
33027
|
+
onError?.();
|
|
33028
|
+
},
|
|
33029
|
+
});
|
|
33030
|
+
return {
|
|
33031
|
+
transactionStatusQuery,
|
|
33032
|
+
};
|
|
33033
|
+
};
|
|
33034
|
+
|
|
33035
|
+
// Statuses that indicate the source deposit has been received and the swap is
|
|
33036
|
+
// now progressing — the point at which it becomes a history-backed transaction.
|
|
33037
|
+
const sourceReceivedStatuses = [
|
|
33038
|
+
// Chainflip
|
|
33039
|
+
"DEPOSIT_RECEIVED",
|
|
33040
|
+
"BROADCAST_REQUESTED",
|
|
33041
|
+
"COMPLETE",
|
|
33042
|
+
// Canton (Squid Intents)
|
|
33043
|
+
"awaiting",
|
|
33044
|
+
];
|
|
33045
|
+
/**
|
|
33046
|
+
* Tracks a generated deposit address before it becomes a persisted swap history item.
|
|
33047
|
+
*
|
|
33048
|
+
* Mirrors the hooks-first pattern of `useExecuteTransaction`: once the source deposit
|
|
33049
|
+
* is received, it registers the transaction in the transaction + history stores, then
|
|
33050
|
+
* signals the view (via `onReceived`) to navigate. The view never writes to the stores.
|
|
33051
|
+
*/
|
|
33052
|
+
const useDepositTransactionStatus = ({ transaction, route, retry = 25, refetchOnWindowFocus = "always", enabled = true, onReceived, }) => {
|
|
33053
|
+
const { fromChain, toChain } = useSwap();
|
|
33054
|
+
const { addSwapTransaction } = useHistory();
|
|
33055
|
+
const getTransaction = useTransactionStore((state) => state.getTransaction);
|
|
33056
|
+
const setTransactionStoreState = useTransactionStore((state) => state.setTransactionState);
|
|
33057
|
+
return useSwapStatusQuery({
|
|
33058
|
+
transaction,
|
|
33059
|
+
retry,
|
|
33060
|
+
refetchOnWindowFocus,
|
|
33061
|
+
enabled,
|
|
33062
|
+
onStatus: ({ status }) => {
|
|
33063
|
+
if (!sourceReceivedStatuses.includes(status))
|
|
33064
|
+
return;
|
|
33065
|
+
if (!transaction?.transactionId || !route?.transactionRequest)
|
|
33066
|
+
return;
|
|
33067
|
+
const txLocalId = transaction.transactionId;
|
|
33068
|
+
if (getTransaction(txLocalId))
|
|
33069
|
+
return;
|
|
33070
|
+
useTransactionStore.setState({
|
|
33071
|
+
txLocalId,
|
|
33072
|
+
currentTransaction: undefined,
|
|
33073
|
+
});
|
|
33074
|
+
const tx = {
|
|
33075
|
+
routeType: route.transactionRequest.type,
|
|
33076
|
+
fromChain,
|
|
33077
|
+
toChain,
|
|
33078
|
+
fromAddress: transaction.fromAddress,
|
|
33079
|
+
transactionId: txLocalId,
|
|
33080
|
+
transactionIdForStatus: transaction.transactionIdForStatus,
|
|
33081
|
+
quoteId: transaction.quoteId ?? "",
|
|
33082
|
+
status: TransactionStatus.ONGOING,
|
|
33083
|
+
sourceStatus: TransactionStatus.SUCCESS,
|
|
33084
|
+
timestamp: Date.now(),
|
|
33085
|
+
};
|
|
33086
|
+
setTransactionStoreState(txLocalId, tx);
|
|
33087
|
+
addSwapTransaction({
|
|
33088
|
+
...tx,
|
|
33089
|
+
params: route.params,
|
|
33090
|
+
estimate: route.estimate,
|
|
33091
|
+
});
|
|
33092
|
+
onReceived?.();
|
|
33093
|
+
},
|
|
33094
|
+
});
|
|
33095
|
+
};
|
|
33096
|
+
|
|
32852
33097
|
const DEFAULT_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/providers/squid.webp";
|
|
32853
33098
|
const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/providers/axelar.webp";
|
|
32854
33099
|
const useEstimate = (squidRoute) => {
|
|
@@ -36167,7 +36412,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36167
36412
|
if (!route.params.fromAddress || !route.params.toAddress) {
|
|
36168
36413
|
throw new Error("From or to address is required");
|
|
36169
36414
|
}
|
|
36170
|
-
const isDirectTransfer =
|
|
36415
|
+
const isDirectTransfer = isChainflipDepositRoute(route);
|
|
36171
36416
|
// Means it's a transfer to a deposit address
|
|
36172
36417
|
// Instead of a Swap/Contract call using a DEX like Jupiter
|
|
36173
36418
|
if (isDirectTransfer) {
|
|
@@ -36178,7 +36423,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36178
36423
|
throw new Error("Deposit address is required");
|
|
36179
36424
|
}
|
|
36180
36425
|
const signature = await executeSolanaTransfer({
|
|
36181
|
-
amount: BigInt(route.params.fromAmount),
|
|
36426
|
+
amount: BigInt(route.params.fromAmount ?? ""),
|
|
36182
36427
|
target: depositData.depositAddress,
|
|
36183
36428
|
signer: solanaSigner,
|
|
36184
36429
|
connection: solanaConnection,
|
|
@@ -36188,7 +36433,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36188
36433
|
const txParams = setTransactionState({
|
|
36189
36434
|
route,
|
|
36190
36435
|
txHash,
|
|
36191
|
-
transactionIdForStatus: depositData.
|
|
36436
|
+
transactionIdForStatus: depositData.statusTrackingId,
|
|
36192
36437
|
userAddress: sourceUserAddress,
|
|
36193
36438
|
status: TransactionStatus.INITIAL_LOADING,
|
|
36194
36439
|
sourceStatus: TransactionStatus.ONGOING,
|
|
@@ -36239,7 +36484,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36239
36484
|
}
|
|
36240
36485
|
});
|
|
36241
36486
|
const swapMutationBitcoin = useMutation(async ({ id, route }) => {
|
|
36242
|
-
const { depositAddress, amount: sendAmount,
|
|
36487
|
+
const { depositAddress, amount: sendAmount, statusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
|
|
36243
36488
|
if (!depositAddress) {
|
|
36244
36489
|
throw new Error(`Invalid deposit address: ${depositAddress}`);
|
|
36245
36490
|
}
|
|
@@ -36262,7 +36507,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36262
36507
|
txHash,
|
|
36263
36508
|
// When bridging from Bitcoin we need to send the chainflipId to the status endpoint
|
|
36264
36509
|
// instead of the Bitcoin transaction hash
|
|
36265
|
-
transactionIdForStatus:
|
|
36510
|
+
transactionIdForStatus: statusTrackingId,
|
|
36266
36511
|
userAddress: sourceUserAddress,
|
|
36267
36512
|
status: TransactionStatus.INITIAL_LOADING,
|
|
36268
36513
|
sourceStatus: TransactionStatus.ONGOING,
|
|
@@ -36863,94 +37108,50 @@ function useSendTransactionStatus({ chain, txHash, }) {
|
|
|
36863
37108
|
* Fetch status of a Swap transaction
|
|
36864
37109
|
*/
|
|
36865
37110
|
const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocus = "always", enabled = true, }) => {
|
|
36866
|
-
const config = useConfigStore((state) => state.config);
|
|
36867
|
-
const isInitialized = useConfigStore((state) => state.isInitialized);
|
|
36868
37111
|
const { replaceSwapTransactionStatus } = useHistory();
|
|
36869
37112
|
const findTransaction = useHistoryStore((state) => state.findTransaction);
|
|
36870
|
-
const [isTransactionComplete, setIsTransactionComplete] = useState(false);
|
|
36871
|
-
const [refetchInterval, setRefetchInterval] = useState(getSwapTxStatusRefetchInterval(transaction));
|
|
36872
|
-
const { getChainType } = useSquidChains();
|
|
36873
37113
|
const currentHistoryItem = useMemo(() => findTransaction({
|
|
36874
37114
|
transactionId: transaction?.transactionId,
|
|
36875
37115
|
txType: HistoryTxType.SWAP,
|
|
36876
37116
|
}), [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, {
|
|
37117
|
+
const transactionStatusQuery = useSwapStatusQuery({
|
|
37118
|
+
transaction,
|
|
37119
|
+
retry,
|
|
37120
|
+
refetchOnWindowFocus,
|
|
36891
37121
|
enabled: enabled &&
|
|
36892
|
-
transaction?.transactionId !== "0" &&
|
|
36893
|
-
!!transaction?.transactionId &&
|
|
36894
|
-
!!transaction.fromAddress &&
|
|
36895
|
-
!!config.apiUrl &&
|
|
36896
|
-
transaction !== undefined &&
|
|
36897
|
-
!isTransactionComplete &&
|
|
36898
|
-
isInitialized &&
|
|
36899
37122
|
!!currentHistoryItem &&
|
|
36900
37123
|
!isHistoryTransactionEnded({
|
|
36901
37124
|
data: currentHistoryItem?.data,
|
|
36902
37125
|
txType: HistoryTxType.SWAP,
|
|
36903
37126
|
}),
|
|
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
|
|
37127
|
+
onEndStatus: ({ status, statusResponse }) => {
|
|
37128
|
+
if (!transaction?.transactionId)
|
|
37129
|
+
return;
|
|
37130
|
+
replaceSwapTransactionStatus({
|
|
37131
|
+
transactionId: transaction.transactionId,
|
|
37132
|
+
statusResponse,
|
|
37133
|
+
status,
|
|
37134
|
+
});
|
|
36913
37135
|
},
|
|
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
|
-
}
|
|
37136
|
+
onNotFound: () => {
|
|
37137
|
+
if (!transaction?.transactionId)
|
|
37138
|
+
return;
|
|
37139
|
+
replaceSwapTransactionStatus({
|
|
37140
|
+
transactionId: transaction.transactionId,
|
|
37141
|
+
statusResponse: undefined,
|
|
37142
|
+
status: TransactionStatus.NOT_FOUND,
|
|
37143
|
+
});
|
|
36930
37144
|
},
|
|
36931
|
-
onError: (
|
|
36932
|
-
// `fetchTransactionStatus` throws an error with a cause being an AxiosError
|
|
36933
|
-
const is404 = is404Error(error.cause);
|
|
37145
|
+
onError: () => {
|
|
36934
37146
|
if (!transaction?.transactionId)
|
|
36935
37147
|
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
|
-
}
|
|
37148
|
+
replaceSwapTransactionStatus({
|
|
37149
|
+
transactionId: transaction.transactionId,
|
|
37150
|
+
statusResponse: undefined,
|
|
37151
|
+
status: TransactionStatus.ERROR,
|
|
37152
|
+
});
|
|
36952
37153
|
},
|
|
36953
|
-
});
|
|
37154
|
+
}).transactionStatusQuery;
|
|
36954
37155
|
return {
|
|
36955
37156
|
transactionStatusQuery,
|
|
36956
37157
|
latestStatus: transactionStatusQuery.data
|
|
@@ -37427,5 +37628,5 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37427
37628
|
React.createElement(CosmosProvider, null, children)))))))))) : (placeholder);
|
|
37428
37629
|
};
|
|
37429
37630
|
|
|
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-
|
|
37631
|
+
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 };
|
|
37632
|
+
//# sourceMappingURL=index-C6O8biTF.js.map
|