@dashevo/dapi-client 0.24.0-dev.6 → 0.24.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/README.md +7 -8
- package/lib/BlockHeadersProvider/BlockHeadersProvider.js +187 -50
- package/lib/BlockHeadersProvider/BlockHeadersReader.js +170 -88
- package/lib/BlockHeadersProvider/createBlockHeadersProviderFromOptions.js +31 -16
- package/lib/DAPIClient.js +0 -6
- package/lib/dapiAddressProvider/DAPIAddress.js +14 -40
- package/lib/dapiAddressProvider/ListDAPIAddressProvider.js +3 -4
- package/lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.js +8 -1
- package/lib/index.js +5 -0
- package/lib/methods/platform/response/Metadata.js +21 -1
- package/lib/methods/platform/response/Proof.js +16 -5
- package/lib/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory.js +1 -1
- package/lib/networkConfigs.js +33 -124
- package/lib/test/bootstrap.js +8 -0
- package/lib/test/fixtures/getMNListDiffsFixture.js +85 -1066
- package/lib/test/fixtures/getMetadataFixture.js +9 -1
- package/lib/test/fixtures/getProofFixture.js +3 -2
- package/lib/test/mocks/BlockHeadersWithChainLocksStreamMock.js +54 -0
- package/lib/test/mocks/mockHeadersChain.js +55 -0
- package/lib/transport/GrpcTransport/GrpcTransport.js +5 -10
- package/lib/transport/GrpcTransport/createGrpcTransportError.js +11 -14
- package/lib/transport/JsonRpcTransport/JsonRpcTransport.js +1 -1
- package/lib/transport/JsonRpcTransport/requestJsonRpc.js +22 -25
- package/lib/transport/ReconnectableStream.js +284 -0
- package/package.json +15 -12
- package/polyfills/fetch-polyfill.js +10 -0
- /package/lib/{test/utils → utils}/wait.js +0 -0
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
class Metadata {
|
|
2
2
|
/**
|
|
3
|
-
* @param {
|
|
3
|
+
* @param {Object} properties
|
|
4
4
|
* @param {number} properties.height - block height
|
|
5
5
|
* @param {number} properties.coreChainLockedHeight - core chain locked height
|
|
6
|
+
* @param {number} properties.timeMs - block time
|
|
7
|
+
* @param {number} properties.protocolVersion - protocol version
|
|
6
8
|
*/
|
|
7
9
|
constructor(properties) {
|
|
8
10
|
this.height = properties.height;
|
|
9
11
|
this.coreChainLockedHeight = properties.coreChainLockedHeight;
|
|
12
|
+
this.timeMs = properties.timeMs;
|
|
13
|
+
this.protocolVersion = properties.protocolVersion;
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
/**
|
|
@@ -26,6 +30,22 @@ class Metadata {
|
|
|
26
30
|
getCoreChainLockedHeight() {
|
|
27
31
|
return this.coreChainLockedHeight;
|
|
28
32
|
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get block time
|
|
36
|
+
* @return {number}
|
|
37
|
+
*/
|
|
38
|
+
getTimeMs() {
|
|
39
|
+
return this.timeMs;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get protocol version
|
|
44
|
+
* @return {number}
|
|
45
|
+
*/
|
|
46
|
+
getProtocolVersion() {
|
|
47
|
+
return this.protocolVersion;
|
|
48
|
+
}
|
|
29
49
|
}
|
|
30
50
|
|
|
31
51
|
module.exports = Metadata;
|
|
@@ -2,13 +2,15 @@ class Proof {
|
|
|
2
2
|
/**
|
|
3
3
|
* @param {object} properties
|
|
4
4
|
* @param {Buffer} properties.merkleProof
|
|
5
|
-
* @param {Buffer} properties.
|
|
5
|
+
* @param {Buffer} properties.quorumHash
|
|
6
6
|
* @param {Buffer} properties.signature
|
|
7
|
+
* @param {number} properties.round
|
|
7
8
|
*/
|
|
8
9
|
constructor(properties) {
|
|
9
10
|
this.merkleProof = properties.merkleProof;
|
|
10
|
-
this.
|
|
11
|
+
this.quorumHash = properties.quorumHash;
|
|
11
12
|
this.signature = properties.signature;
|
|
13
|
+
this.round = properties.round;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -21,8 +23,8 @@ class Proof {
|
|
|
21
23
|
/**
|
|
22
24
|
* @returns {Buffer}
|
|
23
25
|
*/
|
|
24
|
-
|
|
25
|
-
return this.
|
|
26
|
+
getQuorumHash() {
|
|
27
|
+
return this.quorumHash;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -32,6 +34,14 @@ class Proof {
|
|
|
32
34
|
return this.signature;
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @returns {number}
|
|
40
|
+
*/
|
|
41
|
+
getRound() {
|
|
42
|
+
return this.round;
|
|
43
|
+
}
|
|
44
|
+
|
|
35
45
|
/**
|
|
36
46
|
* @param {Object} proofProto
|
|
37
47
|
*
|
|
@@ -40,8 +50,9 @@ class Proof {
|
|
|
40
50
|
static createFromProto(proofProto) {
|
|
41
51
|
return new Proof({
|
|
42
52
|
merkleProof: Buffer.from(proofProto.getMerkleProof()),
|
|
43
|
-
|
|
53
|
+
quorumHash: Buffer.from(proofProto.getQuorumHash()),
|
|
44
54
|
signature: Buffer.from(proofProto.getSignature()),
|
|
55
|
+
round: proofProto.getRound(),
|
|
45
56
|
});
|
|
46
57
|
}
|
|
47
58
|
}
|
package/lib/networkConfigs.js
CHANGED
|
@@ -12,132 +12,41 @@ module.exports = {
|
|
|
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:self-signed',
|
|
16
|
+
'35.166.18.166:1443:self-signed',
|
|
17
|
+
'35.165.50.126:1443:self-signed',
|
|
18
|
+
'52.42.202.128:1443:self-signed',
|
|
19
|
+
'52.12.176.90:1443:self-signed',
|
|
20
|
+
'44.233.44.95:1443:self-signed',
|
|
21
|
+
'35.167.145.149:1443:self-signed',
|
|
22
|
+
'52.34.144.50:1443:self-signed',
|
|
23
|
+
'44.240.98.102:1443:self-signed',
|
|
24
|
+
'54.201.32.131:1443:self-signed',
|
|
25
|
+
'52.10.229.11:1443:self-signed',
|
|
26
|
+
'52.13.132.146:1443:self-signed',
|
|
27
|
+
'44.228.242.181:1443:self-signed',
|
|
28
|
+
'35.82.197.197:1443:self-signed',
|
|
29
|
+
'52.40.219.41:1443:self-signed',
|
|
30
|
+
'44.239.39.153:1443:self-signed',
|
|
31
|
+
'54.149.33.167:1443:self-signed',
|
|
32
|
+
'35.164.23.245:1443:self-signed',
|
|
33
|
+
'52.33.28.47:1443:self-signed',
|
|
34
|
+
'52.43.86.231:1443:self-signed',
|
|
35
|
+
'52.43.13.92:1443:self-signed',
|
|
36
|
+
'35.163.144.230:1443:self-signed',
|
|
37
|
+
'52.89.154.48:1443:self-signed',
|
|
38
|
+
'52.24.124.162:1443:self-signed',
|
|
39
|
+
'44.227.137.77:1443:self-signed',
|
|
40
|
+
'35.85.21.179:1443:self-signed',
|
|
41
|
+
'54.187.14.232:1443:self-signed',
|
|
42
|
+
'54.68.235.201:1443:self-signed',
|
|
43
|
+
'52.13.250.182:1443:self-signed',
|
|
44
|
+
'35.82.49.196:1443:self-signed',
|
|
45
|
+
'44.232.196.6:1443:self-signed',
|
|
46
|
+
'54.189.164.39:1443:self-signed',
|
|
47
|
+
'54.213.204.85:1443:self-signed',
|
|
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',
|
package/lib/test/bootstrap.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require('../../polyfills/fetch-polyfill');
|
|
2
|
+
|
|
1
3
|
const { expect, use } = require('chai');
|
|
2
4
|
const sinon = require('sinon');
|
|
3
5
|
const sinonChai = require('sinon-chai');
|
|
@@ -20,4 +22,10 @@ afterEach(function afterEach() {
|
|
|
20
22
|
this.sinon.restore();
|
|
21
23
|
});
|
|
22
24
|
|
|
25
|
+
before(function before() {
|
|
26
|
+
if (!this.sinon) {
|
|
27
|
+
this.sinon = sinon.createSandbox();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
23
31
|
global.expect = expect;
|