Skip to main content
Version: Next

Class: BatchClient

Constructors​

constructor​

• new BatchClient(options): BatchClient

Parameters​

NameType
optionsBatchClientOptions

Returns​

BatchClient

Defined in​

src/utils/batch/index.ts:30

Properties​

nodeUrl​

• nodeUrl: string

Defined in​

src/utils/batch/index.ts:12


headers​

• headers: object

Defined in​

src/utils/batch/index.ts:14


interval​

• interval: number

Defined in​

src/utils/batch/index.ts:16


requestId​

• requestId: number = 0

Defined in​

src/utils/batch/index.ts:18


pendingRequests​

• Private pendingRequests: Record<string | number, RequestBody> = {}

Defined in​

src/utils/batch/index.ts:20


batchPromises​

• Private batchPromises: Record<string | number, Promise<ResponseBody[]>> = {}

Defined in​

src/utils/batch/index.ts:22


delayTimer​

• Private Optional delayTimer: Timeout

Defined in​

src/utils/batch/index.ts:24


delayPromise​

• Private Optional delayPromise: Promise<void>

Defined in​

src/utils/batch/index.ts:26


delayPromiseResolve​

• Private Optional delayPromiseResolve: () => void

Type declaration​

â–¸ (): void

Returns​

void

Defined in​

src/utils/batch/index.ts:28

Methods​

wait​

â–¸ wait(): Promise<void>

Returns​

Promise<void>

Defined in​

src/utils/batch/index.ts:36


addPendingRequest​

â–¸ addPendingRequest<T>(method, params?, id?): string | number

Type parameters​

NameType
Textends keyof ReadMethods | keyof WriteMethods | keyof TraceMethods

Parameters​

NameType
methodT
params?Methods[T][``"params"``]
id?string | number

Returns​

string | number

Defined in​

src/utils/batch/index.ts:62


sendBatch​

â–¸ sendBatch(requests): Promise<any>

Parameters​

NameType
requestsRequestBody[]

Returns​

Promise<any>

Defined in​

src/utils/batch/index.ts:79


fetch​

â–¸ fetch<T, TResponse>(method, params?, id?): Promise<TResponse>

Automatically batches and fetches JSON-RPC calls in a single request.

Type parameters​

NameType
Textends keyof ReadMethods | keyof WriteMethods | keyof TraceMethods
TResponseextends Object

Parameters​

NameTypeDescription
methodTMethod to call
params?Methods[T][``"params"``]Method parameters
id?string | numberJSON-RPC Request ID

Returns​

Promise<TResponse>

JSON-RPC Response

Defined in​

src/utils/batch/index.ts:96