Compare commits
2 Commits
b65998fca5
...
a293e541d9
| Author | SHA1 | Date | |
|---|---|---|---|
| a293e541d9 | |||
| 8644cd3c82 |
9
dist/batch.d.ts
vendored
9
dist/batch.d.ts
vendored
@ -60,7 +60,6 @@ export declare class BatchTransactionService {
|
||||
export interface BatchEventServiceConstructor {
|
||||
provider: Provider;
|
||||
contract: BaseContract;
|
||||
address?: string | string[];
|
||||
onProgress?: BatchEventOnProgress;
|
||||
concurrencySize?: number;
|
||||
blocksPerRequest?: number;
|
||||
@ -76,6 +75,7 @@ export type BatchEventOnProgress = ({ percentage, type, fromBlock, toBlock, coun
|
||||
count?: number;
|
||||
}) => void;
|
||||
export interface EventInput {
|
||||
address?: string | string[];
|
||||
fromBlock: number;
|
||||
toBlock: number;
|
||||
type: ContractEventName;
|
||||
@ -86,15 +86,14 @@ export interface EventInput {
|
||||
export declare class BatchEventsService {
|
||||
provider: Provider;
|
||||
contract: BaseContract;
|
||||
address?: string | string[];
|
||||
onProgress?: BatchEventOnProgress;
|
||||
concurrencySize: number;
|
||||
blocksPerRequest: number;
|
||||
shouldRetry: boolean;
|
||||
retryMax: number;
|
||||
retryOn: number;
|
||||
constructor({ provider, contract, address, onProgress, concurrencySize, blocksPerRequest, shouldRetry, retryMax, retryOn, }: BatchEventServiceConstructor);
|
||||
getPastEvents({ fromBlock, toBlock, type }: EventInput): Promise<EventLog[]>;
|
||||
constructor({ provider, contract, onProgress, concurrencySize, blocksPerRequest, shouldRetry, retryMax, retryOn, }: BatchEventServiceConstructor);
|
||||
getPastEvents({ address, fromBlock, toBlock, type }: EventInput): Promise<EventLog[]>;
|
||||
createBatchRequest(batchArray: EventInput[]): Promise<EventLog[]>[];
|
||||
getBatchEvents({ fromBlock, toBlock, type }: EventInput): Promise<EventLog[]>;
|
||||
getBatchEvents({ address, fromBlock, toBlock, type }: EventInput): Promise<EventLog[]>;
|
||||
}
|
||||
|
||||
19
dist/index.js
vendored
19
dist/index.js
vendored
@ -427,7 +427,6 @@ class BatchTransactionService {
|
||||
class BatchEventsService {
|
||||
provider;
|
||||
contract;
|
||||
address;
|
||||
onProgress;
|
||||
concurrencySize;
|
||||
blocksPerRequest;
|
||||
@ -437,7 +436,6 @@ class BatchEventsService {
|
||||
constructor({
|
||||
provider,
|
||||
contract,
|
||||
address,
|
||||
onProgress,
|
||||
concurrencySize = 10,
|
||||
blocksPerRequest = 5e3,
|
||||
@ -447,7 +445,6 @@ class BatchEventsService {
|
||||
}) {
|
||||
this.provider = provider;
|
||||
this.contract = contract;
|
||||
this.address = address;
|
||||
this.onProgress = onProgress;
|
||||
this.concurrencySize = concurrencySize;
|
||||
this.blocksPerRequest = blocksPerRequest;
|
||||
@ -455,19 +452,13 @@ class BatchEventsService {
|
||||
this.retryMax = retryMax;
|
||||
this.retryOn = retryOn;
|
||||
}
|
||||
async getPastEvents({ fromBlock, toBlock, type }) {
|
||||
async getPastEvents({ address, fromBlock, toBlock, type }) {
|
||||
let err;
|
||||
let retries = 0;
|
||||
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
||||
try {
|
||||
if (this.address) {
|
||||
return await multiQueryFilter(
|
||||
this.address,
|
||||
this.contract,
|
||||
type,
|
||||
fromBlock,
|
||||
toBlock
|
||||
);
|
||||
if (address) {
|
||||
return await multiQueryFilter(address, this.contract, type, fromBlock, toBlock);
|
||||
}
|
||||
return await this.contract.queryFilter(type, fromBlock, toBlock);
|
||||
} catch (e) {
|
||||
@ -488,14 +479,14 @@ class BatchEventsService {
|
||||
return this.getPastEvents(event);
|
||||
});
|
||||
}
|
||||
async getBatchEvents({ fromBlock, toBlock, type = "*" }) {
|
||||
async getBatchEvents({ address, fromBlock, toBlock, type = "*" }) {
|
||||
if (!toBlock) {
|
||||
toBlock = await this.provider.getBlockNumber();
|
||||
}
|
||||
const eventsToSync = [];
|
||||
for (let i = fromBlock; i < toBlock; i += this.blocksPerRequest) {
|
||||
const j = i + this.blocksPerRequest - 1 > toBlock ? toBlock : i + this.blocksPerRequest - 1;
|
||||
eventsToSync.push({ fromBlock: i, toBlock: j, type });
|
||||
eventsToSync.push({ address, fromBlock: i, toBlock: j, type });
|
||||
}
|
||||
const events = [];
|
||||
const eventChunk = chunk(eventsToSync, this.concurrencySize);
|
||||
|
||||
19
dist/index.mjs
vendored
19
dist/index.mjs
vendored
@ -405,7 +405,6 @@ class BatchTransactionService {
|
||||
class BatchEventsService {
|
||||
provider;
|
||||
contract;
|
||||
address;
|
||||
onProgress;
|
||||
concurrencySize;
|
||||
blocksPerRequest;
|
||||
@ -415,7 +414,6 @@ class BatchEventsService {
|
||||
constructor({
|
||||
provider,
|
||||
contract,
|
||||
address,
|
||||
onProgress,
|
||||
concurrencySize = 10,
|
||||
blocksPerRequest = 5e3,
|
||||
@ -425,7 +423,6 @@ class BatchEventsService {
|
||||
}) {
|
||||
this.provider = provider;
|
||||
this.contract = contract;
|
||||
this.address = address;
|
||||
this.onProgress = onProgress;
|
||||
this.concurrencySize = concurrencySize;
|
||||
this.blocksPerRequest = blocksPerRequest;
|
||||
@ -433,19 +430,13 @@ class BatchEventsService {
|
||||
this.retryMax = retryMax;
|
||||
this.retryOn = retryOn;
|
||||
}
|
||||
async getPastEvents({ fromBlock, toBlock, type }) {
|
||||
async getPastEvents({ address, fromBlock, toBlock, type }) {
|
||||
let err;
|
||||
let retries = 0;
|
||||
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
||||
try {
|
||||
if (this.address) {
|
||||
return await multiQueryFilter(
|
||||
this.address,
|
||||
this.contract,
|
||||
type,
|
||||
fromBlock,
|
||||
toBlock
|
||||
);
|
||||
if (address) {
|
||||
return await multiQueryFilter(address, this.contract, type, fromBlock, toBlock);
|
||||
}
|
||||
return await this.contract.queryFilter(type, fromBlock, toBlock);
|
||||
} catch (e) {
|
||||
@ -466,14 +457,14 @@ class BatchEventsService {
|
||||
return this.getPastEvents(event);
|
||||
});
|
||||
}
|
||||
async getBatchEvents({ fromBlock, toBlock, type = "*" }) {
|
||||
async getBatchEvents({ address, fromBlock, toBlock, type = "*" }) {
|
||||
if (!toBlock) {
|
||||
toBlock = await this.provider.getBlockNumber();
|
||||
}
|
||||
const eventsToSync = [];
|
||||
for (let i = fromBlock; i < toBlock; i += this.blocksPerRequest) {
|
||||
const j = i + this.blocksPerRequest - 1 > toBlock ? toBlock : i + this.blocksPerRequest - 1;
|
||||
eventsToSync.push({ fromBlock: i, toBlock: j, type });
|
||||
eventsToSync.push({ address, fromBlock: i, toBlock: j, type });
|
||||
}
|
||||
const events = [];
|
||||
const eventChunk = chunk(eventsToSync, this.concurrencySize);
|
||||
|
||||
19
dist/tornado.umd.js
vendored
19
dist/tornado.umd.js
vendored
@ -60255,7 +60255,6 @@ class BatchTransactionService {
|
||||
class BatchEventsService {
|
||||
provider;
|
||||
contract;
|
||||
address;
|
||||
onProgress;
|
||||
concurrencySize;
|
||||
blocksPerRequest;
|
||||
@ -60265,7 +60264,6 @@ class BatchEventsService {
|
||||
constructor({
|
||||
provider,
|
||||
contract,
|
||||
address,
|
||||
onProgress,
|
||||
concurrencySize = 10,
|
||||
blocksPerRequest = 5e3,
|
||||
@ -60275,7 +60273,6 @@ class BatchEventsService {
|
||||
}) {
|
||||
this.provider = provider;
|
||||
this.contract = contract;
|
||||
this.address = address;
|
||||
this.onProgress = onProgress;
|
||||
this.concurrencySize = concurrencySize;
|
||||
this.blocksPerRequest = blocksPerRequest;
|
||||
@ -60283,19 +60280,13 @@ class BatchEventsService {
|
||||
this.retryMax = retryMax;
|
||||
this.retryOn = retryOn;
|
||||
}
|
||||
async getPastEvents({ fromBlock, toBlock, type }) {
|
||||
async getPastEvents({ address, fromBlock, toBlock, type }) {
|
||||
let err;
|
||||
let retries = 0;
|
||||
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
||||
try {
|
||||
if (this.address) {
|
||||
return await multiQueryFilter(
|
||||
this.address,
|
||||
this.contract,
|
||||
type,
|
||||
fromBlock,
|
||||
toBlock
|
||||
);
|
||||
if (address) {
|
||||
return await multiQueryFilter(address, this.contract, type, fromBlock, toBlock);
|
||||
}
|
||||
return await this.contract.queryFilter(type, fromBlock, toBlock);
|
||||
} catch (e) {
|
||||
@ -60316,14 +60307,14 @@ class BatchEventsService {
|
||||
return this.getPastEvents(event);
|
||||
});
|
||||
}
|
||||
async getBatchEvents({ fromBlock, toBlock, type = "*" }) {
|
||||
async getBatchEvents({ address, fromBlock, toBlock, type = "*" }) {
|
||||
if (!toBlock) {
|
||||
toBlock = await this.provider.getBlockNumber();
|
||||
}
|
||||
const eventsToSync = [];
|
||||
for (let i = fromBlock; i < toBlock; i += this.blocksPerRequest) {
|
||||
const j = i + this.blocksPerRequest - 1 > toBlock ? toBlock : i + this.blocksPerRequest - 1;
|
||||
eventsToSync.push({ fromBlock: i, toBlock: j, type });
|
||||
eventsToSync.push({ address, fromBlock: i, toBlock: j, type });
|
||||
}
|
||||
const events = [];
|
||||
const eventChunk = (0,_utils__WEBPACK_IMPORTED_MODULE_0__/* .chunk */ .iv)(eventsToSync, this.concurrencySize);
|
||||
|
||||
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
21
src/batch.ts
21
src/batch.ts
@ -422,7 +422,6 @@ export class BatchTransactionService {
|
||||
export interface BatchEventServiceConstructor {
|
||||
provider: Provider;
|
||||
contract: BaseContract;
|
||||
address?: string | string[];
|
||||
onProgress?: BatchEventOnProgress;
|
||||
concurrencySize?: number;
|
||||
blocksPerRequest?: number;
|
||||
@ -447,6 +446,7 @@ export type BatchEventOnProgress = ({
|
||||
|
||||
// To enable iteration only numbers are accepted for fromBlock input
|
||||
export interface EventInput {
|
||||
address?: string | string[];
|
||||
fromBlock: number;
|
||||
toBlock: number;
|
||||
type: ContractEventName;
|
||||
@ -458,7 +458,6 @@ export interface EventInput {
|
||||
export class BatchEventsService {
|
||||
provider: Provider;
|
||||
contract: BaseContract;
|
||||
address?: string | string[];
|
||||
onProgress?: BatchEventOnProgress;
|
||||
concurrencySize: number;
|
||||
blocksPerRequest: number;
|
||||
@ -468,7 +467,6 @@ export class BatchEventsService {
|
||||
constructor({
|
||||
provider,
|
||||
contract,
|
||||
address,
|
||||
onProgress,
|
||||
concurrencySize = 10,
|
||||
blocksPerRequest = 5000,
|
||||
@ -478,7 +476,6 @@ export class BatchEventsService {
|
||||
}: BatchEventServiceConstructor) {
|
||||
this.provider = provider;
|
||||
this.contract = contract;
|
||||
this.address = address;
|
||||
this.onProgress = onProgress;
|
||||
this.concurrencySize = concurrencySize;
|
||||
this.blocksPerRequest = blocksPerRequest;
|
||||
@ -487,21 +484,15 @@ export class BatchEventsService {
|
||||
this.retryOn = retryOn;
|
||||
}
|
||||
|
||||
async getPastEvents({ fromBlock, toBlock, type }: EventInput): Promise<EventLog[]> {
|
||||
async getPastEvents({ address, fromBlock, toBlock, type }: EventInput): Promise<EventLog[]> {
|
||||
let err;
|
||||
let retries = 0;
|
||||
|
||||
// eslint-disable-next-line no-unmodified-loop-condition
|
||||
while ((!this.shouldRetry && retries === 0) || (this.shouldRetry && retries < this.retryMax)) {
|
||||
try {
|
||||
if (this.address) {
|
||||
return (await multiQueryFilter(
|
||||
this.address,
|
||||
this.contract,
|
||||
type,
|
||||
fromBlock,
|
||||
toBlock,
|
||||
)) as EventLog[];
|
||||
if (address) {
|
||||
return (await multiQueryFilter(address, this.contract, type, fromBlock, toBlock)) as EventLog[];
|
||||
}
|
||||
return (await this.contract.queryFilter(type, fromBlock, toBlock)) as EventLog[];
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@ -532,7 +523,7 @@ export class BatchEventsService {
|
||||
});
|
||||
}
|
||||
|
||||
async getBatchEvents({ fromBlock, toBlock, type = '*' }: EventInput): Promise<EventLog[]> {
|
||||
async getBatchEvents({ address, fromBlock, toBlock, type = '*' }: EventInput): Promise<EventLog[]> {
|
||||
if (!toBlock) {
|
||||
toBlock = await this.provider.getBlockNumber();
|
||||
}
|
||||
@ -542,7 +533,7 @@ export class BatchEventsService {
|
||||
for (let i = fromBlock; i < toBlock; i += this.blocksPerRequest) {
|
||||
const j = i + this.blocksPerRequest - 1 > toBlock ? toBlock : i + this.blocksPerRequest - 1;
|
||||
|
||||
eventsToSync.push({ fromBlock: i, toBlock: j, type });
|
||||
eventsToSync.push({ address, fromBlock: i, toBlock: j, type });
|
||||
}
|
||||
|
||||
const events = [];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user