@0xsquid/react-hooks 8.0.5 → 8.0.7-hedera-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/core/constants.d.ts +2 -0
  2. package/dist/core/queries/queries-keys.d.ts +6 -3
  3. package/dist/core/types/evm.d.ts +0 -1
  4. package/dist/hooks/hedera/useHederaTokenAssociations.d.ts +11 -0
  5. package/dist/hooks/index.d.ts +1 -0
  6. package/dist/hooks/transaction/useErc20Allowance.d.ts +3 -11
  7. package/dist/{index-fCnKL8wD.js → index-C0H64ktj.js} +326 -190
  8. package/dist/index-C0H64ktj.js.map +1 -0
  9. package/dist/{index-B402hKhN.js → index-DFAgGls6.js} +327 -194
  10. package/dist/index-DFAgGls6.js.map +1 -0
  11. package/dist/index.esm.js +2 -2
  12. package/dist/index.js +5 -2
  13. package/dist/index.js.map +1 -1
  14. package/dist/{secretService-CIyWIixx.js → secretService-D7gPw0fs.js} +3 -3
  15. package/dist/{secretService-CIyWIixx.js.map → secretService-D7gPw0fs.js.map} +1 -1
  16. package/dist/{secretService-CV_qKM-f.js → secretService-DX3NE6Of.js} +3 -3
  17. package/dist/{secretService-CV_qKM-f.js.map → secretService-DX3NE6Of.js.map} +1 -1
  18. package/dist/services/index.d.ts +1 -0
  19. package/dist/services/internal/hederaService.d.ts +2 -0
  20. package/dist/{stellarService.client-BK4en2TV.js → stellarService.client-Cr3lD8Iw.js} +3 -3
  21. package/dist/{stellarService.client-BK4en2TV.js.map → stellarService.client-Cr3lD8Iw.js.map} +1 -1
  22. package/dist/{stellarService.client-K2_2eYYZ.js → stellarService.client-peMOjG49.js} +3 -3
  23. package/dist/{stellarService.client-K2_2eYYZ.js.map → stellarService.client-peMOjG49.js.map} +1 -1
  24. package/package.json +1 -1
  25. package/dist/index-B402hKhN.js.map +0 -1
  26. package/dist/index-fCnKL8wD.js.map +0 -1
@@ -27,11 +27,11 @@ var wagmi = require('wagmi');
27
27
  var SafeAppsSDK = require('@safe-global/safe-apps-sdk');
28
28
  var core$1 = require('@wallet-standard/core');
29
29
  var slushWallet = require('@mysten/slush-wallet');
30
+ var connectors = require('wagmi/connectors');
30
31
  var stargate = require('@cosmjs/stargate');
31
32
  var client = require('@mysten/sui/client');
32
33
  var protoSigning = require('@cosmjs/proto-signing');
33
34
  var transactions = require('@mysten/sui/transactions');
34
- var connectors = require('wagmi/connectors');
35
35
  var cosmwasmStargate = require('@cosmjs/cosmwasm-stargate');
36
36
  var index_js = require('@injectivelabs/sdk-ts/dist/cjs/core/stargate/index.js');
37
37
  var sdk = require('@0xsquid/sdk');
@@ -140,8 +140,10 @@ const CHAIN_IDS = {
140
140
  GNOSIS: "100",
141
141
  SONIC: "146",
142
142
  HYPER_EVM: "999",
143
+ DCHAIN: "2716446429837000",
143
144
  SONEIUM: "1868",
144
145
  PEAQ: "3338",
146
+ HEDERA: "295",
145
147
  // others
146
148
  BITCOIN: "bitcoin",
147
149
  SOLANA: "solana-mainnet-beta",
@@ -22168,6 +22170,8 @@ var QueryKeys;
22168
22170
  QueryKeys["FiatToCryptoPaymentMethods"] = "fiatToCryptoPaymentMethods";
22169
22171
  QueryKeys["Stellar"] = "stellar";
22170
22172
  QueryKeys["StellarAccountActivatedInfo"] = "stellarAccountActivatedInfo";
22173
+ QueryKeys["Hedera"] = "hedera";
22174
+ QueryKeys["IsHederaTokenAssociated"] = "isHederaTokenAssociated";
22171
22175
  })(QueryKeys || (QueryKeys = {}));
