@ethersphere/bee-js 6.2.0 → 6.4.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/dist/cjs/bee-debug.js +7 -0
- package/dist/cjs/modules/debug/status.js +11 -1
- package/dist/cjs/utils/expose.js +20 -16
- package/dist/cjs/utils/stamps.js +45 -7
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-debug.js +7 -0
- package/dist/mjs/modules/debug/status.js +9 -0
- package/dist/mjs/utils/expose.js +5 -5
- package/dist/mjs/utils/stamps.js +40 -10
- package/dist/types/bee-debug.d.ts +5 -1
- package/dist/types/modules/debug/status.d.ts +2 -1
- package/dist/types/types/debug.d.ts +12 -0
- package/dist/types/types/index.d.ts +17 -5
- package/dist/types/utils/expose.d.ts +5 -5
- package/dist/types/utils/stamps.d.ts +31 -7
- package/package.json +1 -1
package/dist/cjs/bee-debug.js
CHANGED
|
@@ -253,6 +253,13 @@ class BeeDebug {
|
|
|
253
253
|
(0, type_1.assertRequestOptions)(options);
|
|
254
254
|
return settlements.getAllSettlements(this.getRequestOptionsForCall(options));
|
|
255
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Get status of node
|
|
258
|
+
*/
|
|
259
|
+
async getStatus(options) {
|
|
260
|
+
(0, type_1.assertRequestOptions)(options);
|
|
261
|
+
return status.getDebugStatus(this.getRequestOptionsForCall(options));
|
|
262
|
+
}
|
|
256
263
|
/**
|
|
257
264
|
* Get health of node
|
|
258
265
|
*/
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getVersions = exports.isSupportedApiVersion = exports.isSupportedDebugApiVersion = exports.isSupportedMainApiVersion = exports.isSupportedExactVersion = exports.isSupportedVersion = exports.getNodeInfo = exports.getReadiness = exports.getHealth = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_DEBUG_API_VERSION = exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
|
|
6
|
+
exports.getVersions = exports.isSupportedApiVersion = exports.isSupportedDebugApiVersion = exports.isSupportedMainApiVersion = exports.isSupportedExactVersion = exports.isSupportedVersion = exports.getNodeInfo = exports.getReadiness = exports.getHealth = exports.getDebugStatus = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_DEBUG_API_VERSION = exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
|
|
7
7
|
const major_js_1 = __importDefault(require("semver/functions/major.js"));
|
|
8
8
|
const http_1 = require("../../utils/http");
|
|
9
9
|
// Following lines bellow are automatically updated with GitHub Action when Bee version is updated
|
|
@@ -13,8 +13,18 @@ exports.SUPPORTED_API_VERSION = '4.0.0';
|
|
|
13
13
|
exports.SUPPORTED_DEBUG_API_VERSION = '4.0.0';
|
|
14
14
|
exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.substring(0, exports.SUPPORTED_BEE_VERSION_EXACT.indexOf('-'));
|
|
15
15
|
const NODE_INFO_URL = 'node';
|
|
16
|
+
const STATUS_URL = 'status';
|
|
16
17
|
const HEALTH_URL = 'health';
|
|
17
18
|
const READINESS_URL = 'readiness';
|
|
19
|
+
async function getDebugStatus(requestOptions) {
|
|
20
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
21
|
+
method: 'get',
|
|
22
|
+
url: STATUS_URL,
|
|
23
|
+
responseType: 'json',
|
|
24
|
+
});
|
|
25
|
+
return response.data;
|
|
26
|
+
}
|
|
27
|
+
exports.getDebugStatus = getDebugStatus;
|
|
18
28
|
/**
|
|
19
29
|
* Get health of node
|
|
20
30
|
*
|
package/dist/cjs/utils/expose.js
CHANGED
|
@@ -1,44 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStampUsage = exports.
|
|
3
|
+
exports.getStampUsage = exports.getStampTtlSeconds = exports.getStampMaximumCapacityBytes = exports.getStampCostInPlur = exports.getStampCostInBzz = exports.makeMaxTarget = exports.keccak256Hash = exports.readableWebToNode = exports.readableNodeToWeb = exports.normalizeToReadableStream = exports.isReadableStream = exports.isReadable = exports.isNodeReadable = exports.toLittleEndian = exports.makeHexEthAddress = exports.makeEthereumWalletSigner = exports.makeEthAddress = exports.isHexEthAddress = exports.fromLittleEndian = exports.ethToSwarmAddress = exports.makeHexString = exports.isHexString = exports.intToHex = exports.hexToBytes = exports.bytesToHex = exports.assertPrefixedHexString = exports.assertHexString = exports.isFlexBytes = exports.isBytes = exports.flexBytesAtOffset = exports.bytesEqual = exports.bytesAtOffset = exports.assertFlexBytes = exports.assertBytes = exports.getFolderSize = exports.getCollectionSize = void 0;
|
|
4
4
|
var collection_1 = require("./collection");
|
|
5
5
|
Object.defineProperty(exports, "getCollectionSize", { enumerable: true, get: function () { return collection_1.getCollectionSize; } });
|
|
6
6
|
var collection_node_1 = require("./collection.node");
|
|
7
7
|
Object.defineProperty(exports, "getFolderSize", { enumerable: true, get: function () { return collection_node_1.getFolderSize; } });
|
|
8
8
|
var bytes_1 = require("./bytes");
|
|
9
|
-
Object.defineProperty(exports, "isBytes", { enumerable: true, get: function () { return bytes_1.isBytes; } });
|
|
10
9
|
Object.defineProperty(exports, "assertBytes", { enumerable: true, get: function () { return bytes_1.assertBytes; } });
|
|
11
|
-
Object.defineProperty(exports, "isFlexBytes", { enumerable: true, get: function () { return bytes_1.isFlexBytes; } });
|
|
12
10
|
Object.defineProperty(exports, "assertFlexBytes", { enumerable: true, get: function () { return bytes_1.assertFlexBytes; } });
|
|
13
11
|
Object.defineProperty(exports, "bytesAtOffset", { enumerable: true, get: function () { return bytes_1.bytesAtOffset; } });
|
|
14
|
-
Object.defineProperty(exports, "flexBytesAtOffset", { enumerable: true, get: function () { return bytes_1.flexBytesAtOffset; } });
|
|
15
12
|
Object.defineProperty(exports, "bytesEqual", { enumerable: true, get: function () { return bytes_1.bytesEqual; } });
|
|
13
|
+
Object.defineProperty(exports, "flexBytesAtOffset", { enumerable: true, get: function () { return bytes_1.flexBytesAtOffset; } });
|
|
14
|
+
Object.defineProperty(exports, "isBytes", { enumerable: true, get: function () { return bytes_1.isBytes; } });
|
|
15
|
+
Object.defineProperty(exports, "isFlexBytes", { enumerable: true, get: function () { return bytes_1.isFlexBytes; } });
|
|
16
16
|
var hex_1 = require("./hex");
|
|
17
|
-
Object.defineProperty(exports, "
|
|
18
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "assertHexString", { enumerable: true, get: function () { return hex_1.assertHexString; } });
|
|
18
|
+
Object.defineProperty(exports, "assertPrefixedHexString", { enumerable: true, get: function () { return hex_1.assertPrefixedHexString; } });
|
|
19
19
|
Object.defineProperty(exports, "bytesToHex", { enumerable: true, get: function () { return hex_1.bytesToHex; } });
|
|
20
|
+
Object.defineProperty(exports, "hexToBytes", { enumerable: true, get: function () { return hex_1.hexToBytes; } });
|
|
20
21
|
Object.defineProperty(exports, "intToHex", { enumerable: true, get: function () { return hex_1.intToHex; } });
|
|
21
22
|
Object.defineProperty(exports, "isHexString", { enumerable: true, get: function () { return hex_1.isHexString; } });
|
|
22
|
-
Object.defineProperty(exports, "
|
|
23
|
-
Object.defineProperty(exports, "assertPrefixedHexString", { enumerable: true, get: function () { return hex_1.assertPrefixedHexString; } });
|
|
23
|
+
Object.defineProperty(exports, "makeHexString", { enumerable: true, get: function () { return hex_1.makeHexString; } });
|
|
24
24
|
var eth_1 = require("./eth");
|
|
25
|
-
Object.defineProperty(exports, "makeEthAddress", { enumerable: true, get: function () { return eth_1.makeEthAddress; } });
|
|
26
|
-
Object.defineProperty(exports, "makeHexEthAddress", { enumerable: true, get: function () { return eth_1.makeHexEthAddress; } });
|
|
27
|
-
Object.defineProperty(exports, "isHexEthAddress", { enumerable: true, get: function () { return eth_1.isHexEthAddress; } });
|
|
28
25
|
Object.defineProperty(exports, "ethToSwarmAddress", { enumerable: true, get: function () { return eth_1.ethToSwarmAddress; } });
|
|
29
|
-
Object.defineProperty(exports, "toLittleEndian", { enumerable: true, get: function () { return eth_1.toLittleEndian; } });
|
|
30
26
|
Object.defineProperty(exports, "fromLittleEndian", { enumerable: true, get: function () { return eth_1.fromLittleEndian; } });
|
|
27
|
+
Object.defineProperty(exports, "isHexEthAddress", { enumerable: true, get: function () { return eth_1.isHexEthAddress; } });
|
|
28
|
+
Object.defineProperty(exports, "makeEthAddress", { enumerable: true, get: function () { return eth_1.makeEthAddress; } });
|
|
31
29
|
Object.defineProperty(exports, "makeEthereumWalletSigner", { enumerable: true, get: function () { return eth_1.makeEthereumWalletSigner; } });
|
|
30
|
+
Object.defineProperty(exports, "makeHexEthAddress", { enumerable: true, get: function () { return eth_1.makeHexEthAddress; } });
|
|
31
|
+
Object.defineProperty(exports, "toLittleEndian", { enumerable: true, get: function () { return eth_1.toLittleEndian; } });
|
|
32
32
|
var stream_1 = require("./stream");
|
|
33
|
-
Object.defineProperty(exports, "readableWebToNode", { enumerable: true, get: function () { return stream_1.readableWebToNode; } });
|
|
34
|
-
Object.defineProperty(exports, "readableNodeToWeb", { enumerable: true, get: function () { return stream_1.readableNodeToWeb; } });
|
|
35
|
-
Object.defineProperty(exports, "isReadableStream", { enumerable: true, get: function () { return stream_1.isReadableStream; } });
|
|
36
33
|
Object.defineProperty(exports, "isNodeReadable", { enumerable: true, get: function () { return stream_1.isNodeReadable; } });
|
|
37
|
-
Object.defineProperty(exports, "normalizeToReadableStream", { enumerable: true, get: function () { return stream_1.normalizeToReadableStream; } });
|
|
38
34
|
Object.defineProperty(exports, "isReadable", { enumerable: true, get: function () { return stream_1.isReadable; } });
|
|
35
|
+
Object.defineProperty(exports, "isReadableStream", { enumerable: true, get: function () { return stream_1.isReadableStream; } });
|
|
36
|
+
Object.defineProperty(exports, "normalizeToReadableStream", { enumerable: true, get: function () { return stream_1.normalizeToReadableStream; } });
|
|
37
|
+
Object.defineProperty(exports, "readableNodeToWeb", { enumerable: true, get: function () { return stream_1.readableNodeToWeb; } });
|
|
38
|
+
Object.defineProperty(exports, "readableWebToNode", { enumerable: true, get: function () { return stream_1.readableWebToNode; } });
|
|
39
39
|
var hash_1 = require("./hash");
|
|
40
40
|
Object.defineProperty(exports, "keccak256Hash", { enumerable: true, get: function () { return hash_1.keccak256Hash; } });
|
|
41
41
|
var pss_1 = require("./pss");
|
|
42
42
|
Object.defineProperty(exports, "makeMaxTarget", { enumerable: true, get: function () { return pss_1.makeMaxTarget; } });
|
|
43
43
|
var stamps_1 = require("./stamps");
|
|
44
|
+
Object.defineProperty(exports, "getStampCostInBzz", { enumerable: true, get: function () { return stamps_1.getStampCostInBzz; } });
|
|
45
|
+
Object.defineProperty(exports, "getStampCostInPlur", { enumerable: true, get: function () { return stamps_1.getStampCostInPlur; } });
|
|
46
|
+
Object.defineProperty(exports, "getStampMaximumCapacityBytes", { enumerable: true, get: function () { return stamps_1.getStampMaximumCapacityBytes; } });
|
|
47
|
+
Object.defineProperty(exports, "getStampTtlSeconds", { enumerable: true, get: function () { return stamps_1.getStampTtlSeconds; } });
|
|
44
48
|
Object.defineProperty(exports, "getStampUsage", { enumerable: true, get: function () { return stamps_1.getStampUsage; } });
|
package/dist/cjs/utils/stamps.js
CHANGED
|
@@ -1,17 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStampUsage = void 0;
|
|
3
|
+
exports.getStampTtlSeconds = exports.getStampCostInBzz = exports.getStampCostInPlur = exports.getStampMaximumCapacityBytes = exports.getStampUsage = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Utility function that calculates usage of postage batch based on its utilization, depth and bucket depth.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* is small.
|
|
7
|
+
* For smaller depths (up to 20), this may provide less accurate results.
|
|
9
8
|
*
|
|
10
|
-
* @
|
|
11
|
-
* @param depth
|
|
12
|
-
* @param bucketDepth
|
|
9
|
+
* @returns {number} A number between 0 and 1 representing the usage of the postage batch.
|
|
13
10
|
*/
|
|
14
|
-
function getStampUsage(
|
|
11
|
+
function getStampUsage(utilization, depth, bucketDepth) {
|
|
15
12
|
return utilization / Math.pow(2, depth - bucketDepth);
|
|
16
13
|
}
|
|
17
14
|
exports.getStampUsage = getStampUsage;
|
|
15
|
+
/**
|
|
16
|
+
* Utility function that calculates the theoritical maximum capacity of a postage batch based on its depth.
|
|
17
|
+
*
|
|
18
|
+
* For smaller depths (up to 20), this may provide less accurate results.
|
|
19
|
+
*
|
|
20
|
+
* @returns {number} The maximum capacity of the postage batch in bytes.
|
|
21
|
+
*/
|
|
22
|
+
function getStampMaximumCapacityBytes(depth) {
|
|
23
|
+
return 2 ** depth * 4096;
|
|
24
|
+
}
|
|
25
|
+
exports.getStampMaximumCapacityBytes = getStampMaximumCapacityBytes;
|
|
26
|
+
/**
|
|
27
|
+
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
28
|
+
*
|
|
29
|
+
* @returns {number} The cost of the postage batch in PLUR (10000000000000000 [1e16] PLUR = 1 BZZ)
|
|
30
|
+
*/
|
|
31
|
+
function getStampCostInPlur(depth, amount) {
|
|
32
|
+
return 2 ** depth * amount;
|
|
33
|
+
}
|
|
34
|
+
exports.getStampCostInPlur = getStampCostInPlur;
|
|
35
|
+
/**
|
|
36
|
+
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
37
|
+
*
|
|
38
|
+
* @returns {number} The cost of the postage batch in BZZ (1 BZZ = 10000000000000000 [1e16] PLUR)
|
|
39
|
+
*/
|
|
40
|
+
function getStampCostInBzz(depth, amount) {
|
|
41
|
+
const BZZ_UNIT = 10 ** 16;
|
|
42
|
+
return getStampCostInPlur(depth, amount) / BZZ_UNIT;
|
|
43
|
+
}
|
|
44
|
+
exports.getStampCostInBzz = getStampCostInBzz;
|
|
45
|
+
/**
|
|
46
|
+
* Utility function that calculates the TTL of a postage batch based on its amount, price per block and block time.
|
|
47
|
+
*
|
|
48
|
+
* For more accurate results, get the price per block and block time from the Bee node or the blockchain.
|
|
49
|
+
*
|
|
50
|
+
* @returns {number} The TTL of the postage batch in seconds.
|
|
51
|
+
*/
|
|
52
|
+
function getStampTtlSeconds(amount, pricePerBlock = 24000, blockTime = 5) {
|
|
53
|
+
return (amount * blockTime) / pricePerBlock;
|
|
54
|
+
}
|
|
55
|
+
exports.getStampTtlSeconds = getStampTtlSeconds;
|