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