@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
|
@@ -78,6 +78,8 @@ const solanaZeroAddress = "11111111111111111111111111111111";
|
|
|
78
78
|
const suiZeroAddress = "0x0000000000000000000000000000000000000000";
|
|
79
79
|
const xrplZeroAddress = "rrrrrrrrrrrrrrrrrrrrrhoLvTp";
|
|
80
80
|
const stellarZeroAddress = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
|
|
81
|
+
// TODO: check
|
|
82
|
+
const cantonZeroAddress = "none::12200000000000000000000000000000000000000000000000000000000000000000";
|
|
81
83
|
const chainTypeToZeroAddressMap = {
|
|
82
84
|
[squidTypes.ChainType.EVM]: viem.zeroAddress,
|
|
83
85
|
[squidTypes.ChainType.COSMOS]: cosmosZeroAddress,
|
|
@@ -86,6 +88,7 @@ const chainTypeToZeroAddressMap = {
|
|
|
86
88
|
[squidTypes.ChainType.SUI]: suiZeroAddress,
|
|
87
89
|
[squidTypes.ChainType.XRPL]: xrplZeroAddress,
|
|
88
90
|
[squidTypes.ChainType.STELLAR]: stellarZeroAddress,
|
|
91
|
+
[squidTypes.ChainType.CANTON]: cantonZeroAddress,
|
|
89
92
|
};
|
|
90
93
|
const nativeEvmTokenAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
91
94
|
const nativeCosmosTokenAddress = "uosmo";
|
|
@@ -94,6 +97,7 @@ const nativeBitcoinTokenAddress = "satoshi";
|
|
|
94
97
|
const nativeSuiTokenAddress = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
95
98
|
const nativeXrplTokenAddress = "xrp";
|
|
96
99
|
const nativeStellarTokenAddress = "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA";
|
|
100
|
+
const nativeCantonTokenAddress = "DSO::1220b1431ef217342db44d516bb9befde802be7d8899637d290895fa58880f19accc";
|
|
97
101
|
// by setting slippage to undefined, it's set to "auto"
|
|
98
102
|
const defaultSlippage = undefined;
|
|
99
103
|
const destinationAddressResetValue = "null";
|
|
@@ -157,6 +161,7 @@ const CHAIN_IDS = {
|
|
|
157
161
|
XRPL_TESTNET: "xrpl-testnet",
|
|
158
162
|
STELLAR: "stellar-mainnet",
|
|
159
163
|
STELLAR_TESTNET: "stellar-testnet",
|
|
164
|
+
CANTON: "canton",
|
|
160
165
|
};
|
|
161
166
|
const chainTypeToDefaultChainIdMap = {
|
|
162
167
|
[squidTypes.ChainType.EVM]: CHAIN_IDS.ETHEREUM,
|
|
@@ -166,6 +171,7 @@ const chainTypeToDefaultChainIdMap = {
|
|
|
166
171
|
[squidTypes.ChainType.SUI]: CHAIN_IDS.SUI,
|
|
167
172
|
[squidTypes.ChainType.XRPL]: CHAIN_IDS.XRPL,
|
|
168
173
|
[squidTypes.ChainType.STELLAR]: CHAIN_IDS.STELLAR,
|
|
174
|
+
[squidTypes.ChainType.CANTON]: CHAIN_IDS.CANTON,
|
|
169
175
|
};
|
|
170
176
|
const chainTypeToNativeTokenAddressMap = {
|
|
171
177
|
[squidTypes.ChainType.EVM]: nativeEvmTokenAddress,
|
|
@@ -175,6 +181,7 @@ const chainTypeToNativeTokenAddressMap = {
|
|
|
175
181
|
[squidTypes.ChainType.SUI]: nativeSuiTokenAddress,
|
|
176
182
|
[squidTypes.ChainType.XRPL]: nativeXrplTokenAddress,
|
|
177
183
|
[squidTypes.ChainType.STELLAR]: nativeStellarTokenAddress,
|
|
184
|
+
[squidTypes.ChainType.CANTON]: nativeCantonTokenAddress,
|
|
178
185
|
};
|
|
179
186
|
const defaultConfigValues = {
|
|
180
187
|
integratorId: INTEGRATOR_ID,
|
|
@@ -20872,6 +20879,18 @@ const isBitcoinAddressValid = (address) => {
|
|
|
20872
20879
|
}
|
|
20873
20880
|
};
|
|
20874
20881
|
|
|
20882
|
+
// Canton PartyID = address
|
|
20883
|
+
const CANTON_PARTY_ID_SEPARATOR = "::";
|
|
20884
|
+
function isCantonAddressValid(address) {
|
|
20885
|
+
// Canton address format: `name::fingerprint`, where name is an arbitrary string
|
|
20886
|
+
// and fingerprint is a 64-character hex string with a 1220 prefix (SHA-256 hash of the public key)
|
|
20887
|
+
const parts = address.split(CANTON_PARTY_ID_SEPARATOR);
|
|
20888
|
+
if (parts.length !== 2)
|
|
20889
|
+
return false;
|
|
20890
|
+
const [name, fingerprint] = parts;
|
|
20891
|
+
return name.length > 0 && /^1220[0-9a-f]{64}$/.test(fingerprint);
|
|
20892
|
+
}
|
|
20893
|
+
|
|
20875
20894
|
exports.HistoryTxType = void 0;
|
|
20876
20895
|
(function (HistoryTxType) {
|
|
20877
20896
|
HistoryTxType[HistoryTxType["SWAP"] = 0] = "SWAP";
|
|
@@ -20985,6 +21004,7 @@ const getSourceExplorerTxUrl = (chain, txID) => {
|
|
|
20985
21004
|
case CHAIN_IDS.AGORIC:
|
|
20986
21005
|
case CHAIN_IDS.XRPL:
|
|
20987
21006
|
case CHAIN_IDS.XRPL_TESTNET:
|
|
21007
|
+
case CHAIN_IDS.CANTON:
|
|
20988
21008
|
txSuffix = "/transactions/";
|
|
20989
21009
|
break;
|
|
20990
21010
|
case CHAIN_IDS.HEDERA:
|
|
@@ -21094,10 +21114,16 @@ const simplifyRouteAction = (action) => {
|
|
|
21094
21114
|
};
|
|
21095
21115
|
const fetchSwapTransactionStatus = async ({ transaction, integratorId, apiUrl, }) => {
|
|
21096
21116
|
const statusEndpoint = `${apiUrl}/v2/status`;
|
|
21117
|
+
const isCanton = transaction?.fromChain === CHAIN_IDS.CANTON;
|
|
21118
|
+
// For Canton, the backend handles all tx detection/submission from the quoteId
|
|
21119
|
+
// alone, so no transactionId is sent — only the quoteId param below.
|
|
21120
|
+
const transactionId = isCanton
|
|
21121
|
+
? undefined
|
|
21122
|
+
: transaction?.transactionIdForStatus ?? transaction?.transactionId;
|
|
21097
21123
|
try {
|
|
21098
21124
|
const response = await axios.get(statusEndpoint, {
|
|
21099
21125
|
params: {
|
|
21100
|
-
transactionId
|
|
21126
|
+
transactionId,
|
|
21101
21127
|
fromChainId: transaction?.fromChain,
|
|
21102
21128
|
toChainId: transaction?.toChain,
|
|
21103
21129
|
bridgeType: transaction?.bridgeType,
|
|
@@ -21144,7 +21170,7 @@ function isActionCompletedOnSourceTx(action, fromChainId) {
|
|
|
21144
21170
|
function sleep(ms) {
|
|
21145
21171
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21146
21172
|
}
|
|
21147
|
-
const
|
|
21173
|
+
const isChainflipDepositRoute = (route) => {
|
|
21148
21174
|
return (!!route &&
|
|
21149
21175
|
route.transactionRequest?.type === squidTypes.SquidDataType.ChainflipDepositAddress);
|
|
21150
21176
|
};
|
|
@@ -21169,6 +21195,12 @@ function isOnChainTxData(squidData) {
|
|
|
21169
21195
|
squidTypes.SquidDataType.DepositAddressWithMemo,
|
|
21170
21196
|
].includes(squidData.type);
|
|
21171
21197
|
}
|
|
21198
|
+
/**
|
|
21199
|
+
* Checks if a route is of type DepositAddressDirectTransfer
|
|
21200
|
+
*/
|
|
21201
|
+
function isDepositAddressDirectTransferRoute(squidData) {
|
|
21202
|
+
return (squidData.type === squidTypes.SquidDataType.DepositAddressDirectTransfer);
|
|
21203
|
+
}
|
|
21172
21204
|
function getHistoryTransactionId(tx) {
|
|
21173
21205
|
switch (tx.txType) {
|
|
21174
21206
|
case exports.HistoryTxType.SWAP:
|
|
@@ -21671,7 +21703,17 @@ const chainTypeToTrimLength = {
|
|
|
21671
21703
|
start: 4,
|
|
21672
21704
|
end: 4,
|
|
21673
21705
|
},
|
|
21706
|
+
// abc...123::abc...123
|
|
21707
|
+
[squidTypes.ChainType.CANTON]: {
|
|
21708
|
+
start: 3,
|
|
21709
|
+
end: 3,
|
|
21710
|
+
},
|
|
21674
21711
|
};
|
|
21712
|
+
const truncateWithEllipsis = (value, startLength, endLength) => value.length <= startLength + endLength
|
|
21713
|
+
? value
|
|
21714
|
+
: value.slice(0, startLength) +
|
|
21715
|
+
"..." +
|
|
21716
|
+
value.slice(value.length - endLength);
|
|
21675
21717
|
const formatHash = ({ chainType, hash }) => {
|
|
21676
21718
|
if (!hash)
|
|
21677
21719
|
return "";
|
|
@@ -21684,14 +21726,15 @@ const formatHash = ({ chainType, hash }) => {
|
|
|
21684
21726
|
chainTypeFormat = squidTypes.ChainType.COSMOS;
|
|
21685
21727
|
}
|
|
21686
21728
|
}
|
|
21687
|
-
const
|
|
21688
|
-
|
|
21689
|
-
|
|
21690
|
-
|
|
21691
|
-
return
|
|
21692
|
-
|
|
21693
|
-
|
|
21694
|
-
|
|
21729
|
+
const { start, end } = chainTypeToTrimLength[chainTypeFormat];
|
|
21730
|
+
if (chainTypeFormat === squidTypes.ChainType.CANTON &&
|
|
21731
|
+
hash.includes(CANTON_PARTY_ID_SEPARATOR)) {
|
|
21732
|
+
const [namespace, identifier] = hash.split(CANTON_PARTY_ID_SEPARATOR);
|
|
21733
|
+
return (truncateWithEllipsis(namespace, start, end) +
|
|
21734
|
+
CANTON_PARTY_ID_SEPARATOR +
|
|
21735
|
+
truncateWithEllipsis(identifier, start, end));
|
|
21736
|
+
}
|
|
21737
|
+
return truncateWithEllipsis(hash, start, end);
|
|
21695
21738
|
};
|
|
21696
21739
|
const isWalletAddressValid = (chainData, address) => {
|
|
21697
21740
|
if (!address || !chainData?.chainType)
|
|
@@ -21711,6 +21754,8 @@ const isWalletAddressValid = (chainData, address) => {
|
|
|
21711
21754
|
return isXrplAddressValid(address);
|
|
21712
21755
|
case squidTypes.ChainType.STELLAR:
|
|
21713
21756
|
return isStellarAddressValid(address);
|
|
21757
|
+
case squidTypes.ChainType.CANTON:
|
|
21758
|
+
return isCantonAddressValid(address);
|
|
21714
21759
|
}
|
|
21715
21760
|
};
|
|
21716
21761
|
const redirectToExtensionsStore = (wallet) => {
|
|
@@ -21972,6 +22017,8 @@ const connectByChainType = async (chainType, wallet, defaultChain, params) => {
|
|
|
21972
22017
|
connector,
|
|
21973
22018
|
},
|
|
21974
22019
|
});
|
|
22020
|
+
case squidTypes.ChainType.CANTON:
|
|
22021
|
+
return null;
|
|
21975
22022
|
}
|
|
21976
22023
|
};
|
|
21977
22024
|
const getChainTypesToConnect = (selectedChainTypes, defaultChain, supportedChains) => {
|
|
@@ -23046,7 +23093,10 @@ const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute, tokens, chai
|
|
|
23046
23093
|
else {
|
|
23047
23094
|
newFallbackAddress = fallbackAddress ?? initialSwapRoute?.fallbackAddress;
|
|
23048
23095
|
}
|
|
23049
|
-
const
|
|
23096
|
+
const sourceChainChanged = fromChainId !== undefined && fromChainId !== initialSwapRoute?.fromChainId;
|
|
23097
|
+
const newDepositRefundAddress = sourceChainChanged
|
|
23098
|
+
? undefined
|
|
23099
|
+
: depositRefundAddress || initialSwapRoute?.depositRefundAddress;
|
|
23050
23100
|
return {
|
|
23051
23101
|
fromChainId: srcChainId,
|
|
23052
23102
|
fromTokenAddress: sourceTokenAddress,
|
|
@@ -23325,7 +23375,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23325
23375
|
};
|
|
23326
23376
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23327
23377
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23328
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23378
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-DQhP5g0c.js'); });
|
|
23329
23379
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23330
23380
|
};
|
|
23331
23381
|
function getTokenAssetsKey(token) {
|
|
@@ -25299,7 +25349,7 @@ const useSquidTokens = (direction) => {
|
|
|
25299
25349
|
config.availableChains,
|
|
25300
25350
|
direction,
|
|
25301
25351
|
]);
|
|
25302
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = React.useMemo(() => {
|
|
25352
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, cantonTokens, } = React.useMemo(() => {
|
|
25303
25353
|
return tokens?.reduce((acc, token) => {
|
|
25304
25354
|
switch (token.type) {
|
|
25305
25355
|
case squidTypes.ChainType.EVM:
|
|
@@ -25323,6 +25373,9 @@ const useSquidTokens = (direction) => {
|
|
|
25323
25373
|
case squidTypes.ChainType.STELLAR:
|
|
25324
25374
|
acc.stellarTokens.push(token);
|
|
25325
25375
|
break;
|
|
25376
|
+
case squidTypes.ChainType.CANTON:
|
|
25377
|
+
acc.cantonTokens.push(token);
|
|
25378
|
+
break;
|
|
25326
25379
|
}
|
|
25327
25380
|
return acc;
|
|
25328
25381
|
}, {
|
|
@@ -25333,6 +25386,7 @@ const useSquidTokens = (direction) => {
|
|
|
25333
25386
|
suiTokens: [],
|
|
25334
25387
|
xrplTokens: [],
|
|
25335
25388
|
stellarTokens: [],
|
|
25389
|
+
cantonTokens: [],
|
|
25336
25390
|
});
|
|
25337
25391
|
}, [tokens]);
|
|
25338
25392
|
const findToken = React.useCallback((address, chainId) => {
|
|
@@ -25350,6 +25404,7 @@ const useSquidTokens = (direction) => {
|
|
|
25350
25404
|
suiTokens,
|
|
25351
25405
|
xrplTokens,
|
|
25352
25406
|
stellarTokens,
|
|
25407
|
+
cantonTokens,
|
|
25353
25408
|
};
|
|
25354
25409
|
};
|
|
25355
25410
|
|
|
@@ -25887,6 +25942,7 @@ const chainTypeToRefetchInterval = {
|
|
|
25887
25942
|
[squidTypes.ChainType.SUI]: 1_000,
|
|
25888
25943
|
[squidTypes.ChainType.XRPL]: 1_000,
|
|
25889
25944
|
[squidTypes.ChainType.STELLAR]: 1_000,
|
|
25945
|
+
[squidTypes.ChainType.CANTON]: 1_000,
|
|
25890
25946
|
};
|
|
25891
25947
|
/**
|
|
25892
25948
|
* Returns the status refetch interval of a Send transaction
|
|
@@ -26153,7 +26209,7 @@ const useSquidChains = (direction) => {
|
|
|
26153
26209
|
const chain = findChain(chainId);
|
|
26154
26210
|
return chain?.chainType;
|
|
26155
26211
|
}, [findChain]);
|
|
26156
|
-
const { evmChains, cosmosChains, suiChains, stellarChains, xrplChains } = React.useMemo(() => {
|
|
26212
|
+
const { evmChains, cosmosChains, suiChains, stellarChains, xrplChains, cantonChains, } = React.useMemo(() => {
|
|
26157
26213
|
return chains.reduce((acc, chain) => {
|
|
26158
26214
|
switch (chain.chainType) {
|
|
26159
26215
|
case squidTypes.ChainType.EVM:
|
|
@@ -26171,6 +26227,9 @@ const useSquidChains = (direction) => {
|
|
|
26171
26227
|
case squidTypes.ChainType.STELLAR:
|
|
26172
26228
|
acc.stellarChains.push(chain);
|
|
26173
26229
|
break;
|
|
26230
|
+
case squidTypes.ChainType.CANTON:
|
|
26231
|
+
acc.cantonChains.push(chain);
|
|
26232
|
+
break;
|
|
26174
26233
|
}
|
|
26175
26234
|
return acc;
|
|
26176
26235
|
}, {
|
|
@@ -26179,6 +26238,7 @@ const useSquidChains = (direction) => {
|
|
|
26179
26238
|
suiChains: [],
|
|
26180
26239
|
xrplChains: [],
|
|
26181
26240
|
stellarChains: [],
|
|
26241
|
+
cantonChains: [],
|
|
26182
26242
|
});
|
|
26183
26243
|
}, [chains]);
|
|
26184
26244
|
const { supportedSourceChains, supportedDestinationChains } = React.useMemo(() => {
|
|
@@ -26199,6 +26259,7 @@ const useSquidChains = (direction) => {
|
|
|
26199
26259
|
suiChains,
|
|
26200
26260
|
xrplChains,
|
|
26201
26261
|
stellarChains,
|
|
26262
|
+
cantonChains,
|
|
26202
26263
|
getChainType,
|
|
26203
26264
|
findChain,
|
|
26204
26265
|
};
|
|
@@ -26723,7 +26784,7 @@ function useStellarWallets() {
|
|
|
26723
26784
|
try {
|
|
26724
26785
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26725
26786
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
26726
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
26787
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-BQrRZDwB.js'); });
|
|
26727
26788
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26728
26789
|
const promises = modules.map(async (module) => {
|
|
26729
26790
|
const isAvailable = await module.isAvailable();
|
|
@@ -27422,6 +27483,7 @@ const useMultiChainWallet = (chain) => {
|
|
|
27422
27483
|
const suiAddress = connectedAddresses[squidTypes.ChainType.SUI];
|
|
27423
27484
|
const xrplAddress = connectedAddresses[squidTypes.ChainType.XRPL];
|
|
27424
27485
|
const stellarAddress = connectedAddresses[squidTypes.ChainType.STELLAR];
|
|
27486
|
+
const cantonAddress = connectedAddresses[squidTypes.ChainType.CANTON];
|
|
27425
27487
|
// Cosmos is a special case because the address changes on every chain
|
|
27426
27488
|
// so we can't use the default cosmos connected address
|
|
27427
27489
|
const { data: cosmosAddress } = useCosmosForChain(chain);
|
|
@@ -27509,6 +27571,16 @@ const useMultiChainWallet = (chain) => {
|
|
|
27509
27571
|
chainType: chain.chainType,
|
|
27510
27572
|
}),
|
|
27511
27573
|
};
|
|
27574
|
+
case squidTypes.ChainType.CANTON:
|
|
27575
|
+
if (!cantonAddress)
|
|
27576
|
+
return {};
|
|
27577
|
+
return {
|
|
27578
|
+
address: cantonAddress,
|
|
27579
|
+
formatted: formatHash({
|
|
27580
|
+
hash: cantonAddress,
|
|
27581
|
+
chainType: chain.chainType,
|
|
27582
|
+
}),
|
|
27583
|
+
};
|
|
27512
27584
|
}
|
|
27513
27585
|
}, [
|
|
27514
27586
|
chain?.chainType,
|
|
@@ -27520,6 +27592,7 @@ const useMultiChainWallet = (chain) => {
|
|
|
27520
27592
|
suiAddress,
|
|
27521
27593
|
xrplAddress,
|
|
27522
27594
|
stellarAddress,
|
|
27595
|
+
cantonAddress,
|
|
27523
27596
|
]);
|
|
27524
27597
|
/**
|
|
27525
27598
|
* Change current network for desired chain
|
|
@@ -28344,6 +28417,8 @@ async function createClient(chain) {
|
|
|
28344
28417
|
return new XrplRpcClient(chain.rpc);
|
|
28345
28418
|
case squidTypes.ChainType.STELLAR:
|
|
28346
28419
|
return new StellarRpcClient(chain.rpc);
|
|
28420
|
+
case squidTypes.ChainType.CANTON:
|
|
28421
|
+
return null;
|
|
28347
28422
|
}
|
|
28348
28423
|
}
|
|
28349
28424
|
|
|
@@ -29536,7 +29611,7 @@ const useStellarBalance = ({ userAddress, chain, enabled, token, refreshInterval
|
|
|
29536
29611
|
};
|
|
29537
29612
|
|
|
29538
29613
|
function useNativeTokenForChain(chain) {
|
|
29539
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens();
|
|
29614
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, cantonTokens, } = useSquidTokens();
|
|
29540
29615
|
const getTokensForChainType = () => {
|
|
29541
29616
|
if (!chain?.chainType)
|
|
29542
29617
|
return [];
|
|
@@ -29555,6 +29630,8 @@ function useNativeTokenForChain(chain) {
|
|
|
29555
29630
|
return xrplTokens;
|
|
29556
29631
|
case squidTypes.ChainType.STELLAR:
|
|
29557
29632
|
return stellarTokens;
|
|
29633
|
+
case squidTypes.ChainType.CANTON:
|
|
29634
|
+
return cantonTokens;
|
|
29558
29635
|
}
|
|
29559
29636
|
};
|
|
29560
29637
|
const nativeTokenForChainType = React.useMemo(() => {
|
|
@@ -29789,6 +29866,11 @@ const useNativeBalance = (chain) => {
|
|
|
29789
29866
|
break;
|
|
29790
29867
|
case squidTypes.ChainType.STELLAR:
|
|
29791
29868
|
balance = nativeStellarBalance;
|
|
29869
|
+
break;
|
|
29870
|
+
case squidTypes.ChainType.CANTON:
|
|
29871
|
+
// TODO: implement canton balance fetching
|
|
29872
|
+
balance = undefined;
|
|
29873
|
+
break;
|
|
29792
29874
|
}
|
|
29793
29875
|
const balanceFormatted = !!balance
|
|
29794
29876
|
? formatBNToReadable(balance.value, balance.decimals)
|
|
@@ -29825,6 +29907,9 @@ const useNativeBalance = (chain) => {
|
|
|
29825
29907
|
return isXrpLoading;
|
|
29826
29908
|
case squidTypes.ChainType.STELLAR:
|
|
29827
29909
|
return isStellarLoading;
|
|
29910
|
+
case squidTypes.ChainType.CANTON:
|
|
29911
|
+
// TODO: implement canton balance fetching
|
|
29912
|
+
return false;
|
|
29828
29913
|
}
|
|
29829
29914
|
}, [
|
|
29830
29915
|
chain?.chainType,
|
|
@@ -30049,7 +30134,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30049
30134
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30050
30135
|
if (!optionalChains.length)
|
|
30051
30136
|
return;
|
|
30052
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
30137
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-CjEZHrFG.js'); });
|
|
30053
30138
|
const rawProvider = await EthereumProvider.init({
|
|
30054
30139
|
...restParameters,
|
|
30055
30140
|
disableProviderPing: true,
|
|
@@ -30279,6 +30364,8 @@ const useSigner = ({ chain }) => {
|
|
|
30279
30364
|
return isXrplSignerReady;
|
|
30280
30365
|
case squidTypes.ChainType.STELLAR:
|
|
30281
30366
|
return isStellarSignerReady;
|
|
30367
|
+
case squidTypes.ChainType.CANTON:
|
|
30368
|
+
return false;
|
|
30282
30369
|
}
|
|
30283
30370
|
}, [
|
|
30284
30371
|
chain?.chainType,
|
|
@@ -30751,6 +30838,7 @@ function useDepositAddress(squidRoute) {
|
|
|
30751
30838
|
const chainsSupportingDepositAddress = [
|
|
30752
30839
|
CHAIN_IDS.BITCOIN,
|
|
30753
30840
|
CHAIN_IDS.SOLANA,
|
|
30841
|
+
CHAIN_IDS.CANTON,
|
|
30754
30842
|
];
|
|
30755
30843
|
return chainsSupportingDepositAddress.includes(fromChain.chainId);
|
|
30756
30844
|
}, [fromChain?.chainId]);
|
|
@@ -30765,20 +30853,34 @@ function useDepositAddress(squidRoute) {
|
|
|
30765
30853
|
toggleDepositFlow(false);
|
|
30766
30854
|
}, [toggleDepositFlow]);
|
|
30767
30855
|
const closeDepositChannel = React.useCallback(() => {
|
|
30768
|
-
toggleDepositFlow(false);
|
|
30769
30856
|
setDeposit(null);
|
|
30770
|
-
}, [
|
|
30857
|
+
}, [setDeposit]);
|
|
30771
30858
|
const getRouteWithDeposit = reactQuery.useMutation(async ({ route }) => {
|
|
30772
|
-
if (!squid)
|
|
30773
|
-
throw new Error("
|
|
30774
|
-
|
|
30775
|
-
|
|
30776
|
-
|
|
30777
|
-
|
|
30778
|
-
|
|
30779
|
-
|
|
30780
|
-
|
|
30781
|
-
|
|
30859
|
+
if (!squid || !route.transactionRequest)
|
|
30860
|
+
throw new Error("Missing required params");
|
|
30861
|
+
if (isChainflipDepositRoute(route)) {
|
|
30862
|
+
const depositAddressResponse = (await squid.executeRoute({
|
|
30863
|
+
signer: {},
|
|
30864
|
+
route,
|
|
30865
|
+
}));
|
|
30866
|
+
setDeposit({
|
|
30867
|
+
amount: depositAddressResponse.amount,
|
|
30868
|
+
depositAddress: depositAddressResponse.depositAddress,
|
|
30869
|
+
statusTrackingId: depositAddressResponse.chainflipStatusTrackingId,
|
|
30870
|
+
});
|
|
30871
|
+
return;
|
|
30872
|
+
}
|
|
30873
|
+
else if (isDepositAddressDirectTransferRoute(route.transactionRequest)) {
|
|
30874
|
+
const orderHash = route.transactionRequest.data;
|
|
30875
|
+
setDeposit({
|
|
30876
|
+
amount: route.params.fromAmount ?? "",
|
|
30877
|
+
depositAddress: route.transactionRequest.target,
|
|
30878
|
+
// Squid Scan indexes the Canton tx by the orderHash
|
|
30879
|
+
statusTrackingId: orderHash,
|
|
30880
|
+
memo: orderHash,
|
|
30881
|
+
});
|
|
30882
|
+
return;
|
|
30883
|
+
}
|
|
30782
30884
|
});
|
|
30783
30885
|
return {
|
|
30784
30886
|
isEnabled,
|
|
@@ -30817,7 +30919,7 @@ const useUrlSwapParams = () => {
|
|
|
30817
30919
|
|
|
30818
30920
|
const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, queryOptions, }) => {
|
|
30819
30921
|
const { evmChains, cosmosChains, suiChains, xrplChains, stellarChains } = useSquidChains(direction);
|
|
30820
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens(direction);
|
|
30922
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, cantonTokens, } = useSquidTokens(direction);
|
|
30821
30923
|
const { keplrTypeWallet } = useCosmosContext();
|
|
30822
30924
|
const placeholderData = React.useMemo(() => {
|
|
30823
30925
|
const tokens = {
|
|
@@ -30828,6 +30930,7 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30828
30930
|
[squidTypes.ChainType.SUI]: suiTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30829
30931
|
[squidTypes.ChainType.XRPL]: xrplTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30830
30932
|
[squidTypes.ChainType.STELLAR]: stellarTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30933
|
+
[squidTypes.ChainType.CANTON]: cantonTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30831
30934
|
};
|
|
30832
30935
|
if (!chainType) {
|
|
30833
30936
|
// Return all tokens with zero balance
|
|
@@ -30849,6 +30952,7 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30849
30952
|
suiTokens,
|
|
30850
30953
|
xrplTokens,
|
|
30851
30954
|
stellarTokens,
|
|
30955
|
+
cantonTokens,
|
|
30852
30956
|
]);
|
|
30853
30957
|
const isQueryEnabled = React.useMemo(() => {
|
|
30854
30958
|
// Respect the queryOptions.enabled override if provided
|
|
@@ -30871,6 +30975,8 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30871
30975
|
return xrplTokens.length > 0;
|
|
30872
30976
|
case squidTypes.ChainType.STELLAR:
|
|
30873
30977
|
return stellarTokens.length > 0;
|
|
30978
|
+
case squidTypes.ChainType.CANTON:
|
|
30979
|
+
return cantonTokens.length > 0;
|
|
30874
30980
|
}
|
|
30875
30981
|
}, [
|
|
30876
30982
|
chainType,
|
|
@@ -30883,6 +30989,7 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30883
30989
|
suiTokens.length,
|
|
30884
30990
|
xrplTokens.length,
|
|
30885
30991
|
stellarTokens.length,
|
|
30992
|
+
cantonTokens.length,
|
|
30886
30993
|
]);
|
|
30887
30994
|
const query = reactQuery.useQuery(keys().allTokensBalance(address, chainType, direction), async () => {
|
|
30888
30995
|
// Return zero balances if no address
|
|
@@ -30992,6 +31099,12 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
30992
31099
|
direction,
|
|
30993
31100
|
queryOptions,
|
|
30994
31101
|
});
|
|
31102
|
+
const cantonBalancesQuery = useAllTokensWithBalanceForChainType({
|
|
31103
|
+
chainType: squidTypes.ChainType.CANTON,
|
|
31104
|
+
address: connectedAddresses?.[squidTypes.ChainType.CANTON],
|
|
31105
|
+
direction,
|
|
31106
|
+
queryOptions,
|
|
31107
|
+
});
|
|
30995
31108
|
// Create a map of chain type to balance query results
|
|
30996
31109
|
const balanceQueries = React.useMemo(() => ({
|
|
30997
31110
|
[squidTypes.ChainType.EVM]: evmBalancesQuery,
|
|
@@ -31001,6 +31114,7 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
31001
31114
|
[squidTypes.ChainType.SUI]: suiBalancesQuery,
|
|
31002
31115
|
[squidTypes.ChainType.XRPL]: xrplBalancesQuery,
|
|
31003
31116
|
[squidTypes.ChainType.STELLAR]: stellarBalancesQuery,
|
|
31117
|
+
[squidTypes.ChainType.CANTON]: cantonBalancesQuery,
|
|
31004
31118
|
}), [
|
|
31005
31119
|
evmBalancesQuery,
|
|
31006
31120
|
cosmosBalancesQuery,
|
|
@@ -31009,6 +31123,7 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
31009
31123
|
suiBalancesQuery,
|
|
31010
31124
|
xrplBalancesQuery,
|
|
31011
31125
|
stellarBalancesQuery,
|
|
31126
|
+
cantonBalancesQuery,
|
|
31012
31127
|
]);
|
|
31013
31128
|
// Combine all tokens from different chains
|
|
31014
31129
|
const allTokens = React.useMemo(() => Object.values(balanceQueries).flatMap((query) => query.data?.tokens ?? []), [balanceQueries]);
|
|
@@ -31108,6 +31223,9 @@ const useMultiChainBalance = ({ chain, token, userAddress, enabled = true, }) =>
|
|
|
31108
31223
|
return xrplBalance;
|
|
31109
31224
|
case squidTypes.ChainType.STELLAR:
|
|
31110
31225
|
return stellarBalance;
|
|
31226
|
+
case squidTypes.ChainType.CANTON:
|
|
31227
|
+
// TODO: implement canton balance fetching
|
|
31228
|
+
return "0";
|
|
31111
31229
|
}
|
|
31112
31230
|
}, [
|
|
31113
31231
|
chain?.chainType,
|
|
@@ -32216,6 +32334,9 @@ function useSendTransaction({ to, amount, token, chain, }) {
|
|
|
32216
32334
|
chain,
|
|
32217
32335
|
});
|
|
32218
32336
|
break;
|
|
32337
|
+
case squidTypes.ChainType.CANTON: {
|
|
32338
|
+
throw new Error("Not implemented");
|
|
32339
|
+
}
|
|
32219
32340
|
}
|
|
32220
32341
|
return {
|
|
32221
32342
|
amount,
|
|
@@ -32419,6 +32540,8 @@ async function getSendTransactionStatus({ chain, txHash, }) {
|
|
|
32419
32540
|
txHash,
|
|
32420
32541
|
chain,
|
|
32421
32542
|
});
|
|
32543
|
+
case squidTypes.ChainType.CANTON:
|
|
32544
|
+
throw new Error("Not implemented");
|
|
32422
32545
|
}
|
|
32423
32546
|
}
|
|
32424
32547
|
|
|
@@ -32442,7 +32565,7 @@ const useHistory = (txType) => {
|
|
|
32442
32565
|
fromChain: tx.params.fromChain,
|
|
32443
32566
|
fromToken: tx.params.fromToken,
|
|
32444
32567
|
fromAddress: tx.params.fromAddress,
|
|
32445
|
-
fromAmount: tx.params.fromAmount,
|
|
32568
|
+
fromAmount: tx.params.fromAmount ?? "",
|
|
32446
32569
|
toChain: tx.params.toChain,
|
|
32447
32570
|
toToken: tx.params.toToken,
|
|
32448
32571
|
toAddress: tx.params.toAddress,
|
|
@@ -32870,6 +32993,128 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32870
32993
|
};
|
|
32871
32994
|
};
|
|
32872
32995
|
|
|
32996
|
+
const useSwapStatusQuery = ({ transaction, retry = 25, refetchOnWindowFocus = "always", enabled = true, onStatus, onEndStatus, onNotFound, onError, }) => {
|
|
32997
|
+
const config = useConfigStore((state) => state.config);
|
|
32998
|
+
const isInitialized = useConfigStore((state) => state.isInitialized);
|
|
32999
|
+
const [isTransactionComplete, setIsTransactionComplete] = React.useState(false);
|
|
33000
|
+
const [refetchInterval, setRefetchInterval] = React.useState(getSwapTxStatusRefetchInterval(transaction));
|
|
33001
|
+
const { getChainType } = useSquidChains();
|
|
33002
|
+
const fetchTransactionStatusWithLatestConfig = React.useCallback(async () => {
|
|
33003
|
+
const latestConfig = useConfigStore.getState().config;
|
|
33004
|
+
return fetchSwapTransactionStatus({
|
|
33005
|
+
transaction,
|
|
33006
|
+
integratorId: latestConfig.integratorId,
|
|
33007
|
+
apiUrl: latestConfig.apiUrl,
|
|
33008
|
+
});
|
|
33009
|
+
}, [transaction]);
|
|
33010
|
+
const transactionStatusQuery = reactQuery.useQuery(keys().swapTransactionStatus(transaction?.transactionId), fetchTransactionStatusWithLatestConfig, {
|
|
33011
|
+
enabled: enabled &&
|
|
33012
|
+
transaction?.transactionId !== "0" &&
|
|
33013
|
+
!!transaction?.transactionId &&
|
|
33014
|
+
!!transaction.fromAddress &&
|
|
33015
|
+
!!config.apiUrl &&
|
|
33016
|
+
transaction !== undefined &&
|
|
33017
|
+
!isTransactionComplete &&
|
|
33018
|
+
isInitialized,
|
|
33019
|
+
refetchInterval(statusResponse) {
|
|
33020
|
+
if (statusResponse &&
|
|
33021
|
+
transactionEndStatuses.includes(getTransactionStatus(statusResponse) ?? "")) {
|
|
33022
|
+
return false;
|
|
33023
|
+
}
|
|
33024
|
+
return refetchInterval;
|
|
33025
|
+
},
|
|
33026
|
+
retryDelay: getChainType(transaction?.fromChain) === squidTypes.ChainType.COSMOS ? 5000 : 3000,
|
|
33027
|
+
retry: getChainType(transaction?.fromChain) === squidTypes.ChainType.COSMOS ? 6 : retry,
|
|
33028
|
+
refetchOnWindowFocus,
|
|
33029
|
+
onSuccess: (statusResponse) => {
|
|
33030
|
+
WidgetEvents.getInstance().dispatchSwapStatus(statusResponse.squidTransactionStatus ?? "");
|
|
33031
|
+
onStatus?.({
|
|
33032
|
+
status: getTransactionStatus(statusResponse) ?? "",
|
|
33033
|
+
statusResponse,
|
|
33034
|
+
});
|
|
33035
|
+
const endStatus = getTransactionEndStatus({ statusResponse });
|
|
33036
|
+
if (endStatus) {
|
|
33037
|
+
setIsTransactionComplete(true);
|
|
33038
|
+
onEndStatus?.({ status: endStatus, statusResponse });
|
|
33039
|
+
}
|
|
33040
|
+
},
|
|
33041
|
+
onError: (error) => {
|
|
33042
|
+
if (is404Error(error.cause)) {
|
|
33043
|
+
onNotFound?.();
|
|
33044
|
+
return;
|
|
33045
|
+
}
|
|
33046
|
+
setRefetchInterval(-1);
|
|
33047
|
+
setIsTransactionComplete(true);
|
|
33048
|
+
onError?.();
|
|
33049
|
+
},
|
|
33050
|
+
});
|
|
33051
|
+
return {
|
|
33052
|
+
transactionStatusQuery,
|
|
33053
|
+
};
|
|
33054
|
+
};
|
|
33055
|
+
|
|
33056
|
+
// Statuses that indicate the source deposit has been received and the swap is
|
|
33057
|
+
// now progressing — the point at which it becomes a history-backed transaction.
|
|
33058
|
+
const sourceReceivedStatuses = [
|
|
33059
|
+
// Chainflip
|
|
33060
|
+
"DEPOSIT_RECEIVED",
|
|
33061
|
+
"BROADCAST_REQUESTED",
|
|
33062
|
+
"COMPLETE",
|
|
33063
|
+
// Canton (Squid Intents)
|
|
33064
|
+
"awaiting",
|
|
33065
|
+
];
|
|
33066
|
+
/**
|
|
33067
|
+
* Tracks a generated deposit address before it becomes a persisted swap history item.
|
|
33068
|
+
*
|
|
33069
|
+
* Mirrors the hooks-first pattern of `useExecuteTransaction`: once the source deposit
|
|
33070
|
+
* is received, it registers the transaction in the transaction + history stores, then
|
|
33071
|
+
* signals the view (via `onReceived`) to navigate. The view never writes to the stores.
|
|
33072
|
+
*/
|
|
33073
|
+
const useDepositTransactionStatus = ({ transaction, route, retry = 25, refetchOnWindowFocus = "always", enabled = true, onReceived, }) => {
|
|
33074
|
+
const { fromChain, toChain } = useSwap();
|
|
33075
|
+
const { addSwapTransaction } = useHistory();
|
|
33076
|
+
const getTransaction = useTransactionStore((state) => state.getTransaction);
|
|
33077
|
+
const setTransactionStoreState = useTransactionStore((state) => state.setTransactionState);
|
|
33078
|
+
return useSwapStatusQuery({
|
|
33079
|
+
transaction,
|
|
33080
|
+
retry,
|
|
33081
|
+
refetchOnWindowFocus,
|
|
33082
|
+
enabled,
|
|
33083
|
+
onStatus: ({ status }) => {
|
|
33084
|
+
if (!sourceReceivedStatuses.includes(status))
|
|
33085
|
+
return;
|
|
33086
|
+
if (!transaction?.transactionId || !route?.transactionRequest)
|
|
33087
|
+
return;
|
|
33088
|
+
const txLocalId = transaction.transactionId;
|
|
33089
|
+
if (getTransaction(txLocalId))
|
|
33090
|
+
return;
|
|
33091
|
+
useTransactionStore.setState({
|
|
33092
|
+
txLocalId,
|
|
33093
|
+
currentTransaction: undefined,
|
|
33094
|
+
});
|
|
33095
|
+
const tx = {
|
|
33096
|
+
routeType: route.transactionRequest.type,
|
|
33097
|
+
fromChain,
|
|
33098
|
+
toChain,
|
|
33099
|
+
fromAddress: transaction.fromAddress,
|
|
33100
|
+
transactionId: txLocalId,
|
|
33101
|
+
transactionIdForStatus: transaction.transactionIdForStatus,
|
|
33102
|
+
quoteId: transaction.quoteId ?? "",
|
|
33103
|
+
status: exports.TransactionStatus.ONGOING,
|
|
33104
|
+
sourceStatus: exports.TransactionStatus.SUCCESS,
|
|
33105
|
+
timestamp: Date.now(),
|
|
33106
|
+
};
|
|
33107
|
+
setTransactionStoreState(txLocalId, tx);
|
|
33108
|
+
addSwapTransaction({
|
|
33109
|
+
...tx,
|
|
33110
|
+
params: route.params,
|
|
33111
|
+
estimate: route.estimate,
|
|
33112
|
+
});
|
|
33113
|
+
onReceived?.();
|
|
33114
|
+
},
|
|
33115
|
+
});
|
|
33116
|
+
};
|
|
33117
|
+
|
|
32873
33118
|
const DEFAULT_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/providers/squid.webp";
|
|
32874
33119
|
const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/providers/axelar.webp";
|
|
32875
33120
|
const useEstimate = (squidRoute) => {
|
|
@@ -36188,7 +36433,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36188
36433
|
if (!route.params.fromAddress || !route.params.toAddress) {
|
|
36189
36434
|
throw new Error("From or to address is required");
|
|
36190
36435
|
}
|
|
36191
|
-
const isDirectTransfer =
|
|
36436
|
+
const isDirectTransfer = isChainflipDepositRoute(route);
|
|
36192
36437
|
// Means it's a transfer to a deposit address
|
|
36193
36438
|
// Instead of a Swap/Contract call using a DEX like Jupiter
|
|
36194
36439
|
if (isDirectTransfer) {
|
|
@@ -36199,7 +36444,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36199
36444
|
throw new Error("Deposit address is required");
|
|
36200
36445
|
}
|
|
36201
36446
|
const signature = await executeSolanaTransfer({
|
|
36202
|
-
amount: BigInt(route.params.fromAmount),
|
|
36447
|
+
amount: BigInt(route.params.fromAmount ?? ""),
|
|
36203
36448
|
target: depositData.depositAddress,
|
|
36204
36449
|
signer: solanaSigner,
|
|
36205
36450
|
connection: solanaConnection,
|
|
@@ -36209,7 +36454,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36209
36454
|
const txParams = setTransactionState({
|
|
36210
36455
|
route,
|
|
36211
36456
|
txHash,
|
|
36212
|
-
transactionIdForStatus: depositData.
|
|
36457
|
+
transactionIdForStatus: depositData.statusTrackingId,
|
|
36213
36458
|
userAddress: sourceUserAddress,
|
|
36214
36459
|
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
36215
36460
|
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
@@ -36260,7 +36505,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36260
36505
|
}
|
|
36261
36506
|
});
|
|
36262
36507
|
const swapMutationBitcoin = reactQuery.useMutation(async ({ id, route }) => {
|
|
36263
|
-
const { depositAddress, amount: sendAmount,
|
|
36508
|
+
const { depositAddress, amount: sendAmount, statusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
|
|
36264
36509
|
if (!depositAddress) {
|
|
36265
36510
|
throw new Error(`Invalid deposit address: ${depositAddress}`);
|
|
36266
36511
|
}
|
|
@@ -36283,7 +36528,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36283
36528
|
txHash,
|
|
36284
36529
|
// When bridging from Bitcoin we need to send the chainflipId to the status endpoint
|
|
36285
36530
|
// instead of the Bitcoin transaction hash
|
|
36286
|
-
transactionIdForStatus:
|
|
36531
|
+
transactionIdForStatus: statusTrackingId,
|
|
36287
36532
|
userAddress: sourceUserAddress,
|
|
36288
36533
|
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
36289
36534
|
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
@@ -36884,94 +37129,50 @@ function useSendTransactionStatus({ chain, txHash, }) {
|
|
|
36884
37129
|
* Fetch status of a Swap transaction
|
|
36885
37130
|
*/
|
|
36886
37131
|
const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocus = "always", enabled = true, }) => {
|
|
36887
|
-
const config = useConfigStore((state) => state.config);
|
|
36888
|
-
const isInitialized = useConfigStore((state) => state.isInitialized);
|
|
36889
37132
|
const { replaceSwapTransactionStatus } = useHistory();
|
|
36890
37133
|
const findTransaction = useHistoryStore((state) => state.findTransaction);
|
|
36891
|
-
const [isTransactionComplete, setIsTransactionComplete] = React.useState(false);
|
|
36892
|
-
const [refetchInterval, setRefetchInterval] = React.useState(getSwapTxStatusRefetchInterval(transaction));
|
|
36893
|
-
const { getChainType } = useSquidChains();
|
|
36894
37134
|
const currentHistoryItem = React.useMemo(() => findTransaction({
|
|
36895
37135
|
transactionId: transaction?.transactionId,
|
|
36896
37136
|
txType: exports.HistoryTxType.SWAP,
|
|
36897
37137
|
}), [findTransaction, transaction?.transactionId]);
|
|
36898
|
-
|
|
36899
|
-
|
|
36900
|
-
|
|
36901
|
-
|
|
36902
|
-
*/
|
|
36903
|
-
const fetchTransactionStatusWithLatestConfig = React.useCallback(async () => {
|
|
36904
|
-
const latestConfig = useConfigStore.getState().config;
|
|
36905
|
-
return fetchSwapTransactionStatus({
|
|
36906
|
-
transaction,
|
|
36907
|
-
integratorId: latestConfig.integratorId,
|
|
36908
|
-
apiUrl: latestConfig.apiUrl,
|
|
36909
|
-
});
|
|
36910
|
-
}, [transaction]);
|
|
36911
|
-
const transactionStatusQuery = reactQuery.useQuery(keys().swapTransactionStatus(transaction?.transactionId), fetchTransactionStatusWithLatestConfig, {
|
|
37138
|
+
const transactionStatusQuery = useSwapStatusQuery({
|
|
37139
|
+
transaction,
|
|
37140
|
+
retry,
|
|
37141
|
+
refetchOnWindowFocus,
|
|
36912
37142
|
enabled: enabled &&
|
|
36913
|
-
transaction?.transactionId !== "0" &&
|
|
36914
|
-
!!transaction?.transactionId &&
|
|
36915
|
-
!!transaction.fromAddress &&
|
|
36916
|
-
!!config.apiUrl &&
|
|
36917
|
-
transaction !== undefined &&
|
|
36918
|
-
!isTransactionComplete &&
|
|
36919
|
-
isInitialized &&
|
|
36920
37143
|
!!currentHistoryItem &&
|
|
36921
37144
|
!isHistoryTransactionEnded({
|
|
36922
37145
|
data: currentHistoryItem?.data,
|
|
36923
37146
|
txType: exports.HistoryTxType.SWAP,
|
|
36924
37147
|
}),
|
|
36925
|
-
|
|
36926
|
-
|
|
36927
|
-
|
|
36928
|
-
|
|
36929
|
-
|
|
36930
|
-
|
|
36931
|
-
|
|
36932
|
-
}
|
|
36933
|
-
return refetchInterval; // Had to handle a variable here because after onError, we want the interval to stop
|
|
37148
|
+
onEndStatus: ({ status, statusResponse }) => {
|
|
37149
|
+
if (!transaction?.transactionId)
|
|
37150
|
+
return;
|
|
37151
|
+
replaceSwapTransactionStatus({
|
|
37152
|
+
transactionId: transaction.transactionId,
|
|
37153
|
+
statusResponse,
|
|
37154
|
+
status,
|
|
37155
|
+
});
|
|
36934
37156
|
},
|
|
36935
|
-
|
|
36936
|
-
|
|
36937
|
-
|
|
36938
|
-
|
|
36939
|
-
|
|
36940
|
-
|
|
36941
|
-
|
|
36942
|
-
|
|
36943
|
-
if (endStatus && transaction?.transactionId) {
|
|
36944
|
-
setIsTransactionComplete(true);
|
|
36945
|
-
replaceSwapTransactionStatus({
|
|
36946
|
-
transactionId: transaction.transactionId,
|
|
36947
|
-
statusResponse,
|
|
36948
|
-
status: endStatus,
|
|
36949
|
-
});
|
|
36950
|
-
}
|
|
37157
|
+
onNotFound: () => {
|
|
37158
|
+
if (!transaction?.transactionId)
|
|
37159
|
+
return;
|
|
37160
|
+
replaceSwapTransactionStatus({
|
|
37161
|
+
transactionId: transaction.transactionId,
|
|
37162
|
+
statusResponse: undefined,
|
|
37163
|
+
status: exports.TransactionStatus.NOT_FOUND,
|
|
37164
|
+
});
|
|
36951
37165
|
},
|
|
36952
|
-
onError: (
|
|
36953
|
-
// `fetchTransactionStatus` throws an error with a cause being an AxiosError
|
|
36954
|
-
const is404 = is404Error(error.cause);
|
|
37166
|
+
onError: () => {
|
|
36955
37167
|
if (!transaction?.transactionId)
|
|
36956
37168
|
return;
|
|
36957
|
-
|
|
36958
|
-
|
|
36959
|
-
|
|
36960
|
-
|
|
36961
|
-
|
|
36962
|
-
});
|
|
36963
|
-
}
|
|
36964
|
-
else {
|
|
36965
|
-
setRefetchInterval(-1);
|
|
36966
|
-
setIsTransactionComplete(true);
|
|
36967
|
-
replaceSwapTransactionStatus({
|
|
36968
|
-
transactionId: transaction.transactionId,
|
|
36969
|
-
statusResponse: undefined,
|
|
36970
|
-
status: exports.TransactionStatus.ERROR,
|
|
36971
|
-
});
|
|
36972
|
-
}
|
|
37169
|
+
replaceSwapTransactionStatus({
|
|
37170
|
+
transactionId: transaction.transactionId,
|
|
37171
|
+
statusResponse: undefined,
|
|
37172
|
+
status: exports.TransactionStatus.ERROR,
|
|
37173
|
+
});
|
|
36973
37174
|
},
|
|
36974
|
-
});
|
|
37175
|
+
}).transactionStatusQuery;
|
|
36975
37176
|
return {
|
|
36976
37177
|
transactionStatusQuery,
|
|
36977
37178
|
latestStatus: transactionStatusQuery.data
|
|
@@ -37564,9 +37765,10 @@ exports.initializeSquidWithAssetsColors = initializeSquidWithAssetsColors;
|
|
|
37564
37765
|
exports.is404Error = is404Error;
|
|
37565
37766
|
exports.isActionCompletedOnSourceTx = isActionCompletedOnSourceTx;
|
|
37566
37767
|
exports.isChainflipBridgeTransaction = isChainflipBridgeTransaction;
|
|
37768
|
+
exports.isChainflipDepositRoute = isChainflipDepositRoute;
|
|
37567
37769
|
exports.isCoralBridgeAction = isCoralBridgeAction;
|
|
37568
37770
|
exports.isCosmosAddressValid = isCosmosAddressValid;
|
|
37569
|
-
exports.
|
|
37771
|
+
exports.isDepositAddressDirectTransferRoute = isDepositAddressDirectTransferRoute;
|
|
37570
37772
|
exports.isEmptyObject = isEmptyObject;
|
|
37571
37773
|
exports.isEvmChainNotSupportedError = isEvmChainNotSupportedError;
|
|
37572
37774
|
exports.isEvmosChain = isEvmosChain;
|
|
@@ -37646,6 +37848,7 @@ exports.useCountryDetails = useCountryDetails;
|
|
|
37646
37848
|
exports.useCurrencyDetails = useCurrencyDetails;
|
|
37647
37849
|
exports.useDebouncedValue = useDebouncedValue;
|
|
37648
37850
|
exports.useDepositAddress = useDepositAddress;
|
|
37851
|
+
exports.useDepositTransactionStatus = useDepositTransactionStatus;
|
|
37649
37852
|
exports.useEnsDataForAddress = useEnsDataForAddress;
|
|
37650
37853
|
exports.useEnsSearch = useEnsSearch;
|
|
37651
37854
|
exports.useEstimate = useEstimate;
|
|
@@ -37712,4 +37915,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
37712
37915
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37713
37916
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37714
37917
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37715
|
-
//# sourceMappingURL=index-
|
|
37918
|
+
//# sourceMappingURL=index-BOyZL5gB.js.map
|