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