import { createJsonRpcProvider as e } from "../../utils/create-provider.mjs";
import "../../utils/index.mjs";
import { ethers as t } from "ethers";
//#region libs/shared/common/src/functions/web3/events/getTransactionLogEvents.ts
var n = (e, n) => {
	let r = new t.Interface(n);
	try {
		let t = r.parseLog(e);
		if (!t) throw Error("Could not parse log");
		return {
			name: t.name,
			args: t.args
		};
	} catch {
		return console.warn("Could not decode log"), null;
	}
};
async function r(t, r, i, a) {
	try {
		let o = await e(t).getTransactionReceipt(r);
		if (!o) throw Error("Transaction receipt not found");
		if (o.status !== 1) throw Error("Transaction failed");
		let s = o.logs.filter((e) => e.address.toLowerCase() === i.toLowerCase()).map((e) => n(e, a)).filter((e) => e !== null);
		return {
			transactionHash: o.hash,
			from: o.from,
			to: o.to,
			blockNumber: o.blockNumber,
			events: s
		};
	} catch (e) {
		throw console.error("Error retrieving transaction events:", e), e;
	}
}
//#endregion
export { r as getTransactionLogEvents };
