@ethersphere/bee-js 12.3.2-upcoming.116 → 13.0.0-upcoming.gc013bdf
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/balance.js +24 -0
- package/dist/cjs/api/batches.js +26 -0
- package/dist/cjs/{modules → api}/bytes.js +4 -29
- package/dist/cjs/{modules → api}/bzz.js +6 -34
- package/dist/cjs/{modules/debug → api}/chequebook.js +48 -87
- package/dist/cjs/api/chunk.js +43 -0
- package/dist/cjs/api/connectivity.js +86 -0
- package/dist/cjs/api/consumed.js +24 -0
- package/dist/cjs/{modules → api}/envelope.js +3 -2
- package/dist/cjs/api/feed.js +55 -0
- package/dist/cjs/api/grantee.js +62 -0
- package/dist/cjs/{modules/pinning.js → api/pin.js} +13 -34
- package/dist/cjs/api/pss.js +19 -0
- package/dist/cjs/api/redistributionstate.js +17 -0
- package/dist/cjs/{modules/debug/settlements.js → api/settlement.js} +3 -11
- package/dist/cjs/api/soc.js +34 -0
- package/dist/cjs/{modules/debug → api}/stake.js +15 -43
- package/dist/cjs/{modules/debug/stamps.js → api/stamp.js} +41 -57
- package/dist/cjs/api/status.js +67 -0
- package/dist/cjs/{modules → api}/stewardship.js +1 -6
- package/dist/cjs/api/tag.js +51 -0
- package/dist/cjs/{modules/debug/transactions.js → api/transaction.js} +10 -31
- package/dist/cjs/{modules/debug/states.js → api/wallet.js} +4 -36
- package/dist/cjs/bee.js +115 -1978
- package/dist/cjs/chunk/soc.js +23 -65
- package/dist/cjs/feed/identifier.js +3 -4
- package/dist/cjs/feed/index.js +20 -22
- package/dist/cjs/feed/retrievable.js +3 -3
- package/dist/cjs/index.js +18 -8
- package/dist/cjs/manifest/manifest.js +99 -335
- package/dist/cjs/modules/balance.js +86 -0
- package/dist/cjs/modules/cheque.js +92 -0
- package/dist/cjs/modules/chequebook.js +90 -0
- package/dist/cjs/modules/chunk.js +87 -53
- package/dist/cjs/modules/collection.js +145 -0
- package/dist/cjs/modules/connectivity.js +141 -0
- package/dist/cjs/modules/context.js +2 -0
- package/dist/cjs/modules/data.js +119 -0
- package/dist/cjs/modules/feed.js +94 -70
- package/dist/cjs/modules/file.js +113 -0
- package/dist/cjs/modules/grantee.js +86 -55
- package/dist/cjs/modules/messaging.js +248 -0
- package/dist/cjs/modules/pin.js +100 -0
- package/dist/cjs/modules/settlement.js +67 -0
- package/dist/cjs/modules/soc.js +39 -36
- package/dist/cjs/modules/stake.js +110 -0
- package/dist/cjs/modules/stamp.js +199 -0
- package/dist/cjs/modules/status.js +128 -20
- package/dist/cjs/modules/storage.js +191 -0
- package/dist/cjs/modules/tag.js +97 -71
- package/dist/cjs/modules/transaction.js +92 -0
- package/dist/cjs/modules/wallet.js +82 -0
- 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 +24 -16
- package/dist/cjs/utils/chunk-stream.js +17 -9
- 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 +15 -130
- package/dist/index.browser.min.js +2 -1
- package/dist/index.browser.min.js.LICENSE.txt +3 -0
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/api/balance.js +20 -0
- package/dist/mjs/api/batches.js +22 -0
- package/dist/mjs/{modules → api}/bytes.js +2 -27
- package/dist/mjs/{modules → api}/bzz.js +2 -30
- package/dist/mjs/{modules/debug → api}/chequebook.js +50 -89
- package/dist/mjs/api/chunk.js +37 -0
- package/dist/mjs/api/connectivity.js +76 -0
- package/dist/mjs/api/consumed.js +20 -0
- package/dist/mjs/{modules → api}/envelope.js +3 -2
- package/dist/mjs/api/feed.js +52 -0
- package/dist/mjs/api/grantee.js +59 -0
- package/dist/mjs/{modules/pinning.js → api/pin.js} +14 -35
- package/dist/mjs/api/pss.js +18 -0
- package/dist/mjs/api/redistributionstate.js +14 -0
- package/dist/mjs/{modules/debug/settlements.js → api/settlement.js} +3 -11
- package/dist/mjs/api/soc.js +31 -0
- package/dist/mjs/{modules/debug → api}/stake.js +14 -41
- package/dist/mjs/{modules/debug/stamps.js → api/stamp.js} +37 -51
- package/dist/mjs/api/status.js +59 -0
- package/dist/mjs/{modules → api}/stewardship.js +1 -6
- package/dist/mjs/api/tag.js +49 -0
- package/dist/mjs/api/transaction.js +41 -0
- package/dist/mjs/api/wallet.js +38 -0
- package/dist/mjs/bee.js +115 -1965
- package/dist/mjs/chunk/soc.js +13 -51
- package/dist/mjs/feed/identifier.js +2 -3
- package/dist/mjs/feed/index.js +9 -11
- package/dist/mjs/feed/retrievable.js +2 -2
- package/dist/mjs/index.js +2 -5
- package/dist/mjs/manifest/manifest.js +97 -341
- package/dist/mjs/modules/balance.js +49 -0
- package/dist/mjs/modules/cheque.js +55 -0
- package/dist/mjs/modules/chequebook.js +65 -0
- package/dist/mjs/modules/chunk.js +52 -49
- package/dist/mjs/modules/collection.js +108 -0
- package/dist/mjs/modules/connectivity.js +102 -0
- package/dist/mjs/modules/context.js +1 -0
- package/dist/mjs/modules/data.js +82 -0
- package/dist/mjs/modules/feed.js +89 -67
- package/dist/mjs/modules/file.js +78 -0
- package/dist/mjs/modules/grantee.js +52 -55
- package/dist/mjs/modules/messaging.js +213 -0
- package/dist/mjs/modules/pin.js +63 -0
- package/dist/mjs/modules/settlement.js +30 -0
- package/dist/mjs/modules/soc.js +36 -34
- package/dist/mjs/modules/stake.js +76 -0
- package/dist/mjs/modules/stamp.js +170 -0
- package/dist/mjs/modules/status.js +98 -18
- package/dist/mjs/modules/storage.js +185 -0
- package/dist/mjs/modules/tag.js +61 -68
- package/dist/mjs/modules/transaction.js +58 -0
- package/dist/mjs/modules/wallet.js +45 -0
- 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 +5 -5
- 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 +28 -18
- package/dist/mjs/utils/chunk-stream.js +21 -11
- 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 +5 -99
- package/dist/types/api/balance.d.ts +7 -0
- package/dist/types/api/batches.d.ts +7 -0
- package/dist/types/api/bytes.d.ts +11 -0
- package/dist/types/api/bzz.d.ts +12 -0
- package/dist/types/api/chequebook.d.ts +21 -0
- package/dist/types/api/chunk.d.ts +7 -0
- package/dist/types/api/connectivity.d.ts +22 -0
- package/dist/types/api/consumed.d.ts +7 -0
- package/dist/types/{modules → api}/envelope.d.ts +1 -1
- package/dist/types/api/feed.d.ts +40 -0
- package/dist/types/api/grantee.d.ts +11 -0
- package/dist/types/api/pin.d.ts +10 -0
- package/dist/types/api/pss.d.ts +6 -0
- package/dist/types/api/redistributionstate.d.ts +5 -0
- package/dist/types/api/settlement.d.ts +7 -0
- package/dist/types/api/soc.d.ts +6 -0
- package/dist/types/api/stake.d.ts +11 -0
- package/dist/types/api/stamp.d.ts +12 -0
- package/dist/types/api/status.d.ts +11 -0
- package/dist/types/api/stewardship.d.ts +7 -0
- package/dist/types/api/tag.d.ts +12 -0
- package/dist/types/api/transaction.d.ts +9 -0
- package/dist/types/api/wallet.d.ts +9 -0
- package/dist/types/bee.d.ts +71 -1199
- package/dist/types/chunk/soc.d.ts +3 -48
- package/dist/types/feed/identifier.d.ts +1 -1
- package/dist/types/feed/index.d.ts +2 -4
- package/dist/types/feed/retrievable.d.ts +1 -1
- package/dist/types/index.d.ts +17 -20
- package/dist/types/manifest/manifest.d.ts +25 -34
- package/dist/types/modules/balance.d.ts +38 -0
- package/dist/types/modules/cheque.d.ts +40 -0
- package/dist/types/modules/chequebook.d.ts +41 -0
- package/dist/types/modules/chunk.d.ts +30 -20
- package/dist/types/modules/collection.d.ts +77 -0
- package/dist/types/modules/connectivity.d.ts +74 -0
- package/dist/types/modules/context.d.ts +24 -0
- package/dist/types/modules/data.d.ts +55 -0
- package/dist/types/modules/feed.d.ts +47 -49
- package/dist/types/modules/file.d.ts +43 -0
- package/dist/types/modules/grantee.d.ts +40 -8
- package/dist/types/modules/messaging.d.ts +79 -0
- package/dist/types/modules/pin.d.ts +47 -0
- package/dist/types/modules/settlement.d.ts +25 -0
- package/dist/types/modules/soc.d.ts +23 -11
- package/dist/types/modules/stake.d.ts +55 -0
- package/dist/types/modules/stamp.d.ts +96 -0
- package/dist/types/modules/status.d.ts +66 -5
- package/dist/types/modules/storage.d.ts +107 -0
- package/dist/types/modules/tag.d.ts +44 -33
- package/dist/types/modules/transaction.d.ts +42 -0
- package/dist/types/modules/wallet.d.ts +35 -0
- package/dist/types/types/debug.d.ts +1 -1
- package/dist/types/types/index.d.ts +3 -12
- 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 +2 -27
- package/dist/types/utils/tar-uploader.browser.d.ts +1 -1
- package/dist/types/utils/tar-uploader.d.ts +1 -1
- package/package.json +4 -2
- package/dist/cjs/chunk/bmt.js +0 -37
- package/dist/cjs/chunk/cac.js +0 -43
- package/dist/cjs/modules/debug/balance.js +0 -60
- package/dist/cjs/modules/debug/connectivity.js +0 -54
- package/dist/cjs/modules/debug/status.js +0 -104
- package/dist/cjs/modules/gsoc.js +0 -23
- package/dist/cjs/modules/pss.js +0 -48
- package/dist/cjs/stamper/stamper.js +0 -44
- package/dist/cjs/utils/bytes.js +0 -116
- package/dist/cjs/utils/cid.js +0 -37
- package/dist/cjs/utils/redundancy.js +0 -133
- package/dist/cjs/utils/typed-bytes.js +0 -186
- package/dist/mjs/chunk/bmt.js +0 -34
- package/dist/mjs/chunk/cac.js +0 -34
- package/dist/mjs/modules/debug/balance.js +0 -54
- package/dist/mjs/modules/debug/connectivity.js +0 -46
- package/dist/mjs/modules/debug/states.js +0 -68
- package/dist/mjs/modules/debug/status.js +0 -99
- package/dist/mjs/modules/debug/transactions.js +0 -62
- package/dist/mjs/modules/gsoc.js +0 -16
- package/dist/mjs/modules/pss.js +0 -43
- package/dist/mjs/stamper/stamper.js +0 -40
- package/dist/mjs/utils/bytes.js +0 -102
- package/dist/mjs/utils/cid.js +0 -32
- package/dist/mjs/utils/redundancy.js +0 -98
- package/dist/mjs/utils/typed-bytes.js +0 -167
- package/dist/types/chunk/bmt.d.ts +0 -16
- package/dist/types/chunk/cac.d.ts +0 -40
- package/dist/types/modules/bytes.d.ts +0 -35
- package/dist/types/modules/bzz.d.ts +0 -40
- package/dist/types/modules/debug/balance.d.ts +0 -28
- package/dist/types/modules/debug/chequebook.d.ts +0 -60
- package/dist/types/modules/debug/connectivity.d.ts +0 -9
- package/dist/types/modules/debug/settlements.d.ts +0 -15
- package/dist/types/modules/debug/stake.d.ts +0 -30
- package/dist/types/modules/debug/stamps.d.ts +0 -11
- package/dist/types/modules/debug/states.d.ts +0 -23
- package/dist/types/modules/debug/status.d.ts +0 -46
- package/dist/types/modules/debug/transactions.d.ts +0 -30
- package/dist/types/modules/gsoc.d.ts +0 -6
- package/dist/types/modules/pinning.d.ts +0 -30
- package/dist/types/modules/pss.d.ts +0 -22
- package/dist/types/modules/stewardship.d.ts +0 -10
- package/dist/types/stamper/stamper.d.ts +0 -15
- package/dist/types/utils/bytes.d.ts +0 -19
- package/dist/types/utils/cid.d.ts +0 -10
- package/dist/types/utils/redundancy.d.ts +0 -21
- package/dist/types/utils/typed-bytes.d.ts +0 -69
- /package/dist/cjs/{modules → api}/rchash.js +0 -0
- /package/dist/mjs/{modules → api}/rchash.js +0 -0
- /package/dist/types/{modules → api}/rchash.d.ts +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Cheque = void 0;
|
|
37
|
+
const swarm_core_1 = require("swarm-core");
|
|
38
|
+
const schema_1 = require("../utils/schema");
|
|
39
|
+
const api = __importStar(require("../api/chequebook"));
|
|
40
|
+
/**
|
|
41
|
+
* Cheque operations (last cheques and cashouts).
|
|
42
|
+
*
|
|
43
|
+
* Accessed as `bee.cheque`.
|
|
44
|
+
*/
|
|
45
|
+
class Cheque {
|
|
46
|
+
constructor(context) {
|
|
47
|
+
this.context = context;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets the last cheques for all peers.
|
|
51
|
+
*
|
|
52
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
53
|
+
*/
|
|
54
|
+
async getAllLatest(requestOptions) {
|
|
55
|
+
return api.getLastCheques(this.context.getRequestOptionsForCall(requestOptions));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Gets the last cheques for a specific peer.
|
|
59
|
+
*
|
|
60
|
+
* @param address Overlay address of peer.
|
|
61
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
62
|
+
*/
|
|
63
|
+
async getAllLatestForPeer(address, requestOptions) {
|
|
64
|
+
const peer = new swarm_core_1.PeerAddress(address);
|
|
65
|
+
return api.getLastChequesForPeer(this.context.getRequestOptionsForCall(requestOptions), peer);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Gets the last cashout action for a specific peer.
|
|
69
|
+
*
|
|
70
|
+
* @param address Overlay address of peer.
|
|
71
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
72
|
+
*/
|
|
73
|
+
async getLastCashoutAction(address, requestOptions) {
|
|
74
|
+
const peer = new swarm_core_1.PeerAddress(address);
|
|
75
|
+
return api.getLastCashoutAction(this.context.getRequestOptionsForCall(requestOptions), peer);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Cashes out the last cheque for a specific peer.
|
|
79
|
+
*
|
|
80
|
+
* @param address Swarm address of peer
|
|
81
|
+
* @param options
|
|
82
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
83
|
+
*/
|
|
84
|
+
async cashoutLast(address, options, requestOptions) {
|
|
85
|
+
const peer = new swarm_core_1.PeerAddress(address);
|
|
86
|
+
if (options) {
|
|
87
|
+
options = schema_1.TransactionOptionsSchema.parse(options);
|
|
88
|
+
}
|
|
89
|
+
return api.cashoutLastCheque(this.context.getRequestOptionsForCall(requestOptions), peer, options);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.Cheque = Cheque;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Chequebook = void 0;
|
|
37
|
+
const tokens_1 = require("../utils/tokens");
|
|
38
|
+
const type_1 = require("../utils/type");
|
|
39
|
+
const api = __importStar(require("../api/chequebook"));
|
|
40
|
+
/**
|
|
41
|
+
* Chequebook contract operations (address, balance, deposit, withdraw).
|
|
42
|
+
*
|
|
43
|
+
* Accessed as `bee.chequebook`.
|
|
44
|
+
*/
|
|
45
|
+
class Chequebook {
|
|
46
|
+
constructor(context) {
|
|
47
|
+
this.context = context;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets the address of the deployed chequebook.
|
|
51
|
+
*
|
|
52
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
53
|
+
*/
|
|
54
|
+
async getAddress(requestOptions) {
|
|
55
|
+
return api.getChequebookAddress(this.context.getRequestOptionsForCall(requestOptions));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Gets the balance of the chequebook.
|
|
59
|
+
*
|
|
60
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
61
|
+
*/
|
|
62
|
+
async getBalance(requestOptions) {
|
|
63
|
+
return api.getChequebookBalance(this.context.getRequestOptionsForCall(requestOptions));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Deposits tokens from the node wallet into the chequebook.
|
|
67
|
+
*
|
|
68
|
+
* @param amount Amount of BZZ tokens to deposit. If not providing a `BZZ` instance, the amount is denoted in PLUR.
|
|
69
|
+
* @param gasPrice Gas Price in WEI for the transaction call
|
|
70
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
71
|
+
*/
|
|
72
|
+
async deposit(amount, gasPrice, requestOptions) {
|
|
73
|
+
const amountString = amount instanceof tokens_1.BZZ ? amount.toPLURString() : (0, type_1.asNumberString)(amount, { min: 1n, name: 'amount' });
|
|
74
|
+
const gasPriceString = gasPrice ? (0, type_1.asNumberString)(amount, { min: 0n, name: 'gasPrice' }) : undefined;
|
|
75
|
+
return api.depositTokens(this.context.getRequestOptionsForCall(requestOptions), amountString, gasPriceString);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Withdraws tokens from the chequebook to the node wallet.
|
|
79
|
+
*
|
|
80
|
+
* @param amount Amount of BZZ tokens to withdraw. If not providing a `BZZ` instance, the amount is denoted in PLUR.
|
|
81
|
+
* @param gasPrice Gas Price in WEI for the transaction call.
|
|
82
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
83
|
+
*/
|
|
84
|
+
async withdraw(amount, gasPrice, requestOptions) {
|
|
85
|
+
const amountString = amount instanceof tokens_1.BZZ ? amount.toPLURString() : (0, type_1.asNumberString)(amount, { min: 1n, name: 'amount' });
|
|
86
|
+
const gasPriceString = gasPrice ? (0, type_1.asNumberString)(amount, { min: 0n, name: 'gasPrice' }) : undefined;
|
|
87
|
+
return api.withdrawTokens(this.context.getRequestOptionsForCall(requestOptions), amountString, gasPriceString);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.Chequebook = Chequebook;
|
|
@@ -1,59 +1,93 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
method: 'post',
|
|
27
|
-
url: `${endpoint}`,
|
|
28
|
-
data,
|
|
29
|
-
headers: {
|
|
30
|
-
'content-type': 'application/octet-stream',
|
|
31
|
-
...(0, headers_1.prepareRequestHeaders)(stamp, options),
|
|
32
|
-
},
|
|
33
|
-
responseType: 'json',
|
|
34
|
-
});
|
|
35
|
-
const body = upload_1.UploadResultBody.parse(response.data);
|
|
36
|
-
return {
|
|
37
|
-
reference: body.reference,
|
|
38
|
-
tagUid: response.headers['swarm-tag'] ? (0, type_1.makeTagUid)(response.headers['swarm-tag']) : undefined,
|
|
39
|
-
historyAddress: response.headers['swarm-act-history-address']
|
|
40
|
-
? cafe_utility_1.Optional.of(new typed_bytes_1.Reference(response.headers['swarm-act-history-address']))
|
|
41
|
-
: cafe_utility_1.Optional.empty(),
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
42
26
|
};
|
|
43
|
-
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Chunk = void 0;
|
|
37
|
+
const swarm_core_1 = require("swarm-core");
|
|
38
|
+
const types_1 = require("../types");
|
|
39
|
+
const error_1 = require("../utils/error");
|
|
40
|
+
const schema_1 = require("../utils/schema");
|
|
41
|
+
const api = __importStar(require("../api/chunk"));
|
|
44
42
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* @param requestOptions Options for making requests
|
|
48
|
-
* @param hash Bee content reference
|
|
43
|
+
* Chunk operations backed by the `/chunks` endpoint.
|
|
49
44
|
*
|
|
45
|
+
* Accessed as `bee.chunk`.
|
|
50
46
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
class Chunk {
|
|
48
|
+
constructor(context) {
|
|
49
|
+
this.context = context;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Uploads a chunk to the network.
|
|
53
|
+
*
|
|
54
|
+
* Chunks uploaded with this method should be retrieved with {@link download}.
|
|
55
|
+
*
|
|
56
|
+
* @param stamp Postage Batch ID or an Envelope created with the `bee.createEnvelope` method.
|
|
57
|
+
* @param data Raw chunk to be uploaded (Content Addressed Chunk or Single Owner Chunk)
|
|
58
|
+
* @param options Additional options like tag, encryption, pinning, content-type and request options
|
|
59
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
60
|
+
*/
|
|
61
|
+
async upload(stamp, data, options, requestOptions) {
|
|
62
|
+
const isSOC = 'identifier' in data && 'signature' in data && 'owner' in data;
|
|
63
|
+
data = data instanceof Uint8Array ? data : data.data;
|
|
64
|
+
if (options) {
|
|
65
|
+
options = schema_1.UploadOptionsSchema.parse(options);
|
|
66
|
+
}
|
|
67
|
+
if (data.length < swarm_core_1.Span.LENGTH) {
|
|
68
|
+
throw new error_1.BeeArgumentError(`Chunk has to have size of at least ${swarm_core_1.Span.LENGTH}.`, data);
|
|
69
|
+
}
|
|
70
|
+
if (!isSOC && data.length > types_1.CHUNK_SIZE + swarm_core_1.Span.LENGTH) {
|
|
71
|
+
throw new error_1.BeeArgumentError(`Content Addressed Chunk must not exceed ${types_1.CHUNK_SIZE + swarm_core_1.Span.LENGTH} bytes.`, data);
|
|
72
|
+
}
|
|
73
|
+
if (isSOC && data.length > types_1.CHUNK_SIZE + swarm_core_1.Span.LENGTH + swarm_core_1.Signature.LENGTH + swarm_core_1.Identifier.LENGTH) {
|
|
74
|
+
throw new error_1.BeeArgumentError(`Single Owner Chunk must not exceed ${types_1.CHUNK_SIZE + swarm_core_1.Span.LENGTH + swarm_core_1.Signature.LENGTH + swarm_core_1.Identifier.LENGTH} bytes.`, data);
|
|
75
|
+
}
|
|
76
|
+
return api.upload(this.context.getRequestOptionsForCall(requestOptions), data, stamp, options);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Downloads a chunk as a `Uint8Array`.
|
|
80
|
+
*
|
|
81
|
+
* @param reference Bee chunk reference in hex string (either 64 or 128 chars long) or ENS domain.
|
|
82
|
+
* @param options Options that affects the request behavior
|
|
83
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
84
|
+
*/
|
|
85
|
+
async download(reference, options, requestOptions) {
|
|
86
|
+
const ref = new swarm_core_1.Reference(reference);
|
|
87
|
+
if (options) {
|
|
88
|
+
options = schema_1.DownloadOptionsSchema.parse(options);
|
|
89
|
+
}
|
|
90
|
+
return api.download(this.context.getRequestOptionsForCall(requestOptions), ref, options);
|
|
91
|
+
}
|
|
59
92
|
}
|
|
93
|
+
exports.Chunk = Chunk;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Collection = void 0;
|
|
37
|
+
const swarm_core_1 = require("swarm-core");
|
|
38
|
+
const chunk_stream_1 = require("../utils/chunk-stream");
|
|
39
|
+
const collection_1 = require("../utils/collection");
|
|
40
|
+
const collection_node_1 = require("../utils/collection.node");
|
|
41
|
+
const schema_1 = require("../utils/schema");
|
|
42
|
+
const api = __importStar(require("../api/bzz"));
|
|
43
|
+
/**
|
|
44
|
+
* Collection (multi-file) operations backed by the `/bzz` endpoint.
|
|
45
|
+
*
|
|
46
|
+
* Accessed as `bee.collection`.
|
|
47
|
+
*/
|
|
48
|
+
class Collection {
|
|
49
|
+
constructor(context) {
|
|
50
|
+
this.context = context;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Uploads a collection that you assemble yourself.
|
|
54
|
+
*
|
|
55
|
+
* @param postageBatchId
|
|
56
|
+
* @param collection
|
|
57
|
+
* @param options Collection and request options
|
|
58
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
59
|
+
*/
|
|
60
|
+
async upload(postageBatchId, collection, options, requestOptions) {
|
|
61
|
+
const batchId = new swarm_core_1.BatchId(postageBatchId);
|
|
62
|
+
(0, collection_1.assertCollection)(collection);
|
|
63
|
+
if (options) {
|
|
64
|
+
options = schema_1.CollectionUploadOptionsSchema.parse(options);
|
|
65
|
+
}
|
|
66
|
+
return api.uploadCollection(this.context.getRequestOptionsForCall(requestOptions), collection, batchId, options);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Uploads a collection of files using the browser `FileList` API.
|
|
70
|
+
*
|
|
71
|
+
* @param postageBatchId Postage BatchId to be used to upload the data with
|
|
72
|
+
* @param fileList list of files to be uploaded
|
|
73
|
+
* @param options Additional options like tag, encryption, pinning and request options
|
|
74
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
75
|
+
*/
|
|
76
|
+
async uploadFromFileList(postageBatchId, fileList, options, requestOptions) {
|
|
77
|
+
const batchId = new swarm_core_1.BatchId(postageBatchId);
|
|
78
|
+
if (options) {
|
|
79
|
+
options = schema_1.CollectionUploadOptionsSchema.parse(options);
|
|
80
|
+
}
|
|
81
|
+
const data = (0, collection_1.makeCollectionFromFileList)(fileList);
|
|
82
|
+
return api.uploadCollection(this.context.getRequestOptionsForCall(requestOptions), data, batchId, options);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Uploads a collection of files from a directory on the filesystem.
|
|
86
|
+
*
|
|
87
|
+
* Available only in Node.js as it uses the `fs` module.
|
|
88
|
+
*
|
|
89
|
+
* @param postageBatchId Postage BatchId to be used to upload the data with
|
|
90
|
+
* @param dir the path of the files to be uploaded
|
|
91
|
+
* @param options Additional options like tag, encryption, pinning and request options
|
|
92
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
93
|
+
*/
|
|
94
|
+
async uploadFromDirectory(postageBatchId, dir, options, requestOptions) {
|
|
95
|
+
const batchId = new swarm_core_1.BatchId(postageBatchId);
|
|
96
|
+
if (options) {
|
|
97
|
+
options = schema_1.CollectionUploadOptionsSchema.parse(options);
|
|
98
|
+
}
|
|
99
|
+
const data = await (0, collection_node_1.makeCollectionFromFS)(dir);
|
|
100
|
+
return api.uploadCollection(this.context.getRequestOptionsForCall(requestOptions), data, batchId, options);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Uploads a collection of files by streaming them to the Bee node, which supports arbitrary
|
|
104
|
+
* sizes, but may be slower due to uploading chunks one by one.
|
|
105
|
+
*
|
|
106
|
+
* Only intended for the browser environment.
|
|
107
|
+
*
|
|
108
|
+
* @param postageBatchId
|
|
109
|
+
* @param files
|
|
110
|
+
* @param onUploadProgress
|
|
111
|
+
* @param options
|
|
112
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
113
|
+
*/
|
|
114
|
+
async stream(postageBatchId, files, onUploadProgress, options, requestOptions) {
|
|
115
|
+
const batchId = new swarm_core_1.BatchId(postageBatchId);
|
|
116
|
+
return (0, chunk_stream_1.streamFiles)(this.context.bee, files, batchId, onUploadProgress, options, this.context.getRequestOptionsForCall(requestOptions));
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Uploads a directory by streaming its contents directly to the Bee node, which supports
|
|
120
|
+
* arbitrary directory sizes, but may be slower due to uploading chunks one by one.
|
|
121
|
+
*
|
|
122
|
+
* Only intended for the Node.js environment.
|
|
123
|
+
*
|
|
124
|
+
* @param postageBatchId
|
|
125
|
+
* @param dir
|
|
126
|
+
* @param onUploadProgress
|
|
127
|
+
* @param options
|
|
128
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
129
|
+
*/
|
|
130
|
+
async streamFromDirectory(postageBatchId, dir, onUploadProgress, options, requestOptions) {
|
|
131
|
+
const batchId = new swarm_core_1.BatchId(postageBatchId);
|
|
132
|
+
return (0, chunk_stream_1.streamDirectory)(this.context.bee, dir, batchId, onUploadProgress, options, this.context.getRequestOptionsForCall(requestOptions));
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Hashes a directory locally and returns the root hash (Swarm reference).
|
|
136
|
+
*
|
|
137
|
+
* The actual Swarm reference may be different as there is no canonical hashing of directories.
|
|
138
|
+
*
|
|
139
|
+
* @param dir
|
|
140
|
+
*/
|
|
141
|
+
async hashDirectory(dir) {
|
|
142
|
+
return (0, chunk_stream_1.hashDirectory)(dir);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.Collection = Collection;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Connectivity = void 0;
|
|
37
|
+
const swarm_core_1 = require("swarm-core");
|
|
38
|
+
const api = __importStar(require("../api/connectivity"));
|
|
39
|
+
/**
|
|
40
|
+
* Peer, topology and network connectivity operations.
|
|
41
|
+
*
|
|
42
|
+
* Accessed as `bee.connectivity`.
|
|
43
|
+
*/
|
|
44
|
+
class Connectivity {
|
|
45
|
+
constructor(context) {
|
|
46
|
+
this.context = context;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Pings the Bee node to see if there is a live Bee node on the given URL.
|
|
50
|
+
*
|
|
51
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
52
|
+
* @throws If connection was not successful throw error
|
|
53
|
+
*/
|
|
54
|
+
async checkConnection(requestOptions) {
|
|
55
|
+
return api.checkConnection(this.context.getRequestOptionsForCall(requestOptions));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Pings the Bee node to see if there is a live Bee node on the given URL.
|
|
59
|
+
*
|
|
60
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
61
|
+
* @returns true if successful, false on error
|
|
62
|
+
*/
|
|
63
|
+
async isConnected(requestOptions) {
|
|
64
|
+
try {
|
|
65
|
+
await this.checkConnection(requestOptions);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Checks the `/gateway` endpoint to see if the remote API is a gateway.
|
|
74
|
+
*
|
|
75
|
+
* Do note that this is not a standard way to check for gateway nodes,
|
|
76
|
+
* but some of the gateway tooling expose this endpoint.
|
|
77
|
+
*
|
|
78
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
79
|
+
*/
|
|
80
|
+
async isGateway(requestOptions) {
|
|
81
|
+
try {
|
|
82
|
+
return await api.isGateway(this.context.getRequestOptionsForCall(requestOptions));
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Fetches the overlay, underlay, Ethereum, and other addresses of the Bee node.
|
|
90
|
+
*
|
|
91
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
92
|
+
*/
|
|
93
|
+
async getNodeAddresses(requestOptions) {
|
|
94
|
+
return api.getNodeAddresses(this.context.getRequestOptionsForCall(requestOptions));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Fetches the list of blocked peers for this node.
|
|
98
|
+
*
|
|
99
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
100
|
+
*/
|
|
101
|
+
async getBlocklist(requestOptions) {
|
|
102
|
+
return api.getBlocklist(this.context.getRequestOptionsForCall(requestOptions));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Gets list of peers for this node.
|
|
106
|
+
*
|
|
107
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
108
|
+
*/
|
|
109
|
+
async getPeers(requestOptions) {
|
|
110
|
+
return api.getPeers(this.context.getRequestOptionsForCall(requestOptions));
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Disconnects from a specific peer.
|
|
114
|
+
*
|
|
115
|
+
* @param peer Overlay address of the peer to be removed.
|
|
116
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
117
|
+
*/
|
|
118
|
+
async removePeer(peer, requestOptions) {
|
|
119
|
+
const address = new swarm_core_1.PeerAddress(peer);
|
|
120
|
+
return api.removePeer(this.context.getRequestOptionsForCall(requestOptions), address);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Fetches topology and connectivity information of the Bee node.
|
|
124
|
+
*
|
|
125
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
126
|
+
*/
|
|
127
|
+
async getTopology(requestOptions) {
|
|
128
|
+
return api.getTopology(this.context.getRequestOptionsForCall(requestOptions));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Pings a specific peer to check its availability.
|
|
132
|
+
*
|
|
133
|
+
* @param peer Overlay address of the peer to be pinged.
|
|
134
|
+
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
135
|
+
*/
|
|
136
|
+
async ping(peer, requestOptions) {
|
|
137
|
+
const address = new swarm_core_1.PeerAddress(peer);
|
|
138
|
+
return api.ping(this.context.getRequestOptionsForCall(requestOptions), address);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.Connectivity = Connectivity;
|