@dashevo/dapi-client 0.24.0-dev.6 → 0.25.0-dev.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/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/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/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;
|