@dashevo/dapi-client 1.0.0-pr.1825.1 → 1.0.0-pr.1825.11

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.
@@ -5,7 +5,8 @@ const getBlockByHashFactory = require('./getBlockByHashFactory');
5
5
  const getBlockByHeightFactory = require('./getBlockByHeightFactory');
6
6
  const getBlockHashFactory = require('./getBlockHashFactory');
7
7
  const getMnListDiffFactory = require('./getMnListDiffFactory');
8
- const getStatusFactory = require('./getStatusFactory');
8
+ const getBlockchainStatusFactory = require('./getBlockchainStatusFactory');
9
+ const getMasternodeStatusFactory = require('./getMasternodeStatusFactory');
9
10
  const getTransactionFactory = require('./getTransaction/getTransactionFactory');
10
11
  const subscribeToTransactionsWithProofsFactory = require('./subscribeToTransactionsWithProofsFactory');
11
12
  const subscribeToBlockHeadersWithChainLocksFactory = require('./subscribeToBlockHeadersWithChainLocksFactory');
@@ -23,7 +24,8 @@ class CoreMethodsFacade {
23
24
  this.getBlockByHeight = getBlockByHeightFactory(grpcTransport);
24
25
  this.getBlockHash = getBlockHashFactory(jsonRpcTransport);
25
26
  this.getMnListDiff = getMnListDiffFactory(jsonRpcTransport);
26
- this.getStatus = getStatusFactory(grpcTransport);
27
+ this.getBlockchainStatus = getBlockchainStatusFactory(grpcTransport);
28
+ this.getMasternodeStatus = getMasternodeStatusFactory(grpcTransport);
27
29
  this.getTransaction = getTransactionFactory(grpcTransport);
28
30
  this.subscribeToTransactionsWithProofs = subscribeToTransactionsWithProofsFactory(
29
31
  grpcTransport,
@@ -0,0 +1,59 @@
1
+ const {
2
+ v0: {
3
+ GetBlockchainStatusRequest,
4
+ GetBlockchainStatusResponse,
5
+ CorePromiseClient,
6
+ },
7
+ } = require('@dashevo/dapi-grpc');
8
+
9
+ /**
10
+ * @param {GrpcTransport} grpcTransport
11
+ * @returns {getBlockchainStatus}
12
+ */
13
+ function getBlockchainStatusFactory(grpcTransport) {
14
+ /**
15
+ * Get Core chain status
16
+ * @typedef {getBlockchainStatus}
17
+ * @param {DAPIClientOptions} [options]
18
+ * @returns {Promise<object>}
19
+ */
20
+ async function getBlockchainStatus(options = {}) {
21
+ const getBlockchainStatusRequest = new GetBlockchainStatusRequest();
22
+
23
+ const response = await grpcTransport.request(
24
+ CorePromiseClient,
25
+ 'getBlockchainStatus',
26
+ getBlockchainStatusRequest,
27
+ options,
28
+ );
29
+
30
+ const responseObject = response.toObject();
31
+
32
+ // Respond with Buffers instead of base64 for binary fields
33
+
34
+ if (response.getChain()) {
35
+ if (response.getChain()
36
+ .getBestBlockHash()) {
37
+ responseObject.chain.bestBlockHash = Buffer.from(response.getChain()
38
+ .getBestBlockHash());
39
+ }
40
+
41
+ if (response.getChain()
42
+ .getChainWork()) {
43
+ responseObject.chain.chainWork = Buffer.from(response.getChain()
44
+ .getChainWork());
45
+ }
46
+ }
47
+
48
+ // Respond with constant names instead of constant values
49
+
50
+ responseObject.status = Object.keys(GetBlockchainStatusResponse.Status)
51
+ .find((key) => GetBlockchainStatusResponse.Status[key] === responseObject.status);
52
+
53
+ return responseObject;
54
+ }
55
+
56
+ return getBlockchainStatus;
57
+ }
58
+
59
+ module.exports = getBlockchainStatusFactory;
@@ -0,0 +1,45 @@
1
+ const {
2
+ v0: {
3
+ GetMasternodeStatusRequest,
4
+ GetMasternodeStatusResponse,
5
+ CorePromiseClient,
6
+ },
7
+ } = require('@dashevo/dapi-grpc');
8
+
9
+ /**
10
+ * @param {GrpcTransport} grpcTransport
11
+ * @returns {getMasternodeStatus}
12
+ */
13
+ function getMasternodeStatusFactory(grpcTransport) {
14
+ /**
15
+ * Get Core chain status
16
+ * @typedef {getMasternodeStatus}
17
+ * @param {DAPIClientOptions} [options]
18
+ * @returns {Promise<object>}
19
+ */
20
+ async function getMasternodeStatus(options = {}) {
21
+ const getMasternodeStatusRequest = new GetMasternodeStatusRequest();
22
+
23
+ const response = await grpcTransport.request(
24
+ CorePromiseClient,
25
+ 'getMasternodeStatus',
26
+ getMasternodeStatusRequest,
27
+ options,
28
+ );
29
+
30
+ const responseObject = response.toObject();
31
+
32
+ // Respond with constant names instead of constant values
33
+
34
+ responseObject.status = Object.keys(GetMasternodeStatusResponse.Status)
35
+ .find((key) => GetMasternodeStatusResponse.Status[key] === responseObject.status);
36
+
37
+ responseObject.proTxHash = Buffer.from(responseObject.proTxHash, 'base64');
38
+
39
+ return responseObject;
40
+ }
41
+
42
+ return getMasternodeStatus;
43
+ }
44
+
45
+ module.exports = getMasternodeStatusFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/dapi-client",
3
- "version": "1.0.0-pr.1825.1",
3
+ "version": "1.0.0-pr.1825.11",
4
4
  "description": "Client library used to access Dash DAPI endpoints",
5
5
  "main": "lib/index.js",
6
6
  "contributors": [
@@ -26,11 +26,11 @@
26
26
  }
27
27
  ],
28
28
  "dependencies": {
29
- "@dashevo/dapi-grpc": "1.0.0-pr.1825.1",
30
- "@dashevo/dash-spv": "1.0.0-pr.1825.1",
29
+ "@dashevo/dapi-grpc": "1.0.0-pr.1825.11",
30
+ "@dashevo/dash-spv": "1.0.0-pr.1825.11",
31
31
  "@dashevo/dashcore-lib": "~0.21.1",
32
- "@dashevo/grpc-common": "1.0.0-pr.1825.1",
33
- "@dashevo/wasm-dpp": "1.0.0-pr.1825.1",
32
+ "@dashevo/grpc-common": "1.0.0-pr.1825.11",
33
+ "@dashevo/wasm-dpp": "1.0.0-pr.1825.11",
34
34
  "bs58": "^4.0.1",
35
35
  "cbor": "^8.0.0",
36
36
  "google-protobuf": "^3.12.2",
@@ -1,68 +0,0 @@
1
- const {
2
- v0: {
3
- GetStatusRequest,
4
- GetStatusResponse,
5
- CorePromiseClient,
6
- },
7
- } = require('@dashevo/dapi-grpc');
8
-
9
- /**
10
- * @param {GrpcTransport} grpcTransport
11
- * @returns {getStatus}
12
- */
13
- function getStatusFactory(grpcTransport) {
14
- /**
15
- * Get Core chain status
16
- * @typedef {getStatus}
17
- * @param {DAPIClientOptions} [options]
18
- * @returns {Promise<object>}
19
- */
20
- async function getStatus(options = {}) {
21
- const getStatusRequest = new GetStatusRequest();
22
-
23
- const response = await grpcTransport.request(
24
- CorePromiseClient,
25
- 'getStatus',
26
- getStatusRequest,
27
- options,
28
- );
29
-
30
- const responseObject = response.toObject();
31
-
32
- // Respond with Buffers instead of base64 for binary fields
33
-
34
- if (response.getChain()) {
35
- if (response.getChain().getBestBlockHash()) {
36
- responseObject.chain.bestBlockHash = Buffer.from(response.getChain().getBestBlockHash());
37
- }
38
-
39
- if (response.getChain().getChainWork()) {
40
- responseObject.chain.chainWork = Buffer.from(response.getChain().getChainWork());
41
- }
42
- }
43
-
44
- if (response.getMasternode()) {
45
- if (response.getMasternode().getProTxHash()) {
46
- responseObject.masternode.proTxHash = Buffer.from(response.getMasternode().getProTxHash());
47
- }
48
- }
49
-
50
- // Respond with constant names instead of constant values
51
-
52
- responseObject.status = Object.keys(GetStatusResponse.Status)
53
- .find((key) => GetStatusResponse.Status[key] === responseObject.status);
54
-
55
- if (responseObject.masternode) {
56
- responseObject.masternode.status = Object.keys(GetStatusResponse.Masternode.Status)
57
- .find((key) => (
58
- GetStatusResponse.Masternode.Status[key] === responseObject.masternode.status
59
- ));
60
- }
61
-
62
- return responseObject;
63
- }
64
-
65
- return getStatus;
66
- }
67
-
68
- module.exports = getStatusFactory;