export function getValueFromLogs(args) {
    const relevantLogs = getValuesFromLogs(args);
    if (!relevantLogs || relevantLogs.length === 0) {
        return null;
    }
    return relevantLogs[0];
}
export function getValuesFromLogs(args) {
    const parsedLogs = args.logs
        .map((log) => {
        try {
            return args.iface.parseLog(log);
        }
        catch (error) {
            // assume that failing to parse is irrelevant log
            return null;
        }
    })
        .filter((log) => log !== null);
    const relevantLogs = parsedLogs.filter((log) => log.name === args.eventName);
    if (relevantLogs.length === 0) {
        return null;
    }
    return relevantLogs.map((relevantLog) => relevantLog.args[args.eventArgsKey]);
}
export function getValuesFromLogsExt(args) {
    const parsedLogs = args.logs
        .map((log) => {
        try {
            return args.iface.parseLog(log);
        }
        catch (error) {
            // assume that failing to parse is irrelevant log
            return null;
        }
    })
        .filter((log) => log !== null);
    const relevantLogs = parsedLogs.filter((log) => args.eventNames.includes(log.name));
    if (relevantLogs.length === 0) {
        return null;
    }
    const ret = {};
    for (const eventArgsKey of args.eventArgsKeys) {
        ret[eventArgsKey] = relevantLogs.map((relevantLog) => relevantLog.args[eventArgsKey]);
    }
    return ret;
}
//# sourceMappingURL=logs.js.map