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