@ethersphere/bee-js 2.0.0 → 3.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 (159) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +2 -2
  3. package/dist/index.browser.min.js +1 -1
  4. package/dist/index.browser.min.js.map +1 -1
  5. package/dist/index.min.js +1 -1
  6. package/dist/index.min.js.map +1 -1
  7. package/dist/src/bee-debug.d.ts +38 -6
  8. package/dist/src/bee.d.ts +34 -46
  9. package/dist/src/modules/chunk.d.ts +2 -10
  10. package/dist/src/modules/debug/stamps.d.ts +2 -0
  11. package/dist/src/modules/debug/status.d.ts +10 -4
  12. package/dist/src/modules/stewardship.d.ts +1 -0
  13. package/dist/src/types/debug.d.ts +11 -0
  14. package/dist/src/types/index.d.ts +6 -7
  15. package/dist/src/utils/bytes.d.ts +1 -1
  16. package/dist/src/utils/expose.d.ts +1 -0
  17. package/dist/src/utils/stamps.d.ts +12 -0
  18. package/package.json +10 -8
  19. package/.babelrc.js +0 -33
  20. package/.depcheckrc.json +0 -27
  21. package/.editorconfig +0 -6
  22. package/.eslintignore +0 -1
  23. package/.eslintrc.js +0 -109
  24. package/.gitattributes +0 -1
  25. package/.github/config.yaml +0 -23
  26. package/.github/workflows/check.yaml +0 -57
  27. package/.github/workflows/publish_npmjs.yaml +0 -20
  28. package/.github/workflows/release_github.yaml +0 -20
  29. package/.github/workflows/tests.yaml +0 -128
  30. package/.huskyrc +0 -5
  31. package/.prettierrc +0 -13
  32. package/.vscode/launch.json +0 -49
  33. package/.vscode/settings.json +0 -39
  34. package/CODEOWNERS +0 -1
  35. package/CODE_OF_CONDUCT.md +0 -76
  36. package/commitlint.config.js +0 -3
  37. package/dist/src/modules/stamps.d.ts +0 -4
  38. package/jest-puppeteer.config.js +0 -5
  39. package/jest.config.ts +0 -85
  40. package/src/bee-debug.ts +0 -559
  41. package/src/bee.ts +0 -1070
  42. package/src/chunk/bmt.ts +0 -55
  43. package/src/chunk/cac.ts +0 -79
  44. package/src/chunk/serialize.ts +0 -16
  45. package/src/chunk/signer.ts +0 -141
  46. package/src/chunk/soc.ts +0 -190
  47. package/src/chunk/span.ts +0 -33
  48. package/src/feed/index.ts +0 -217
  49. package/src/feed/json.ts +0 -33
  50. package/src/feed/topic.ts +0 -23
  51. package/src/feed/type.ts +0 -12
  52. package/src/index.ts +0 -24
  53. package/src/modules/bytes.ts +0 -70
  54. package/src/modules/bzz.ts +0 -179
  55. package/src/modules/chunk.ts +0 -69
  56. package/src/modules/debug/balance.ts +0 -63
  57. package/src/modules/debug/chequebook.ts +0 -175
  58. package/src/modules/debug/chunk.ts +0 -39
  59. package/src/modules/debug/connectivity.ts +0 -61
  60. package/src/modules/debug/settlements.ts +0 -33
  61. package/src/modules/debug/stamps.ts +0 -76
  62. package/src/modules/debug/states.ts +0 -35
  63. package/src/modules/debug/status.ts +0 -35
  64. package/src/modules/debug/tag.ts +0 -19
  65. package/src/modules/debug/transactions.ts +0 -79
  66. package/src/modules/feed.ts +0 -105
  67. package/src/modules/pinning.ts +0 -74
  68. package/src/modules/pss.ts +0 -49
  69. package/src/modules/soc.ts +0 -40
  70. package/src/modules/stamps.ts +0 -59
  71. package/src/modules/status.ts +0 -13
  72. package/src/modules/stewardship.ts +0 -18
  73. package/src/modules/tag.ts +0 -83
  74. package/src/types/debug.ts +0 -204
  75. package/src/types/index.ts +0 -566
  76. package/src/types/ky-universal/common.d.ts +0 -17
  77. package/src/types/ky-universal/hooks.d.ts +0 -103
  78. package/src/types/ky-universal/index.d.ts +0 -125
  79. package/src/types/ky-universal/options.d.ts +0 -235
  80. package/src/types/ky-universal/response.d.ts +0 -38
  81. package/src/types/ky-universal/retry.d.ts +0 -39
  82. package/src/types/tar-js.d.ts +0 -1
  83. package/src/types/webpack-bundle-analyzer/index.d.ts +0 -13
  84. package/src/utils/bytes.ts +0 -144
  85. package/src/utils/collection.ts +0 -151
  86. package/src/utils/data.browser.ts +0 -68
  87. package/src/utils/data.ts +0 -48
  88. package/src/utils/error.ts +0 -23
  89. package/src/utils/eth.ts +0 -229
  90. package/src/utils/expose.ts +0 -48
  91. package/src/utils/file.ts +0 -40
  92. package/src/utils/hash.ts +0 -16
  93. package/src/utils/headers.ts +0 -63
  94. package/src/utils/hex.ts +0 -186
  95. package/src/utils/http.ts +0 -141
  96. package/src/utils/merge.ts +0 -34
  97. package/src/utils/pss.ts +0 -16
  98. package/src/utils/stream.ts +0 -146
  99. package/src/utils/tar.ts +0 -30
  100. package/src/utils/type.ts +0 -394
  101. package/src/utils/uint64.ts +0 -31
  102. package/src/utils/url.ts +0 -52
  103. package/test/bee.sh +0 -187
  104. package/test/data/1.txt +0 -1
  105. package/test/data/2.txt +0 -0
  106. package/test/data/empty +0 -0
  107. package/test/data/sub/3.txt +0 -1
  108. package/test/data/sub//303/251 +0 -0
  109. package/test/data/sub//360/237/230/216 +0 -0
  110. package/test/integration/bee-class.browser.spec.ts +0 -272
  111. package/test/integration/bee-class.spec.ts +0 -631
  112. package/test/integration/bee-debug-class.spec.ts +0 -85
  113. package/test/integration/chunk/bmt.spec.ts +0 -33
  114. package/test/integration/chunk/cac.spec.ts +0 -27
  115. package/test/integration/chunk/soc.spec.ts +0 -38
  116. package/test/integration/feed/index.spec.ts +0 -84
  117. package/test/integration/modules/bytes.spec.ts +0 -23
  118. package/test/integration/modules/bzz.spec.ts +0 -265
  119. package/test/integration/modules/chunk.spec.ts +0 -29
  120. package/test/integration/modules/debug/balance.spec.ts +0 -70
  121. package/test/integration/modules/debug/chequebook.spec.ts +0 -64
  122. package/test/integration/modules/debug/connectivity.spec.ts +0 -69
  123. package/test/integration/modules/debug/settlements.spec.ts +0 -34
  124. package/test/integration/modules/debug/states.spec.ts +0 -34
  125. package/test/integration/modules/debug/status.spec.ts +0 -65
  126. package/test/integration/modules/debug/tag.spec.ts +0 -27
  127. package/test/integration/modules/debug/transactions.spec.ts +0 -10
  128. package/test/integration/modules/feed.spec.ts +0 -61
  129. package/test/integration/modules/pinning.spec.ts +0 -155
  130. package/test/integration/modules/pss.spec.ts +0 -97
  131. package/test/integration/modules/status.spec.ts +0 -10
  132. package/test/integration/modules/stewardship.spec.ts +0 -32
  133. package/test/integration/modules/tag.spec.ts +0 -51
  134. package/test/test-type-sequencer.js +0 -36
  135. package/test/testpage/testpage.html +0 -20
  136. package/test/tests-setup.ts +0 -94
  137. package/test/unit/assertions.ts +0 -460
  138. package/test/unit/bee-class.spec.ts +0 -976
  139. package/test/unit/bee-debug-class.spec.ts +0 -435
  140. package/test/unit/chunk/bmt.spec.ts +0 -16
  141. package/test/unit/chunk/cac.spec.ts +0 -29
  142. package/test/unit/chunk/serialize.spec.ts +0 -24
  143. package/test/unit/chunk/signer.spec.ts +0 -140
  144. package/test/unit/chunk/soc.spec.ts +0 -25
  145. package/test/unit/chunk/span.spec.ts +0 -38
  146. package/test/unit/feed/json.spec.ts +0 -73
  147. package/test/unit/nock.ts +0 -151
  148. package/test/unit/utils/bytes.spec.ts +0 -32
  149. package/test/unit/utils/collection.spec.ts +0 -22
  150. package/test/unit/utils/eth.spec.ts +0 -224
  151. package/test/unit/utils/hex.spec.ts +0 -115
  152. package/test/unit/utils/stream.spec.ts +0 -30
  153. package/test/unit/utils/type.spec.ts +0 -32
  154. package/test/unit/utils/uint64.spec.ts +0 -102
  155. package/test/utils.ts +0 -328
  156. package/tsconfig.json +0 -18
  157. package/tsconfig.test.json +0 -11
  158. package/typedoc.json +0 -7
  159. package/webpack.config.ts +0 -141
