Change validateEvents params
This commit is contained in:
parent
8644cd3c82
commit
a293e541d9
8
dist/events/base.d.ts
vendored
8
dist/events/base.d.ts
vendored
@ -50,8 +50,8 @@ export declare class BaseEventsService<EventType extends MinimalEvents> {
|
||||
getLatestEvents({ fromBlock }: {
|
||||
fromBlock: number;
|
||||
}): Promise<BaseEvents<EventType>>;
|
||||
validateEvents<S>({ events, lastBlock, hasNewEvents, }: BaseEvents<EventType> & {
|
||||
hasNewEvents?: boolean;
|
||||
validateEvents<S>({ events, newEvents, lastBlock, }: BaseEvents<EventType> & {
|
||||
newEvents: EventType[];
|
||||
}): Promise<S>;
|
||||
/**
|
||||
* Handle saving events
|
||||
@ -83,8 +83,8 @@ export declare class BaseTornadoService extends BaseEventsService<DepositsEvents
|
||||
constructor(serviceConstructor: BaseTornadoServiceConstructor);
|
||||
getInstanceName(): string;
|
||||
formatEvents(events: EventLog[]): Promise<(DepositsEvents | WithdrawalsEvents)[]>;
|
||||
validateEvents<S>({ events, hasNewEvents, }: BaseEvents<DepositsEvents | WithdrawalsEvents> & {
|
||||
hasNewEvents?: boolean;
|
||||
validateEvents<S>({ events, newEvents, }: BaseEvents<DepositsEvents | WithdrawalsEvents> & {
|
||||
newEvents: (DepositsEvents | WithdrawalsEvents)[];
|
||||
}): Promise<S>;
|
||||
getLatestEvents({ fromBlock, }: {
|
||||
fromBlock: number;
|
||||
|
12
dist/index.js
vendored
12
dist/index.js
vendored
@ -2207,8 +2207,8 @@ class BaseEventsService {
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
async validateEvents({
|
||||
events,
|
||||
lastBlock,
|
||||
hasNewEvents
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
return void 0;
|
||||
}
|
||||
@ -2244,8 +2244,8 @@ class BaseEventsService {
|
||||
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
||||
const validateResult = await this.validateEvents({
|
||||
events: allEvents,
|
||||
lastBlock,
|
||||
hasNewEvents: Boolean(newEvents.events.length)
|
||||
newEvents: newEvents.events,
|
||||
lastBlock
|
||||
});
|
||||
if (savedEvents.fromCache || newEvents.events.length) {
|
||||
await this.saveEvents({ events: allEvents, lastBlock });
|
||||
@ -2324,7 +2324,7 @@ class BaseTornadoService extends BaseEventsService {
|
||||
}
|
||||
async validateEvents({
|
||||
events,
|
||||
hasNewEvents
|
||||
newEvents
|
||||
}) {
|
||||
if (events.length && this.getType() === "Deposit") {
|
||||
const depositEvents = events;
|
||||
@ -2333,7 +2333,7 @@ class BaseTornadoService extends BaseEventsService {
|
||||
const errMsg = `Deposit events invalid wants ${depositEvents.length - 1} leafIndex have ${lastEvent.leafIndex}`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
if (this.merkleTreeService && (!this.optionalTree || hasNewEvents)) {
|
||||
if (this.merkleTreeService && (!this.optionalTree || newEvents.length)) {
|
||||
return await this.merkleTreeService.verifyTree(depositEvents);
|
||||
}
|
||||
}
|
||||
|
12
dist/index.mjs
vendored
12
dist/index.mjs
vendored
@ -2185,8 +2185,8 @@ class BaseEventsService {
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
async validateEvents({
|
||||
events,
|
||||
lastBlock,
|
||||
hasNewEvents
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
return void 0;
|
||||
}
|
||||
@ -2222,8 +2222,8 @@ class BaseEventsService {
|
||||
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
||||
const validateResult = await this.validateEvents({
|
||||
events: allEvents,
|
||||
lastBlock,
|
||||
hasNewEvents: Boolean(newEvents.events.length)
|
||||
newEvents: newEvents.events,
|
||||
lastBlock
|
||||
});
|
||||
if (savedEvents.fromCache || newEvents.events.length) {
|
||||
await this.saveEvents({ events: allEvents, lastBlock });
|
||||
@ -2302,7 +2302,7 @@ class BaseTornadoService extends BaseEventsService {
|
||||
}
|
||||
async validateEvents({
|
||||
events,
|
||||
hasNewEvents
|
||||
newEvents
|
||||
}) {
|
||||
if (events.length && this.getType() === "Deposit") {
|
||||
const depositEvents = events;
|
||||
@ -2311,7 +2311,7 @@ class BaseTornadoService extends BaseEventsService {
|
||||
const errMsg = `Deposit events invalid wants ${depositEvents.length - 1} leafIndex have ${lastEvent.leafIndex}`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
if (this.merkleTreeService && (!this.optionalTree || hasNewEvents)) {
|
||||
if (this.merkleTreeService && (!this.optionalTree || newEvents.length)) {
|
||||
return await this.merkleTreeService.verifyTree(depositEvents);
|
||||
}
|
||||
}
|
||||
|
12
dist/tornado.umd.js
vendored
12
dist/tornado.umd.js
vendored
@ -90494,8 +90494,8 @@ class BaseEventsService {
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
async validateEvents({
|
||||
events,
|
||||
lastBlock,
|
||||
hasNewEvents
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
return void 0;
|
||||
}
|
||||
@ -90531,8 +90531,8 @@ class BaseEventsService {
|
||||
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
||||
const validateResult = await this.validateEvents({
|
||||
events: allEvents,
|
||||
lastBlock,
|
||||
hasNewEvents: Boolean(newEvents.events.length)
|
||||
newEvents: newEvents.events,
|
||||
lastBlock
|
||||
});
|
||||
if (savedEvents.fromCache || newEvents.events.length) {
|
||||
await this.saveEvents({ events: allEvents, lastBlock });
|
||||
@ -90611,7 +90611,7 @@ class BaseTornadoService extends BaseEventsService {
|
||||
}
|
||||
async validateEvents({
|
||||
events,
|
||||
hasNewEvents
|
||||
newEvents
|
||||
}) {
|
||||
if (events.length && this.getType() === "Deposit") {
|
||||
const depositEvents = events;
|
||||
@ -90620,7 +90620,7 @@ class BaseTornadoService extends BaseEventsService {
|
||||
const errMsg = `Deposit events invalid wants ${depositEvents.length - 1} leafIndex have ${lastEvent.leafIndex}`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
if (this.merkleTreeService && (!this.optionalTree || hasNewEvents)) {
|
||||
if (this.merkleTreeService && (!this.optionalTree || newEvents.length)) {
|
||||
return await this.merkleTreeService.verifyTree(depositEvents);
|
||||
}
|
||||
}
|
||||
|
2
dist/tornado.umd.min.js
vendored
2
dist/tornado.umd.min.js
vendored
File diff suppressed because one or more lines are too long
@ -225,9 +225,9 @@ export class BaseEventsService<EventType extends MinimalEvents> {
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
async validateEvents<S>({
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock,
|
||||
hasNewEvents,
|
||||
}: BaseEvents<EventType> & { hasNewEvents?: boolean }): Promise<S> {
|
||||
}: BaseEvents<EventType> & { newEvents: EventType[] }): Promise<S> {
|
||||
return undefined as S;
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/no-unused-vars */
|
||||
@ -274,8 +274,8 @@ export class BaseEventsService<EventType extends MinimalEvents> {
|
||||
|
||||
const validateResult = await this.validateEvents<S>({
|
||||
events: allEvents,
|
||||
newEvents: newEvents.events,
|
||||
lastBlock,
|
||||
hasNewEvents: Boolean(newEvents.events.length),
|
||||
});
|
||||
|
||||
// If the events are loaded from cache or we have found new events, save them
|
||||
@ -380,9 +380,9 @@ export class BaseTornadoService extends BaseEventsService<DepositsEvents | Withd
|
||||
|
||||
async validateEvents<S>({
|
||||
events,
|
||||
hasNewEvents,
|
||||
newEvents,
|
||||
}: BaseEvents<DepositsEvents | WithdrawalsEvents> & {
|
||||
hasNewEvents?: boolean;
|
||||
newEvents: (DepositsEvents | WithdrawalsEvents)[];
|
||||
}) {
|
||||
if (events.length && this.getType() === 'Deposit') {
|
||||
const depositEvents = events as DepositsEvents[];
|
||||
@ -394,7 +394,7 @@ export class BaseTornadoService extends BaseEventsService<DepositsEvents | Withd
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
if (this.merkleTreeService && (!this.optionalTree || hasNewEvents)) {
|
||||
if (this.merkleTreeService && (!this.optionalTree || newEvents.length)) {
|
||||
return (await this.merkleTreeService.verifyTree(depositEvents)) as S;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user