forked from tornado-packages/tornado-core
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 }: {
|
getLatestEvents({ fromBlock }: {
|
||||||
fromBlock: number;
|
fromBlock: number;
|
||||||
}): Promise<BaseEvents<EventType>>;
|
}): Promise<BaseEvents<EventType>>;
|
||||||
validateEvents<S>({ events, lastBlock, hasNewEvents, }: BaseEvents<EventType> & {
|
validateEvents<S>({ events, newEvents, lastBlock, }: BaseEvents<EventType> & {
|
||||||
hasNewEvents?: boolean;
|
newEvents: EventType[];
|
||||||
}): Promise<S>;
|
}): Promise<S>;
|
||||||
/**
|
/**
|
||||||
* Handle saving events
|
* Handle saving events
|
||||||
@ -83,8 +83,8 @@ export declare class BaseTornadoService extends BaseEventsService<DepositsEvents
|
|||||||
constructor(serviceConstructor: BaseTornadoServiceConstructor);
|
constructor(serviceConstructor: BaseTornadoServiceConstructor);
|
||||||
getInstanceName(): string;
|
getInstanceName(): string;
|
||||||
formatEvents(events: EventLog[]): Promise<(DepositsEvents | WithdrawalsEvents)[]>;
|
formatEvents(events: EventLog[]): Promise<(DepositsEvents | WithdrawalsEvents)[]>;
|
||||||
validateEvents<S>({ events, hasNewEvents, }: BaseEvents<DepositsEvents | WithdrawalsEvents> & {
|
validateEvents<S>({ events, newEvents, }: BaseEvents<DepositsEvents | WithdrawalsEvents> & {
|
||||||
hasNewEvents?: boolean;
|
newEvents: (DepositsEvents | WithdrawalsEvents)[];
|
||||||
}): Promise<S>;
|
}): Promise<S>;
|
||||||
getLatestEvents({ fromBlock, }: {
|
getLatestEvents({ fromBlock, }: {
|
||||||
fromBlock: number;
|
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 */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
async validateEvents({
|
async validateEvents({
|
||||||
events,
|
events,
|
||||||
lastBlock,
|
newEvents,
|
||||||
hasNewEvents
|
lastBlock
|
||||||
}) {
|
}) {
|
||||||
return void 0;
|
return void 0;
|
||||||
}
|
}
|
||||||
@ -2244,8 +2244,8 @@ class BaseEventsService {
|
|||||||
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
||||||
const validateResult = await this.validateEvents({
|
const validateResult = await this.validateEvents({
|
||||||
events: allEvents,
|
events: allEvents,
|
||||||
lastBlock,
|
newEvents: newEvents.events,
|
||||||
hasNewEvents: Boolean(newEvents.events.length)
|
lastBlock
|
||||||
});
|
});
|
||||||
if (savedEvents.fromCache || newEvents.events.length) {
|
if (savedEvents.fromCache || newEvents.events.length) {
|
||||||
await this.saveEvents({ events: allEvents, lastBlock });
|
await this.saveEvents({ events: allEvents, lastBlock });
|
||||||
@ -2324,7 +2324,7 @@ class BaseTornadoService extends BaseEventsService {
|
|||||||
}
|
}
|
||||||
async validateEvents({
|
async validateEvents({
|
||||||
events,
|
events,
|
||||||
hasNewEvents
|
newEvents
|
||||||
}) {
|
}) {
|
||||||
if (events.length && this.getType() === "Deposit") {
|
if (events.length && this.getType() === "Deposit") {
|
||||||
const depositEvents = events;
|
const depositEvents = events;
|
||||||
@ -2333,7 +2333,7 @@ class BaseTornadoService extends BaseEventsService {
|
|||||||
const errMsg = `Deposit events invalid wants ${depositEvents.length - 1} leafIndex have ${lastEvent.leafIndex}`;
|
const errMsg = `Deposit events invalid wants ${depositEvents.length - 1} leafIndex have ${lastEvent.leafIndex}`;
|
||||||
throw new Error(errMsg);
|
throw new Error(errMsg);
|
||||||
}
|
}
|
||||||
if (this.merkleTreeService && (!this.optionalTree || hasNewEvents)) {
|
if (this.merkleTreeService && (!this.optionalTree || newEvents.length)) {
|
||||||
return await this.merkleTreeService.verifyTree(depositEvents);
|
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 */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
async validateEvents({
|
async validateEvents({
|
||||||
events,
|
events,
|
||||||
lastBlock,
|
newEvents,
|
||||||
hasNewEvents
|
lastBlock
|
||||||
}) {
|
}) {
|
||||||
return void 0;
|
return void 0;
|
||||||
}
|
}
|
||||||
@ -2222,8 +2222,8 @@ class BaseEventsService {
|
|||||||
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
||||||
const validateResult = await this.validateEvents({
|
const validateResult = await this.validateEvents({
|
||||||
events: allEvents,
|
events: allEvents,
|
||||||
lastBlock,
|
newEvents: newEvents.events,
|
||||||
hasNewEvents: Boolean(newEvents.events.length)
|
lastBlock
|
||||||
});
|
});
|
||||||
if (savedEvents.fromCache || newEvents.events.length) {
|
if (savedEvents.fromCache || newEvents.events.length) {
|
||||||
await this.saveEvents({ events: allEvents, lastBlock });
|
await this.saveEvents({ events: allEvents, lastBlock });
|
||||||
@ -2302,7 +2302,7 @@ class BaseTornadoService extends BaseEventsService {
|
|||||||
}
|
}
|
||||||
async validateEvents({
|
async validateEvents({
|
||||||
events,
|
events,
|
||||||
hasNewEvents
|
newEvents
|
||||||
}) {
|
}) {
|
||||||
if (events.length && this.getType() === "Deposit") {
|
if (events.length && this.getType() === "Deposit") {
|
||||||
const depositEvents = events;
|
const depositEvents = events;
|
||||||
@ -2311,7 +2311,7 @@ class BaseTornadoService extends BaseEventsService {
|
|||||||
const errMsg = `Deposit events invalid wants ${depositEvents.length - 1} leafIndex have ${lastEvent.leafIndex}`;
|
const errMsg = `Deposit events invalid wants ${depositEvents.length - 1} leafIndex have ${lastEvent.leafIndex}`;
|
||||||
throw new Error(errMsg);
|
throw new Error(errMsg);
|
||||||
}
|
}
|
||||||
if (this.merkleTreeService && (!this.optionalTree || hasNewEvents)) {
|
if (this.merkleTreeService && (!this.optionalTree || newEvents.length)) {
|
||||||
return await this.merkleTreeService.verifyTree(depositEvents);
|
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 */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
async validateEvents({
|
async validateEvents({
|
||||||
events,
|
events,
|
||||||
lastBlock,
|
newEvents,
|
||||||
hasNewEvents
|
lastBlock
|
||||||
}) {
|
}) {
|
||||||
return void 0;
|
return void 0;
|
||||||
}
|
}
|
||||||
@ -90531,8 +90531,8 @@ class BaseEventsService {
|
|||||||
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
||||||
const validateResult = await this.validateEvents({
|
const validateResult = await this.validateEvents({
|
||||||
events: allEvents,
|
events: allEvents,
|
||||||
lastBlock,
|
newEvents: newEvents.events,
|
||||||
hasNewEvents: Boolean(newEvents.events.length)
|
lastBlock
|
||||||
});
|
});
|
||||||
if (savedEvents.fromCache || newEvents.events.length) {
|
if (savedEvents.fromCache || newEvents.events.length) {
|
||||||
await this.saveEvents({ events: allEvents, lastBlock });
|
await this.saveEvents({ events: allEvents, lastBlock });
|
||||||
@ -90611,7 +90611,7 @@ class BaseTornadoService extends BaseEventsService {
|
|||||||
}
|
}
|
||||||
async validateEvents({
|
async validateEvents({
|
||||||
events,
|
events,
|
||||||
hasNewEvents
|
newEvents
|
||||||
}) {
|
}) {
|
||||||
if (events.length && this.getType() === "Deposit") {
|
if (events.length && this.getType() === "Deposit") {
|
||||||
const depositEvents = events;
|
const depositEvents = events;
|
||||||
@ -90620,7 +90620,7 @@ class BaseTornadoService extends BaseEventsService {
|
|||||||
const errMsg = `Deposit events invalid wants ${depositEvents.length - 1} leafIndex have ${lastEvent.leafIndex}`;
|
const errMsg = `Deposit events invalid wants ${depositEvents.length - 1} leafIndex have ${lastEvent.leafIndex}`;
|
||||||
throw new Error(errMsg);
|
throw new Error(errMsg);
|
||||||
}
|
}
|
||||||
if (this.merkleTreeService && (!this.optionalTree || hasNewEvents)) {
|
if (this.merkleTreeService && (!this.optionalTree || newEvents.length)) {
|
||||||
return await this.merkleTreeService.verifyTree(depositEvents);
|
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 */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
async validateEvents<S>({
|
async validateEvents<S>({
|
||||||
events,
|
events,
|
||||||
|
newEvents,
|
||||||
lastBlock,
|
lastBlock,
|
||||||
hasNewEvents,
|
}: BaseEvents<EventType> & { newEvents: EventType[] }): Promise<S> {
|
||||||
}: BaseEvents<EventType> & { hasNewEvents?: boolean }): Promise<S> {
|
|
||||||
return undefined as S;
|
return undefined as S;
|
||||||
}
|
}
|
||||||
/* eslint-enable @typescript-eslint/no-unused-vars */
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
||||||
@ -274,8 +274,8 @@ export class BaseEventsService<EventType extends MinimalEvents> {
|
|||||||
|
|
||||||
const validateResult = await this.validateEvents<S>({
|
const validateResult = await this.validateEvents<S>({
|
||||||
events: allEvents,
|
events: allEvents,
|
||||||
|
newEvents: newEvents.events,
|
||||||
lastBlock,
|
lastBlock,
|
||||||
hasNewEvents: Boolean(newEvents.events.length),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// If the events are loaded from cache or we have found new events, save them
|
// 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>({
|
async validateEvents<S>({
|
||||||
events,
|
events,
|
||||||
hasNewEvents,
|
newEvents,
|
||||||
}: BaseEvents<DepositsEvents | WithdrawalsEvents> & {
|
}: BaseEvents<DepositsEvents | WithdrawalsEvents> & {
|
||||||
hasNewEvents?: boolean;
|
newEvents: (DepositsEvents | WithdrawalsEvents)[];
|
||||||
}) {
|
}) {
|
||||||
if (events.length && this.getType() === 'Deposit') {
|
if (events.length && this.getType() === 'Deposit') {
|
||||||
const depositEvents = events as DepositsEvents[];
|
const depositEvents = events as DepositsEvents[];
|
||||||
@ -394,7 +394,7 @@ export class BaseTornadoService extends BaseEventsService<DepositsEvents | Withd
|
|||||||
throw new Error(errMsg);
|
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;
|
return (await this.merkleTreeService.verifyTree(depositEvents)) as S;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user