@ethersphere/bee-js 13.0.0-upcoming.gc013bdf → 13.0.0-upcoming.gc78f60a
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/api/bytes.js +3 -3
- package/dist/cjs/api/bzz.js +5 -5
- package/dist/cjs/api/chunk.js +3 -3
- package/dist/cjs/api/envelope.js +3 -3
- package/dist/cjs/api/feed.js +4 -4
- package/dist/cjs/api/pin.js +2 -2
- package/dist/cjs/api/soc.js +2 -2
- package/dist/cjs/bee.js +6 -6
- package/dist/cjs/chunk/soc.js +16 -16
- package/dist/cjs/feed/identifier.js +3 -3
- package/dist/cjs/feed/index.js +17 -17
- package/dist/cjs/feed/retrievable.js +2 -2
- package/dist/cjs/index.js +17 -17
- package/dist/cjs/manifest/manifest.js +8 -8
- package/dist/cjs/modules/balance.js +3 -3
- package/dist/cjs/modules/cheque.js +4 -4
- package/dist/cjs/modules/chunk.js +8 -8
- package/dist/cjs/modules/collection.js +6 -6
- package/dist/cjs/modules/connectivity.js +3 -3
- package/dist/cjs/modules/data.js +4 -4
- package/dist/cjs/modules/feed.js +10 -10
- package/dist/cjs/modules/file.js +3 -3
- package/dist/cjs/modules/grantee.js +9 -9
- package/dist/cjs/modules/messaging.js +14 -14
- package/dist/cjs/modules/pin.js +6 -6
- package/dist/cjs/modules/settlement.js +2 -2
- package/dist/cjs/modules/soc.js +3 -3
- package/dist/cjs/modules/stamp.js +7 -7
- package/dist/cjs/modules/tag.js +2 -2
- package/dist/cjs/modules/transaction.js +4 -4
- package/dist/cjs/modules/wallet.js +3 -3
- package/dist/cjs/types/schema/chequebook.js +5 -5
- package/dist/cjs/types/schema/connectivity.js +5 -5
- package/dist/cjs/types/schema/envelope.js +5 -5
- package/dist/cjs/types/schema/grantee.js +4 -4
- package/dist/cjs/types/schema/stake.js +2 -2
- package/dist/cjs/types/schema/stamps.js +4 -4
- package/dist/cjs/types/schema/states.js +2 -2
- package/dist/cjs/types/schema/transactions.js +3 -3
- package/dist/cjs/types/schema/upload.js +2 -2
- package/dist/cjs/utils/chunk-stream.browser.js +3 -3
- package/dist/cjs/utils/chunk-stream.js +4 -4
- package/dist/cjs/utils/constants.js +3 -3
- package/dist/cjs/utils/expose.js +4 -4
- package/dist/cjs/utils/headers.js +4 -4
- package/dist/cjs/utils/pss.js +2 -2
- package/dist/cjs/utils/resource-locator.js +2 -2
- package/dist/cjs/utils/schema.js +4 -4
- package/dist/cjs/utils/stamps.js +14 -14
- package/dist/codemod/index.js +133 -0
- package/dist/codemod/transforms/v13.js +268 -0
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/api/bytes.js +1 -1
- package/dist/mjs/api/bzz.js +1 -1
- package/dist/mjs/api/chunk.js +1 -1
- package/dist/mjs/api/envelope.js +1 -1
- package/dist/mjs/api/feed.js +1 -1
- package/dist/mjs/api/pin.js +1 -1
- package/dist/mjs/api/soc.js +1 -1
- package/dist/mjs/bee.js +1 -1
- package/dist/mjs/chunk/soc.js +3 -3
- package/dist/mjs/feed/identifier.js +2 -2
- package/dist/mjs/feed/index.js +3 -3
- package/dist/mjs/feed/retrievable.js +1 -1
- package/dist/mjs/index.js +1 -1
- package/dist/mjs/manifest/manifest.js +3 -3
- package/dist/mjs/modules/balance.js +1 -1
- package/dist/mjs/modules/cheque.js +1 -1
- package/dist/mjs/modules/chunk.js +1 -1
- package/dist/mjs/modules/collection.js +1 -1
- package/dist/mjs/modules/connectivity.js +1 -1
- package/dist/mjs/modules/data.js +1 -1
- package/dist/mjs/modules/feed.js +1 -1
- package/dist/mjs/modules/file.js +1 -1
- package/dist/mjs/modules/grantee.js +1 -1
- package/dist/mjs/modules/messaging.js +1 -1
- package/dist/mjs/modules/pin.js +1 -1
- package/dist/mjs/modules/settlement.js +1 -1
- package/dist/mjs/modules/soc.js +1 -1
- package/dist/mjs/modules/stamp.js +1 -1
- package/dist/mjs/modules/tag.js +1 -1
- package/dist/mjs/modules/transaction.js +1 -1
- package/dist/mjs/modules/wallet.js +1 -1
- package/dist/mjs/types/schema/chequebook.js +1 -1
- package/dist/mjs/types/schema/connectivity.js +1 -1
- package/dist/mjs/types/schema/envelope.js +1 -1
- package/dist/mjs/types/schema/grantee.js +1 -1
- package/dist/mjs/types/schema/stake.js +1 -1
- package/dist/mjs/types/schema/stamps.js +1 -1
- package/dist/mjs/types/schema/states.js +1 -1
- package/dist/mjs/types/schema/transactions.js +1 -1
- package/dist/mjs/types/schema/upload.js +1 -1
- package/dist/mjs/utils/chunk-stream.browser.js +1 -1
- package/dist/mjs/utils/chunk-stream.js +1 -1
- package/dist/mjs/utils/constants.js +1 -1
- package/dist/mjs/utils/expose.js +1 -1
- package/dist/mjs/utils/headers.js +1 -1
- package/dist/mjs/utils/pss.js +1 -1
- package/dist/mjs/utils/resource-locator.js +1 -1
- package/dist/mjs/utils/schema.js +1 -1
- package/dist/mjs/utils/stamps.js +1 -1
- package/dist/types/api/balance.d.ts +1 -1
- package/dist/types/api/batches.d.ts +1 -1
- package/dist/types/api/bytes.d.ts +1 -1
- package/dist/types/api/bzz.d.ts +1 -1
- package/dist/types/api/chequebook.d.ts +1 -1
- package/dist/types/api/chunk.d.ts +1 -1
- package/dist/types/api/connectivity.d.ts +1 -1
- package/dist/types/api/consumed.d.ts +1 -1
- package/dist/types/api/envelope.d.ts +1 -1
- package/dist/types/api/feed.d.ts +1 -1
- package/dist/types/api/grantee.d.ts +1 -1
- package/dist/types/api/pin.d.ts +1 -1
- package/dist/types/api/pss.d.ts +1 -1
- package/dist/types/api/settlement.d.ts +1 -1
- package/dist/types/api/soc.d.ts +1 -1
- package/dist/types/api/stake.d.ts +1 -1
- package/dist/types/api/stamp.d.ts +1 -1
- package/dist/types/api/stewardship.d.ts +1 -1
- package/dist/types/api/tag.d.ts +1 -1
- package/dist/types/api/transaction.d.ts +1 -1
- package/dist/types/api/wallet.d.ts +1 -1
- package/dist/types/bee.d.ts +1 -1
- package/dist/types/chunk/soc.d.ts +1 -1
- package/dist/types/feed/identifier.d.ts +1 -1
- package/dist/types/feed/index.d.ts +1 -1
- package/dist/types/feed/retrievable.d.ts +1 -1
- package/dist/types/index.d.ts +16 -16
- package/dist/types/manifest/manifest.d.ts +2 -2
- package/dist/types/modules/balance.d.ts +1 -1
- package/dist/types/modules/cheque.d.ts +1 -1
- package/dist/types/modules/chequebook.d.ts +1 -1
- package/dist/types/modules/chunk.d.ts +1 -1
- package/dist/types/modules/collection.d.ts +2 -2
- package/dist/types/modules/connectivity.d.ts +1 -1
- package/dist/types/modules/context.d.ts +1 -1
- package/dist/types/modules/data.d.ts +1 -1
- package/dist/types/modules/feed.d.ts +1 -1
- package/dist/types/modules/file.d.ts +1 -1
- package/dist/types/modules/grantee.d.ts +1 -1
- package/dist/types/modules/messaging.d.ts +1 -1
- package/dist/types/modules/pin.d.ts +1 -1
- package/dist/types/modules/settlement.d.ts +1 -1
- package/dist/types/modules/soc.d.ts +1 -1
- package/dist/types/modules/stake.d.ts +1 -1
- package/dist/types/modules/stamp.d.ts +1 -1
- package/dist/types/modules/storage.d.ts +1 -1
- package/dist/types/modules/tag.d.ts +1 -1
- package/dist/types/modules/transaction.d.ts +1 -1
- package/dist/types/modules/wallet.d.ts +1 -1
- package/dist/types/types/debug.d.ts +1 -1
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/types/schema/chequebook.d.ts +1 -1
- package/dist/types/types/schema/connectivity.d.ts +1 -1
- package/dist/types/types/schema/grantee.d.ts +1 -1
- package/dist/types/types/schema/stake.d.ts +1 -1
- package/dist/types/types/schema/stamps.d.ts +1 -1
- package/dist/types/types/schema/states.d.ts +1 -1
- package/dist/types/types/schema/transactions.d.ts +1 -1
- package/dist/types/types/schema/upload.d.ts +1 -1
- package/dist/types/utils/chunk-stream.browser.d.ts +1 -1
- package/dist/types/utils/chunk-stream.d.ts +2 -2
- package/dist/types/utils/constants.d.ts +1 -1
- package/dist/types/utils/expose.d.ts +1 -1
- package/dist/types/utils/headers.d.ts +1 -1
- package/dist/types/utils/pss.d.ts +1 -1
- package/dist/types/utils/resource-locator.d.ts +1 -1
- package/dist/types/utils/schema.d.ts +1 -1
- package/dist/types/utils/stamps.d.ts +1 -1
- package/dist/types/utils/tar-uploader.browser.d.ts +1 -1
- package/dist/types/utils/tar-uploader.d.ts +1 -1
- package/package.json +7 -3
package/dist/cjs/api/bytes.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.upload = upload;
|
|
|
4
4
|
exports.head = head;
|
|
5
5
|
exports.download = download;
|
|
6
6
|
exports.downloadReadable = downloadReadable;
|
|
7
|
-
const
|
|
7
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
8
8
|
const cafe_utility_1 = require("cafe-utility");
|
|
9
9
|
const upload_1 = require("../types/schema/upload");
|
|
10
10
|
const headers_1 = require("../utils/headers");
|
|
@@ -31,7 +31,7 @@ async function upload(requestOptions, data, postageBatchId, options) {
|
|
|
31
31
|
reference: body.reference,
|
|
32
32
|
tagUid: response.headers['swarm-tag'] ? (0, type_1.makeTagUid)(response.headers['swarm-tag']) : undefined,
|
|
33
33
|
historyAddress: response.headers['swarm-act-history-address']
|
|
34
|
-
? cafe_utility_1.Optional.of(new
|
|
34
|
+
? cafe_utility_1.Optional.of(new core_sdk_1.Reference(response.headers['swarm-act-history-address']))
|
|
35
35
|
: cafe_utility_1.Optional.empty(),
|
|
36
36
|
};
|
|
37
37
|
}
|
|
@@ -54,7 +54,7 @@ async function download(requestOptions, resource, options) {
|
|
|
54
54
|
url: `${endpoint}/${resource}`,
|
|
55
55
|
headers: (0, headers_1.prepareRequestHeaders)(null, options),
|
|
56
56
|
});
|
|
57
|
-
return new
|
|
57
|
+
return new core_sdk_1.Bytes(response.data);
|
|
58
58
|
}
|
|
59
59
|
async function downloadReadable(requestOptions, resource, options) {
|
|
60
60
|
if (options) {
|
package/dist/cjs/api/bzz.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.uploadFile = uploadFile;
|
|
|
4
4
|
exports.downloadFile = downloadFile;
|
|
5
5
|
exports.downloadFileReadable = downloadFileReadable;
|
|
6
6
|
exports.uploadCollection = uploadCollection;
|
|
7
|
-
const
|
|
7
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
8
8
|
const cafe_utility_1 = require("cafe-utility");
|
|
9
9
|
const upload_1 = require("../types/schema/upload");
|
|
10
10
|
const collection_1 = require("../utils/collection");
|
|
@@ -36,7 +36,7 @@ async function uploadFile(requestOptions, data, postageBatchId, name, options) {
|
|
|
36
36
|
reference: body.reference,
|
|
37
37
|
tagUid: response.headers['swarm-tag'] ? (0, type_1.makeTagUid)(response.headers['swarm-tag']) : undefined,
|
|
38
38
|
historyAddress: response.headers['swarm-act-history-address']
|
|
39
|
-
? cafe_utility_1.Optional.of(new
|
|
39
|
+
? cafe_utility_1.Optional.of(new core_sdk_1.Reference(response.headers['swarm-act-history-address']))
|
|
40
40
|
: cafe_utility_1.Optional.empty(),
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -49,12 +49,12 @@ async function downloadFile(requestOptions, resource, path = '', options) {
|
|
|
49
49
|
});
|
|
50
50
|
const file = {
|
|
51
51
|
...(0, headers_1.readFileHeaders)(response.headers),
|
|
52
|
-
data: new
|
|
52
|
+
data: new core_sdk_1.Bytes(response.data),
|
|
53
53
|
};
|
|
54
54
|
return file;
|
|
55
55
|
}
|
|
56
56
|
async function downloadFileReadable(requestOptions, reference, path = '', options) {
|
|
57
|
-
reference = new
|
|
57
|
+
reference = new core_sdk_1.Reference(reference);
|
|
58
58
|
const response = await (0, http_1.http)(requestOptions, {
|
|
59
59
|
method: 'GET',
|
|
60
60
|
responseType: 'stream',
|
|
@@ -77,7 +77,7 @@ async function uploadCollection(requestOptions, collection, postageBatchId, opti
|
|
|
77
77
|
reference: body.reference,
|
|
78
78
|
tagUid: response.headers['swarm-tag'] ? (0, type_1.makeTagUid)(response.headers['swarm-tag']) : undefined,
|
|
79
79
|
historyAddress: response.headers['swarm-act-history-address']
|
|
80
|
-
? cafe_utility_1.Optional.of(new
|
|
80
|
+
? cafe_utility_1.Optional.of(new core_sdk_1.Reference(response.headers['swarm-act-history-address']))
|
|
81
81
|
: cafe_utility_1.Optional.empty(),
|
|
82
82
|
};
|
|
83
83
|
}
|
package/dist/cjs/api/chunk.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.upload = upload;
|
|
4
4
|
exports.download = download;
|
|
5
|
-
const
|
|
5
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
6
6
|
const cafe_utility_1 = require("cafe-utility");
|
|
7
7
|
const upload_1 = require("../types/schema/upload");
|
|
8
8
|
const headers_1 = require("../utils/headers");
|
|
@@ -28,12 +28,12 @@ async function upload(requestOptions, data, stamp, options) {
|
|
|
28
28
|
reference: body.reference,
|
|
29
29
|
tagUid: response.headers['swarm-tag'] ? (0, type_1.makeTagUid)(response.headers['swarm-tag']) : undefined,
|
|
30
30
|
historyAddress: response.headers['swarm-act-history-address']
|
|
31
|
-
? cafe_utility_1.Optional.of(new
|
|
31
|
+
? cafe_utility_1.Optional.of(new core_sdk_1.Reference(response.headers['swarm-act-history-address']))
|
|
32
32
|
: cafe_utility_1.Optional.empty(),
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
async function download(requestOptions, reference, options) {
|
|
36
|
-
reference = new
|
|
36
|
+
reference = new core_sdk_1.Reference(reference);
|
|
37
37
|
const response = await (0, http_1.http)(requestOptions, {
|
|
38
38
|
responseType: 'arraybuffer',
|
|
39
39
|
url: `${endpoint}/${reference}`,
|
package/dist/cjs/api/envelope.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.postEnvelope = postEnvelope;
|
|
4
|
-
const
|
|
4
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
5
5
|
const envelope_1 = require("../types/schema/envelope");
|
|
6
6
|
const http_1 = require("../utils/http");
|
|
7
7
|
const ENVELOPE_ENDPOINT = 'envelope';
|
|
@@ -16,10 +16,10 @@ async function postEnvelope(requestOptions, postageBatchId, reference) {
|
|
|
16
16
|
});
|
|
17
17
|
const body = envelope_1.PostEnvelopeBodyResponse.parse(response.data);
|
|
18
18
|
return {
|
|
19
|
-
issuer: new
|
|
19
|
+
issuer: new core_sdk_1.EthAddress(body.issuer),
|
|
20
20
|
index: body.index,
|
|
21
21
|
timestamp: body.timestamp,
|
|
22
|
-
signature: new
|
|
22
|
+
signature: new core_sdk_1.Signature(body.signature),
|
|
23
23
|
batchId: postageBatchId,
|
|
24
24
|
};
|
|
25
25
|
}
|
package/dist/cjs/api/feed.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createFeedManifest = createFeedManifest;
|
|
4
4
|
exports.fetchLatestFeedUpdate = fetchLatestFeedUpdate;
|
|
5
5
|
exports.probeFeed = probeFeed;
|
|
6
|
-
const
|
|
6
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
7
7
|
const upload_1 = require("../types/schema/upload");
|
|
8
8
|
const error_1 = require("../utils/error");
|
|
9
9
|
const headers_1 = require("../utils/headers");
|
|
@@ -28,8 +28,8 @@ function readFeedUpdateHeaders(headers) {
|
|
|
28
28
|
throw new error_1.BeeError('Response did not contain expected swarm-feed-index-next!');
|
|
29
29
|
}
|
|
30
30
|
return {
|
|
31
|
-
feedIndex: new
|
|
32
|
-
feedIndexNext: new
|
|
31
|
+
feedIndex: new core_sdk_1.FeedIndex(feedIndex),
|
|
32
|
+
feedIndexNext: new core_sdk_1.FeedIndex(feedIndexNext),
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
async function fetchLatestFeedUpdate(requestOptions, owner, topic, options) {
|
|
@@ -39,7 +39,7 @@ async function fetchLatestFeedUpdate(requestOptions, owner, topic, options) {
|
|
|
39
39
|
params: { ...options },
|
|
40
40
|
});
|
|
41
41
|
return {
|
|
42
|
-
payload: new
|
|
42
|
+
payload: new core_sdk_1.Bytes(response.data),
|
|
43
43
|
...readFeedUpdateHeaders(response.headers),
|
|
44
44
|
};
|
|
45
45
|
}
|
package/dist/cjs/api/pin.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.pin = pin;
|
|
|
4
4
|
exports.unpin = unpin;
|
|
5
5
|
exports.getAllPins = getAllPins;
|
|
6
6
|
exports.getPin = getPin;
|
|
7
|
-
const
|
|
7
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
8
8
|
const pinning_1 = require("../types/schema/pinning");
|
|
9
9
|
const upload_1 = require("../types/schema/upload");
|
|
10
10
|
const http_1 = require("../utils/http");
|
|
@@ -33,7 +33,7 @@ async function getAllPins(requestOptions) {
|
|
|
33
33
|
url: PINNING_ENDPOINT,
|
|
34
34
|
});
|
|
35
35
|
const { references } = pinning_1.GetAllPinsResponse.parse(response.data);
|
|
36
|
-
return (references ?? []).map(x => new
|
|
36
|
+
return (references ?? []).map(x => new core_sdk_1.Reference(x));
|
|
37
37
|
}
|
|
38
38
|
/** Gets the pinning status of the chunk with the given reference. */
|
|
39
39
|
async function getPin(requestOptions, reference) {
|
package/dist/cjs/api/soc.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.upload = upload;
|
|
4
|
-
const
|
|
4
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
5
5
|
const cafe_utility_1 = require("cafe-utility");
|
|
6
6
|
const upload_1 = require("../types/schema/upload");
|
|
7
7
|
const headers_1 = require("../utils/headers");
|
|
@@ -28,7 +28,7 @@ async function upload(requestOptions, owner, identifier, signature, data, stamp,
|
|
|
28
28
|
reference: body.reference,
|
|
29
29
|
tagUid: response.headers['swarm-tag'] ? (0, type_1.makeTagUid)(response.headers['swarm-tag']) : undefined,
|
|
30
30
|
historyAddress: response.headers['swarm-act-history-address']
|
|
31
|
-
? cafe_utility_1.Optional.of(new
|
|
31
|
+
? cafe_utility_1.Optional.of(new core_sdk_1.Reference(response.headers['swarm-act-history-address']))
|
|
32
32
|
: cafe_utility_1.Optional.empty(),
|
|
33
33
|
};
|
|
34
34
|
}
|
package/dist/cjs/bee.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Bee = void 0;
|
|
4
4
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
|
-
const
|
|
5
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
6
6
|
const envelope_1 = require("./api/envelope");
|
|
7
7
|
const rchash_1 = require("./api/rchash");
|
|
8
8
|
const soc_1 = require("./chunk/soc");
|
|
@@ -49,7 +49,7 @@ class Bee {
|
|
|
49
49
|
(0, url_1.assertBeeUrl)(url);
|
|
50
50
|
this.url = (0, url_1.stripLastSlash)(url);
|
|
51
51
|
if (options?.signer) {
|
|
52
|
-
this.signer = new
|
|
52
|
+
this.signer = new core_sdk_1.PrivateKey(options.signer);
|
|
53
53
|
}
|
|
54
54
|
this.network = options?.network ?? 'gnosis';
|
|
55
55
|
this.requestOptions = {
|
|
@@ -102,7 +102,7 @@ class Bee {
|
|
|
102
102
|
* @param span Optional span for the chunk. If not provided, it will be set to the length of the payload.
|
|
103
103
|
*/
|
|
104
104
|
makeContentAddressedChunk(rawPayload, span) {
|
|
105
|
-
return (0,
|
|
105
|
+
return (0, core_sdk_1.makeContentAddressedChunk)(rawPayload, span);
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Attempts to unmarshal arbitrary data into a Content Addressed Chunk.
|
|
@@ -111,7 +111,7 @@ class Bee {
|
|
|
111
111
|
* @param data The chunk data (`span` and `payload`)
|
|
112
112
|
*/
|
|
113
113
|
unmarshalContentAddressedChunk(data) {
|
|
114
|
-
return (0,
|
|
114
|
+
return (0, core_sdk_1.unmarshalContentAddressedChunk)(data);
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Creates a Single Owner Chunk.
|
|
@@ -169,8 +169,8 @@ class Bee {
|
|
|
169
169
|
* @returns
|
|
170
170
|
*/
|
|
171
171
|
async createEnvelope(postageBatchId, reference, requestOptions) {
|
|
172
|
-
postageBatchId = new
|
|
173
|
-
reference = new
|
|
172
|
+
postageBatchId = new core_sdk_1.BatchId(postageBatchId);
|
|
173
|
+
reference = new core_sdk_1.Reference(reference);
|
|
174
174
|
return (0, envelope_1.postEnvelope)(this.getRequestOptionsForCall(requestOptions), postageBatchId, reference);
|
|
175
175
|
}
|
|
176
176
|
/**
|
package/dist/cjs/chunk/soc.js
CHANGED
|
@@ -40,8 +40,8 @@ exports.uploadSingleOwnerChunk = uploadSingleOwnerChunk;
|
|
|
40
40
|
exports.uploadSingleOwnerChunkData = uploadSingleOwnerChunkData;
|
|
41
41
|
exports.uploadSingleOwnerChunkWithWrappedChunk = uploadSingleOwnerChunkWithWrappedChunk;
|
|
42
42
|
exports.downloadSingleOwnerChunk = downloadSingleOwnerChunk;
|
|
43
|
-
const
|
|
44
|
-
Object.defineProperty(exports, "makeSOCAddress", { enumerable: true, get: function () { return
|
|
43
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
44
|
+
Object.defineProperty(exports, "makeSOCAddress", { enumerable: true, get: function () { return core_sdk_1.makeSOCAddress; } });
|
|
45
45
|
const chunkAPI = __importStar(require("../api/chunk"));
|
|
46
46
|
const socAPI = __importStar(require("../api/soc"));
|
|
47
47
|
const error_1 = require("../utils/error");
|
|
@@ -56,7 +56,7 @@ const error_1 = require("../utils/error");
|
|
|
56
56
|
*/
|
|
57
57
|
function unmarshalSingleOwnerChunk(data, address) {
|
|
58
58
|
try {
|
|
59
|
-
return (0,
|
|
59
|
+
return (0, core_sdk_1.unmarshalSingleOwnerChunk)(data, address);
|
|
60
60
|
}
|
|
61
61
|
catch (e) {
|
|
62
62
|
throw new error_1.BeeError(e.message);
|
|
@@ -70,10 +70,10 @@ function unmarshalSingleOwnerChunk(data, address) {
|
|
|
70
70
|
* @param signer The signer interface for signing the chunk
|
|
71
71
|
*/
|
|
72
72
|
function makeSingleOwnerChunk(address, span, payload, identifier, signer) {
|
|
73
|
-
identifier = new
|
|
74
|
-
signer = new
|
|
75
|
-
const wrappedChunk = { data:
|
|
76
|
-
return (0,
|
|
73
|
+
identifier = new core_sdk_1.Identifier(identifier);
|
|
74
|
+
signer = new core_sdk_1.PrivateKey(signer);
|
|
75
|
+
const wrappedChunk = { data: core_sdk_1.Bytes.concat(span.toUint8Array(), payload.toUint8Array()), span, payload, address };
|
|
76
|
+
return (0, core_sdk_1.makeSingleOwnerChunk)(wrappedChunk, identifier, signer.toBigInt());
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Helper function to upload a chunk.
|
|
@@ -86,7 +86,7 @@ function makeSingleOwnerChunk(address, span, payload, identifier, signer) {
|
|
|
86
86
|
* @param options Upload options
|
|
87
87
|
*/
|
|
88
88
|
async function uploadSingleOwnerChunk(requestOptions, chunk, stamp, options) {
|
|
89
|
-
const data =
|
|
89
|
+
const data = core_sdk_1.Bytes.concat(chunk.span.toUint8Array(), chunk.payload.toUint8Array());
|
|
90
90
|
return socAPI.upload(requestOptions, chunk.owner, chunk.identifier, chunk.signature, data, stamp, options);
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
@@ -100,15 +100,15 @@ async function uploadSingleOwnerChunk(requestOptions, chunk, stamp, options) {
|
|
|
100
100
|
* @param options
|
|
101
101
|
*/
|
|
102
102
|
async function uploadSingleOwnerChunkData(requestOptions, signer, stamp, identifier, data, options) {
|
|
103
|
-
signer = new
|
|
104
|
-
identifier = new
|
|
105
|
-
const cac = (0,
|
|
103
|
+
signer = new core_sdk_1.PrivateKey(signer);
|
|
104
|
+
identifier = new core_sdk_1.Identifier(identifier);
|
|
105
|
+
const cac = (0, core_sdk_1.makeContentAddressedChunk)(data);
|
|
106
106
|
const soc = cac.toSingleOwnerChunk(identifier, signer);
|
|
107
107
|
return uploadSingleOwnerChunk(requestOptions, soc, stamp, options);
|
|
108
108
|
}
|
|
109
109
|
async function uploadSingleOwnerChunkWithWrappedChunk(requestOptions, signer, stamp, identifier, wrappedChunk, options) {
|
|
110
|
-
signer = new
|
|
111
|
-
identifier = new
|
|
110
|
+
signer = new core_sdk_1.PrivateKey(signer);
|
|
111
|
+
identifier = new core_sdk_1.Identifier(identifier);
|
|
112
112
|
const soc = wrappedChunk.toSingleOwnerChunk(identifier, signer);
|
|
113
113
|
return uploadSingleOwnerChunk(requestOptions, soc, stamp, options);
|
|
114
114
|
}
|
|
@@ -120,9 +120,9 @@ async function uploadSingleOwnerChunkWithWrappedChunk(requestOptions, signer, st
|
|
|
120
120
|
* @param identifier The identifier of the chunk
|
|
121
121
|
*/
|
|
122
122
|
async function downloadSingleOwnerChunk(requestOptions, ownerAddress, identifier) {
|
|
123
|
-
identifier = new
|
|
124
|
-
ownerAddress = new
|
|
125
|
-
const address = (0,
|
|
123
|
+
identifier = new core_sdk_1.Identifier(identifier);
|
|
124
|
+
ownerAddress = new core_sdk_1.EthAddress(ownerAddress);
|
|
125
|
+
const address = (0, core_sdk_1.makeSOCAddress)(identifier, ownerAddress);
|
|
126
126
|
const cac = await chunkAPI.download(requestOptions, address.toHex());
|
|
127
127
|
return unmarshalSingleOwnerChunk(cac, address);
|
|
128
128
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeFeedIdentifier = makeFeedIdentifier;
|
|
4
|
-
const
|
|
4
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
5
5
|
function makeFeedIdentifier(topic, index) {
|
|
6
|
-
index = typeof index === 'number' ?
|
|
7
|
-
return new
|
|
6
|
+
index = typeof index === 'number' ? core_sdk_1.FeedIndex.fromBigInt(BigInt(index)) : index;
|
|
7
|
+
return new core_sdk_1.Identifier((0, core_sdk_1.keccak256)(core_sdk_1.Bytes.concat(topic.toUint8Array(), index.toUint8Array())));
|
|
8
8
|
}
|
package/dist/cjs/feed/index.js
CHANGED
|
@@ -43,7 +43,7 @@ exports.makeFeedReader = makeFeedReader;
|
|
|
43
43
|
exports.makeFeedWriter = makeFeedWriter;
|
|
44
44
|
const cafe_utility_1 = require("cafe-utility");
|
|
45
45
|
const zod_1 = require("zod");
|
|
46
|
-
const
|
|
46
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
47
47
|
const soc_1 = require("../chunk/soc");
|
|
48
48
|
const bytes = __importStar(require("../api/bytes"));
|
|
49
49
|
const chunkAPI = __importStar(require("../api/chunk"));
|
|
@@ -64,18 +64,18 @@ async function findNextIndex(requestOptions, owner, topic) {
|
|
|
64
64
|
}
|
|
65
65
|
catch (e) {
|
|
66
66
|
if (e instanceof error_1.BeeResponseError) {
|
|
67
|
-
return
|
|
67
|
+
return core_sdk_1.FeedIndex.fromBigInt(0n);
|
|
68
68
|
}
|
|
69
69
|
throw e;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
async function updateFeedWithReference(requestOptions, signer, topic, reference, postageBatchId, options) {
|
|
73
|
-
reference = new
|
|
73
|
+
reference = new core_sdk_1.Reference(reference);
|
|
74
74
|
const nextIndex = options?.index ?? (await findNextIndex(requestOptions, signer.publicKey().address(), topic));
|
|
75
75
|
const identifier = (0, identifier_1.makeFeedIdentifier)(topic, nextIndex);
|
|
76
76
|
const at = options?.at ?? Date.now() / 1000.0;
|
|
77
|
-
const timestamp = (0,
|
|
78
|
-
const payloadBytes =
|
|
77
|
+
const timestamp = (0, core_sdk_1.numberToUint64)(BigInt(Math.floor(at)), 'BE');
|
|
78
|
+
const payloadBytes = core_sdk_1.Bytes.concat(timestamp, reference.toUint8Array());
|
|
79
79
|
return (0, soc_1.uploadSingleOwnerChunkData)(requestOptions, signer, postageBatchId, identifier, payloadBytes, options);
|
|
80
80
|
}
|
|
81
81
|
async function updateFeedWithPayload(requestOptions, signer, topic, data, postageBatchId, options) {
|
|
@@ -83,37 +83,37 @@ async function updateFeedWithPayload(requestOptions, signer, topic, data, postag
|
|
|
83
83
|
const identifier = (0, identifier_1.makeFeedIdentifier)(topic, nextIndex);
|
|
84
84
|
if (data.length > 4096) {
|
|
85
85
|
const uploadResult = await bytes.upload(requestOptions, data, postageBatchId, options);
|
|
86
|
-
const rootChunk = (0,
|
|
86
|
+
const rootChunk = (0, core_sdk_1.unmarshalContentAddressedChunk)(await chunkAPI.download(requestOptions, uploadResult.reference));
|
|
87
87
|
return (0, soc_1.uploadSingleOwnerChunkWithWrappedChunk)(requestOptions, signer, postageBatchId, identifier, rootChunk, options);
|
|
88
88
|
}
|
|
89
89
|
const dataString = zod_1.z.string().safeParse(data);
|
|
90
|
-
return (0, soc_1.uploadSingleOwnerChunkData)(requestOptions, signer, postageBatchId, identifier, dataString.success ?
|
|
90
|
+
return (0, soc_1.uploadSingleOwnerChunkData)(requestOptions, signer, postageBatchId, identifier, dataString.success ? core_sdk_1.Bytes.fromUtf8(dataString.data).toUint8Array() : data, options);
|
|
91
91
|
}
|
|
92
92
|
function getFeedUpdateChunkReference(owner, topic, index) {
|
|
93
93
|
const identifier = (0, identifier_1.makeFeedIdentifier)(topic, index);
|
|
94
|
-
return new
|
|
94
|
+
return new core_sdk_1.Reference((0, core_sdk_1.keccak256)(core_sdk_1.Bytes.concat(identifier.toUint8Array(), owner.toUint8Array())));
|
|
95
95
|
}
|
|
96
96
|
async function downloadFeedUpdate(requestOptions, owner, topic, index, hasTimestamp = false) {
|
|
97
|
-
index = typeof index === 'number' ?
|
|
97
|
+
index = typeof index === 'number' ? core_sdk_1.FeedIndex.fromBigInt(BigInt(index)) : index;
|
|
98
98
|
const address = getFeedUpdateChunkReference(owner, topic, index);
|
|
99
99
|
const data = await chunkAPI.download(requestOptions, address.toHex());
|
|
100
100
|
const soc = (0, soc_1.unmarshalSingleOwnerChunk)(data, address);
|
|
101
101
|
let timestamp = cafe_utility_1.Optional.empty();
|
|
102
102
|
if (hasTimestamp) {
|
|
103
|
-
const timestampBytes =
|
|
104
|
-
timestamp = cafe_utility_1.Optional.of(Number((0,
|
|
103
|
+
const timestampBytes = core_sdk_1.Bytes.fromSlice(soc.payload.toUint8Array(), TIMESTAMP_PAYLOAD_OFFSET, TIMESTAMP_PAYLOAD_SIZE);
|
|
104
|
+
timestamp = cafe_utility_1.Optional.of(Number((0, core_sdk_1.uint64ToNumber)(timestampBytes.toUint8Array(), 'BE')));
|
|
105
105
|
}
|
|
106
106
|
return {
|
|
107
107
|
timestamp,
|
|
108
|
-
payload: new
|
|
108
|
+
payload: new core_sdk_1.Bytes(soc.payload.offset(hasTimestamp ? REFERENCE_PAYLOAD_OFFSET : 0)),
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
async function downloadFeedUpdateAsCAC(requestOptions, owner, topic, index) {
|
|
112
|
-
index = typeof index === 'number' ?
|
|
112
|
+
index = typeof index === 'number' ? core_sdk_1.FeedIndex.fromBigInt(BigInt(index)) : index;
|
|
113
113
|
const address = getFeedUpdateChunkReference(owner, topic, index);
|
|
114
114
|
const data = await chunkAPI.download(requestOptions, address);
|
|
115
115
|
const soc = (0, soc_1.unmarshalSingleOwnerChunk)(data, address);
|
|
116
|
-
return (0,
|
|
116
|
+
return (0, core_sdk_1.makeContentAddressedChunk)(soc.payload, soc.span);
|
|
117
117
|
}
|
|
118
118
|
function makeFeedReader(requestOptions, topic, owner) {
|
|
119
119
|
// TODO: remove after enough time has passed in deprecated version
|
|
@@ -122,7 +122,7 @@ function makeFeedReader(requestOptions, topic, owner) {
|
|
|
122
122
|
return (0, feed_1.fetchLatestFeedUpdate)(requestOptions, owner, topic);
|
|
123
123
|
}
|
|
124
124
|
const update = await downloadFeedUpdate(requestOptions, owner, topic, options.index, options.hasTimestamp ?? true);
|
|
125
|
-
const feedIndex = typeof options.index === 'number' ?
|
|
125
|
+
const feedIndex = typeof options.index === 'number' ? core_sdk_1.FeedIndex.fromBigInt(BigInt(options.index)) : options.index;
|
|
126
126
|
return {
|
|
127
127
|
payload: update.payload,
|
|
128
128
|
feedIndex,
|
|
@@ -137,7 +137,7 @@ function makeFeedReader(requestOptions, topic, owner) {
|
|
|
137
137
|
const payload = cac.span.toBigInt() <= 4096n
|
|
138
138
|
? cac.payload
|
|
139
139
|
: await bytes.download(requestOptions, new resource_locator_1.ResourceLocator(cac.address));
|
|
140
|
-
const feedIndex = typeof options.index === 'number' ?
|
|
140
|
+
const feedIndex = typeof options.index === 'number' ? core_sdk_1.FeedIndex.fromBigInt(BigInt(options.index)) : options.index;
|
|
141
141
|
return {
|
|
142
142
|
payload,
|
|
143
143
|
feedIndex,
|
|
@@ -151,7 +151,7 @@ function makeFeedReader(requestOptions, topic, owner) {
|
|
|
151
151
|
}
|
|
152
152
|
const payload = await download({ ...options, index: index });
|
|
153
153
|
return {
|
|
154
|
-
reference: new
|
|
154
|
+
reference: new core_sdk_1.Reference(payload.payload.toUint8Array()),
|
|
155
155
|
feedIndex: payload.feedIndex,
|
|
156
156
|
feedIndexNext: payload.feedIndexNext ?? payload.feedIndex.next(),
|
|
157
157
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.areAllSequentialFeedsUpdateRetrievable = areAllSequentialFeedsUpdateRetrievable;
|
|
4
|
-
const
|
|
4
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
5
5
|
const cafe_utility_1 = require("cafe-utility");
|
|
6
6
|
const index_1 = require("./index");
|
|
7
7
|
/**
|
|
@@ -36,7 +36,7 @@ function getAllSequenceUpdateReferences(owner, topic, index) {
|
|
|
36
36
|
const count = index.toBigInt();
|
|
37
37
|
const updateReferences = [];
|
|
38
38
|
for (let i = 0n; i <= count; i++) {
|
|
39
|
-
updateReferences.push((0, index_1.getFeedUpdateChunkReference)(owner, topic,
|
|
39
|
+
updateReferences.push((0, index_1.getFeedUpdateChunkReference)(owner, topic, core_sdk_1.FeedIndex.fromBigInt(i)));
|
|
40
40
|
}
|
|
41
41
|
return updateReferences;
|
|
42
42
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -39,23 +39,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.Bee = exports.Size = exports.Utils = exports.Duration = exports.SUPPORTED_BEE_VERSION_EXACT = exports.SUPPORTED_BEE_VERSION = exports.MantarayNode = exports.TransactionId = exports.Topic = exports.Stamper = exports.Span = exports.Signature = exports.Reference = exports.PublicKey = exports.PrivateKey = exports.PeerAddress = exports.Identifier = exports.FeedIndex = exports.EthAddress = exports.ChunkSplitter = exports.ChunkBuilder = exports.Bytes = exports.BatchId = void 0;
|
|
40
40
|
const bee_1 = require("./bee");
|
|
41
41
|
Object.defineProperty(exports, "Bee", { enumerable: true, get: function () { return bee_1.Bee; } });
|
|
42
|
-
var
|
|
43
|
-
Object.defineProperty(exports, "BatchId", { enumerable: true, get: function () { return
|
|
44
|
-
Object.defineProperty(exports, "Bytes", { enumerable: true, get: function () { return
|
|
45
|
-
Object.defineProperty(exports, "ChunkBuilder", { enumerable: true, get: function () { return
|
|
46
|
-
Object.defineProperty(exports, "ChunkSplitter", { enumerable: true, get: function () { return
|
|
47
|
-
Object.defineProperty(exports, "EthAddress", { enumerable: true, get: function () { return
|
|
48
|
-
Object.defineProperty(exports, "FeedIndex", { enumerable: true, get: function () { return
|
|
49
|
-
Object.defineProperty(exports, "Identifier", { enumerable: true, get: function () { return
|
|
50
|
-
Object.defineProperty(exports, "PeerAddress", { enumerable: true, get: function () { return
|
|
51
|
-
Object.defineProperty(exports, "PrivateKey", { enumerable: true, get: function () { return
|
|
52
|
-
Object.defineProperty(exports, "PublicKey", { enumerable: true, get: function () { return
|
|
53
|
-
Object.defineProperty(exports, "Reference", { enumerable: true, get: function () { return
|
|
54
|
-
Object.defineProperty(exports, "Signature", { enumerable: true, get: function () { return
|
|
55
|
-
Object.defineProperty(exports, "Span", { enumerable: true, get: function () { return
|
|
56
|
-
Object.defineProperty(exports, "Stamper", { enumerable: true, get: function () { return
|
|
57
|
-
Object.defineProperty(exports, "Topic", { enumerable: true, get: function () { return
|
|
58
|
-
Object.defineProperty(exports, "TransactionId", { enumerable: true, get: function () { return
|
|
42
|
+
var core_sdk_1 = require("@ethersphere/core-sdk");
|
|
43
|
+
Object.defineProperty(exports, "BatchId", { enumerable: true, get: function () { return core_sdk_1.BatchId; } });
|
|
44
|
+
Object.defineProperty(exports, "Bytes", { enumerable: true, get: function () { return core_sdk_1.Bytes; } });
|
|
45
|
+
Object.defineProperty(exports, "ChunkBuilder", { enumerable: true, get: function () { return core_sdk_1.ChunkBuilder; } });
|
|
46
|
+
Object.defineProperty(exports, "ChunkSplitter", { enumerable: true, get: function () { return core_sdk_1.ChunkSplitter; } });
|
|
47
|
+
Object.defineProperty(exports, "EthAddress", { enumerable: true, get: function () { return core_sdk_1.EthAddress; } });
|
|
48
|
+
Object.defineProperty(exports, "FeedIndex", { enumerable: true, get: function () { return core_sdk_1.FeedIndex; } });
|
|
49
|
+
Object.defineProperty(exports, "Identifier", { enumerable: true, get: function () { return core_sdk_1.Identifier; } });
|
|
50
|
+
Object.defineProperty(exports, "PeerAddress", { enumerable: true, get: function () { return core_sdk_1.PeerAddress; } });
|
|
51
|
+
Object.defineProperty(exports, "PrivateKey", { enumerable: true, get: function () { return core_sdk_1.PrivateKey; } });
|
|
52
|
+
Object.defineProperty(exports, "PublicKey", { enumerable: true, get: function () { return core_sdk_1.PublicKey; } });
|
|
53
|
+
Object.defineProperty(exports, "Reference", { enumerable: true, get: function () { return core_sdk_1.Reference; } });
|
|
54
|
+
Object.defineProperty(exports, "Signature", { enumerable: true, get: function () { return core_sdk_1.Signature; } });
|
|
55
|
+
Object.defineProperty(exports, "Span", { enumerable: true, get: function () { return core_sdk_1.Span; } });
|
|
56
|
+
Object.defineProperty(exports, "Stamper", { enumerable: true, get: function () { return core_sdk_1.Stamper; } });
|
|
57
|
+
Object.defineProperty(exports, "Topic", { enumerable: true, get: function () { return core_sdk_1.Topic; } });
|
|
58
|
+
Object.defineProperty(exports, "TransactionId", { enumerable: true, get: function () { return core_sdk_1.TransactionId; } });
|
|
59
59
|
var manifest_1 = require("./manifest/manifest");
|
|
60
60
|
Object.defineProperty(exports, "MantarayNode", { enumerable: true, get: function () { return manifest_1.MantarayNode; } });
|
|
61
61
|
var version_1 = require("./version");
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MantarayNode = void 0;
|
|
4
4
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
|
-
const
|
|
5
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
6
6
|
/**
|
|
7
7
|
* Uploads `node` and every node beneath it, updating each `selfAddress` in
|
|
8
8
|
* place. Only the network/ACT-history side is bee-js specific - the trie
|
|
9
|
-
* structure and marshaling live entirely in
|
|
9
|
+
* structure and marshaling live entirely in core-sdk's MantarayNode.
|
|
10
10
|
*/
|
|
11
11
|
async function saveRecursively(node, bee, postageBatchId, options, requestOptions) {
|
|
12
12
|
for (const fork of node.forks.values()) {
|
|
@@ -43,7 +43,7 @@ async function loadRecursively(node, bee, options, requestOptions) {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
const data = (await bee.data.download(fork.node.selfAddress, downloadOptions, requestOptions)).toUint8Array();
|
|
46
|
-
const loaded =
|
|
46
|
+
const loaded = core_sdk_1.MantarayNode.unmarshalFromData(data, fork.node.selfAddress);
|
|
47
47
|
fork.node.targetAddress = loaded.targetAddress;
|
|
48
48
|
fork.node.forks = loaded.forks;
|
|
49
49
|
fork.node.path = fork.prefix;
|
|
@@ -53,12 +53,12 @@ async function loadRecursively(node, bee, options, requestOptions) {
|
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* bee-js's Bee-client-coupled view of a Mantaray node: the trie structure,
|
|
56
|
-
* marshaling, and byte-level operations all delegate to
|
|
56
|
+
* marshaling, and byte-level operations all delegate to core-sdk's
|
|
57
57
|
* `MantarayNode`; this class only adds what needs a live `Bee` instance
|
|
58
58
|
* (uploading/downloading, ACT history, feed resolution).
|
|
59
59
|
*/
|
|
60
60
|
class MantarayNode {
|
|
61
|
-
constructor(core = new
|
|
61
|
+
constructor(core = new core_sdk_1.MantarayNode()) {
|
|
62
62
|
this.core = core;
|
|
63
63
|
}
|
|
64
64
|
get obfuscationKey() {
|
|
@@ -141,7 +141,7 @@ class MantarayNode {
|
|
|
141
141
|
* Do not forget calling `loadRecursively` on the returned node to load the entire tree.
|
|
142
142
|
*/
|
|
143
143
|
static async unmarshal(bee, reference, options, requestOptions) {
|
|
144
|
-
reference = new
|
|
144
|
+
reference = new core_sdk_1.Reference(reference);
|
|
145
145
|
const data = (await bee.data.download(reference, options, requestOptions)).toUint8Array();
|
|
146
146
|
return this.unmarshalFromData(data, reference.toUint8Array());
|
|
147
147
|
}
|
|
@@ -151,13 +151,13 @@ class MantarayNode {
|
|
|
151
151
|
* Do not forget calling `loadRecursively` on the returned node to load the entire tree.
|
|
152
152
|
*/
|
|
153
153
|
static unmarshalFromData(data, selfAddress) {
|
|
154
|
-
return new MantarayNode(
|
|
154
|
+
return new MantarayNode(core_sdk_1.MantarayNode.unmarshalFromData(data, selfAddress));
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* Adds a fork to the node.
|
|
158
158
|
*/
|
|
159
159
|
addFork(path, reference, metadata) {
|
|
160
|
-
this.core.addFork(path, reference instanceof
|
|
160
|
+
this.core.addFork(path, reference instanceof core_sdk_1.Bytes ? reference.toUint8Array() : reference, metadata);
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
163
|
* Removes a fork from the node.
|
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.Balance = void 0;
|
|
37
|
-
const
|
|
37
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
38
38
|
const balanceApi = __importStar(require("../api/balance"));
|
|
39
39
|
const consumedApi = __importStar(require("../api/consumed"));
|
|
40
40
|
/**
|
|
@@ -61,7 +61,7 @@ class Balance {
|
|
|
61
61
|
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
62
62
|
*/
|
|
63
63
|
async getPeer(address, requestOptions) {
|
|
64
|
-
const peer = new
|
|
64
|
+
const peer = new core_sdk_1.PeerAddress(address);
|
|
65
65
|
return balanceApi.getPeerBalance(this.context.getRequestOptionsForCall(requestOptions), peer);
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
@@ -79,7 +79,7 @@ class Balance {
|
|
|
79
79
|
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
80
80
|
*/
|
|
81
81
|
async getAllPastDueConsumptionForPeer(address, requestOptions) {
|
|
82
|
-
const peer = new
|
|
82
|
+
const peer = new core_sdk_1.PeerAddress(address);
|
|
83
83
|
return consumedApi.getPastDueConsumptionPeerBalance(this.context.getRequestOptionsForCall(requestOptions), peer);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.Cheque = void 0;
|
|
37
|
-
const
|
|
37
|
+
const core_sdk_1 = require("@ethersphere/core-sdk");
|
|
38
38
|
const schema_1 = require("../utils/schema");
|
|
39
39
|
const api = __importStar(require("../api/chequebook"));
|
|
40
40
|
/**
|
|
@@ -61,7 +61,7 @@ class Cheque {
|
|
|
61
61
|
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
62
62
|
*/
|
|
63
63
|
async getAllLatestForPeer(address, requestOptions) {
|
|
64
|
-
const peer = new
|
|
64
|
+
const peer = new core_sdk_1.PeerAddress(address);
|
|
65
65
|
return api.getLastChequesForPeer(this.context.getRequestOptionsForCall(requestOptions), peer);
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
@@ -71,7 +71,7 @@ class Cheque {
|
|
|
71
71
|
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
72
72
|
*/
|
|
73
73
|
async getLastCashoutAction(address, requestOptions) {
|
|
74
|
-
const peer = new
|
|
74
|
+
const peer = new core_sdk_1.PeerAddress(address);
|
|
75
75
|
return api.getLastCashoutAction(this.context.getRequestOptionsForCall(requestOptions), peer);
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
@@ -82,7 +82,7 @@ class Cheque {
|
|
|
82
82
|
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
83
83
|
*/
|
|
84
84
|
async cashoutLast(address, options, requestOptions) {
|
|
85
|
-
const peer = new
|
|
85
|
+
const peer = new core_sdk_1.PeerAddress(address);
|
|
86
86
|
if (options) {
|
|
87
87
|
options = schema_1.TransactionOptionsSchema.parse(options);
|
|
88
88
|
}
|