@ethersphere/bee-js 5.1.1 → 5.1.2
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/README.md +14 -6
- package/dist/223.index.browser.min.js +3 -0
- package/dist/223.index.browser.min.js.LICENSE.txt +1 -0
- package/dist/223.index.browser.min.js.map +1 -0
- package/dist/cjs/bee-debug.js +208 -312
- package/dist/cjs/bee.js +258 -353
- package/dist/cjs/chunk/signer.js +11 -22
- package/dist/cjs/chunk/soc.js +33 -50
- package/dist/cjs/chunk/span.js +1 -1
- package/dist/cjs/feed/index.js +50 -65
- package/dist/cjs/feed/json.js +8 -21
- package/dist/cjs/feed/retrievable.js +14 -27
- package/dist/cjs/modules/bytes.js +25 -37
- package/dist/cjs/modules/bzz.js +63 -68
- package/dist/cjs/modules/chunk.js +17 -27
- package/dist/cjs/modules/debug/balance.js +24 -41
- package/dist/cjs/modules/debug/chequebook.js +71 -96
- package/dist/cjs/modules/debug/chunk.js +13 -26
- package/dist/cjs/modules/debug/connectivity.js +32 -53
- package/dist/cjs/modules/debug/settlements.js +12 -25
- package/dist/cjs/modules/debug/stake.js +20 -33
- package/dist/cjs/modules/debug/stamps.js +45 -66
- package/dist/cjs/modules/debug/states.js +27 -40
- package/dist/cjs/modules/debug/status.js +53 -80
- package/dist/cjs/modules/debug/tag.js +6 -17
- package/dist/cjs/modules/debug/transactions.js +23 -40
- package/dist/cjs/modules/feed.js +17 -27
- package/dist/cjs/modules/pinning.js +24 -41
- package/dist/cjs/modules/pss.js +9 -20
- package/dist/cjs/modules/soc.js +12 -20
- package/dist/cjs/modules/status.js +4 -15
- package/dist/cjs/modules/stewardship.js +10 -23
- package/dist/cjs/modules/tag.js +28 -47
- package/dist/cjs/utils/collection.browser.js +4 -17
- package/dist/cjs/utils/collection.js +11 -22
- package/dist/cjs/utils/collection.node.js +42 -86
- package/dist/cjs/utils/data.browser.js +46 -59
- package/dist/cjs/utils/data.js +22 -35
- package/dist/cjs/utils/eth.js +31 -43
- package/dist/cjs/utils/file.js +9 -20
- package/dist/cjs/utils/headers.js +4 -4
- package/dist/cjs/utils/http.js +78 -93
- package/dist/cjs/utils/merge.js +1 -1
- package/dist/cjs/utils/sleep.js +2 -13
- package/dist/cjs/utils/type.js +14 -12
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.LICENSE.txt +1 -3
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-debug.js +209 -450
- package/dist/mjs/bee.js +256 -491
- package/dist/mjs/chunk/bmt.js +4 -10
- package/dist/mjs/chunk/cac.js +0 -3
- package/dist/mjs/chunk/signer.js +12 -63
- package/dist/mjs/chunk/soc.js +33 -85
- package/dist/mjs/chunk/span.js +3 -6
- package/dist/mjs/feed/identifier.js +0 -6
- package/dist/mjs/feed/index.js +53 -97
- package/dist/mjs/feed/json.js +10 -49
- package/dist/mjs/feed/retrievable.js +13 -64
- package/dist/mjs/feed/topic.js +0 -2
- package/dist/mjs/index.js +1 -2
- package/dist/mjs/modules/bytes.js +25 -65
- package/dist/mjs/modules/bzz.js +64 -108
- package/dist/mjs/modules/chunk.js +17 -54
- package/dist/mjs/modules/debug/balance.js +24 -68
- package/dist/mjs/modules/debug/chequebook.js +75 -138
- package/dist/mjs/modules/debug/chunk.js +13 -51
- package/dist/mjs/modules/debug/connectivity.js +32 -76
- package/dist/mjs/modules/debug/settlements.js +12 -50
- package/dist/mjs/modules/debug/stake.js +20 -61
- package/dist/mjs/modules/debug/stamps.js +47 -94
- package/dist/mjs/modules/debug/states.js +25 -66
- package/dist/mjs/modules/debug/status.js +66 -125
- package/dist/mjs/modules/debug/tag.js +6 -41
- package/dist/mjs/modules/debug/transactions.js +25 -69
- package/dist/mjs/modules/feed.js +17 -57
- package/dist/mjs/modules/pinning.js +24 -68
- package/dist/mjs/modules/pss.js +11 -47
- package/dist/mjs/modules/soc.js +14 -48
- package/dist/mjs/modules/status.js +4 -39
- package/dist/mjs/modules/stewardship.js +10 -47
- package/dist/mjs/modules/tag.js +31 -78
- package/dist/mjs/types/debug.js +0 -1
- package/dist/mjs/types/index.js +0 -4
- package/dist/mjs/utils/bytes.js +6 -14
- package/dist/mjs/utils/collection.browser.js +4 -42
- package/dist/mjs/utils/collection.js +11 -57
- package/dist/mjs/utils/collection.node.js +42 -150
- package/dist/mjs/utils/data.browser.js +49 -94
- package/dist/mjs/utils/data.js +19 -62
- package/dist/mjs/utils/error.js +0 -5
- package/dist/mjs/utils/eth.js +37 -95
- package/dist/mjs/utils/file.js +11 -50
- package/dist/mjs/utils/hash.js +0 -1
- package/dist/mjs/utils/headers.js +6 -14
- package/dist/mjs/utils/hex.js +6 -25
- package/dist/mjs/utils/http.js +80 -138
- package/dist/mjs/utils/merge.js +3 -7
- package/dist/mjs/utils/pss.js +0 -2
- package/dist/mjs/utils/reference.js +2 -5
- package/dist/mjs/utils/sleep.js +2 -37
- package/dist/mjs/utils/stream.js +0 -23
- package/dist/mjs/utils/tar.js +2 -5
- package/dist/mjs/utils/type.js +18 -82
- package/dist/mjs/utils/uint64.js +0 -1
- package/dist/mjs/utils/url.js +2 -10
- package/dist/types/bee-debug.d.ts +2 -2
- package/dist/types/bee.d.ts +2 -26
- package/dist/types/chunk/cac.d.ts +1 -1
- package/dist/types/chunk/soc.d.ts +8 -7
- package/dist/types/feed/index.d.ts +9 -8
- package/dist/types/feed/type.d.ts +1 -1
- package/dist/types/modules/bytes.d.ts +6 -5
- package/dist/types/modules/bzz.d.ts +9 -8
- package/dist/types/modules/chunk.d.ts +5 -4
- package/dist/types/modules/debug/balance.d.ts +10 -9
- package/dist/types/modules/debug/chequebook.d.ts +18 -17
- package/dist/types/modules/debug/chunk.d.ts +6 -5
- package/dist/types/modules/debug/connectivity.d.ts +8 -7
- package/dist/types/modules/debug/settlements.d.ts +6 -5
- package/dist/types/modules/debug/stake.d.ts +5 -4
- package/dist/types/modules/debug/stamps.d.ts +8 -7
- package/dist/types/modules/debug/states.d.ts +8 -7
- package/dist/types/modules/debug/status.d.ts +15 -15
- package/dist/types/modules/debug/tag.d.ts +4 -3
- package/dist/types/modules/debug/transactions.d.ts +6 -5
- package/dist/types/modules/feed.d.ts +4 -3
- package/dist/types/modules/pinning.d.ts +8 -7
- package/dist/types/modules/pss.d.ts +4 -3
- package/dist/types/modules/soc.d.ts +3 -2
- package/dist/types/modules/status.d.ts +3 -3
- package/dist/types/modules/stewardship.d.ts +4 -3
- package/dist/types/modules/tag.d.ts +7 -6
- package/dist/types/types/debug.d.ts +1 -1
- package/dist/types/types/index.d.ts +30 -34
- package/dist/types/utils/eth.d.ts +3 -3
- package/dist/types/utils/hex.d.ts +2 -2
- package/dist/types/utils/http.d.ts +6 -6
- package/package.json +34 -39
- package/dist/cjs/types/ky-options.js +0 -8
- package/dist/cjs/types/ky-universal/common.js +0 -8
- package/dist/cjs/types/ky-universal/hooks.js +0 -8
- package/dist/cjs/types/ky-universal/retry.js +0 -8
- package/dist/mjs/types/ky-options.js +0 -7
- package/dist/mjs/types/ky-universal/common.js +0 -7
- package/dist/mjs/types/ky-universal/hooks.js +0 -7
- package/dist/mjs/types/ky-universal/retry.js +0 -7
- package/dist/types/types/ky-options.d.ts +0 -221
- package/dist/types/types/ky-universal/common.d.ts +0 -13
- package/dist/types/types/ky-universal/hooks.d.ts +0 -92
- package/dist/types/types/ky-universal/retry.d.ts +0 -38
package/dist/mjs/bee-debug.js
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
1
|
import * as connectivity from "./modules/debug/connectivity.js";
|
|
34
2
|
import * as balance from "./modules/debug/balance.js";
|
|
35
3
|
import * as chequebook from "./modules/debug/chequebook.js";
|
|
@@ -44,55 +12,44 @@ import { assertAddress, assertBatchId, assertCashoutOptions, assertNonNegativeIn
|
|
|
44
12
|
import { STAMPS_DEPTH_MAX, STAMPS_DEPTH_MIN } from "./types/index.js";
|
|
45
13
|
import * as tag from "./modules/debug/tag.js";
|
|
46
14
|
import * as stamps from "./modules/debug/stamps.js";
|
|
47
|
-
import {
|
|
15
|
+
import { DEFAULT_KY_CONFIG, wrapRequestClosure, wrapResponseClosure } from "./utils/http.js";
|
|
48
16
|
import { sleep } from "./utils/sleep.js";
|
|
17
|
+
import { deepMerge } from "./utils/merge.js";
|
|
49
18
|
export class BeeDebug {
|
|
50
19
|
constructor(url, options) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
assertBeeUrl(url); // Remove last slash if present, as our endpoint strings starts with `/...`
|
|
20
|
+
assertBeeUrl(url);
|
|
21
|
+
// Remove last slash if present, as our endpoint strings starts with `/...`
|
|
54
22
|
// which could lead to double slash in URL to which Bee responds with
|
|
55
23
|
// unnecessary redirects.
|
|
56
|
-
|
|
57
24
|
this.url = stripLastSlash(url);
|
|
58
25
|
const kyOptions = {
|
|
59
26
|
prefixUrl: this.url,
|
|
60
|
-
timeout:
|
|
61
|
-
retry: options
|
|
62
|
-
fetch: options
|
|
27
|
+
timeout: options?.timeout ?? false,
|
|
28
|
+
retry: options?.retry,
|
|
29
|
+
fetch: options?.fetch,
|
|
63
30
|
hooks: {
|
|
64
31
|
beforeRequest: [],
|
|
65
32
|
afterResponse: []
|
|
66
33
|
}
|
|
67
34
|
};
|
|
68
|
-
|
|
69
|
-
if (options === null || options === void 0 ? void 0 : options.defaultHeaders) {
|
|
35
|
+
if (options?.defaultHeaders) {
|
|
70
36
|
kyOptions.headers = options.defaultHeaders;
|
|
71
37
|
}
|
|
72
|
-
|
|
73
|
-
if (options === null || options === void 0 ? void 0 : options.onRequest) {
|
|
38
|
+
if (options?.onRequest) {
|
|
74
39
|
kyOptions.hooks.beforeRequest.push(wrapRequestClosure(options.onRequest));
|
|
75
40
|
}
|
|
76
|
-
|
|
77
|
-
if (options === null || options === void 0 ? void 0 : options.onResponse) {
|
|
41
|
+
if (options?.onResponse) {
|
|
78
42
|
kyOptions.hooks.afterResponse.push(wrapResponseClosure(options.onResponse));
|
|
79
43
|
}
|
|
80
|
-
|
|
81
|
-
this.ky = makeDefaultKy(kyOptions);
|
|
44
|
+
this.kyOptions = deepMerge(DEFAULT_KY_CONFIG, kyOptions);
|
|
82
45
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return
|
|
86
|
-
assertRequestOptions(options);
|
|
87
|
-
return connectivity.getNodeAddresses(this.getKy(options));
|
|
88
|
-
});
|
|
46
|
+
async getNodeAddresses(options) {
|
|
47
|
+
assertRequestOptions(options);
|
|
48
|
+
return connectivity.getNodeAddresses(this.getKyOptionsForCall(options));
|
|
89
49
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return
|
|
93
|
-
assertRequestOptions(options);
|
|
94
|
-
return connectivity.getBlocklist(this.getKy(options));
|
|
95
|
-
});
|
|
50
|
+
async getBlocklist(options) {
|
|
51
|
+
assertRequestOptions(options);
|
|
52
|
+
return connectivity.getBlocklist(this.getKyOptionsForCall(options));
|
|
96
53
|
}
|
|
97
54
|
/**
|
|
98
55
|
* Retrieve tag extended information from Bee node
|
|
@@ -104,178 +61,121 @@ export class BeeDebug {
|
|
|
104
61
|
* @see [Bee API reference - `GET /tags/{uid}`](https://docs.ethswarm.org/debug-api/#tag/Tag)
|
|
105
62
|
*
|
|
106
63
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
} else {
|
|
118
|
-
throw new TypeError('tagUid has to be either Tag or a number (UID)!');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return tag.retrieveExtendedTag(this.getKy(options), tagUid);
|
|
122
|
-
});
|
|
64
|
+
async retrieveExtendedTag(tagUid, options) {
|
|
65
|
+
assertRequestOptions(options);
|
|
66
|
+
if (isTag(tagUid)) {
|
|
67
|
+
tagUid = tagUid.uid;
|
|
68
|
+
} else if (typeof tagUid === 'number') {
|
|
69
|
+
assertNonNegativeInteger(tagUid, 'UID');
|
|
70
|
+
} else {
|
|
71
|
+
throw new TypeError('tagUid has to be either Tag or a number (UID)!');
|
|
72
|
+
}
|
|
73
|
+
return tag.retrieveExtendedTag(this.getKyOptionsForCall(options), tagUid);
|
|
123
74
|
}
|
|
124
75
|
/**
|
|
125
76
|
* Get list of peers for this node
|
|
126
77
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
getTopology(options) {
|
|
145
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
assertRequestOptions(options);
|
|
147
|
-
return connectivity.getTopology(this.getKy(options));
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
pingPeer(peer, options) {
|
|
152
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
assertRequestOptions(options);
|
|
154
|
-
assertAddress(peer);
|
|
155
|
-
return connectivity.pingPeer(this.getKy(options), peer);
|
|
156
|
-
});
|
|
78
|
+
async getPeers(options) {
|
|
79
|
+
assertRequestOptions(options);
|
|
80
|
+
return connectivity.getPeers(this.getKyOptionsForCall(options));
|
|
81
|
+
}
|
|
82
|
+
async removePeer(peer, options) {
|
|
83
|
+
assertRequestOptions(options);
|
|
84
|
+
assertAddress(peer);
|
|
85
|
+
return connectivity.removePeer(this.getKyOptionsForCall(options), peer);
|
|
86
|
+
}
|
|
87
|
+
async getTopology(options) {
|
|
88
|
+
assertRequestOptions(options);
|
|
89
|
+
return connectivity.getTopology(this.getKyOptionsForCall(options));
|
|
90
|
+
}
|
|
91
|
+
async pingPeer(peer, options) {
|
|
92
|
+
assertRequestOptions(options);
|
|
93
|
+
assertAddress(peer);
|
|
94
|
+
return connectivity.pingPeer(this.getKyOptionsForCall(options), peer);
|
|
157
95
|
}
|
|
158
96
|
/*
|
|
159
97
|
* Balance endpoints
|
|
160
98
|
*/
|
|
161
|
-
|
|
162
99
|
/**
|
|
163
100
|
* Get the balances with all known peers including prepaid services
|
|
164
101
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
-
assertRequestOptions(options);
|
|
170
|
-
return balance.getAllBalances(this.getKy(options));
|
|
171
|
-
});
|
|
102
|
+
async getAllBalances(options) {
|
|
103
|
+
assertRequestOptions(options);
|
|
104
|
+
return balance.getAllBalances(this.getKyOptionsForCall(options));
|
|
172
105
|
}
|
|
173
106
|
/**
|
|
174
107
|
* Get the balances with a specific peer including prepaid services
|
|
175
108
|
*
|
|
176
109
|
* @param address Swarm address of peer
|
|
177
110
|
*/
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
return
|
|
182
|
-
assertRequestOptions(options);
|
|
183
|
-
assertAddress(address);
|
|
184
|
-
return balance.getPeerBalance(this.getKy(options), address);
|
|
185
|
-
});
|
|
111
|
+
async getPeerBalance(address, options) {
|
|
112
|
+
assertRequestOptions(options);
|
|
113
|
+
assertAddress(address);
|
|
114
|
+
return balance.getPeerBalance(this.getKyOptionsForCall(options), address);
|
|
186
115
|
}
|
|
187
116
|
/**
|
|
188
117
|
* Get the past due consumption balances with all known peers
|
|
189
118
|
*/
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
-
assertRequestOptions(options);
|
|
195
|
-
return balance.getPastDueConsumptionBalances(this.getKy(options));
|
|
196
|
-
});
|
|
119
|
+
async getPastDueConsumptionBalances(options) {
|
|
120
|
+
assertRequestOptions(options);
|
|
121
|
+
return balance.getPastDueConsumptionBalances(this.getKyOptionsForCall(options));
|
|
197
122
|
}
|
|
198
123
|
/**
|
|
199
124
|
* Get the past due consumption balance with a specific peer
|
|
200
125
|
*
|
|
201
126
|
* @param address Swarm address of peer
|
|
202
127
|
*/
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return
|
|
207
|
-
assertRequestOptions(options);
|
|
208
|
-
assertAddress(address);
|
|
209
|
-
return balance.getPastDueConsumptionPeerBalance(this.getKy(options), address);
|
|
210
|
-
});
|
|
128
|
+
async getPastDueConsumptionPeerBalance(address, options) {
|
|
129
|
+
assertRequestOptions(options);
|
|
130
|
+
assertAddress(address);
|
|
131
|
+
return balance.getPastDueConsumptionPeerBalance(this.getKyOptionsForCall(options), address);
|
|
211
132
|
}
|
|
212
133
|
/*
|
|
213
134
|
* Chequebook endpoints
|
|
214
135
|
*/
|
|
215
|
-
|
|
216
136
|
/**
|
|
217
137
|
* Get the address of the chequebook contract used.
|
|
218
138
|
*
|
|
219
139
|
* **Warning:** The address is returned with 0x prefix unlike all other calls.
|
|
220
140
|
* https://github.com/ethersphere/bee/issues/1443
|
|
221
141
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
-
assertRequestOptions(options);
|
|
227
|
-
return chequebook.getChequebookAddress(this.getKy(options));
|
|
228
|
-
});
|
|
142
|
+
async getChequebookAddress(options) {
|
|
143
|
+
assertRequestOptions(options);
|
|
144
|
+
return chequebook.getChequebookAddress(this.getKyOptionsForCall(options));
|
|
229
145
|
}
|
|
230
146
|
/**
|
|
231
147
|
* Get the balance of the chequebook
|
|
232
148
|
*/
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
237
|
-
assertRequestOptions(options);
|
|
238
|
-
return chequebook.getChequebookBalance(this.getKy(options));
|
|
239
|
-
});
|
|
149
|
+
async getChequebookBalance(options) {
|
|
150
|
+
assertRequestOptions(options);
|
|
151
|
+
return chequebook.getChequebookBalance(this.getKyOptionsForCall(options));
|
|
240
152
|
}
|
|
241
153
|
/**
|
|
242
154
|
* Get last cheques for all peers
|
|
243
155
|
*/
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
248
|
-
assertRequestOptions(options);
|
|
249
|
-
return chequebook.getLastCheques(this.getKy(options));
|
|
250
|
-
});
|
|
156
|
+
async getLastCheques(options) {
|
|
157
|
+
assertRequestOptions(options);
|
|
158
|
+
return chequebook.getLastCheques(this.getKyOptionsForCall(options));
|
|
251
159
|
}
|
|
252
160
|
/**
|
|
253
161
|
* Get last cheques for the peer
|
|
254
162
|
*
|
|
255
163
|
* @param address Swarm address of peer
|
|
256
164
|
*/
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return
|
|
261
|
-
assertRequestOptions(options);
|
|
262
|
-
assertAddress(address);
|
|
263
|
-
return chequebook.getLastChequesForPeer(this.getKy(options), address);
|
|
264
|
-
});
|
|
165
|
+
async getLastChequesForPeer(address, options) {
|
|
166
|
+
assertRequestOptions(options);
|
|
167
|
+
assertAddress(address);
|
|
168
|
+
return chequebook.getLastChequesForPeer(this.getKyOptionsForCall(options), address);
|
|
265
169
|
}
|
|
266
170
|
/**
|
|
267
171
|
* Get last cashout action for the peer
|
|
268
172
|
*
|
|
269
173
|
* @param address Swarm address of peer
|
|
270
174
|
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
return
|
|
275
|
-
assertRequestOptions(options);
|
|
276
|
-
assertAddress(address);
|
|
277
|
-
return chequebook.getLastCashoutAction(this.getKy(options), address);
|
|
278
|
-
});
|
|
175
|
+
async getLastCashoutAction(address, options) {
|
|
176
|
+
assertRequestOptions(options);
|
|
177
|
+
assertAddress(address);
|
|
178
|
+
return chequebook.getLastCashoutAction(this.getKyOptionsForCall(options), address);
|
|
279
179
|
}
|
|
280
180
|
/**
|
|
281
181
|
* Cashout the last cheque for the peer
|
|
@@ -285,14 +185,10 @@ export class BeeDebug {
|
|
|
285
185
|
* @param options.gasPrice Gas price for the cashout transaction in WEI
|
|
286
186
|
* @param options.gasLimit Gas limit for the cashout transaction in WEI
|
|
287
187
|
*/
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return
|
|
292
|
-
assertCashoutOptions(options);
|
|
293
|
-
assertAddress(address);
|
|
294
|
-
return chequebook.cashoutLastCheque(this.getKy(options), address, options);
|
|
295
|
-
});
|
|
188
|
+
async cashoutLastCheque(address, options) {
|
|
189
|
+
assertCashoutOptions(options);
|
|
190
|
+
assertAddress(address);
|
|
191
|
+
return chequebook.cashoutLastCheque(this.getKyOptionsForCall(options), address, options);
|
|
296
192
|
}
|
|
297
193
|
/**
|
|
298
194
|
* Deposit tokens from overlay address into chequebook
|
|
@@ -301,19 +197,13 @@ export class BeeDebug {
|
|
|
301
197
|
* @param gasPrice Gas Price in WEI for the transaction call
|
|
302
198
|
* @return string Hash of the transaction
|
|
303
199
|
*/
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (gasPrice) {
|
|
312
|
-
assertNonNegativeInteger(gasPrice);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return chequebook.depositTokens(this.getKy(options), amount, gasPrice);
|
|
316
|
-
});
|
|
200
|
+
async depositTokens(amount, gasPrice, options) {
|
|
201
|
+
assertRequestOptions(options);
|
|
202
|
+
assertNonNegativeInteger(amount);
|
|
203
|
+
if (gasPrice) {
|
|
204
|
+
assertNonNegativeInteger(gasPrice);
|
|
205
|
+
}
|
|
206
|
+
return chequebook.depositTokens(this.getKyOptionsForCall(options), amount, gasPrice);
|
|
317
207
|
}
|
|
318
208
|
/**
|
|
319
209
|
* Withdraw tokens from the chequebook to the overlay address
|
|
@@ -322,81 +212,54 @@ export class BeeDebug {
|
|
|
322
212
|
* @param gasPrice Gas Price in WEI for the transaction call
|
|
323
213
|
* @return string Hash of the transaction
|
|
324
214
|
*/
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
if (gasPrice) {
|
|
333
|
-
assertNonNegativeInteger(gasPrice);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return chequebook.withdrawTokens(this.getKy(options), amount, gasPrice);
|
|
337
|
-
});
|
|
215
|
+
async withdrawTokens(amount, gasPrice, options) {
|
|
216
|
+
assertRequestOptions(options);
|
|
217
|
+
assertNonNegativeInteger(amount);
|
|
218
|
+
if (gasPrice) {
|
|
219
|
+
assertNonNegativeInteger(gasPrice);
|
|
220
|
+
}
|
|
221
|
+
return chequebook.withdrawTokens(this.getKyOptionsForCall(options), amount, gasPrice);
|
|
338
222
|
}
|
|
339
223
|
/*
|
|
340
224
|
* Settlements endpoint
|
|
341
225
|
*/
|
|
342
|
-
|
|
343
226
|
/**
|
|
344
227
|
* Get amount of sent and received from settlements with a peer
|
|
345
228
|
*
|
|
346
229
|
* @param address Swarm address of peer
|
|
347
230
|
*/
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
return
|
|
352
|
-
assertRequestOptions(options);
|
|
353
|
-
assertAddress(address);
|
|
354
|
-
return settlements.getSettlements(this.getKy(options), address);
|
|
355
|
-
});
|
|
231
|
+
async getSettlements(address, options) {
|
|
232
|
+
assertRequestOptions(options);
|
|
233
|
+
assertAddress(address);
|
|
234
|
+
return settlements.getSettlements(this.getKyOptionsForCall(options), address);
|
|
356
235
|
}
|
|
357
236
|
/**
|
|
358
237
|
* Get settlements with all known peers and total amount sent or received
|
|
359
238
|
*/
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
364
|
-
assertRequestOptions(options);
|
|
365
|
-
return settlements.getAllSettlements(this.getKy(options));
|
|
366
|
-
});
|
|
239
|
+
async getAllSettlements(options) {
|
|
240
|
+
assertRequestOptions(options);
|
|
241
|
+
return settlements.getAllSettlements(this.getKyOptionsForCall(options));
|
|
367
242
|
}
|
|
368
243
|
/**
|
|
369
244
|
* Get health of node
|
|
370
245
|
*/
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
375
|
-
assertRequestOptions(options);
|
|
376
|
-
return status.getHealth(this.getKy(options));
|
|
377
|
-
});
|
|
246
|
+
async getHealth(options) {
|
|
247
|
+
assertRequestOptions(options);
|
|
248
|
+
return status.getHealth(this.getKyOptionsForCall(options));
|
|
378
249
|
}
|
|
379
250
|
/**
|
|
380
251
|
* Get readiness of node
|
|
381
252
|
*/
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
386
|
-
assertRequestOptions(options);
|
|
387
|
-
return status.getReadiness(this.getKy(options));
|
|
388
|
-
});
|
|
253
|
+
async getReadiness(options) {
|
|
254
|
+
assertRequestOptions(options);
|
|
255
|
+
return status.getReadiness(this.getKyOptionsForCall(options));
|
|
389
256
|
}
|
|
390
257
|
/**
|
|
391
258
|
* Get mode information of node
|
|
392
259
|
*/
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
397
|
-
assertRequestOptions(options);
|
|
398
|
-
return status.getNodeInfo(this.getKy(options));
|
|
399
|
-
});
|
|
260
|
+
async getNodeInfo(options) {
|
|
261
|
+
assertRequestOptions(options);
|
|
262
|
+
return status.getNodeInfo(this.getKyOptionsForCall(options));
|
|
400
263
|
}
|
|
401
264
|
/**
|
|
402
265
|
* Connnects to a node and checks if it is a supported Bee version by the bee-js
|
|
@@ -404,13 +267,9 @@ export class BeeDebug {
|
|
|
404
267
|
* @returns true if the Bee node version is supported
|
|
405
268
|
* @deprecated Use `BeeDebug.isSupportedExactVersion()` instead
|
|
406
269
|
*/
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
411
|
-
assertRequestOptions(options);
|
|
412
|
-
return status.isSupportedVersion(this.getKy(options));
|
|
413
|
-
});
|
|
270
|
+
async isSupportedVersion(options) {
|
|
271
|
+
assertRequestOptions(options);
|
|
272
|
+
return status.isSupportedVersion(this.getKyOptionsForCall(options));
|
|
414
273
|
}
|
|
415
274
|
/**
|
|
416
275
|
* Connects to a node and checks if its version matches with the one that bee-js supports.
|
|
@@ -422,13 +281,9 @@ export class BeeDebug {
|
|
|
422
281
|
*
|
|
423
282
|
* @param options
|
|
424
283
|
*/
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
429
|
-
assertRequestOptions(options);
|
|
430
|
-
return status.isSupportedExactVersion(this.getKy(options));
|
|
431
|
-
});
|
|
284
|
+
async isSupportedExactVersion(options) {
|
|
285
|
+
assertRequestOptions(options);
|
|
286
|
+
return status.isSupportedExactVersion(this.getKyOptionsForCall(options));
|
|
432
287
|
}
|
|
433
288
|
/**
|
|
434
289
|
* Connects to a node and checks if its main's API version matches with the one that bee-js supports.
|
|
@@ -438,13 +293,9 @@ export class BeeDebug {
|
|
|
438
293
|
*
|
|
439
294
|
* @param options
|
|
440
295
|
*/
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
445
|
-
assertRequestOptions(options);
|
|
446
|
-
return status.isSupportedMainApiVersion(this.getKy(options));
|
|
447
|
-
});
|
|
296
|
+
async isSupportedMainApiVersion(options) {
|
|
297
|
+
assertRequestOptions(options);
|
|
298
|
+
return status.isSupportedMainApiVersion(this.getKyOptionsForCall(options));
|
|
448
299
|
}
|
|
449
300
|
/**
|
|
450
301
|
* Connects to a node and checks if its Debug API version matches with the one that bee-js supports.
|
|
@@ -454,13 +305,9 @@ export class BeeDebug {
|
|
|
454
305
|
*
|
|
455
306
|
* @param options
|
|
456
307
|
*/
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
461
|
-
assertRequestOptions(options);
|
|
462
|
-
return status.isSupportedDebugApiVersion(this.getKy(options));
|
|
463
|
-
});
|
|
308
|
+
async isSupportedDebugApiVersion(options) {
|
|
309
|
+
assertRequestOptions(options);
|
|
310
|
+
return status.isSupportedDebugApiVersion(this.getKyOptionsForCall(options));
|
|
464
311
|
}
|
|
465
312
|
/**
|
|
466
313
|
*
|
|
@@ -470,13 +317,9 @@ export class BeeDebug {
|
|
|
470
317
|
*
|
|
471
318
|
* @param options
|
|
472
319
|
*/
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
477
|
-
assertRequestOptions(options);
|
|
478
|
-
return status.isSupportedDebugApiVersion(this.getKy(options));
|
|
479
|
-
});
|
|
320
|
+
async isSupportedApiVersion(options) {
|
|
321
|
+
assertRequestOptions(options);
|
|
322
|
+
return status.isSupportedDebugApiVersion(this.getKyOptionsForCall(options));
|
|
480
323
|
}
|
|
481
324
|
/**
|
|
482
325
|
* Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
|
|
@@ -484,48 +327,32 @@ export class BeeDebug {
|
|
|
484
327
|
*
|
|
485
328
|
* @param options
|
|
486
329
|
*/
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
491
|
-
assertRequestOptions(options);
|
|
492
|
-
return status.getVersions(this.getKy(options));
|
|
493
|
-
});
|
|
330
|
+
async getVersions(options) {
|
|
331
|
+
assertRequestOptions(options);
|
|
332
|
+
return status.getVersions(this.getKyOptionsForCall(options));
|
|
494
333
|
}
|
|
495
334
|
/**
|
|
496
335
|
* Get reserve state
|
|
497
336
|
*/
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
502
|
-
assertRequestOptions(options);
|
|
503
|
-
return states.getReserveState(this.getKy(options));
|
|
504
|
-
});
|
|
337
|
+
async getReserveState(options) {
|
|
338
|
+
assertRequestOptions(options);
|
|
339
|
+
return states.getReserveState(this.getKyOptionsForCall(options));
|
|
505
340
|
}
|
|
506
341
|
/**
|
|
507
342
|
* Get chain state
|
|
508
343
|
*/
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
513
|
-
assertRequestOptions(options);
|
|
514
|
-
return states.getChainState(this.getKy(options));
|
|
515
|
-
});
|
|
344
|
+
async getChainState(options) {
|
|
345
|
+
assertRequestOptions(options);
|
|
346
|
+
return states.getChainState(this.getKyOptionsForCall(options));
|
|
516
347
|
}
|
|
517
348
|
/**
|
|
518
349
|
* Get wallet balances for xDai and BZZ of the Bee node
|
|
519
350
|
*
|
|
520
351
|
* @param options
|
|
521
352
|
*/
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
526
|
-
assertRequestOptions(options);
|
|
527
|
-
return states.getWalletBalance(this.getKy(options));
|
|
528
|
-
});
|
|
353
|
+
async getWalletBalance(options) {
|
|
354
|
+
assertRequestOptions(options);
|
|
355
|
+
return states.getWalletBalance(this.getKyOptionsForCall(options));
|
|
529
356
|
}
|
|
530
357
|
/**
|
|
531
358
|
* Creates new postage batch from the funds that the node has available in its Ethereum account.
|
|
@@ -544,30 +371,21 @@ export class BeeDebug {
|
|
|
544
371
|
* @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
|
|
545
372
|
* @see [Bee Debug API reference - `POST /stamps`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post)
|
|
546
373
|
*/
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
const stamp = yield stamps.createPostageBatch(this.getKy(options), amount, depth, options);
|
|
564
|
-
|
|
565
|
-
if ((options === null || options === void 0 ? void 0 : options.waitForUsable) !== false) {
|
|
566
|
-
yield this.waitForUsablePostageStamp(stamp, options === null || options === void 0 ? void 0 : options.waitForUsableTimeout);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
return stamp;
|
|
570
|
-
});
|
|
374
|
+
async createPostageBatch(amount, depth, options) {
|
|
375
|
+
assertPostageBatchOptions(options);
|
|
376
|
+
assertPositiveInteger(amount);
|
|
377
|
+
assertNonNegativeInteger(depth);
|
|
378
|
+
if (depth < STAMPS_DEPTH_MIN) {
|
|
379
|
+
throw new BeeArgumentError(`Depth has to be at least ${STAMPS_DEPTH_MIN}`, depth);
|
|
380
|
+
}
|
|
381
|
+
if (depth > STAMPS_DEPTH_MAX) {
|
|
382
|
+
throw new BeeArgumentError(`Depth has to be at most ${STAMPS_DEPTH_MAX}`, depth);
|
|
383
|
+
}
|
|
384
|
+
const stamp = await stamps.createPostageBatch(this.getKyOptionsForCall(options), amount, depth, options);
|
|
385
|
+
if (options?.waitForUsable !== false) {
|
|
386
|
+
await this.waitForUsablePostageStamp(stamp, options?.waitForUsableTimeout);
|
|
387
|
+
}
|
|
388
|
+
return stamp;
|
|
571
389
|
}
|
|
572
390
|
/**
|
|
573
391
|
* Topup a fresh amount of BZZ to given Postage Batch.
|
|
@@ -584,15 +402,11 @@ export class BeeDebug {
|
|
|
584
402
|
* @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
|
|
585
403
|
* @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)
|
|
586
404
|
*/
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
assertNonNegativeInteger(amount, 'Amount');
|
|
593
|
-
assertBatchId(postageBatchId);
|
|
594
|
-
yield stamps.topUpBatch(this.getKy(options), postageBatchId, amount);
|
|
595
|
-
});
|
|
405
|
+
async topUpBatch(postageBatchId, amount, options) {
|
|
406
|
+
assertRequestOptions(options);
|
|
407
|
+
assertNonNegativeInteger(amount, 'Amount');
|
|
408
|
+
assertBatchId(postageBatchId);
|
|
409
|
+
await stamps.topUpBatch(this.getKyOptionsForCall(options), postageBatchId, amount);
|
|
596
410
|
}
|
|
597
411
|
/**
|
|
598
412
|
* Dilute given Postage Batch with new depth (that has to be bigger then the original depth), which allows
|
|
@@ -610,15 +424,11 @@ export class BeeDebug {
|
|
|
610
424
|
* @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
|
|
611
425
|
* @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)
|
|
612
426
|
*/
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
assertNonNegativeInteger(depth, 'Depth');
|
|
619
|
-
assertBatchId(postageBatchId);
|
|
620
|
-
yield stamps.diluteBatch(this.getKy(options), postageBatchId, depth);
|
|
621
|
-
});
|
|
427
|
+
async diluteBatch(postageBatchId, depth, options) {
|
|
428
|
+
assertRequestOptions(options);
|
|
429
|
+
assertNonNegativeInteger(depth, 'Depth');
|
|
430
|
+
assertBatchId(postageBatchId);
|
|
431
|
+
await stamps.diluteBatch(this.getKyOptionsForCall(options), postageBatchId, depth);
|
|
622
432
|
}
|
|
623
433
|
/**
|
|
624
434
|
* Return details for specific postage batch.
|
|
@@ -628,14 +438,10 @@ export class BeeDebug {
|
|
|
628
438
|
* @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
|
|
629
439
|
* @see [Bee Debug API reference - `GET /stamps/${id}`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{id}/get)
|
|
630
440
|
*/
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
return
|
|
635
|
-
assertRequestOptions(options);
|
|
636
|
-
assertBatchId(postageBatchId);
|
|
637
|
-
return stamps.getPostageBatch(this.getKy(options), postageBatchId);
|
|
638
|
-
});
|
|
441
|
+
async getPostageBatch(postageBatchId, options) {
|
|
442
|
+
assertRequestOptions(options);
|
|
443
|
+
assertBatchId(postageBatchId);
|
|
444
|
+
return stamps.getPostageBatch(this.getKyOptionsForCall(options), postageBatchId);
|
|
639
445
|
}
|
|
640
446
|
/**
|
|
641
447
|
* Return detailed information related to buckets for specific postage batch.
|
|
@@ -645,14 +451,10 @@ export class BeeDebug {
|
|
|
645
451
|
* @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
|
|
646
452
|
* @see [Bee Debug API reference - `GET /stamps/${id}/buckets`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{id}~1buckets/get)
|
|
647
453
|
*/
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
return
|
|
652
|
-
assertRequestOptions(options);
|
|
653
|
-
assertBatchId(postageBatchId);
|
|
654
|
-
return stamps.getPostageBatchBuckets(this.getKy(options), postageBatchId);
|
|
655
|
-
});
|
|
454
|
+
async getPostageBatchBuckets(postageBatchId, options) {
|
|
455
|
+
assertRequestOptions(options);
|
|
456
|
+
assertBatchId(postageBatchId);
|
|
457
|
+
return stamps.getPostageBatchBuckets(this.getKyOptionsForCall(options), postageBatchId);
|
|
656
458
|
}
|
|
657
459
|
/**
|
|
658
460
|
* Return all postage batches that has the node available.
|
|
@@ -660,37 +462,25 @@ export class BeeDebug {
|
|
|
660
462
|
* @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
|
|
661
463
|
* @see [Bee Debug API reference - `GET /stamps`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps/get)
|
|
662
464
|
*/
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
667
|
-
assertRequestOptions(options);
|
|
668
|
-
return stamps.getAllPostageBatches(this.getKy(options));
|
|
669
|
-
});
|
|
465
|
+
async getAllPostageBatch(options) {
|
|
466
|
+
assertRequestOptions(options);
|
|
467
|
+
return stamps.getAllPostageBatches(this.getKyOptionsForCall(options));
|
|
670
468
|
}
|
|
671
469
|
/**
|
|
672
470
|
* Return lists of all current pending transactions that the Bee made
|
|
673
471
|
*/
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
678
|
-
assertRequestOptions(options);
|
|
679
|
-
return transactions.getAllTransactions(this.getKy(options));
|
|
680
|
-
});
|
|
472
|
+
async getAllPendingTransactions(options) {
|
|
473
|
+
assertRequestOptions(options);
|
|
474
|
+
return transactions.getAllTransactions(this.getKyOptionsForCall(options));
|
|
681
475
|
}
|
|
682
476
|
/**
|
|
683
477
|
* Return transaction information for specific transaction
|
|
684
478
|
* @param transactionHash
|
|
685
479
|
*/
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
return
|
|
690
|
-
assertRequestOptions(options);
|
|
691
|
-
assertTransactionHash(transactionHash);
|
|
692
|
-
return transactions.getTransaction(this.getKy(options), transactionHash);
|
|
693
|
-
});
|
|
480
|
+
async getPendingTransaction(transactionHash, options) {
|
|
481
|
+
assertRequestOptions(options);
|
|
482
|
+
assertTransactionHash(transactionHash);
|
|
483
|
+
return transactions.getTransaction(this.getKyOptionsForCall(options), transactionHash);
|
|
694
484
|
}
|
|
695
485
|
/**
|
|
696
486
|
* Rebroadcast already created transaction.
|
|
@@ -698,46 +488,32 @@ export class BeeDebug {
|
|
|
698
488
|
*
|
|
699
489
|
* @param transactionHash
|
|
700
490
|
*/
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
return
|
|
705
|
-
assertRequestOptions(options);
|
|
706
|
-
assertTransactionHash(transactionHash);
|
|
707
|
-
return transactions.rebroadcastTransaction(this.getKy(options), transactionHash);
|
|
708
|
-
});
|
|
491
|
+
async rebroadcastPendingTransaction(transactionHash, options) {
|
|
492
|
+
assertRequestOptions(options);
|
|
493
|
+
assertTransactionHash(transactionHash);
|
|
494
|
+
return transactions.rebroadcastTransaction(this.getKyOptionsForCall(options), transactionHash);
|
|
709
495
|
}
|
|
710
496
|
/**
|
|
711
497
|
* Cancel currently pending transaction
|
|
712
498
|
* @param transactionHash
|
|
713
499
|
* @param gasPrice
|
|
714
500
|
*/
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
if (gasPrice) {
|
|
723
|
-
assertNonNegativeInteger(gasPrice);
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
return transactions.cancelTransaction(this.getKy(options), transactionHash, gasPrice);
|
|
727
|
-
});
|
|
501
|
+
async cancelPendingTransaction(transactionHash, gasPrice, options) {
|
|
502
|
+
assertRequestOptions(options);
|
|
503
|
+
assertTransactionHash(transactionHash);
|
|
504
|
+
if (gasPrice) {
|
|
505
|
+
assertNonNegativeInteger(gasPrice);
|
|
506
|
+
}
|
|
507
|
+
return transactions.cancelTransaction(this.getKyOptionsForCall(options), transactionHash, gasPrice);
|
|
728
508
|
}
|
|
729
509
|
/**
|
|
730
510
|
* Gets the staked amount of BZZ (in PLUR unit) as number string.
|
|
731
511
|
*
|
|
732
512
|
* @param options
|
|
733
513
|
*/
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
738
|
-
assertRequestOptions(options);
|
|
739
|
-
return stake.getStake(this.getKy(options));
|
|
740
|
-
});
|
|
514
|
+
async getStake(options) {
|
|
515
|
+
assertRequestOptions(options);
|
|
516
|
+
return stake.getStake(this.getKyOptionsForCall(options));
|
|
741
517
|
}
|
|
742
518
|
/**
|
|
743
519
|
* Deposits given amount of BZZ token (in PLUR unit).
|
|
@@ -747,40 +523,23 @@ export class BeeDebug {
|
|
|
747
523
|
* @param amount Amount of BZZ token (in PLUR unit) to be staked. Minimum is 100_000_000_000_000_000 PLUR (10 BZZ).
|
|
748
524
|
* @param options
|
|
749
525
|
*/
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
762
|
-
const TIME_STEP = 1500;
|
|
763
|
-
|
|
764
|
-
for (let time = 0; time < timeout; time += TIME_STEP) {
|
|
765
|
-
const stamp = yield this.getPostageBatch(id);
|
|
766
|
-
|
|
767
|
-
if (stamp.usable) {
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
yield sleep(TIME_STEP);
|
|
526
|
+
async depositStake(amount, options) {
|
|
527
|
+
assertRequestOptions(options);
|
|
528
|
+
assertTransactionOptions(options);
|
|
529
|
+
await stake.stake(this.getKyOptionsForCall(options), amount, options);
|
|
530
|
+
}
|
|
531
|
+
async waitForUsablePostageStamp(id, timeout = 120000) {
|
|
532
|
+
const TIME_STEP = 1500;
|
|
533
|
+
for (let time = 0; time < timeout; time += TIME_STEP) {
|
|
534
|
+
const stamp = await this.getPostageBatch(id);
|
|
535
|
+
if (stamp.usable) {
|
|
536
|
+
return;
|
|
772
537
|
}
|
|
773
|
-
|
|
774
|
-
throw new BeeError('Timeout on waiting for postage stamp to become usable');
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
getKy(options) {
|
|
779
|
-
if (!options) {
|
|
780
|
-
return this.ky;
|
|
538
|
+
await sleep(TIME_STEP);
|
|
781
539
|
}
|
|
782
|
-
|
|
783
|
-
|
|
540
|
+
throw new BeeError('Timeout on waiting for postage stamp to become usable');
|
|
541
|
+
}
|
|
542
|
+
getKyOptionsForCall(options) {
|
|
543
|
+
return deepMerge(this.kyOptions, options);
|
|
784
544
|
}
|
|
785
|
-
|
|
786
545
|
}
|