@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
@@ -8,35 +8,4 @@ export class BeeArgumentError extends BeeError {
8
8
  super(message);
9
9
  this.value = value;
10
10
  }
11
- }
12
- export class BeeRequestError extends BeeError {
13
- /**
14
- * @param message
15
- * @param requestOptions KyOptions that were used to assemble the request. THIS MIGHT NOT BE COMPLETE! If custom Ky instance was used that has set defaults then these defaults are not visible in this object!
16
- */
17
- constructor(message, requestOptions) {
18
- super(message);
19
- this.requestOptions = requestOptions;
20
- }
21
- }
22
- export class BeeResponseError extends BeeError {
23
- /**
24
- * @param status HTTP status code number
25
- * @param response Response returned from the server
26
- * @param responseBody Response body as string which is returned from response.text() call
27
- * @param requestOptions KyOptions that were used to assemble the request. THIS MIGHT NOT BE COMPLETE! If custom Ky instance was used that has set defaults then these defaults are not visible in this object!
28
- * @param message
29
- */
30
- constructor(status, response, responseBody, requestOptions, message) {
31
- super(message);
32
- this.status = status;
33
- this.response = response;
34
- this.responseBody = responseBody;
35
- this.requestOptions = requestOptions;
36
- }
37
- }
38
- export class BeeNotAJsonError extends BeeError {
39
- constructor() {
40
- super(`Received response is not valid JSON.`);
41
- }
42
11
  }
@@ -26,9 +26,9 @@ function readTagUid(header) {
26
26
  return parseInt(header, 10);
27
27
  }
