@dashevo/dapi-client 0.25.11 → 0.25.13

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.
@@ -7,8 +7,8 @@ const getIdentitiesByPublicKeyHashesFactory = require('./getIdentitiesByPublicKe
7
7
  const waitForStateTransitionResultFactory = require('./waitForStateTransitionResult/waitForStateTransitionResultFactory');
8
8
  const getConsensusParamsFactory = require('./getConsensusParams/getConsensusParamsFactory');
9
9
  const getEpochsInfoFactory = require('./getEpochsInfo/getEpochsInfoFactory');
10
- const getVersionUpgradeVoteStatusFactory = require('./getVersionUpgradeVoteStatus/getVersionUpgradeVoteStatusFactory');
11
- const getVersionUpgradeStateFactory = require('./getVersionUpgradeState/getVersionUpgradeStateFactory');
10
+ const getProtocolVersionUpgradeVoteStatusFactory = require('./getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory');
11
+ const getProtocolVersionUpgradeStateFactory = require('./getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory');
12
12
 
13
13
  class PlatformMethodsFacade {
14
14
  /**
@@ -24,8 +24,10 @@ class PlatformMethodsFacade {
24
24
  this.waitForStateTransitionResult = waitForStateTransitionResultFactory(grpcTransport);
25
25
  this.getConsensusParams = getConsensusParamsFactory(grpcTransport);
26
26
  this.getEpochsInfo = getEpochsInfoFactory(grpcTransport);
27
- this.getVersionUpgradeVoteStatus = getVersionUpgradeVoteStatusFactory(grpcTransport);
28
- this.getVersionUpgradeState = getVersionUpgradeStateFactory(grpcTransport);
27
+ this.getProtocolVersionUpgradeVoteStatus = getProtocolVersionUpgradeVoteStatusFactory(
28
+ grpcTransport,
29
+ );
30
+ this.getProtocolVersionUpgradeState = getProtocolVersionUpgradeStateFactory(grpcTransport);
29
31
  }
30
32
  }
31
33
 
@@ -2,7 +2,7 @@ const AbstractResponse = require('../response/AbstractResponse');
2
2
  const VersionEntry = require('./VersionEntry');
3
3
  const InvalidResponseError = require('../response/errors/InvalidResponseError');
4
4
 
5
- class GetVersionUpgradeStateResponse extends AbstractResponse {
5
+ class GetProtocolVersionUpgradeStateResponse extends AbstractResponse {
6
6
  /**
7
7
  * @param {VersionEntry[]} versionEntries
8
8
  * @param {Metadata} metadata
@@ -23,7 +23,7 @@ class GetVersionUpgradeStateResponse extends AbstractResponse {
23
23
 
24
24
  /**
25
25
  * @param proto
26
- * @returns {GetVersionUpgradeStateResponse}
26
+ * @returns {GetProtocolVersionUpgradeStateResponse}
27
27
  */
28
28
  static createFromProto(proto) {
29
29
  const versions = proto.getV0().getVersions();
@@ -45,7 +45,7 @@ class GetVersionUpgradeStateResponse extends AbstractResponse {
45
45
  ));
46
46
  }
47
47
 
48
- return new GetVersionUpgradeStateResponse(
48
+ return new GetProtocolVersionUpgradeStateResponse(
49
49
  versionEntries,
50
50
  metadata,
51
51
  proof,
@@ -53,4 +53,4 @@ class GetVersionUpgradeStateResponse extends AbstractResponse {
53
53
  }
54
54
  }
55
55
 
56
- module.exports = GetVersionUpgradeStateResponse;
56
+ module.exports = GetProtocolVersionUpgradeStateResponse;
@@ -0,0 +1,63 @@
1
+ const {
2
+ v0: {
3
+ PlatformPromiseClient,
4
+ GetProtocolVersionUpgradeStateRequest,
5
+ },
6
+ } = require('@dashevo/dapi-grpc');
7
+
8
+ const GetProtocolVersionUpgradeStateResponse = require('./GetProtocolVersionUpgradeStateResponse');
9
+ const InvalidResponseError = require('../response/errors/InvalidResponseError');
10
+
11
+ /**
12
+ * @param {GrpcTransport} grpcTransport
13
+ * @returns {getProtocolVersionUpgradeState}
14
+ */
15
+ function getProtocolVersionUpgradeStateFactory(grpcTransport) {
16
+ /**
17
+ * Fetch the version upgrade state
18
+ *
19
+ * @typedef {getProtocolVersionUpgradeState}
20
+ * @param {DAPIClientOptions & {prove: boolean}} [options]
21
+ * @returns {Promise<GetProtocolVersionUpgradeStateResponse>}
22
+ */
23
+ async function getProtocolVersionUpgradeState(options = {}) {
24
+ const { GetProtocolVersionUpgradeStateRequestV0 } = GetProtocolVersionUpgradeStateRequest;
25
+ const getProtocolVersionUpgradeStateRequest = new GetProtocolVersionUpgradeStateRequest();
26
+ getProtocolVersionUpgradeStateRequest.setV0(
27
+ new GetProtocolVersionUpgradeStateRequestV0()
28
+ .setProve(!!options.prove),
29
+ );
30
+
31
+ let lastError;
32
+
33
+ // TODO: simple retry before the dapi versioning is properly implemented
34
+ for (let i = 0; i < 3; i += 1) {
35
+ try {
36
+ // eslint-disable-next-line no-await-in-loop
37
+ const getProtocolVersionUpgradeStateResponse = await grpcTransport.request(
38
+ PlatformPromiseClient,
39
+ 'getProtocolVersionUpgradeState',
40
+ getProtocolVersionUpgradeStateRequest,
41
+ options,
42
+ );
43
+
44
+ return GetProtocolVersionUpgradeStateResponse
45
+ .createFromProto(getProtocolVersionUpgradeStateResponse);
46
+ } catch (e) {
47
+ if (e instanceof InvalidResponseError) {
48
+ lastError = e;
49
+ } else {
50
+ throw e;
51
+ }
52
+ }
53
+ }
54
+
55
+ // If we made it past the cycle it means that the retry didn't work,
56
+ // and we're throwing the last error encountered
57
+ throw lastError;
58
+ }
59
+
60
+ return getProtocolVersionUpgradeState;
61
+ }
62
+
63
+ module.exports = getProtocolVersionUpgradeStateFactory;
@@ -2,7 +2,7 @@ const AbstractResponse = require('../response/AbstractResponse');
2
2
  const VersionSignal = require('./VersionSignal');
3
3
  const InvalidResponseError = require('../response/errors/InvalidResponseError');
4
4
 
5
- class GetVersionUpgradeVoteStatusResponse extends AbstractResponse {
5
+ class GetProtocolVersionUpgradeVoteStatusResponse extends AbstractResponse {
6
6
  /**
7
7
  * @param {VersionSignal[]} versionSignals
8
8
  * @param {Metadata} metadata
@@ -23,7 +23,7 @@ class GetVersionUpgradeVoteStatusResponse extends AbstractResponse {
23
23
 
24
24
  /**
25
25
  * @param proto
26
- * @returns {GetVersionUpgradeVoteStatusResponse}
26
+ * @returns {GetProtocolVersionUpgradeVoteStatusResponse}
27
27
  */
28
28
  static createFromProto(proto) {
29
29
  const versions = proto.getV0().getVersions();
@@ -45,7 +45,7 @@ class GetVersionUpgradeVoteStatusResponse extends AbstractResponse {
45
45
  ));
46
46
  }
47
47
 
48
- return new GetVersionUpgradeVoteStatusResponse(
48
+ return new GetProtocolVersionUpgradeVoteStatusResponse(
49
49
  versionSignals,
50
50
  metadata,
51
51
  proof,
@@ -53,4 +53,4 @@ class GetVersionUpgradeVoteStatusResponse extends AbstractResponse {
53
53
  }
54
54
  }
55
55
 
56
- module.exports = GetVersionUpgradeVoteStatusResponse;
56
+ module.exports = GetProtocolVersionUpgradeVoteStatusResponse;
@@ -0,0 +1,72 @@
1
+ const {
2
+ v0: {
3
+ PlatformPromiseClient,
4
+ GetProtocolVersionUpgradeVoteStatusRequest,
5
+ },
6
+ } = require('@dashevo/dapi-grpc');
7
+
8
+ const GetProtocolVersionUpgradeVoteStatusResponse = require('./GetProtocolVersionUpgradeVoteStatusResponse');
9
+ const InvalidResponseError = require('../response/errors/InvalidResponseError');
10
+
11
+ /**
12
+ * @param {GrpcTransport} grpcTransport
13
+ * @returns {getProtocolVersionUpgradeVoteStatus}
14
+ */
15
+ function getProtocolVersionUpgradeVoteStatusFactory(grpcTransport) {
16
+ /**
17
+ * Fetch the version upgrade vote status
18
+ *
19
+ * @typedef {getProtocolVersionUpgradeVoteStatus}
20
+ * @param {string} startProTxHash
21
+ * @param {number} count
22
+ * @param {DAPIClientOptions & {prove: boolean}} [options]
23
+ * @returns {Promise<GetProtocolVersionUpgradeVoteStatusResponse>}
24
+ */
25
+ async function getProtocolVersionUpgradeVoteStatus(startProTxHash, count, options = {}) {
26
+ const {
27
+ GetProtocolVersionUpgradeVoteStatusRequestV0,
28
+ } = GetProtocolVersionUpgradeVoteStatusRequest;
29
+
30
+ // eslint-disable-next-line max-len
31
+ const getProtocolVersionUpgradeVoteStatusRequest = new GetProtocolVersionUpgradeVoteStatusRequest();
32
+
33
+ getProtocolVersionUpgradeVoteStatusRequest.setV0(
34
+ new GetProtocolVersionUpgradeVoteStatusRequestV0()
35
+ .setStartProTxHash(Buffer.from(startProTxHash, 'hex'))
36
+ .setCount(count)
37
+ .setProve(!!options.prove),
38
+ );
39
+
40
+ let lastError;
41
+
42
+ // TODO: simple retry before the dapi versioning is properly implemented
43
+ for (let i = 0; i < 3; i += 1) {
44
+ try {
45
+ // eslint-disable-next-line no-await-in-loop
46
+ const getProtocolVersionUpgradeVoteStatusResponse = await grpcTransport.request(
47
+ PlatformPromiseClient,
48
+ 'getProtocolVersionUpgradeVoteStatus',
49
+ getProtocolVersionUpgradeVoteStatusRequest,
50
+ options,
51
+ );
52
+
53
+ return GetProtocolVersionUpgradeVoteStatusResponse
54
+ .createFromProto(getProtocolVersionUpgradeVoteStatusResponse);
55
+ } catch (e) {
56
+ if (e instanceof InvalidResponseError) {
57
+ lastError = e;
58
+ } else {
59
+ throw e;
60
+ }
61
+ }
62
+ }
63
+
64
+ // If we made it past the cycle it means that the retry didn't work,
65
+ // and we're throwing the last error encountered
66
+ throw lastError;
67
+ }
68
+
69
+ return getProtocolVersionUpgradeVoteStatus;
70
+ }
71
+
72
+ module.exports = getProtocolVersionUpgradeVoteStatusFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/dapi-client",
3
- "version": "0.25.11",
3
+ "version": "0.25.13",
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": "0.25.11",
30
- "@dashevo/dash-spv": "0.25.11",
29
+ "@dashevo/dapi-grpc": "0.25.13",
30
+ "@dashevo/dash-spv": "0.25.13",
31
31
  "@dashevo/dashcore-lib": "~0.21.0",
32
- "@dashevo/grpc-common": "0.25.11",
33
- "@dashevo/wasm-dpp": "0.25.11",
32
+ "@dashevo/grpc-common": "0.25.13",
33
+ "@dashevo/wasm-dpp": "0.25.13",
34
34
  "bs58": "^4.0.1",
35
35
  "cbor": "^8.0.0",
36
36
  "google-protobuf": "^3.12.2",
@@ -1,63 +0,0 @@
1
- const {
2
- v0: {
3
- PlatformPromiseClient,
4
- GetVersionUpgradeStateRequest,
5
- },
6
- } = require('@dashevo/dapi-grpc');
7
-
8
- const GetVersionUpgradeStateResponse = require('./GetVersionUpgradeStateResponse');
9
- const InvalidResponseError = require('../response/errors/InvalidResponseError');
10
-
11
- /**
12
- * @param {GrpcTransport} grpcTransport
13
- * @returns {getVersionUpgradeState}
14
- */
15
- function getVersionUpgradeStateFactory(grpcTransport) {
16
- /**
17
- * Fetch the version upgrade state
18
- *
19
- * @typedef {getVersionUpgradeState}
20
- * @param {DAPIClientOptions & {prove: boolean}} [options]
21
- * @returns {Promise<GetVersionUpgradeStateResponse>}
22
- */
23
- async function getVersionUpgradeState(options = {}) {
24
- const { GetVersionUpgradeStateRequestV0 } = GetVersionUpgradeStateRequest;
25
- const getVersionUpgradeStateRequest = new GetVersionUpgradeStateRequest();
26
- getVersionUpgradeStateRequest.setV0(
27
- new GetVersionUpgradeStateRequestV0()
28
- .setProve(!!options.prove),
29
- );
30
-
31
- let lastError;
32
-
33
- // TODO: simple retry before the dapi versioning is properly implemented
34
- for (let i = 0; i < 3; i += 1) {
35
- try {
36
- // eslint-disable-next-line no-await-in-loop
37
- const getVersionUpgradeStateResponse = await grpcTransport.request(
38
- PlatformPromiseClient,
39
- 'getVersionUpgradeState',
40
- getVersionUpgradeStateRequest,
41
- options,
42
- );
43
-
44
- return GetVersionUpgradeStateResponse
45
- .createFromProto(getVersionUpgradeStateResponse);
46
- } catch (e) {
47
- if (e instanceof InvalidResponseError) {
48
- lastError = e;
49
- } else {
50
- throw e;
51
- }
52
- }
53
- }
54
-
55
- // If we made it past the cycle it means that the retry didn't work,
56
- // and we're throwing the last error encountered
57
- throw lastError;
58
- }
59
-
60
- return getVersionUpgradeState;
61
- }
62
-
63
- module.exports = getVersionUpgradeStateFactory;
@@ -1,67 +0,0 @@
1
- const {
2
- v0: {
3
- PlatformPromiseClient,
4
- GetVersionUpgradeVoteStatusRequest,
5
- },
6
- } = require('@dashevo/dapi-grpc');
7
-
8
- const GetVersionUpgradeVoteStatusResponse = require('./GetVersionUpgradeVoteStatusResponse');
9
- const InvalidResponseError = require('../response/errors/InvalidResponseError');
10
-
11
- /**
12
- * @param {GrpcTransport} grpcTransport
13
- * @returns {getVersionUpgradeVoteStatus}
14
- */
15
- function getVersionUpgradeVoteStatusFactory(grpcTransport) {
16
- /**
17
- * Fetch the version upgrade vote status
18
- *
19
- * @typedef {getVersionUpgradeVoteStatus}
20
- * @param {string} startProTxHash
21
- * @param {number} count
22
- * @param {DAPIClientOptions & {prove: boolean}} [options]
23
- * @returns {Promise<GetVersionUpgradeVoteStatusResponse>}
24
- */
25
- async function getVersionUpgradeVoteStatus(startProTxHash, count, options = {}) {
26
- const { GetVersionUpgradeVoteStatusRequestV0 } = GetVersionUpgradeVoteStatusRequest;
27
- const getVersionUpgradeVoteStatusRequest = new GetVersionUpgradeVoteStatusRequest();
28
- getVersionUpgradeVoteStatusRequest.setV0(
29
- new GetVersionUpgradeVoteStatusRequestV0()
30
- .setStartProTxHash(Buffer.from(startProTxHash, 'hex'))
31
- .setCount(count)
32
- .setProve(!!options.prove),
33
- );
34
-
35
- let lastError;
36
-
37
- // TODO: simple retry before the dapi versioning is properly implemented
38
- for (let i = 0; i < 3; i += 1) {
39
- try {
40
- // eslint-disable-next-line no-await-in-loop
41
- const getVersionUpgradeVoteStatusResponse = await grpcTransport.request(
42
- PlatformPromiseClient,
43
- 'getVersionUpgradeVoteStatus',
44
- getVersionUpgradeVoteStatusRequest,
45
- options,
46
- );
47
-
48
- return GetVersionUpgradeVoteStatusResponse
49
- .createFromProto(getVersionUpgradeVoteStatusResponse);
50
- } catch (e) {
51
- if (e instanceof InvalidResponseError) {
52
- lastError = e;
53
- } else {
54
- throw e;
55
- }
56
- }
57
- }
58
-
59
- // If we made it past the cycle it means that the retry didn't work,
60
- // and we're throwing the last error encountered
61
- throw lastError;
62
- }
63
-
64
- return getVersionUpgradeVoteStatus;
65
- }
66
-
67
- module.exports = getVersionUpgradeVoteStatusFactory;