|
| 1 | +--- |
| 2 | +id: 'BatchClient' |
| 3 | +title: 'Class: BatchClient' |
| 4 | +sidebar_label: 'BatchClient' |
| 5 | +sidebar_position: 0 |
| 6 | +custom_edit_url: null |
| 7 | +--- |
| 8 | + |
| 9 | +## Constructors |
| 10 | + |
| 11 | +### constructor |
| 12 | + |
| 13 | +• **new BatchClient**(`options`): [`BatchClient`](BatchClient.md) |
| 14 | + |
| 15 | +#### Parameters |
| 16 | + |
| 17 | +| Name | Type | |
| 18 | +| :-------- | :------------------------------------------------------- | |
| 19 | +| `options` | [`BatchClientOptions`](../modules.md#batchclientoptions) | |
| 20 | + |
| 21 | +#### Returns |
| 22 | + |
| 23 | +[`BatchClient`](BatchClient.md) |
| 24 | + |
| 25 | +#### Defined in |
| 26 | + |
| 27 | +[src/utils/batch/index.ts:33](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L33) |
| 28 | + |
| 29 | +## Properties |
| 30 | + |
| 31 | +### nodeUrl |
| 32 | + |
| 33 | +• **nodeUrl**: `string` |
| 34 | + |
| 35 | +#### Defined in |
| 36 | + |
| 37 | +[src/utils/batch/index.ts:13](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L13) |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +### headers |
| 42 | + |
| 43 | +• **headers**: `object` |
| 44 | + |
| 45 | +#### Defined in |
| 46 | + |
| 47 | +[src/utils/batch/index.ts:15](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L15) |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +### interval |
| 52 | + |
| 53 | +• **interval**: `number` |
| 54 | + |
| 55 | +#### Defined in |
| 56 | + |
| 57 | +[src/utils/batch/index.ts:17](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L17) |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +### requestId |
| 62 | + |
| 63 | +• **requestId**: `number` = `0` |
| 64 | + |
| 65 | +#### Defined in |
| 66 | + |
| 67 | +[src/utils/batch/index.ts:19](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L19) |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +### pendingRequests |
| 72 | + |
| 73 | +• `Private` **pendingRequests**: `Record`<`string` \| `number`, [`RequestBody`](../namespaces/types.RPC.JRPC.md#requestbody)\> = `{}` |
| 74 | + |
| 75 | +#### Defined in |
| 76 | + |
| 77 | +[src/utils/batch/index.ts:21](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L21) |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +### batchPromises |
| 82 | + |
| 83 | +• `Private` **batchPromises**: `Record`<`string` \| `number`, `Promise`<[`ResponseBody`](../namespaces/types.RPC.JRPC.md#responsebody)[]\>\> = `{}` |
| 84 | + |
| 85 | +#### Defined in |
| 86 | + |
| 87 | +[src/utils/batch/index.ts:23](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L23) |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +### delayTimer |
| 92 | + |
| 93 | +• `Private` `Optional` **delayTimer**: `Timeout` |
| 94 | + |
| 95 | +#### Defined in |
| 96 | + |
| 97 | +[src/utils/batch/index.ts:25](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L25) |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +### delayPromise |
| 102 | + |
| 103 | +• `Private` `Optional` **delayPromise**: `Promise`<`void`\> |
| 104 | + |
| 105 | +#### Defined in |
| 106 | + |
| 107 | +[src/utils/batch/index.ts:27](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L27) |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +### delayPromiseResolve |
| 112 | + |
| 113 | +• `Private` `Optional` **delayPromiseResolve**: () => `void` |
| 114 | + |
| 115 | +#### Type declaration |
| 116 | + |
| 117 | +▸ (): `void` |
| 118 | + |
| 119 | +##### Returns |
| 120 | + |
| 121 | +`void` |
| 122 | + |
| 123 | +#### Defined in |
| 124 | + |
| 125 | +[src/utils/batch/index.ts:29](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L29) |
| 126 | + |
| 127 | +--- |
| 128 | + |
| 129 | +### baseFetch |
| 130 | + |
| 131 | +• `Private` **baseFetch**: (`input`: `RequestInfo` \| `URL`, `init?`: `RequestInit`) => `Promise`<`Response`\> |
| 132 | + |
| 133 | +#### Type declaration |
| 134 | + |
| 135 | +▸ (`input`, `init?`): `Promise`<`Response`\> |
| 136 | + |
| 137 | +##### Parameters |
| 138 | + |
| 139 | +| Name | Type | |
| 140 | +| :------ | :--------------------- | |
| 141 | +| `input` | `RequestInfo` \| `URL` | |
| 142 | +| `init?` | `RequestInit` | |
| 143 | + |
| 144 | +##### Returns |
| 145 | + |
| 146 | +`Promise`<`Response`\> |
| 147 | + |
| 148 | +#### Defined in |
| 149 | + |
| 150 | +[src/utils/batch/index.ts:31](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L31) |
| 151 | + |
| 152 | +## Methods |
| 153 | + |
| 154 | +### wait |
| 155 | + |
| 156 | +▸ **wait**(): `Promise`<`void`\> |
| 157 | + |
| 158 | +#### Returns |
| 159 | + |
| 160 | +`Promise`<`void`\> |
| 161 | + |
| 162 | +#### Defined in |
| 163 | + |
| 164 | +[src/utils/batch/index.ts:40](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L40) |
| 165 | + |
| 166 | +--- |
| 167 | + |
| 168 | +### addPendingRequest |
| 169 | + |
| 170 | +▸ **addPendingRequest**<`T`\>(`method`, `params?`, `id?`): `string` \| `number` |
| 171 | + |
| 172 | +#### Type parameters |
| 173 | + |
| 174 | +| Name | Type | |
| 175 | +| :--- | :-------------------------------------------------------------------------- | |
| 176 | +| `T` | extends keyof `ReadMethods` \| keyof `WriteMethods` \| keyof `TraceMethods` | |
| 177 | + |
| 178 | +#### Parameters |
| 179 | + |
| 180 | +| Name | Type | |
| 181 | +| :-------- | :------------------------------------------------------------------------------- | |
| 182 | +| `method` | `T` | |
| 183 | +| `params?` | [`Methods`](../namespaces/types.RPC.RPCSPEC07.API.md#methods)[`T`][``"params"``] | |
| 184 | +| `id?` | `string` \| `number` | |
| 185 | + |
| 186 | +#### Returns |
| 187 | + |
| 188 | +`string` \| `number` |
| 189 | + |
| 190 | +#### Defined in |
| 191 | + |
| 192 | +[src/utils/batch/index.ts:66](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L66) |
| 193 | + |
| 194 | +--- |
| 195 | + |
| 196 | +### sendBatch |
| 197 | + |
| 198 | +▸ **sendBatch**(`requests`): `Promise`<`any`\> |
| 199 | + |
| 200 | +#### Parameters |
| 201 | + |
| 202 | +| Name | Type | |
| 203 | +| :--------- | :------------------------------------------------------------- | |
| 204 | +| `requests` | [`RequestBody`](../namespaces/types.RPC.JRPC.md#requestbody)[] | |
| 205 | + |
| 206 | +#### Returns |
| 207 | + |
| 208 | +`Promise`<`any`\> |
| 209 | + |
| 210 | +#### Defined in |
| 211 | + |
| 212 | +[src/utils/batch/index.ts:83](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L83) |
| 213 | + |
| 214 | +--- |
| 215 | + |
| 216 | +### fetch |
| 217 | + |
| 218 | +▸ **fetch**<`T`, `TResponse`\>(`method`, `params?`, `id?`): `Promise`<`TResponse`\> |
| 219 | + |
| 220 | +Automatically batches and fetches JSON-RPC calls in a single request. |
| 221 | + |
| 222 | +#### Type parameters |
| 223 | + |
| 224 | +| Name | Type | |
| 225 | +| :---------- | :-------------------------------------------------------------------------- | |
| 226 | +| `T` | extends keyof `ReadMethods` \| keyof `WriteMethods` \| keyof `TraceMethods` | |
| 227 | +| `TResponse` | extends `Object` | |
| 228 | + |
| 229 | +#### Parameters |
| 230 | + |
| 231 | +| Name | Type | Description | |
| 232 | +| :-------- | :------------------------------------------------------------------------------- | :------------------ | |
| 233 | +| `method` | `T` | Method to call | |
| 234 | +| `params?` | [`Methods`](../namespaces/types.RPC.RPCSPEC07.API.md#methods)[`T`][``"params"``] | Method parameters | |
| 235 | +| `id?` | `string` \| `number` | JSON-RPC Request ID | |
| 236 | + |
| 237 | +#### Returns |
| 238 | + |
| 239 | +`Promise`<`TResponse`\> |
| 240 | + |
| 241 | +JSON-RPC Response |
| 242 | + |
| 243 | +#### Defined in |
| 244 | + |
| 245 | +[src/utils/batch/index.ts:100](https://github.com/starknet-io/starknet.js/blob/v6.24.1/src/utils/batch/index.ts#L100) |
0 commit comments