import { ContractType as e } from "../../types/ethereum-network.types.mjs";
import { isSolanaLike as t, networkRegistry as n } from "../../constants/chains.constants.mjs";
import { getMerkleAccountPublicKey as r } from "../pre-transaction/solana.mjs";
import { createCustomSolanaConnection as i } from "../utils/create-provider.mjs";
import { getContractWithFetcherByChainId as a } from "../web3/getContractMetadata.mjs";
import { fetchSolanaMerkleTreeRootHash as o } from "../web3/fetchSolanaMerkleTreeRootHash.mjs";
import { Keypair as s, PublicKey as c } from "@solana/web3.js";
import { AnchorProvider as l, Program as u } from "@coral-xyz/anchor";
//#region libs/shared/common/src/functions/snarkjs/fetchOnChainRootHashes.ts
var d = () => {
	let e = s.generate();
	return {
		publicKey: e.publicKey,
		payer: e,
		signTransaction: async (e) => e,
		signAllTransactions: async (e) => e
	};
}, f = async (t) => ({ hinkalRootHash: await a(t, e.HinkalContract).getRootHash() }), p = async (e) => {
	let { contractData: t, fetchRpcUrl: a } = n[e], { hinkalIdl: s, hinkalAddress: f, originalDeployer: p } = t;
	if (!s || !f || !p || !a) throw Error(`Missing Solana configuration for chain ${e}`);
	return { hinkalRootHash: await o(new u(s, new l(i(a), d(), {
		preflightCommitment: "confirmed",
		commitment: "confirmed"
	})), r(new c(f), new c(p))) };
}, m = async (e) => t(e) ? p(e) : f(e);
//#endregion
export { m as fetchOnChainRootHashes };
