@ethersphere/bee-js 4.1.1 → 5.1.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 +8 -7
- package/dist/cjs/bee-debug.js +42 -2
- package/dist/cjs/bee.js +9 -3
- package/dist/cjs/chunk/soc.js +5 -1
- package/dist/cjs/feed/index.js +5 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/modules/debug/connectivity.js +2 -2
- package/dist/cjs/modules/debug/stake.js +55 -0
- package/dist/cjs/modules/debug/stamps.js +1 -1
- package/dist/cjs/modules/debug/status.js +26 -4
- package/dist/cjs/modules/pinning.js +1 -5
- package/dist/cjs/types/index.js +5 -1
- package/dist/cjs/utils/type.js +16 -7
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-debug.js +44 -2
- package/dist/mjs/bee.js +4 -2
- package/dist/mjs/modules/debug/connectivity.js +2 -2
- package/dist/mjs/modules/debug/stake.js +78 -0
- package/dist/mjs/modules/debug/stamps.js +1 -1
- package/dist/mjs/modules/debug/status.js +24 -3
- package/dist/mjs/modules/pinning.js +1 -7
- package/dist/mjs/utils/type.js +15 -6
- package/dist/types/bee-debug.d.ts +20 -1
- package/dist/types/bee.d.ts +2 -3
- package/dist/types/modules/debug/stake.d.ts +15 -0
- package/dist/types/modules/debug/status.d.ts +9 -3
- package/dist/types/modules/pinning.d.ts +1 -1
- package/dist/types/types/debug.d.ts +4 -8
- package/dist/types/types/index.d.ts +25 -8
- package/dist/types/utils/type.d.ts +7 -2
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
[](https://github.com/RichardLitt/standard-readme)
|
|
7
7
|
[](https://github.com/feross/standard)
|
|
8
8
|

|
|
9
|
-

|
|
10
10
|

|
|
11
11
|
|
|
12
12
|
> Client library for connecting to Bee decentralised storage
|
|
13
13
|
|
|
14
14
|
**Warning: This project is in beta state. There might (and most probably will) be changes in the future to its API and working. Also, no guarantees can be made about its stability, efficiency, and security at this stage.**
|
|
15
15
|
|
|
16
|
-
This project is intended to be used with **Bee version 1.
|
|
16
|
+
This project is intended to be used with **Bee version <!-- SUPPORTED_BEE_START -->1.7.0<!-- SUPPORTED_BEE_END -->**. Using it with older or newer Bee versions is not recommended and may not work. Stay up to date by joining the [official Discord](https://discord.gg/GU22h2utj6) and by keeping an eye on the [releases tab](https://github.com/ethersphere/bee-js/releases).
|
|
17
17
|
|
|
18
18
|
## Table of Contents
|
|
19
19
|
|
|
@@ -71,14 +71,15 @@ Loading this module through a script tag will make the `BeeJs` object available
|
|
|
71
71
|
## Usage
|
|
72
72
|
|
|
73
73
|
```js
|
|
74
|
-
import { Bee } from
|
|
74
|
+
import { Bee, BeeDebug } from '@ethersphere/bee-js'
|
|
75
75
|
|
|
76
|
-
bee = new Bee(
|
|
76
|
+
const bee = new Bee('http://localhost:1633')
|
|
77
|
+
const beeDebug = new BeeDebug('http://localhost:1635')
|
|
77
78
|
|
|
78
79
|
// Be aware, this creates on-chain transactions that spend Eth and BZZ!
|
|
79
|
-
const batchId = await
|
|
80
|
-
const
|
|
81
|
-
const data = await bee.downloadData(
|
|
80
|
+
const batchId = await beeDebug.createPostageBatch('2000', 20)
|
|
81
|
+
const { reference } = await bee.uploadData(batchId, 'Bee is awesome!')
|
|
82
|
+
const data = await bee.downloadData(reference)
|
|
82
83
|
|
|
83
84
|
console.log(data.text()) // prints 'Bee is awesome!'
|
|
84
85
|
```
|
package/dist/cjs/bee-debug.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -36,6 +40,7 @@ const settlements = __importStar(require("./modules/debug/settlements"));
|
|
|
36
40
|
const status = __importStar(require("./modules/debug/status"));
|
|
37
41
|
const transactions = __importStar(require("./modules/debug/transactions"));
|
|
38
42
|
const states = __importStar(require("./modules/debug/states"));
|
|
43
|
+
const stake = __importStar(require("./modules/debug/stake"));
|
|
39
44
|
const error_1 = require("./utils/error");
|
|
40
45
|
const url_1 = require("./utils/url");
|
|
41
46
|
const type_1 = require("./utils/type");
|
|
@@ -323,6 +328,15 @@ class BeeDebug {
|
|
|
323
328
|
return status.getHealth(this.getKy(options));
|
|
324
329
|
});
|
|
325
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Get readiness of node
|
|
333
|
+
*/
|
|
334
|
+
getReadiness(options) {
|
|
335
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
336
|
+
(0, type_1.assertRequestOptions)(options);
|
|
337
|
+
return status.getReadiness(this.getKy(options));
|
|
338
|
+
});
|
|
339
|
+
}
|
|
326
340
|
/**
|
|
327
341
|
* Get mode information of node
|
|
328
342
|
*/
|
|
@@ -472,7 +486,7 @@ class BeeDebug {
|
|
|
472
486
|
throw new error_1.BeeArgumentError(`Depth has to be at most ${types_1.STAMPS_DEPTH_MAX}`, depth);
|
|
473
487
|
}
|
|
474
488
|
const stamp = yield stamps.createPostageBatch(this.getKy(options), amount, depth, options);
|
|
475
|
-
if (options === null || options === void 0 ? void 0 : options.waitForUsable) {
|
|
489
|
+
if ((options === null || options === void 0 ? void 0 : options.waitForUsable) !== false) {
|
|
476
490
|
yield this.waitForUsablePostageStamp(stamp, options === null || options === void 0 ? void 0 : options.waitForUsableTimeout);
|
|
477
491
|
}
|
|
478
492
|
return stamp;
|
|
@@ -615,6 +629,32 @@ class BeeDebug {
|
|
|
615
629
|
return transactions.cancelTransaction(this.getKy(options), transactionHash, gasPrice);
|
|
616
630
|
});
|
|
617
631
|
}
|
|
632
|
+
/**
|
|
633
|
+
* Gets the staked amount of BZZ (in PLUR unit) as number string.
|
|
634
|
+
*
|
|
635
|
+
* @param options
|
|
636
|
+
*/
|
|
637
|
+
getStake(options) {
|
|
638
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
639
|
+
(0, type_1.assertRequestOptions)(options);
|
|
640
|
+
return stake.getStake(this.getKy(options));
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Deposits given amount of BZZ token (in PLUR unit).
|
|
645
|
+
*
|
|
646
|
+
* Be aware that staked BZZ tokens can **not** be withdrawn.
|
|
647
|
+
*
|
|
648
|
+
* @param amount Amount of BZZ token (in PLUR unit) to be staked. Minimum is 100_000_000_000_000_000 PLUR (10 BZZ).
|
|
649
|
+
* @param options
|
|
650
|
+
*/
|
|
651
|
+
depositStake(amount, options) {
|
|
652
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
653
|
+
(0, type_1.assertRequestOptions)(options);
|
|
654
|
+
(0, type_1.assertTransactionOptions)(options);
|
|
655
|
+
yield stake.stake(this.getKy(options), amount, options);
|
|
656
|
+
});
|
|
657
|
+
}
|
|
618
658
|
waitForUsablePostageStamp(id, timeout = 120000) {
|
|
619
659
|
return __awaiter(this, void 0, void 0, function* () {
|
|
620
660
|
const TIME_STEP = 1500;
|
package/dist/cjs/bee.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -761,7 +765,6 @@ class Bee {
|
|
|
761
765
|
*
|
|
762
766
|
* @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
|
|
763
767
|
* @see [Bee API reference - `POST /feeds`](https://docs.ethswarm.org/api/#tag/Feed/paths/~1feeds~1{owner}~1{topic}/post)
|
|
764
|
-
* TODO: Once breaking add support for Feed CID
|
|
765
768
|
*/
|
|
766
769
|
createFeedManifest(postageBatchId, type, topic, owner, options) {
|
|
767
770
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -770,7 +773,10 @@ class Bee {
|
|
|
770
773
|
(0, type_2.assertBatchId)(postageBatchId);
|
|
771
774
|
const canonicalTopic = (0, topic_1.makeTopic)(topic);
|
|
772
775
|
const canonicalOwner = (0, eth_1.makeHexEthAddress)(owner);
|
|
773
|
-
|
|
776
|
+
const reference = yield (0, feed_2.createFeedManifest)(this.getKy(options), canonicalOwner, canonicalTopic, postageBatchId, {
|
|
777
|
+
type,
|
|
778
|
+
});
|
|
779
|
+
return (0, type_2.addCidConversionFunction)({ reference }, swarm_cid_1.ReferenceType.FEED);
|
|
774
780
|
});
|
|
775
781
|
}
|
|
776
782
|
/**
|
package/dist/cjs/chunk/soc.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/cjs/feed/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -27,7 +27,7 @@ function getPeers(ky) {
|
|
|
27
27
|
path: 'peers',
|
|
28
28
|
responseType: 'json',
|
|
29
29
|
});
|
|
30
|
-
return response.data.peers
|
|
30
|
+
return response.data.peers;
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
exports.getPeers = getPeers;
|
|
@@ -37,7 +37,7 @@ function getBlocklist(ky) {
|
|
|
37
37
|
path: 'blocklist',
|
|
38
38
|
responseType: 'json',
|
|
39
39
|
});
|
|
40
|
-
return response.data.peers
|
|
40
|
+
return response.data.peers;
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
exports.getBlocklist = getBlocklist;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.stake = exports.getStake = void 0;
|
|
13
|
+
const http_1 = require("../../utils/http");
|
|
14
|
+
const STAKE_ENDPOINT = 'stake';
|
|
15
|
+
/**
|
|
16
|
+
* Gets the staked amount
|
|
17
|
+
*
|
|
18
|
+
* @param ky Ky instance for given Bee class instance
|
|
19
|
+
*/
|
|
20
|
+
function getStake(ky) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const response = yield (0, http_1.http)(ky, {
|
|
23
|
+
method: 'get',
|
|
24
|
+
responseType: 'json',
|
|
25
|
+
path: `${STAKE_ENDPOINT}`,
|
|
26
|
+
});
|
|
27
|
+
return response.data.stakedAmount.toString();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.getStake = getStake;
|
|
31
|
+
/**
|
|
32
|
+
* Stake given amount of tokens.
|
|
33
|
+
*
|
|
34
|
+
* @param ky
|
|
35
|
+
* @param amount
|
|
36
|
+
* @param options
|
|
37
|
+
*/
|
|
38
|
+
function stake(ky, amount, options) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const headers = {};
|
|
41
|
+
if (options === null || options === void 0 ? void 0 : options.gasPrice) {
|
|
42
|
+
headers['gas-price'] = options.gasPrice.toString();
|
|
43
|
+
}
|
|
44
|
+
if (options === null || options === void 0 ? void 0 : options.gasLimit) {
|
|
45
|
+
headers['gas-limit'] = options.gasLimit.toString();
|
|
46
|
+
}
|
|
47
|
+
yield (0, http_1.http)(ky, {
|
|
48
|
+
method: 'post',
|
|
49
|
+
responseType: 'json',
|
|
50
|
+
path: `${STAKE_ENDPOINT}/deposit/${amount}`,
|
|
51
|
+
headers,
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports.stake = stake;
|
|
@@ -12,17 +12,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getVersions = exports.isSupportedApiVersion = exports.isSupportedDebugApiVersion = exports.isSupportedMainApiVersion = exports.isSupportedExactVersion = exports.isSupportedVersion = exports.getNodeInfo = exports.getHealth = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_DEBUG_API_VERSION = exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
|
|
15
|
+
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;
|
|
16
16
|
const http_1 = require("../../utils/http");
|
|
17
17
|
const major_js_1 = __importDefault(require("semver/functions/major.js"));
|
|
18
18
|
// Following lines bellow are automatically updated with GitHub Action when Bee version is updated
|
|
19
19
|
// so if you are changing anything about them change the `update_bee` action accordingly!
|
|
20
|
-
exports.SUPPORTED_BEE_VERSION_EXACT = '1.
|
|
21
|
-
exports.SUPPORTED_API_VERSION = '3.0
|
|
22
|
-
exports.SUPPORTED_DEBUG_API_VERSION = '2.0
|
|
20
|
+
exports.SUPPORTED_BEE_VERSION_EXACT = '1.9.0-13a47043';
|
|
21
|
+
exports.SUPPORTED_API_VERSION = '3.2.0';
|
|
22
|
+
exports.SUPPORTED_DEBUG_API_VERSION = '3.2.0';
|
|
23
23
|
exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.substring(0, exports.SUPPORTED_BEE_VERSION_EXACT.indexOf('-'));
|
|
24
24
|
const NODE_INFO_URL = 'node';
|
|
25
25
|
const HEALTH_URL = 'health';
|
|
26
|
+
const READINESS_URL = 'readiness';
|
|
26
27
|
/**
|
|
27
28
|
* Get health of node
|
|
28
29
|
*
|
|
@@ -39,6 +40,26 @@ function getHealth(ky) {
|
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
exports.getHealth = getHealth;
|
|
43
|
+
/**
|
|
44
|
+
* Get readiness of node
|
|
45
|
+
*
|
|
46
|
+
* @param ky Ky debug instance
|
|
47
|
+
*/
|
|
48
|
+
function getReadiness(ky) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
try {
|
|
51
|
+
const response = yield (0, http_1.http)(ky, {
|
|
52
|
+
method: 'get',
|
|
53
|
+
path: READINESS_URL,
|
|
54
|
+
});
|
|
55
|
+
return response.status === 200;
|
|
56
|
+
}
|
|
57
|
+
catch (_a) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
exports.getReadiness = getReadiness;
|
|
42
63
|
/**
|
|
43
64
|
* Get information about Bee node
|
|
44
65
|
*
|
|
@@ -63,6 +84,7 @@ exports.getNodeInfo = getNodeInfo;
|
|
|
63
84
|
* @returns true if the Bee node version is supported
|
|
64
85
|
* @deprecated Use `isSupportedExactVersion` instead
|
|
65
86
|
*/
|
|
87
|
+
// TODO: Remove on break
|
|
66
88
|
function isSupportedVersion(ky) {
|
|
67
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
90
|
return isSupportedExactVersion(ky);
|
|
@@ -74,11 +74,7 @@ function getAllPins(ky) {
|
|
|
74
74
|
responseType: 'json',
|
|
75
75
|
path: `${PINNING_ENDPOINT}`,
|
|
76
76
|
});
|
|
77
|
-
|
|
78
|
-
if (result === null) {
|
|
79
|
-
return [];
|
|
80
|
-
}
|
|
81
|
-
return result;
|
|
77
|
+
return response.data.references;
|
|
82
78
|
});
|
|
83
79
|
}
|
|
84
80
|
exports.getAllPins = getAllPins;
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/cjs/utils/type.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertTransactionHash = exports.makeTagUid = exports.assertAllTagsOptions = exports.assertFileData = exports.assertData = exports.assertCashoutOptions = exports.assertPostageBatchOptions = exports.assertPublicKey = exports.assertPssMessageHandler = exports.assertAddressPrefix = exports.assertTag = exports.isTag = exports.assertCollectionUploadOptions = exports.assertFileUploadOptions = exports.assertUploadOptions = exports.assertRequestOptions = exports.assertBatchId = exports.assertAddress = exports.addCidConversionFunction = exports.makeReferenceOrEns = exports.assertReferenceOrEns = exports.assertReference = exports.assertPositiveInteger = exports.assertNonNegativeInteger = exports.assertInteger = exports.assertBoolean = exports.assertStrictlyObject = exports.isError = exports.isStrictlyObject = exports.isObject = exports.isInteger = exports.isUint8Array = void 0;
|
|
3
|
+
exports.assertTransactionHash = exports.makeTagUid = exports.assertAllTagsOptions = exports.assertFileData = exports.assertData = exports.assertCashoutOptions = exports.assertTransactionOptions = exports.assertPostageBatchOptions = exports.assertPublicKey = exports.assertPssMessageHandler = exports.assertAddressPrefix = exports.assertTag = exports.isTag = exports.assertCollectionUploadOptions = exports.assertFileUploadOptions = exports.assertUploadOptions = exports.assertRequestOptions = exports.assertBatchId = exports.assertAddress = exports.addCidConversionFunction = exports.makeReferenceOrEns = exports.assertReferenceOrEns = exports.assertReference = exports.assertPositiveInteger = exports.assertNonNegativeInteger = exports.assertInteger = exports.assertBoolean = exports.assertStrictlyObject = exports.isError = exports.isStrictlyObject = exports.isObject = exports.isInteger = exports.isUint8Array = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const error_1 = require("./error");
|
|
6
6
|
const file_1 = require("./file");
|
|
@@ -165,7 +165,7 @@ exports.makeReferenceOrEns = makeReferenceOrEns;
|
|
|
165
165
|
* @param cidType Type as described in the @ethersphere/swarm-cids-js -> ReferenceType
|
|
166
166
|
*/
|
|
167
167
|
function addCidConversionFunction(result, cidType) {
|
|
168
|
-
return Object.assign(Object.assign({}, result), {
|
|
168
|
+
return Object.assign(Object.assign({}, result), { cid() {
|
|
169
169
|
return (0, swarm_cid_1.encodeReference)(result.reference, cidType).toString();
|
|
170
170
|
} });
|
|
171
171
|
}
|
|
@@ -322,20 +322,29 @@ function assertPostageBatchOptions(value) {
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
exports.assertPostageBatchOptions = assertPostageBatchOptions;
|
|
325
|
-
function
|
|
325
|
+
function assertTransactionOptions(value, name = 'TransactionOptions') {
|
|
326
326
|
if (value === undefined) {
|
|
327
327
|
return;
|
|
328
328
|
}
|
|
329
|
-
assertStrictlyObject(value);
|
|
329
|
+
assertStrictlyObject(value, name);
|
|
330
330
|
const options = value;
|
|
331
|
-
assertRequestOptions(options, 'PostageBatchOptions');
|
|
332
331
|
if (options === null || options === void 0 ? void 0 : options.gasLimit) {
|
|
333
|
-
assertNonNegativeInteger(options.gasLimit);
|
|
332
|
+
assertNonNegativeInteger(options.gasLimit, name);
|
|
334
333
|
}
|
|
335
334
|
if (options === null || options === void 0 ? void 0 : options.gasPrice) {
|
|
336
|
-
assertNonNegativeInteger(options.gasPrice);
|
|
335
|
+
assertNonNegativeInteger(options.gasPrice, name);
|
|
337
336
|
}
|
|
338
337
|
}
|
|
338
|
+
exports.assertTransactionOptions = assertTransactionOptions;
|
|
339
|
+
function assertCashoutOptions(value) {
|
|
340
|
+
if (value === undefined) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
assertStrictlyObject(value);
|
|
344
|
+
const options = value;
|
|
345
|
+
assertRequestOptions(options, 'CashoutOptions');
|
|
346
|
+
assertTransactionOptions(options, 'CashoutOptions');
|
|
347
|
+
}
|
|
339
348
|
exports.assertCashoutOptions = assertCashoutOptions;
|
|
340
349
|
/**
|
|
341
350
|
* Check whether the given parameter is valid data to upload
|