@dashevo/dapi-client 0.25.0-dev.9 → 0.25.0-pr.1545.2
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/lib/BlockHeadersProvider/BlockHeadersProvider.js +14 -16
- package/lib/DAPIClient.js +8 -0
- package/lib/logger/index.js +76 -0
- package/lib/methods/platform/PlatformMethodsFacade.js +10 -0
- package/lib/methods/platform/getConsensusParams/getConsensusParamsFactory.js +10 -2
- package/lib/methods/platform/getConsensusParams/getConsensusParamsResponse.js +2 -2
- package/lib/methods/platform/getDataContract/GetDataContractResponse.js +1 -1
- package/lib/methods/platform/getDataContract/getDataContractFactory.js +6 -2
- package/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.js +55 -0
- package/lib/methods/platform/getDataContractHistory/getDataContractHistoryFactory.js +86 -0
- package/lib/methods/platform/getDocuments/GetDocumentsResponse.js +4 -1
- package/lib/methods/platform/getDocuments/getDocumentsFactory.js +12 -8
- package/lib/methods/platform/getEpochsInfo/EpochInfo.js +54 -0
- package/lib/methods/platform/getEpochsInfo/GetEpochsInfoResponse.js +59 -0
- package/lib/methods/platform/getEpochsInfo/getEpochsInfoFactory.js +69 -0
- package/lib/methods/platform/getIdentitiesByPublicKeyHashes/GetIdentitiesByPublicKeyHashesResponse.js +10 -1
- package/lib/methods/platform/getIdentitiesByPublicKeyHashes/getIdentitiesByPublicKeyHashesFactory.js +6 -3
- package/lib/methods/platform/getIdentity/GetIdentityResponse.js +2 -2
- package/lib/methods/platform/getIdentity/getIdentityFactory.js +6 -2
- package/lib/methods/platform/getProtocolVersionUpgradeState/GetProtocolVersionUpgradeStateResponse.js +56 -0
- package/lib/methods/platform/getProtocolVersionUpgradeState/VersionEntry.js +26 -0
- package/lib/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.js +63 -0
- package/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.js +56 -0
- package/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/VersionSignal.js +26 -0
- package/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js +72 -0
- package/lib/methods/platform/response/AbstractResponse.js +2 -2
- package/lib/methods/platform/response/Proof.js +3 -3
- package/lib/methods/platform/waitForStateTransitionResult/WaitForStateTransitionResultResponse.js +8 -7
- package/lib/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory.js +7 -4
- package/lib/networkConfigs.js +38 -129
- package/lib/test/bootstrap.js +6 -0
- package/lib/transport/GrpcTransport/GrpcTransport.js +7 -0
- package/lib/transport/GrpcTransport/errors/InternalServerError.js +2 -2
- package/lib/transport/JsonRpcTransport/JsonRpcTransport.js +6 -0
- package/lib/transport/JsonRpcTransport/requestJsonRpc.js +2 -3
- package/package.json +13 -10
- package/polyfills/fetch-polyfill.js +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const logger = require('../../logger');
|
|
2
|
+
|
|
1
3
|
const MaxRetriesReachedError = require('../errors/response/MaxRetriesReachedError');
|
|
2
4
|
const NoAvailableAddressesForRetryError = require('../errors/response/NoAvailableAddressesForRetryError');
|
|
3
5
|
const NoAvailableAddressesError = require('../errors/NoAvailableAddressesError');
|
|
@@ -27,6 +29,7 @@ class GrpcTransport {
|
|
|
27
29
|
this.globalOptions = globalOptions;
|
|
28
30
|
|
|
29
31
|
this.lastUsedAddress = null;
|
|
32
|
+
this.logger = logger.getForId(globalOptions.loggerOptions.identifier);
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
/**
|
|
@@ -67,6 +70,8 @@ class GrpcTransport {
|
|
|
67
70
|
);
|
|
68
71
|
}
|
|
69
72
|
|
|
73
|
+
this.logger.debug(`GRPC Request ${method} to ${address.toString()}`, { options });
|
|
74
|
+
|
|
70
75
|
try {
|
|
71
76
|
const result = await client[method](requestMessage, {}, requestOptions);
|
|
72
77
|
|
|
@@ -78,6 +83,8 @@ class GrpcTransport {
|
|
|
78
83
|
} catch (error) {
|
|
79
84
|
this.lastUsedAddress = address;
|
|
80
85
|
|
|
86
|
+
this.logger.error(`GRPC Request ${method} to ${address.toString()} failed with error: ${error.message}`);
|
|
87
|
+
|
|
81
88
|
// for unknown errors
|
|
82
89
|
if (error.code === undefined) {
|
|
83
90
|
throw error;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const RetriableResponseError = require('../../errors/response/RetriableResponseError');
|
|
2
2
|
|
|
3
|
-
class InternalServerError extends
|
|
3
|
+
class InternalServerError extends RetriableResponseError {
|
|
4
4
|
/**
|
|
5
5
|
* @param {number} code
|
|
6
6
|
* @param {string} message
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const logger = require('../../logger');
|
|
2
|
+
|
|
1
3
|
const MaxRetriesReachedError = require('../errors/response/MaxRetriesReachedError');
|
|
2
4
|
const NoAvailableAddressesForRetryError = require('../errors/response/NoAvailableAddressesForRetryError');
|
|
3
5
|
const NoAvailableAddressesError = require('../errors/NoAvailableAddressesError');
|
|
@@ -29,6 +31,8 @@ class JsonRpcTransport {
|
|
|
29
31
|
|
|
30
32
|
this.createJsonTransportError = createJsonTransportError;
|
|
31
33
|
|
|
34
|
+
this.logger = logger.getForId(globalOptions.loggerOptions.identifier);
|
|
35
|
+
|
|
32
36
|
this.lastUsedAddress = null;
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -63,6 +67,8 @@ class JsonRpcTransport {
|
|
|
63
67
|
requestOptions.timeout = options.timeout;
|
|
64
68
|
}
|
|
65
69
|
|
|
70
|
+
this.logger.debug(`JSON-RPC Request ${method} to ${address.toString()}`, { options });
|
|
71
|
+
|
|
66
72
|
try {
|
|
67
73
|
const result = await this.requestJsonRpc(
|
|
68
74
|
address.getProtocol(),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const https = require('https');
|
|
2
2
|
const JsonRpcError = require('./errors/JsonRpcError');
|
|
3
3
|
const WrongHttpCodeError = require('./errors/WrongHttpCodeError');
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* @typedef {requestJsonRpc}
|
|
7
6
|
* @param {string} protocol
|
|
@@ -58,19 +57,19 @@ async function requestJsonRpc(protocol, host, port, selfSigned, method, params,
|
|
|
58
57
|
rejectUnauthorized: false,
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
|
-
|
|
62
60
|
// eslint-disable-next-line
|
|
63
61
|
const response = await fetch(url, requestOptions);
|
|
64
62
|
|
|
65
63
|
if (typeof requestTimeoutId !== 'undefined') {
|
|
66
64
|
clearTimeout(requestTimeoutId);
|
|
67
65
|
}
|
|
68
|
-
const data = await response.json();
|
|
69
66
|
|
|
70
67
|
if (!response.ok) {
|
|
71
68
|
throw new WrongHttpCodeError(requestInfo, response.status, response.statusText);
|
|
72
69
|
}
|
|
73
70
|
|
|
71
|
+
const data = await response.json();
|
|
72
|
+
|
|
74
73
|
if (data.error) {
|
|
75
74
|
throw new JsonRpcError(requestInfo, data.error);
|
|
76
75
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-client",
|
|
3
|
-
"version": "0.25.0-
|
|
3
|
+
"version": "0.25.0-pr.1545.2",
|
|
4
4
|
"description": "Client library used to access Dash DAPI endpoints",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"contributors": [
|
|
@@ -26,25 +26,27 @@
|
|
|
26
26
|
}
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@dashevo/dapi-grpc": "0.25.0-
|
|
30
|
-
"@dashevo/dash-spv": "0.25.0-
|
|
31
|
-
"@dashevo/dashcore-lib": "~0.
|
|
32
|
-
"@dashevo/
|
|
33
|
-
"@dashevo/
|
|
34
|
-
"@dashevo/wasm-dpp": "0.25.0-dev.9",
|
|
29
|
+
"@dashevo/dapi-grpc": "0.25.0-pr.1545.2",
|
|
30
|
+
"@dashevo/dash-spv": "0.25.0-pr.1545.2",
|
|
31
|
+
"@dashevo/dashcore-lib": "~0.21.0",
|
|
32
|
+
"@dashevo/grpc-common": "0.25.0-pr.1545.2",
|
|
33
|
+
"@dashevo/wasm-dpp": "0.25.0-pr.1545.2",
|
|
35
34
|
"bs58": "^4.0.1",
|
|
36
35
|
"cbor": "^8.0.0",
|
|
36
|
+
"google-protobuf": "^3.12.2",
|
|
37
37
|
"lodash": "^4.17.21",
|
|
38
38
|
"node-fetch": "^2.6.7",
|
|
39
39
|
"node-inspect-extracted": "^1.0.8",
|
|
40
|
-
"wasm-x11-hash": "~0.0.2"
|
|
40
|
+
"wasm-x11-hash": "~0.0.2",
|
|
41
|
+
"winston": "^3.2.1"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@babel/core": "^7.15.5",
|
|
44
45
|
"assert-browserify": "^2.0.0",
|
|
45
46
|
"babel-loader": "^8.2.2",
|
|
47
|
+
"browserify-zlib": "^0.2.0",
|
|
46
48
|
"buffer": "^6.0.3",
|
|
47
|
-
"chai": "^4.3.
|
|
49
|
+
"chai": "^4.3.9",
|
|
48
50
|
"chai-as-promised": "^7.1.1",
|
|
49
51
|
"comment-parser": "^0.7.6",
|
|
50
52
|
"core-js": "^3.17.2",
|
|
@@ -55,7 +57,6 @@
|
|
|
55
57
|
"eslint-plugin-import": "^2.24.2",
|
|
56
58
|
"eslint-plugin-jsdoc": "^27.0.0",
|
|
57
59
|
"events": "^3.3.0",
|
|
58
|
-
"google-protobuf": "^3.12.2",
|
|
59
60
|
"karma": "^6.4.1",
|
|
60
61
|
"karma-chai": "^0.1.0",
|
|
61
62
|
"karma-chrome-launcher": "^3.1.0",
|
|
@@ -65,8 +66,10 @@
|
|
|
65
66
|
"karma-webpack": "^5.0.0",
|
|
66
67
|
"mocha": "^9.1.2",
|
|
67
68
|
"nyc": "^15.1.0",
|
|
69
|
+
"os-browserify": "^0.3.0",
|
|
68
70
|
"path-browserify": "^1.0.1",
|
|
69
71
|
"process": "^0.11.10",
|
|
72
|
+
"setimmediate": "^1.0.5",
|
|
70
73
|
"sinon": "^11.1.2",
|
|
71
74
|
"sinon-chai": "^3.7.0",
|
|
72
75
|
"stream-browserify": "^3.0.0",
|