@dashevo/dapi-client 1.1.1 → 1.2.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/docs/_sidebar.md
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
- [.subscribeToMasternodeList()](usage/application/core/subscribeToMasternodeList.md)
|
|
19
19
|
- Platform
|
|
20
20
|
- [.broadcastStateTransition()](usage/application/platform/broadcastStateTransition.md)
|
|
21
|
+
- [.getStatus()](usage/application/platform/getStatus.md)
|
|
21
22
|
- [.getDataContract()](usage/application/platform/getDataContract.md)
|
|
22
23
|
- [.getDocuments()](usage/application/platform/getDocuments.md)
|
|
23
24
|
- [.getIdentityByFirstPublicKey()](usage/application/platform/getIdentityByFirstPublicKey.md)
|
|
@@ -14,6 +14,7 @@ const getIdentityContractNonceFactory = require('./getIdentityContractNonce/getI
|
|
|
14
14
|
const getIdentityNonceFactory = require('./getIdentityNonce/getIdentityNonceFactory');
|
|
15
15
|
const getIdentityKeysFactory = require('./getIdentityKeys/getIdentityKeysFactory');
|
|
16
16
|
const getTotalCreditsInPlatformFactory = require('./getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory');
|
|
17
|
+
const getStatusFactory = require('./getStatus/getStatusFactory');
|
|
17
18
|
|
|
18
19
|
class PlatformMethodsFacade {
|
|
19
20
|
/**
|
|
@@ -38,6 +39,7 @@ class PlatformMethodsFacade {
|
|
|
38
39
|
this.getIdentityNonce = getIdentityNonceFactory(grpcTransport);
|
|
39
40
|
this.getIdentityKeys = getIdentityKeysFactory(grpcTransport);
|
|
40
41
|
this.getTotalCreditsInPlatform = getTotalCreditsInPlatformFactory(grpcTransport);
|
|
42
|
+
this.getStatus = getStatusFactory(grpcTransport);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const {
|
|
2
|
+
v0: {
|
|
3
|
+
PlatformPromiseClient,
|
|
4
|
+
GetStatusRequest,
|
|
5
|
+
},
|
|
6
|
+
} = require('@dashevo/dapi-grpc');
|
|
7
|
+
|
|
8
|
+
const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {GrpcTransport} grpcTransport
|
|
12
|
+
* @returns {getIdentity}
|
|
13
|
+
*/
|
|
14
|
+
function getStatusFactory(grpcTransport) {
|
|
15
|
+
/**
|
|
16
|
+
* Fetch the identity by id
|
|
17
|
+
* @typedef {getIdentity}
|
|
18
|
+
* @param {Buffer} id
|
|
19
|
+
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
|
20
|
+
* @returns {Promise<GetIdentityResponse>}
|
|
21
|
+
*/
|
|
22
|
+
async function getStatus(options = {}) {
|
|
23
|
+
const { GetStatusRequestV0 } = GetStatusRequest;
|
|
24
|
+
const getStatusRequest = new GetStatusRequest();
|
|
25
|
+
|
|
26
|
+
getStatusRequest.setV0(
|
|
27
|
+
new GetStatusRequestV0(),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
let lastError;
|
|
31
|
+
|
|
32
|
+
// TODO: simple retry before the dapi versioning is properly implemented
|
|
33
|
+
for (let i = 0; i < 3; i += 1) {
|
|
34
|
+
try {
|
|
35
|
+
// eslint-disable-next-line no-await-in-loop
|
|
36
|
+
const getStatusResponse = await grpcTransport.request(
|
|
37
|
+
PlatformPromiseClient,
|
|
38
|
+
'getStatus',
|
|
39
|
+
getStatusRequest,
|
|
40
|
+
options,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (getStatusResponse.getV0() === undefined) {
|
|
44
|
+
// noinspection ExceptionCaughtLocallyJS
|
|
45
|
+
throw new InvalidResponseError('GetStatusResponseV0 is not defined');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return getStatusResponse.getV0().toObject();
|
|
49
|
+
} catch (e) {
|
|
50
|
+
if (e instanceof InvalidResponseError) {
|
|
51
|
+
lastError = e;
|
|
52
|
+
} else {
|
|
53
|
+
throw e;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// If we made it past the cycle it means that the retry didn't work,
|
|
59
|
+
// and we're throwing the last error encountered
|
|
60
|
+
throw lastError;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return getStatus;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = getStatusFactory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
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.
|
|
30
|
-
"@dashevo/dash-spv": "2.
|
|
29
|
+
"@dashevo/dapi-grpc": "1.2.0",
|
|
30
|
+
"@dashevo/dash-spv": "2.2.0",
|
|
31
31
|
"@dashevo/dashcore-lib": "~0.21.3",
|
|
32
|
-
"@dashevo/grpc-common": "1.
|
|
33
|
-
"@dashevo/wasm-dpp": "1.
|
|
32
|
+
"@dashevo/grpc-common": "1.2.0",
|
|
33
|
+
"@dashevo/wasm-dpp": "1.2.0",
|
|
34
34
|
"bs58": "^4.0.1",
|
|
35
35
|
"cbor": "^8.0.0",
|
|
36
36
|
"google-protobuf": "^3.12.2",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"string_decoder": "^1.3.0",
|
|
77
77
|
"url": "^0.11.3",
|
|
78
78
|
"util": "^0.12.4",
|
|
79
|
-
"webpack": "^5.
|
|
79
|
+
"webpack": "^5.94.0",
|
|
80
80
|
"webpack-cli": "^4.9.1"
|
|
81
81
|
},
|
|
82
82
|
"files": [
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"test:integration": "mocha './test/integration/**/*.spec.js'",
|
|
93
93
|
"test:node": "NODE_ENV=test mocha",
|
|
94
94
|
"test:browsers": "karma start ./karma.conf.js --single-run",
|
|
95
|
-
"test:coverage": "NODE_ENV=test nyc --check-coverage --stmts=98 --branch=98 --funcs=98 --lines=
|
|
95
|
+
"test:coverage": "NODE_ENV=test nyc --check-coverage --stmts=98 --branch=98 --funcs=98 --lines=89 yarn run mocha 'test/unit/**/*.spec.js' 'test/integration/**/*.spec.js'",
|
|
96
96
|
"prepublishOnly": "yarn run build:web"
|
|
97
97
|
},
|
|
98
98
|
"ultra": {
|