28
28
  export function readFileHeaders(headers) {
29
- const name = readContentDispositionFilename(headers.get('content-disposition'));
30
- const tagUid = readTagUid(headers.get('swarm-tag-uid'));
31
- const contentType = headers.get('content-type') || undefined;
29
+ const name = readContentDispositionFilename(headers['content-disposition']);
30
+ const tagUid = readTagUid(headers['swarm-tag-uid']);
31
+ const contentType = headers['content-type'] || undefined;
32
32
  return {
33
33
  name,
34
34
  tagUid,
@@ -1,150 +1,22 @@
1
- import { BeeError, BeeNotAJsonError, BeeRequestError, BeeResponseError } from "./error.js";
2
- import { normalizeToReadableStream } from "./stream.js";
3
- import { isObject, isStrictlyObject } from "./type.js";
4
- import { deepMerge } from "./merge.js";
5
- export const DEFAULT_KY_CONFIG = {
1
+ import axios from 'axios';
2
+ import { Objects } from 'cafe-utility';
3
+ export const DEFAULT_HTTP_CONFIG = {
6
4
  headers: {
7
5
  accept: 'application/json, text/plain, */*',
8
6
  'user-agent': `bee-js`
9
7
  }
10
8
  };
11
- function isHttpError(e) {
12
- return isObject(e) && typeof e.response !== 'undefined';
13
- }
14
- function isHttpRequestError(e) {
15
- return isObject(e) && typeof e.request !== 'undefined';
16
- }
17
- function headersToObject(header) {
18
- return [...header.entries()].reduce((obj, [key, val]) => {
19
- obj[key] = val;
20
- return obj;
21
- }, {});
22
- }
23
- function wrapRequest(request) {
24
- return {
25
- url: request.url,
26
- method: request.method.toUpperCase(),
27
- headers: headersToObject(request.headers)
28
- };
29
- }
30
- export function wrapRequestClosure(cb) {
31
- return async request => {
32
- await cb(wrapRequest(request));
33
- };
34
- }
35
- export function wrapResponseClosure(cb) {
36
- return async (request, options, response) => {
37
- await cb({
38
- headers: headersToObject(response.headers),
39
- status: response.status,
40
- statusText: response.statusText,
41
- request: wrapRequest(request)
42
- });
43
- };
44
- }
45
9
  /**
46
- * Filters out entries that has undefined value from headers object.
47
- * Modifies the original object!
48
- *
49
- * @param obj
10
+ * Main function to make HTTP requests.
11
+ * @param options User defined settings
12
+ * @param config Internal settings and/or Bee settings
50
13
  */
51
- // eslint-disable-next-line @typescript-eslint/ban-types
52
- export function filterHeaders(obj) {
53
- if (obj === undefined) {
54
- return undefined;
55
- }
56
- isStrictlyObject(obj);
57
- const typedObj = obj;
58
- for (const key in typedObj) {
59
- if (typedObj[key] === undefined) {
60
- delete typedObj[key];
61
- }
62
- }
63
- if (Object.keys(typedObj).length === 0) {
64
- return undefined;
65
- }
66
- return typedObj;
67
- }
68
- /**
69
- * Main utility function to make HTTP requests.
70
- * @param kyOptions
71
- * @param config
72
- */
73
- export async function http(kyOptions, config) {
14
+ export async function http(options, config) {
74
15
  try {
75
- const ky = await getKy();
76
- const {
77
- path,
78
- responseType,
79
- ...kyConfig
80
- } = deepMerge(kyOptions, config);
81
- const response = await ky(path, {
82
- ...kyConfig,
83
- searchParams: filterHeaders(kyConfig.searchParams)
84
- });
85
- switch (responseType) {
86
- case 'stream':
87
- if (!response.body) {
88
- throw new BeeError('Response was expected to get data but did not get any!');
89
- }
90
- response.parsedData = normalizeToReadableStream(response.body);
91
- break;
92
- case 'arraybuffer':
93
- response.parsedData = await response.arrayBuffer();
94
- break;
95
- case 'json':
96
- try {
97
- response.parsedData = await response.json();
98
- } catch (e) {
99
- throw new BeeNotAJsonError();
100
- }
101
- break;
102
- default:
103
- break;
104
- // If responseType is not set, then no data are expected
105
- }
106
-
16
+ const requestConfig = Objects.deepMerge3(DEFAULT_HTTP_CONFIG, config, options);
17
+ const response = await axios(requestConfig);
107
18
  return response;
108
19
  } catch (e) {
109
- // Passthrough thrown errors
110
- if (e instanceof BeeNotAJsonError) {
111
- throw e;
112
- }
113
- if (isHttpError(e)) {
114
- let message;
115
- // We store the response body here as it can be read only once in Response's lifecycle so to make it exposed
116
- // to the user in the BeeResponseError, for further analysis.
117
- const body = await e.response.text();
118
- try {
119
- // The response can be Bee's JSON with structure `{code, message}` lets try to parse it
120
- message = JSON.parse(body).message;
121
- } catch (e) {}
122
- if (message) {
123
- throw new BeeResponseError(e.response.status, e.response, body, config, `${e.response.statusText}: ${message}`);
124
- } else {
125
- throw new BeeResponseError(e.response.status, e.response, body, config, e.response.statusText);
126
- }
127
- } else if (isHttpRequestError(e)) {
128
- throw new BeeRequestError(e.message, config);
129
- } else {
130
- // Node 18 has native `fetch` implementation called Undici. Errors from this implementation have top level generic
131
- // message "fetch failed" with the more specific error placed into `cause` property. Instead of "fetch failed" we
132
- // expose the underlying problem.
133
- if (e.cause) {
134
- throw new BeeError(e.cause.message);
135
- }
136
- throw new BeeError(e.message);
137
- }
138
- }
139
- }
140
- let ky;
141
- async function getKy() {
142
- if (ky) {
143
- return ky;
144
- }
145
- ky = (await import('ky-universal')).default;
146
- if (!ky) {
147
- throw new Error('Ky was not found while it should have been!');
20
+ throw e;
148
21
  }
149
- return ky;
150
22
  }
@@ -1,9 +1,9 @@
1
- import { ADDRESS_HEX_LENGTH, BATCH_ID_HEX_LENGTH, ENCRYPTED_REFERENCE_HEX_LENGTH, PUBKEY_HEX_LENGTH, REFERENCE_HEX_LENGTH, TAGS_LIMIT_MAX, TAGS_LIMIT_MIN, PSS_TARGET_HEX_LENGTH_MAX } from "../types/index.js";
1
+ import { decodeCid, encodeReference } from '@ethersphere/swarm-cid';
2
+ import { ADDRESS_HEX_LENGTH, BATCH_ID_HEX_LENGTH, ENCRYPTED_REFERENCE_HEX_LENGTH, PSS_TARGET_HEX_LENGTH_MAX, PUBKEY_HEX_LENGTH, REFERENCE_HEX_LENGTH, TAGS_LIMIT_MAX, TAGS_LIMIT_MIN } from "../types/index.js";
2
3
  import { BeeArgumentError, BeeError } from "./error.js";
3
4
  import { isFile } from "./file.js";
4
5
  import { assertHexString, assertPrefixedHexString, isHexString } from "./hex.js";
5
6
  import { isReadable } from "./stream.js";
6
- import { decodeCid, encodeReference } from '@ethersphere/swarm-cid';
7
7
  export function isUint8Array(obj) {
8
8
  return obj instanceof Uint8Array;
9
9
  }
@@ -164,9 +164,6 @@ export function assertRequestOptions(value, name = 'RequestOptions') {
164
164
  if (options.timeout) {
165
165
  assertNonNegativeInteger(options.timeout, `${name}.timeout`);
166
166
  }
167
- if (options.fetch && typeof options.fetch !== 'function') {
168
- throw new TypeError(`${name}.fetch has to be a function or undefined!`);
169
- }
170
167
  }
171
168
  export function assertUploadOptions(value, name = 'UploadOptions') {
172
169
  if (!isStrictlyObject(value)) {
@@ -1,5 +1,5 @@
1
- import type { Address, AllSettlements, BalanceResponse, BeeVersions, ChainState, ChequebookAddressResponse, ChequebookBalanceResponse, ExtendedTag, Health, LastCashoutActionResponse, LastChequesForPeerResponse, LastChequesResponse, NodeAddresses, NodeInfo, NumberString, Peer, PeerBalance, PingResponse, PostageBatch, PostageBatchBuckets, RedistributionState, RemovePeerResponse, ReserveState, Settlements, Topology, TransactionHash, TransactionInfo, WalletBalance } from './types';
2
- import { BatchId, BeeOptions, CashoutOptions, PostageBatchOptions, RequestOptions, Tag, TransactionOptions } from './types';
1
+ import type { Address, AllSettlements, BalanceResponse, BeeRequestOptions, BeeVersions, ChainState, ChequebookAddressResponse, ChequebookBalanceResponse, ExtendedTag, Health, LastCashoutActionResponse, LastChequesForPeerResponse, LastChequesResponse, NodeAddresses, NodeInfo, NumberString, Peer, PeerBalance, PingResponse, PostageBatch, PostageBatchBuckets, RedistributionState, RemovePeerResponse, ReserveState, Settlements, Topology, TransactionHash, TransactionInfo, WalletBalance } from './types';
2
+ import { BatchId, BeeOptions, CashoutOptions, PostageBatchOptions, Tag, TransactionOptions } from './types';
3
3
  export declare class BeeDebug {
4
4
  /**
5
5
  * URL on which is the Debug API of Bee node exposed
@@ -9,10 +9,10 @@ export declare class BeeDebug {
9
9
  * Ky instance that defines connection to Bee node
10
10
  * @private
11
11
  */
12
- private readonly kyOptions;
12
+ private readonly requestOptions;
13
13
  constructor(url: string, options?: BeeOptions);
14
- getNodeAddresses(options?: RequestOptions): Promise<NodeAddresses>;
15
- getBlocklist(options?: RequestOptions): Promise<Peer[]>;
14
+ getNodeAddresses(options?: BeeRequestOptions): Promise<NodeAddresses>;
15
+ getBlocklist(options?: BeeRequestOptions): Promise<Peer[]>;
16
16
  /**
17
17
  * Retrieve tag extended information from Bee node
18
18
  *
@@ -23,61 +23,61 @@ export declare class BeeDebug {
23
23
  * @see [Bee API reference - `GET /tags/{uid}`](https://docs.ethswarm.org/debug-api/#tag/Tag)
24
24
  *
25
25
  */
26
- retrieveExtendedTag(tagUid: number | Tag, options?: RequestOptions): Promise<ExtendedTag>;
26
+ retrieveExtendedTag(tagUid: number | Tag, options?: BeeRequestOptions): Promise<ExtendedTag>;
27
27
  /**
28
28
  * Get list of peers for this node
29
29
  */
30
- getPeers(options?: RequestOptions): Promise<Peer[]>;
31
- removePeer(peer: string | Address, options?: RequestOptions): Promise<RemovePeerResponse>;
32
- getTopology(options?: RequestOptions): Promise<Topology>;
33
- pingPeer(peer: string | Address, options?: RequestOptions): Promise<PingResponse>;
30
+ getPeers(options?: BeeRequestOptions): Promise<Peer[]>;
31
+ removePeer(peer: string | Address, options?: BeeRequestOptions): Promise<RemovePeerResponse>;
32
+ getTopology(options?: BeeRequestOptions): Promise<Topology>;
33
+ pingPeer(peer: string | Address, options?: BeeRequestOptions): Promise<PingResponse>;
34
34
  /**
35
35
  * Get the balances with all known peers including prepaid services
36
36
  */
37
- getAllBalances(options?: RequestOptions): Promise<BalanceResponse>;
37
+ getAllBalances(options?: BeeRequestOptions): Promise<BalanceResponse>;
38
38
  /**
39
39
  * Get the balances with a specific peer including prepaid services
40
40
  *
41
41
  * @param address Swarm address of peer
42
42
  */
43
- getPeerBalance(address: Address | string, options?: RequestOptions): Promise<PeerBalance>;
43
+ getPeerBalance(address: Address | string, options?: BeeRequestOptions): Promise<PeerBalance>;
44
44
  /**
45
45
  * Get the past due consumption balances with all known peers
46
46
  */
47
- getPastDueConsumptionBalances(options?: RequestOptions): Promise<BalanceResponse>;
47
+ getPastDueConsumptionBalances(options?: BeeRequestOptions): Promise<BalanceResponse>;
48
48
  /**
49
49
  * Get the past due consumption balance with a specific peer
50
50
  *
51
51
  * @param address Swarm address of peer
52
52
  */
53
- getPastDueConsumptionPeerBalance(address: Address | string, options?: RequestOptions): Promise<PeerBalance>;
53
+ getPastDueConsumptionPeerBalance(address: Address | string, options?: BeeRequestOptions): Promise<PeerBalance>;
54
54
  /**
55
55
  * Get the address of the chequebook contract used.
56
56
  *
57
57
  * **Warning:** The address is returned with 0x prefix unlike all other calls.
58
58
  * https://github.com/ethersphere/bee/issues/1443
59
59
  */
60
- getChequebookAddress(options?: RequestOptions): Promise<ChequebookAddressResponse>;
60
+ getChequebookAddress(options?: BeeRequestOptions): Promise<ChequebookAddressResponse>;
61
61
  /**
62
62
  * Get the balance of the chequebook
63
63
  */
64
- getChequebookBalance(options?: RequestOptions): Promise<ChequebookBalanceResponse>;
64
+ getChequebookBalance(options?: BeeRequestOptions): Promise<ChequebookBalanceResponse>;
65
65
  /**
66
66
  * Get last cheques for all peers
67
67
  */
68
- getLastCheques(options?: RequestOptions): Promise<LastChequesResponse>;
68
+ getLastCheques(options?: BeeRequestOptions): Promise<LastChequesResponse>;
69
69
  /**
70
70
  * Get last cheques for the peer
71
71
  *
72
72
  * @param address Swarm address of peer
73
73
  */
74
- getLastChequesForPeer(address: Address | string, options?: RequestOptions): Promise<LastChequesForPeerResponse>;
74
+ getLastChequesForPeer(address: Address | string, options?: BeeRequestOptions): Promise<LastChequesForPeerResponse>;
75
75
  /**
76
76
  * Get last cashout action for the peer
77
77
  *
78
78
  * @param address Swarm address of peer
79
79
  */
80
- getLastCashoutAction(address: Address | string, options?: RequestOptions): Promise<LastCashoutActionResponse>;
80
+ getLastCashoutAction(address: Address | string, options?: BeeRequestOptions): Promise<LastCashoutActionResponse>;
81
81
  /**
82
82
  * Cashout the last cheque for the peer
83
83
  *
@@ -86,7 +86,7 @@ export declare class BeeDebug {
86
86
  * @param options.gasPrice Gas price for the cashout transaction in WEI
87
87
  * @param options.gasLimit Gas limit for the cashout transaction in WEI
88
88
  */
89
- cashoutLastCheque(address: string | Address, options?: CashoutOptions): Promise<string>;
89
+ cashoutLastCheque(address: string | Address, options?: CashoutOptions, requestOptions?: BeeRequestOptions): Promise<string>;
90
90
  /**
91
91
  * Deposit tokens from overlay address into chequebook
92
92
  *
@@ -94,7 +94,7 @@ export declare class BeeDebug {
94
94
  * @param gasPrice Gas Price in WEI for the transaction call
95
95
  * @return string Hash of the transaction
96
96
  */
97
- depositTokens(amount: number | NumberString, gasPrice?: NumberString, options?: RequestOptions): Promise<string>;
97
+ depositTokens(amount: number | NumberString, gasPrice?: NumberString, options?: BeeRequestOptions): Promise<string>;
98
98
  /**
99
99
  * Withdraw tokens from the chequebook to the overlay address
100
100
  *
@@ -102,36 +102,36 @@ export declare class BeeDebug {
102
102
  * @param gasPrice Gas Price in WEI for the transaction call
103
103
  * @return string Hash of the transaction
104
104
  */
105
- withdrawTokens(amount: number | NumberString, gasPrice?: NumberString, options?: RequestOptions): Promise<string>;
105
+ withdrawTokens(amount: number | NumberString, gasPrice?: NumberString, options?: BeeRequestOptions): Promise<string>;
106
106
  /**
107
107
  * Get amount of sent and received from settlements with a peer
108
108
  *
109
109
  * @param address Swarm address of peer
110
110
  */
111
- getSettlements(address: Address | string, options?: RequestOptions): Promise<Settlements>;
111
+ getSettlements(address: Address | string, options?: BeeRequestOptions): Promise<Settlements>;
112
112
  /**
113
113
  * Get settlements with all known peers and total amount sent or received
114
114
  */
115
- getAllSettlements(options?: RequestOptions): Promise<AllSettlements>;
115
+ getAllSettlements(options?: BeeRequestOptions): Promise<AllSettlements>;
116
116
  /**
117
117
  * Get health of node
118
118
  */
119
- getHealth(options?: RequestOptions): Promise<Health>;
119
+ getHealth(options?: BeeRequestOptions): Promise<Health>;
120
120
  /**
121
121
  * Get readiness of node
122
122
  */
123
- getReadiness(options?: RequestOptions): Promise<boolean>;
123
+ getReadiness(options?: BeeRequestOptions): Promise<boolean>;
124
124
  /**
125
125
  * Get mode information of node
126
126
  */
127
- getNodeInfo(options?: RequestOptions): Promise<NodeInfo>;
127
+ getNodeInfo(options?: BeeRequestOptions): Promise<NodeInfo>;
128
128
  /**
129
129
  * Connnects to a node and checks if it is a supported Bee version by the bee-js
130
130
  *
131
131
  * @returns true if the Bee node version is supported
132
132
  * @deprecated Use `BeeDebug.isSupportedExactVersion()` instead
133
133
  */
134
- isSupportedVersion(options?: RequestOptions): Promise<boolean> | never;
134
+ isSupportedVersion(options?: BeeRequestOptions): Promise<boolean> | never;
135
135
  /**
136
136
  * Connects to a node and checks if its version matches with the one that bee-js supports.
137
137
  *
@@ -142,7 +142,7 @@ export declare class BeeDebug {
142
142
  *
143
143
  * @param options
144
144
  */
145
- isSupportedExactVersion(options?: RequestOptions): Promise<boolean> | never;
145
+ isSupportedExactVersion(options?: BeeRequestOptions): Promise<boolean> | never;
146
146
  /**
147
147
  * Connects to a node and checks if its main's API version matches with the one that bee-js supports.
148
148
  *
@@ -151,7 +151,7 @@ export declare class BeeDebug {
151
151
  *
152
152
  * @param options
153
153
  */
154
- isSupportedMainApiVersion(options?: RequestOptions): Promise<boolean> | never;
154
+ isSupportedMainApiVersion(options?: BeeRequestOptions): Promise<boolean> | never;
155
155
  /**
156
156
  * Connects to a node and checks if its Debug API version matches with the one that bee-js supports.
157
157
  *
@@ -160,7 +160,7 @@ export declare class BeeDebug {
160
160
  *
161
161
  * @param options
162
162
  */
163
- isSupportedDebugApiVersion(options?: RequestOptions): Promise<boolean> | never;
163
+ isSupportedDebugApiVersion(options?: BeeRequestOptions): Promise<boolean> | never;
164
164
  /**
165
165
  *
166
166
  * Connects to a node and checks if its Main and Debug API versions matches with the one that bee-js supports.
@@ -169,28 +169,28 @@ export declare class BeeDebug {
169
169
  *
170
170
  * @param options
171
171
  */
172
- isSupportedApiVersion(options?: RequestOptions): Promise<boolean> | never;
172
+ isSupportedApiVersion(options?: BeeRequestOptions): Promise<boolean> | never;
173
173
  /**
174
174
  * Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
175
175
  * and versions that bee-js supports (properties prefixed with `supported*`).
176
176
  *
177
177
  * @param options
178
178
  */
179
- getVersions(options?: RequestOptions): Promise<BeeVersions> | never;
179
+ getVersions(options?: BeeRequestOptions): Promise<BeeVersions> | never;
180
180
  /**
181
181
  * Get reserve state
182
182
  */
183
- getReserveState(options?: RequestOptions): Promise<ReserveState>;
183
+ getReserveState(options?: BeeRequestOptions): Promise<ReserveState>;
184
184
  /**
185
185
  * Get chain state
186
186
  */
187
- getChainState(options?: RequestOptions): Promise<ChainState>;
187
+ getChainState(options?: BeeRequestOptions): Promise<ChainState>;
188
188
  /**
189
189
  * Get wallet balances for xDai and BZZ of the Bee node
190
190
  *
191
191
  * @param options
192
192
  */
193
- getWalletBalance(options?: RequestOptions): Promise<WalletBalance>;
193
+ getWalletBalance(options?: BeeRequestOptions): Promise<WalletBalance>;
194
194
  /**
195
195
  * Creates new postage batch from the funds that the node has available in its Ethereum account.
196
196
  *
@@ -208,7 +208,7 @@ export declare class BeeDebug {
208
208
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
209
209
  * @see [Bee Debug API reference - `POST /stamps`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post)
210
210
  */
211
- createPostageBatch(amount: NumberString, depth: number, options?: PostageBatchOptions): Promise<BatchId>;
211
+ createPostageBatch(amount: NumberString, depth: number, options?: PostageBatchOptions, requestOptions?: BeeRequestOptions): Promise<BatchId>;
212
212
  /**
213
213
  * Topup a fresh amount of BZZ to given Postage Batch.
214
214
  *
@@ -224,7 +224,7 @@ export declare class BeeDebug {
224
224
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
225
225
  * @see [Bee Debug API reference - `PATCH /stamps/topup/${id}/${amount}`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1topup~1{id}~1{amount}/patch)
226
226
  */
227
- topUpBatch(postageBatchId: BatchId | string, amount: NumberString, options?: RequestOptions): Promise<void>;
227
+ topUpBatch(postageBatchId: BatchId | string, amount: NumberString, options?: BeeRequestOptions): Promise<void>;
228
228
  /**
229
229
  * Dilute given Postage Batch with new depth (that has to be bigger then the original depth), which allows
230
230
  * the Postage Batch to be used for more chunks.
@@ -241,7 +241,7 @@ export declare class BeeDebug {
241
241
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
242
242
  * @see [Bee Debug API reference - `PATCH /stamps/topup/${id}/${amount}`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1topup~1{id}~1{amount}/patch)
243
243
  */
244
- diluteBatch(postageBatchId: BatchId | string, depth: number, options?: RequestOptions): Promise<void>;
244
+ diluteBatch(postageBatchId: BatchId | string, depth: number, options?: BeeRequestOptions): Promise<void>;
245
245
  /**
246
246
  * Return details for specific postage batch.
247
247
  *
@@ -250,7 +250,7 @@ export declare class BeeDebug {
250
250
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
251
251
  * @see [Bee Debug API reference - `GET /stamps/${id}`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{id}/get)
252
252
  */
253
- getPostageBatch(postageBatchId: BatchId | string, options?: RequestOptions): Promise<PostageBatch>;
253
+ getPostageBatch(postageBatchId: BatchId | string, options?: BeeRequestOptions): Promise<PostageBatch>;
254
254
  /**
255
255
  * Return detailed information related to buckets for specific postage batch.
256
256
  *
@@ -259,42 +259,42 @@ export declare class BeeDebug {
259
259
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
260
260
  * @see [Bee Debug API reference - `GET /stamps/${id}/buckets`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{id}~1buckets/get)
261
261
  */
262
- getPostageBatchBuckets(postageBatchId: BatchId | string, options?: RequestOptions): Promise<PostageBatchBuckets>;
262
+ getPostageBatchBuckets(postageBatchId: BatchId | string, options?: BeeRequestOptions): Promise<PostageBatchBuckets>;
263
263
  /**
264
264
  * Return all postage batches that has the node available.
265
265
  *
266
266
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
267
267
  * @see [Bee Debug API reference - `GET /stamps`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps/get)
268
268
  */
269
- getAllPostageBatch(options?: RequestOptions): Promise<PostageBatch[]>;
269
+ getAllPostageBatch(options?: BeeRequestOptions): Promise<PostageBatch[]>;
270
270
  /**
271
271
  * Return lists of all current pending transactions that the Bee made
272
272
  */
273
- getAllPendingTransactions(options?: RequestOptions): Promise<TransactionInfo[]>;
273
+ getAllPendingTransactions(options?: BeeRequestOptions): Promise<TransactionInfo[]>;
274
274
  /**
275
275
  * Return transaction information for specific transaction
276
276
  * @param transactionHash
277
277
  */
278
- getPendingTransaction(transactionHash: TransactionHash | string, options?: RequestOptions): Promise<TransactionInfo>;
278
+ getPendingTransaction(transactionHash: TransactionHash | string, options?: BeeRequestOptions): Promise<TransactionInfo>;
279
279
  /**
280
280
  * Rebroadcast already created transaction.
281
281
  * This is mainly needed when your transaction fall off mempool from other reason is not incorporated into block.
282
282
  *
283
283
  * @param transactionHash
284
284
  */
285
- rebroadcastPendingTransaction(transactionHash: TransactionHash | string, options?: RequestOptions): Promise<TransactionHash>;
285
+ rebroadcastPendingTransaction(transactionHash: TransactionHash | string, options?: BeeRequestOptions): Promise<TransactionHash>;
286
286
  /**
287
287
  * Cancel currently pending transaction
288
288
  * @param transactionHash
289
289
  * @param gasPrice
290
290
  */
291
- cancelPendingTransaction(transactionHash: TransactionHash | string, gasPrice?: NumberString, options?: RequestOptions): Promise<TransactionHash>;
291
+ cancelPendingTransaction(transactionHash: TransactionHash | string, gasPrice?: NumberString, options?: BeeRequestOptions): Promise<TransactionHash>;
292
292
  /**
293
293
  * Gets the staked amount of BZZ (in PLUR unit) as number string.
294
294
  *
295
295
  * @param options
296
296
  */
297
- getStake(options?: RequestOptions): Promise<NumberString>;
297
+ getStake(options?: BeeRequestOptions): Promise<NumberString>;
298
298
  /**
299
299
  * Deposits given amount of BZZ token (in PLUR unit).
300
300
  *
@@ -303,13 +303,13 @@ export declare class BeeDebug {
303
303
  * @param amount Amount of BZZ token (in PLUR unit) to be staked. Minimum is 100_000_000_000_000_000 PLUR (10 BZZ).
304
304
  * @param options
305
305
  */
306
- depositStake(amount: NumberString, options?: RequestOptions & TransactionOptions): Promise<void>;
306
+ depositStake(amount: NumberString, options?: TransactionOptions, requestOptions?: BeeRequestOptions): Promise<void>;
307
307
  /**
308
308
  * Get current status of node in redistribution game
309
309
  *
310
310
  * @param options
311
311
  */
312
- getRedistributionState(options?: RequestOptions): Promise<RedistributionState>;
312
+ getRedistributionState(options?: BeeRequestOptions): Promise<RedistributionState>;
313
313
  private waitForUsablePostageStamp;
314
- private getKyOptionsForCall;
314
+ private getRequestOptionsForCall;
315
315
  }