@0xsquid/react-hooks 8.0.6 → 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.
@@ -64,8 +64,10 @@ export declare const CHAIN_IDS: {
64
64
  readonly GNOSIS: "100";
65
65
  readonly SONIC: "146";
66
66
  readonly HYPER_EVM: "999";
67
+ readonly DCHAIN: "2716446429837000";
67
68
  readonly SONEIUM: "1868";
68
69
  readonly PEAQ: "3338";
70
+ readonly HEDERA: "295";
69
71
  readonly BITCOIN: "bitcoin";
70
72
  readonly SOLANA: "solana-mainnet-beta";
71
73
  readonly SUI: "sui-mainnet";
@@ -34,7 +34,9 @@ export declare enum QueryKeys {
34
34
  XrplAccountActivatedInfo = "xrplAccountActivatedInfo",
35
35
  FiatToCryptoPaymentMethods = "fiatToCryptoPaymentMethods",
36
36
  Stellar = "stellar",
37
- StellarAccountActivatedInfo = "stellarAccountActivatedInfo"
37
+ StellarAccountActivatedInfo = "stellarAccountActivatedInfo",
38
+ Hedera = "hedera",
39
+ IsHederaTokenAssociated = "isHederaTokenAssociated"
38
40
  }
39
41
  export declare const keys: () => {
40
42
  all: QueryKeys;
@@ -45,6 +47,7 @@ export declare const keys: () => {
45
47
  transactions: () => QueryKeys[];
46
48
  xrpl: () => QueryKeys[];
47
49
  stellar: () => QueryKeys[];
50
+ hedera: () => QueryKeys[];
48
51
  coinGeckoPrices: (coingeckoIds?: string[]) => (string | undefined)[];
49
52
  historicalData: (coingeckoId?: string, timeFrame?: Timeframe) => (string | undefined)[];
50
53
  tokensData: (tokens?: TokenWithBalance[]) => (string | undefined)[];
@@ -69,5 +72,6 @@ export declare const keys: () => {
69
72
  isXrplTrustLineApproved: (address: string | undefined, chainId: string | undefined, chainType: ChainType | undefined, tokenAddress: string | undefined, trustLineLimit: string | undefined, amountToApprove: bigint | undefined) => (string | undefined)[];
70
73
  xrplAccountActivatedInfo: (destinationAddress: string | undefined, toChainId: string | undefined, toChainType: ChainType | undefined) => (string | undefined)[];
71
74
  stellarAccountActivatedInfo: (address: string | undefined, chainId: string | undefined, chainType: ChainType | undefined) => (string | undefined)[];
75
+ isHederaTokenAssociated: (address: string | undefined, chainId: string | undefined, chainType: ChainType | undefined, tokenAddress: string | undefined) => (string | undefined)[];
72
76
  };
73
77
  export declare const getPrefixKey: (key: QueryKeys) => QueryKeys[];
@@ -0,0 +1,11 @@
1
+ import { ChainData, Token } from "@0xsquid/squid-types";
2
+ interface Params {
3
+ address: string | undefined;
4
+ token: Token | undefined;
5
+ chain: ChainData | undefined;
6
+ }
7
+ export declare function useHederaTokenAssociations({ address, chain, token }: Params): {
8
+ isTokenAssociated: import("@tanstack/react-query").UseQueryResult<boolean, unknown>;
9
+ associateToken: import("@tanstack/react-query").UseMutationResult<boolean, unknown, void, unknown>;
10
+ };
11
+ export {};
@@ -2,6 +2,7 @@ export { useTrackSearchEmpty } from "./analytics/useTrackSearchEmpty";
2
2
  export { useSquidChains } from "./chains/useSquidChains";
3
3
  export { useClient } from "./client/useClient";
4
4
  export { useCosmosForChain } from "./cosmos/useCosmosForChain";
5
+ export { useHederaTokenAssociations } from "./hedera/useHederaTokenAssociations";
5
6
  export { useKeyboardNavigation } from "./navigation/useKeyboardNavigation";
6
7
  export * from "./onramp/useFiatToCrypto";
7
8
  export { useSquidQueryClient } from "./query/useSquidQueryClient";
@@ -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
  // ============
@@ -22357,6 +22362,17 @@ const keys = () => ({
22357
22362
  chainId,
22358
22363
  chainType,
22359
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
+ ],
22360
22376
  });
22361
22377
  const getPrefixKey = (key) => {
22362
22378
  switch (key) {
@@ -22374,6 +22390,8 @@ const getPrefixKey = (key) => {
22374
22390
  return [...keys().transactions(), key];
22375
22391
  case QueryKeys.XrplTrustLine:
22376
22392
  return [...keys().xrpl(), key];
22393
+ case QueryKeys.IsHederaTokenAssociated:
22394
+ return [...keys().hedera(), key];
22377
22395
  default:
22378
22396
  return [QueryKeys.All, key];
22379
22397
  }
@@ -23067,6 +23085,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23067
23085
  { chainId: CHAIN_IDS.CELO, address: nativeEvmTokenAddress },
23068
23086
  // SagaEVM is gasless, so the native token is not used
23069
23087
  { chainId: CHAIN_IDS.SAGA_EVM, address: nativeEvmTokenAddress },
23088
+ { chainId: CHAIN_IDS.DCHAIN, address: nativeEvmTokenAddress },
23070
23089
  ];
23071
23090
  return (tokens.filter((token) => {
23072
23091
  if (direction) {
@@ -23084,7 +23103,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23084
23103
  };
23085
23104
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
23086
23105
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
23087
- const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-M8SCtgDG.js'); });
23106
+ const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-D7gPw0fs.js'); });
23088
23107
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
23089
23108
  };
23090
23109
  function getTokenAssetsKey(token) {
@@ -24457,6 +24476,13 @@ function getSuggestedAmountsForCurrency(currencyCode) {
24457
24476
  return amounts.map(adaptiveRound);
24458
24477
  }
24459
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
+
24460
24486
  /**
24461
24487
  * Minimum length of a search query to search by address
24462
24488
  * Some tokens can have very short addresses (e.g. "uosmo", "uixo", "satoshi", etc...)
@@ -26260,7 +26286,7 @@ function useStellarWallets() {
26260
26286
  return;
26261
26287
  try {
26262
26288
  const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
26263
- const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-CNTH5mSh.js'); });
26289
+ const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-peMOjG49.js'); });
26264
26290
  const modules = initializeAllModules();
26265
26291
  const promises = modules.map(async (module) => {
26266
26292
  const isAvailable = await module.isAvailable();
@@ -27560,6 +27586,268 @@ function useTrackSearchEmpty({ searchQuery, resultsLength, context, debounceMs =
27560
27586
  }, [context, debounceMs, resultsLength, searchQuery]);
27561
27587
  }
27562
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
+
27563
27851
  const useKeyboardNavigation = ({ onEscape }) => {
27564
27852
  const onKeyDown = React.useCallback((event) => {
27565
27853
  if (event.key === "Escape") {
@@ -27608,6 +27896,7 @@ const chainIdToMulticall3AddressMap = {
27608
27896
  [CHAIN_IDS.SAGA_EVM]: "0x864DDc9B50B9A0dF676d826c9B9EDe9F8913a160",
27609
27897
  [CHAIN_IDS.XRPL_EVM]: "0xaB3a12b26e72F4D6D9B579aCb5027a0918eF1114",
27610
27898
  [CHAIN_IDS.XRPL_EVM_TESTNET]: "0x82Cc144D7d0AD4B1c27cb41420e82b82Ad6e9B31",
27899
+ [CHAIN_IDS.HEDERA]: "0xf21405c87d8538d22607eb9987cd3386121dd5dd",
27611
27900
  };
27612
27901
  /**
27613
27902
  * Returns the multicall3 address for a given chain ID
@@ -29673,12 +29962,20 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
29673
29962
  retry: 2,
29674
29963
  },
29675
29964
  });
29676
- const balance = isNativeToken ? nativeBalance?.value : erc20Balance;
29677
- const isLoading = isNativeToken ? isNativeTokenLoading : isErc20Loading;
29678
- const formattedBalance = balance != null && token?.decimals != null
29679
- ? formatBNToReadable(balance, token.decimals)
29680
- : "0";
29681
- 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
+ };
29682
29979
  };
29683
29980
  const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
29684
29981
  const { isConnected } = useCosmosContext();
@@ -30668,146 +30965,6 @@ async function sendTransactionStellar({ amount, signer, to, token, chain, }) {
30668
30965
  };
30669
30966
  }
30670
30967
 
30671
- const createWagmiConfig = (squidChains) => {
30672
- const filteredEvmChains = squidChains.filter((chain) => chain.chainType === squidTypes.ChainType.EVM);
30673
- if (filteredEvmChains.length === 0) {
30674
- throw new Error("At least one chain is required");
30675
- }
30676
- const wagmiChains = filteredEvmChains.map((chain) => {
30677
- return viem.defineChain({
30678
- id: Number(chain.chainId),
30679
- name: chain.networkName,
30680
- nativeCurrency: {
30681
- name: chain.nativeCurrency.name,
30682
- symbol: chain.nativeCurrency.symbol,
30683
- decimals: chain.nativeCurrency.decimals,
30684
- },
30685
- rpcUrls: {
30686
- public: {
30687
- http: [chain.rpc],
30688
- },
30689
- default: {
30690
- http: [chain.rpc],
30691
- },
30692
- },
30693
- });
30694
- });
30695
- return wagmi.createConfig({
30696
- chains: wagmiChains,
30697
- transports: Object.fromEntries(wagmiChains.map((chain) => [
30698
- chain.id,
30699
- wagmi.http(chain.rpcUrls.public.http[0] ?? ""),
30700
- ])),
30701
- connectors: [
30702
- connectors.injected(),
30703
- connectors.safe({
30704
- allowedDomains: [/app.safe.global$/],
30705
- }),
30706
- connectors.metaMask({
30707
- dappMetadata: {
30708
- name: SQUID_METADATA.name,
30709
- url: SQUID_METADATA.url,
30710
- iconUrl: SQUID_METADATA.icon,
30711
- },
30712
- }),
30713
- connectors.coinbaseWallet({
30714
- appName: SQUID_METADATA.name,
30715
- appLogoUrl: SQUID_METADATA.icon,
30716
- }),
30717
- connectors.walletConnect({
30718
- projectId: WALLETCONNECT_PROJECT_ID,
30719
- metadata: {
30720
- url: SQUID_METADATA.url,
30721
- name: SQUID_METADATA.name,
30722
- icons: [SQUID_METADATA.icon],
30723
- description: SQUID_METADATA.description,
30724
- },
30725
- }),
30726
- ],
30727
- });
30728
- };
30729
- // Taken from wagmi docs
30730
- // https://wagmi.sh/react/guides/ethers
30731
- function clientToSigner(client) {
30732
- const { account, chain, transport } = client;
30733
- if (!account || !chain || !transport) {
30734
- return undefined;
30735
- }
30736
- const network = {
30737
- chainId: chain.id,
30738
- name: chain.name,
30739
- ensAddress: chain.contracts?.ensRegistry?.address,
30740
- };
30741
- const provider = new ethers.BrowserProvider(transport, network);
30742
- const signer = new ethers.JsonRpcSigner(provider, account.address);
30743
- return signer;
30744
- }
30745
-
30746
- function useEvmSigner({ chainId }) {
30747
- const { connector } = wagmi.useAccount();
30748
- const { data: client } = wagmi.useWalletClient({ chainId, connector });
30749
- const signer = React.useMemo(() => (client ? clientToSigner(client) : undefined), [client]);
30750
- return { signer };
30751
- }
30752
- const useSigner = ({ chain }) => {
30753
- const evmChainId = chain?.chainType === squidTypes.ChainType.EVM ? Number(chain.chainId) : undefined;
30754
- // EVM and Cosmos need a different signer for each chain
30755
- // This is not the case for Solana or Bitcoin as there's only one chain in those ecosystems
30756
- const { signer: evmSigner } = useEvmSigner({ chainId: evmChainId });
30757
- const { signer: cosmosSigner } = useCosmosSigner({ chain });
30758
- const { signer: solanaSigner } = useSolanaContext();
30759
- const { signer: bitcoinSigner } = useBitcoinContext();
30760
- const { signer: suiSigner } = useSuiContext();
30761
- const { signer: xrplSigner } = useXrplContext();
30762
- const { signer: stellarSigner } = useStellarContext();
30763
- const isEvmSignerReady = !!evmSigner;
30764
- const isSolanaSignerReady = !!solanaSigner;
30765
- const isCosmosSignerReady = !!cosmosSigner;
30766
- const isBitcoinSignerReady = !!bitcoinSigner;
30767
- const isSuiSignerReady = !!suiSigner;
30768
- const isXrplSignerReady = !!xrplSigner;
30769
- const isStellarSignerReady = !!stellarSigner;
30770
- const isSignerReady = React.useMemo(() => {
30771
- if (!chain?.chainType)
30772
- return false;
30773
- switch (chain.chainType) {
30774
- case squidTypes.ChainType.EVM:
30775
- return isEvmSignerReady;
30776
- case squidTypes.ChainType.COSMOS:
30777
- return isCosmosSignerReady;
30778
- case squidTypes.ChainType.BTC:
30779
- return isBitcoinSignerReady;
30780
- case squidTypes.ChainType.SOLANA:
30781
- return isSolanaSignerReady;
30782
- case squidTypes.ChainType.SUI:
30783
- return isSuiSignerReady;
30784
- case squidTypes.ChainType.XRPL:
30785
- return isXrplSignerReady;
30786
- case squidTypes.ChainType.STELLAR:
30787
- return isStellarSignerReady;
30788
- }
30789
- }, [
30790
- chain?.chainType,
30791
- isEvmSignerReady,
30792
- isCosmosSignerReady,
30793
- isBitcoinSignerReady,
30794
- isSolanaSignerReady,
30795
- isSuiSignerReady,
30796
- isXrplSignerReady,
30797
- isStellarSignerReady,
30798
- ]);
30799
- return {
30800
- isSignerReady,
30801
- evmSigner,
30802
- cosmosSigner,
30803
- bitcoinSigner,
30804
- solanaSigner,
30805
- suiSigner,
30806
- xrplSigner,
30807
- stellarSigner,
30808
- };
30809
- };
30810
-
30811
30968
  function useSendTransaction({ to, amount, token, chain, }) {
30812
30969
  const { connectedWalletsByChainType } = useWallet();
30813
30970
  const { connectedAddress } = useMultiChainWallet(chain);
@@ -36451,6 +36608,8 @@ exports.cleanAmount = cleanAmount;
36451
36608
  exports.compareTransactionIds = compareTransactionIds;
36452
36609
  exports.connectCosmosWallet = connectCosmosWallet;
36453
36610
  exports.connectWallet = connectWallet;
36611
+ exports.convertEvmAddressToHederaAccountId = convertEvmAddressToHederaAccountId;
36612
+ exports.convertHederaAccountIdToEvmAddress = convertHederaAccountIdToEvmAddress;
36454
36613
  exports.convertTokenAmountToUSD = convertTokenAmountToUSD;
36455
36614
  exports.convertUSDToTokenAmount = convertUSDToTokenAmount;
36456
36615
  exports.createQuoteRequestParamsHash = createQuoteRequestParamsHash;
@@ -36612,6 +36771,7 @@ exports.useGetOnrampPaymentTypes = useGetOnrampPaymentTypes;
36612
36771
  exports.useGetRoute = useGetRoute;
36613
36772
  exports.useGetRouteWrapper = useGetRouteWrapper;
36614
36773
  exports.useGnosisContext = useGnosisContext;
36774
+ exports.useHederaTokenAssociations = useHederaTokenAssociations;
36615
36775
  exports.useHistoricalData = useHistoricalData;
36616
36776
  exports.useHistory = useHistory;
36617
36777
  exports.useHistoryStore = useHistoryStore;
@@ -36652,4 +36812,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
36652
36812
  exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
36653
36813
  exports.walletIconBaseUrl = walletIconBaseUrl;
36654
36814
  exports.walletSupportsChainType = walletSupportsChainType;
36655
- //# sourceMappingURL=index-C23cJ6Ws.js.map
36815
+ //# sourceMappingURL=index-C0H64ktj.js.map