22172
22176
  const keys = () => ({
22173
22177
  // ============
@@ -22181,6 +22185,7 @@ const keys = () => ({
22181
22185
  transactions: () => [QueryKeys.All, QueryKeys.Transactions],
22182
22186
  xrpl: () => [QueryKeys.All, QueryKeys.Xrpl],
22183
22187
  stellar: () => [QueryKeys.All, QueryKeys.Stellar],
22188
+ hedera: () => [QueryKeys.All, QueryKeys.Hedera],
22184
22189
  // ============
22185
22190
  // Tokens
22186
22191
  // ============
@@ -22270,7 +22275,7 @@ const keys = () => ({
22270
22275
  // ============
22271
22276
  // Approval
22272
22277
  // ============
22273
- routeApproved: (routeData, allowanceInWei, approvalType) => [
22278
+ routeApproved: (routeData, allowanceInWei) => [
22274
22279
  ...keys().transactions(),
22275
22280
  QueryKeys.RouteApproved,
22276
22281
  routeData?.params.fromAddress,
@@ -22278,7 +22283,6 @@ const keys = () => ({
22278
22283
  routeData?.params.fromToken,
22279
22284
  routeData?.params.fromAmount,
22280
22285
  allowanceInWei?.toString(),
22281
- approvalType,
22282
22286
  ],
22283
22287
  sendTransactionGas: (chainId, tokenAddress, from) => [
22284
22288
  QueryKeys.All,
@@ -22358,6 +22362,17 @@ const keys = () => ({
22358
22362
  chainId,
22359
22363
  chainType,
22360
22364
  ],
22365
+ // ============
22366
+ // Hedera
22367
+ // ============
22368
+ isHederaTokenAssociated: (address, chainId, chainType, tokenAddress) => [
22369
+ ...keys().hedera(),
22370
+ QueryKeys.IsHederaTokenAssociated,
22371
+ address,
22372
+ chainId,
22373
+ chainType,
22374
+ tokenAddress,
22375
+ ],
22361
22376
  });
22362
22377
  const getPrefixKey = (key) => {
22363
22378
  switch (key) {
@@ -22375,6 +22390,8 @@ const getPrefixKey = (key) => {
22375
22390
  return [...keys().transactions(), key];
22376
22391
  case QueryKeys.XrplTrustLine:
22377
22392
  return [...keys().xrpl(), key];
22393
+ case QueryKeys.IsHederaTokenAssociated:
22394
+ return [...keys().hedera(), key];
22378
22395
  default:
22379
22396
  return [QueryKeys.All, key];
22380
22397
  }
@@ -23068,6 +23085,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23068
23085
  { chainId: CHAIN_IDS.CELO, address: nativeEvmTokenAddress },
23069
23086
  // SagaEVM is gasless, so the native token is not used
23070
23087
  { chainId: CHAIN_IDS.SAGA_EVM, address: nativeEvmTokenAddress },
23088
+ { chainId: CHAIN_IDS.DCHAIN, address: nativeEvmTokenAddress },
23071
23089
  ];
23072
23090
  return (tokens.filter((token) => {
23073
23091
  if (direction) {
@@ -23085,7 +23103,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23085
23103
  };
23086
23104
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
23087
23105
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
23088
- const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-CIyWIixx.js'); });
23106
+ const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-D7gPw0fs.js'); });
23089
23107
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
23090
23108
  };
23091
23109
  function getTokenAssetsKey(token) {
@@ -24458,6 +24476,13 @@ function getSuggestedAmountsForCurrency(currencyCode) {
24458
24476
  return amounts.map(adaptiveRound);
24459
24477
  }
24460
24478
 
24479
+ function convertHederaAccountIdToEvmAddress(accId) {
24480
+ return "0x" + Number(accId.split(".").at(-1)).toString(16).padStart(40, "0");
24481
+ }
24482
+ function convertEvmAddressToHederaAccountId(address) {
24483
+ return "0.0." + Number(address);
24484
+ }
24485
+
24461
24486
  /**
24462
24487
  * Minimum length of a search query to search by address
24463
24488
  * Some tokens can have very short addresses (e.g. "uosmo", "uixo", "satoshi", etc...)
@@ -26261,7 +26286,7 @@ function useStellarWallets() {
26261
26286
  return;
26262
26287
  try {
26263
26288
  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'); });
26289
+ const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-peMOjG49.js'); });
26265
26290
  const modules = initializeAllModules();
26266
26291
  const promises = modules.map(async (module) => {
26267
26292
  const isAvailable = await module.isAvailable();
@@ -27561,6 +27586,268 @@ function useTrackSearchEmpty({ searchQuery, resultsLength, context, debounceMs =
27561
27586
  }, [context, debounceMs, resultsLength, searchQuery]);
27562
27587
  }
27563
27588
 
27589
+ const createWagmiConfig = (squidChains) => {
27590
+ const filteredEvmChains = squidChains.filter((chain) => chain.chainType === squidTypes.ChainType.EVM);
27591
+ if (filteredEvmChains.length === 0) {
27592
+ throw new Error("At least one chain is required");
27593
+ }
27594
+ const wagmiChains = filteredEvmChains.map((chain) => {
27595
+ return viem.defineChain({
27596
+ id: Number(chain.chainId),
27597
+ name: chain.networkName,
27598
+ nativeCurrency: {
27599
+ name: chain.nativeCurrency.name,
27600
+ symbol: chain.nativeCurrency.symbol,
27601
+ decimals: chain.nativeCurrency.decimals,
27602
+ },
27603
+ rpcUrls: {
27604
+ public: {
27605
+ http: [chain.rpc],
27606
+ },
27607
+ default: {
27608
+ http: [chain.rpc],
27609
+ },
27610
+ },
27611
+ });
27612
+ });
27613
+ return wagmi.createConfig({
27614
+ chains: wagmiChains,
27615
+ transports: Object.fromEntries(wagmiChains.map((chain) => [
27616
+ chain.id,
27617
+ wagmi.http(chain.rpcUrls.public.http[0] ?? ""),
27618
+ ])),
27619
+ connectors: [
27620
+ connectors.injected(),
27621
+ connectors.safe({
27622
+ allowedDomains: [/app.safe.global$/],
27623
+ }),
27624
+ connectors.metaMask({
27625
+ dappMetadata: {
27626
+ name: SQUID_METADATA.name,
27627
+ url: SQUID_METADATA.url,
27628
+ iconUrl: SQUID_METADATA.icon,
27629
+ },
27630
+ }),
27631
+ connectors.coinbaseWallet({
27632
+ appName: SQUID_METADATA.name,
27633
+ appLogoUrl: SQUID_METADATA.icon,
27634
+ }),
27635
+ connectors.walletConnect({
27636
+ projectId: WALLETCONNECT_PROJECT_ID,
27637
+ metadata: {
27638
+ url: SQUID_METADATA.url,
27639
+ name: SQUID_METADATA.name,
27640
+ icons: [SQUID_METADATA.icon],
27641
+ description: SQUID_METADATA.description,
27642
+ },
27643
+ }),
27644
+ ],
27645
+ });
27646
+ };
27647
+ // Taken from wagmi docs
27648
+ // https://wagmi.sh/react/guides/ethers
27649
+ function clientToSigner(client) {
27650
+ const { account, chain, transport } = client;
27651
+ if (!account || !chain || !transport) {
27652
+ return undefined;
27653
+ }
27654
+ const network = {
27655
+ chainId: chain.id,
27656
+ name: chain.name,
27657
+ ensAddress: chain.contracts?.ensRegistry?.address,
27658
+ };
27659
+ const provider = new ethers.BrowserProvider(transport, network);
27660
+ const signer = new ethers.JsonRpcSigner(provider, account.address);
27661
+ return signer;
27662
+ }
27663
+
27664
+ function useEvmSigner({ chainId }) {
27665
+ const { connector } = wagmi.useAccount();
27666
+ const { data: client } = wagmi.useWalletClient({ chainId, connector });
27667
+ const signer = React.useMemo(() => (client ? clientToSigner(client) : undefined), [client]);
27668
+ return { signer };
27669
+ }
27670
+ const useSigner = ({ chain }) => {
27671
+ const evmChainId = chain?.chainType === squidTypes.ChainType.EVM ? Number(chain.chainId) : undefined;
27672
+ // EVM and Cosmos need a different signer for each chain
27673
+ // This is not the case for Solana or Bitcoin as there's only one chain in those ecosystems
27674
+ const { signer: evmSigner } = useEvmSigner({ chainId: evmChainId });
27675
+ const { signer: cosmosSigner } = useCosmosSigner({ chain });
27676
+ const { signer: solanaSigner } = useSolanaContext();
27677
+ const { signer: bitcoinSigner } = useBitcoinContext();
27678
+ const { signer: suiSigner } = useSuiContext();
27679
+ const { signer: xrplSigner } = useXrplContext();
27680
+ const { signer: stellarSigner } = useStellarContext();
27681
+ const isEvmSignerReady = !!evmSigner;
27682
+ const isSolanaSignerReady = !!solanaSigner;
27683
+ const isCosmosSignerReady = !!cosmosSigner;
27684
+ const isBitcoinSignerReady = !!bitcoinSigner;
27685
+ const isSuiSignerReady = !!suiSigner;
27686
+ const isXrplSignerReady = !!xrplSigner;
27687
+ const isStellarSignerReady = !!stellarSigner;
27688
+ const isSignerReady = React.useMemo(() => {
27689
+ if (!chain?.chainType)
27690
+ return false;
27691
+ switch (chain.chainType) {
27692
+ case squidTypes.ChainType.EVM:
27693
+ return isEvmSignerReady;
27694
+ case squidTypes.ChainType.COSMOS:
27695
+ return isCosmosSignerReady;
27696
+ case squidTypes.ChainType.BTC:
27697
+ return isBitcoinSignerReady;
27698
+ case squidTypes.ChainType.SOLANA:
27699
+ return isSolanaSignerReady;
27700
+ case squidTypes.ChainType.SUI:
27701
+ return isSuiSignerReady;
27702
+ case squidTypes.ChainType.XRPL:
27703
+ return isXrplSignerReady;
27704
+ case squidTypes.ChainType.STELLAR:
27705
+ return isStellarSignerReady;
27706
+ }
27707
+ }, [
27708
+ chain?.chainType,
27709
+ isEvmSignerReady,
27710
+ isCosmosSignerReady,
27711
+ isBitcoinSignerReady,
27712
+ isSolanaSignerReady,
27713
+ isSuiSignerReady,
27714
+ isXrplSignerReady,
27715
+ isStellarSignerReady,
27716
+ ]);
27717
+ return {
27718
+ isSignerReady,
27719
+ evmSigner,
27720
+ cosmosSigner,
27721
+ bitcoinSigner,
27722
+ solanaSigner,
27723
+ suiSigner,
27724
+ xrplSigner,
27725
+ stellarSigner,
27726
+ };
27727
+ };
27728
+
27729
+ function useHederaTokenAssociations({ address, chain, token }) {
27730
+ const publicClient = wagmi.usePublicClient({
27731
+ chainId: Number(CHAIN_IDS.HEDERA),
27732
+ });
27733
+ const { evmSigner } = useSigner({ chain });
27734
+ const queryClient = reactQuery.useQueryClient();
27735
+ /**
27736
+ * Creates a token association transaction where the destination account authorizes to receive the given token
27737
+ */
27738
+ const associateToken = reactQuery.useMutation({
27739
+ mutationFn: async () => {
27740
+ try {
27741
+ if (!evmSigner) {
27742
+ throw new Error("EVM signer not found");
27743
+ }
27744
+ if (chain?.chainId !== CHAIN_IDS.HEDERA ||
27745
+ token?.chainId !== CHAIN_IDS.HEDERA) {
27746
+ throw new Error("Chain and token to associate must be on Hedera");
27747
+ }
27748
+ const tokenAddress = parseEvmAddress(token.address);
27749
+ if (!tokenAddress) {
27750
+ throw new Error("Invalid token address");
27751
+ }
27752
+ const userAddress = parseEvmAddress(address);
27753
+ if (!userAddress) {
27754
+ throw new Error("Invalid user address");
27755
+ }
27756
+ const encodedData = viem.encodeFunctionData({
27757
+ abi: [
27758
+ {
27759
+ inputs: [],
27760
+ name: "associate",
27761
+ outputs: [
27762
+ {
27763
+ internalType: "uint256",
27764
+ name: "responseCode",
27765
+ type: "uint256",
27766
+ },
27767
+ ],
27768
+ stateMutability: "nonpayable",
27769
+ type: "function",
27770
+ },
27771
+ ],
27772
+ functionName: "associate",
27773
+ args: [],
27774
+ });
27775
+ const txRes = await evmSigner.sendTransaction({
27776
+ data: encodedData,
27777
+ to: tokenAddress,
27778
+ chainId: chain.chainId,
27779
+ });
27780
+ const receipt = await txRes.wait();
27781
+ if (receipt?.status !== 1) {
27782
+ throw new Error(`Transaction failed with status: ${receipt?.status}`);
27783
+ }
27784
+ return true;
27785
+ }
27786
+ catch (error) {
27787
+ console.error("Error associating Hedera token:", error);
27788
+ return false;
27789
+ }
27790
+ },
27791
+ async onSuccess() {
27792
+ queryClient.refetchQueries({
27793
+ queryKey: getPrefixKey(QueryKeys.IsHederaTokenAssociated),
27794
+ });
27795
+ },
27796
+ });
27797
+ /**
27798
+ * Checks if the destination account has associated the given token.
27799
+ *
27800
+ * Hedera requires accounts to associate a token before being able to receive it.
27801
+ *
27802
+ * Accounts which have max. associations set to -1 can receive any token without previous association
27803
+ */
27804
+ const isTokenAssociated = reactQuery.useQuery({
27805
+ queryKey: keys().isHederaTokenAssociated(address, token?.chainId, token?.type, token?.address),
27806
+ queryFn: async () => {
27807
+ if (token?.chainId !== CHAIN_IDS.HEDERA) {
27808
+ return true;
27809
+ }
27810
+ // The native HBAR token doesn't need an association
27811
+ if (token.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase()) {
27812
+ return true;
27813
+ }
27814
+ if (!publicClient) {
27815
+ throw new Error("Public client not found");
27816
+ }
27817
+ const url = `https://mainnet-public.mirrornode.hedera.com/api/v1/accounts/${address}`;
27818
+ const response = await fetch(url);
27819
+ const data = await response.json();
27820
+ switch (data.max_automatic_token_associations) {
27821
+ case -1: {
27822
+ // Unlimited auto associations
27823
+ return true;
27824
+ }
27825
+ case 0: {
27826
+ // No auto associations, token needs to be associated beforehand
27827
+ const tokenId = convertEvmAddressToHederaAccountId(token.address);
27828
+ return data.balance.tokens.some((t) => t.token_id === tokenId);
27829
+ }
27830
+ default: {
27831
+ // Limited auto associations, check if there is an available slot
27832
+ const url2 = `https://mainnet-public.mirrornode.hedera.com/api/v1/accounts/${address}/tokens`;
27833
+ const response2 = await fetch(url2);
27834
+ const data2 = await response2.json();
27835
+ if (!data2.tokens)
27836
+ return false;
27837
+ const autoAssociatedTokens = data2.tokens.filter((t) => t.automatic_association);
27838
+ const remainingAutoAssociations = data.max_automatic_token_associations - autoAssociatedTokens.length;
27839
+ return remainingAutoAssociations > 0;
27840
+ }
27841
+ }
27842
+ },
27843
+ enabled: !!address && !!publicClient && token?.chainId === CHAIN_IDS.HEDERA,
27844
+ });
27845
+ return {
27846
+ isTokenAssociated,
27847
+ associateToken,
27848
+ };
27849
+ }
27850
+
27564
27851
  const useKeyboardNavigation = ({ onEscape }) => {
27565
27852
  const onKeyDown = React.useCallback((event) => {
27566
27853
  if (event.key === "Escape") {
@@ -27609,6 +27896,7 @@ const chainIdToMulticall3AddressMap = {
27609
27896
  [CHAIN_IDS.SAGA_EVM]: "0x864DDc9B50B9A0dF676d826c9B9EDe9F8913a160",
27610
27897
  [CHAIN_IDS.XRPL_EVM]: "0xaB3a12b26e72F4D6D9B579aCb5027a0918eF1114",
27611
27898
  [CHAIN_IDS.XRPL_EVM_TESTNET]: "0x82Cc144D7d0AD4B1c27cb41420e82b82Ad6e9B31",
27899
+ [CHAIN_IDS.HEDERA]: "0xf21405c87d8538d22607eb9987cd3386121dd5dd",
27612
27900
  };
27613
27901
  /**
27614
27902
  * Returns the multicall3 address for a given chain ID
@@ -29674,12 +29962,20 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
29674
29962
  retry: 2,
29675
29963
  },
29676
29964
  });
29677
- const balance = isNativeToken ? nativeBalance?.value : erc20Balance;
29678
- const isLoading = isNativeToken ? isNativeTokenLoading : isErc20Loading;
29679
- const formattedBalance = balance != null && token?.decimals != null
29680
- ? formatBNToReadable(balance, token.decimals)
29681
- : "0";
29682
- return { balance: formattedBalance, isLoading };
29965
+ if (isNativeToken) {
29966
+ return {
29967
+ isLoading: isNativeTokenLoading,
29968
+ balance: nativeBalance
29969
+ ? formatBNToReadable(nativeBalance.value, nativeBalance.decimals)
29970
+ : "0",
29971
+ };
29972
+ }
29973
+ return {
29974
+ balance: erc20Balance && token
29975
+ ? formatBNToReadable(erc20Balance, token.decimals)
29976
+ : "0",
29977
+ isLoading: isErc20Loading,
29978
+ };
29683
29979
  };
29684
29980
  const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
29685
29981
  const { isConnected } = useCosmosContext();
@@ -30669,146 +30965,6 @@ async function sendTransactionStellar({ amount, signer, to, token, chain, }) {
30669
30965
  };
30670
30966
  }
30671
30967
 
30672
- const createWagmiConfig = (squidChains) => {
30673
- const filteredEvmChains = squidChains.filter((chain) => chain.chainType === squidTypes.ChainType.EVM);
30674
- if (filteredEvmChains.length === 0) {
30675
- throw new Error("At least one chain is required");
30676
- }
30677
- const wagmiChains = filteredEvmChains.map((chain) => {
30678
- return viem.defineChain({
30679
- id: Number(chain.chainId),
30680
- name: chain.networkName,
30681
- nativeCurrency: {
30682
- name: chain.nativeCurrency.name,
30683
- symbol: chain.nativeCurrency.symbol,
30684
- decimals: chain.nativeCurrency.decimals,
30685
- },
30686
- rpcUrls: {
30687
- public: {
30688
- http: [chain.rpc],
30689
- },
30690
- default: {
30691
- http: [chain.rpc],
30692
- },
30693
- },
30694
- });
30695
- });
30696
- return wagmi.createConfig({
30697
- chains: wagmiChains,
30698
- transports: Object.fromEntries(wagmiChains.map((chain) => [
30699
- chain.id,
30700
- wagmi.http(chain.rpcUrls.public.http[0] ?? ""),
30701
- ])),
30702
- connectors: [
30703
- connectors.injected(),
30704
- connectors.safe({
30705
- allowedDomains: [/app.safe.global$/],
30706
- }),
30707
- connectors.metaMask({
30708
- dappMetadata: {
30709
- name: SQUID_METADATA.name,
30710
- url: SQUID_METADATA.url,
30711
- iconUrl: SQUID_METADATA.icon,
30712
- },
30713
- }),
30714
- connectors.coinbaseWallet({
30715
- appName: SQUID_METADATA.name,
30716
- appLogoUrl: SQUID_METADATA.icon,
30717
- }),
30718
- connectors.walletConnect({
30719
- projectId: WALLETCONNECT_PROJECT_ID,
30720
- metadata: {
30721
- url: SQUID_METADATA.url,
30722
- name: SQUID_METADATA.name,
30723
- icons: [SQUID_METADATA.icon],
30724
- description: SQUID_METADATA.description,
30725
- },
30726
- }),
30727
- ],
30728
- });
30729
- };
30730
- // Taken from wagmi docs
30731
- // https://wagmi.sh/react/guides/ethers
30732
- function clientToSigner(client) {
30733
- const { account, chain, transport } = client;
30734
- if (!account || !chain || !transport) {
30735
- return undefined;
30736
- }
30737
- const network = {
30738
- chainId: chain.id,
30739
- name: chain.name,
30740
- ensAddress: chain.contracts?.ensRegistry?.address,
30741
- };
30742
- const provider = new ethers.BrowserProvider(transport, network);
30743
- const signer = new ethers.JsonRpcSigner(provider, account.address);
30744
- return signer;
30745
- }
30746
-
30747
- function useEvmSigner({ chainId }) {
30748
- const { connector } = wagmi.useAccount();
30749
- const { data: client } = wagmi.useWalletClient({ chainId, connector });
30750
- const signer = React.useMemo(() => (client ? clientToSigner(client) : undefined), [client]);
30751
- return { signer };
30752
- }
30753
- const useSigner = ({ chain }) => {
30754
- const evmChainId = chain?.chainType === squidTypes.ChainType.EVM ? Number(chain.chainId) : undefined;
30755
- // EVM and Cosmos need a different signer for each chain
30756
- // This is not the case for Solana or Bitcoin as there's only one chain in those ecosystems
30757
- const { signer: evmSigner } = useEvmSigner({ chainId: evmChainId });
30758
- const { signer: cosmosSigner } = useCosmosSigner({ chain });
30759
- const { signer: solanaSigner } = useSolanaContext();
30760
- const { signer: bitcoinSigner } = useBitcoinContext();
30761
- const { signer: suiSigner } = useSuiContext();
30762
- const { signer: xrplSigner } = useXrplContext();
30763
- const { signer: stellarSigner } = useStellarContext();
30764
- const isEvmSignerReady = !!evmSigner;
30765
- const isSolanaSignerReady = !!solanaSigner;
30766
- const isCosmosSignerReady = !!cosmosSigner;
30767
- const isBitcoinSignerReady = !!bitcoinSigner;
30768
- const isSuiSignerReady = !!suiSigner;
30769
- const isXrplSignerReady = !!xrplSigner;
30770
- const isStellarSignerReady = !!stellarSigner;
30771
- const isSignerReady = React.useMemo(() => {
30772
- if (!chain?.chainType)
30773
- return false;
30774
- switch (chain.chainType) {
30775
- case squidTypes.ChainType.EVM:
30776
- return isEvmSignerReady;
30777
- case squidTypes.ChainType.COSMOS:
30778
- return isCosmosSignerReady;
30779
- case squidTypes.ChainType.BTC:
30780
- return isBitcoinSignerReady;
30781
- case squidTypes.ChainType.SOLANA:
30782
- return isSolanaSignerReady;
30783
- case squidTypes.ChainType.SUI:
30784
- return isSuiSignerReady;
30785
- case squidTypes.ChainType.XRPL:
30786
- return isXrplSignerReady;
30787
- case squidTypes.ChainType.STELLAR:
30788
- return isStellarSignerReady;
30789
- }
30790
- }, [
30791
- chain?.chainType,
30792
- isEvmSignerReady,
30793
- isCosmosSignerReady,
30794
- isBitcoinSignerReady,
30795
- isSolanaSignerReady,
30796
- isSuiSignerReady,
30797
- isXrplSignerReady,
30798
- isStellarSignerReady,
30799
- ]);
30800
- return {
30801
- isSignerReady,
30802
- evmSigner,
30803
- cosmosSigner,
30804
- bitcoinSigner,
30805
- solanaSigner,
30806
- suiSigner,
30807
- xrplSigner,
30808
- stellarSigner,
30809
- };
30810
- };
30811
-
30812
30968
  function useSendTransaction({ to, amount, token, chain, }) {
30813
30969
  const { connectedWalletsByChainType } = useWallet();
30814
30970
  const { connectedAddress } = useMultiChainWallet(chain);
@@ -31526,11 +31682,12 @@ var ics20Abi = [
31526
31682
  }
31527
31683
  ];
31528
31684
 
31529
- const useErc20Allowance = ({ tokenAddress, ownerAddress, spenderAddress, amount = BigInt(0), chainId, enabled = true, }) => {
31685
+ const useErc20Allowance = ({ tokenAddress, ownerAddress, spenderAddress, amount = BigInt(0), chainId, transactionType, enabled = true, }) => {
31530
31686
  const parsedTokenAddress = parseEvmAddress(tokenAddress);
31531
31687
  const parsedOwnerAddress = parseEvmAddress(ownerAddress);
31532
31688
  const parsedSpenderAddress = parseEvmAddress(spenderAddress);
31533
31689
  const isNativeToken = parsedTokenAddress?.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
31690
+ const isDepositAddressTx = transactionType === squidTypes.SquidDataType.DepositAddressCalldata;
31534
31691
  const result = wagmi.useReadContract({
31535
31692
  abi: viem.erc20Abi,
31536
31693
  address: parsedTokenAddress ?? undefined,
@@ -31544,17 +31701,16 @@ const useErc20Allowance = ({ tokenAddress, ownerAddress, spenderAddress, amount
31544
31701
  Boolean(parsedTokenAddress &&
31545
31702
  parsedOwnerAddress &&
31546
31703
  parsedSpenderAddress &&
31547
- !isNativeToken),
31704
+ !isNativeToken &&
31705
+ !isDepositAddressTx),
31548
31706
  },
31549
31707
  });
31550
31708
  if (!parsedTokenAddress || !parsedOwnerAddress || !parsedSpenderAddress) {
31551
- return {
31552
- hasAllowance: false,
31553
- error: new Error("Invalid or missing address"),
31554
- };
31709
+ return { hasAllowance: false };
31555
31710
  }
31556
- if (isNativeToken) {
31557
- return { hasAllowance: true, isNativeToken: true };
31711
+ // Native tokens and deposit address transactions don't need approval
31712
+ if (isNativeToken || isDepositAddressTx) {
31713
+ return { hasAllowance: true };
31558
31714
  }
31559
31715
  const allowanceInWei = result.data ?? BigInt(0);
31560
31716
  const hasAllowance = allowanceInWei >= amount;
@@ -31622,26 +31778,8 @@ const useApproval = ({ squidRoute, }) => {
31622
31778
  const isSrcChainEvmos = isEvmosChain(fromChain);
31623
31779
  const isSagaSameChainSwap = isSameChain &&
31624
31780
  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";
31781
+ // Use ICS20 for Evmos chains, except for SagaEVM same-chain swaps
31782
+ const useIcs20 = isSrcChainEvmos && !isSagaSameChainSwap;
31645
31783
  const { hasAllowance: hasErc20Allowance, query: erc20AllowanceQuery, allowanceInWei: erc20AllowanceInWei, } = useErc20Allowance({
31646
31784
  tokenAddress: fromToken?.address,
31647
31785
  ownerAddress: sourceUserAddress,
@@ -31649,7 +31787,8 @@ const useApproval = ({ squidRoute, }) => {
31649
31787
  ?.target,
31650
31788
  amount: BigInt(squidRoute?.params.fromAmount ?? "0"),
31651
31789
  chainId: Number(fromChain?.chainId),
31652
- enabled: useErc20,
31790
+ transactionType: squidRoute?.transactionRequest?.type,
31791
+ enabled: !useIcs20,
31653
31792
  });
31654
31793
  const { hasAllowance: hasIcs20Allowance, query: ics20AllowanceQuery, allowanceInWei: ics20AllowanceInWei, } = useIcs20Allowance({
31655
31794
  ownerAddress: sourceUserAddress,
@@ -31668,10 +31807,7 @@ const useApproval = ({ squidRoute, }) => {
31668
31807
  * On Error: Showing the error message if any
31669
31808
  * @returns {boolean} approved
31670
31809
  */
31671
- const routeApproved = reactQuery.useQuery(keys().routeApproved(squidRoute, allowanceInWei, approvalType), async () => {
31672
- if (approvalType === null) {
31673
- return true;
31674
- }
31810
+ const routeApproved = reactQuery.useQuery(keys().routeApproved(squidRoute, allowanceInWei), async () => {
31675
31811
  // Approval is only needed for EVM chains
31676
31812
  if (getChainType(squidRoute?.params.fromChain) === squidTypes.ChainType.EVM) {
31677
31813
  return hasAllowance;
@@ -31680,8 +31816,8 @@ const useApproval = ({ squidRoute, }) => {
31680
31816
  }, {
31681
31817
  enabled: !!squidRoute &&
31682
31818
  !!sourceUserAddress &&
31683
- ((!allowanceQuery?.isLoading && allowanceQuery?.isFetched) ||
31684
- approvalType === null),
31819
+ !allowanceQuery?.isLoading &&
31820
+ allowanceQuery?.isFetched,
31685
31821
  });
31686
31822
  // USDT has a very specific way of handling approvals
31687
31823
  // ```
@@ -31771,9 +31907,6 @@ const useApproval = ({ squidRoute, }) => {
31771
31907
  */
31772
31908
  const approveRoute = reactQuery.useMutation(async () => {
31773
31909
  try {
31774
- if (approvalType === null) {
31775
- return true;
31776
- }
31777
31910
  if (fromToken?.address === nativeEvmTokenAddress) {
31778
31911
  return true;
31779
31912
  }
@@ -36475,6 +36608,8 @@ exports.cleanAmount = cleanAmount;
36475
36608
  exports.compareTransactionIds = compareTransactionIds;
36476
36609
  exports.connectCosmosWallet = connectCosmosWallet;
36477
36610
  exports.connectWallet = connectWallet;
36611
+ exports.convertEvmAddressToHederaAccountId = convertEvmAddressToHederaAccountId;
36612
+ exports.convertHederaAccountIdToEvmAddress = convertHederaAccountIdToEvmAddress;
36478
36613
  exports.convertTokenAmountToUSD = convertTokenAmountToUSD;
36479
36614
  exports.convertUSDToTokenAmount = convertUSDToTokenAmount;
36480
36615
  exports.createQuoteRequestParamsHash = createQuoteRequestParamsHash;
@@ -36636,6 +36771,7 @@ exports.useGetOnrampPaymentTypes = useGetOnrampPaymentTypes;
36636
36771
  exports.useGetRoute = useGetRoute;
36637
36772
  exports.useGetRouteWrapper = useGetRouteWrapper;
36638
36773
  exports.useGnosisContext = useGnosisContext;
36774
+ exports.useHederaTokenAssociations = useHederaTokenAssociations;
36639
36775
  exports.useHistoricalData = useHistoricalData;
36640
36776
  exports.useHistory = useHistory;
36641
36777
  exports.useHistoryStore = useHistoryStore;
@@ -36676,4 +36812,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
36676
36812
  exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
36677
36813
  exports.walletIconBaseUrl = walletIconBaseUrl;
36678
36814
  exports.walletSupportsChainType = walletSupportsChainType;
36679
- //# sourceMappingURL=index-fCnKL8wD.js.map
36815
+ //# sourceMappingURL=index-C0H64ktj.js.map