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