package/src/bee-debug.ts DELETED
@@ -1,559 +0,0 @@
1
- import * as connectivity from './modules/debug/connectivity'
2
- import * as balance from './modules/debug/balance'
3
- import * as chequebook from './modules/debug/chequebook'
4
- import * as settlements from './modules/debug/settlements'
5
- import * as status from './modules/debug/status'
6
- import * as transactions from './modules/debug/transactions'
7
- import * as states from './modules/debug/states'
8
- import type {
9
- Address,
10
- Peer,
11
- BalanceResponse,
12
- PeerBalance,
13
- ChequebookAddressResponse,
14
- ChequebookBalanceResponse,
15
- LastChequesResponse,
16
- LastChequesForPeerResponse,
17
- LastCashoutActionResponse,
18
- Settlements,
19
- AllSettlements,
20
- RemovePeerResponse,
21
- Topology,
22
- PingResponse,
23
- Health,
24
- NodeAddresses,
25
- ReserveState,
26
- ChainState,
27
- NumberString,
28
- ExtendedTag,
29
- PostageBatchBuckets,
30
- DebugPostageBatch,
31
- Ky,
32
- TransactionInfo,
33
- TransactionHash,
34
- } from './types'
35
- import { BeeArgumentError } from './utils/error'
36
- import { assertBeeUrl, stripLastSlash } from './utils/url'
37
- import {
38
- assertAddress,
39
- assertBatchId,
40
- assertBoolean,
41
- assertCashoutOptions,
42
- assertNonNegativeInteger,
43
- assertRequestOptions,
44
- assertTransactionHash,
45
- isTag,
46
- } from './utils/type'
47
- import {
48
- BatchId,
49
- BeeOptions,
50
- CashoutOptions,
51
- PostageBatchOptions,
52
- RequestOptions,
53
- STAMPS_DEPTH_MAX,
54
- STAMPS_DEPTH_MIN,
55
- Tag,
56
- } from './types'
57
- import * as tag from './modules/debug/tag'
58
- import * as stamps from './modules/debug/stamps'
59
- import type { Options as KyOptions } from 'ky-universal'
60
- import { makeDefaultKy, wrapRequestClosure, wrapResponseClosure } from './utils/http'
61
-
62
- /**
63
- * The BeeDebug class provides a way of interacting with the Bee debug APIs based on the provided url
64
- *
65
- * @param url URL of a running Bee node
66
- */
67
- export class BeeDebug {
68
- /**
69
- * URL on which is the Debug API of Bee node exposed
70
- */
71
- public readonly url: string
72
-
73
- /**
74
- * Ky instance that defines connection to Bee node
75
- * @private
76
- */
77
- private readonly ky: Ky
78
-
79
- constructor(url: string, options?: BeeOptions) {
80
- assertBeeUrl(url)
81
-
82
- // Remove last slash if present, as our endpoint strings starts with `/...`
83
- // which could lead to double slash in URL to which Bee responds with
84
- // unnecessary redirects.
85
- this.url = stripLastSlash(url)
86
-
87
- const kyOptions: KyOptions = {
88
- prefixUrl: this.url,
89
- timeout: options?.timeout ?? false,
90
- retry: options?.retry,
91
- fetch: options?.fetch,
92
- hooks: {
93
- beforeRequest: [],
94
- afterResponse: [],
95
- },
96
- }
97
-
98
- if (options?.defaultHeaders) {
99
- kyOptions.headers = options.defaultHeaders
100
- }
101
-
102
- if (options?.onRequest) {
103
- kyOptions.hooks!.beforeRequest!.push(wrapRequestClosure(options.onRequest))
104
- }
105
-
106
- if (options?.onResponse) {
107
- kyOptions.hooks!.afterResponse!.push(wrapResponseClosure(options.onResponse))
108
- }
109
-
110
- this.ky = makeDefaultKy(kyOptions)
111
- }
112
-
113
- async getNodeAddresses(options?: RequestOptions): Promise<NodeAddresses> {
114
- assertRequestOptions(options)
115
-
116
- return connectivity.getNodeAddresses(this.getKy(options))
117
- }
118
-
119
- async getBlocklist(options?: RequestOptions): Promise<Peer[]> {
120
- assertRequestOptions(options)
121
-
122
- return connectivity.getBlocklist(this.getKy(options))
123
- }
124
-
125
- /**
126
- * Retrieve tag extended information from Bee node
127
- *
128
- * @param tagUid UID or tag object to be retrieved
129
- * @throws TypeError if tagUid is in not correct format
130
- *
131
- * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
132
- * @see [Bee API reference - `GET /tags/{uid}`](https://docs.ethswarm.org/debug-api/#tag/Tag)
133
- *
134
- */
135
- async retrieveExtendedTag(tagUid: number | Tag, options?: RequestOptions): Promise<ExtendedTag> {
136
- assertRequestOptions(options)
137
-
138
- if (isTag(tagUid)) {
139
- tagUid = tagUid.uid
140
- } else if (typeof tagUid === 'number') {
141
- assertNonNegativeInteger(tagUid, 'UID')
142
- } else {
143
- throw new TypeError('tagUid has to be either Tag or a number (UID)!')
144
- }
145
-
146
- return tag.retrieveExtendedTag(this.getKy(options), tagUid)
147
- }
148
-
149
- /**
150
- * Get list of peers for this node
151
- */
152
- async getPeers(options?: RequestOptions): Promise<Peer[]> {
153
- assertRequestOptions(options)
154
-
155
- return connectivity.getPeers(this.getKy(options))
156
- }
157
-
158
- async removePeer(peer: string | Address, options?: RequestOptions): Promise<RemovePeerResponse> {
159
- assertRequestOptions(options)
160
- assertAddress(peer)
161
-
162
- return connectivity.removePeer(this.getKy(options), peer)
163
- }
164
-
165
- async getTopology(options?: RequestOptions): Promise<Topology> {
166
- assertRequestOptions(options)
167
-
168
- return connectivity.getTopology(this.getKy(options))
169
- }
170
-
171
- async pingPeer(peer: string | Address, options?: RequestOptions): Promise<PingResponse> {
172
- assertRequestOptions(options)
173
- assertAddress(peer)
174
-
175
- return connectivity.pingPeer(this.getKy(options), peer)
176
- }
177
-
178
- /*
179
- * Balance endpoints
180
- */
181
-
182
- /**
183
- * Get the balances with all known peers including prepaid services
184
- */
185
- async getAllBalances(options?: RequestOptions): Promise<BalanceResponse> {
186
- assertRequestOptions(options)
187
-
188
- return balance.getAllBalances(this.getKy(options))
189
- }
190
-
191
- /**
192
- * Get the balances with a specific peer including prepaid services
193
- *
194
- * @param address Swarm address of peer
195
- */
196
- async getPeerBalance(address: Address | string, options?: RequestOptions): Promise<PeerBalance> {
197
- assertRequestOptions(options)
198
- assertAddress(address)
199
-
200
- return balance.getPeerBalance(this.getKy(options), address)
201
- }
202
-
203
- /**
204
- * Get the past due consumption balances with all known peers
205
- */
206
- async getPastDueConsumptionBalances(options?: RequestOptions): Promise<BalanceResponse> {
207
- assertRequestOptions(options)
208
-
209
- return balance.getPastDueConsumptionBalances(this.getKy(options))
210
- }
211
-
212
- /**
213
- * Get the past due consumption balance with a specific peer
214
- *
215
- * @param address Swarm address of peer
216
- */
217
- async getPastDueConsumptionPeerBalance(address: Address | string, options?: RequestOptions): Promise<PeerBalance> {
218
- assertRequestOptions(options)
219
- assertAddress(address)
220
-
221
- return balance.getPastDueConsumptionPeerBalance(this.getKy(options), address)
222
- }
223
-
224
- /*
225
- * Chequebook endpoints
226
- */
227
-
228
- /**
229
- * Get the address of the chequebook contract used.
230
- *
231
- * **Warning:** The address is returned with 0x prefix unlike all other calls.
232
- * https://github.com/ethersphere/bee/issues/1443
233
- */
234
- async getChequebookAddress(options?: RequestOptions): Promise<ChequebookAddressResponse> {
235
- assertRequestOptions(options)
236
-
237
- return chequebook.getChequebookAddress(this.getKy(options))
238
- }
239
-
240
- /**
241
- * Get the balance of the chequebook
242
- */
243
- async getChequebookBalance(options?: RequestOptions): Promise<ChequebookBalanceResponse> {
244
- assertRequestOptions(options)
245
-
246
- return chequebook.getChequebookBalance(this.getKy(options))
247
- }
248
-
249
- /**
250
- * Get last cheques for all peers
251
- */
252
- async getLastCheques(options?: RequestOptions): Promise<LastChequesResponse> {
253
- assertRequestOptions(options)
254
-
255
- return chequebook.getLastCheques(this.getKy(options))
256
- }
257
-
258
- /**
259
- * Get last cheques for the peer
260
- *
261
- * @param address Swarm address of peer
262
- */
263
- async getLastChequesForPeer(
264
- address: Address | string,
265
- options?: RequestOptions,
266
- ): Promise<LastChequesForPeerResponse> {
267
- assertRequestOptions(options)
268
- assertAddress(address)
269
-
270
- return chequebook.getLastChequesForPeer(this.getKy(options), address)
271
- }
272
-
273
- /**
274
- * Get last cashout action for the peer
275
- *
276
- * @param address Swarm address of peer
277
- */
278
- async getLastCashoutAction(address: Address | string, options?: RequestOptions): Promise<LastCashoutActionResponse> {
279
- assertRequestOptions(options)
280
- assertAddress(address)
281
-
282
- return chequebook.getLastCashoutAction(this.getKy(options), address)
283
- }
284
-
285
- /**
286
- * Cashout the last cheque for the peer
287
- *
288
- * @param address Swarm address of peer
289
- * @param options
290
- * @param options.gasPrice Gas price for the cashout transaction in WEI
291
- * @param options.gasLimit Gas limit for the cashout transaction in WEI
292
- */
293
- async cashoutLastCheque(address: string | Address, options?: CashoutOptions): Promise<string> {
294
- assertCashoutOptions(options)
295
- assertAddress(address)
296
-
297
- return chequebook.cashoutLastCheque(this.getKy(options), address, options)
298
- }
299
-
300
- /**
301
- * Deposit tokens from overlay address into chequebook
302
- *
303
- * @param amount Amount of tokens to deposit (must be positive integer)
304
- * @param gasPrice Gas Price in WEI for the transaction call
305
- * @return string Hash of the transaction
306
- */
307
- async depositTokens(
308
- amount: number | NumberString,
309
- gasPrice?: NumberString,
310
- options?: RequestOptions,
311
- ): Promise<string> {
312
- assertRequestOptions(options)
313
- assertNonNegativeInteger(amount)
314
-
315
- if (gasPrice) {
316
- assertNonNegativeInteger(gasPrice)
317
- }
318
-
319
- return chequebook.depositTokens(this.getKy(options), amount, gasPrice)
320
- }
321
-
322
- /**
323
- * Withdraw tokens from the chequebook to the overlay address
324
- *
325
- * @param amount Amount of tokens to withdraw (must be positive integer)
326
- * @param gasPrice Gas Price in WEI for the transaction call
327
- * @return string Hash of the transaction
328
- */
329
- async withdrawTokens(
330
- amount: number | NumberString,
331
- gasPrice?: NumberString,
332
- options?: RequestOptions,
333
- ): Promise<string> {
334
- assertRequestOptions(options)
335
- assertNonNegativeInteger(amount)
336
-
337
- if (gasPrice) {
338
- assertNonNegativeInteger(gasPrice)
339
- }
340
-
341
- return chequebook.withdrawTokens(this.getKy(options), amount, gasPrice)
342
- }
343
-
344
- /*
345
- * Settlements endpoint
346
- */
347
-
348
- /**
349
- * Get amount of sent and received from settlements with a peer
350
- *
351
- * @param address Swarm address of peer
352
- */
353
- async getSettlements(address: Address | string, options?: RequestOptions): Promise<Settlements> {
354
- assertRequestOptions(options)
355
- assertAddress(address)
356
-
357
- return settlements.getSettlements(this.getKy(options), address)
358
- }
359
-
360
- /**
361
- * Get settlements with all known peers and total amount sent or received
362
- */
363
- async getAllSettlements(options?: RequestOptions): Promise<AllSettlements> {
364
- assertRequestOptions(options)
365
-
366
- return settlements.getAllSettlements(this.getKy(options))
367
- }
368
-
369
- /**
370
- * Get health of node
371
- */
372
- async getHealth(options?: RequestOptions): Promise<Health> {
373
- assertRequestOptions(options)
374
-
375
- return status.getHealth(this.getKy(options))
376
- }
377
-
378
- /**
379
- * Connnects to a node and checks if it is a supported Bee version by the bee-js
380
- *
381
- * @returns true if the Bee node version is supported
382
- */
383
- async isSupportedVersion(options?: RequestOptions): Promise<boolean> | never {
384
- assertRequestOptions(options)
385
-
386
- return status.isSupportedVersion(this.getKy(options))
387
- }
388
-
389
- /**
390
- * Get reserve state
391
- */
392
- async getReserveState(options?: RequestOptions): Promise<ReserveState> {
393
- assertRequestOptions(options)
394
-
395
- return states.getReserveState(this.getKy(options))
396
- }
397
-
398
- /**
399
- * Get chain state
400
- */
401
- async getChainState(options?: RequestOptions): Promise<ChainState> {
402
- assertRequestOptions(options)
403
-
404
- return states.getChainState(this.getKy(options))
405
- }
406
-
407
- /**
408
- * Creates new postage batch from the funds that the node has available in its Ethereum account.
409
- *
410
- * For better understanding what each parameter means and what are the optimal values please see
411
- * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
412
- *
413
- * **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
414
- *
415
- * @param amount Amount that represents the value per chunk, has to be greater or equal zero.
416
- * @param depth Logarithm of the number of chunks that can be stamped with the batch.
417
- * @param options Options for creation of postage batch
418
- * @throws BeeArgumentError when negative amount or depth is specified
419
- * @throws TypeError if non-integer value is passed to amount or depth
420
- *
421
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
422
- * @see [Bee Debug API reference - `POST /stamps`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post)
423
- */
424
- async createPostageBatch(amount: NumberString, depth: number, options?: PostageBatchOptions): Promise<BatchId> {
425
- assertRequestOptions(options)
426
- assertNonNegativeInteger(amount)
427
- assertNonNegativeInteger(depth)
428
-
429
- if (depth < STAMPS_DEPTH_MIN) {
430
- throw new BeeArgumentError(`Depth has to be at least ${STAMPS_DEPTH_MIN}`, depth)
431
- }
432
-
433
- if (depth > STAMPS_DEPTH_MAX) {
434
- throw new BeeArgumentError(`Depth has to be at most ${STAMPS_DEPTH_MAX}`, depth)
435
- }
436
-
437
- if (options?.gasPrice) {
438
- assertNonNegativeInteger(options.gasPrice)
439
- }
440
-
441
- if (options?.immutableFlag !== undefined) {
442
- assertBoolean(options.immutableFlag)
443
- }
444
-
445
- return stamps.createPostageBatch(this.getKy(options), amount, depth, options)
446
- }
447
-
448
- /**
449
- * Return details for specific postage batch.
450
- *
451
- * @param postageBatchId Batch ID
452
- *
453
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
454
- * @see [Bee Debug API reference - `GET /stamps/${id}`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{id}/get)
455
- */
456
- async getPostageBatch(postageBatchId: BatchId | string, options?: RequestOptions): Promise<DebugPostageBatch> {
457
- assertRequestOptions(options)
458
- assertBatchId(postageBatchId)
459
-
460
- return stamps.getPostageBatch(this.getKy(options), postageBatchId)
461
- }
462
-
463
- /**
464
- * Return detailed information related to buckets for specific postage batch.
465
- *
466
- * @param postageBatchId Batch ID
467
- *
468
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
469
- * @see [Bee Debug API reference - `GET /stamps/${id}/buckets`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{id}~1buckets/get)
470
- */
471
- async getPostageBatchBuckets(
472
- postageBatchId: BatchId | string,
473
- options?: RequestOptions,
474
- ): Promise<PostageBatchBuckets> {
475
- assertRequestOptions(options)
476
- assertBatchId(postageBatchId)
477
-
478
- return stamps.getPostageBatchBuckets(this.getKy(options), postageBatchId)
479
- }
480
-
481
- /**
482
- * Return all postage batches that has the node available.
483
- *
484
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
485
- * @see [Bee Debug API reference - `GET /stamps`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps/get)
486
- */
487
- async getAllPostageBatch(options?: RequestOptions): Promise<DebugPostageBatch[]> {
488
- assertRequestOptions(options)
489
-
490
- return stamps.getAllPostageBatches(this.getKy(options))
491
- }
492
-
493
- /**
494
- * Return lists of all current pending transactions that the Bee made
495
- */
496
- async getAllPendingTransactions(options?: RequestOptions): Promise<TransactionInfo[]> {
497
- assertRequestOptions(options)
498
-
499
- return transactions.getAllTransactions(this.getKy(options))
500
- }
501
-
502
- /**
503
- * Return transaction information for specific transaction
504
- * @param transactionHash
505
- */
506
- async getPendingTransaction(
507
- transactionHash: TransactionHash | string,
508
- options?: RequestOptions,
509
- ): Promise<TransactionInfo> {
510
- assertRequestOptions(options)
511
- assertTransactionHash(transactionHash)
512
-
513
- return transactions.getTransaction(this.getKy(options), transactionHash)
514
- }
515
-
516
- /**
517
- * Rebroadcast already created transaction.
518
- * This is mainly needed when your transaction fall off mempool from other reason is not incorporated into block.
519
- *
520
- * @param transactionHash
521
- */
522
- async rebroadcastPendingTransaction(
523
- transactionHash: TransactionHash | string,
524
- options?: RequestOptions,
525
- ): Promise<TransactionHash> {
526
- assertRequestOptions(options)
527
- assertTransactionHash(transactionHash)
528
-
529
- return transactions.rebroadcastTransaction(this.getKy(options), transactionHash)
530
- }
531
-
532
- /**
533
- * Cancel currently pending transaction
534
- * @param transactionHash
535
- * @param gasPrice
536
- */
537
- async cancelPendingTransaction(
538
- transactionHash: TransactionHash | string,
539
- gasPrice?: NumberString,
540
- options?: RequestOptions,
541
- ): Promise<TransactionHash> {
542
- assertRequestOptions(options)
543
- assertTransactionHash(transactionHash)
544
-
545
- if (gasPrice) {
546
- assertNonNegativeInteger(gasPrice)
547
- }
548
-
549
- return transactions.cancelTransaction(this.getKy(options), transactionHash, gasPrice)
550
- }
551
-
552
- private getKy(options?: RequestOptions): Ky {
553
- if (!options) {
554
- return this.ky
555
- }
556
-
557
- return this.ky.extend(options)
558
- }
559
- }