import { getUtxosEnclaveCall as e, storeUtxoEnclaveCall as t } from "../../API/enclaveUtxoCalls.mjs";
import { Utxo as n } from "../../data-structures/utxo/Utxo.mjs";
import { makeEnclaveHandshakeAndEncryptInput as r } from "./encryptInputForEnclave.mjs";
import { Logger as i } from "../../error-handling/logger.mjs";
import { deserializeUtxoConstructorParams as a, serializeUtxoConstructorParams as o } from "./serialize-utxos.utils.mjs";
//#region libs/shared/common/src/functions/utils/enclave-utxo-storage.ts
var s = (e) => {
	let t = /* @__PURE__ */ new Set(), r = [];
	for (let i of e) {
		let e = new n(a(i)).getCommitment();
		t.has(e) || (t.add(e), r.push(i));
	}
	return r;
}, c = async (e, n, i, a, s) => {
	let { keyCiphertext: c, inputCiphertext: l } = await r({
		...o(i.getConstructableParams()),
		senderAddress: e,
		...s ? { claimableSignature: s } : {}
	});
	await t(n, l, c, a);
}, l = async (t, n, a, o, c) => {
	try {
		let { keyCiphertext: i, inputCiphertext: l } = await r(n), { utxos: u } = await e(t, l, i, a, o, c);
		return s(u);
	} catch {
		return i.log("failed to fetch utxos from gcp"), [];
	}
};
//#endregion
export { l as getUtxosFromEnclave, c as storeUtxoInEnclave };
