@upcoming/bee-js 9.9.0 → 10.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/bee.js CHANGED
@@ -66,21 +66,23 @@ const type_1 = require("./utils/type");
66
66
  const typed_bytes_1 = require("./utils/typed-bytes");
67
67
  const url_1 = require("./utils/url");
68
68
  /**
69
- * The main component that abstracts operations available on the main Bee API.
69
+ * The main component that abstracts operations available on the Bee API.
70
70
  *
71
- * Not all methods are always available as it depends in what mode is Bee node launched in.
72
- * For example gateway mode and light node mode has only limited set of endpoints enabled.
71
+ * Instantiate with `new Bee(url, options)` where `url` is the Bee node URL and `options` are optional parameters.
72
+ *
73
+ * @example
74
+ * const bee = new Bee('http://localhost:1633')
73
75
  */
74
76
  class Bee {
75
77
  /**
76
78
  * @param url URL on which is the main API of Bee node exposed
77
79
  * @param options
80
+ *
81
+ * @example
82
+ * const bee = new Bee('http://localhost:1633')
78
83
  */
79
84
  constructor(url, options) {
80
85
  (0, url_1.assertBeeUrl)(url);
81
- // Remove last slash if present, as our endpoint strings starts with `/...`
82
- // which could lead to double slash in URL to which Bee responds with
83
- // unnecessary redirects.
84
86
  this.url = (0, url_1.stripLastSlash)(url);
85
87
  if (options?.signer) {
86
88
  this.signer = new typed_bytes_1.PrivateKey(options.signer);
@@ -96,15 +98,19 @@ class Bee {
96
98
  };
97
99
  }
98
100
  /**
99
- * Upload data to a Bee node
101
+ * Uploads raw data to the network (as opposed to uploading chunks or files).
100
102
  *
101
- * @param postageBatchId Postage BatchId to be used to upload the data with
102
- * @param data Data to be uploaded
103
- * @param options Additional options like tag, encryption, pinning, content-type and request options
103
+ * Data uploaded with this method should be retrieved with the {@link downloadData} method.
104
+ *
105
+ * @param postageBatchId Usable Postage Batch ID with sufficient capacity to upload the data.
106
+ * @param data A `string` (text data) or `Uint8Array` (raw data) to be uploaded.
107
+ * @param options Additional options like tag, encryption, pinning, content-type and request options.
108
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
104
109
  *
105
110
  * @returns reference is a content hash of the data
106
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
111
+ *
107
112
  * @see [Bee API reference - `POST /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes/post)
113
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
108
114
  */
109
115
  async uploadData(postageBatchId, data, options, requestOptions) {
110
116
  postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
@@ -115,21 +121,32 @@ class Bee {
115
121
  return bytes.upload(this.getRequestOptionsForCall(requestOptions), data, postageBatchId, options);
116
122
  }
117
123
  /**
118
- * Requests content length for a `/bytes` reference
124
+ * Fetches content length for a `/bytes` reference.
125
+ *
126
+ * @param reference
127
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
119
128
  *
120
- * @see [Bee API reference - `HEAD /bytes/`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1%7Breference%7D/head)
129
+ * @see [Bee API reference - `HEAD /bytes/{reference}`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1%7Breference%7D/head)
121
130
  */
122
- async probeData(reference, options) {
131
+ async probeData(reference, requestOptions) {
123
132
  reference = new typed_bytes_1.Reference(reference);
124
- return bytes.head(this.getRequestOptionsForCall(options), reference);
133
+ return bytes.head(this.getRequestOptionsForCall(requestOptions), reference);
125
134
  }
126
135
  /**
127
- * Download data as a byte array
136
+ * Downloads raw data through the `GET /bytes/{reference}` endpoint.
128
137
  *
129
- * @param resource Swarm reference, Swarm CID, or ENS domain
138
+ * This method may be used to download data that was uploaded with the {@link uploadData} method.
139
+ *
140
+ * For downloading files or using the `GET /bzz/{reference}/` endpoint, use the {@link downloadFile} method instead.
141
+ * For downloading chunks or using the `GET /chunks/{reference} endpoint, use the `downloadChunk` method instead.
142
+ *
143
+ * @param resource Swarm reference, Swarm CID, or ENS domain.
130
144
  * @param options Options that affects the request behavior
145
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
146
+ *
131
147
  * @throws TypeError if some of the input parameters is not expected type
132
148
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
149
+ *
133
150
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
134
151
  * @see [Bee API reference - `GET /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1{reference}/get)
135
152
  */
@@ -140,12 +157,18 @@ class Bee {
140
157
  return bytes.download(this.getRequestOptionsForCall(requestOptions), new resource_locator_1.ResourceLocator(resource), options);
141
158
  }
142
159
  /**
143
- * Download data as a Readable stream
160
+ * Download raw data through the `GET /bytes/{reference}` endpoint.
161
+ *
162
+ * This method may be used to download data that was uploaded with the {@link uploadData} method.
163
+ *
164
+ * Only tested in Node.js environment.
165
+ *
166
+ * @param resource Swarm reference, Swarm CID, or ENS domain.
167
+ * @param options Options that affects the request behavior.
168
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
169
+ *
170
+ * @returns ReadableStream of Uint8Array
144
171
  *
145
- * @param resource Swarm reference, Swarm CID, or ENS domain
146
- * @param options Options that affects the request behavior
147
- * @throws TypeError if some of the input parameters is not expected type
148
- * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
149
172
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
150
173
  * @see [Bee API reference - `GET /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1{reference}/get)
151
174
  */
@@ -156,11 +179,14 @@ class Bee {
156
179
  return bytes.downloadReadable(this.getRequestOptionsForCall(requestOptions), new resource_locator_1.ResourceLocator(resource), options);
157
180
  }
158
181
  /**
159
- * Upload chunk to a Bee node
182
+ * Uploads a chunk to the network.
183
+ *
184
+ * Chunks uploaded with this method should be retrieved with the {@link downloadChunk} method.
160
185
  *
161
- * @param postageBatchId Postage BatchId to be used to upload the chunk with
186
+ * @param stamp Postage Batch ID or an Envelope created with the {@link createEnvelope} method.
162
187
  * @param data Raw chunk to be uploaded
163
188
  * @param options Additional options like tag, encryption, pinning, content-type and request options
189
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
164
190
  *
165
191
  * @returns reference is a content hash of the data
166
192
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
@@ -180,12 +206,17 @@ class Bee {
180
206
  return chunk.upload(this.getRequestOptionsForCall(requestOptions), data, stamp, options);
181
207
  }
182
208
  /**
183
- * Download chunk as a byte array
209
+ * Downloads a chunk as a `Uint8Array`.
210
+ *
211
+ * May be used to download chunks uploaded with the {@link uploadChunk} method.
212
+ *
213
+ * Use {@link downloadData} method to download raw data uploaded with the {@link uploadData} method.
214
+ * Use {@link downloadFile} method to download files uploaded with the {@link uploadFile} method.
184
215
  *
185
216
  * @param reference Bee chunk reference in hex string (either 64 or 128 chars long) or ENS domain.
186
217
  * @param options Options that affects the request behavior
187
- * @throws TypeError if some of the input parameters is not expected type
188
- * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
218
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
219
+ *
189
220
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
190
221
  * @see [Bee API reference - `GET /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks~1{address}/get)
191
222
  */
@@ -199,7 +230,7 @@ class Bee {
199
230
  /**
200
231
  * Create a grantees list from the given array of public keys.
201
232
  *
202
- * The grantees list can be obtained with the `getGrantees` method.
233
+ * The grantees list can be obtained with the {@link getGrantees} method.
203
234
  *
204
235
  * @param postageBatchId - The ID of the postage batch.
205
236
  * @param grantees - An array of public keys representing the grantees.
@@ -229,7 +260,7 @@ class Bee {
229
260
  * @param history - The history.
230
261
  * @param postageBatchId - The ID of the postage batch.
231
262
  * @param grantees - The grantees.
232
- * @param requestOptions - Optional request options.
263
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
233
264
  * @returns A Promise that resolves to to a `GranteesResult` object.
234
265
  */
235
266
  async patchGrantees(postageBatchId, reference, history, grantees, requestOptions) {
@@ -243,12 +274,18 @@ class Bee {
243
274
  return grantee.patchGrantees(postageBatchId, reference, history, publicKeys, this.getRequestOptionsForCall(requestOptions));
244
275
  }
245
276
  /**
246
- * Upload single file to a Bee node.
277
+ * Uploads a single file to a Bee node.
278
+ *
279
+ * To download the file, use the {@link downloadFile} method.
280
+ *
281
+ * Use {@link uploadData} method to upload raw data that can be downloaded with the {@link downloadData} method.
282
+ * Use {@link uploadChunk} method to upload chunks that can be downloaded with the {@link downloadChunk} method.
247
283
  *
248
284
  * @param postageBatchId Postage BatchId to be used to upload the data with
249
285
  * @param data Data or file to be uploaded
250
286
  * @param name Optional name of the uploaded file
251
287
  * @param options Additional options like tag, encryption, pinning, content-type and request options
288
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
252
289
  *
253
290
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
254
291
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
@@ -276,14 +313,13 @@ class Bee {
276
313
  }
277
314
  }
278
315
  /**
279
- * Download single file.
316
+ * Downloads a single file.
280
317
  *
281
- * @param resource Swarm reference, Swarm CID, or ENS domain
318
+ * @param resource Swarm reference, Swarm CID, or ENS domain.
282
319
  * @param path If reference points to manifest, then this parameter defines path to the file
283
320
  * @param options Options that affects the request behavior
284
- * @throws TypeError if some of the input parameters is not expected type
285
- * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
286
- * @see Data
321
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
322
+ *
287
323
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
288
324
  * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D~1%7Bpath%7D/get)
289
325
  */
@@ -299,8 +335,7 @@ class Bee {
299
335
  * @param reference Bee file reference in hex string (either 64 or 128 chars long), ENS domain or Swarm CID.
300
336
  * @param path If reference points to manifest / collections, then this parameter defines path to the file
301
337
  * @param options Options that affects the request behavior
302
- * @throws TypeError if some of the input parameters is not expected type
303
- * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
338
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
304
339
  *
305
340
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
306
341
  * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D~1%7Bpath%7D/get)
@@ -323,6 +358,7 @@ class Bee {
323
358
  * @param postageBatchId Postage BatchId to be used to upload the data with
324
359
  * @param fileList list of files to be uploaded
325
360
  * @param options Additional options like tag, encryption, pinning and request options
361
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
326
362
  *
327
363
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
328
364
  * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download#upload-a-directory)
@@ -336,13 +372,57 @@ class Bee {
336
372
  const data = (0, collection_1.makeCollectionFromFileList)(fileList);
337
373
  return bzz.uploadCollection(this.getRequestOptionsForCall(requestOptions), data, postageBatchId, options);
338
374
  }
375
+ /**
376
+ * Hashes a directory locally and returns the root hash (Swarm reference).
377
+ *
378
+ * The actual Swarm reference may be different as there is no canonical hashing of directories.
379
+ * For example, metadata may have different casing, or the order of metadata may differ.
380
+ * Such small differences will result in different Swarm references.
381
+ *
382
+ * Different implementations of the Mantaray structure may also result in different Swarm references.
383
+ *
384
+ * @param dir
385
+ * @returns
386
+ */
339
387
  async hashDirectory(dir) {
340
388
  return (0, chunk_stream_1.hashDirectory)(dir);
341
389
  }
390
+ /**
391
+ * Uploads a directory to the network. The difference between this method and {@link uploadFilesFromDirectory} is that
392
+ * this method streams the directory contents directly to the Bee node, which supports arbitrary directory sizes,
393
+ * but may be slower due to uploading chunks one by one.
394
+ *
395
+ * Options such as encryption, erasure coding and ACT are not yet available for this method.
396
+ *
397
+ * Only intended for the Node.js environment.
398
+ *
399
+ * @param postageBatchId
400
+ * @param dir
401
+ * @param onUploadProgress
402
+ * @param options
403
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
404
+ * @returns
405
+ */
342
406
  async streamDirectory(postageBatchId, dir, onUploadProgress, options, requestOptions) {
343
407
  postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
344
408
  return (0, chunk_stream_1.streamDirectory)(this, dir, postageBatchId, onUploadProgress, options, this.getRequestOptionsForCall(requestOptions));
345
409
  }
410
+ /**
411
+ * Uploads a collection of files to the network. The difference between this method and {@link uploadFiles} is that
412
+ * this method streams the files to the Bee node, which supports arbitrary sizes,
413
+ * but may be slower due to uploading chunks one by one.
414
+ *
415
+ * Options such as encryption, erasure coding and ACT are not yet available for this method.
416
+ *
417
+ * Only intended for the browser environment.
418
+ *
419
+ * @param postageBatchId
420
+ * @param files
421
+ * @param onUploadProgress
422
+ * @param options
423
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
424
+ * @returns
425
+ */
346
426
  async streamFiles(postageBatchId, files, onUploadProgress, options, requestOptions) {
347
427
  postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
348
428
  return (0, chunk_stream_1.streamFiles)(this, files, postageBatchId, onUploadProgress, options, this.getRequestOptionsForCall(requestOptions));
@@ -390,23 +470,23 @@ class Bee {
390
470
  return bzz.uploadCollection(this.getRequestOptionsForCall(requestOptions), data, postageBatchId, options);
391
471
  }
392
472
  /**
393
- * Create a new Tag which is meant for tracking progres of syncing data across network.
473
+ * Creates a new Tag which is meant for tracking upload and synchronization progress.
474
+ *
475
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
394
476
  *
395
- * @param options Options that affects the request behavior
396
477
  * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
397
478
  * @see [Bee API reference - `POST /tags`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/post)
398
479
  */
399
- async createTag(options) {
400
- return tag.createTag(this.getRequestOptionsForCall(options));
480
+ async createTag(requestOptions) {
481
+ return tag.createTag(this.getRequestOptionsForCall(requestOptions));
401
482
  }
402
483
  /**
403
- * Fetches all tags.
484
+ * Fetches all tags in a paginated manner.
404
485
  *
405
486
  * The listing is limited by options.limit. So you have to iterate using options.offset to get all tags.
406
487
  *
407
- * @param options Options that affects the request behavior
408
- * @throws TypeError if limit or offset are not numbers or undefined
409
- * @throws BeeArgumentError if limit or offset have invalid options
488
+ * @param options Specify `limit` and `offset` to paginate through the tags.
489
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
410
490
  *
411
491
  * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
412
492
  * @see [Bee API reference - `GET /tags`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/get)
@@ -418,34 +498,31 @@ class Bee {
418
498
  return tag.getAllTags(this.getRequestOptionsForCall(requestOptions), options?.offset, options?.limit);
419
499
  }
420
500
  /**
421
- * Retrieve tag information from Bee node
501
+ * Retrieves tag information from Bee node.
422
502
  *
423
503
  * @param tagUid UID or tag object to be retrieved
424
- * @param options Options that affects the request behavior
425
- * @throws TypeError if tagUid is in not correct format
504
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
426
505
  *
427
506
  * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
428
507
  * @see [Bee API reference - `GET /tags/{uid}`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1{uid}/get)
429
508
  *
430
509
  */
431
- async retrieveTag(tagUid, options) {
510
+ async retrieveTag(tagUid, requestOptions) {
432
511
  tagUid = (0, type_1.makeTagUid)(tagUid);
433
- return tag.retrieveTag(this.getRequestOptionsForCall(options), tagUid);
512
+ return tag.retrieveTag(this.getRequestOptionsForCall(requestOptions), tagUid);
434
513
  }
435
514
  /**
436
- * Delete Tag
515
+ * Deletes Tag.
437
516
  *
438
517
  * @param tagUid UID or tag object to be retrieved
439
- * @param options Options that affects the request behavior
440
- * @throws TypeError if tagUid is in not correct format
441
- * @throws BeeResponse error if something went wrong on the Bee node side while deleting the tag.
518
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
442
519
  *
443
520
  * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
444
521
  * @see [Bee API reference - `DELETE /tags/{uid}`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1{uid}/delete)
445
522
  */
446
- async deleteTag(tagUid, options) {
523
+ async deleteTag(tagUid, requestOptions) {
447
524
  tagUid = (0, type_1.makeTagUid)(tagUid);
448
- return tag.deleteTag(this.getRequestOptionsForCall(options), tagUid);
525
+ return tag.deleteTag(this.getRequestOptionsForCall(requestOptions), tagUid);
449
526
  }
450
527
  /**
451
528
  * Update tag's total chunks count.
@@ -455,99 +532,90 @@ class Bee {
455
532
  *
456
533
  * @param tagUid UID or tag object to be retrieved
457
534
  * @param reference The root reference that contains all the chunks to be counted
458
- * @param options Options that affects the request behavior
459
- * @throws TypeError if tagUid is in not correct format
460
- * @throws BeeResponse error if something went wrong on the Bee node side while deleting the tag.
535
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
461
536
  *
462
537
  * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
463
538
  * @see [Bee API reference - `PATCH /tags/{uid}`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1{uid}/patch)
464
539
  */
465
- async updateTag(tagUid, reference, options) {
540
+ async updateTag(tagUid, reference, requestOptions) {
466
541
  reference = new typed_bytes_1.Reference(reference);
467
542
  tagUid = (0, type_1.makeTagUid)(tagUid);
468
- return tag.updateTag(this.getRequestOptionsForCall(options), tagUid, reference);
543
+ return tag.updateTag(this.getRequestOptionsForCall(requestOptions), tagUid, reference);
469
544
  }
470
545
  /**
471
- * Pin local data with given reference
546
+ * Pins local data with given reference.
472
547
  *
473
548
  * @param reference Data reference
474
- * @param options Options that affects the request behavior
475
- * @throws TypeError if reference is in not correct format
549
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
476
550
  *
477
551
  * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
478
552
  */
479
- async pin(reference, options) {
553
+ async pin(reference, requestOptions) {
480
554
  reference = new typed_bytes_1.Reference(reference);
481
- return pinning.pin(this.getRequestOptionsForCall(options), reference);
555
+ return pinning.pin(this.getRequestOptionsForCall(requestOptions), reference);
482
556
  }
483
557
  /**
484
- * Unpin local data with given reference
558
+ * Unpins local data with given reference.
485
559
  *
486
560
  * @param reference Data reference
487
- * @param options Options that affects the request behavior
488
- * @throws TypeError if reference is in not correct format
561
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
489
562
  *
490
563
  * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
491
564
  */
492
- async unpin(reference, options) {
565
+ async unpin(reference, requestOptions) {
493
566
  reference = new typed_bytes_1.Reference(reference);
494
- return pinning.unpin(this.getRequestOptionsForCall(options), reference);
567
+ return pinning.unpin(this.getRequestOptionsForCall(requestOptions), reference);
495
568
  }
496
569
  /**
497
- * Get list of all locally pinned references
570
+ * Gets list of all locally pinned references.
571
+ *
572
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
498
573
  *
499
- * @param options Options that affects the request behavior
500
574
  * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
501
575
  */
502
- async getAllPins(options) {
503
- return pinning.getAllPins(this.getRequestOptionsForCall(options));
576
+ async getAllPins(requestOptions) {
577
+ return pinning.getAllPins(this.getRequestOptionsForCall(requestOptions));
504
578
  }
505
579
  /**
506
580
  * Get pinning status of chunk with given reference
507
581
  *
508
582
  * @param reference Bee data reference in hex string (either 64 or 128 chars long) or ENS domain.
509
- * @param options Options that affects the request behavior
510
- * @throws TypeError if some of the input parameters is not expected type
511
- * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
583
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
512
584
  *
513
585
  * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
514
586
  */
515
- async getPin(reference, options) {
587
+ async getPin(reference, requestOptions) {
516
588
  reference = new typed_bytes_1.Reference(reference);
517
- return pinning.getPin(this.getRequestOptionsForCall(options), reference);
589
+ return pinning.getPin(this.getRequestOptionsForCall(requestOptions), reference);
518
590
  }
519
591
  /**
520
592
  * Instructs the Bee node to reupload a locally pinned data into the network.
521
593
  *
594
+ * @param postageBatchId Postage Batch ID that will be used to re-upload the data.
522
595
  * @param reference Bee data reference to be re-uploaded in hex string (either 64 or 128 chars long) or ENS domain.
523
- * @param options Options that affects the request behavior
524
- * @throws BeeArgumentError if the reference is not locally pinned
525
- * @throws TypeError if some of the input parameters is not expected type
526
- * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
596
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
527
597
  *
528
598
  * @see [Bee API reference - `PUT /stewardship`](https://docs.ethswarm.org/api/#tag/Stewardship/paths/~1stewardship~1{reference}/put)
529
599
  */
530
- async reuploadPinnedData(postageBatchId, reference, options) {
600
+ async reuploadPinnedData(postageBatchId, reference, requestOptions) {
531
601
  postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
532
602
  reference = new typed_bytes_1.Reference(reference);
533
- await stewardship.reupload(this.getRequestOptionsForCall(options), postageBatchId, reference);
603
+ await stewardship.reupload(this.getRequestOptionsForCall(requestOptions), postageBatchId, reference);
534
604
  }
535
605
  /**
536
606
  * Checks if content specified by reference is retrievable from the network.
537
607
  *
538
608
  * @param reference Bee data reference to be checked in hex string (either 64 or 128 chars long) or ENS domain.
539
- * @param options Options that affects the request behavior
540
- * @throws TypeError if some of the input parameters is not expected type
541
- * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
609
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
542
610
  *
543
611
  * @see [Bee API reference - `GET /stewardship`](https://docs.ethswarm.org/api/#tag/Stewardship/paths/~1stewardship~1{reference}/get)
544
612
  */
545
- async isReferenceRetrievable(reference, options) {
613
+ async isReferenceRetrievable(reference, requestOptions) {
546
614
  reference = new typed_bytes_1.Reference(reference);
547
- return stewardship.isRetrievable(this.getRequestOptionsForCall(options), reference);
615
+ return stewardship.isRetrievable(this.getRequestOptionsForCall(requestOptions), reference);
548
616
  }
549
617
  /**
550
- * Functions that validates if feed is retrievable in the network.
618
+ * Functions that validate if feed is retrievable in the network.
551
619
  *
552
620
  * If no index is passed then it check for "latest" update, which is a weaker guarantee as nobody can be really
553
621
  * sure what is the "latest" update.
@@ -560,6 +628,7 @@ class Bee {
560
628
  * @param topic
561
629
  * @param index
562
630
  * @param options
631
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
563
632
  */
564
633
  async isFeedRetrievable(owner, topic, index, options, requestOptions) {
565
634
  owner = new typed_bytes_1.EthAddress(owner);
@@ -590,36 +659,33 @@ class Bee {
590
659
  * most likely for setting up an encrypted communication
591
660
  * channel by sending an one-off message.
592
661
  *
593
- * **Warning! If the recipient Bee node is a light node, then he will never receive the message!**
594
- * This is because light nodes does not fully participate in the data exchange in Swarm network and hence the message won't arrive to them.
662
+ * **Warning! Only full nodes can accept PSS messages.**
595
663
  *
596
664
  * @param postageBatchId Postage BatchId that will be assigned to sent message
597
665
  * @param topic Topic name
598
666
  * @param target Target message address prefix. Has a limit on length. Recommend to use `Utils.Pss.makeMaxTarget()` to get the most specific target that Bee node will accept.
599
667
  * @param data Message to be sent
600
668
  * @param recipient Recipient public key
601
- * @param options Options that affects the request behavior
602
- * @throws TypeError if `data`, `batchId`, `target` or `recipient` are in invalid format
669
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
603
670
  *
604
671
  * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
605
672
  * @see [Bee API reference - `POST /pss`](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1send~1{topic}~1{targets}/post)
606
673
  */
607
- async pssSend(postageBatchId, topic, target, data, recipient, options) {
674
+ async pssSend(postageBatchId, topic, target, data, recipient, requestOptions) {
608
675
  postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
609
676
  (0, type_1.assertData)(data);
610
677
  if (recipient) {
611
678
  recipient = new typed_bytes_1.PublicKey(recipient);
612
- return pss.send(this.getRequestOptionsForCall(options), topic, target, data, postageBatchId, recipient);
679
+ return pss.send(this.getRequestOptionsForCall(requestOptions), topic, target, data, postageBatchId, recipient);
613
680
  }
614
681
  else {
615
- return pss.send(this.getRequestOptionsForCall(options), topic, target, data, postageBatchId);
682
+ return pss.send(this.getRequestOptionsForCall(requestOptions), topic, target, data, postageBatchId);
616
683
  }
617
684
  }
618
685
  /**
619
- * Subscribe to messages for given topic with Postal Service for Swarm
686
+ * Subscribes to messages for given topic with the Postal Service for Swarm.
620
687
  *
621
- * **Warning! If connected Bee node is a light node, then he will never receive any message!**
622
- * This is because light nodes does not fully participate in the data exchange in Swarm network and hence the message won't arrive to them.
688
+ * **Warning! Only full nodes can accept PSS messages.**
623
689
  *
624
690
  * @param topic Topic name
625
691
  * @param handler Message handler interface
@@ -634,17 +700,14 @@ class Bee {
634
700
  const ws = pss.subscribe(this.url, topic, this.requestOptions.headers);
635
701
  let cancelled = false;
636
702
  const cancel = () => {
637
- if (cancelled === false) {
703
+ if (!cancelled) {
638
704
  cancelled = true;
639
- // although the WebSocket API offers a `close` function, it seems that
640
- // with the library that we are using (isomorphic-ws) it doesn't close
641
- // the websocket properly, whereas `terminate` does
642
705
  if (ws.terminate) {
643
706
  ws.terminate();
644
707
  }
645
708
  else {
646
709
  ws.close();
647
- } // standard Websocket in browser does not have terminate function
710
+ }
648
711
  }
649
712
  };
650
713
  const subscription = {
@@ -658,28 +721,24 @@ class Bee {
658
721
  }
659
722
  };
660
723
  ws.onerror = event => {
661
- // ignore errors after subscription was cancelled
662
724
  if (!cancelled) {
663
725
  handler.onError(new error_1.BeeError(event.message), subscription);
664
726
  }
665
727
  };
728
+ ws.onclose = () => {
729
+ handler.onClose(subscription);
730
+ };
666
731
  return subscription;
667
732
  }
668
733
  /**
669
- * Receive message with Postal Service for Swarm
670
- *
671
- * Because sending a PSS message is slow and CPU intensive,
672
- * it is not supposed to be used for general messaging but
673
- * most likely for setting up an encrypted communication
674
- * channel by sending an one-off message.
734
+ * Receives message using the Postal Service for Swarm.
675
735
  *
676
736
  * This is a helper function to wait for exactly one message to
677
737
  * arrive and then cancel the subscription. Additionally a
678
738
  * timeout can be provided for the message to arrive or else
679
739
  * an error will be thrown.
680
740
  *
681
- * **Warning! If connected Bee node is a light node, then he will never receive any message!**
682
- * This is because light nodes does not fully participate in the data exchange in Swarm network and hence the message won't arrive to them.
741
+ * **Warning! Only full nodes can accept PSS messages.**
683
742
  *
684
743
  * @param topic Topic name
685
744
  * @param timeoutMsec Timeout in milliseconds
@@ -706,6 +765,10 @@ class Bee {
706
765
  subscription.cancel();
707
766
  resolve(message);
708
767
  },
768
+ onClose: () => {
769
+ clearTimeout(timeout);
770
+ subscription.cancel();
771
+ },
709
772
  });
710
773
  if (timeoutMsec > 0) {
711
774
  timeout = setTimeout(() => {
@@ -715,6 +778,22 @@ class Bee {
715
778
  }
716
779
  });
717
780
  }
781
+ /**
782
+ * Mines the signer (a private key) to be used to send GSOC messages to the specific target overlay address.
783
+ *
784
+ * Use {@link gsocSend} to send GSOC messages with the mined signer.
785
+ *
786
+ * Use {@link gsocSubscribe} to subscribe to GSOC messages for the specified owner (of the signer) and identifier.
787
+ *
788
+ * See {@link gsocSend} or {@link gsocSubscribe} for concrete examples of usage.
789
+ *
790
+ * **Warning! Only full nodes can accept GSOC messages.**
791
+ *
792
+ * @param targetOverlay
793
+ * @param identifier
794
+ * @param proximity
795
+ * @returns
796
+ */
718
797
  gsocMine(targetOverlay, identifier, proximity = 12) {
719
798
  targetOverlay = new typed_bytes_1.PeerAddress(targetOverlay);
720
799
  identifier = new typed_bytes_1.Identifier(identifier);
@@ -730,6 +809,29 @@ class Bee {
730
809
  }
731
810
  throw Error('Could not mine a valid signer');
732
811
  }
812
+ /**
813
+ * Sends a GSOC message with the specified signer and identifier.
814
+ *
815
+ * Use {@link gsocMine} to mine a signer for the target overlay address.
816
+ *
817
+ * Use {@link gsocSubscribe} to subscribe to GSOC messages for the specified owner (of the signer) and identifier.
818
+ *
819
+ * **Warning! Only full nodes can accept GSOC messages.**
820
+ *
821
+ * @param postageBatchId
822
+ * @param signer
823
+ * @param identifier
824
+ * @param data
825
+ * @param options
826
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
827
+ * @returns
828
+ *
829
+ * @example
830
+ * const identifier = NULL_IDENTIFIER
831
+ * const overlay = '0x1234567890123456789012345678901234567890'
832
+ * const signer = bee.gsocMine(overlay, identifier)
833
+ * await bee.gsocSend(postageBatchId, signer, identifier, 'GSOC!')
834
+ */
733
835
  async gsocSend(postageBatchId, signer, identifier, data, options, requestOptions) {
734
836
  postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
735
837
  signer = new typed_bytes_1.PrivateKey(signer);
@@ -738,6 +840,37 @@ class Bee {
738
840
  const soc = (0, soc_1.makeSingleOwnerChunk)(cac, identifier, signer);
739
841
  return gsoc.send(this.getRequestOptionsForCall(requestOptions), soc, postageBatchId, options);
740
842
  }
843
+ /**
844
+ * Subscribes to GSOC messages for the specified owner (of the signer) and identifier.
845
+ *
846
+ * Use {@link gsocMine} to mine a signer for the target overlay address.
847
+ *
848
+ * Use {@link gsocSend} to send GSOC messages with the mined signer.
849
+ *
850
+ * **Warning! Only full nodes can accept GSOC messages.**
851
+ *
852
+ * @param address
853
+ * @param identifier
854
+ * @param handler
855
+ * @returns
856
+ *
857
+ * @example
858
+ * const identifier = NULL_IDENTIFIER
859
+ * const { overlay } = await bee.getNodeAddresses()
860
+ * const signer = bee.gsocMine(overlay, identifier)
861
+ *
862
+ * const subscription = bee.gsocSubscribe(signer.publicKey().address(), identifier, {
863
+ * onMessage(message) {
864
+ * // handle
865
+ * },
866
+ * onError(error) {
867
+ * // handle
868
+ * },
869
+ * onClose() {
870
+ * // handle
871
+ * }
872
+ * })
873
+ */
741
874
  gsocSubscribe(address, identifier, handler) {
742
875
  address = new typed_bytes_1.EthAddress(address);
743
876
  identifier = new typed_bytes_1.Identifier(identifier);
@@ -746,7 +879,7 @@ class Bee {
746
879
  const ws = gsoc.subscribe(this.url, socAddress, this.requestOptions.headers);
747
880
  let cancelled = false;
748
881
  const cancel = () => {
749
- if (cancelled === false) {
882
+ if (!cancelled) {
750
883
  cancelled = true;
751
884
  if (ws.terminate) {
752
885
  ws.terminate();
@@ -771,17 +904,21 @@ class Bee {
771
904
  handler.onError(new error_1.BeeError(event.message), subscription);
772
905
  }
773
906
  };
907
+ ws.onclose = () => {
908
+ handler.onClose(subscription);
909
+ };
774
910
  return subscription;
775
911
  }
776
912
  /**
777
- * Create feed manifest chunk and return the reference to it.
913
+ * Creates a feed manifest chunk and returns the reference to it.
778
914
  *
779
- * Feed manifest chunk allows for a feed to be able to be resolved through `/bzz` endpoint.
915
+ * Feed manifest chunks allow for a feed to be able to be resolved through `/bzz` endpoint.
780
916
  *
781
917
  * @param postageBatchId Postage BatchId to be used to create the Feed Manifest
782
918
  * @param topic Topic in hex or bytes
783
919
  * @param owner Owner's ethereum address in hex or bytes
784
920
  * @param options Options that affects the request behavior
921
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
785
922
  *
786
923
  * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
787
924
  * @see [Bee API reference - `POST /feeds`](https://docs.ethswarm.org/api/#tag/Feed/paths/~1feeds~1{owner}~1{topic}/post)
@@ -796,35 +933,35 @@ class Bee {
796
933
  return (0, feed_2.createFeedManifest)(this.getRequestOptionsForCall(requestOptions), owner, topic, postageBatchId, options);
797
934
  }
798
935
  /**
799
- * Make a new feed reader for downloading feed updates.
936
+ * Makes a new feed reader for downloading feed updates.
800
937
  *
801
938
  * @param topic Topic in hex or bytes
802
939
  * @param owner Owner's ethereum address in hex or bytes
803
- * @param options Options that affects the request behavior
940
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
804
941
  *
805
942
  * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
806
943
  */
807
- makeFeedReader(topic, owner, options) {
944
+ makeFeedReader(topic, owner, requestOptions) {
808
945
  topic = new typed_bytes_1.Topic(topic);
809
946
  owner = new typed_bytes_1.EthAddress(owner);
810
- return (0, feed_1.makeFeedReader)(this.getRequestOptionsForCall(options), topic, owner);
947
+ return (0, feed_1.makeFeedReader)(this.getRequestOptionsForCall(requestOptions), topic, owner);
811
948
  }
812
949
  /**
813
- * Make a new feed writer for updating feeds
950
+ * Makes a new feed writer for updating feeds
814
951
  *
815
952
  * @param topic Topic in hex or bytes
816
953
  * @param signer The signer's private key or a Signer instance that can sign data
817
- * @param options Options that affects the request behavior
954
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
818
955
  *
819
956
  * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
820
957
  */
821
- makeFeedWriter(topic, signer, options) {
958
+ makeFeedWriter(topic, signer, requestOptions) {
822
959
  topic = new typed_bytes_1.Topic(topic);
823
960
  signer = signer ? new typed_bytes_1.PrivateKey(signer) : this.signer;
824
961
  if (!signer) {
825
962
  throw Error('No signer provided');
826
963
  }
827
- return (0, feed_1.makeFeedWriter)(this.getRequestOptionsForCall(options), topic, signer);
964
+ return (0, feed_1.makeFeedWriter)(this.getRequestOptionsForCall(requestOptions), topic, signer);
828
965
  }
829
966
  async fetchLatestFeedUpdate(topic, owner, requestOptions) {
830
967
  topic = new typed_bytes_1.Topic(topic);
@@ -835,62 +972,91 @@ class Bee {
835
972
  * Returns an object for reading single owner chunks
836
973
  *
837
974
  * @param ownerAddress The ethereum address of the owner
838
- * @param options Options that affects the request behavior
975
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
839
976
  * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/develop/tools-and-features/chunk-types#single-owner-chunks)
840
977
  */
841
- makeSOCReader(ownerAddress, options) {
978
+ makeSOCReader(ownerAddress, requestOptions) {
842
979
  ownerAddress = new typed_bytes_1.EthAddress(ownerAddress);
843
980
  return {
844
981
  owner: ownerAddress,
845
- download: soc_1.downloadSingleOwnerChunk.bind(null, this.getRequestOptionsForCall(options), ownerAddress),
982
+ download: soc_1.downloadSingleOwnerChunk.bind(null, this.getRequestOptionsForCall(requestOptions), ownerAddress),
846
983
  };
847
984
  }
848
985
  /**
849
986
  * Returns an object for reading and writing single owner chunks
850
987
  *
851
988
  * @param signer The signer's private key or a Signer instance that can sign data
852
- * @param options Options that affects the request behavior
989
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
853
990
  * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/develop/tools-and-features/chunk-types#single-owner-chunks)
854
991
  */
855
- makeSOCWriter(signer, options) {
992
+ makeSOCWriter(signer, requestOptions) {
856
993
  signer = signer ? new typed_bytes_1.PrivateKey(signer) : this.signer;
857
994
  if (!signer) {
858
995
  throw Error('No signer provided');
859
996
  }
860
997
  return {
861
- ...this.makeSOCReader(signer.publicKey().address(), options),
862
- upload: soc_1.uploadSingleOwnerChunkData.bind(null, this.getRequestOptionsForCall(options), signer),
998
+ ...this.makeSOCReader(signer.publicKey().address(), requestOptions),
999
+ upload: soc_1.uploadSingleOwnerChunkData.bind(null, this.getRequestOptionsForCall(requestOptions), signer),
863
1000
  };
864
1001
  }
865
- async createEnvelope(postageBatchId, reference, options) {
1002
+ /**
1003
+ * Creates the postage batch signature for a specific chunk address.
1004
+ *
1005
+ * This is for advanced usage, where a pre-signed chunk can be uploaded
1006
+ * through a different Bee node.
1007
+ *
1008
+ * @param postageBatchId
1009
+ * @param reference
1010
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1011
+ *
1012
+ * @example
1013
+ * const envelope = await bee.createEnvelope(batchId, chunk.address)
1014
+ * await bee.uploadChunk(envelope, chunk)
1015
+ *
1016
+ * @returns
1017
+ */
1018
+ async createEnvelope(postageBatchId, reference, requestOptions) {
866
1019
  postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
867
1020
  reference = new typed_bytes_1.Reference(reference);
868
- return (0, envelope_1.postEnvelope)(this.getRequestOptionsForCall(options), postageBatchId, reference);
1021
+ return (0, envelope_1.postEnvelope)(this.getRequestOptionsForCall(requestOptions), postageBatchId, reference);
869
1022
  }
870
1023
  /**
871
- * Get reserve commitment hash duration seconds
1024
+ * Gets reserve commitment hash duration seconds.
1025
+ *
1026
+ * To be able to participe in the storage incentives and not get frozen, this should
1027
+ * ideally run under 5 minutes.
1028
+ *
1029
+ * This is a CPU intensice operation, as roughly 2^22 chunks are hashed in the process.
1030
+ *
1031
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1032
+ *
1033
+ * @example
1034
+ * const addresses = await bee.getNodeAddresses()
1035
+ * const topology = await bee.getTopology()
1036
+ * const result = await bee.rchash(topology.depth, addresses.overlay.toHex(), addresses.overlay.toHex())
1037
+ * // result is a number of seconds
872
1038
  */
873
- async rchash(depth, anchor1, anchor2, options) {
874
- return (0, rchash_1.rchash)(this.getRequestOptionsForCall(options), depth, anchor1, anchor2);
1039
+ async rchash(depth, anchor1, anchor2, requestOptions) {
1040
+ return (0, rchash_1.rchash)(this.getRequestOptionsForCall(requestOptions), depth, anchor1, anchor2);
875
1041
  }
876
1042
  /**
877
- * Ping the Bee node to see if there is a live Bee node on the given URL.
1043
+ * Pings the Bee node to see if there is a live Bee node on the given URL.
878
1044
  *
879
- * @param options Options that affects the request behavior
1045
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
880
1046
  * @throws If connection was not successful throw error
881
1047
  */
882
- async checkConnection(options) {
883
- return status.checkConnection(this.getRequestOptionsForCall(options));
1048
+ async checkConnection(requestOptions) {
1049
+ return status.checkConnection(this.getRequestOptionsForCall(requestOptions));
884
1050
  }
885
1051
  /**
886
- * Ping the Bee node to see if there is a live Bee node on the given URL.
1052
+ * Pings the Bee node to see if there is a live Bee node on the given URL.
887
1053
  *
888
- * @param options Options that affects the request behavior
1054
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
889
1055
  * @returns true if successful, false on error
890
1056
  */
891
- async isConnected(options) {
1057
+ async isConnected(requestOptions) {
892
1058
  try {
893
- await status.checkConnection(this.getRequestOptionsForCall(options));
1059
+ await status.checkConnection(this.getRequestOptionsForCall(requestOptions));
894
1060
  }
895
1061
  catch (e) {
896
1062
  return false;
@@ -903,117 +1069,170 @@ class Bee {
903
1069
  * Do note that this is not a standard way to check for gateway nodes,
904
1070
  * but some of the gateway tooling expose this endpoint.
905
1071
  *
906
- * @param options
1072
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
907
1073
  */
908
- async isGateway(options) {
909
- return status.isGateway(this.getRequestOptionsForCall(options));
1074
+ async isGateway(requestOptions) {
1075
+ return status.isGateway(this.getRequestOptionsForCall(requestOptions));
910
1076
  }
911
- // Legacy debug API
912
- async getNodeAddresses(options) {
913
- return connectivity.getNodeAddresses(this.getRequestOptionsForCall(options));
1077
+ /**
1078
+ * Fetches the overlay, underlay, Ethereum, and other addresses of the Bee node.
1079
+ *
1080
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1081
+ * @returns
1082
+ */
1083
+ async getNodeAddresses(requestOptions) {
1084
+ return connectivity.getNodeAddresses(this.getRequestOptionsForCall(requestOptions));
914
1085
  }
915
- async getBlocklist(options) {
916
- return connectivity.getBlocklist(this.getRequestOptionsForCall(options));
1086
+ /**
1087
+ * Fetches the list of blocked peers for this node.
1088
+ *
1089
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1090
+ * @returns
1091
+ */
1092
+ async getBlocklist(requestOptions) {
1093
+ return connectivity.getBlocklist(this.getRequestOptionsForCall(requestOptions));
917
1094
  }
918
1095
  /**
919
- * Get list of peers for this node
1096
+ * Gets list of peers for this node.
1097
+ *
1098
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
920
1099
  */
921
- async getPeers(options) {
922
- return connectivity.getPeers(this.getRequestOptionsForCall(options));
1100
+ async getPeers(requestOptions) {
1101
+ return connectivity.getPeers(this.getRequestOptionsForCall(requestOptions));
923
1102
  }
924
- async removePeer(peer, options) {
1103
+ /**
1104
+ * Disconnects from a specific peer.
1105
+ *
1106
+ * @param peer Overlay address of the peer to be removed.
1107
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1108
+ * @returns
1109
+ */
1110
+ async removePeer(peer, requestOptions) {
925
1111
  peer = new typed_bytes_1.PeerAddress(peer);
926
- return connectivity.removePeer(this.getRequestOptionsForCall(options), peer);
1112
+ return connectivity.removePeer(this.getRequestOptionsForCall(requestOptions), peer);
927
1113
  }
928
- async getTopology(options) {
929
- return connectivity.getTopology(this.getRequestOptionsForCall(options));
1114
+ /**
1115
+ * Fetches topology and connectivity information of the Bee node.
1116
+ *
1117
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1118
+ * @returns
1119
+ */
1120
+ async getTopology(requestOptions) {
1121
+ return connectivity.getTopology(this.getRequestOptionsForCall(requestOptions));
930
1122
  }
931
- async pingPeer(peer, options) {
1123
+ /**
1124
+ * Pings a specific peer to check its availability.
1125
+ *
1126
+ * @param peer Overlay address of the peer to be pinged.
1127
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1128
+ * @returns
1129
+ */
1130
+ async pingPeer(peer, requestOptions) {
932
1131
  peer = new typed_bytes_1.PeerAddress(peer);
933
- return connectivity.pingPeer(this.getRequestOptionsForCall(options), peer);
1132
+ return connectivity.pingPeer(this.getRequestOptionsForCall(requestOptions), peer);
934
1133
  }
935
- /*
936
- * Balance endpoints
937
- */
938
1134
  /**
939
- * Get the balances with all known peers including prepaid services
1135
+ * Gets the SWAP balances with all known peers including prepaid services.
1136
+ *
1137
+ * This is related to the bandwidth incentives and the chequebook.
1138
+ *
1139
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
940
1140
  */
941
- async getAllBalances(options) {
942
- return balance.getAllBalances(this.getRequestOptionsForCall(options));
1141
+ async getAllBalances(requestOptions) {
1142
+ return balance.getAllBalances(this.getRequestOptionsForCall(requestOptions));
943
1143
  }
944
1144
  /**
945
- * Get the balances with a specific peer including prepaid services
1145
+ * Gets the SWAP balances for a specific peer including prepaid services.
946
1146
  *
947
1147
  * @param address Swarm address of peer
1148
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
948
1149
  */
949
- async getPeerBalance(address, options) {
1150
+ async getPeerBalance(address, requestOptions) {
950
1151
  address = new typed_bytes_1.PeerAddress(address);
951
- return balance.getPeerBalance(this.getRequestOptionsForCall(options), address);
1152
+ return balance.getPeerBalance(this.getRequestOptionsForCall(requestOptions), address);
952
1153
  }
953
1154
  /**
954
- * Get the past due consumption balances with all known peers
1155
+ * Gets the past due consumption balances for all known peers.
1156
+ *
1157
+ * This is related to the bandwidth incentives and the chequebook.
1158
+ *
1159
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
955
1160
  */
956
- async getPastDueConsumptionBalances(options) {
957
- return balance.getPastDueConsumptionBalances(this.getRequestOptionsForCall(options));
1161
+ async getPastDueConsumptionBalances(requestOptions) {
1162
+ return balance.getPastDueConsumptionBalances(this.getRequestOptionsForCall(requestOptions));
958
1163
  }
959
1164
  /**
960
- * Get the past due consumption balance with a specific peer
1165
+ * Gets the past due consumption balance for a specific peer.
1166
+ *
1167
+ * This is related to the bandwidth incentives and the chequebook.
961
1168
  *
962
1169
  * @param address Swarm address of peer
1170
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
963
1171
  */
964
- async getPastDueConsumptionPeerBalance(address, options) {
1172
+ async getPastDueConsumptionPeerBalance(address, requestOptions) {
965
1173
  address = new typed_bytes_1.PeerAddress(address);
966
- return balance.getPastDueConsumptionPeerBalance(this.getRequestOptionsForCall(options), address);
1174
+ return balance.getPastDueConsumptionPeerBalance(this.getRequestOptionsForCall(requestOptions), address);
967
1175
  }
968
- /*
969
- * Chequebook endpoints
970
- */
971
1176
  /**
972
- * Get the address of the chequebook contract used.
1177
+ * Gets the address of the deloyed chequebook.
973
1178
  *
974
- * **Warning:** The address is returned with 0x prefix unlike all other calls.
975
- * https://github.com/ethersphere/bee/issues/1443
1179
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
976
1180
  */
977
- async getChequebookAddress(options) {
978
- return chequebook.getChequebookAddress(this.getRequestOptionsForCall(options));
1181
+ async getChequebookAddress(requestOptions) {
1182
+ return chequebook.getChequebookAddress(this.getRequestOptionsForCall(requestOptions));
979
1183
  }
980
1184
  /**
981
- * Get the balance of the chequebook
1185
+ * Gets the balance of the chequebook.
1186
+ *
1187
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
982
1188
  */
983
- async getChequebookBalance(options) {
984
- return chequebook.getChequebookBalance(this.getRequestOptionsForCall(options));
1189
+ async getChequebookBalance(requestOptions) {
1190
+ return chequebook.getChequebookBalance(this.getRequestOptionsForCall(requestOptions));
985
1191
  }
986
1192
  /**
987
- * Get last cheques for all peers
1193
+ * Gets the last cheques for all peers.
1194
+ *
1195
+ * This is related to the bandwidth incentives and the chequebook.
1196
+ *
1197
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
988
1198
  */
989
- async getLastCheques(options) {
990
- return chequebook.getLastCheques(this.getRequestOptionsForCall(options));
1199
+ async getLastCheques(requestOptions) {
1200
+ return chequebook.getLastCheques(this.getRequestOptionsForCall(requestOptions));
991
1201
  }
992
1202
  /**
993
- * Get last cheques for the peer
1203
+ * Gets the last cheques for a specific peer.
994
1204
  *
995
- * @param address Swarm address of peer
1205
+ * This is related to the bandwidth incentives and the chequebook.
1206
+ *
1207
+ * @param address Overlay address of peer.
1208
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
996
1209
  */
997
- async getLastChequesForPeer(address, options) {
1210
+ async getLastChequesForPeer(address, requestOptions) {
998
1211
  address = new typed_bytes_1.PeerAddress(address);
999
- return chequebook.getLastChequesForPeer(this.getRequestOptionsForCall(options), address);
1212
+ return chequebook.getLastChequesForPeer(this.getRequestOptionsForCall(requestOptions), address);
1000
1213
  }
1001
1214
  /**
1002
- * Get last cashout action for the peer
1215
+ * Gets the last cashout action for a specific peer.
1003
1216
  *
1004
- * @param address Swarm address of peer
1217
+ * This is related to the bandwidth incentives and the chequebook.
1218
+ *
1219
+ * @param address Overlay address of peer.
1220
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1005
1221
  */
1006
- async getLastCashoutAction(address, options) {
1222
+ async getLastCashoutAction(address, requestOptions) {
1007
1223
  address = new typed_bytes_1.PeerAddress(address);
1008
- return chequebook.getLastCashoutAction(this.getRequestOptionsForCall(options), address);
1224
+ return chequebook.getLastCashoutAction(this.getRequestOptionsForCall(requestOptions), address);
1009
1225
  }
1010
1226
  /**
1011
- * Cashout the last cheque for the peer
1227
+ * Cashes out the last cheque for a specific peer.
1228
+ *
1229
+ * This is related to the bandwidth incentives and the chequebook.
1012
1230
  *
1013
1231
  * @param address Swarm address of peer
1014
1232
  * @param options
1015
1233
  * @param options.gasPrice Gas price for the cashout transaction in WEI
1016
1234
  * @param options.gasLimit Gas limit for the cashout transaction in WEI
1235
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1017
1236
  */
1018
1237
  async cashoutLastCheque(address, options, requestOptions) {
1019
1238
  address = new typed_bytes_1.PeerAddress(address);
@@ -1023,117 +1242,151 @@ class Bee {
1023
1242
  return chequebook.cashoutLastCheque(this.getRequestOptionsForCall(requestOptions), address, options);
1024
1243
  }
1025
1244
  /**
1026
- * Deposit tokens from node wallet into chequebook
1245
+ * Deposits tokens from the node wallet into the chequebook.
1027
1246
  *
1028
1247
  * @param amount Amount of tokens to deposit (must be positive integer)
1029
1248
  * @param gasPrice Gas Price in WEI for the transaction call
1249
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1250
+ *
1030
1251
  * @return string Hash of the transaction
1031
1252
  * @deprecated Use `depositBZZToChequebook` instead.
1032
1253
  */
1033
- async depositTokens(amount, gasPrice, options) {
1034
- return this.depositBZZToChequebook(amount, gasPrice, options);
1254
+ async depositTokens(amount, gasPrice, requestOptions) {
1255
+ return this.depositBZZToChequebook(amount, gasPrice, requestOptions);
1035
1256
  }
1036
1257
  /**
1037
- * Deposit tokens from node wallet into chequebook
1258
+ * Deposits tokens from the node wallet into the chequebook.
1038
1259
  *
1039
1260
  * @param amount Amount of tokens to deposit (must be positive integer)
1040
1261
  * @param gasPrice Gas Price in WEI for the transaction call
1262
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1263
+ *
1041
1264
  * @return string Hash of the transaction
1042
1265
  */
1043
- async depositBZZToChequebook(amount, gasPrice, options) {
1266
+ async depositBZZToChequebook(amount, gasPrice, requestOptions) {
1044
1267
  const amountString = amount instanceof tokens_1.BZZ ? amount.toPLURString() : (0, type_1.asNumberString)(amount, { min: 1n, name: 'amount' });
1045
1268
  let gasPriceString;
1046
1269
  if (gasPrice) {
1047
1270
  gasPriceString = (0, type_1.asNumberString)(amount, { min: 0n, name: 'gasPrice' });
1048
1271
  }
1049
- return chequebook.depositTokens(this.getRequestOptionsForCall(options), amountString, gasPriceString);
1272
+ return chequebook.depositTokens(this.getRequestOptionsForCall(requestOptions), amountString, gasPriceString);
1050
1273
  }
1051
1274
  /**
1052
- * Withdraw tokens from the chequebook to the node wallet
1275
+ * Withdraws tokens from the chequebook to the node wallet.
1053
1276
  *
1054
1277
  * @param amount Amount of tokens to withdraw (must be positive integer)
1055
1278
  * @param gasPrice Gas Price in WEI for the transaction call
1279
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1280
+ *
1056
1281
  * @return string Hash of the transaction
1057
1282
  * @deprecated Use `withdrawBZZFromChequebook` instead.
1058
1283
  */
1059
- async withdrawTokens(amount, gasPrice, options) {
1060
- return this.withdrawBZZFromChequebook(amount, gasPrice, options);
1284
+ async withdrawTokens(amount, gasPrice, requestOptions) {
1285
+ return this.withdrawBZZFromChequebook(amount, gasPrice, requestOptions);
1061
1286
  }
1062
1287
  /**
1063
- * Withdraw tokens from the chequebook to the node wallet
1288
+ * Withdraws tokens from the chequebook to the node wallet.
1064
1289
  *
1065
- * @param amount Amount of tokens to withdraw (must be positive integer)
1066
- * @param gasPrice Gas Price in WEI for the transaction call
1067
- * @return string Hash of the transaction
1290
+ * @param amount Amount of BZZ tokens to withdraw. If not providing a `BZZ` instance, the amount is denoted in PLUR.
1291
+ * @param gasPrice Gas Price in WEI for the transaction call.
1292
+ * @return Transaction ID
1068
1293
  */
1069
- async withdrawBZZFromChequebook(amount, gasPrice, options) {
1294
+ async withdrawBZZFromChequebook(amount, gasPrice, requestOptions) {
1070
1295
  // TODO: check BZZ in tests
1071
1296
  const amountString = amount instanceof tokens_1.BZZ ? amount.toPLURString() : (0, type_1.asNumberString)(amount, { min: 1n, name: 'amount' });
1072
1297
  let gasPriceString;
1073
1298
  if (gasPrice) {
1074
1299
  gasPriceString = (0, type_1.asNumberString)(amount, { min: 0n, name: 'gasPrice' });
1075
1300
  }
1076
- return chequebook.withdrawTokens(this.getRequestOptionsForCall(options), amountString, gasPriceString);
1301
+ return chequebook.withdrawTokens(this.getRequestOptionsForCall(requestOptions), amountString, gasPriceString);
1077
1302
  }
1078
- async withdrawBZZToExternalWallet(amount, address, options) {
1303
+ /**
1304
+ * Withdraws BZZ from the node wallet (not chequebook) to a whitelisted external wallet address.
1305
+ *
1306
+ * @param amount Amount of BZZ tokens to withdraw. If not providing a `BZZ` instance, the amount is denoted in PLUR.
1307
+ * @param address
1308
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1309
+ * @return Transaction ID
1310
+ */
1311
+ async withdrawBZZToExternalWallet(amount, address, requestOptions) {
1079
1312
  amount = amount instanceof tokens_1.BZZ ? amount : tokens_1.BZZ.fromPLUR(amount);
1080
1313
  address = new typed_bytes_1.EthAddress(address);
1081
- return states.withdrawBZZ(this.getRequestOptionsForCall(options), amount, address);
1314
+ return states.withdrawBZZ(this.getRequestOptionsForCall(requestOptions), amount, address);
1082
1315
  }
1083
- async withdrawDAIToExternalWallet(amount, address, options) {
1316
+ /**
1317
+ * Withdraws DAI from the node wallet (not chequebook) to a whitelisted external wallet address.
1318
+ *
1319
+ * @param amount Amount of DAI tokens to withdraw. If not providing a `DAI` instance, the amount is denoted in wei.
1320
+ * @param address
1321
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1322
+ * @return Transaction ID
1323
+ */
1324
+ async withdrawDAIToExternalWallet(amount, address, requestOptions) {
1084
1325
  amount = amount instanceof tokens_1.DAI ? amount : tokens_1.DAI.fromWei(amount);
1085
1326
  address = new typed_bytes_1.EthAddress(address);
1086
- return states.withdrawDAI(this.getRequestOptionsForCall(options), amount, address);
1327
+ return states.withdrawDAI(this.getRequestOptionsForCall(requestOptions), amount, address);
1087
1328
  }
1088
- /*
1089
- * Settlements endpoint
1090
- */
1091
1329
  /**
1092
- * Get amount of sent and received from settlements with a peer
1330
+ * Gets the amount of sent and received micropayments from settlements with a peer.
1331
+ *
1332
+ * This is related to the bandwidth incentives and the chequebook.
1093
1333
  *
1094
1334
  * @param address Swarm address of peer
1335
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1095
1336
  */
1096
- async getSettlements(address, options) {
1337
+ async getSettlements(address, requestOptions) {
1097
1338
  address = new typed_bytes_1.PeerAddress(address);
1098
- return settlements.getSettlements(this.getRequestOptionsForCall(options), address);
1339
+ return settlements.getSettlements(this.getRequestOptionsForCall(requestOptions), address);
1099
1340
  }
1100
1341
  /**
1101
- * Get settlements with all known peers and total amount sent or received
1342
+ * Gets settlements with all known peers and total amount sent or received.
1343
+ *
1344
+ * This is related to the bandwidth incentives and the chequebook.
1345
+ *
1346
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1102
1347
  */
1103
- async getAllSettlements(options) {
1104
- return settlements.getAllSettlements(this.getRequestOptionsForCall(options));
1348
+ async getAllSettlements(requestOptions) {
1349
+ return settlements.getAllSettlements(this.getRequestOptionsForCall(requestOptions));
1105
1350
  }
1106
1351
  /**
1107
- * Get status of node
1352
+ * Gets the general status of the node.
1353
+ *
1354
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1108
1355
  */
1109
- async getStatus(options) {
1110
- return debugStatus.getDebugStatus(this.getRequestOptionsForCall(options));
1356
+ async getStatus(requestOptions) {
1357
+ return debugStatus.getDebugStatus(this.getRequestOptionsForCall(requestOptions));
1111
1358
  }
1112
1359
  /**
1113
- * Get health of node
1360
+ * Gets the health of the node.
1361
+ *
1362
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1114
1363
  */
1115
- async getHealth(options) {
1116
- return debugStatus.getHealth(this.getRequestOptionsForCall(options));
1364
+ async getHealth(requestOptions) {
1365
+ return debugStatus.getHealth(this.getRequestOptionsForCall(requestOptions));
1117
1366
  }
1118
1367
  /**
1119
- * Get readiness of node
1368
+ * Gets the readiness status of the node.
1369
+ *
1370
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1120
1371
  */
1121
- async getReadiness(options) {
1122
- return debugStatus.getReadiness(this.getRequestOptionsForCall(options));
1372
+ async getReadiness(requestOptions) {
1373
+ return debugStatus.getReadiness(this.getRequestOptionsForCall(requestOptions));
1123
1374
  }
1124
1375
  /**
1125
- * Get mode information of node
1376
+ * Get mode information of node.
1377
+ *
1378
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1126
1379
  */
1127
- async getNodeInfo(options) {
1128
- return debugStatus.getNodeInfo(this.getRequestOptionsForCall(options));
1380
+ async getNodeInfo(requestOptions) {
1381
+ return debugStatus.getNodeInfo(this.getRequestOptionsForCall(requestOptions));
1129
1382
  }
1130
1383
  /**
1131
1384
  * Connects to a node and checks if its version matches with the one that bee-js supports.
1132
1385
  *
1133
- * @param options
1386
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1134
1387
  */
1135
- async isSupportedExactVersion(options) {
1136
- return debugStatus.isSupportedExactVersion(this.getRequestOptionsForCall(options));
1388
+ async isSupportedExactVersion(requestOptions) {
1389
+ return debugStatus.isSupportedExactVersion(this.getRequestOptionsForCall(requestOptions));
1137
1390
  }
1138
1391
  /**
1139
1392
  *
@@ -1141,53 +1394,56 @@ class Bee {
1141
1394
  *
1142
1395
  * This should be the main way how to check compatibility for your app and Bee node.
1143
1396
  *
1144
- * @param options
1397
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1145
1398
  */
1146
- async isSupportedApiVersion(options) {
1147
- return debugStatus.isSupportedApiVersion(this.getRequestOptionsForCall(options));
1399
+ async isSupportedApiVersion(requestOptions) {
1400
+ return debugStatus.isSupportedApiVersion(this.getRequestOptionsForCall(requestOptions));
1148
1401
  }
1149
1402
  /**
1150
1403
  * Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
1151
1404
  * and versions that bee-js supports (properties prefixed with `supported*`).
1152
1405
  *
1153
- * @param options
1406
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1154
1407
  */
1155
- async getVersions(options) {
1156
- return debugStatus.getVersions(this.getRequestOptionsForCall(options));
1408
+ async getVersions(requestOptions) {
1409
+ return debugStatus.getVersions(this.getRequestOptionsForCall(requestOptions));
1157
1410
  }
1158
1411
  /**
1159
- * Get reserve state
1412
+ * Get reserve state.
1413
+ *
1414
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1160
1415
  */
1161
- async getReserveState(options) {
1162
- return states.getReserveState(this.getRequestOptionsForCall(options));
1416
+ async getReserveState(requestOptions) {
1417
+ return states.getReserveState(this.getRequestOptionsForCall(requestOptions));
1163
1418
  }
1164
1419
  /**
1165
- * Get chain state
1420
+ * Gets chain state.
1421
+ *
1422
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1166
1423
  */
1167
- async getChainState(options) {
1168
- return states.getChainState(this.getRequestOptionsForCall(options));
1424
+ async getChainState(requestOptions) {
1425
+ return states.getChainState(this.getRequestOptionsForCall(requestOptions));
1169
1426
  }
1170
1427
  /**
1171
- * Get wallet balances for DAI and BZZ of the Bee node
1428
+ * Gets DAI and BZZ balances of the Bee node wallet.
1172
1429
  *
1173
- * @param options
1430
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1174
1431
  */
1175
- async getWalletBalance(options) {
1176
- return states.getWalletBalance(this.getRequestOptionsForCall(options));
1432
+ async getWalletBalance(requestOptions) {
1433
+ return states.getWalletBalance(this.getRequestOptionsForCall(requestOptions));
1177
1434
  }
1178
1435
  /**
1179
- * Creates new postage batch from the funds that the node has available in its Ethereum account.
1436
+ * Creates a new postage batch, spending BZZ tokens from the node wallet.
1180
1437
  *
1181
- * For better understanding what each parameter means and what are the optimal values please see
1182
- * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction#keep-your-data-alive).
1438
+ * Use {@link buyStorage} for a more convenient way to create postage batch.
1183
1439
  *
1184
- * **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
1440
+ * For better understanding what each parameter means and what the optimal values are, see
1441
+ * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction#keep-your-data-alive).
1185
1442
  *
1186
- * @param amount Amount that represents the value per chunk, has to be greater or equal zero.
1187
- * @param depth Logarithm of the number of chunks that can be stamped with the batch.
1443
+ * @param amount TTL parameter - 1 day at the minimum of 24,000 storage price requires an amount of 414,720,000.
1444
+ * @param depth Capacity parameter - 17..255 - depth 17 provides 512MB of theoretical capacity, 18 provides 1GB, 19 provides 2GB, etc.
1188
1445
  * @param options Options for creation of postage batch
1189
- * @throws BeeArgumentError when negative amount or depth is specified
1190
- * @throws TypeError if non-integer value is passed to amount or depth
1446
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1191
1447
  *
1192
1448
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1193
1449
  * @see [Bee Debug API reference - `POST /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post)
@@ -1211,6 +1467,24 @@ class Bee {
1211
1467
  }
1212
1468
  return stamp;
1213
1469
  }
1470
+ /**
1471
+ * A more convenient method to create a postage batch, which is analogous
1472
+ * to buying storage for a certain size and duration on the Swarm network.
1473
+ *
1474
+ * Use {@link getStorageCost} to calculate the cost of creating a postage batch.
1475
+ *
1476
+ * For the low level API, use {@link createPostageBatch}.
1477
+ *
1478
+ * @example const batchId = await bee.buyStorage(Size.fromGigabytes(8), Duration.fromDays(31))
1479
+
1480
+ * @param size
1481
+ * @param duration
1482
+ * @param options
1483
+ * @param requestOptions
1484
+ * @param encryption
1485
+ * @param erasureCodeLevel
1486
+ * @returns
1487
+ */
1214
1488
  async buyStorage(size, duration, options, requestOptions, encryption, erasureCodeLevel) {
1215
1489
  const chainState = await this.getChainState(requestOptions);
1216
1490
  const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
@@ -1220,238 +1494,399 @@ class Bee {
1220
1494
  }
1221
1495
  return this.createPostageBatch(amount, depth, options, requestOptions);
1222
1496
  }
1223
- async getStorageCost(size, duration, options, encryption, erasureCodeLevel) {
1224
- const chainState = await this.getChainState(options);
1497
+ /**
1498
+ * Calculates the estimated BZZ cost for creating a postage batch for the given size and duration.
1499
+ *
1500
+ * Use {@link buyStorage} to create a postage batch with the calculated cost.
1501
+ *
1502
+ * @example const bzz = await bee.getStorageCost(Size.fromGigabytes(1), Duration.fromDays(30))
1503
+ *
1504
+ * @param size Size of the data to be stored.
1505
+ * @param duration Duration for which the data should be stored.
1506
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1507
+ * @param encryption Assume the future uploaded data is encrypted, which skews the capacity of the postage batch.
1508
+ * @param erasureCodeLevel Assume the future uploaded data is erasure coded, which skews the capacity of the postage batch.
1509
+ * @returns
1510
+ */
1511
+ async getStorageCost(size, duration, requestOptions, encryption, erasureCodeLevel) {
1512
+ const chainState = await this.getChainState(requestOptions);
1225
1513
  const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
1226
1514
  const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
1227
1515
  return (0, stamps_1.getStampCost)(depth, amount);
1228
1516
  }
1229
- async extendStorage(postageBatchId, size, duration, options, encryption, erasureCodeLevel) {
1230
- const batch = await this.getPostageBatch(postageBatchId, options);
1517
+ /**
1518
+ * Extends the storage of a postage batch by either increasing its size, duration or both.
1519
+ *
1520
+ * The size is ABSOLUTE, while the duration is RELATIVE to the current duration of the postage batch.
1521
+ *
1522
+ * Use {@link getExtensionCost} to calculate the cost of extending the storage.
1523
+ *
1524
+ * @example
1525
+ * // Increases the size to 8GB (unless it is already at 8GB or higher)
1526
+ * // and extends the duration by 30 days (regardless of the current duration).
1527
+ * await bee.extendStorage(batchId, Size.fromGigabytes(8), Duration.fromDays(30))
1528
+ *
1529
+ * @example
1530
+ * // To increase the duration to a desired date, pass a second parameter to `Duration.fromEndDate`.
1531
+ * // With the second parameter, the duration is set to the difference between the current end date and the desired end date.
1532
+ * const oneMonth = new Date(Date.now() + Dates.days(31))
1533
+ * const batch = await bee.getPostageBatch(batchId)
1534
+ * await bee.extendStorage(batchId, Size.fromGigabytes(8), Duration.fromEndDate(oneMonth, batch.duration.toEndDate()))
1535
+ *
1536
+ * @param postageBatchId Batch ID of the postage batch to extend.
1537
+ * @param size Absolute size to extend the postage batch to.
1538
+ * @param duration Relative duration to extend the postage batch by.
1539
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1540
+ * @param encryption Assume the future uploaded data is encrypted, which skews the capacity of the postage batch.
1541
+ * @param erasureCodeLevel Assume the future uploaded data is erasure coded, which skews the capacity of the postage batch.
1542
+ * @returns
1543
+ */
1544
+ async extendStorage(postageBatchId, size, duration, requestOptions, encryption, erasureCodeLevel) {
1545
+ const batch = await this.getPostageBatch(postageBatchId, requestOptions);
1231
1546
  const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
1232
- const chainState = await this.getChainState(options);
1547
+ const chainState = await this.getChainState(requestOptions);
1233
1548
  const depthDelta = depth - batch.depth;
1234
- const multiplier = depthDelta === 0 ? 1n : 2n ** BigInt(depthDelta);
1235
- const additionalAmount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
1236
- const targetAmount = duration.isZero()
1237
- ? BigInt(batch.amount) * multiplier
1238
- : (BigInt(batch.amount) + additionalAmount) * multiplier;
1239
- const amountDelta = targetAmount - BigInt(batch.amount);
1240
- const transactionId = await this.topUpBatch(batch.batchID, amountDelta, options);
1241
- if (depthDelta) {
1242
- return this.diluteBatch(batch.batchID, depth, options);
1549
+ const multiplier = depthDelta <= 0 ? 1n : 2n ** BigInt(depthDelta);
1550
+ const blockTime = this.network === 'gnosis' ? 5 : 15;
1551
+ const additionalAmount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, blockTime);
1552
+ const currentAmount = (0, stamps_1.getAmountForDuration)(batch.duration, chainState.currentPrice, blockTime);
1553
+ const targetAmount = duration.isZero() ? currentAmount * multiplier : currentAmount + additionalAmount * multiplier;
1554
+ const amountDelta = targetAmount - currentAmount;
1555
+ const transactionId = await this.topUpBatch(batch.batchID, amountDelta, requestOptions);
1556
+ if (depthDelta > 0) {
1557
+ return this.diluteBatch(batch.batchID, depth, requestOptions);
1243
1558
  }
1244
1559
  return transactionId;
1245
1560
  }
1246
- async extendStorageSize(postageBatchId, size, options, encryption, erasureCodeLevel) {
1247
- const batch = await this.getPostageBatch(postageBatchId, options);
1561
+ /**
1562
+ * Extends the storage size of a postage batch by increasing its depth.
1563
+ *
1564
+ * Use {@link getSizeExtensionCost} to calculate the cost of extending the size.
1565
+ * Use {@link extendStorage} to extend both size and duration.
1566
+ *
1567
+ * @param postageBatchId
1568
+ * @param size Absolute size to extend the postage batch to.
1569
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1570
+ * @param encryption Assume the future uploaded data is encrypted, which skews the capacity of the postage batch.
1571
+ * @param erasureCodeLevel Assume the future uploaded data is erasure coded, which skews the capacity of the postage batch.
1572
+ * @returns
1573
+ */
1574
+ async extendStorageSize(postageBatchId, size, requestOptions, encryption, erasureCodeLevel) {
1575
+ const chainState = await this.getChainState(requestOptions);
1576
+ const batch = await this.getPostageBatch(postageBatchId, requestOptions);
1248
1577
  const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
1249
1578
  const delta = depth - batch.depth;
1250
1579
  if (delta <= 0) {
1251
1580
  throw new error_1.BeeArgumentError('New depth has to be greater than the original depth', depth);
1252
1581
  }
1253
- await this.topUpBatch(batch.batchID, BigInt(batch.amount) * (2n ** BigInt(delta) - 1n) + 1n, options);
1254
- return this.diluteBatch(batch.batchID, depth, options);
1582
+ const currentAmount = (0, stamps_1.getAmountForDuration)(batch.duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
1583
+ await this.topUpBatch(batch.batchID, currentAmount * (2n ** BigInt(delta) - 1n) + 1n, requestOptions);
1584
+ return this.diluteBatch(batch.batchID, depth, requestOptions);
1255
1585
  }
1256
- async extendStorageDuration(postageBatchId, duration, options) {
1257
- const batch = await this.getPostageBatch(postageBatchId, options);
1258
- const chainState = await this.getChainState(options);
1586
+ /**
1587
+ * Extends the duration of a postage batch.
1588
+ *
1589
+ * Use {@link getDurationExtensionCost} to calculate the cost of extending the duration.
1590
+ * Use {@link extendStorage} to extend both size and duration.
1591
+ *
1592
+ * @param postageBatchId
1593
+ * @param duration Relative duration to extend the postage batch by.
1594
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1595
+ * @returns
1596
+ */
1597
+ async extendStorageDuration(postageBatchId, duration, requestOptions) {
1598
+ const batch = await this.getPostageBatch(postageBatchId, requestOptions);
1599
+ const chainState = await this.getChainState(requestOptions);
1259
1600
  const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
1260
- return this.topUpBatch(batch.batchID, amount, options);
1261
- }
1262
- async getExtensionCost(postageBatchId, size, duration, options, encryption, erasureCodeLevel) {
1263
- const batch = await this.getPostageBatch(postageBatchId, options);
1264
- const chainState = await this.getChainState(options);
1265
- const amount = duration.isZero()
1266
- ? 0n
1267
- : (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
1601
+ return this.topUpBatch(batch.batchID, amount, requestOptions);
1602
+ }
1603
+ /**
1604
+ * Calculates the cost of extending both the duration and the capacity of a postage batch.
1605
+ *
1606
+ * The size is ABSOLUTE, while the duration is RELATIVE to the current duration of the postage batch.
1607
+ *
1608
+ * Use {@link extendStorage} to extend the the duration and capacity of a postage batch.
1609
+ *
1610
+ * @param postageBatchId
1611
+ * @param size Absolute size to extend the postage batch to.
1612
+ * @param duration Relative duration to extend the postage batch by.
1613
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1614
+ * @param encryption Assume the future uploaded data is encrypted, which skews the capacity of the postage batch.
1615
+ * @param erasureCodeLevel Assume the future uploaded data is erasure coded, which skews the capacity of the postage batch.
1616
+ * @returns
1617
+ */
1618
+ async getExtensionCost(postageBatchId, size, duration, requestOptions, encryption, erasureCodeLevel) {
1619
+ const batch = await this.getPostageBatch(postageBatchId, requestOptions);
1620
+ const chainState = await this.getChainState(requestOptions);
1621
+ const blockTime = this.network === 'gnosis' ? 5 : 15;
1622
+ const amount = duration.isZero() ? 0n : (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, blockTime);
1268
1623
  const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
1269
- const currentCost = (0, stamps_1.getStampCost)(batch.depth, batch.amount);
1270
- const newCost = (0, stamps_1.getStampCost)(depth, BigInt(batch.amount) + amount);
1624
+ const currentAmount = (0, stamps_1.getAmountForDuration)(batch.duration, chainState.currentPrice, blockTime);
1625
+ const currentCost = (0, stamps_1.getStampCost)(batch.depth, currentAmount);
1626
+ const newCost = (0, stamps_1.getStampCost)(Math.max(batch.depth, depth), currentAmount + amount);
1271
1627
  return newCost.minus(currentCost);
1272
1628
  }
1273
- async getSizeExtensionCost(postageBatchId, size, options, encryption, erasureCodeLevel) {
1274
- const batch = await this.getPostageBatch(postageBatchId, options);
1629
+ /**
1630
+ * Calculates the cost of extending the size of a postage batch.
1631
+ *
1632
+ * The size is ABSOLUTE, so if the postage batch already equals or is greater than the given size,
1633
+ * the cost will be zero.
1634
+ *
1635
+ * Use {@link extendStorageSize} to extend the size of a postage batch.
1636
+ *
1637
+ * Use {@link getExtensionCost} to get the cost of extending both size and duration.
1638
+ * Use {@link getDurationExtensionCost} to get the cost of extending only the duration.
1639
+ *
1640
+ * @param postageBatchId
1641
+ * @param size
1642
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1643
+ * @param encryption Assume the future uploaded data is encrypted, which skews the capacity of the postage batch.
1644
+ * @param erasureCodeLevel Assume the future uploaded data is erasure coded, which skews the capacity of the postage batch.
1645
+ * @returns
1646
+ */
1647
+ async getSizeExtensionCost(postageBatchId, size, requestOptions, encryption, erasureCodeLevel) {
1648
+ const batch = await this.getPostageBatch(postageBatchId, requestOptions);
1649
+ const chainState = await this.getChainState(requestOptions);
1275
1650
  const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
1276
1651
  const delta = depth - batch.depth;
1277
1652
  if (delta <= 0) {
1278
1653
  throw new error_1.BeeArgumentError('New depth has to be greater than the original depth', depth);
1279
1654
  }
1280
- const currentCost = (0, stamps_1.getStampCost)(batch.depth, batch.amount);
1281
- const newCost = (0, stamps_1.getStampCost)(depth, batch.amount);
1655
+ const currentAmount = (0, stamps_1.getAmountForDuration)(batch.duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
1656
+ const currentCost = (0, stamps_1.getStampCost)(batch.depth, currentAmount);
1657
+ const newCost = (0, stamps_1.getStampCost)(depth, currentAmount);
1282
1658
  return newCost.minus(currentCost);
1283
1659
  }
1284
- async getDurationExtensionCost(postageBatchId, duration, options) {
1285
- const batch = await this.getPostageBatch(postageBatchId, options);
1286
- const chainState = await this.getChainState(options);
1660
+ /**
1661
+ * Calculates the cost of extending the duration of a postage batch.
1662
+ *
1663
+ * The duration is RELATIVE to the current duration of the postage batch,
1664
+ * e.g. specifying `Duration.fromDays(30)` will extend the current duration by 30 days,
1665
+ * regardless of the current duration.
1666
+ *
1667
+ * Use {@link extendStorageDuration} to extend the duration of a postage batch.
1668
+ *
1669
+ * Use {@link getExtensionCost} to get the cost of extending both size and duration.
1670
+ * Use {@link getSizeExtensionCost} to get the cost of extending only the size.
1671
+ *
1672
+ * @param postageBatchId
1673
+ * @param duration
1674
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1675
+ * @returns
1676
+ */
1677
+ async getDurationExtensionCost(postageBatchId, duration, requestOptions) {
1678
+ const batch = await this.getPostageBatch(postageBatchId, requestOptions);
1679
+ const chainState = await this.getChainState(requestOptions);
1287
1680
  const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
1288
1681
  return (0, stamps_1.getStampCost)(batch.depth, amount);
1289
1682
  }
1290
1683
  /**
1291
- * Topup a fresh amount of BZZ to given Postage Batch.
1684
+ * Increases the duration of a postage batch by increasing its amount.
1685
+ *
1686
+ * For a more convenient way to extend the postage batch, refer to the methods below.
1687
+ *
1688
+ * Use {@link getDurationExtensionCost}, {@link getSizeExtensionCost} or {@link getExtensionCost}
1689
+ * to calculate the costs of extending the postage batch properties.
1690
+ *
1691
+ * Use {@link extendStorageDuration}, {@link extendStorageSize} or {@link extendStorage}
1692
+ * to extend the postage batch properties.
1292
1693
  *
1293
1694
  * For better understanding what each parameter means and what are the optimal values please see
1294
1695
  * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive).
1295
1696
  *
1296
1697
  * @param postageBatchId Batch ID
1297
1698
  * @param amount Amount to be added to the batch
1298
- * @param options Request options
1699
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1299
1700
  *
1300
1701
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1301
1702
  * @see [Bee Debug API reference - `PATCH /stamps/topup/${id}/${amount}`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1topup~1{batch_id}~1{amount}/patch)
1302
1703
  */
1303
- async topUpBatch(postageBatchId, amount, options) {
1704
+ async topUpBatch(postageBatchId, amount, requestOptions) {
1304
1705
  postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
1305
1706
  const amountString = (0, type_1.asNumberString)(amount, { min: 1n, name: 'amount' });
1306
- return stamps.topUpBatch(this.getRequestOptionsForCall(options), postageBatchId, amountString);
1707
+ return stamps.topUpBatch(this.getRequestOptionsForCall(requestOptions), postageBatchId, amountString);
1307
1708
  }
1308
1709
  /**
1309
- * Dilute given Postage Batch with new depth (that has to be bigger then the original depth), which allows
1310
- * the Postage Batch to be used for more chunks.
1710
+ * Dilutes a postage batch to extend its capacity by increasing its depth.
1711
+ *
1712
+ * This is a free operation, as for every depth increase, the capacity is doubled,
1713
+ * but the amount (duration) is halved.
1714
+ *
1715
+ * To increase the capacity of the postage batch while retaining the same amount (duration),
1716
+ * you need to top up the postage batch first using {@link topUpBatch}.
1717
+ *
1718
+ * For a more convenient way to extend the postage batch, refer to the methods below.
1719
+ *
1720
+ * Use {@link getDurationExtensionCost}, {@link getSizeExtensionCost} or {@link getExtensionCost}
1721
+ * to calculate the costs of extending the postage batch properties.
1722
+ *
1723
+ * Use {@link extendStorageDuration}, {@link extendStorageSize} or {@link extendStorage}
1724
+ * to extend the postage batch properties.
1311
1725
  *
1312
1726
  * For better understanding what each parameter means and what are the optimal values please see
1313
1727
  * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive).
1314
1728
  *
1315
1729
  * @param postageBatchId Batch ID
1316
1730
  * @param depth Amount to be added to the batch
1317
- * @param options Request options
1731
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1318
1732
  *
1319
1733
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1320
1734
  * @see [Bee Debug API reference - `PATCH /stamps/topup/${id}/${amount}`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1dilute~1%7Bbatch_id%7D~1%7Bdepth%7D/patch)
1321
1735
  */
1322
- async diluteBatch(postageBatchId, depth, options) {
1736
+ async diluteBatch(postageBatchId, depth, requestOptions) {
1323
1737
  postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
1324
1738
  depth = cafe_utility_1.Types.asNumber(depth, { name: 'depth', min: 18, max: 255 });
1325
- return stamps.diluteBatch(this.getRequestOptionsForCall(options), postageBatchId, depth);
1739
+ return stamps.diluteBatch(this.getRequestOptionsForCall(requestOptions), postageBatchId, depth);
1326
1740
  }
1327
1741
  /**
1328
- * Return details for specific postage batch.
1742
+ * Returns details for specific postage batch.
1329
1743
  *
1330
1744
  * @param postageBatchId Batch ID
1745
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1746
+ * @param encryption Assume that uploads with this postage batch are encrypted, which skews the capacity.
1747
+ * @param erasureCodeLevel Assume that uploads with this postage batch are erasure coded, which skews the capacity.
1331
1748
  *
1332
1749
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1333
1750
  * @see [Bee Debug API reference - `GET /stamps/${id}`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1%7Bbatch_id%7D/get)
1334
1751
  */
1335
- async getPostageBatch(postageBatchId, options) {
1752
+ async getPostageBatch(postageBatchId, requestOptions, encryption, erasureCodeLevel) {
1336
1753
  postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
1337
- return stamps.getPostageBatch(this.getRequestOptionsForCall(options), postageBatchId);
1754
+ return stamps.getPostageBatch(this.getRequestOptionsForCall(requestOptions), postageBatchId, encryption, erasureCodeLevel);
1338
1755
  }
1339
1756
  /**
1340
1757
  * Return detailed information related to buckets for specific postage batch.
1341
1758
  *
1342
1759
  * @param postageBatchId Batch ID
1760
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1343
1761
  *
1344
1762
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1345
1763
  * @see [Bee Debug API reference - `GET /stamps/${id}/buckets`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1%7Bbatch_id%7D~1buckets/get)
1346
1764
  */
1347
- async getPostageBatchBuckets(postageBatchId, options) {
1765
+ async getPostageBatchBuckets(postageBatchId, requestOptions) {
1348
1766
  postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
1349
- return stamps.getPostageBatchBuckets(this.getRequestOptionsForCall(options), postageBatchId);
1767
+ return stamps.getPostageBatchBuckets(this.getRequestOptionsForCall(requestOptions), postageBatchId);
1350
1768
  }
1351
1769
  /**
1352
- * Return all postage batches that has the node available.
1770
+ * Returns all postage batches that belongs to the node.
1771
+ *
1772
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1353
1773
  *
1354
1774
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1355
1775
  * @see [Bee Debug API reference - `GET /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps/get)
1356
1776
  * @deprecated Use `getPostageBatches` instead
1357
1777
  */
1358
- async getAllPostageBatch(options) {
1359
- return stamps.getAllPostageBatches(this.getRequestOptionsForCall(options)); // TODO: remove in June 2025
1778
+ async getAllPostageBatch(requestOptions) {
1779
+ return stamps.getAllPostageBatches(this.getRequestOptionsForCall(requestOptions)); // TODO: remove in June 2025
1360
1780
  }
1361
1781
  /**
1362
- * Return all globally available postage batches.
1782
+ * Returns all postage batches that are globally available on the Swarm network.
1783
+ *
1784
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1785
+ *
1363
1786
  * @deprecated Use `getGlobalPostageBatches` instead
1364
1787
  */
1365
- async getAllGlobalPostageBatch(options) {
1366
- return stamps.getGlobalPostageBatches(this.getRequestOptionsForCall(options)); // TODO: remove in June 2025
1788
+ async getAllGlobalPostageBatch(requestOptions) {
1789
+ return stamps.getGlobalPostageBatches(this.getRequestOptionsForCall(requestOptions)); // TODO: remove in June 2025
1367
1790
  }
1368
1791
  /**
1369
- * Return all postage batches that belong to the node.
1792
+ * Returns all postage batches that belong to the node.
1793
+ *
1794
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1370
1795
  *
1371
1796
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1372
1797
  * @see [Bee Debug API reference - `GET /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps/get)
1373
1798
  */
1374
- async getPostageBatches(options) {
1375
- return stamps.getAllPostageBatches(this.getRequestOptionsForCall(options));
1799
+ async getPostageBatches(requestOptions) {
1800
+ return stamps.getAllPostageBatches(this.getRequestOptionsForCall(requestOptions));
1376
1801
  }
1377
1802
  /**
1378
- * Return all globally available postage batches.
1803
+ * Returns all globally available postage batches.
1804
+ *
1805
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1379
1806
  */
1380
- async getGlobalPostageBatches(options) {
1381
- return stamps.getGlobalPostageBatches(this.getRequestOptionsForCall(options));
1807
+ async getGlobalPostageBatches(requestOptions) {
1808
+ return stamps.getGlobalPostageBatches(this.getRequestOptionsForCall(requestOptions));
1382
1809
  }
1383
1810
  /**
1384
- * Return lists of all current pending transactions that the Bee made
1811
+ * Fetches the list of all current pending transactions for the Bee node.
1812
+ *
1813
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1385
1814
  */
1386
- async getAllPendingTransactions(options) {
1387
- return transactions.getAllTransactions(this.getRequestOptionsForCall(options));
1815
+ async getAllPendingTransactions(requestOptions) {
1816
+ return transactions.getAllTransactions(this.getRequestOptionsForCall(requestOptions));
1388
1817
  }
1389
1818
  /**
1390
- * Return transaction information for specific transaction
1819
+ * Fetches the transaction information for a specific transaction.
1820
+ *
1391
1821
  * @param transactionHash
1822
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1392
1823
  */
1393
- async getPendingTransaction(transactionHash, options) {
1824
+ async getPendingTransaction(transactionHash, requestOptions) {
1394
1825
  transactionHash = new typed_bytes_1.TransactionId(transactionHash);
1395
- return transactions.getTransaction(this.getRequestOptionsForCall(options), transactionHash);
1826
+ return transactions.getTransaction(this.getRequestOptionsForCall(requestOptions), transactionHash);
1396
1827
  }
1397
1828
  /**
1398
- * Rebroadcast already created transaction.
1399
- * This is mainly needed when your transaction fall off mempool from other reason is not incorporated into block.
1829
+ * Rebroadcasts already created transaction.
1830
+ *
1831
+ * This is mainly needed when the transaction falls off mempool or is not incorporated into any block.
1400
1832
  *
1401
1833
  * @param transactionHash
1834
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1402
1835
  */
1403
- async rebroadcastPendingTransaction(transactionHash, options) {
1836
+ async rebroadcastPendingTransaction(transactionHash, requestOptions) {
1404
1837
  transactionHash = new typed_bytes_1.TransactionId(transactionHash);
1405
- return transactions.rebroadcastTransaction(this.getRequestOptionsForCall(options), transactionHash);
1838
+ return transactions.rebroadcastTransaction(this.getRequestOptionsForCall(requestOptions), transactionHash);
1406
1839
  }
1407
1840
  /**
1408
- * Cancels a currently pending transaction
1841
+ * Cancels a currently pending transaction.
1842
+ *
1409
1843
  * @param transactionHash
1410
1844
  * @param gasPrice
1845
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1411
1846
  */
1412
- async cancelPendingTransaction(transactionHash, gasPrice, options) {
1847
+ async cancelPendingTransaction(transactionHash, gasPrice, requestOptions) {
1413
1848
  transactionHash = new typed_bytes_1.TransactionId(transactionHash);
1414
1849
  let gasPriceString;
1415
1850
  if (gasPrice) {
1416
1851
  gasPriceString = (0, type_1.asNumberString)(gasPrice, { min: 0n, name: 'gasPrice' });
1417
1852
  }
1418
- return transactions.cancelTransaction(this.getRequestOptionsForCall(options), transactionHash, gasPriceString);
1853
+ return transactions.cancelTransaction(this.getRequestOptionsForCall(requestOptions), transactionHash, gasPriceString);
1419
1854
  }
1420
1855
  /**
1421
- * Gets the amount of staked BZZ
1856
+ * Gets the amount of staked BZZ.
1422
1857
  *
1423
- * @param options HTTP request options, such as `headers` or `timeout`
1858
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1424
1859
  */
1425
- async getStake(options) {
1426
- return stake.getStake(this.getRequestOptionsForCall(options));
1860
+ async getStake(requestOptions) {
1861
+ return stake.getStake(this.getRequestOptionsForCall(requestOptions));
1427
1862
  }
1428
1863
  /**
1429
1864
  * Gets the amount of withdrawable staked BZZ.
1430
1865
  *
1431
- * @param options HTTP request options, such as `headers` or `timeout`
1866
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1432
1867
  */
1433
- async getWithdrawableStake(options) {
1434
- return stake.getWithdrawableStake(this.getRequestOptionsForCall(options));
1868
+ async getWithdrawableStake(requestOptions) {
1869
+ return stake.getWithdrawableStake(this.getRequestOptionsForCall(requestOptions));
1435
1870
  }
1436
1871
  /**
1437
- * Withdraws ALL surplus staked BZZ to the node wallet.
1872
+ * Withdraws all surplus staked BZZ to the node wallet.
1438
1873
  *
1439
- * Use the `getWithdrawableStake` method to check how much surplus stake is available.
1874
+ * Use the {@link getWithdrawableStake} method to check how much surplus stake is available.
1440
1875
  *
1441
- * @param options HTTP request options, such as `headers` or `timeout`
1876
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1442
1877
  */
1443
- async withdrawSurplusStake(options) {
1444
- return stake.withdrawSurplusStake(this.getRequestOptionsForCall(options));
1878
+ async withdrawSurplusStake(requestOptions) {
1879
+ return stake.withdrawSurplusStake(this.getRequestOptionsForCall(requestOptions));
1445
1880
  }
1446
1881
  /**
1447
1882
  * Withdraws all staked BZZ to the node wallet.
1448
1883
  *
1449
1884
  * **Only available when the staking contract is paused and is in the process of being migrated to a new contract!**
1450
1885
  *
1451
- * @param options HTTP request options, such as `headers` or `timeout`
1886
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1452
1887
  */
1453
- async migrateStake(options) {
1454
- return stake.migrateStake(this.getRequestOptionsForCall(options));
1888
+ async migrateStake(requestOptions) {
1889
+ return stake.migrateStake(this.getRequestOptionsForCall(requestOptions));
1455
1890
  }
1456
1891
  /**
1457
1892
  * Stakes the given amount of BZZ. Initial deposit must be at least 10 BZZ.
@@ -1459,7 +1894,8 @@ class Bee {
1459
1894
  * Be aware that staked BZZ tokens can **not** be withdrawn.
1460
1895
  *
1461
1896
  * @param amount Amount of BZZ tokens to be staked. If not providing a `BZZ` instance, the amount is denoted in PLUR.
1462
- * @param options HTTP request options, such as `headers` or `timeout`
1897
+ * @param options
1898
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1463
1899
  */
1464
1900
  async depositStake(amount, options, requestOptions) {
1465
1901
  const amountString = amount instanceof tokens_1.BZZ ? amount.toPLURString() : (0, type_1.asNumberString)(amount, { min: 1n, name: 'amount' });
@@ -1469,12 +1905,14 @@ class Bee {
1469
1905
  return stake.stake(this.getRequestOptionsForCall(requestOptions), amountString, options);
1470
1906
  }
1471
1907
  /**
1472
- * Gets current status of node in redistribution game
1908
+ * Gets current status of node in redistribution game.
1473
1909
  *
1474
- * @param options HTTP request options, such as `headers` or `timeout`
1910
+ * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1911
+ *
1912
+ * @see [Bee API reference - `GET /redistributionstate`](https://docs.ethswarm.org/api/#tag/RedistributionState/paths/~1redistributionstate/get)
1475
1913
  */
1476
- async getRedistributionState(options) {
1477
- return stake.getRedistributionState(this.getRequestOptionsForCall(options));
1914
+ async getRedistributionState(requestOptions) {
1915
+ return stake.getRedistributionState(this.getRequestOptionsForCall(requestOptions));
1478
1916
  }
1479
1917
  async waitForUsablePostageStamp(id, timeout = 240000) {
1480
1918
  const TIME_STEP = 3000;
@@ -1492,11 +1930,11 @@ class Bee {
1492
1930
  }
1493
1931
  throw new error_1.BeeError('Timeout on waiting for postage stamp to become usable');
1494
1932
  }
1495
- getRequestOptionsForCall(options) {
1496
- if (options) {
1497
- options = (0, type_1.prepareBeeRequestOptions)(options);
1933
+ getRequestOptionsForCall(requestOptions) {
1934
+ if (requestOptions) {
1935
+ requestOptions = (0, type_1.prepareBeeRequestOptions)(requestOptions);
1498
1936
  }
1499
- return options ? cafe_utility_1.Objects.deepMerge2(this.requestOptions, options) : this.requestOptions;
1937
+ return requestOptions ? cafe_utility_1.Objects.deepMerge2(this.requestOptions, requestOptions) : this.requestOptions;
1500
1938
  }
1501
1939
  }
1502
1940
  exports.Bee = Bee;