@ethersphere/bee-js 6.9.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -65
- package/dist/cjs/bee.js +533 -6
- package/dist/cjs/chunk/cac.js +3 -3
- package/dist/cjs/chunk/soc.js +5 -5
- package/dist/cjs/chunk/span.js +2 -6
- package/dist/cjs/feed/identifier.js +2 -2
- package/dist/cjs/feed/index.js +7 -8
- package/dist/cjs/feed/retrievable.js +2 -2
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/modules/bytes.js +3 -3
- package/dist/cjs/modules/bzz.js +9 -20
- package/dist/cjs/modules/chunk.js +2 -2
- package/dist/cjs/modules/debug/balance.js +4 -4
- package/dist/cjs/modules/debug/chequebook.js +8 -8
- package/dist/cjs/modules/debug/chunk.js +2 -19
- package/dist/cjs/modules/debug/settlements.js +2 -2
- package/dist/cjs/modules/debug/stake.js +3 -3
- package/dist/cjs/modules/debug/states.js +4 -19
- package/dist/cjs/modules/debug/status.js +15 -32
- package/dist/cjs/modules/debug/tag.js +1 -1
- package/dist/cjs/modules/debug/transactions.js +4 -4
- package/dist/cjs/modules/feed.js +6 -7
- package/dist/cjs/modules/pinning.js +4 -4
- package/dist/cjs/modules/pss.js +1 -1
- package/dist/cjs/modules/soc.js +1 -1
- package/dist/cjs/modules/status.js +1 -1
- package/dist/cjs/modules/stewardship.js +1 -1
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/types/index.js +5 -1
- package/dist/cjs/utils/collection.js +7 -22
- package/dist/cjs/utils/collection.node.js +2 -1
- package/dist/cjs/utils/data.browser.js +1 -49
- package/dist/cjs/utils/error.js +2 -6
- package/dist/cjs/utils/eth.js +1 -1
- package/dist/cjs/utils/expose.js +1 -8
- package/dist/cjs/utils/file.js +2 -2
- package/dist/cjs/utils/http.js +6 -25
- package/dist/cjs/utils/tar-uploader.browser.js +26 -0
- package/dist/cjs/utils/tar-uploader.js +27 -0
- package/dist/cjs/utils/tar-writer.browser.js +17 -0
- package/dist/cjs/utils/tar-writer.js +21 -0
- package/dist/cjs/utils/tar.browser.js +65 -0
- package/dist/cjs/utils/tar.js +47 -21
- package/dist/cjs/utils/type.js +7 -3
- package/dist/cjs/utils/url.js +1 -6
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.LICENSE.txt +0 -42
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee.js +533 -9
- package/dist/mjs/chunk/cac.js +4 -4
- package/dist/mjs/chunk/soc.js +6 -6
- package/dist/mjs/chunk/span.js +2 -6
- package/dist/mjs/feed/identifier.js +2 -2
- package/dist/mjs/feed/index.js +7 -11
- package/dist/mjs/feed/retrievable.js +2 -2
- package/dist/mjs/index.js +1 -2
- package/dist/mjs/modules/bytes.js +3 -3
- package/dist/mjs/modules/bzz.js +8 -20
- package/dist/mjs/modules/chunk.js +2 -2
- package/dist/mjs/modules/debug/balance.js +4 -4
- package/dist/mjs/modules/debug/chequebook.js +8 -8
- package/dist/mjs/modules/debug/chunk.js +1 -17
- package/dist/mjs/modules/debug/settlements.js +2 -2
- package/dist/mjs/modules/debug/stake.js +3 -3
- package/dist/mjs/modules/debug/states.js +4 -19
- package/dist/mjs/modules/debug/status.js +15 -34
- package/dist/mjs/modules/debug/tag.js +1 -1
- package/dist/mjs/modules/debug/transactions.js +4 -4
- package/dist/mjs/modules/feed.js +6 -7
- package/dist/mjs/modules/pinning.js +4 -4
- package/dist/mjs/modules/pss.js +1 -1
- package/dist/mjs/modules/soc.js +1 -1
- package/dist/mjs/modules/status.js +1 -1
- package/dist/mjs/modules/stewardship.js +1 -1
- package/dist/mjs/package.json +6 -2
- package/dist/mjs/types/index.js +4 -0
- package/dist/mjs/utils/collection.js +7 -22
- package/dist/mjs/utils/collection.node.js +2 -1
- package/dist/mjs/utils/data.browser.js +0 -57
- package/dist/mjs/utils/error.js +2 -6
- package/dist/mjs/utils/eth.js +1 -1
- package/dist/mjs/utils/expose.js +0 -1
- package/dist/mjs/utils/http.js +5 -2
- package/dist/mjs/utils/tar-uploader.browser.js +22 -0
- package/dist/mjs/utils/tar-uploader.js +23 -0
- package/dist/mjs/utils/tar-writer.browser.js +12 -0
- package/dist/mjs/utils/tar-writer.js +16 -0
- package/dist/mjs/utils/tar.browser.js +61 -0
- package/dist/mjs/utils/tar.js +45 -16
- package/dist/mjs/utils/type.js +4 -1
- package/dist/mjs/utils/url.js +1 -6
- package/dist/types/bee.d.ts +305 -4
- package/dist/types/chunk/soc.d.ts +2 -2
- package/dist/types/feed/identifier.d.ts +1 -1
- package/dist/types/feed/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -3
- package/dist/types/modules/bytes.d.ts +3 -3
- package/dist/types/modules/bzz.d.ts +14 -6
- package/dist/types/modules/chunk.d.ts +2 -2
- package/dist/types/modules/debug/balance.d.ts +4 -4
- package/dist/types/modules/debug/chequebook.d.ts +8 -8
- package/dist/types/modules/debug/chunk.d.ts +1 -10
- package/dist/types/modules/debug/settlements.d.ts +2 -2
- package/dist/types/modules/debug/stake.d.ts +3 -3
- package/dist/types/modules/debug/states.d.ts +3 -3
- package/dist/types/modules/debug/status.d.ts +10 -20
- package/dist/types/modules/debug/tag.d.ts +1 -1
- package/dist/types/modules/debug/transactions.d.ts +4 -4
- package/dist/types/modules/feed.d.ts +6 -9
- package/dist/types/modules/pinning.d.ts +4 -4
- package/dist/types/modules/pss.d.ts +1 -1
- package/dist/types/modules/soc.d.ts +1 -1
- package/dist/types/modules/status.d.ts +1 -1
- package/dist/types/modules/stewardship.d.ts +1 -1
- package/dist/types/types/debug.d.ts +0 -3
- package/dist/types/types/index.d.ts +9 -17
- package/dist/types/utils/collection.browser.d.ts +1 -1
- package/dist/types/utils/collection.d.ts +3 -3
- package/dist/types/utils/collection.node.d.ts +1 -1
- package/dist/types/utils/data.browser.d.ts +0 -7
- package/dist/types/utils/data.d.ts +1 -2
- package/dist/types/utils/error.d.ts +2 -7
- package/dist/types/utils/eth.d.ts +1 -1
- package/dist/types/utils/expose.d.ts +0 -1
- package/dist/types/utils/tar-uploader.browser.d.ts +4 -0
- package/dist/types/utils/tar-uploader.d.ts +4 -0
- package/dist/types/utils/tar-writer.browser.d.ts +3 -0
- package/dist/types/utils/tar-writer.d.ts +3 -0
- package/dist/types/utils/tar.browser.d.ts +9 -0
- package/dist/types/utils/tar.d.ts +10 -2
- package/dist/types/utils/type.d.ts +4 -1
- package/package.json +4 -19
- package/dist/cjs/bee-debug.js +0 -590
- package/dist/cjs/chunk/serialize.js +0 -19
- package/dist/cjs/utils/stream.js +0 -146
- package/dist/cjs/utils/uint64.js +0 -29
- package/dist/mjs/bee-debug.js +0 -560
- package/dist/mjs/chunk/serialize.js +0 -15
- package/dist/mjs/utils/stream.js +0 -129
- package/dist/mjs/utils/uint64.js +0 -22
- package/dist/types/bee-debug.d.ts +0 -323
- package/dist/types/chunk/serialize.d.ts +0 -6
- package/dist/types/utils/stream.d.ts +0 -40
- package/dist/types/utils/uint64.d.ts +0 -4
package/dist/mjs/feed/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Binary } from 'cafe-utility';
|
|
2
2
|
import { makeSingleOwnerChunkFromData, uploadSingleOwnerChunkData } from "../chunk/soc.js";
|
|
3
3
|
import * as chunkAPI from "../modules/chunk.js";
|
|
4
4
|
import { fetchLatestFeedUpdate } from "../modules/feed.js";
|
|
@@ -9,7 +9,6 @@ import { keccak256Hash } from "../utils/hash.js";
|
|
|
9
9
|
import { bytesToHex, hexToBytes, makeHexString } from "../utils/hex.js";
|
|
10
10
|
import { makeBytesReference } from "../utils/reference.js";
|
|
11
11
|
import { assertAddress } from "../utils/type.js";
|
|
12
|
-
import { readUint64BigEndian, writeUint64BigEndian } from "../utils/uint64.js";
|
|
13
12
|
import { makeFeedIdentifier } from "./identifier.js";
|
|
14
13
|
const TIMESTAMP_PAYLOAD_OFFSET = 0;
|
|
15
14
|
const TIMESTAMP_PAYLOAD_SIZE = 8;
|
|
@@ -25,13 +24,13 @@ export async function findNextIndex(requestOptions, owner, topic, options) {
|
|
|
25
24
|
throw e;
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
export async function updateFeed(requestOptions, signer, topic, reference, postageBatchId, options
|
|
27
|
+
export async function updateFeed(requestOptions, signer, topic, reference, postageBatchId, options) {
|
|
29
28
|
const ownerHex = makeHexEthAddress(signer.address);
|
|
30
|
-
const nextIndex = index
|
|
29
|
+
const nextIndex = options?.index || (await findNextIndex(requestOptions, ownerHex, topic, options));
|
|
31
30
|
const identifier = makeFeedIdentifier(topic, nextIndex);
|
|
32
31
|
const at = options?.at ?? Date.now() / 1000.0;
|
|
33
|
-
const timestamp =
|
|
34
|
-
const payloadBytes =
|
|
32
|
+
const timestamp = Binary.numberToUint64BE(at);
|
|
33
|
+
const payloadBytes = Binary.concatBytes(timestamp, reference);
|
|
35
34
|
return uploadSingleOwnerChunkData(requestOptions, signer, postageBatchId, identifier, payloadBytes, options);
|
|
36
35
|
}
|
|
37
36
|
export function getFeedUpdateChunkReference(owner, topic, index) {
|
|
@@ -45,7 +44,7 @@ export async function downloadFeedUpdate(requestOptions, owner, topic, index) {
|
|
|
45
44
|
const soc = makeSingleOwnerChunkFromData(data, address);
|
|
46
45
|
const payload = soc.payload();
|
|
47
46
|
const timestampBytes = bytesAtOffset(payload, TIMESTAMP_PAYLOAD_OFFSET, TIMESTAMP_PAYLOAD_SIZE);
|
|
48
|
-
const timestamp =
|
|
47
|
+
const timestamp = Binary.uint64BEToNumber(timestampBytes);
|
|
49
48
|
const reference = makeBytesReference(payload, REFERENCE_PAYLOAD_OFFSET);
|
|
50
49
|
return {
|
|
51
50
|
timestamp,
|
|
@@ -59,10 +58,7 @@ export function makeFeedReader(requestOptions, type, topic, owner) {
|
|
|
59
58
|
topic,
|
|
60
59
|
async download(options) {
|
|
61
60
|
if (!options?.index && options?.index !== 0) {
|
|
62
|
-
return fetchLatestFeedUpdate(requestOptions, owner, topic
|
|
63
|
-
...options,
|
|
64
|
-
type
|
|
65
|
-
});
|
|
61
|
+
return fetchLatestFeedUpdate(requestOptions, owner, topic);
|
|
66
62
|
}
|
|
67
63
|
const update = await downloadFeedUpdate(requestOptions, hexToBytes(owner), topic, options.index);
|
|
68
64
|
return {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Binary } from 'cafe-utility';
|
|
1
2
|
import { bytesToHex } from "../utils/hex.js";
|
|
2
|
-
import { readUint64BigEndian } from "../utils/uint64.js";
|
|
3
3
|
import { getFeedUpdateChunkReference } from "./index.js";
|
|
4
4
|
function makeNumericIndex(index) {
|
|
5
5
|
if (index instanceof Uint8Array) {
|
|
6
|
-
return
|
|
6
|
+
return Binary.uint64BEToNumber(index);
|
|
7
7
|
}
|
|
8
8
|
if (typeof index === 'string') {
|
|
9
9
|
return parseInt(index);
|
package/dist/mjs/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Bee } from "./bee.js";
|
|
2
|
-
import { BeeDebug } from "./bee-debug.js";
|
|
3
2
|
export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from "./modules/debug/status.js";
|
|
4
3
|
export * from "./types/index.js";
|
|
5
4
|
export * from "./utils/error.js";
|
|
6
5
|
export * as Utils from "./utils/expose.js";
|
|
7
|
-
export { Bee
|
|
6
|
+
export { Bee };
|
|
@@ -6,7 +6,7 @@ const endpoint = 'bytes';
|
|
|
6
6
|
/**
|
|
7
7
|
* Upload data to a Bee node
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
9
|
+
* @param requestOptions Options for making requests
|
|
10
10
|
* @param data Data to be uploaded
|
|
11
11
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
12
12
|
* @param options Additional options like tag, encryption, pinning
|
|
@@ -30,7 +30,7 @@ export async function upload(requestOptions, data, postageBatchId, options) {
|
|
|
30
30
|
/**
|
|
31
31
|
* Download data as a byte array
|
|
32
32
|
*
|
|
33
|
-
* @param
|
|
33
|
+
* @param requestOptions Options for making requests
|
|
34
34
|
* @param hash Bee content reference
|
|
35
35
|
*/
|
|
36
36
|
export async function download(requestOptions, hash, options) {
|
|
@@ -44,7 +44,7 @@ export async function download(requestOptions, hash, options) {
|
|
|
44
44
|
/**
|
|
45
45
|
* Download data as a readable stream
|
|
46
46
|
*
|
|
47
|
-
* @param
|
|
47
|
+
* @param requestOptions Options for making requests
|
|
48
48
|
* @param hash Bee content reference
|
|
49
49
|
*/
|
|
50
50
|
export async function downloadReadable(requestOptions, hash, options) {
|
package/dist/mjs/modules/bzz.js
CHANGED
|
@@ -2,9 +2,8 @@ import { wrapBytesWithHelpers } from "../utils/bytes.js";
|
|
|
2
2
|
import { assertCollection } from "../utils/collection.js";
|
|
3
3
|
import { extractDownloadHeaders, extractRedundantUploadHeaders, readFileHeaders } from "../utils/headers.js";
|
|
4
4
|
import { http } from "../utils/http.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { makeTagUid } from "../utils/type.js";
|
|
5
|
+
import { uploadTar } from "../utils/tar-uploader.js";
|
|
6
|
+
import { isReadable, makeTagUid } from "../utils/type.js";
|
|
8
7
|
const bzzEndpoint = 'bzz';
|
|
9
8
|
function extractFileUploadHeaders(postageBatchId, options) {
|
|
10
9
|
const headers = extractRedundantUploadHeaders(postageBatchId, options);
|
|
@@ -15,7 +14,7 @@ function extractFileUploadHeaders(postageBatchId, options) {
|
|
|
15
14
|
/**
|
|
16
15
|
* Upload single file
|
|
17
16
|
*
|
|
18
|
-
* @param
|
|
17
|
+
* @param requestOptions Options for making requests
|
|
19
18
|
* @param data Files data
|
|
20
19
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
21
20
|
* @param name Name that will be attached to the uploaded file. Wraps the data into manifest with set index document.
|
|
@@ -48,7 +47,7 @@ export async function uploadFile(requestOptions, data, postageBatchId, name, opt
|
|
|
48
47
|
/**
|
|
49
48
|
* Download single file as a buffer
|
|
50
49
|
*
|
|
51
|
-
* @param
|
|
50
|
+
* @param requestOptions Options for making requests
|
|
52
51
|
* @param hash Bee file or collection hash
|
|
53
52
|
* @param path If hash is collection then this defines path to a single file in the collection
|
|
54
53
|
*/
|
|
@@ -68,7 +67,7 @@ export async function downloadFile(requestOptions, hash, path = '', options) {
|
|
|
68
67
|
/**
|
|
69
68
|
* Download single file as a readable stream
|
|
70
69
|
*
|
|
71
|
-
* @param
|
|
70
|
+
* @param requestOptions Options for making requests
|
|
72
71
|
* @param hash Bee file or collection hash
|
|
73
72
|
* @param path If hash is collection then this defines path to a single file in the collection
|
|
74
73
|
*/
|
|
@@ -85,7 +84,7 @@ export async function downloadFileReadable(requestOptions, hash, path = '', opti
|
|
|
85
84
|
};
|
|
86
85
|
return file;
|
|
87
86
|
}
|
|
88
|
-
function extractCollectionUploadHeaders(postageBatchId, options) {
|
|
87
|
+
export function extractCollectionUploadHeaders(postageBatchId, options) {
|
|
89
88
|
const headers = extractRedundantUploadHeaders(postageBatchId, options);
|
|
90
89
|
if (options?.indexDocument) {
|
|
91
90
|
headers['swarm-index-document'] = options.indexDocument;
|
|
@@ -97,25 +96,14 @@ function extractCollectionUploadHeaders(postageBatchId, options) {
|
|
|
97
96
|
}
|
|
98
97
|
/**
|
|
99
98
|
* Upload collection
|
|
100
|
-
* @param
|
|
99
|
+
* @param requestOptions Options for making requests
|
|
101
100
|
* @param collection Collection of Uint8Array buffers to upload
|
|
102
101
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
103
102
|
* @param options
|
|
104
103
|
*/
|
|
105
104
|
export async function uploadCollection(requestOptions, collection, postageBatchId, options) {
|
|
106
105
|
assertCollection(collection);
|
|
107
|
-
const
|
|
108
|
-
const response = await http(requestOptions, {
|
|
109
|
-
method: 'post',
|
|
110
|
-
url: bzzEndpoint,
|
|
111
|
-
data: tarData,
|
|
112
|
-
responseType: 'json',
|
|
113
|
-
headers: {
|
|
114
|
-
'content-type': 'application/x-tar',
|
|
115
|
-
'swarm-collection': 'true',
|
|
116
|
-
...extractCollectionUploadHeaders(postageBatchId, options)
|
|
117
|
-
}
|
|
118
|
-
});
|
|
106
|
+
const response = await uploadTar(requestOptions, collection, postageBatchId, options);
|
|
119
107
|
return {
|
|
120
108
|
reference: response.data.reference,
|
|
121
109
|
tagUid: response.headers['swarm-tag'] ? makeTagUid(response.headers['swarm-tag']) : undefined
|
|
@@ -9,7 +9,7 @@ const endpoint = 'chunks';
|
|
|
9
9
|
* The span stores the length of the payload in uint64 little endian encoding.
|
|
10
10
|
* Upload expects the chuck data to be set accordingly.
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
12
|
+
* @param requestOptions Options for making requests
|
|
13
13
|
* @param data Chunk data to be uploaded
|
|
14
14
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
15
15
|
* @param options Additional options like tag, encryption, pinning
|
|
@@ -30,7 +30,7 @@ export async function upload(requestOptions, data, postageBatchId, options) {
|
|
|
30
30
|
/**
|
|
31
31
|
* Download chunk data as a byte array
|
|
32
32
|
*
|
|
33
|
-
* @param
|
|
33
|
+
* @param requestOptions Options for making requests
|
|
34
34
|
* @param hash Bee content reference
|
|
35
35
|
*
|
|
36
36
|
*/
|
|
@@ -4,7 +4,7 @@ const consumedEndpoint = 'consumed';
|
|
|
4
4
|
/**
|
|
5
5
|
* Get the balances with all known peers including prepaid services
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
7
|
+
* @param requestOptions Options for making requests
|
|
8
8
|
*/
|
|
9
9
|
export async function getAllBalances(requestOptions) {
|
|
10
10
|
const response = await http(requestOptions, {
|
|
@@ -16,7 +16,7 @@ export async function getAllBalances(requestOptions) {
|
|
|
16
16
|
/**
|
|
17
17
|
* Get the balances with a specific peer including prepaid services
|
|
18
18
|
*
|
|
19
|
-
* @param
|
|
19
|
+
* @param requestOptions Options for making requests
|
|
20
20
|
* @param address Swarm address of peer
|
|
21
21
|
*/
|
|
22
22
|
export async function getPeerBalance(requestOptions, address) {
|
|
@@ -29,7 +29,7 @@ export async function getPeerBalance(requestOptions, address) {
|
|
|
29
29
|
/**
|
|
30
30
|
* Get the past due consumption balances with all known peers
|
|
31
31
|
*
|
|
32
|
-
* @param
|
|
32
|
+
* @param requestOptions Options for making requests
|
|
33
33
|
*/
|
|
34
34
|
export async function getPastDueConsumptionBalances(requestOptions) {
|
|
35
35
|
const response = await http(requestOptions, {
|
|
@@ -41,7 +41,7 @@ export async function getPastDueConsumptionBalances(requestOptions) {
|
|
|
41
41
|
/**
|
|
42
42
|
* Get the past due consumption balance with a specific peer
|
|
43
43
|
*
|
|
44
|
-
* @param
|
|
44
|
+
* @param requestOptions Options for making requests
|
|
45
45
|
* @param address Swarm address of peer
|
|
46
46
|
*/
|
|
47
47
|
export async function getPastDueConsumptionPeerBalance(requestOptions, address) {
|
|
@@ -3,7 +3,7 @@ const chequebookEndpoint = 'chequebook';
|
|
|
3
3
|
/**
|
|
4
4
|
* Get the address of the chequebook contract used
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
6
|
+
* @param requestOptions Options for making requests
|
|
7
7
|
*/
|
|
8
8
|
export async function getChequebookAddress(requestOptions) {
|
|
9
9
|
const response = await http(requestOptions, {
|
|
@@ -15,7 +15,7 @@ export async function getChequebookAddress(requestOptions) {
|
|
|
15
15
|
/**
|
|
16
16
|
* Get the balance of the chequebook
|
|
17
17
|
*
|
|
18
|
-
* @param
|
|
18
|
+
* @param requestOptions Options for making requests
|
|
19
19
|
*/
|
|
20
20
|
export async function getChequebookBalance(requestOptions) {
|
|
21
21
|
const response = await http(requestOptions, {
|
|
@@ -27,7 +27,7 @@ export async function getChequebookBalance(requestOptions) {
|
|
|
27
27
|
/**
|
|
28
28
|
* Get last cashout action for the peer
|
|
29
29
|
*
|
|
30
|
-
* @param
|
|
30
|
+
* @param requestOptions Options for making requests
|
|
31
31
|
* @param peer Swarm address of peer
|
|
32
32
|
*/
|
|
33
33
|
export async function getLastCashoutAction(requestOptions, peer) {
|
|
@@ -40,7 +40,7 @@ export async function getLastCashoutAction(requestOptions, peer) {
|
|
|
40
40
|
/**
|
|
41
41
|
* Cashout the last cheque for the peer
|
|
42
42
|
*
|
|
43
|
-
* @param
|
|
43
|
+
* @param requestOptions Options for making requests
|
|
44
44
|
* @param peer Swarm address of peer
|
|
45
45
|
* @param options
|
|
46
46
|
*/
|
|
@@ -63,7 +63,7 @@ export async function cashoutLastCheque(requestOptions, peer, options) {
|
|
|
63
63
|
/**
|
|
64
64
|
* Get last cheques for the peer
|
|
65
65
|
*
|
|
66
|
-
* @param
|
|
66
|
+
* @param requestOptions Options for making requests
|
|
67
67
|
* @param peer Swarm address of peer
|
|
68
68
|
*/
|
|
69
69
|
export async function getLastChequesForPeer(requestOptions, peer) {
|
|
@@ -76,7 +76,7 @@ export async function getLastChequesForPeer(requestOptions, peer) {
|
|
|
76
76
|
/**
|
|
77
77
|
* Get last cheques for all peers
|
|
78
78
|
*
|
|
79
|
-
* @param
|
|
79
|
+
* @param requestOptions Options for making requests
|
|
80
80
|
*/
|
|
81
81
|
export async function getLastCheques(requestOptions) {
|
|
82
82
|
const response = await http(requestOptions, {
|
|
@@ -88,7 +88,7 @@ export async function getLastCheques(requestOptions) {
|
|
|
88
88
|
/**
|
|
89
89
|
* Deposit tokens from overlay address into chequebook
|
|
90
90
|
*
|
|
91
|
-
* @param
|
|
91
|
+
* @param requestOptions Options for making requests
|
|
92
92
|
* @param amount Amount of tokens to deposit
|
|
93
93
|
* @param gasPrice Gas Price in WEI for the transaction call
|
|
94
94
|
* @return string Hash of the transaction
|
|
@@ -112,7 +112,7 @@ export async function depositTokens(requestOptions, amount, gasPrice) {
|
|
|
112
112
|
/**
|
|
113
113
|
* Withdraw tokens from the chequebook to the overlay address
|
|
114
114
|
*
|
|
115
|
-
* @param
|
|
115
|
+
* @param requestOptions Options for making requests
|
|
116
116
|
* @param amount Amount of tokens to withdraw
|
|
117
117
|
* @param gasPrice Gas Price in WEI for the transaction call
|
|
118
118
|
* @return string Hash of the transaction
|
|
@@ -3,7 +3,7 @@ const endpoint = 'chunks';
|
|
|
3
3
|
/**
|
|
4
4
|
* Check if chunk at address exists locally
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
6
|
+
* @param requestOptions Options for making requests
|
|
7
7
|
* @param address Swarm address of chunk
|
|
8
8
|
*
|
|
9
9
|
* @returns BeeGenericResponse if chunk is found or throws an exception
|
|
@@ -14,20 +14,4 @@ export async function checkIfChunkExistsLocally(requestOptions, address) {
|
|
|
14
14
|
responseType: 'json'
|
|
15
15
|
});
|
|
16
16
|
return response.data;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Delete a chunk from local storage
|
|
20
|
-
*
|
|
21
|
-
* @param kyOptions Ky Options for making requests
|
|
22
|
-
* @param address Swarm address of chunk
|
|
23
|
-
*
|
|
24
|
-
* @returns BeeGenericResponse if chunk was deleted or throws an exception
|
|
25
|
-
*/
|
|
26
|
-
export async function deleteChunkFromLocalStorage(requestOptions, address) {
|
|
27
|
-
const response = await http(requestOptions, {
|
|
28
|
-
method: 'delete',
|
|
29
|
-
url: `${endpoint}/${address}`,
|
|
30
|
-
responseType: 'json'
|
|
31
|
-
});
|
|
32
|
-
return response.data;
|
|
33
17
|
}
|
|
@@ -3,7 +3,7 @@ const settlementsEndpoint = 'settlements';
|
|
|
3
3
|
/**
|
|
4
4
|
* Get amount of sent and received from settlements with a peer
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
6
|
+
* @param requestOptions Options for making requests
|
|
7
7
|
* @param peer Swarm address of peer
|
|
8
8
|
*/
|
|
9
9
|
export async function getSettlements(requestOptions, peer) {
|
|
@@ -16,7 +16,7 @@ export async function getSettlements(requestOptions, peer) {
|
|
|
16
16
|
/**
|
|
17
17
|
* Get settlements with all known peers and total amount sent or received
|
|
18
18
|
*
|
|
19
|
-
* @param
|
|
19
|
+
* @param requestOptions Options for making requests
|
|
20
20
|
*/
|
|
21
21
|
export async function getAllSettlements(requestOptions) {
|
|
22
22
|
const response = await http(requestOptions, {
|
|
@@ -4,7 +4,7 @@ const REDISTRIBUTION_ENDPOINT = 'redistributionstate';
|
|
|
4
4
|
/**
|
|
5
5
|
* Gets the staked amount
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
7
|
+
* @param requestOptions Options for making requests
|
|
8
8
|
*/
|
|
9
9
|
export async function getStake(requestOptions) {
|
|
10
10
|
const response = await http(requestOptions, {
|
|
@@ -17,7 +17,7 @@ export async function getStake(requestOptions) {
|
|
|
17
17
|
/**
|
|
18
18
|
* Stake given amount of tokens.
|
|
19
19
|
*
|
|
20
|
-
* @param
|
|
20
|
+
* @param requestOptions Options for making requests
|
|
21
21
|
* @param amount
|
|
22
22
|
* @param options
|
|
23
23
|
*/
|
|
@@ -39,7 +39,7 @@ export async function stake(requestOptions, amount, options) {
|
|
|
39
39
|
/**
|
|
40
40
|
* Get current status of node in redistribution game
|
|
41
41
|
*
|
|
42
|
-
* @param
|
|
42
|
+
* @param requestOptions Options for making requests
|
|
43
43
|
*/
|
|
44
44
|
export async function getRedistributionState(requestOptions) {
|
|
45
45
|
const response = await http(requestOptions, {
|
|
@@ -5,7 +5,7 @@ const CHAIN_STATE_ENDPOINT = 'chainstate';
|
|
|
5
5
|
/**
|
|
6
6
|
* Get state of reserve
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
8
|
+
* @param requestOptions Options for making requests
|
|
9
9
|
*/
|
|
10
10
|
export async function getReserveState(requestOptions) {
|
|
11
11
|
const response = await http(requestOptions, {
|
|
@@ -18,7 +18,7 @@ export async function getReserveState(requestOptions) {
|
|
|
18
18
|
/**
|
|
19
19
|
* Get state of reserve
|
|
20
20
|
*
|
|
21
|
-
* @param
|
|
21
|
+
* @param requestOptions Options for making requests
|
|
22
22
|
*/
|
|
23
23
|
export async function getChainState(requestOptions) {
|
|
24
24
|
const response = await http(requestOptions, {
|
|
@@ -31,7 +31,7 @@ export async function getChainState(requestOptions) {
|
|
|
31
31
|
/**
|
|
32
32
|
* Get wallet balances for xDai and BZZ of the node
|
|
33
33
|
*
|
|
34
|
-
* @param
|
|
34
|
+
* @param requestOptions Options for making requests
|
|
35
35
|
*/
|
|
36
36
|
export async function getWalletBalance(requestOptions) {
|
|
37
37
|
const response = await http(requestOptions, {
|
|
@@ -39,20 +39,5 @@ export async function getWalletBalance(requestOptions) {
|
|
|
39
39
|
url: `${WALLET_ENDPOINT}`,
|
|
40
40
|
responseType: 'json'
|
|
41
41
|
});
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* TODO: Remove on next break
|
|
46
|
-
* @param data
|
|
47
|
-
*/
|
|
48
|
-
function mapWalletProperties(data) {
|
|
49
|
-
return {
|
|
50
|
-
// @ts-ignore: Needed for backward compatibility mapping
|
|
51
|
-
bzz: data.bzzBalance,
|
|
52
|
-
// @ts-ignore: Needed for backward compatibility mapping
|
|
53
|
-
xDai: data.nativeTokenBalance,
|
|
54
|
-
// @ts-ignore: Needed for backward compatibility mapping
|
|
55
|
-
contractAddress: data.chequebookContractAddress,
|
|
56
|
-
...data
|
|
57
|
-
};
|
|
42
|
+
return response.data;
|
|
58
43
|
}
|
|
@@ -4,7 +4,7 @@ import { http } from "../../utils/http.js"; // Following lines bellow are automa
|
|
|
4
4
|
export const SUPPORTED_BEE_VERSION_EXACT = '1.18.2-759f56f';
|
|
5
5
|
export const SUPPORTED_API_VERSION = '4.0.0';
|
|
6
6
|
export const SUPPORTED_DEBUG_API_VERSION = '4.0.0';
|
|
7
|
-
export const SUPPORTED_BEE_VERSION = SUPPORTED_BEE_VERSION_EXACT.
|
|
7
|
+
export const SUPPORTED_BEE_VERSION = SUPPORTED_BEE_VERSION_EXACT.split('-')[0];
|
|
8
8
|
const NODE_INFO_URL = 'node';
|
|
9
9
|
const STATUS_URL = 'status';
|
|
10
10
|
const HEALTH_URL = 'health';
|
|
@@ -20,7 +20,7 @@ export async function getDebugStatus(requestOptions) {
|
|
|
20
20
|
/**
|
|
21
21
|
* Get health of node
|
|
22
22
|
*
|
|
23
|
-
* @param
|
|
23
|
+
* @param requestOptions Options for making requests
|
|
24
24
|
*/
|
|
25
25
|
export async function getHealth(requestOptions) {
|
|
26
26
|
const response = await http(requestOptions, {
|
|
@@ -33,7 +33,7 @@ export async function getHealth(requestOptions) {
|
|
|
33
33
|
/**
|
|
34
34
|
* Get readiness of node
|
|
35
35
|
*
|
|
36
|
-
* @param
|
|
36
|
+
* @param requestOptions Options for making requests
|
|
37
37
|
*/
|
|
38
38
|
export async function getReadiness(requestOptions) {
|
|
39
39
|
try {
|
|
@@ -49,7 +49,7 @@ export async function getReadiness(requestOptions) {
|
|
|
49
49
|
/**
|
|
50
50
|
* Get information about Bee node
|
|
51
51
|
*
|
|
52
|
-
* @param
|
|
52
|
+
* @param requestOptions Options for making requests
|
|
53
53
|
*/
|
|
54
54
|
export async function getNodeInfo(requestOptions) {
|
|
55
55
|
const response = await http(requestOptions, {
|
|
@@ -62,8 +62,7 @@ export async function getNodeInfo(requestOptions) {
|
|
|
62
62
|
/**
|
|
63
63
|
* Connects to a node and checks if it is a supported Bee version by the bee-js
|
|
64
64
|
*
|
|
65
|
-
* @param
|
|
66
|
-
*
|
|
65
|
+
* @param requestOptions Options for making requests
|
|
67
66
|
* @returns true if the Bee node version is supported
|
|
68
67
|
* @deprecated Use `isSupportedExactVersion` instead
|
|
69
68
|
*/
|
|
@@ -79,7 +78,7 @@ export async function isSupportedVersion(requestOptions) {
|
|
|
79
78
|
* `isSupportedApiVersion`, `isSupportedMainApiVersion` or `isSupportedDebugApiVersion`
|
|
80
79
|
* based on your use-case.
|
|
81
80
|
*
|
|
82
|
-
* @param
|
|
81
|
+
* @param requestOptions Options for making requests
|
|
83
82
|
*/
|
|
84
83
|
export async function isSupportedExactVersion(requestOptions) {
|
|
85
84
|
const {
|
|
@@ -90,10 +89,10 @@ export async function isSupportedExactVersion(requestOptions) {
|
|
|
90
89
|
/**
|
|
91
90
|
* Connects to a node and checks if its main's API version matches with the one that bee-js supports.
|
|
92
91
|
*
|
|
93
|
-
* This is useful if you are not using `
|
|
92
|
+
* This is useful if you are not using `Bee` class (for anything else then this check)
|
|
94
93
|
* and want to make sure about compatibility.
|
|
95
94
|
*
|
|
96
|
-
* @param
|
|
95
|
+
* @param requestOptions Options for making requests
|
|
97
96
|
*/
|
|
98
97
|
export async function isSupportedMainApiVersion(requestOptions) {
|
|
99
98
|
const {
|
|
@@ -102,51 +101,33 @@ export async function isSupportedMainApiVersion(requestOptions) {
|
|
|
102
101
|
return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION);
|
|
103
102
|
}
|
|
104
103
|
/**
|
|
105
|
-
* Connects to a node and checks if its
|
|
106
|
-
*
|
|
107
|
-
* This is useful if you are not using `Bee` class in your application and want to make sure
|
|
108
|
-
* about compatibility.
|
|
109
|
-
*
|
|
110
|
-
* @param ky
|
|
111
|
-
*/
|
|
112
|
-
export async function isSupportedDebugApiVersion(requestOptions) {
|
|
113
|
-
const {
|
|
114
|
-
debugApiVersion
|
|
115
|
-
} = await getHealth(requestOptions);
|
|
116
|
-
return getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Connects to a node and checks if its Main and Debug API versions matches with the one that bee-js supports.
|
|
104
|
+
* Connects to a node and checks if its Main API versions matches with the one that bee-js supports.
|
|
120
105
|
*
|
|
121
106
|
* This should be the main way how to check compatibility for your app and Bee node.
|
|
122
107
|
*
|
|
123
|
-
* @param
|
|
108
|
+
* @param requestOptions Options for making requests
|
|
124
109
|
*/
|
|
125
110
|
export async function isSupportedApiVersion(requestOptions) {
|
|
126
111
|
const {
|
|
127
|
-
apiVersion
|
|
128
|
-
debugApiVersion
|
|
112
|
+
apiVersion
|
|
129
113
|
} = await getHealth(requestOptions);
|
|
130
|
-
return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION)
|
|
114
|
+
return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION);
|
|
131
115
|
}
|
|
132
116
|
/**
|
|
133
117
|
* Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
|
|
134
118
|
* and versions that bee-js supports (properties prefixed with `supported*`).
|
|
135
119
|
*
|
|
136
|
-
* @param
|
|
120
|
+
* @param requestOptions Options for making requests
|
|
137
121
|
*/
|
|
138
122
|
export async function getVersions(requestOptions) {
|
|
139
123
|
const {
|
|
140
124
|
version,
|
|
141
|
-
apiVersion
|
|
142
|
-
debugApiVersion
|
|
125
|
+
apiVersion
|
|
143
126
|
} = await getHealth(requestOptions);
|
|
144
127
|
return {
|
|
145
128
|
supportedBeeVersion: SUPPORTED_BEE_VERSION_EXACT,
|
|
146
129
|
supportedBeeApiVersion: SUPPORTED_API_VERSION,
|
|
147
|
-
supportedBeeDebugApiVersion: SUPPORTED_DEBUG_API_VERSION,
|
|
148
130
|
beeVersion: version,
|
|
149
|
-
beeApiVersion: apiVersion
|
|
150
|
-
beeDebugApiVersion: debugApiVersion
|
|
131
|
+
beeApiVersion: apiVersion
|
|
151
132
|
};
|
|
152
133
|
}
|
|
@@ -3,7 +3,7 @@ const endpoint = 'tags';
|
|
|
3
3
|
/**
|
|
4
4
|
* Retrieve tag with extended information from Bee node
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
6
|
+
* @param requestOptions Options for making requests
|
|
7
7
|
* @param uid UID of tag to be retrieved
|
|
8
8
|
*/
|
|
9
9
|
export async function retrieveExtendedTag(requestOptions, uid) {
|
|
@@ -3,7 +3,7 @@ const transactionsEndpoint = 'transactions';
|
|
|
3
3
|
/**
|
|
4
4
|
* Get list of all pending transactions
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
6
|
+
* @param requestOptions Options for making requests
|
|
7
7
|
*/
|
|
8
8
|
export async function getAllTransactions(requestOptions) {
|
|
9
9
|
const response = await http(requestOptions, {
|
|
@@ -15,7 +15,7 @@ export async function getAllTransactions(requestOptions) {
|
|
|
15
15
|
/**
|
|
16
16
|
* Get information for specific pending transactions
|
|
17
17
|
*
|
|
18
|
-
* @param
|
|
18
|
+
* @param requestOptions Options for making requests
|
|
19
19
|
* @param transactionHash Hash of the transaction
|
|
20
20
|
*/
|
|
21
21
|
export async function getTransaction(requestOptions, transactionHash) {
|
|
@@ -28,7 +28,7 @@ export async function getTransaction(requestOptions, transactionHash) {
|
|
|
28
28
|
/**
|
|
29
29
|
* Rebroadcast existing transaction
|
|
30
30
|
*
|
|
31
|
-
* @param
|
|
31
|
+
* @param requestOptions Options for making requests
|
|
32
32
|
* @param transactionHash Hash of the transaction
|
|
33
33
|
*/
|
|
34
34
|
export async function rebroadcastTransaction(requestOptions, transactionHash) {
|
|
@@ -42,7 +42,7 @@ export async function rebroadcastTransaction(requestOptions, transactionHash) {
|
|
|
42
42
|
/**
|
|
43
43
|
* Cancel existing transaction
|
|
44
44
|
*
|
|
45
|
-
* @param
|
|
45
|
+
* @param requestOptions Options for making requests
|
|
46
46
|
* @param transactionHash Hash of the transaction
|
|
47
47
|
* @param gasPrice Optional gas price
|
|
48
48
|
*/
|
package/dist/mjs/modules/feed.js
CHANGED
|
@@ -5,18 +5,17 @@ const feedEndpoint = 'feeds';
|
|
|
5
5
|
/**
|
|
6
6
|
* Create an initial feed root manifest
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
8
|
+
* @param requestOptions Options for making requests
|
|
9
9
|
* @param owner Owner's ethereum address in hex
|
|
10
10
|
* @param topic Topic in hex
|
|
11
11
|
* @param postageBatchId Postage BatchId to be used to create the Feed Manifest
|
|
12
12
|
* @param options Additional options, like type (default: 'sequence')
|
|
13
13
|
*/
|
|
14
|
-
export async function createFeedManifest(requestOptions, owner, topic, postageBatchId
|
|
14
|
+
export async function createFeedManifest(requestOptions, owner, topic, postageBatchId) {
|
|
15
15
|
const response = await http(requestOptions, {
|
|
16
16
|
method: 'post',
|
|
17
17
|
responseType: 'json',
|
|
18
18
|
url: `${feedEndpoint}/${owner}/${topic}`,
|
|
19
|
-
params: options,
|
|
20
19
|
headers: extractUploadHeaders(postageBatchId)
|
|
21
20
|
});
|
|
22
21
|
return response.data.reference;
|
|
@@ -43,10 +42,10 @@ function readFeedUpdateHeaders(headers) {
|
|
|
43
42
|
* the reference it contains along with its index and the
|
|
44
43
|
* index of the subsequent update.
|
|
45
44
|
*
|
|
46
|
-
* @param
|
|
47
|
-
* @param owner
|
|
48
|
-
* @param topic
|
|
49
|
-
* @param options
|
|
45
|
+
* @param requestOptions Options for making requests
|
|
46
|
+
* @param owner Owner's ethereum address in hex
|
|
47
|
+
* @param topic Topic in hex
|
|
48
|
+
* @param options Additional options, like index, at, type
|
|
50
49
|
*/
|
|
51
50
|
export async function fetchLatestFeedUpdate(requestOptions, owner, topic, options) {
|
|
52
51
|
const response = await http(requestOptions, {
|
|
@@ -3,7 +3,7 @@ const PINNING_ENDPOINT = 'pins';
|
|
|
3
3
|
/**
|
|
4
4
|
* Pin data with given reference
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
6
|
+
* @param requestOptions Options for making requests
|
|
7
7
|
* @param reference Bee data reference
|
|
8
8
|
*/
|
|
9
9
|
export async function pin(requestOptions, reference) {
|
|
@@ -16,7 +16,7 @@ export async function pin(requestOptions, reference) {
|
|
|
16
16
|
/**
|
|
17
17
|
* Unpin data with given reference
|
|
18
18
|
*
|
|
19
|
-
* @param
|
|
19
|
+
* @param requestOptions Options for making requests
|
|
20
20
|
* @param reference Bee data reference
|
|
21
21
|
*/
|
|
22
22
|
export async function unpin(requestOptions, reference) {
|
|
@@ -29,7 +29,7 @@ export async function unpin(requestOptions, reference) {
|
|
|
29
29
|
/**
|
|
30
30
|
* Get pin status for specific address.
|
|
31
31
|
*
|
|
32
|
-
* @param
|
|
32
|
+
* @param requestOptions Options for making requests
|
|
33
33
|
* @param reference
|
|
34
34
|
* @throws Error if given address is not pinned
|
|
35
35
|
*/
|
|
@@ -44,7 +44,7 @@ export async function getPin(requestOptions, reference) {
|
|
|
44
44
|
/**
|
|
45
45
|
* Get list of all pins
|
|
46
46
|
*
|
|
47
|
-
* @param
|
|
47
|
+
* @param requestOptions Options for making requests
|
|
48
48
|
*/
|
|
49
49
|
export async function getAllPins(requestOptions) {
|
|
50
50
|
const response = await http(requestOptions, {
|