@0xsquid/react-hooks 8.8.1-beta-canton.2 → 8.8.1-beta-canton.4
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/hooks/store/useDepositAddressStore.d.ts +8 -2
- package/dist/hooks/swap/useDepositAddress.d.ts +4 -3
- package/dist/{index-V9dhUfwW.js → index-D5QOR7JT.js} +52 -28
- package/dist/index-D5QOR7JT.js.map +1 -0
- package/dist/{index-cJsML84P.js → index-mgE1SeE-.js} +53 -28
- package/dist/index-mgE1SeE-.js.map +1 -0
- package/dist/{index.es-DEBBJ-GV.js → index.es-3JPbTFKq.js} +2 -2
- package/dist/{index.es-DEBBJ-GV.js.map → index.es-3JPbTFKq.js.map} +1 -1
- package/dist/{index.es-D9Pry03v.js → index.es-Cq4mUT_n.js} +2 -2
- package/dist/{index.es-D9Pry03v.js.map → index.es-Cq4mUT_n.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/{secretService-Gq4sPaW9.js → secretService-DOOg6zVn.js} +2 -2
- package/dist/{secretService-Gq4sPaW9.js.map → secretService-DOOg6zVn.js.map} +1 -1
- package/dist/{secretService-CX1ATsQ9.js → secretService-DWq78rM5.js} +2 -2
- package/dist/{secretService-CX1ATsQ9.js.map → secretService-DWq78rM5.js.map} +1 -1
- package/dist/services/internal/assetsService.d.ts +10 -1
- package/dist/{stellarService.client-DqVLshhy.js → stellarService.client-C-pOt34O.js} +2 -2
- package/dist/{stellarService.client-DqVLshhy.js.map → stellarService.client-C-pOt34O.js.map} +1 -1
- package/dist/{stellarService.client-CCKxXDnB.js → stellarService.client-DBROJ4yf.js} +2 -2
- package/dist/{stellarService.client-CCKxXDnB.js.map → stellarService.client-DBROJ4yf.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-V9dhUfwW.js.map +0 -1
- package/dist/index-cJsML84P.js.map +0 -1
|
@@ -23375,7 +23375,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23375
23375
|
};
|
|
23376
23376
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23377
23377
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23378
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23378
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-DWq78rM5.js'); });
|
|
23379
23379
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23380
23380
|
};
|
|
23381
23381
|
function getTokenAssetsKey(token) {
|
|
@@ -23402,9 +23402,29 @@ async function fetchAssetsColors() {
|
|
|
23402
23402
|
};
|
|
23403
23403
|
}
|
|
23404
23404
|
}
|
|
23405
|
-
|
|
23406
|
-
|
|
23407
|
-
|
|
23405
|
+
const supportedChainTypes = new Set(Object.values(squidTypes.ChainType));
|
|
23406
|
+
function isSupportedChainType(chainType) {
|
|
23407
|
+
return supportedChainTypes.has(chainType);
|
|
23408
|
+
}
|
|
23409
|
+
/**
|
|
23410
|
+
* Normalizes SDK data after each init/refetch before the rest of hooks consumes it.
|
|
23411
|
+
*
|
|
23412
|
+
* - Removes chains whose chainType is not supported by the local package.
|
|
23413
|
+
* - Drops tokens for those removed chains.
|
|
23414
|
+
* - Converts Evmos chains/tokens to EVM.
|
|
23415
|
+
* - Applies optional asset colors.
|
|
23416
|
+
*/
|
|
23417
|
+
function initializeSquidData(squid, assetsColors = {
|
|
23418
|
+
chains: {},
|
|
23419
|
+
tokens: {},
|
|
23420
|
+
}) {
|
|
23421
|
+
const supportedChains = squid.chains.filter((chain) => isSupportedChainType(chain.chainType));
|
|
23422
|
+
const supportedChainIds = new Set(supportedChains.map((chain) => chain.chainId));
|
|
23423
|
+
const evmosChainIds = supportedChains
|
|
23424
|
+
.filter(isEvmosChain)
|
|
23425
|
+
.map((c) => c.chainId);
|
|
23426
|
+
const supportedTokens = squid.tokens.filter((token) => supportedChainIds.has(token.chainId));
|
|
23427
|
+
squid.tokens = supportedTokens.map((token) => {
|
|
23408
23428
|
const isEvmosToken = evmosChainIds.includes(token.chainId);
|
|
23409
23429
|
return {
|
|
23410
23430
|
...token,
|
|
@@ -23413,7 +23433,7 @@ function initializeSquidWithAssetsColors(squid, assetsColors) {
|
|
|
23413
23433
|
textColor: assetsColors.tokens[getTokenAssetsKey(token)]?.textColor,
|
|
23414
23434
|
};
|
|
23415
23435
|
});
|
|
23416
|
-
squid.chains =
|
|
23436
|
+
squid.chains = supportedChains.map((chain) => {
|
|
23417
23437
|
const bgColor = assetsColors.chains[chain.chainId]?.bgColor;
|
|
23418
23438
|
// convert evmos cosmos chains to evm chains
|
|
23419
23439
|
// TODO: this will be fixed in the backend
|
|
@@ -25290,7 +25310,7 @@ const useSquid = () => {
|
|
|
25290
25310
|
queryFn: async () => {
|
|
25291
25311
|
if (squid) {
|
|
25292
25312
|
await squid?.init();
|
|
25293
|
-
|
|
25313
|
+
initializeSquidData(squid, assetsColors);
|
|
25294
25314
|
return squid;
|
|
25295
25315
|
}
|
|
25296
25316
|
return null;
|
|
@@ -26784,7 +26804,7 @@ function useStellarWallets() {
|
|
|
26784
26804
|
try {
|
|
26785
26805
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26786
26806
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
26787
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
26807
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-DBROJ4yf.js'); });
|
|
26788
26808
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26789
26809
|
const promises = modules.map(async (module) => {
|
|
26790
26810
|
const isAvailable = await module.isAvailable();
|
|
@@ -30134,7 +30154,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30134
30154
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30135
30155
|
if (!optionalChains.length)
|
|
30136
30156
|
return;
|
|
30137
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
30157
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-3JPbTFKq.js'); });
|
|
30138
30158
|
const rawProvider = await EthereumProvider.init({
|
|
30139
30159
|
...restParameters,
|
|
30140
30160
|
disableProviderPing: true,
|
|
@@ -30815,21 +30835,21 @@ const useSendTransactionStore = zustand.create((set, get) => ({
|
|
|
30815
30835
|
|
|
30816
30836
|
const useDepositAddressStore = zustand.create((set) => ({
|
|
30817
30837
|
deposit: null,
|
|
30818
|
-
|
|
30838
|
+
selectedPaymentMethod: "connectedWallet",
|
|
30819
30839
|
setDeposit: (data) => {
|
|
30820
30840
|
set({ deposit: data });
|
|
30821
30841
|
},
|
|
30822
|
-
|
|
30823
|
-
set({
|
|
30842
|
+
setPaymentMethod: (method) => {
|
|
30843
|
+
set({ selectedPaymentMethod: method });
|
|
30824
30844
|
},
|
|
30825
30845
|
}));
|
|
30826
30846
|
|
|
30827
30847
|
function useDepositAddress(squidRoute) {
|
|
30828
|
-
const {
|
|
30829
|
-
|
|
30848
|
+
const { selectedPaymentMethod, depositAddress } = useDepositAddressStore((state) => ({
|
|
30849
|
+
selectedPaymentMethod: state.selectedPaymentMethod,
|
|
30830
30850
|
depositAddress: state.deposit?.depositAddress,
|
|
30831
30851
|
}));
|
|
30832
|
-
const { setDeposit,
|
|
30852
|
+
const { setDeposit, setPaymentMethod, deposit } = useDepositAddressStore();
|
|
30833
30853
|
const { squid } = useSquidStore();
|
|
30834
30854
|
const { fromChain } = useSwap();
|
|
30835
30855
|
const isAvailableAsPaymentMethod = React.useMemo(() => {
|
|
@@ -30846,12 +30866,14 @@ function useDepositAddress(squidRoute) {
|
|
|
30846
30866
|
return (squidRoute?.transactionRequest?.type ===
|
|
30847
30867
|
squidTypes.SquidDataType.ChainflipDepositAddress);
|
|
30848
30868
|
}, [squidRoute?.transactionRequest?.type]);
|
|
30849
|
-
|
|
30850
|
-
|
|
30851
|
-
|
|
30852
|
-
|
|
30853
|
-
|
|
30854
|
-
|
|
30869
|
+
// Effective payment method: the user's intent clamped by what the current
|
|
30870
|
+
// source chain can actually do. Reading this (instead of raw intent) is what
|
|
30871
|
+
// keeps every consumer in sync — if the source chain can't use a deposit
|
|
30872
|
+
// address, the effective method is "connectedWallet" immediately at read time.
|
|
30873
|
+
const paymentMethod = isAvailableAsPaymentMethod
|
|
30874
|
+
? selectedPaymentMethod
|
|
30875
|
+
: "connectedWallet";
|
|
30876
|
+
const isDepositAddressActive = paymentMethod === "depositAddress";
|
|
30855
30877
|
const closeDepositChannel = React.useCallback(() => {
|
|
30856
30878
|
setDeposit(null);
|
|
30857
30879
|
}, [setDeposit]);
|
|
@@ -30883,11 +30905,11 @@ function useDepositAddress(squidRoute) {
|
|
|
30883
30905
|
}
|
|
30884
30906
|
});
|
|
30885
30907
|
return {
|
|
30886
|
-
|
|
30908
|
+
paymentMethod,
|
|
30909
|
+
isDepositAddressActive,
|
|
30887
30910
|
isAvailableAsPaymentMethod,
|
|
30888
30911
|
swapWillGenerateDepositAddress,
|
|
30889
|
-
|
|
30890
|
-
disable,
|
|
30912
|
+
setPaymentMethod,
|
|
30891
30913
|
getRouteWithDeposit,
|
|
30892
30914
|
depositAddress,
|
|
30893
30915
|
closeDepositChannel,
|
|
@@ -36977,7 +36999,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36977
36999
|
const squid = useSquidStore((state) => state.squid);
|
|
36978
37000
|
const fallbackAddress = useSwapRoutePersistStore((store) => store.swapRoute?.fallbackAddress);
|
|
36979
37001
|
const depositRefundAddress = useSwapRoutePersistStore((store) => store.swapRoute?.depositRefundAddress);
|
|
36980
|
-
const {
|
|
37002
|
+
const { isDepositAddressActive } = useDepositAddress();
|
|
36981
37003
|
const getRouteMutation = useGetRoute();
|
|
36982
37004
|
const { fromChain, toChain, fromPrice, destinationAddress: { address: destinationAddress } = {}, fromToken, toToken, } = useSwap();
|
|
36983
37005
|
const { connectedAddress: { address: sourceConnectedAddress }, } = useMultiChainWallet(fromChain);
|
|
@@ -36985,7 +37007,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36985
37007
|
// Tokens will be sent to this address in case of swap failure
|
|
36986
37008
|
//
|
|
36987
37009
|
// If deposit address is not selected, we use the connected address as the source address instead
|
|
36988
|
-
const sourceUserAddress =
|
|
37010
|
+
const sourceUserAddress = isDepositAddressActive
|
|
36989
37011
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
36990
37012
|
: sourceConnectedAddress;
|
|
36991
37013
|
const squidRouteQueryKeys = React.useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromPrice, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChain?.chainType, config.preHook, config.postHook, config.overrideGasRefundAddress), [
|
|
@@ -37572,8 +37594,10 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37572
37594
|
}
|
|
37573
37595
|
if (assetsColorsResponse.status === "fulfilled") {
|
|
37574
37596
|
useAssetsColorsStore.setState(assetsColorsResponse.value);
|
|
37575
|
-
initializeSquidWithAssetsColors(squid, assetsColorsResponse.value);
|
|
37576
37597
|
}
|
|
37598
|
+
initializeSquidData(squid, assetsColorsResponse.status === "fulfilled"
|
|
37599
|
+
? assetsColorsResponse.value
|
|
37600
|
+
: undefined);
|
|
37577
37601
|
const shouldResetSwapRouteStore =
|
|
37578
37602
|
// reset swap route if specified in config
|
|
37579
37603
|
!config?.loadPreviousStateFromLocalStorage ||
|
|
@@ -37762,7 +37786,7 @@ exports.getXummClient = getXummClient;
|
|
|
37762
37786
|
exports.groupTokensByChainId = groupTokensByChainId;
|
|
37763
37787
|
exports.groupTokensBySymbol = groupTokensBySymbol;
|
|
37764
37788
|
exports.handleTransactionErrorEvents = handleTransactionErrorEvents;
|
|
37765
|
-
exports.
|
|
37789
|
+
exports.initializeSquidData = initializeSquidData;
|
|
37766
37790
|
exports.is404Error = is404Error;
|
|
37767
37791
|
exports.isActionCompletedOnSourceTx = isActionCompletedOnSourceTx;
|
|
37768
37792
|
exports.isChainflipBridgeTransaction = isChainflipBridgeTransaction;
|
|
@@ -37785,6 +37809,7 @@ exports.isStatusError = isStatusError;
|
|
|
37785
37809
|
exports.isStellarAddressValid = isStellarAddressValid;
|
|
37786
37810
|
exports.isStellarIssuedToken = isStellarIssuedToken;
|
|
37787
37811
|
exports.isStellarToken = isStellarToken;
|
|
37812
|
+
exports.isSupportedChainType = isSupportedChainType;
|
|
37788
37813
|
exports.isSwapRouteError = isSwapRouteError;
|
|
37789
37814
|
exports.isUserRejectionError = isUserRejectionError;
|
|
37790
37815
|
exports.isValidHorizonAsset = isValidHorizonAsset;
|
|
@@ -37916,4 +37941,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
37916
37941
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37917
37942
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37918
37943
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37919
|
-
//# sourceMappingURL=index-
|
|
37944
|
+
//# sourceMappingURL=index-mgE1SeE-.js.map
|