event-log-harvester
Advanced tools
Comparing version 0.0.5 to 0.1.0
@@ -1,8 +0,3 @@ | ||
import { Config, EventFiltersRecord, Log } from './types'; | ||
import { Config, EventFiltersRecord, Log, LogDecodedRecord } from './types'; | ||
type LogDecoded<T extends EventFiltersRecord> = Awaited<ReturnType<T[keyof T][number]["decodeLog"]>>; | ||
type LogDecodedRecord<T extends EventFiltersRecord> = { | ||
[K in keyof T]: Array<LogDecoded<T>>; | ||
}; | ||
export declare function fetchAndDecodeLogs<T extends EventFiltersRecord, D extends Log>(getLogs: Config<D, T>["getLogs"], eventFiltersRecord: T, fromBlock: number, toBlock: number, failOnDecodeError?: boolean): Promise<LogDecodedRecord<T>>; | ||
export {}; |
@@ -13,2 +13,2 @@ import { Config, EventFiltersRecord, Log } from './types'; | ||
*/ | ||
export declare function fetchAndDecodeLogsWithRetries<T extends EventFiltersRecord, D extends Log>(getLogs: Config<D, T>["getLogs"], eventFiltersRecord: T, fromBlock: number, toBlock: number, maxRetries: number, failOnDecodeError?: boolean): Promise<{ [K in keyof T]: Awaited<ReturnType<T[keyof T][number]["decodeLog"]>>[]; }>; | ||
export declare function fetchAndDecodeLogsWithRetries<T extends EventFiltersRecord, D extends Log>(getLogs: Config<D, T>["getLogs"], eventFiltersRecord: T, fromBlock: number, toBlock: number, maxRetries: number, failOnDecodeError?: boolean): Promise<import('./types').LogDecodedRecord<T>>; |
export * from './types'; | ||
export { fetchAndDecodeLogsBatch } from './fetchAndDecodeLogsBatch'; | ||
export { harvestLogs } from './harvestLogs.ts'; |
@@ -11,3 +11,3 @@ async function F(i, t, r, s, c) { | ||
k && (o = void 0); | ||
const w = await i({ | ||
const a = (await i({ | ||
fromBlock: r, | ||
@@ -17,5 +17,3 @@ toBlock: s, | ||
topics: e.size > 0 ? Array.from(e) : void 0 | ||
}); | ||
console.log("Raw logs fetched:", w); | ||
const a = w.map(async (f) => { | ||
})).map(async (f) => { | ||
for (const m in t) | ||
@@ -89,7 +87,7 @@ await E( | ||
...Object.values(s).flat().map((a) => a.fromBlock) | ||
), w = Math.max( | ||
), b = Math.max( | ||
...Object.values(s).flat().map((a) => a.toBlock) | ||
); | ||
for (let a = k; a <= w; a += t) { | ||
const f = Math.min(a + t - 1, w), m = L( | ||
for (let a = k; a <= b; a += t) { | ||
const f = Math.min(a + t - 1, b), m = L( | ||
s, | ||
@@ -110,9 +108,9 @@ a, | ||
e[n] || (e[n] = []); | ||
const b = h[n]; | ||
e[n].push(...b); | ||
const g = m[n].map((l) => { | ||
const w = h[n]; | ||
e[n].push(...w); | ||
const y = m[n].map((l) => { | ||
if (l.callback) { | ||
const p = b.filter((u) => { | ||
const y = !l.addresses || l.addresses.includes(u.address), B = l.topics[0] === u.topics[0], v = u.blockNumber >= l.fromBlock && u.blockNumber <= l.toBlock; | ||
return y && B && v; | ||
const p = w.filter((u) => { | ||
const g = !l.addresses || l.addresses.includes(u.address), v = l.topics[0] === u.topics[0], B = u.blockNumber >= l.fromBlock && u.blockNumber <= l.toBlock; | ||
return g && v && B; | ||
}); | ||
@@ -132,3 +130,3 @@ if (p.length > 0) | ||
try { | ||
await Promise.all(g); | ||
await Promise.all(y); | ||
} catch (l) { | ||
@@ -144,3 +142,3 @@ if (console.error(`Error in callback for filter ${n}:`, l), o) | ||
export { | ||
M as fetchAndDecodeLogsBatch | ||
M as harvestLogs | ||
}; |
@@ -34,1 +34,5 @@ export type Log = { | ||
export type EventFiltersRecord = Record<string, EventFilter<any>[]>; | ||
export type LogDecoded<T extends EventFiltersRecord> = Awaited<ReturnType<T[keyof T][number]["decodeLog"]>>; | ||
export type LogDecodedRecord<T extends EventFiltersRecord> = { | ||
[K in keyof T]: Array<LogDecoded<T>>; | ||
}; |
{ | ||
"name": "event-log-harvester", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14879
217