@dashevo/dapi-client 0.25.0-dev.2 → 0.25.0-dev.20
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/methods/platform/PlatformMethodsFacade.js +2 -0
- package/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.js +55 -0
- package/lib/methods/platform/getDataContractHistory/getDataContractHistoryFactory.js +82 -0
- package/lib/methods/platform/getDocuments/GetDocumentsResponse.js +4 -1
- package/lib/methods/platform/getIdentitiesByPublicKeyHashes/GetIdentitiesByPublicKeyHashesResponse.js +4 -1
- package/lib/methods/platform/response/Proof.js +3 -3
- package/lib/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory.js +1 -1
- package/lib/networkConfigs.js +38 -129
- package/lib/transport/GrpcTransport/errors/InternalServerError.js +2 -2
- package/lib/transport/JsonRpcTransport/requestJsonRpc.js +2 -3
- package/package.json +8 -8
- package/polyfills/fetch-polyfill.js +1 -1
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
const EventEmitter = require('events');
|
|
2
|
-
const { configure: configureDashcore } = require('@dashevo/dashcore-lib');
|
|
3
|
-
const X11 = require('wasm-x11-hash');
|
|
4
2
|
const { SpvChain, SPVError } = require('@dashevo/dash-spv');
|
|
5
3
|
|
|
6
4
|
const BlockHeadersReader = require('./BlockHeadersReader');
|
|
@@ -51,7 +49,6 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
51
49
|
this.spvChain = new SpvChain(this.options.network, 100);
|
|
52
50
|
|
|
53
51
|
this.state = STATES.IDLE;
|
|
54
|
-
this.wasmX11Ready = false;
|
|
55
52
|
|
|
56
53
|
this.errorHandler = this.errorHandler.bind(this);
|
|
57
54
|
this.headersHandler = this.headersHandler.bind(this);
|
|
@@ -79,13 +76,7 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
79
76
|
* @private
|
|
80
77
|
*/
|
|
81
78
|
async init() {
|
|
82
|
-
|
|
83
|
-
const x11Hash = await X11();
|
|
84
|
-
configureDashcore({
|
|
85
|
-
x11hash: x11Hash,
|
|
86
|
-
});
|
|
87
|
-
this.wasmX11Ready = true;
|
|
88
|
-
}
|
|
79
|
+
await SpvChain.wasmX11Ready();
|
|
89
80
|
|
|
90
81
|
if (!this.blockHeadersReader) {
|
|
91
82
|
this.blockHeadersReader = new BlockHeadersReader(
|
|
@@ -113,12 +104,18 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
113
104
|
* Initializes SPV chain with a list of headers and a known lastSyncedHeaderHeight
|
|
114
105
|
*
|
|
115
106
|
* @param headers
|
|
116
|
-
* @param
|
|
107
|
+
* @param firstHeaderHeight
|
|
117
108
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
109
|
+
async initializeChainWith(headers, firstHeaderHeight) {
|
|
110
|
+
await SpvChain.wasmX11Ready();
|
|
111
|
+
|
|
112
|
+
if (headers.length === 0) {
|
|
113
|
+
// If there are no headers, initialize chain from genesis
|
|
114
|
+
this.spvChain.initialize();
|
|
115
|
+
} else {
|
|
116
|
+
this.spvChain.initialize(headers[0], firstHeaderHeight);
|
|
117
|
+
this.spvChain.addHeaders(headers);
|
|
118
|
+
}
|
|
122
119
|
}
|
|
123
120
|
|
|
124
121
|
/**
|
|
@@ -130,7 +127,8 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
130
127
|
ensureChainRoot(height) {
|
|
131
128
|
// Flush spv chain in case header at specified height was not found
|
|
132
129
|
if (!this.spvChain.hashesByHeight.has(height - 1)) {
|
|
133
|
-
this.spvChain.reset(
|
|
130
|
+
this.spvChain.reset();
|
|
131
|
+
this.spvChain.pendingStartBlockHeight = height;
|
|
134
132
|
}
|
|
135
133
|
}
|
|
136
134
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const broadcastStateTransitionFactory = require('./broadcastStateTransition/broadcastStateTransitionFactory');
|
|
2
2
|
const getDataContractFactory = require('./getDataContract/getDataContractFactory');
|
|
3
|
+
const getDataContractHistoryFactory = require('./getDataContractHistory/getDataContractHistoryFactory');
|
|
3
4
|
const getDocumentsFactory = require('./getDocuments/getDocumentsFactory');
|
|
4
5
|
const getIdentityFactory = require('./getIdentity/getIdentityFactory');
|
|
5
6
|
const getIdentitiesByPublicKeyHashesFactory = require('./getIdentitiesByPublicKeyHashes/getIdentitiesByPublicKeyHashesFactory');
|
|
@@ -13,6 +14,7 @@ class PlatformMethodsFacade {
|
|
|
13
14
|
constructor(grpcTransport) {
|
|
14
15
|
this.broadcastStateTransition = broadcastStateTransitionFactory(grpcTransport);
|
|
15
16
|
this.getDataContract = getDataContractFactory(grpcTransport);
|
|
17
|
+
this.getDataContractHistory = getDataContractHistoryFactory(grpcTransport);
|
|
16
18
|
this.getDocuments = getDocumentsFactory(grpcTransport);
|
|
17
19
|
this.getIdentity = getIdentityFactory(grpcTransport);
|
|
18
20
|
this.getIdentitiesByPublicKeyHashes = getIdentitiesByPublicKeyHashesFactory(grpcTransport);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const AbstractResponse = require('../response/AbstractResponse');
|
|
2
|
+
const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
3
|
+
|
|
4
|
+
class GetDataContractHistoryResponse extends AbstractResponse {
|
|
5
|
+
/**
|
|
6
|
+
* @param {object.<number, Buffer>} dataContractHistory
|
|
7
|
+
* @param {Metadata} metadata
|
|
8
|
+
* @param {Proof} [proof]
|
|
9
|
+
*/
|
|
10
|
+
constructor(dataContractHistory, metadata, proof = undefined) {
|
|
11
|
+
super(metadata, proof);
|
|
12
|
+
|
|
13
|
+
this.dataContractHistory = dataContractHistory;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @returns {object.<number, Buffer>}
|
|
18
|
+
*/
|
|
19
|
+
getDataContractHistory() {
|
|
20
|
+
return this.dataContractHistory;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param proto
|
|
25
|
+
* @returns {GetDataContractHistoryResponse}
|
|
26
|
+
*/
|
|
27
|
+
static createFromProto(proto) {
|
|
28
|
+
// History is something that we need to call a method to get a list of entries on
|
|
29
|
+
const dataContractHistory = proto.getDataContractHistory();
|
|
30
|
+
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(proto);
|
|
31
|
+
|
|
32
|
+
if (!dataContractHistory && !proof) {
|
|
33
|
+
throw new InvalidResponseError('DataContract is not defined');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const history = {};
|
|
37
|
+
|
|
38
|
+
if (dataContractHistory) {
|
|
39
|
+
const dataContractHistoryEntries = dataContractHistory.getDataContractEntriesList();
|
|
40
|
+
|
|
41
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
42
|
+
for (const historyEntry of dataContractHistoryEntries) {
|
|
43
|
+
history[historyEntry.getDate()] = historyEntry.getValue();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return new GetDataContractHistoryResponse(
|
|
48
|
+
history,
|
|
49
|
+
metadata,
|
|
50
|
+
proof,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = GetDataContractHistoryResponse;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const {
|
|
2
|
+
v0: {
|
|
3
|
+
PlatformPromiseClient,
|
|
4
|
+
GetDataContractHistoryRequest,
|
|
5
|
+
},
|
|
6
|
+
} = require('@dashevo/dapi-grpc');
|
|
7
|
+
|
|
8
|
+
const { UInt32Value } = require('google-protobuf/google/protobuf/wrappers_pb');
|
|
9
|
+
|
|
10
|
+
const GetDataContractHistoryResponse = require('./GetDataContractHistoryResponse');
|
|
11
|
+
const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
12
|
+
/**
|
|
13
|
+
* @param {GrpcTransport} grpcTransport
|
|
14
|
+
* @returns {getDataContractHistory}
|
|
15
|
+
*/
|
|
16
|
+
function getDataContractHistoryFactory(grpcTransport) {
|
|
17
|
+
/**
|
|
18
|
+
* Fetch Data Contract by id
|
|
19
|
+
*
|
|
20
|
+
* @typedef {getDataContractHistory}
|
|
21
|
+
* @param {Buffer} contractId
|
|
22
|
+
* @param {number} [startAtMs]
|
|
23
|
+
* @param {number} [limit]
|
|
24
|
+
* @param {number} [offset]
|
|
25
|
+
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
|
26
|
+
* @returns {Promise<GetDataContractHistoryResponse>}
|
|
27
|
+
*/
|
|
28
|
+
async function getDataContractHistory(
|
|
29
|
+
contractId,
|
|
30
|
+
startAtMs = 0,
|
|
31
|
+
limit = 10,
|
|
32
|
+
offset = 0,
|
|
33
|
+
options = {},
|
|
34
|
+
) {
|
|
35
|
+
const getDataContractHistoryRequest = new GetDataContractHistoryRequest();
|
|
36
|
+
|
|
37
|
+
// need to convert objects inherited from Buffer to pure buffer as google protobuf
|
|
38
|
+
// doesn't support extended buffers
|
|
39
|
+
// https://github.com/protocolbuffers/protobuf/blob/master/js/binary/utils.js#L1049
|
|
40
|
+
if (Buffer.isBuffer(contractId)) {
|
|
41
|
+
// eslint-disable-next-line no-param-reassign
|
|
42
|
+
contractId = Buffer.from(contractId);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getDataContractHistoryRequest.setId(contractId);
|
|
46
|
+
getDataContractHistoryRequest.setStartAtMs(startAtMs);
|
|
47
|
+
getDataContractHistoryRequest.setLimit(new UInt32Value([limit]));
|
|
48
|
+
getDataContractHistoryRequest.setOffset(new UInt32Value([offset]));
|
|
49
|
+
getDataContractHistoryRequest.setProve(!!options.prove);
|
|
50
|
+
|
|
51
|
+
let lastError;
|
|
52
|
+
|
|
53
|
+
// TODO: simple retry before the dapi versioning is properly implemented
|
|
54
|
+
for (let i = 0; i < 3; i += 1) {
|
|
55
|
+
try {
|
|
56
|
+
// eslint-disable-next-line no-await-in-loop
|
|
57
|
+
const getDataContractHistoryResponse = await grpcTransport.request(
|
|
58
|
+
PlatformPromiseClient,
|
|
59
|
+
'getDataContractHistory',
|
|
60
|
+
getDataContractHistoryRequest,
|
|
61
|
+
options,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return GetDataContractHistoryResponse.createFromProto(getDataContractHistoryResponse);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
if (e instanceof InvalidResponseError) {
|
|
67
|
+
lastError = e;
|
|
68
|
+
} else {
|
|
69
|
+
throw e;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// If we made it past the cycle it means that the retry didn't work,
|
|
75
|
+
// and we're throwing the last error encountered
|
|
76
|
+
throw lastError;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return getDataContractHistory;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = getDataContractHistoryFactory;
|
|
@@ -26,8 +26,11 @@ class GetDocumentsResponse extends AbstractResponse {
|
|
|
26
26
|
static createFromProto(proto) {
|
|
27
27
|
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(proto);
|
|
28
28
|
|
|
29
|
+
const documents = proto.getDocuments();
|
|
30
|
+
|
|
29
31
|
return new GetDocumentsResponse(
|
|
30
|
-
|
|
32
|
+
documents !== undefined
|
|
33
|
+
? documents.getDocumentsList().map((document) => Buffer.from(document)) : [],
|
|
31
34
|
metadata,
|
|
32
35
|
proof,
|
|
33
36
|
);
|
|
@@ -26,8 +26,11 @@ class GetIdentitiesByPublicKeyHashesResponse extends AbstractResponse {
|
|
|
26
26
|
static createFromProto(proto) {
|
|
27
27
|
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(proto);
|
|
28
28
|
|
|
29
|
+
const identitiesList = proto.getIdentities();
|
|
30
|
+
|
|
29
31
|
return new GetIdentitiesByPublicKeyHashesResponse(
|
|
30
|
-
|
|
32
|
+
identitiesList !== undefined
|
|
33
|
+
? identitiesList.getIdentitiesList_asU8().map((identity) => Buffer.from(identity)) : [],
|
|
31
34
|
metadata,
|
|
32
35
|
proof,
|
|
33
36
|
);
|
|
@@ -16,7 +16,7 @@ class Proof {
|
|
|
16
16
|
/**
|
|
17
17
|
* @returns {Buffer}
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
getGrovedbProof() {
|
|
20
20
|
return this.merkleProof;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -43,13 +43,13 @@ class Proof {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* @param {
|
|
46
|
+
* @param {object} proofProto
|
|
47
47
|
*
|
|
48
48
|
* @returns {Proof}
|
|
49
49
|
*/
|
|
50
50
|
static createFromProto(proofProto) {
|
|
51
51
|
return new Proof({
|
|
52
|
-
merkleProof: Buffer.from(proofProto.
|
|
52
|
+
merkleProof: Buffer.from(proofProto.getGrovedbProof()),
|
|
53
53
|
quorumHash: Buffer.from(proofProto.getQuorumHash()),
|
|
54
54
|
signature: Buffer.from(proofProto.getSignature()),
|
|
55
55
|
round: proofProto.getRound(),
|
package/lib/networkConfigs.js
CHANGED
|
@@ -1,143 +1,52 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
testnet: {
|
|
3
3
|
seeds: [
|
|
4
|
-
'seed-1.testnet.networks.dash.org',
|
|
5
|
-
'seed-2.testnet.networks.dash.org',
|
|
6
|
-
'seed-3.testnet.networks.dash.org',
|
|
7
|
-
'seed-4.testnet.networks.dash.org',
|
|
8
|
-
'seed-5.testnet.networks.dash.org',
|
|
4
|
+
'seed-1.testnet.networks.dash.org:1443',
|
|
5
|
+
'seed-2.testnet.networks.dash.org:1443',
|
|
6
|
+
'seed-3.testnet.networks.dash.org:1443',
|
|
7
|
+
'seed-4.testnet.networks.dash.org:1443',
|
|
8
|
+
'seed-5.testnet.networks.dash.org:1443',
|
|
9
9
|
],
|
|
10
10
|
network: 'testnet',
|
|
11
11
|
// Since we don't have PoSe atm, 3rd party masternodes sometimes provide wrong data
|
|
12
12
|
// that breaks test suite and application logic. Temporary solution is to hardcode
|
|
13
13
|
// reliable DCG testnet masternodes to connect. Should be removed when PoSe is introduced.
|
|
14
14
|
dapiAddressesWhiteList: [
|
|
15
|
-
'34.
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'35.
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'54.
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'
|
|
34
|
-
'52.
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
43
|
-
'
|
|
44
|
-
'35.
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
'54.186.161.236',
|
|
49
|
-
'52.13.63.7',
|
|
50
|
-
'18.236.233.225',
|
|
51
|
-
'54.191.138.72',
|
|
52
|
-
'54.191.59.75',
|
|
53
|
-
'18.237.160.84',
|
|
54
|
-
'54.218.236.193',
|
|
55
|
-
'54.148.178.140',
|
|
56
|
-
'35.161.168.136',
|
|
57
|
-
'35.161.33.22',
|
|
58
|
-
'35.160.130.44',
|
|
59
|
-
'34.212.104.247',
|
|
60
|
-
'52.13.29.83',
|
|
61
|
-
'54.149.39.172',
|
|
62
|
-
'35.89.93.255',
|
|
63
|
-
'35.85.46.137',
|
|
64
|
-
'54.188.154.252',
|
|
65
|
-
'54.218.11.172',
|
|
66
|
-
'54.186.47.235',
|
|
67
|
-
'54.244.145.48',
|
|
68
|
-
'18.236.232.153',
|
|
69
|
-
'34.220.226.135',
|
|
70
|
-
'34.220.30.59',
|
|
71
|
-
'18.237.160.97',
|
|
72
|
-
'18.236.146.99',
|
|
73
|
-
'35.88.169.18',
|
|
74
|
-
'35.164.17.198',
|
|
75
|
-
'54.218.80.158',
|
|
76
|
-
'34.220.102.107',
|
|
77
|
-
'35.165.60.113',
|
|
78
|
-
'34.215.234.63',
|
|
79
|
-
'35.89.146.226',
|
|
80
|
-
'35.89.86.26',
|
|
81
|
-
'35.88.160.231',
|
|
82
|
-
'54.245.8.155',
|
|
83
|
-
'52.36.221.94',
|
|
84
|
-
'52.35.46.188',
|
|
85
|
-
'34.221.153.67',
|
|
86
|
-
'54.212.153.15',
|
|
87
|
-
'35.85.55.192',
|
|
88
|
-
'35.89.105.90',
|
|
89
|
-
'52.24.22.52',
|
|
90
|
-
'54.212.33.96',
|
|
91
|
-
'52.10.19.238',
|
|
92
|
-
'35.160.190.165',
|
|
93
|
-
'34.219.3.61',
|
|
94
|
-
'54.187.32.187',
|
|
95
|
-
'35.162.221.77',
|
|
96
|
-
'35.91.64.183',
|
|
97
|
-
'18.236.189.15',
|
|
98
|
-
'35.91.145.195',
|
|
99
|
-
'54.186.251.30',
|
|
100
|
-
'54.245.9.46',
|
|
101
|
-
'35.91.48.128',
|
|
102
|
-
'54.244.75.85',
|
|
103
|
-
'34.221.159.53',
|
|
104
|
-
'35.89.88.166',
|
|
105
|
-
'54.185.249.165',
|
|
106
|
-
'54.245.9.209',
|
|
107
|
-
'34.222.167.162',
|
|
108
|
-
'54.191.88.232',
|
|
109
|
-
'54.191.111.112',
|
|
110
|
-
'18.237.146.37',
|
|
111
|
-
'35.89.148.27',
|
|
112
|
-
'35.91.8.48',
|
|
113
|
-
'18.236.208.138',
|
|
114
|
-
'54.213.60.60',
|
|
115
|
-
'35.92.151.94',
|
|
116
|
-
'18.237.241.37',
|
|
117
|
-
'54.202.209.229',
|
|
118
|
-
'34.221.9.70',
|
|
119
|
-
'35.89.38.62',
|
|
120
|
-
'54.218.81.193',
|
|
121
|
-
'34.221.158.21',
|
|
122
|
-
'35.88.97.57',
|
|
123
|
-
'54.68.247.40',
|
|
124
|
-
'35.88.168.176',
|
|
125
|
-
'35.89.202.171',
|
|
126
|
-
'34.220.106.205',
|
|
127
|
-
'34.210.86.23',
|
|
128
|
-
'44.230.40.184',
|
|
15
|
+
'34.214.48.68:1443',
|
|
16
|
+
'35.166.18.166:1443',
|
|
17
|
+
'35.165.50.126:1443',
|
|
18
|
+
'52.42.202.128:1443',
|
|
19
|
+
'52.12.176.90:1443',
|
|
20
|
+
'44.233.44.95:1443',
|
|
21
|
+
'35.167.145.149:1443',
|
|
22
|
+
'52.34.144.50:1443',
|
|
23
|
+
'44.240.98.102:1443',
|
|
24
|
+
'54.201.32.131:1443',
|
|
25
|
+
'52.10.229.11:1443',
|
|
26
|
+
'52.13.132.146:1443',
|
|
27
|
+
'44.228.242.181:1443',
|
|
28
|
+
'35.82.197.197:1443',
|
|
29
|
+
'52.40.219.41:1443',
|
|
30
|
+
'44.239.39.153:1443',
|
|
31
|
+
'54.149.33.167:1443',
|
|
32
|
+
'35.164.23.245:1443',
|
|
33
|
+
'52.33.28.47:1443',
|
|
34
|
+
'52.43.86.231:1443',
|
|
35
|
+
'52.43.13.92:1443',
|
|
36
|
+
'35.163.144.230:1443',
|
|
37
|
+
'52.89.154.48:1443',
|
|
38
|
+
'52.24.124.162:1443',
|
|
39
|
+
'44.227.137.77:1443',
|
|
40
|
+
'35.85.21.179:1443',
|
|
41
|
+
'54.187.14.232:1443',
|
|
42
|
+
'54.68.235.201:1443',
|
|
43
|
+
'52.13.250.182:1443',
|
|
44
|
+
'35.82.49.196:1443',
|
|
45
|
+
'44.232.196.6:1443',
|
|
46
|
+
'54.189.164.39:1443',
|
|
47
|
+
'54.213.204.85:1443',
|
|
129
48
|
],
|
|
130
49
|
},
|
|
131
|
-
evonet: {
|
|
132
|
-
seeds: [
|
|
133
|
-
'seed-1.evonet.networks.dash.org',
|
|
134
|
-
'seed-2.evonet.networks.dash.org',
|
|
135
|
-
'seed-3.evonet.networks.dash.org',
|
|
136
|
-
'seed-4.evonet.networks.dash.org',
|
|
137
|
-
'seed-5.evonet.networks.dash.org',
|
|
138
|
-
],
|
|
139
|
-
network: 'evonet',
|
|
140
|
-
},
|
|
141
50
|
local: {
|
|
142
51
|
dapiAddresses: ['127.0.0.1'],
|
|
143
52
|
network: 'regtest',
|
|
@@ -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,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-dev.
|
|
3
|
+
"version": "0.25.0-dev.20",
|
|
4
4
|
"description": "Client library used to access Dash DAPI endpoints",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"contributors": [
|
|
@@ -26,14 +26,15 @@
|
|
|
26
26
|
}
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@dashevo/dapi-grpc": "0.25.0-dev.
|
|
30
|
-
"@dashevo/dash-spv": "0.25.0-dev.
|
|
31
|
-
"@dashevo/dashcore-lib": "~0.20.
|
|
32
|
-
"@dashevo/dpp": "0.25.0-dev.
|
|
33
|
-
"@dashevo/grpc-common": "0.25.0-dev.
|
|
34
|
-
"@dashevo/wasm-dpp": "0.25.0-dev.
|
|
29
|
+
"@dashevo/dapi-grpc": "0.25.0-dev.20",
|
|
30
|
+
"@dashevo/dash-spv": "0.25.0-dev.20",
|
|
31
|
+
"@dashevo/dashcore-lib": "~0.20.9",
|
|
32
|
+
"@dashevo/dpp": "0.25.0-dev.20",
|
|
33
|
+
"@dashevo/grpc-common": "0.25.0-dev.20",
|
|
34
|
+
"@dashevo/wasm-dpp": "0.25.0-dev.20",
|
|
35
35
|
"bs58": "^4.0.1",
|
|
36
36
|
"cbor": "^8.0.0",
|
|
37
|
+
"google-protobuf": "^3.12.2",
|
|
37
38
|
"lodash": "^4.17.21",
|
|
38
39
|
"node-fetch": "^2.6.7",
|
|
39
40
|
"node-inspect-extracted": "^1.0.8",
|
|
@@ -55,7 +56,6 @@
|
|
|
55
56
|
"eslint-plugin-import": "^2.24.2",
|
|
56
57
|
"eslint-plugin-jsdoc": "^27.0.0",
|
|
57
58
|
"events": "^3.3.0",
|
|
58
|
-
"google-protobuf": "^3.12.2",
|
|
59
59
|
"karma": "^6.4.1",
|
|
60
60
|
"karma-chai": "^0.1.0",
|
|
61
61
|
"karma-chrome-launcher": "^3.1.0",
|