@upcoming/bee-js 9.9.1 → 11.1.0

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