@ethersphere/bee-js 5.2.0 → 6.0.0-pre.1

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 (111) hide show
  1. package/dist/cjs/bee-debug.js +58 -72
  2. package/dist/cjs/bee.js +71 -86
  3. package/dist/cjs/chunk/soc.js +14 -14
  4. package/dist/cjs/feed/index.js +20 -21
  5. package/dist/cjs/feed/json.js +2 -2
  6. package/dist/cjs/feed/retrievable.js +7 -8
  7. package/dist/cjs/index.js +7 -7
  8. package/dist/cjs/modules/bytes.js +15 -15
  9. package/dist/cjs/modules/bzz.js +24 -25
  10. package/dist/cjs/modules/chunk.js +10 -10
  11. package/dist/cjs/modules/debug/balance.js +16 -16
  12. package/dist/cjs/modules/debug/chequebook.js +34 -34
  13. package/dist/cjs/modules/debug/chunk.js +8 -8
  14. package/dist/cjs/modules/debug/connectivity.js +24 -24
  15. package/dist/cjs/modules/debug/settlements.js +8 -8
  16. package/dist/cjs/modules/debug/stake.js +11 -11
  17. package/dist/cjs/modules/debug/stamps.js +25 -25
  18. package/dist/cjs/modules/debug/states.js +12 -12
  19. package/dist/cjs/modules/debug/status.js +24 -24
  20. package/dist/cjs/modules/debug/tag.js +4 -4
  21. package/dist/cjs/modules/debug/transactions.js +16 -16
  22. package/dist/cjs/modules/feed.js +14 -14
  23. package/dist/cjs/modules/pinning.js +14 -14
  24. package/dist/cjs/modules/pss.js +6 -6
  25. package/dist/cjs/modules/soc.js +6 -6
  26. package/dist/cjs/modules/status.js +3 -3
  27. package/dist/cjs/modules/stewardship.js +7 -7
  28. package/dist/cjs/modules/tag.js +20 -20
  29. package/dist/cjs/utils/error.js +1 -35
  30. package/dist/cjs/utils/headers.js +3 -3
  31. package/dist/cjs/utils/http.js +14 -141
  32. package/dist/cjs/utils/type.js +1 -4
  33. package/dist/index.browser.min.js +1 -1
  34. package/dist/index.browser.min.js.LICENSE.txt +0 -8
  35. package/dist/index.browser.min.js.map +1 -1
  36. package/dist/mjs/bee-debug.js +59 -73
  37. package/dist/mjs/bee.js +72 -87
  38. package/dist/mjs/chunk/soc.js +14 -14
  39. package/dist/mjs/feed/index.js +20 -21
  40. package/dist/mjs/feed/json.js +2 -2
  41. package/dist/mjs/feed/retrievable.js +7 -8
  42. package/dist/mjs/index.js +2 -2
  43. package/dist/mjs/modules/bytes.js +15 -15
  44. package/dist/mjs/modules/bzz.js +24 -25
  45. package/dist/mjs/modules/chunk.js +10 -10
  46. package/dist/mjs/modules/debug/balance.js +16 -16
  47. package/dist/mjs/modules/debug/chequebook.js +34 -34
  48. package/dist/mjs/modules/debug/chunk.js +8 -8
  49. package/dist/mjs/modules/debug/connectivity.js +24 -24
  50. package/dist/mjs/modules/debug/settlements.js +8 -8
  51. package/dist/mjs/modules/debug/stake.js +11 -11
  52. package/dist/mjs/modules/debug/stamps.js +25 -25
  53. package/dist/mjs/modules/debug/states.js +12 -12
  54. package/dist/mjs/modules/debug/status.js +24 -25
  55. package/dist/mjs/modules/debug/tag.js +4 -4
  56. package/dist/mjs/modules/debug/transactions.js +16 -16
  57. package/dist/mjs/modules/feed.js +14 -14
  58. package/dist/mjs/modules/pinning.js +14 -14
  59. package/dist/mjs/modules/pss.js +6 -6
  60. package/dist/mjs/modules/soc.js +6 -6
  61. package/dist/mjs/modules/status.js +3 -3
  62. package/dist/mjs/modules/stewardship.js +7 -7
  63. package/dist/mjs/modules/tag.js +20 -20
  64. package/dist/mjs/utils/error.js +0 -31
  65. package/dist/mjs/utils/headers.js +3 -3
  66. package/dist/mjs/utils/http.js +10 -138
  67. package/dist/mjs/utils/type.js +2 -5
  68. package/dist/types/bee-debug.d.ts +50 -50
  69. package/dist/types/bee.d.ts +34 -34
  70. package/dist/types/chunk/soc.d.ts +5 -6
  71. package/dist/types/feed/index.d.ts +7 -8
  72. package/dist/types/feed/json.d.ts +2 -2
  73. package/dist/types/feed/retrievable.d.ts +2 -2
  74. package/dist/types/index.d.ts +2 -4
  75. package/dist/types/modules/bytes.d.ts +4 -5
  76. package/dist/types/modules/bzz.d.ts +5 -6
  77. package/dist/types/modules/chunk.d.ts +3 -4
  78. package/dist/types/modules/debug/balance.d.ts +5 -6
  79. package/dist/types/modules/debug/chequebook.d.ts +9 -10
  80. package/dist/types/modules/debug/chunk.d.ts +3 -4
  81. package/dist/types/modules/debug/connectivity.d.ts +7 -8
  82. package/dist/types/modules/debug/settlements.d.ts +3 -4
  83. package/dist/types/modules/debug/stake.d.ts +4 -5
  84. package/dist/types/modules/debug/stamps.d.ts +7 -8
  85. package/dist/types/modules/debug/states.d.ts +4 -5
  86. package/dist/types/modules/debug/status.d.ts +10 -10
  87. package/dist/types/modules/debug/tag.d.ts +2 -3
  88. package/dist/types/modules/debug/transactions.d.ts +5 -6
  89. package/dist/types/modules/feed.d.ts +3 -4
  90. package/dist/types/modules/pinning.d.ts +5 -6
  91. package/dist/types/modules/pss.d.ts +2 -3
  92. package/dist/types/modules/soc.d.ts +2 -3
  93. package/dist/types/modules/status.d.ts +2 -2
  94. package/dist/types/modules/stewardship.d.ts +3 -4
  95. package/dist/types/modules/tag.d.ts +6 -7
  96. package/dist/types/types/debug.d.ts +2 -2
  97. package/dist/types/types/index.d.ts +12 -51
  98. package/dist/types/utils/error.d.ts +0 -26
  99. package/dist/types/utils/headers.d.ts +1 -1
  100. package/dist/types/utils/http.d.ts +12 -21
  101. package/dist/types/utils/type.d.ts +2 -2
  102. package/package.json +4 -4
  103. package/dist/223.index.browser.min.js +0 -3
  104. package/dist/223.index.browser.min.js.LICENSE.txt +0 -1
  105. package/dist/223.index.browser.min.js.map +0 -1
  106. package/dist/cjs/utils/merge.js +0 -34
  107. package/dist/cjs/utils/sleep.js +0 -12
  108. package/dist/mjs/utils/merge.js +0 -32
  109. package/dist/mjs/utils/sleep.js +0 -8
  110. package/dist/types/utils/merge.d.ts +0 -8
  111. package/dist/types/utils/sleep.d.ts +0 -6
