require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../types/ethereum-network.types.cjs`),n=require(`../pre-transaction/solana.cjs`),r=require(`../utils/create-provider.cjs`),i=require(`../web3/getContractMetadata.cjs`),a=require(`../web3/fetchSolanaMerkleTreeRootHash.cjs`);let o=require(`@coral-xyz/anchor`),s=require(`@solana/web3.js`);var c=()=>{let e=s.Keypair.generate();return{publicKey:e.publicKey,payer:e,signTransaction:async e=>e,signAllTransactions:async e=>e}},l=async e=>{let n=i.getContractWithFetcherByChainId(e,t.ContractType.HinkalContract),r=i.getContractWithFetcherByChainId(e,t.ContractType.AccessTokenContract),[a,o]=await Promise.all([n.getRootHash(),r.getRootHash()]);return{hinkalRootHash:a,accessTokenRootHash:o}},u=async t=>{let{contractData:i,fetchRpcUrl:l}=e.networkRegistry[t],{hinkalIdl:u,hinkalAddress:d,originalDeployer:f}=i;if(!u||!d||!f||!l)throw Error(`Missing Solana configuration for chain ${t}`);let p=new o.Program(u,new o.AnchorProvider(r.createCustomSolanaConnection(l),c(),{preflightCommitment:`confirmed`,commitment:`confirmed`})),m=new s.PublicKey(d),h=new s.PublicKey(f),g=n.getMerkleAccountPublicKey(m,h),_=n.getAccessTokenMerkleAccountPublicKey(m,h),[v,y]=await Promise.all([a.fetchSolanaMerkleTreeRootHash(p,g),a.fetchSolanaMerkleTreeRootHash(p,_)]);return{hinkalRootHash:v,accessTokenRootHash:y}},d=async t=>e.isSolanaLike(t)?u(t):l(t);exports.fetchOnChainRootHashes=d;