import { RELAYER_CONFIG as e } from "../../../constants/server.constants.mjs";
import { RELAYER_URL as t } from "../../../API/getServerURL.mjs";
import { httpClient as n } from "../../../data-structures/http/HttpClient.mjs";
import { callRelayerSolanaTransactBatchAPI as r, callRelayerTransactAPI as i, callRelayerTransactBatchAPI as a } from "../../../API/callRelayer.mjs";
import { ErrorWithRelayerTransaction as o } from "../../../error-handling/customErrors/ErrorWithTx.mjs";
import { serializeCircomData as s } from "../../snarkjs/common.snarkjs.mjs";
import "../../../error-handling/index.mjs";
import "../../snarkjs/index.mjs";
//#region libs/shared/common/src/functions/web3/functionCalls/transactCallRelayer.ts
var c = (e) => {
	if (e.status === "success") return e.message;
	throw e.message && e.error ? new o(e.error, e.message) : Error(e.error);
}, l = async (e, t, n, r, a, o, l, u, d) => {
	let f = s(r);
	return c(await i({
		chainId: e,
		a: t[0],
		b: t[1],
		c: t[2],
		dimData: n,
		circomData: f,
		withUniswapWorkAround: o,
		authorizationData: l,
		adminData: u,
		tronProofSignature: d,
		commitmentValidationData: a
	}));
}, u = async (r) => c(await n.post(`${t}${e.SOLANA_TRANSACT}`, r)), d = (e) => {
	if (e.status === "success") return e.message.scheduleId;
	throw Error(e.error || "Batch transaction failed");
}, f = async (e, t, n, r, i, o) => {
	let c = t.map((e) => s(e.circomData));
	return d(await a({
		chainId: e,
		transactions: t.map((t, n) => ({
			chainId: e,
			a: t.zkCallData[0],
			b: t.zkCallData[1],
			c: t.zkCallData[2],
			dimData: t.dimData,
			circomData: c[n],
			commitmentValidationData: t.commitmentValidationData,
			withUniswapWorkAround: t.withUniswapWorkAround,
			authorizationData: t.authorizationData,
			adminData: t.adminData,
			recipientAddress: t.recipientAddress,
			tronProofSignature: t.tronProofSignature
		})),
		txCompletionTime: r,
		hashedEthereumAddress: n,
		ref: i,
		hashedDashboardAccountId: o
	}));
}, p = async (e, t, n, i, a, o) => d(await r({
	chainId: e,
	transactions: t,
	hashedEthereumAddress: n,
	txCompletionTime: i,
	ref: a,
	hashedDashboardAccountId: o
}));
//#endregion
export { u as solanaTransactCallRelayer, p as solanaTransactCallRelayerBatch, l as transactCallRelayer, f as transactCallRelayerBatch };
