import { networkRegistry as e } from "../../constants/chains.constants.mjs";
import { httpClient as t } from "../../data-structures/http/HttpClient.mjs";
import { addressToHexFormat as n, createTronCallData as r } from "./tron.utils.mjs";
//#region libs/shared/common/src/functions/utils/tronSimulation.utils.ts
var i = async (i, a, o, s, c, l, u) => {
	let d = n(a), f = n(l), p = e[i].fetchRpcUrl;
	if (!p) throw Error("missing rpc url for tron simulation");
	let m = r(s, o, c), h = await t.post(p, {
		jsonrpc: "2.0",
		id: 1,
		method: "eth_call",
		params: [{
			from: f,
			to: d,
			data: m,
			value: u ? `0x${(u ?? 0n).toString(16)}` : void 0
		}, "latest"]
	});
	if (h.error) {
		let e = h.error.message || "Unknown revert";
		throw Error(`Tron Transaction Simulation reverted: ${e}`);
	}
};
//#endregion
export { i as simulateTronTransaction };
