@0xsquid/react-hooks 8.0.5 → 8.0.6

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.
@@ -22270,7 +22270,7 @@ const keys = () => ({
22270
22270
  // ============
22271
22271
  // Approval
22272
22272
  // ============
22273
- routeApproved: (routeData, allowanceInWei, approvalType) => [
22273
+ routeApproved: (routeData, allowanceInWei) => [
22274
22274
  ...keys().transactions(),
22275
22275
  QueryKeys.RouteApproved,
22276
22276
  routeData?.params.fromAddress,
@@ -22278,7 +22278,6 @@ const keys = () => ({
22278
22278
  routeData?.params.fromToken,
22279
22279
  routeData?.params.fromAmount,
22280
22280
  allowanceInWei?.toString(),
22281
- approvalType,
22282
22281
  ],
22283
22282
  sendTransactionGas: (chainId, tokenAddress, from) => [
22284
22283
  QueryKeys.All,
@@ -23085,7 +23084,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23085
23084
  };
23086
23085
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
23087
23086
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
23088
- const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-CIyWIixx.js'); });
23087
+ const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-M8SCtgDG.js'); });
23089
23088
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
23090
23089
  };
23091
23090
  function getTokenAssetsKey(token) {
@@ -26261,7 +26260,7 @@ function useStellarWallets() {
26261
26260
  return;
26262
26261
  try {
26263
26262
  const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
26264
- const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-K2_2eYYZ.js'); });
26263
+ const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-CNTH5mSh.js'); });
26265
26264
  const modules = initializeAllModules();
26266
26265
  const promises = modules.map(async (module) => {
26267
26266
  const isAvailable = await module.isAvailable();
@@ -31526,11 +31525,12 @@ var ics20Abi = [
31526
31525
  }
31527
31526
  ];
31528
31527
 
31529
- const useErc20Allowance = ({ tokenAddress, ownerAddress, spenderAddress, amount = BigInt(0), chainId, enabled = true, }) => {
31528
+ const useErc20Allowance = ({ tokenAddress, ownerAddress, spenderAddress, amount = BigInt(0), chainId, transactionType, enabled = true, }) => {
31530
31529
  const parsedTokenAddress = parseEvmAddress(tokenAddress);
31531
31530
  const parsedOwnerAddress = parseEvmAddress(ownerAddress);
31532
31531
  const parsedSpenderAddress = parseEvmAddress(spenderAddress);
31533
31532
  const isNativeToken = parsedTokenAddress?.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
31533
+ const isDepositAddressTx = transactionType === squidTypes.SquidDataType.DepositAddressCalldata;
31534
31534
  const result = wagmi.useReadContract({
31535
31535
  abi: viem.erc20Abi,
31536
31536
  address: parsedTokenAddress ?? undefined,
@@ -31544,17 +31544,16 @@ const useErc20Allowance = ({ tokenAddress, ownerAddress, spenderAddress, amount
31544
31544
  Boolean(parsedTokenAddress &&
31545
31545
  parsedOwnerAddress &&
31546
31546
  parsedSpenderAddress &&
31547
- !isNativeToken),
31547
+ !isNativeToken &&
31548
+ !isDepositAddressTx),
31548
31549
  },
31549
31550
  });
31550
31551
  if (!parsedTokenAddress || !parsedOwnerAddress || !parsedSpenderAddress) {
31551
- return {
31552
- hasAllowance: false,
31553
- error: new Error("Invalid or missing address"),
31554
- };
31552
+ return { hasAllowance: false };
31555
31553
  }
31556
- if (isNativeToken) {
31557
- return { hasAllowance: true, isNativeToken: true };
31554
+ // Native tokens and deposit address transactions don't need approval
31555
+ if (isNativeToken || isDepositAddressTx) {
31556
+ return { hasAllowance: true };
31558
31557
  }
31559
31558
  const allowanceInWei = result.data ?? BigInt(0);
31560
31559
  const hasAllowance = allowanceInWei >= amount;
@@ -31622,26 +31621,8 @@ const useApproval = ({ squidRoute, }) => {
31622
31621
  const isSrcChainEvmos = isEvmosChain(fromChain);
31623
31622
  const isSagaSameChainSwap = isSameChain &&
31624
31623
  fromChain?.chainId.toString() === CHAIN_IDS.SAGA_EVM.toString();
31625
- const approvalType = React.useMemo(() => {
31626
- if (squidRoute?.transactionRequest?.type ===
31627
- squidTypes.SquidDataType.DepositAddressCalldata) {
31628
- // No approvals needed for deposit address calls
31629
- return null;
31630
- }
31631
- if (isSrcChainEvmos && !isSagaSameChainSwap) {
31632
- // Use ICS20 for Evmos chains, except for SagaEVM same-chain swaps
31633
- return "ics20";
31634
- }
31635
- else {
31636
- return "erc20";
31637
- }
31638
- }, [
31639
- isSagaSameChainSwap,
31640
- isSrcChainEvmos,
31641
- squidRoute?.transactionRequest?.type,
31642
- ]);
31643
- const useIcs20 = approvalType === "ics20";
31644
- const useErc20 = approvalType === "erc20";
31624
+ // Use ICS20 for Evmos chains, except for SagaEVM same-chain swaps
31625
+ const useIcs20 = isSrcChainEvmos && !isSagaSameChainSwap;
31645
31626
  const { hasAllowance: hasErc20Allowance, query: erc20AllowanceQuery, allowanceInWei: erc20AllowanceInWei, } = useErc20Allowance({
31646
31627
  tokenAddress: fromToken?.address,
31647
31628
  ownerAddress: sourceUserAddress,
@@ -31649,7 +31630,8 @@ const useApproval = ({ squidRoute, }) => {
31649
31630
  ?.target,
31650
31631
  amount: BigInt(squidRoute?.params.fromAmount ?? "0"),
31651
31632
  chainId: Number(fromChain?.chainId),
31652
- enabled: useErc20,
31633
+ transactionType: squidRoute?.transactionRequest?.type,
31634
+ enabled: !useIcs20,
31653
31635
  });
31654
31636
  const { hasAllowance: hasIcs20Allowance, query: ics20AllowanceQuery, allowanceInWei: ics20AllowanceInWei, } = useIcs20Allowance({
31655
31637
  ownerAddress: sourceUserAddress,
@@ -31668,10 +31650,7 @@ const useApproval = ({ squidRoute, }) => {
31668
31650
  * On Error: Showing the error message if any
31669
31651
  * @returns {boolean} approved
31670
31652
  */
31671
- const routeApproved = reactQuery.useQuery(keys().routeApproved(squidRoute, allowanceInWei, approvalType), async () => {
31672
- if (approvalType === null) {
31673
- return true;
31674
- }
31653
+ const routeApproved = reactQuery.useQuery(keys().routeApproved(squidRoute, allowanceInWei), async () => {
31675
31654
  // Approval is only needed for EVM chains
31676
31655
  if (getChainType(squidRoute?.params.fromChain) === squidTypes.ChainType.EVM) {
31677
31656
  return hasAllowance;
@@ -31680,8 +31659,8 @@ const useApproval = ({ squidRoute, }) => {
31680
31659
  }, {
31681
31660
  enabled: !!squidRoute &&
31682
31661
  !!sourceUserAddress &&
31683
- ((!allowanceQuery?.isLoading && allowanceQuery?.isFetched) ||
31684
- approvalType === null),
31662
+ !allowanceQuery?.isLoading &&
31663
+ allowanceQuery?.isFetched,
31685
31664
  });
31686
31665
  // USDT has a very specific way of handling approvals
31687
31666
  // ```
@@ -31771,9 +31750,6 @@ const useApproval = ({ squidRoute, }) => {
31771
31750
  */
31772
31751
  const approveRoute = reactQuery.useMutation(async () => {
31773
31752
  try {
31774
- if (approvalType === null) {
31775
- return true;
31776
- }
31777
31753
  if (fromToken?.address === nativeEvmTokenAddress) {
31778
31754
  return true;
31779
31755
  }
@@ -36676,4 +36652,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
36676
36652
  exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
36677
36653
  exports.walletIconBaseUrl = walletIconBaseUrl;
36678
36654
  exports.walletSupportsChainType = walletSupportsChainType;
36679
- //# sourceMappingURL=index-fCnKL8wD.js.map
36655
+ //# sourceMappingURL=index-C23cJ6Ws.js.map