@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/mjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Bee } from "./bee.js";
|
|
2
2
|
import { BeeDebug } from "./bee-debug.js";
|
|
3
|
-
export
|
|
3
|
+
export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from "./modules/debug/status.js";
|
|
4
4
|
export * from "./types/index.js";
|
|
5
5
|
export * from "./utils/error.js";
|
|
6
|
-
export
|
|
6
|
+
export * as Utils from "./utils/expose.js";
|
|
7
7
|
export { Bee, BeeDebug };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { wrapBytesWithHelpers } from "../utils/bytes.js";
|
|
1
2
|
import { prepareData } from "../utils/data.js";
|
|
2
3
|
import { extractUploadHeaders } from "../utils/headers.js";
|
|
3
4
|
import { http } from "../utils/http.js";
|
|
4
|
-
import { wrapBytesWithHelpers } from "../utils/bytes.js";
|
|
5
5
|
import { makeTagUid } from "../utils/type.js";
|
|
6
6
|
const endpoint = 'bytes';
|
|
7
7
|
/**
|
|
@@ -12,20 +12,20 @@ const endpoint = 'bytes';
|
|
|
12
12
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
13
13
|
* @param options Additional options like tag, encryption, pinning
|
|
14
14
|
*/
|
|
15
|
-
export async function upload(
|
|
16
|
-
const response = await http(
|
|
17
|
-
|
|
15
|
+
export async function upload(requestOptions, data, postageBatchId, options) {
|
|
16
|
+
const response = await http(requestOptions, {
|
|
17
|
+
url: endpoint,
|
|
18
18
|
method: 'post',
|
|
19
19
|
responseType: 'json',
|
|
20
|
-
|
|
20
|
+
data: await prepareData(data),
|
|
21
21
|
headers: {
|
|
22
22
|
'content-type': 'application/octet-stream',
|
|
23
23
|
...extractUploadHeaders(postageBatchId, options)
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
return {
|
|
27
|
-
reference: response.
|
|
28
|
-
tagUid: makeTagUid(response.headers
|
|
27
|
+
reference: response.data.reference,
|
|
28
|
+
tagUid: makeTagUid(response.headers['swarm-tag'])
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
@@ -34,12 +34,12 @@ export async function upload(kyOptions, data, postageBatchId, options) {
|
|
|
34
34
|
* @param ky
|
|
35
35
|
* @param hash Bee content reference
|
|
36
36
|
*/
|
|
37
|
-
export async function download(
|
|
38
|
-
const response = await http(
|
|
37
|
+
export async function download(requestOptions, hash) {
|
|
38
|
+
const response = await http(requestOptions, {
|
|
39
39
|
responseType: 'arraybuffer',
|
|
40
|
-
|
|
40
|
+
url: `${endpoint}/${hash}`
|
|
41
41
|
});
|
|
42
|
-
return wrapBytesWithHelpers(new Uint8Array(response.
|
|
42
|
+
return wrapBytesWithHelpers(new Uint8Array(response.data));
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Download data as a readable stream
|
|
@@ -47,10 +47,10 @@ export async function download(kyOptions, hash) {
|
|
|
47
47
|
* @param ky
|
|
48
48
|
* @param hash Bee content reference
|
|
49
49
|
*/
|
|
50
|
-
export async function downloadReadable(
|
|
51
|
-
const response = await http(
|
|
50
|
+
export async function downloadReadable(requestOptions, hash) {
|
|
51
|
+
const response = await http(requestOptions, {
|
|
52
52
|
responseType: 'stream',
|
|
53
|
-
|
|
53
|
+
url: `${endpoint}/${hash}`
|
|
54
54
|
});
|
|
55
|
-
return response.
|
|
55
|
+
return response.data;
|
|
56
56
|
}
|
package/dist/mjs/modules/bzz.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { wrapBytesWithHelpers } from "../utils/bytes.js";
|
|
2
|
+
import { assertCollection } from "../utils/collection.js";
|
|
1
3
|
import { extractUploadHeaders, readFileHeaders } from "../utils/headers.js";
|
|
2
4
|
import { http } from "../utils/http.js";
|
|
3
|
-
import { prepareData } from "../utils/data.js";
|
|
4
|
-
import { makeTar } from "../utils/tar.js";
|
|
5
|
-
import { assertCollection } from "../utils/collection.js";
|
|
6
|
-
import { wrapBytesWithHelpers } from "../utils/bytes.js";
|
|
7
5
|
import { isReadable } from "../utils/stream.js";
|
|
6
|
+
import { makeTar } from "../utils/tar.js";
|
|
8
7
|
import { makeTagUid } from "../utils/type.js";
|
|
9
8
|
const bzzEndpoint = 'bzz';
|
|
10
9
|
function extractFileUploadHeaders(postageBatchId, options) {
|
|
@@ -22,26 +21,26 @@ function extractFileUploadHeaders(postageBatchId, options) {
|
|
|
22
21
|
* @param name Name that will be attached to the uploaded file. Wraps the data into manifest with set index document.
|
|
23
22
|
* @param options
|
|
24
23
|
*/
|
|
25
|
-
export async function uploadFile(
|
|
24
|
+
export async function uploadFile(requestOptions, data, postageBatchId, name, options) {
|
|
26
25
|
if (isReadable(data) && !options?.contentType) {
|
|
27
26
|
if (!options) options = {};
|
|
28
27
|
options.contentType = 'application/octet-stream';
|
|
29
28
|
}
|
|
30
|
-
const response = await http(
|
|
29
|
+
const response = await http(requestOptions, {
|
|
31
30
|
method: 'post',
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
url: bzzEndpoint,
|
|
32
|
+
data,
|
|
34
33
|
headers: {
|
|
35
34
|
...extractFileUploadHeaders(postageBatchId, options)
|
|
36
35
|
},
|
|
37
|
-
|
|
36
|
+
params: {
|
|
38
37
|
name
|
|
39
38
|
},
|
|
40
39
|
responseType: 'json'
|
|
41
40
|
});
|
|
42
41
|
return {
|
|
43
|
-
reference: response.
|
|
44
|
-
tagUid: makeTagUid(response.headers
|
|
42
|
+
reference: response.data.reference,
|
|
43
|
+
tagUid: makeTagUid(response.headers['swarm-tag'])
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
46
|
/**
|
|
@@ -51,15 +50,15 @@ export async function uploadFile(kyOptions, data, postageBatchId, name, options)
|
|
|
51
50
|
* @param hash Bee file or collection hash
|
|
52
51
|
* @param path If hash is collection then this defines path to a single file in the collection
|
|
53
52
|
*/
|
|
54
|
-
export async function downloadFile(
|
|
55
|
-
const response = await http(
|
|
53
|
+
export async function downloadFile(requestOptions, hash, path = '') {
|
|
54
|
+
const response = await http(requestOptions, {
|
|
56
55
|
method: 'GET',
|
|
57
56
|
responseType: 'arraybuffer',
|
|
58
|
-
|
|
57
|
+
url: `${bzzEndpoint}/${hash}/${path}`
|
|
59
58
|
});
|
|
60
59
|
const file = {
|
|
61
60
|
...readFileHeaders(response.headers),
|
|
62
|
-
data: wrapBytesWithHelpers(new Uint8Array(response.
|
|
61
|
+
data: wrapBytesWithHelpers(new Uint8Array(response.data))
|
|
63
62
|
};
|
|
64
63
|
return file;
|
|
65
64
|
}
|
|
@@ -70,15 +69,15 @@ export async function downloadFile(kyOptions, hash, path = '') {
|
|
|
70
69
|
* @param hash Bee file or collection hash
|
|
71
70
|
* @param path If hash is collection then this defines path to a single file in the collection
|
|
72
71
|
*/
|
|
73
|
-
export async function downloadFileReadable(
|
|
74
|
-
const response = await http(
|
|
72
|
+
export async function downloadFileReadable(requestOptions, hash, path = '') {
|
|
73
|
+
const response = await http(requestOptions, {
|
|
75
74
|
method: 'GET',
|
|
76
75
|
responseType: 'stream',
|
|
77
|
-
|
|
76
|
+
url: `${bzzEndpoint}/${hash}/${path}`
|
|
78
77
|
});
|
|
79
78
|
const file = {
|
|
80
79
|
...readFileHeaders(response.headers),
|
|
81
|
-
data: response.
|
|
80
|
+
data: response.data
|
|
82
81
|
};
|
|
83
82
|
return file;
|
|
84
83
|
}
|
|
@@ -95,13 +94,13 @@ function extractCollectionUploadHeaders(postageBatchId, options) {
|
|
|
95
94
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
96
95
|
* @param options
|
|
97
96
|
*/
|
|
98
|
-
export async function uploadCollection(
|
|
97
|
+
export async function uploadCollection(requestOptions, collection, postageBatchId, options) {
|
|
99
98
|
assertCollection(collection);
|
|
100
99
|
const tarData = makeTar(collection);
|
|
101
|
-
const response = await http(
|
|
100
|
+
const response = await http(requestOptions, {
|
|
102
101
|
method: 'post',
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
url: bzzEndpoint,
|
|
103
|
+
data: tarData,
|
|
105
104
|
responseType: 'json',
|
|
106
105
|
headers: {
|
|
107
106
|
'content-type': 'application/x-tar',
|
|
@@ -110,7 +109,7 @@ export async function uploadCollection(kyOptions, collection, postageBatchId, op
|
|
|
110
109
|
}
|
|
111
110
|
});
|
|
112
111
|
return {
|
|
113
|
-
reference: response.
|
|
114
|
-
tagUid: makeTagUid(response.headers
|
|
112
|
+
reference: response.data.reference,
|
|
113
|
+
tagUid: makeTagUid(response.headers['swarm-tag'])
|
|
115
114
|
};
|
|
116
115
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { wrapBytesWithHelpers } from "../utils/bytes.js";
|
|
1
2
|
import { extractUploadHeaders } from "../utils/headers.js";
|
|
2
3
|
import { http } from "../utils/http.js";
|
|
3
|
-
import { wrapBytesWithHelpers } from "../utils/bytes.js";
|
|
4
4
|
const endpoint = 'chunks';
|
|
5
5
|
/**
|
|
6
6
|
* Upload chunk to a Bee node
|
|
@@ -14,18 +14,18 @@ const endpoint = 'chunks';
|
|
|
14
14
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
15
15
|
* @param options Additional options like tag, encryption, pinning
|
|
16
16
|
*/
|
|
17
|
-
export async function upload(
|
|
18
|
-
const response = await http(
|
|
17
|
+
export async function upload(requestOptions, data, postageBatchId, options) {
|
|
18
|
+
const response = await http(requestOptions, {
|
|
19
19
|
method: 'post',
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
url: `${endpoint}`,
|
|
21
|
+
data,
|
|
22
22
|
headers: {
|
|
23
23
|
'content-type': 'application/octet-stream',
|
|
24
24
|
...extractUploadHeaders(postageBatchId, options)
|
|
25
25
|
},
|
|
26
26
|
responseType: 'json'
|
|
27
27
|
});
|
|
28
|
-
return response.
|
|
28
|
+
return response.data.reference;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Download chunk data as a byte array
|
|
@@ -34,10 +34,10 @@ export async function upload(kyOptions, data, postageBatchId, options) {
|
|
|
34
34
|
* @param hash Bee content reference
|
|
35
35
|
*
|
|
36
36
|
*/
|
|
37
|
-
export async function download(
|
|
38
|
-
const response = await http(
|
|
37
|
+
export async function download(requestOptions, hash) {
|
|
38
|
+
const response = await http(requestOptions, {
|
|
39
39
|
responseType: 'arraybuffer',
|
|
40
|
-
|
|
40
|
+
url: `${endpoint}/${hash}`
|
|
41
41
|
});
|
|
42
|
-
return wrapBytesWithHelpers(new Uint8Array(response.
|
|
42
|
+
return wrapBytesWithHelpers(new Uint8Array(response.data));
|
|
43
43
|
}
|
|
@@ -6,12 +6,12 @@ const consumedEndpoint = 'consumed';
|
|
|
6
6
|
*
|
|
7
7
|
* @param kyOptions Ky Options for making requests
|
|
8
8
|
*/
|
|
9
|
-
export async function getAllBalances(
|
|
10
|
-
const response = await http(
|
|
11
|
-
|
|
9
|
+
export async function getAllBalances(requestOptions) {
|
|
10
|
+
const response = await http(requestOptions, {
|
|
11
|
+
url: balancesEndpoint,
|
|
12
12
|
responseType: 'json'
|
|
13
13
|
});
|
|
14
|
-
return response.
|
|
14
|
+
return response.data;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Get the balances with a specific peer including prepaid services
|
|
@@ -19,24 +19,24 @@ export async function getAllBalances(kyOptions) {
|
|
|
19
19
|
* @param kyOptions Ky Options for making requests
|
|
20
20
|
* @param address Swarm address of peer
|
|
21
21
|
*/
|
|
22
|
-
export async function getPeerBalance(
|
|
23
|
-
const response = await http(
|
|
24
|
-
|
|
22
|
+
export async function getPeerBalance(requestOptions, address) {
|
|
23
|
+
const response = await http(requestOptions, {
|
|
24
|
+
url: `${balancesEndpoint}/${address}`,
|
|
25
25
|
responseType: 'json'
|
|
26
26
|
});
|
|
27
|
-
return response.
|
|
27
|
+
return response.data;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Get the past due consumption balances with all known peers
|
|
31
31
|
*
|
|
32
32
|
* @param kyOptions Ky Options for making requests
|
|
33
33
|
*/
|
|
34
|
-
export async function getPastDueConsumptionBalances(
|
|
35
|
-
const response = await http(
|
|
36
|
-
|
|
34
|
+
export async function getPastDueConsumptionBalances(requestOptions) {
|
|
35
|
+
const response = await http(requestOptions, {
|
|
36
|
+
url: consumedEndpoint,
|
|
37
37
|
responseType: 'json'
|
|
38
38
|
});
|
|
39
|
-
return response.
|
|
39
|
+
return response.data;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Get the past due consumption balance with a specific peer
|
|
@@ -44,10 +44,10 @@ export async function getPastDueConsumptionBalances(kyOptions) {
|
|
|
44
44
|
* @param kyOptions Ky Options for making requests
|
|
45
45
|
* @param address Swarm address of peer
|
|
46
46
|
*/
|
|
47
|
-
export async function getPastDueConsumptionPeerBalance(
|
|
48
|
-
const response = await http(
|
|
49
|
-
|
|
47
|
+
export async function getPastDueConsumptionPeerBalance(requestOptions, address) {
|
|
48
|
+
const response = await http(requestOptions, {
|
|
49
|
+
url: `${consumedEndpoint}/${address}`,
|
|
50
50
|
responseType: 'json'
|
|
51
51
|
});
|
|
52
|
-
return response.
|
|
52
|
+
return response.data;
|
|
53
53
|
}
|
|
@@ -5,24 +5,24 @@ const chequebookEndpoint = 'chequebook';
|
|
|
5
5
|
*
|
|
6
6
|
* @param kyOptions Ky Options for making requests
|
|
7
7
|
*/
|
|
8
|
-
export async function getChequebookAddress(
|
|
9
|
-
const response = await http(
|
|
10
|
-
|
|
8
|
+
export async function getChequebookAddress(requestOptions) {
|
|
9
|
+
const response = await http(requestOptions, {
|
|
10
|
+
url: chequebookEndpoint + '/address',
|
|
11
11
|
responseType: 'json'
|
|
12
12
|
});
|
|
13
|
-
return response.
|
|
13
|
+
return response.data;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Get the balance of the chequebook
|
|
17
17
|
*
|
|
18
18
|
* @param kyOptions Ky Options for making requests
|
|
19
19
|
*/
|
|
20
|
-
export async function getChequebookBalance(
|
|
21
|
-
const response = await http(
|
|
22
|
-
|
|
20
|
+
export async function getChequebookBalance(requestOptions) {
|
|
21
|
+
const response = await http(requestOptions, {
|
|
22
|
+
url: chequebookEndpoint + '/balance',
|
|
23
23
|
responseType: 'json'
|
|
24
24
|
});
|
|
25
|
-
return response.
|
|
25
|
+
return response.data;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Get last cashout action for the peer
|
|
@@ -30,12 +30,12 @@ export async function getChequebookBalance(kyOptions) {
|
|
|
30
30
|
* @param kyOptions Ky Options for making requests
|
|
31
31
|
* @param peer Swarm address of peer
|
|
32
32
|
*/
|
|
33
|
-
export async function getLastCashoutAction(
|
|
34
|
-
const response = await http(
|
|
35
|
-
|
|
33
|
+
export async function getLastCashoutAction(requestOptions, peer) {
|
|
34
|
+
const response = await http(requestOptions, {
|
|
35
|
+
url: chequebookEndpoint + `/cashout/${peer}`,
|
|
36
36
|
responseType: 'json'
|
|
37
37
|
});
|
|
38
|
-
return response.
|
|
38
|
+
return response.data;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Cashout the last cheque for the peer
|
|
@@ -44,7 +44,7 @@ export async function getLastCashoutAction(kyOptions, peer) {
|
|
|
44
44
|
* @param peer Swarm address of peer
|
|
45
45
|
* @param options
|
|
46
46
|
*/
|
|
47
|
-
export async function cashoutLastCheque(
|
|
47
|
+
export async function cashoutLastCheque(requestOptions, peer, options) {
|
|
48
48
|
const headers = {};
|
|
49
49
|
if (options?.gasPrice) {
|
|
50
50
|
headers['gas-price'] = options.gasPrice.toString();
|
|
@@ -52,13 +52,13 @@ export async function cashoutLastCheque(kyOptions, peer, options) {
|
|
|
52
52
|
if (options?.gasLimit) {
|
|
53
53
|
headers['gas-limit'] = options.gasLimit.toString();
|
|
54
54
|
}
|
|
55
|
-
const response = await http(
|
|
55
|
+
const response = await http(requestOptions, {
|
|
56
56
|
method: 'post',
|
|
57
|
-
|
|
57
|
+
url: chequebookEndpoint + `/cashout/${peer}`,
|
|
58
58
|
responseType: 'json',
|
|
59
59
|
headers
|
|
60
60
|
});
|
|
61
|
-
return response.
|
|
61
|
+
return response.data.transactionHash;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Get last cheques for the peer
|
|
@@ -66,24 +66,24 @@ export async function cashoutLastCheque(kyOptions, peer, options) {
|
|
|
66
66
|
* @param kyOptions Ky Options for making requests
|
|
67
67
|
* @param peer Swarm address of peer
|
|
68
68
|
*/
|
|
69
|
-
export async function getLastChequesForPeer(
|
|
70
|
-
const response = await http(
|
|
71
|
-
|
|
69
|
+
export async function getLastChequesForPeer(requestOptions, peer) {
|
|
70
|
+
const response = await http(requestOptions, {
|
|
71
|
+
url: chequebookEndpoint + `/cheque/${peer}`,
|
|
72
72
|
responseType: 'json'
|
|
73
73
|
});
|
|
74
|
-
return response.
|
|
74
|
+
return response.data;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Get last cheques for all peers
|
|
78
78
|
*
|
|
79
79
|
* @param kyOptions Ky Options for making requests
|
|
80
80
|
*/
|
|
81
|
-
export async function getLastCheques(
|
|
82
|
-
const response = await http(
|
|
83
|
-
|
|
81
|
+
export async function getLastCheques(requestOptions) {
|
|
82
|
+
const response = await http(requestOptions, {
|
|
83
|
+
url: chequebookEndpoint + '/cheque',
|
|
84
84
|
responseType: 'json'
|
|
85
85
|
});
|
|
86
|
-
return response.
|
|
86
|
+
return response.data;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Deposit tokens from overlay address into chequebook
|
|
@@ -93,21 +93,21 @@ export async function getLastCheques(kyOptions) {
|
|
|
93
93
|
* @param gasPrice Gas Price in WEI for the transaction call
|
|
94
94
|
* @return string Hash of the transaction
|
|
95
95
|
*/
|
|
96
|
-
export async function depositTokens(
|
|
96
|
+
export async function depositTokens(requestOptions, amount, gasPrice) {
|
|
97
97
|
const headers = {};
|
|
98
98
|
if (gasPrice) {
|
|
99
99
|
headers['gas-price'] = gasPrice.toString();
|
|
100
100
|
}
|
|
101
|
-
const response = await http(
|
|
101
|
+
const response = await http(requestOptions, {
|
|
102
102
|
method: 'post',
|
|
103
|
-
|
|
103
|
+
url: chequebookEndpoint + '/deposit',
|
|
104
104
|
responseType: 'json',
|
|
105
|
-
|
|
105
|
+
params: {
|
|
106
106
|
amount: amount.toString(10)
|
|
107
107
|
},
|
|
108
108
|
headers
|
|
109
109
|
});
|
|
110
|
-
return response.
|
|
110
|
+
return response.data.transactionHash;
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* Withdraw tokens from the chequebook to the overlay address
|
|
@@ -117,19 +117,19 @@ export async function depositTokens(kyOptions, amount, gasPrice) {
|
|
|
117
117
|
* @param gasPrice Gas Price in WEI for the transaction call
|
|
118
118
|
* @return string Hash of the transaction
|
|
119
119
|
*/
|
|
120
|
-
export async function withdrawTokens(
|
|
120
|
+
export async function withdrawTokens(requestOptions, amount, gasPrice) {
|
|
121
121
|
const headers = {};
|
|
122
122
|
if (gasPrice) {
|
|
123
123
|
headers['gas-price'] = gasPrice.toString();
|
|
124
124
|
}
|
|
125
|
-
const response = await http(
|
|
125
|
+
const response = await http(requestOptions, {
|
|
126
126
|
method: 'post',
|
|
127
|
-
|
|
127
|
+
url: chequebookEndpoint + '/withdraw',
|
|
128
128
|
responseType: 'json',
|
|
129
|
-
|
|
129
|
+
params: {
|
|
130
130
|
amount: amount.toString(10)
|
|
131
131
|
},
|
|
132
132
|
headers
|
|
133
133
|
});
|
|
134
|
-
return response.
|
|
134
|
+
return response.data.transactionHash;
|
|
135
135
|
}
|
|
@@ -8,12 +8,12 @@ const endpoint = 'chunks';
|
|
|
8
8
|
*
|
|
9
9
|
* @returns BeeGenericResponse if chunk is found or throws an exception
|
|
10
10
|
*/
|
|
11
|
-
export async function checkIfChunkExistsLocally(
|
|
12
|
-
const response = await http(
|
|
13
|
-
|
|
11
|
+
export async function checkIfChunkExistsLocally(requestOptions, address) {
|
|
12
|
+
const response = await http(requestOptions, {
|
|
13
|
+
url: `${endpoint}/${address}`,
|
|
14
14
|
responseType: 'json'
|
|
15
15
|
});
|
|
16
|
-
return response.
|
|
16
|
+
return response.data;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Delete a chunk from local storage
|
|
@@ -23,11 +23,11 @@ export async function checkIfChunkExistsLocally(kyOptions, address) {
|
|
|
23
23
|
*
|
|
24
24
|
* @returns BeeGenericResponse if chunk was deleted or throws an exception
|
|
25
25
|
*/
|
|
26
|
-
export async function deleteChunkFromLocalStorage(
|
|
27
|
-
const response = await http(
|
|
26
|
+
export async function deleteChunkFromLocalStorage(requestOptions, address) {
|
|
27
|
+
const response = await http(requestOptions, {
|
|
28
28
|
method: 'delete',
|
|
29
|
-
|
|
29
|
+
url: `${endpoint}/${address}`,
|
|
30
30
|
responseType: 'json'
|
|
31
31
|
});
|
|
32
|
-
return response.
|
|
32
|
+
return response.data;
|
|
33
33
|
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import { http } from "../../utils/http.js";
|
|
2
|
-
export async function getNodeAddresses(
|
|
3
|
-
const response = await http(
|
|
4
|
-
|
|
2
|
+
export async function getNodeAddresses(requestOptions) {
|
|
3
|
+
const response = await http(requestOptions, {
|
|
4
|
+
url: 'addresses',
|
|
5
5
|
responseType: 'json'
|
|
6
6
|
});
|
|
7
|
-
return response.
|
|
7
|
+
return response.data;
|
|
8
8
|
}
|
|
9
|
-
export async function getPeers(
|
|
10
|
-
const response = await http(
|
|
11
|
-
|
|
9
|
+
export async function getPeers(requestOptions) {
|
|
10
|
+
const response = await http(requestOptions, {
|
|
11
|
+
url: 'peers',
|
|
12
12
|
responseType: 'json'
|
|
13
13
|
});
|
|
14
|
-
return response.
|
|
14
|
+
return response.data.peers;
|
|
15
15
|
}
|
|
16
|
-
export async function getBlocklist(
|
|
17
|
-
const response = await http(
|
|
18
|
-
|
|
16
|
+
export async function getBlocklist(requestOptions) {
|
|
17
|
+
const response = await http(requestOptions, {
|
|
18
|
+
url: 'blocklist',
|
|
19
19
|
responseType: 'json'
|
|
20
20
|
});
|
|
21
|
-
return response.
|
|
21
|
+
return response.data.peers;
|
|
22
22
|
}
|
|
23
|
-
export async function removePeer(
|
|
24
|
-
const response = await http(
|
|
25
|
-
|
|
23
|
+
export async function removePeer(requestOptions, peer) {
|
|
24
|
+
const response = await http(requestOptions, {
|
|
25
|
+
url: `peers/${peer}`,
|
|
26
26
|
responseType: 'json',
|
|
27
27
|
method: 'DELETE'
|
|
28
28
|
});
|
|
29
|
-
return response.
|
|
29
|
+
return response.data;
|
|
30
30
|
}
|
|
31
|
-
export async function getTopology(
|
|
32
|
-
const response = await http(
|
|
33
|
-
|
|
31
|
+
export async function getTopology(requestOptions) {
|
|
32
|
+
const response = await http(requestOptions, {
|
|
33
|
+
url: `topology`,
|
|
34
34
|
responseType: 'json'
|
|
35
35
|
});
|
|
36
|
-
return response.
|
|
36
|
+
return response.data;
|
|
37
37
|
}
|
|
38
|
-
export async function pingPeer(
|
|
39
|
-
const response = await http(
|
|
40
|
-
|
|
38
|
+
export async function pingPeer(requestOptions, peer) {
|
|
39
|
+
const response = await http(requestOptions, {
|
|
40
|
+
url: `pingpong/${peer}`,
|
|
41
41
|
responseType: 'json',
|
|
42
42
|
method: 'POST'
|
|
43
43
|
});
|
|
44
|
-
return response.
|
|
44
|
+
return response.data;
|
|
45
45
|
}
|
|
@@ -6,22 +6,22 @@ const settlementsEndpoint = 'settlements';
|
|
|
6
6
|
* @param kyOptions Ky Options for making requests
|
|
7
7
|
* @param peer Swarm address of peer
|
|
8
8
|
*/
|
|
9
|
-
export async function getSettlements(
|
|
10
|
-
const response = await http(
|
|
11
|
-
|
|
9
|
+
export async function getSettlements(requestOptions, peer) {
|
|
10
|
+
const response = await http(requestOptions, {
|
|
11
|
+
url: `${settlementsEndpoint}/${peer}`,
|
|
12
12
|
responseType: 'json'
|
|
13
13
|
});
|
|
14
|
-
return response.
|
|
14
|
+
return response.data;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Get settlements with all known peers and total amount sent or received
|
|
18
18
|
*
|
|
19
19
|
* @param kyOptions Ky Options for making requests
|
|
20
20
|
*/
|
|
21
|
-
export async function getAllSettlements(
|
|
22
|
-
const response = await http(
|
|
23
|
-
|
|
21
|
+
export async function getAllSettlements(requestOptions) {
|
|
22
|
+
const response = await http(requestOptions, {
|
|
23
|
+
url: settlementsEndpoint,
|
|
24
24
|
responseType: 'json'
|
|
25
25
|
});
|
|
26
|
-
return response.
|
|
26
|
+
return response.data;
|
|
27
27
|
}
|
|
@@ -6,13 +6,13 @@ const REDISTRIBUTION_ENDPOINT = 'redistributionstate';
|
|
|
6
6
|
*
|
|
7
7
|
* @param kyOptions Ky Options for making requests
|
|
8
8
|
*/
|
|
9
|
-
export async function getStake(
|
|
10
|
-
const response = await http(
|
|
9
|
+
export async function getStake(requestOptions) {
|
|
10
|
+
const response = await http(requestOptions, {
|
|
11
11
|
method: 'get',
|
|
12
12
|
responseType: 'json',
|
|
13
|
-
|
|
13
|
+
url: `${STAKE_ENDPOINT}`
|
|
14
14
|
});
|
|
15
|
-
return response.
|
|
15
|
+
return response.data.stakedAmount.toString();
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Stake given amount of tokens.
|
|
@@ -21,7 +21,7 @@ export async function getStake(kyOptions) {
|
|
|
21
21
|
* @param amount
|
|
22
22
|
* @param options
|
|
23
23
|
*/
|
|
24
|
-
export async function stake(
|
|
24
|
+
export async function stake(requestOptions, amount, options) {
|
|
25
25
|
const headers = {};
|
|
26
26
|
if (options?.gasPrice) {
|
|
27
27
|
headers['gas-price'] = options.gasPrice.toString();
|
|
@@ -29,10 +29,10 @@ export async function stake(kyOptions, amount, options) {
|
|
|
29
29
|
if (options?.gasLimit) {
|
|
30
30
|
headers['gas-limit'] = options.gasLimit.toString();
|
|
31
31
|
}
|
|
32
|
-
await http(
|
|
32
|
+
await http(requestOptions, {
|
|
33
33
|
method: 'post',
|
|
34
34
|
responseType: 'json',
|
|
35
|
-
|
|
35
|
+
url: `${STAKE_ENDPOINT}/${amount}`,
|
|
36
36
|
headers
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -41,11 +41,11 @@ export async function stake(kyOptions, amount, options) {
|
|
|
41
41
|
*
|
|
42
42
|
* @param kyOptions Ky Options for making requests
|
|
43
43
|
*/
|
|
44
|
-
export async function getRedistributionState(
|
|
45
|
-
const response = await http(
|
|
44
|
+
export async function getRedistributionState(requestOptions) {
|
|
45
|
+
const response = await http(requestOptions, {
|
|
46
46
|
method: 'get',
|
|
47
47
|
responseType: 'json',
|
|
48
|
-
|
|
48
|
+
url: REDISTRIBUTION_ENDPOINT
|
|
49
49
|
});
|
|
50
|
-
return response.
|
|
50
|
+
return response.data;
|
|
51
51
|
}
|