import { networkRegistry as e } from "../../constants/chains.constants.mjs";
import { contractMetadataMapping as t } from "../../constants/contracts.constants.mjs";
import { transactionErrorCodes as n } from "../../error-handling/error-codes.constants.mjs";
import { addressToHexFormat as r } from "../utils/tron.utils.mjs";
import { createJsonRpcProvider as i } from "../utils/create-provider.mjs";
import { ethers as a } from "ethers";
//#region libs/shared/common/src/functions/web3/getContractMetadata.ts
var o = (r, i) => {
	let a = e[i];
	if (!a) throw Error(n.UNSUPPORTED_NETWORK);
	let o = t[r];
	if (!o) throw Error(`Unsupported contractType: ${r}`);
	return o(a.contractData);
}, s = (e, t, n, i) => {
	let s = o(e, t);
	if (!s.abi) throw Error(`No ABI configured for contractType: ${e}`);
	if (s.address && n) throw Error(`Overriding address is not supported for contractType: ${e}`);
	let c = s.address ?? n;
	if (!c) throw Error(`No contractAddress configured for contractType: ${e}`);
	return new a.Contract(r(c), s.abi, i);
}, c = (e, t, n = void 0) => s(t, e, n, i(e));
//#endregion
export { s as getContract, o as getContractMetadata, c as getContractWithFetcherByChainId };