@@ -6,15 +6,13 @@ import * as stake from "./modules/debug/stake.js";
6
6
  import * as states from "./modules/debug/states.js";
7
7
  import * as status from "./modules/debug/status.js";
8
8
  import * as transactions from "./modules/debug/transactions.js";
9
+ import { Objects, System } from 'cafe-utility';
9
10
  import * as stamps from "./modules/debug/stamps.js";
10
11
  import * as tag from "./modules/debug/tag.js";
11
12
  import { STAMPS_DEPTH_MAX, STAMPS_DEPTH_MIN } from "./types/index.js";
12
13
  import { BeeArgumentError, BeeError } from "./utils/error.js";
13
14
  import { assertAddress, assertBatchId, assertCashoutOptions, assertNonNegativeInteger, assertPositiveInteger, assertPostageBatchOptions, assertRequestOptions, assertTransactionHash, assertTransactionOptions, isTag } from "./utils/type.js";
14
15
  import { assertBeeUrl, stripLastSlash } from "./utils/url.js";
15
- import { DEFAULT_KY_CONFIG, wrapRequestClosure, wrapResponseClosure } from "./utils/http.js";
16
- import { deepMerge } from "./utils/merge.js";
17
- import { sleep } from "./utils/sleep.js";
18
16
  export class BeeDebug {
19
17
  constructor(url, options) {
20
18
  assertBeeUrl(url);
@@ -22,34 +20,22 @@ export class BeeDebug {
22
20
  // which could lead to double slash in URL to which Bee responds with
23
21
  // unnecessary redirects.
24
22
  this.url = stripLastSlash(url);
25
- const kyOptions = {
26
- prefixUrl: this.url,
27
- timeout: options?.timeout ?? false,
28
- retry: options?.retry,
29
- fetch: options?.fetch,
30
- hooks: {
31
- beforeRequest: [],
32
- afterResponse: []
33
- }
23
+ const requestOptions = {
24
+ baseURL: this.url,
25
+ timeout: options?.timeout ?? false
34
26
  };
35
- if (options?.defaultHeaders) {
36
- kyOptions.headers = options.defaultHeaders;
37
- }
38
- if (options?.onRequest) {
39
- kyOptions.hooks.beforeRequest.push(wrapRequestClosure(options.onRequest));
40
- }
41
- if (options?.onResponse) {
42
- kyOptions.hooks.afterResponse.push(wrapResponseClosure(options.onResponse));
27
+ if (options?.headers) {
28
+ requestOptions.headers = options.headers;
43
29
  }
44
- this.kyOptions = deepMerge(DEFAULT_KY_CONFIG, kyOptions);
30
+ this.requestOptions = requestOptions;
45
31
  }
46
32
  async getNodeAddresses(options) {
47
33
  assertRequestOptions(options);
48
- return connectivity.getNodeAddresses(this.getKyOptionsForCall(options));
34
+ return connectivity.getNodeAddresses(this.getRequestOptionsForCall(options));
49
35
  }
50
36
  async getBlocklist(options) {
51
37
  assertRequestOptions(options);
52
- return connectivity.getBlocklist(this.getKyOptionsForCall(options));
38
+ return connectivity.getBlocklist(this.getRequestOptionsForCall(options));
53
39
  }
54
40
  /**
55
41
  * Retrieve tag extended information from Bee node
@@ -70,28 +56,28 @@ export class BeeDebug {
70
56
  } else {
71
57
  throw new TypeError('tagUid has to be either Tag or a number (UID)!');
72
58
  }
73
- return tag.retrieveExtendedTag(this.getKyOptionsForCall(options), tagUid);
59
+ return tag.retrieveExtendedTag(this.getRequestOptionsForCall(options), tagUid);
74
60
  }
75
61
  /**
76
62
  * Get list of peers for this node
77
63
  */
78
64
  async getPeers(options) {
79
65
  assertRequestOptions(options);
80
- return connectivity.getPeers(this.getKyOptionsForCall(options));
66
+ return connectivity.getPeers(this.getRequestOptionsForCall(options));
81
67
  }
82
68
  async removePeer(peer, options) {
83
69
  assertRequestOptions(options);
84
70
  assertAddress(peer);
85
- return connectivity.removePeer(this.getKyOptionsForCall(options), peer);
71
+ return connectivity.removePeer(this.getRequestOptionsForCall(options), peer);
86
72
  }
87
73
  async getTopology(options) {
88
74
  assertRequestOptions(options);
89
- return connectivity.getTopology(this.getKyOptionsForCall(options));
75
+ return connectivity.getTopology(this.getRequestOptionsForCall(options));
90
76
  }
91
77
  async pingPeer(peer, options) {
92
78
  assertRequestOptions(options);
93
79
  assertAddress(peer);
94
- return connectivity.pingPeer(this.getKyOptionsForCall(options), peer);
80
+ return connectivity.pingPeer(this.getRequestOptionsForCall(options), peer);
95
81
  }
96
82
  /*
97
83
  * Balance endpoints
@@ -101,7 +87,7 @@ export class BeeDebug {
101
87
  */
102
88
  async getAllBalances(options) {
103
89
  assertRequestOptions(options);
104
- return balance.getAllBalances(this.getKyOptionsForCall(options));
90
+ return balance.getAllBalances(this.getRequestOptionsForCall(options));
105
91
  }
106
92
  /**
107
93
  * Get the balances with a specific peer including prepaid services
@@ -111,14 +97,14 @@ export class BeeDebug {
111
97
  async getPeerBalance(address, options) {
112
98
  assertRequestOptions(options);
113
99
  assertAddress(address);
114
- return balance.getPeerBalance(this.getKyOptionsForCall(options), address);
100
+ return balance.getPeerBalance(this.getRequestOptionsForCall(options), address);
115
101
  }
116
102
  /**
117
103
  * Get the past due consumption balances with all known peers
118
104
  */
119
105
  async getPastDueConsumptionBalances(options) {
120
106
  assertRequestOptions(options);
121
- return balance.getPastDueConsumptionBalances(this.getKyOptionsForCall(options));
107
+ return balance.getPastDueConsumptionBalances(this.getRequestOptionsForCall(options));
122
108
  }
123
109
  /**
124
110
  * Get the past due consumption balance with a specific peer
@@ -128,7 +114,7 @@ export class BeeDebug {
128
114
  async getPastDueConsumptionPeerBalance(address, options) {
129
115
  assertRequestOptions(options);
130
116
  assertAddress(address);
131
- return balance.getPastDueConsumptionPeerBalance(this.getKyOptionsForCall(options), address);
117
+ return balance.getPastDueConsumptionPeerBalance(this.getRequestOptionsForCall(options), address);
132
118
  }
133
119
  /*
134
120
  * Chequebook endpoints
@@ -141,21 +127,21 @@ export class BeeDebug {
141
127
  */
142
128
  async getChequebookAddress(options) {
143
129
  assertRequestOptions(options);
144
- return chequebook.getChequebookAddress(this.getKyOptionsForCall(options));
130
+ return chequebook.getChequebookAddress(this.getRequestOptionsForCall(options));
145
131
  }
146
132
  /**
147
133
  * Get the balance of the chequebook
148
134
  */
149
135
  async getChequebookBalance(options) {
150
136
  assertRequestOptions(options);
151
- return chequebook.getChequebookBalance(this.getKyOptionsForCall(options));
137
+ return chequebook.getChequebookBalance(this.getRequestOptionsForCall(options));
152
138
  }
153
139
  /**
154
140
  * Get last cheques for all peers
155
141
  */
156
142
  async getLastCheques(options) {
157
143
  assertRequestOptions(options);
158
- return chequebook.getLastCheques(this.getKyOptionsForCall(options));
144
+ return chequebook.getLastCheques(this.getRequestOptionsForCall(options));
159
145
  }
160
146
  /**
161
147
  * Get last cheques for the peer
@@ -165,7 +151,7 @@ export class BeeDebug {
165
151
  async getLastChequesForPeer(address, options) {
166
152
  assertRequestOptions(options);
167
153
  assertAddress(address);
168
- return chequebook.getLastChequesForPeer(this.getKyOptionsForCall(options), address);
154
+ return chequebook.getLastChequesForPeer(this.getRequestOptionsForCall(options), address);
169
155
  }
170
156
  /**
171
157
  * Get last cashout action for the peer
@@ -175,7 +161,7 @@ export class BeeDebug {
175
161
  async getLastCashoutAction(address, options) {
176
162
  assertRequestOptions(options);
177
163
  assertAddress(address);
178
- return chequebook.getLastCashoutAction(this.getKyOptionsForCall(options), address);
164
+ return chequebook.getLastCashoutAction(this.getRequestOptionsForCall(options), address);
179
165
  }
180
166
  /**
181
167
  * Cashout the last cheque for the peer
@@ -185,10 +171,10 @@ export class BeeDebug {
185
171
  * @param options.gasPrice Gas price for the cashout transaction in WEI
186
172
  * @param options.gasLimit Gas limit for the cashout transaction in WEI
187
173
  */
188
- async cashoutLastCheque(address, options) {
174
+ async cashoutLastCheque(address, options, requestOptions) {
189
175
  assertCashoutOptions(options);
190
176
  assertAddress(address);
191
- return chequebook.cashoutLastCheque(this.getKyOptionsForCall(options), address, options);
177
+ return chequebook.cashoutLastCheque(this.getRequestOptionsForCall(requestOptions), address, options);
192
178
  }
193
179
  /**
194
180
  * Deposit tokens from overlay address into chequebook
@@ -203,7 +189,7 @@ export class BeeDebug {
203
189
  if (gasPrice) {
204
190
  assertNonNegativeInteger(gasPrice);
205
191
  }
206
- return chequebook.depositTokens(this.getKyOptionsForCall(options), amount, gasPrice);
192
+ return chequebook.depositTokens(this.getRequestOptionsForCall(options), amount, gasPrice);
207
193
  }
208
194
  /**
209
195
  * Withdraw tokens from the chequebook to the overlay address
@@ -218,7 +204,7 @@ export class BeeDebug {
218
204
  if (gasPrice) {
219
205
  assertNonNegativeInteger(gasPrice);
220
206
  }
221
- return chequebook.withdrawTokens(this.getKyOptionsForCall(options), amount, gasPrice);
207
+ return chequebook.withdrawTokens(this.getRequestOptionsForCall(options), amount, gasPrice);
222
208
  }
223
209
  /*
224
210
  * Settlements endpoint
@@ -231,35 +217,35 @@ export class BeeDebug {
231
217
  async getSettlements(address, options) {
232
218
  assertRequestOptions(options);
233
219
  assertAddress(address);
234
- return settlements.getSettlements(this.getKyOptionsForCall(options), address);
220
+ return settlements.getSettlements(this.getRequestOptionsForCall(options), address);
235
221
  }
236
222
  /**
237
223
  * Get settlements with all known peers and total amount sent or received
238
224
  */
239
225
  async getAllSettlements(options) {
240
226
  assertRequestOptions(options);
241
- return settlements.getAllSettlements(this.getKyOptionsForCall(options));
227
+ return settlements.getAllSettlements(this.getRequestOptionsForCall(options));
242
228
  }
243
229
  /**
244
230
  * Get health of node
245
231
  */
246
232
  async getHealth(options) {
247
233
  assertRequestOptions(options);
248
- return status.getHealth(this.getKyOptionsForCall(options));
234
+ return status.getHealth(this.getRequestOptionsForCall(options));
249
235
  }
250
236
  /**
251
237
  * Get readiness of node
252
238
  */
253
239
  async getReadiness(options) {
254
240
  assertRequestOptions(options);
255
- return status.getReadiness(this.getKyOptionsForCall(options));
241
+ return status.getReadiness(this.getRequestOptionsForCall(options));
256
242
  }
257
243
  /**
258
244
  * Get mode information of node
259
245
  */
260
246
  async getNodeInfo(options) {
261
247
  assertRequestOptions(options);
262
- return status.getNodeInfo(this.getKyOptionsForCall(options));
248
+ return status.getNodeInfo(this.getRequestOptionsForCall(options));
263
249
  }
264
250
  /**
265
251
  * Connnects to a node and checks if it is a supported Bee version by the bee-js
@@ -269,7 +255,7 @@ export class BeeDebug {
269
255
  */
270
256
  async isSupportedVersion(options) {
271
257
  assertRequestOptions(options);
272
- return status.isSupportedVersion(this.getKyOptionsForCall(options));
258
+ return status.isSupportedVersion(this.getRequestOptionsForCall(options));
273
259
  }
274
260
  /**
275
261
  * Connects to a node and checks if its version matches with the one that bee-js supports.
@@ -283,7 +269,7 @@ export class BeeDebug {
283
269
  */
284
270
  async isSupportedExactVersion(options) {
285
271
  assertRequestOptions(options);
286
- return status.isSupportedExactVersion(this.getKyOptionsForCall(options));
272
+ return status.isSupportedExactVersion(this.getRequestOptionsForCall(options));
287
273
  }
288
274
  /**
289
275
  * Connects to a node and checks if its main's API version matches with the one that bee-js supports.
@@ -295,7 +281,7 @@ export class BeeDebug {
295
281
  */
296
282
  async isSupportedMainApiVersion(options) {
297
283
  assertRequestOptions(options);
298
- return status.isSupportedMainApiVersion(this.getKyOptionsForCall(options));
284
+ return status.isSupportedMainApiVersion(this.getRequestOptionsForCall(options));
299
285
  }
300
286
  /**
301
287
  * Connects to a node and checks if its Debug API version matches with the one that bee-js supports.
@@ -307,7 +293,7 @@ export class BeeDebug {
307
293
  */
308
294
  async isSupportedDebugApiVersion(options) {
309
295
  assertRequestOptions(options);
310
- return status.isSupportedDebugApiVersion(this.getKyOptionsForCall(options));
296
+ return status.isSupportedDebugApiVersion(this.getRequestOptionsForCall(options));
311
297
  }
312
298
  /**
313
299
  *
@@ -319,7 +305,7 @@ export class BeeDebug {
319
305
  */
320
306
  async isSupportedApiVersion(options) {
321
307
  assertRequestOptions(options);
322
- return status.isSupportedDebugApiVersion(this.getKyOptionsForCall(options));
308
+ return status.isSupportedDebugApiVersion(this.getRequestOptionsForCall(options));
323
309
  }
324
310
  /**
325
311
  * Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
@@ -329,21 +315,21 @@ export class BeeDebug {
329
315
  */
330
316
  async getVersions(options) {
331
317
  assertRequestOptions(options);
332
- return status.getVersions(this.getKyOptionsForCall(options));
318
+ return status.getVersions(this.getRequestOptionsForCall(options));
333
319
  }
334
320
  /**
335
321
  * Get reserve state
336
322
  */
337
323
  async getReserveState(options) {
338
324
  assertRequestOptions(options);
339
- return states.getReserveState(this.getKyOptionsForCall(options));
325
+ return states.getReserveState(this.getRequestOptionsForCall(options));
340
326
  }
341
327
  /**
342
328
  * Get chain state
343
329
  */
344
330
  async getChainState(options) {
345
331
  assertRequestOptions(options);
346
- return states.getChainState(this.getKyOptionsForCall(options));
332
+ return states.getChainState(this.getRequestOptionsForCall(options));
347
333
  }
348
334
  /**
349
335
  * Get wallet balances for xDai and BZZ of the Bee node
@@ -352,7 +338,7 @@ export class BeeDebug {
352
338
  */
353
339
  async getWalletBalance(options) {
354
340
  assertRequestOptions(options);
355
- return states.getWalletBalance(this.getKyOptionsForCall(options));
341
+ return states.getWalletBalance(this.getRequestOptionsForCall(options));
356
342
  }
357
343
  /**
358
344
  * Creates new postage batch from the funds that the node has available in its Ethereum account.
@@ -371,7 +357,7 @@ export class BeeDebug {
371
357
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
372
358
  * @see [Bee Debug API reference - `POST /stamps`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post)
373
359
  */
374
- async createPostageBatch(amount, depth, options) {
360
+ async createPostageBatch(amount, depth, options, requestOptions) {
375
361
  assertPostageBatchOptions(options);
376
362
  assertPositiveInteger(amount);
377
363
  assertNonNegativeInteger(depth);
@@ -381,7 +367,7 @@ export class BeeDebug {
381
367
  if (depth > STAMPS_DEPTH_MAX) {
382
368
  throw new BeeArgumentError(`Depth has to be at most ${STAMPS_DEPTH_MAX}`, depth);
383
369
  }
384
- const stamp = await stamps.createPostageBatch(this.getKyOptionsForCall(options), amount, depth, options);
370
+ const stamp = await stamps.createPostageBatch(this.getRequestOptionsForCall(requestOptions), amount, depth, options);
385
371
  if (options?.waitForUsable !== false) {
386
372
  await this.waitForUsablePostageStamp(stamp, options?.waitForUsableTimeout);
387
373
  }
@@ -406,7 +392,7 @@ export class BeeDebug {
406
392
  assertRequestOptions(options);
407
393
  assertNonNegativeInteger(amount, 'Amount');
408
394
  assertBatchId(postageBatchId);
409
- await stamps.topUpBatch(this.getKyOptionsForCall(options), postageBatchId, amount);
395
+ await stamps.topUpBatch(this.getRequestOptionsForCall(options), postageBatchId, amount);
410
396
  }
411
397
  /**
412
398
  * Dilute given Postage Batch with new depth (that has to be bigger then the original depth), which allows
@@ -428,7 +414,7 @@ export class BeeDebug {
428
414
  assertRequestOptions(options);
429
415
  assertNonNegativeInteger(depth, 'Depth');
430
416
  assertBatchId(postageBatchId);
431
- await stamps.diluteBatch(this.getKyOptionsForCall(options), postageBatchId, depth);
417
+ await stamps.diluteBatch(this.getRequestOptionsForCall(options), postageBatchId, depth);
432
418
  }
433
419
  /**
434
420
  * Return details for specific postage batch.
@@ -441,7 +427,7 @@ export class BeeDebug {
441
427
  async getPostageBatch(postageBatchId, options) {
442
428
  assertRequestOptions(options);
443
429
  assertBatchId(postageBatchId);
444
- return stamps.getPostageBatch(this.getKyOptionsForCall(options), postageBatchId);
430
+ return stamps.getPostageBatch(this.getRequestOptionsForCall(options), postageBatchId);
445
431
  }
446
432
  /**
447
433
  * Return detailed information related to buckets for specific postage batch.
@@ -454,7 +440,7 @@ export class BeeDebug {
454
440
  async getPostageBatchBuckets(postageBatchId, options) {
455
441
  assertRequestOptions(options);
456
442
  assertBatchId(postageBatchId);
457
- return stamps.getPostageBatchBuckets(this.getKyOptionsForCall(options), postageBatchId);
443
+ return stamps.getPostageBatchBuckets(this.getRequestOptionsForCall(options), postageBatchId);
458
444
  }
459
445
  /**
460
446
  * Return all postage batches that has the node available.
@@ -464,14 +450,14 @@ export class BeeDebug {
464
450
  */
465
451
  async getAllPostageBatch(options) {
466
452
  assertRequestOptions(options);
467
- return stamps.getAllPostageBatches(this.getKyOptionsForCall(options));
453
+ return stamps.getAllPostageBatches(this.getRequestOptionsForCall(options));
468
454
  }
469
455
  /**
470
456
  * Return lists of all current pending transactions that the Bee made
471
457
  */
472
458
  async getAllPendingTransactions(options) {
473
459
  assertRequestOptions(options);
474
- return transactions.getAllTransactions(this.getKyOptionsForCall(options));
460
+ return transactions.getAllTransactions(this.getRequestOptionsForCall(options));
475
461
  }
476
462
  /**
477
463
  * Return transaction information for specific transaction
@@ -480,7 +466,7 @@ export class BeeDebug {
480
466
  async getPendingTransaction(transactionHash, options) {
481
467
  assertRequestOptions(options);
482
468
  assertTransactionHash(transactionHash);
483
- return transactions.getTransaction(this.getKyOptionsForCall(options), transactionHash);
469
+ return transactions.getTransaction(this.getRequestOptionsForCall(options), transactionHash);
484
470
  }
485
471
  /**
486
472
  * Rebroadcast already created transaction.
@@ -491,7 +477,7 @@ export class BeeDebug {
491
477
  async rebroadcastPendingTransaction(transactionHash, options) {
492
478
  assertRequestOptions(options);
493
479
  assertTransactionHash(transactionHash);
494
- return transactions.rebroadcastTransaction(this.getKyOptionsForCall(options), transactionHash);
480
+ return transactions.rebroadcastTransaction(this.getRequestOptionsForCall(options), transactionHash);
495
481
  }
496
482
  /**
497
483
  * Cancel currently pending transaction
@@ -504,7 +490,7 @@ export class BeeDebug {
504
490
  if (gasPrice) {
505
491
  assertNonNegativeInteger(gasPrice);
506
492
  }
507
- return transactions.cancelTransaction(this.getKyOptionsForCall(options), transactionHash, gasPrice);
493
+ return transactions.cancelTransaction(this.getRequestOptionsForCall(options), transactionHash, gasPrice);
508
494
  }
509
495
  /**
510
496
  * Gets the staked amount of BZZ (in PLUR unit) as number string.
@@ -513,7 +499,7 @@ export class BeeDebug {
513
499
  */
514
500
  async getStake(options) {
515
501
  assertRequestOptions(options);
516
- return stake.getStake(this.getKyOptionsForCall(options));
502
+ return stake.getStake(this.getRequestOptionsForCall(options));
517
503
  }
518
504
  /**
519
505
  * Deposits given amount of BZZ token (in PLUR unit).
@@ -523,10 +509,10 @@ export class BeeDebug {
523
509
  * @param amount Amount of BZZ token (in PLUR unit) to be staked. Minimum is 100_000_000_000_000_000 PLUR (10 BZZ).
524
510
  * @param options
525
511
  */
526
- async depositStake(amount, options) {
512
+ async depositStake(amount, options, requestOptions) {
527
513
  assertRequestOptions(options);
528
514
  assertTransactionOptions(options);
529
- await stake.stake(this.getKyOptionsForCall(options), amount, options);
515
+ await stake.stake(this.getRequestOptionsForCall(requestOptions), amount, options);
530
516
  }
531
517
  /**
532
518
  * Get current status of node in redistribution game
@@ -535,7 +521,7 @@ export class BeeDebug {
535
521
  */
536
522
  async getRedistributionState(options) {
537
523
  assertRequestOptions(options);
538
- return stake.getRedistributionState(this.getKyOptionsForCall(options));
524
+ return stake.getRedistributionState(this.getRequestOptionsForCall(options));
539
525
  }
540
526
  async waitForUsablePostageStamp(id, timeout = 120000) {
541
527
  const TIME_STEP = 1500;
@@ -544,11 +530,11 @@ export class BeeDebug {
544
530
  if (stamp.usable) {
545
531
  return;
546
532
  }
547
- await sleep(TIME_STEP);
533
+ await System.sleepMillis(TIME_STEP);
548
534
  }
549
535
  throw new BeeError('Timeout on waiting for postage stamp to become usable');
550
536
  }
551
- getKyOptionsForCall(options) {
552
- return deepMerge(this.kyOptions, options);
537
+ getRequestOptionsForCall(options) {
538
+ return options ? Objects.deepMerge2(this.requestOptions, options) : this.requestOptions;
553
539
  }
554
540
  }