@dashevo/dapi-client 0.25.16-pr.1562.7 → 0.25.16-pr.1574.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 +3 -1
- package/lib/BlockHeadersProvider/BlockHeadersReader.js +9 -2
- package/lib/SimplifiedMasternodeListProvider/SimplifiedMasternodeListProvider.js +6 -1
- package/lib/dapiAddressProvider/DAPIAddress.js +9 -1
- package/lib/dapiAddressProvider/ListDAPIAddressProvider.js +5 -0
- package/lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.js +2 -0
- package/lib/methods/core/broadcastTransactionFactory.js +1 -0
- package/lib/methods/core/generateToAddressFactory.js +1 -0
- package/lib/methods/core/getBestBlockHashFactory.js +1 -0
- package/lib/methods/core/getBlockByHashFactory.js +1 -0
- package/lib/methods/core/getBlockByHeightFactory.js +1 -0
- package/lib/methods/core/getBlockHashFactory.js +1 -0
- package/lib/methods/core/getMnListDiffFactory.js +1 -0
- package/lib/methods/core/getStatusFactory.js +1 -0
- package/lib/methods/core/getTransaction/GetTransactionResponse.js +6 -0
- package/lib/methods/core/getTransaction/getTransactionFactory.js +1 -0
- package/lib/methods/platform/broadcastStateTransition/broadcastStateTransitionFactory.js +1 -0
- package/lib/methods/platform/getConsensusParams/getConsensusParamsFactory.js +1 -0
- package/lib/methods/platform/getDataContract/getDataContractFactory.js +1 -0
- package/lib/methods/platform/getDataContractHistory/getDataContractHistoryFactory.js +1 -0
- package/lib/methods/platform/getDocuments/getDocumentsFactory.js +1 -0
- package/lib/methods/platform/getEpochsInfo/getEpochsInfoFactory.js +1 -0
- package/lib/methods/platform/getIdentitiesByPublicKeyHashes/getIdentitiesByPublicKeyHashesFactory.js +1 -0
- package/lib/methods/platform/getIdentity/getIdentityFactory.js +1 -0
- package/lib/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.js +1 -0
- package/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js +1 -0
- package/lib/methods/platform/response/AbstractResponse.js +1 -0
- package/lib/methods/platform/response/Metadata.js +5 -3
- package/lib/methods/platform/response/Proof.js +1 -0
- package/lib/test/fixtures/getMNListDiffsFixture.js +1 -0
- package/lib/transport/GrpcTransport/GrpcTransport.js +5 -1
- package/lib/transport/JsonRpcTransport/JsonRpcTransport.js +3 -0
- package/lib/transport/JsonRpcTransport/errors/JsonRpcError.js +3 -0
- package/lib/transport/ReconnectableStream.js +9 -0
- package/lib/utils/wait.js +3 -1
- package/package.json +15 -15
|
@@ -39,7 +39,6 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
39
39
|
* @param {Function} [createHistoricalSyncStream]
|
|
40
40
|
* @param {Function} [createContinuousSyncStream]
|
|
41
41
|
*/
|
|
42
|
-
// eslint-disable-next-line default-param-last
|
|
43
42
|
constructor(options = {}, createHistoricalSyncStream, createContinuousSyncStream) {
|
|
44
43
|
super();
|
|
45
44
|
this.options = {
|
|
@@ -103,6 +102,7 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
103
102
|
|
|
104
103
|
/**
|
|
105
104
|
* Initializes SPV chain with a list of headers and a known lastSyncedHeaderHeight
|
|
105
|
+
*
|
|
106
106
|
* @param headers
|
|
107
107
|
* @param firstHeaderHeight
|
|
108
108
|
*/
|
|
@@ -120,6 +120,7 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* Checks whether spv chain has header at specified height and flushes chains if not
|
|
123
|
+
*
|
|
123
124
|
* @private
|
|
124
125
|
* @param height
|
|
125
126
|
*/
|
|
@@ -133,6 +134,7 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
133
134
|
|
|
134
135
|
/**
|
|
135
136
|
* Reads historical block headers
|
|
137
|
+
*
|
|
136
138
|
* @param fromBlockHeight
|
|
137
139
|
* @param toBlockHeight
|
|
138
140
|
* @returns {Promise<void>}
|
|
@@ -21,7 +21,6 @@ class BlockHeadersReader extends EventEmitter {
|
|
|
21
21
|
* @param createHistoricalSyncStream
|
|
22
22
|
* @param createContinuousSyncStream
|
|
23
23
|
*/
|
|
24
|
-
// eslint-disable-next-line default-param-last
|
|
25
24
|
constructor(options = {}, createHistoricalSyncStream, createContinuousSyncStream) {
|
|
26
25
|
super();
|
|
27
26
|
this.createHistoricalSyncStream = createHistoricalSyncStream;
|
|
@@ -32,12 +31,14 @@ class BlockHeadersReader extends EventEmitter {
|
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
33
|
* Holds references to the historical streams
|
|
34
|
+
*
|
|
35
35
|
* @type {Stream[]}
|
|
36
36
|
*/
|
|
37
37
|
this.historicalStreams = [];
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Holds reference to the continuous sync stream
|
|
41
|
+
*
|
|
41
42
|
* @type {Stream}
|
|
42
43
|
*/
|
|
43
44
|
this.continuousSyncStream = null;
|
|
@@ -45,6 +46,7 @@ class BlockHeadersReader extends EventEmitter {
|
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
48
|
* Reads historical block heights using multiple streams
|
|
49
|
+
*
|
|
48
50
|
* @param {number} fromBlockHeight
|
|
49
51
|
* @param {number} toBlockHeight
|
|
50
52
|
* @returns {Promise<void>}
|
|
@@ -90,6 +92,7 @@ class BlockHeadersReader extends EventEmitter {
|
|
|
90
92
|
|
|
91
93
|
/**
|
|
92
94
|
* Subscribes to continuously arriving block headers
|
|
95
|
+
*
|
|
93
96
|
* @param {number} fromBlockHeight
|
|
94
97
|
* @returns {Promise<ReconnectableStream>}
|
|
95
98
|
*/
|
|
@@ -128,6 +131,7 @@ class BlockHeadersReader extends EventEmitter {
|
|
|
128
131
|
|
|
129
132
|
/**
|
|
130
133
|
* Kills stream in case of deliberate rejection from the outside
|
|
134
|
+
*
|
|
131
135
|
* @param e
|
|
132
136
|
*/
|
|
133
137
|
const rejectHeaders = async (e) => {
|
|
@@ -183,8 +187,9 @@ class BlockHeadersReader extends EventEmitter {
|
|
|
183
187
|
/**
|
|
184
188
|
* A HOF that returns a function to subscribe to historical block headers and chain locks
|
|
185
189
|
* and handles retry logic
|
|
190
|
+
*
|
|
186
191
|
* @private
|
|
187
|
-
* @param {number} [maxRetries] - maximum amount of retries
|
|
192
|
+
* @param {number} [maxRetries=0] - maximum amount of retries
|
|
188
193
|
* @returns {function(*, *): Promise<Stream>}
|
|
189
194
|
*/
|
|
190
195
|
createSubscribeToHistoricalBatch(maxRetries = 0) {
|
|
@@ -192,6 +197,7 @@ class BlockHeadersReader extends EventEmitter {
|
|
|
192
197
|
|
|
193
198
|
/**
|
|
194
199
|
* Subscribes to the stream of historical data and handles retry logic
|
|
200
|
+
*
|
|
195
201
|
* @param {number} fromBlockHeight
|
|
196
202
|
* @param {number} count
|
|
197
203
|
* @returns {Promise<Stream>}
|
|
@@ -243,6 +249,7 @@ class BlockHeadersReader extends EventEmitter {
|
|
|
243
249
|
|
|
244
250
|
/**
|
|
245
251
|
* Kills stream in case of deliberate rejection from the outside
|
|
252
|
+
*
|
|
246
253
|
* @param e
|
|
247
254
|
*/
|
|
248
255
|
const rejectHeaders = (e) => {
|
|
@@ -6,7 +6,7 @@ class SimplifiedMasternodeListProvider {
|
|
|
6
6
|
*
|
|
7
7
|
* @param {JsonRpcTransport} jsonRpcTransport - JsonRpcTransport instance
|
|
8
8
|
* @param {object} [options] - Options
|
|
9
|
-
* @param {number} [options.updateInterval]
|
|
9
|
+
* @param {number} [options.updateInterval=60000]
|
|
10
10
|
* @param {string} [options.network]
|
|
11
11
|
*/
|
|
12
12
|
constructor(jsonRpcTransport, options = {}) {
|
|
@@ -26,6 +26,7 @@ class SimplifiedMasternodeListProvider {
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Returns simplified masternode list
|
|
29
|
+
*
|
|
29
30
|
* @returns {Promise<SimplifiedMNList>}
|
|
30
31
|
*/
|
|
31
32
|
async getSimplifiedMNList() {
|
|
@@ -38,6 +39,7 @@ class SimplifiedMasternodeListProvider {
|
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* Checks whether simplified masternode list needs update
|
|
42
|
+
*
|
|
41
43
|
* @private
|
|
42
44
|
* @returns {boolean}
|
|
43
45
|
*/
|
|
@@ -47,6 +49,7 @@ class SimplifiedMasternodeListProvider {
|
|
|
47
49
|
|
|
48
50
|
/**
|
|
49
51
|
* Updates simplified masternodes list. No need to call it manually
|
|
52
|
+
*
|
|
50
53
|
* @private
|
|
51
54
|
*/
|
|
52
55
|
async updateMasternodeList() {
|
|
@@ -73,6 +76,7 @@ class SimplifiedMasternodeListProvider {
|
|
|
73
76
|
|
|
74
77
|
/**
|
|
75
78
|
* Fetches masternode diff from DAPI
|
|
79
|
+
*
|
|
76
80
|
* @private
|
|
77
81
|
* @returns {Promise<SimplifiedMNListDiff>}
|
|
78
82
|
*/
|
|
@@ -90,6 +94,7 @@ class SimplifiedMasternodeListProvider {
|
|
|
90
94
|
|
|
91
95
|
/**
|
|
92
96
|
* Reset simplifiedMNList
|
|
97
|
+
*
|
|
93
98
|
* @private
|
|
94
99
|
*/
|
|
95
100
|
reset() {
|
|
@@ -6,7 +6,6 @@ class DAPIAddress {
|
|
|
6
6
|
*/
|
|
7
7
|
constructor(address) {
|
|
8
8
|
if (address instanceof DAPIAddress) {
|
|
9
|
-
// eslint-disable-next-line no-constructor-return
|
|
10
9
|
return new DAPIAddress(address.toJSON());
|
|
11
10
|
}
|
|
12
11
|
|
|
@@ -38,6 +37,7 @@ class DAPIAddress {
|
|
|
38
37
|
|
|
39
38
|
/**
|
|
40
39
|
* Get protocol
|
|
40
|
+
*
|
|
41
41
|
* @returns {string}
|
|
42
42
|
*/
|
|
43
43
|
getProtocol() {
|
|
@@ -46,6 +46,7 @@ class DAPIAddress {
|
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Get host
|
|
49
|
+
*
|
|
49
50
|
* @returns {string}
|
|
50
51
|
*/
|
|
51
52
|
getHost() {
|
|
@@ -54,6 +55,7 @@ class DAPIAddress {
|
|
|
54
55
|
|
|
55
56
|
/**
|
|
56
57
|
* Set host
|
|
58
|
+
*
|
|
57
59
|
* @param {string} host
|
|
58
60
|
* @returns {DAPIAddress}
|
|
59
61
|
*/
|
|
@@ -65,6 +67,7 @@ class DAPIAddress {
|
|
|
65
67
|
|
|
66
68
|
/**
|
|
67
69
|
* Get port
|
|
70
|
+
*
|
|
68
71
|
* @returns {number}
|
|
69
72
|
*/
|
|
70
73
|
getPort() {
|
|
@@ -73,6 +76,7 @@ class DAPIAddress {
|
|
|
73
76
|
|
|
74
77
|
/**
|
|
75
78
|
* Set port
|
|
79
|
+
*
|
|
76
80
|
* @param {number} port
|
|
77
81
|
* @returns {DAPIAddress}
|
|
78
82
|
*/
|
|
@@ -84,6 +88,7 @@ class DAPIAddress {
|
|
|
84
88
|
|
|
85
89
|
/**
|
|
86
90
|
* Get ProRegTx hash
|
|
91
|
+
*
|
|
87
92
|
* @returns {string}
|
|
88
93
|
*/
|
|
89
94
|
getProRegTxHash() {
|
|
@@ -106,6 +111,7 @@ class DAPIAddress {
|
|
|
106
111
|
|
|
107
112
|
/**
|
|
108
113
|
* Mark address as banned
|
|
114
|
+
*
|
|
109
115
|
* @returns {DAPIAddress}
|
|
110
116
|
*/
|
|
111
117
|
markAsBanned() {
|
|
@@ -117,6 +123,7 @@ class DAPIAddress {
|
|
|
117
123
|
|
|
118
124
|
/**
|
|
119
125
|
* Mark address as live
|
|
126
|
+
*
|
|
120
127
|
* @returns {DAPIAddress}
|
|
121
128
|
*/
|
|
122
129
|
markAsLive() {
|
|
@@ -142,6 +149,7 @@ class DAPIAddress {
|
|
|
142
149
|
|
|
143
150
|
/**
|
|
144
151
|
* Return DAPIAddress as plain object
|
|
152
|
+
*
|
|
145
153
|
* @returns {RawDAPIAddress}
|
|
146
154
|
*/
|
|
147
155
|
toJSON() {
|
|
@@ -17,6 +17,7 @@ class ListDAPIAddressProvider {
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Get random address
|
|
20
|
+
*
|
|
20
21
|
* @returns {Promise<DAPIAddress|undefined>}
|
|
21
22
|
*/
|
|
22
23
|
async getLiveAddress() {
|
|
@@ -46,6 +47,7 @@ class ListDAPIAddressProvider {
|
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
* Get all addresses
|
|
50
|
+
*
|
|
49
51
|
* @returns {DAPIAddress[]}
|
|
50
52
|
*/
|
|
51
53
|
getAllAddresses() {
|
|
@@ -54,6 +56,7 @@ class ListDAPIAddressProvider {
|
|
|
54
56
|
|
|
55
57
|
/**
|
|
56
58
|
* Set addresses
|
|
59
|
+
*
|
|
57
60
|
* @param {DAPIAddress[]} addresses
|
|
58
61
|
* @returns {ListDAPIAddressProvider}
|
|
59
62
|
*/
|
|
@@ -65,6 +68,7 @@ class ListDAPIAddressProvider {
|
|
|
65
68
|
|
|
66
69
|
/**
|
|
67
70
|
* Check if we have live addresses left
|
|
71
|
+
*
|
|
68
72
|
* @returns {Promise<boolean>} - True if there are live address left
|
|
69
73
|
*/
|
|
70
74
|
async hasLiveAddresses() {
|
|
@@ -75,6 +79,7 @@ class ListDAPIAddressProvider {
|
|
|
75
79
|
|
|
76
80
|
/**
|
|
77
81
|
* Get live addresses
|
|
82
|
+
*
|
|
78
83
|
* @returns {DAPIAddress[]}
|
|
79
84
|
*/
|
|
80
85
|
getLiveAddresses() {
|
|
@@ -14,6 +14,7 @@ class SimplifiedMasternodeListDAPIAddressProvider {
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Get random live DAPI address from SML
|
|
17
|
+
*
|
|
17
18
|
* @returns {Promise<DAPIAddress>}
|
|
18
19
|
*/
|
|
19
20
|
async getLiveAddress() {
|
|
@@ -65,6 +66,7 @@ class SimplifiedMasternodeListDAPIAddressProvider {
|
|
|
65
66
|
|
|
66
67
|
/**
|
|
67
68
|
* Check if we have live addresses left
|
|
69
|
+
*
|
|
68
70
|
* @returns {Promise<boolean>}
|
|
69
71
|
*/
|
|
70
72
|
async hasLiveAddresses() {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
function generateToAddressFactory(jsonRpcTransport) {
|
|
6
6
|
/**
|
|
7
7
|
* ONLY FOR TESTING PURPOSES WITH REGTEST. WILL NOT WORK ON TESTNET/LIVENET.
|
|
8
|
+
*
|
|
8
9
|
* @typedef {generateToAddress}
|
|
9
10
|
* @param {number} blocksNumber - Number of blocks to generate
|
|
10
11
|
* @param {string} address - The address that will receive the newly generated Dash
|
|
@@ -22,6 +22,7 @@ class GetTransactionResponse {
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Get transaction
|
|
25
|
+
*
|
|
25
26
|
* @returns {Buffer}
|
|
26
27
|
*/
|
|
27
28
|
getTransaction() {
|
|
@@ -30,6 +31,7 @@ class GetTransactionResponse {
|
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Get block hash
|
|
34
|
+
*
|
|
33
35
|
* @returns {Buffer}
|
|
34
36
|
*/
|
|
35
37
|
getBlockHash() {
|
|
@@ -38,6 +40,7 @@ class GetTransactionResponse {
|
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
42
|
* Get height
|
|
43
|
+
*
|
|
41
44
|
* @returns {number}
|
|
42
45
|
*/
|
|
43
46
|
getHeight() {
|
|
@@ -46,6 +49,7 @@ class GetTransactionResponse {
|
|
|
46
49
|
|
|
47
50
|
/**
|
|
48
51
|
* Get number of confirmations
|
|
52
|
+
*
|
|
49
53
|
* @returns {number}
|
|
50
54
|
*/
|
|
51
55
|
getConfirmations() {
|
|
@@ -54,6 +58,7 @@ class GetTransactionResponse {
|
|
|
54
58
|
|
|
55
59
|
/**
|
|
56
60
|
* Is transaction instant locked
|
|
61
|
+
*
|
|
57
62
|
* @returns {boolean}
|
|
58
63
|
*/
|
|
59
64
|
isInstantLocked() {
|
|
@@ -62,6 +67,7 @@ class GetTransactionResponse {
|
|
|
62
67
|
|
|
63
68
|
/**
|
|
64
69
|
* Is transaction chain locked
|
|
70
|
+
*
|
|
65
71
|
* @returns {boolean}
|
|
66
72
|
*/
|
|
67
73
|
isChainLocked() {
|
|
@@ -15,6 +15,7 @@ const InvalidResponseError = require('../../platform/response/errors/InvalidResp
|
|
|
15
15
|
function getTransactionFactory(grpcTransport) {
|
|
16
16
|
/**
|
|
17
17
|
* Get Transaction by ID
|
|
18
|
+
*
|
|
18
19
|
* @typedef {getTransaction}
|
|
19
20
|
* @param {string} id
|
|
20
21
|
* @param {DAPIClientOptions} [options]
|
|
@@ -14,6 +14,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
|
14
14
|
function broadcastStateTransitionFactory(grpcTransport) {
|
|
15
15
|
/**
|
|
16
16
|
* Broadcast State Transaction
|
|
17
|
+
*
|
|
17
18
|
* @typedef {broadcastStateTransition}
|
|
18
19
|
* @param {Buffer} stateTransition
|
|
19
20
|
* @param {DAPIClientOptions} [options]
|
|
@@ -15,6 +15,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
|
15
15
|
function getDataContractFactory(grpcTransport) {
|
|
16
16
|
/**
|
|
17
17
|
* Fetch Data Contract by id
|
|
18
|
+
*
|
|
18
19
|
* @typedef {getDataContract}
|
|
19
20
|
* @param {Buffer} contractId
|
|
20
21
|
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
|
@@ -16,6 +16,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
|
16
16
|
function getDataContractHistoryFactory(grpcTransport) {
|
|
17
17
|
/**
|
|
18
18
|
* Fetch Data Contract by id
|
|
19
|
+
*
|
|
19
20
|
* @typedef {getDataContractHistory}
|
|
20
21
|
* @param {Buffer} contractId
|
|
21
22
|
* @param {number} [startAtMs]
|
|
@@ -17,6 +17,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
|
17
17
|
function getDocumentsFactory(grpcTransport) {
|
|
18
18
|
/**
|
|
19
19
|
* Fetch Documents from Drive
|
|
20
|
+
*
|
|
20
21
|
* @typedef {getDocuments}
|
|
21
22
|
* @param {Buffer} contractId - Data Contract ID
|
|
22
23
|
* @param {string} type - Document type
|
package/lib/methods/platform/getIdentitiesByPublicKeyHashes/getIdentitiesByPublicKeyHashesFactory.js
CHANGED
|
@@ -15,6 +15,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
|
15
15
|
function getIdentitiesByPublicKeyHashesFactory(grpcTransport) {
|
|
16
16
|
/**
|
|
17
17
|
* Fetch the identities by public key hashes
|
|
18
|
+
*
|
|
18
19
|
* @typedef {getIdentitiesByPublicKeyHashes}
|
|
19
20
|
* @param {Buffer[]} publicKeyHashes
|
|
20
21
|
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
|
@@ -15,6 +15,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
|
15
15
|
function getIdentityFactory(grpcTransport) {
|
|
16
16
|
/**
|
|
17
17
|
* Fetch the identity by id
|
|
18
|
+
*
|
|
18
19
|
* @typedef {getIdentity}
|
|
19
20
|
* @param {Buffer} id
|
|
20
21
|
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
package/lib/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.js
CHANGED
|
@@ -15,6 +15,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
|
15
15
|
function getProtocolVersionUpgradeStateFactory(grpcTransport) {
|
|
16
16
|
/**
|
|
17
17
|
* Fetch the version upgrade state
|
|
18
|
+
*
|
|
18
19
|
* @typedef {getProtocolVersionUpgradeState}
|
|
19
20
|
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
|
20
21
|
* @returns {Promise<GetProtocolVersionUpgradeStateResponse>}
|
|
@@ -15,6 +15,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
|
15
15
|
function getProtocolVersionUpgradeVoteStatusFactory(grpcTransport) {
|
|
16
16
|
/**
|
|
17
17
|
* Fetch the version upgrade vote status
|
|
18
|
+
*
|
|
18
19
|
* @typedef {getProtocolVersionUpgradeVoteStatus}
|
|
19
20
|
* @param {string} startProTxHash
|
|
20
21
|
* @param {number} count
|
|
@@ -1,6 +1,6 @@
|
|
|
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
6
|
* @param {number} properties.timeMs - block time
|
|
@@ -15,6 +15,7 @@ class Metadata {
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Get height
|
|
18
|
+
*
|
|
18
19
|
* @returns {number} - block height
|
|
19
20
|
*/
|
|
20
21
|
getHeight() {
|
|
@@ -23,6 +24,7 @@ class Metadata {
|
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Get core chain locked height
|
|
27
|
+
*
|
|
26
28
|
* @returns {number} - core chain locked height
|
|
27
29
|
*/
|
|
28
30
|
getCoreChainLockedHeight() {
|
|
@@ -31,7 +33,7 @@ class Metadata {
|
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* Get block time
|
|
34
|
-
* @
|
|
36
|
+
* @return {number}
|
|
35
37
|
*/
|
|
36
38
|
getTimeMs() {
|
|
37
39
|
return this.timeMs;
|
|
@@ -39,7 +41,7 @@ class Metadata {
|
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
43
|
* Get protocol version
|
|
42
|
-
* @
|
|
44
|
+
* @return {number}
|
|
43
45
|
*/
|
|
44
46
|
getProtocolVersion() {
|
|
45
47
|
return this.protocolVersion;
|
|
@@ -34,10 +34,12 @@ class GrpcTransport {
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Make request to DAPI node
|
|
37
|
+
*
|
|
37
38
|
* @param {Function} ClientClass
|
|
38
39
|
* @param {string} method
|
|
39
40
|
* @param {object} requestMessage
|
|
40
41
|
* @param {DAPIClientOptions} [options]
|
|
42
|
+
*
|
|
41
43
|
* @returns {Promise<object>}
|
|
42
44
|
*/
|
|
43
45
|
async request(ClientClass, method, requestMessage, options = { }) {
|
|
@@ -121,6 +123,7 @@ class GrpcTransport {
|
|
|
121
123
|
|
|
122
124
|
/**
|
|
123
125
|
* Get last used address
|
|
126
|
+
*
|
|
124
127
|
* @returns {DAPIAddress|null}
|
|
125
128
|
*/
|
|
126
129
|
getLastUsedAddress() {
|
|
@@ -129,7 +132,8 @@ class GrpcTransport {
|
|
|
129
132
|
|
|
130
133
|
/**
|
|
131
134
|
*
|
|
132
|
-
*Get gRPC url string
|
|
135
|
+
* Get gRPC url string
|
|
136
|
+
*
|
|
133
137
|
* @private
|
|
134
138
|
* @param {DAPIAddress} address
|
|
135
139
|
* @returns {string}
|
|
@@ -38,9 +38,11 @@ class JsonRpcTransport {
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Make request to DAPI node
|
|
41
|
+
*
|
|
41
42
|
* @param {string} method
|
|
42
43
|
* @param {object} [params]
|
|
43
44
|
* @param {DAPIClientOptions} [options]
|
|
45
|
+
*
|
|
44
46
|
* @returns {Promise<object>}
|
|
45
47
|
*/
|
|
46
48
|
async request(method, params = {}, options = {}) {
|
|
@@ -120,6 +122,7 @@ class JsonRpcTransport {
|
|
|
120
122
|
|
|
121
123
|
/**
|
|
122
124
|
* Get last used address
|
|
125
|
+
*
|
|
123
126
|
* @returns {DAPIAddress|null}
|
|
124
127
|
*/
|
|
125
128
|
getLastUsedAddress() {
|
|
@@ -30,6 +30,7 @@ class JsonRpcError extends DAPIClientError {
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Get error message
|
|
33
|
+
*
|
|
33
34
|
* @returns {string}
|
|
34
35
|
*/
|
|
35
36
|
getMessage() {
|
|
@@ -38,6 +39,7 @@ class JsonRpcError extends DAPIClientError {
|
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* Get error data
|
|
42
|
+
*
|
|
41
43
|
* @returns {object}
|
|
42
44
|
*/
|
|
43
45
|
getData() {
|
|
@@ -46,6 +48,7 @@ class JsonRpcError extends DAPIClientError {
|
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
50
|
* Get original error code
|
|
51
|
+
*
|
|
49
52
|
* @returns {number}
|
|
50
53
|
*/
|
|
51
54
|
getCode() {
|
|
@@ -36,6 +36,7 @@ const EVENTS = {
|
|
|
36
36
|
class ReconnectableStream extends EventEmitter {
|
|
37
37
|
/**
|
|
38
38
|
* Helper that wraps stream creation function and performs auto connection
|
|
39
|
+
*
|
|
39
40
|
* @param {Function} createStreamFunction - function returning grpc-js/grpc-web stream
|
|
40
41
|
* @param {ReconnectableStreamOptions} options
|
|
41
42
|
* @returns {function(...[*]): Promise<ReconnectableStream>}
|
|
@@ -60,6 +61,7 @@ class ReconnectableStream extends EventEmitter {
|
|
|
60
61
|
/**
|
|
61
62
|
* Auto-reconnect interval in millisecond
|
|
62
63
|
* It is needed to automatically reconnect to another DAPI node
|
|
64
|
+
*
|
|
63
65
|
* @type {number}
|
|
64
66
|
*/
|
|
65
67
|
this.autoReconnectInterval = opts.autoReconnectInterval;
|
|
@@ -153,6 +155,7 @@ class ReconnectableStream extends EventEmitter {
|
|
|
153
155
|
* Function that adds EventEmitter style listeners
|
|
154
156
|
* to the stream and also rewires stream cancel function
|
|
155
157
|
* in order to automatically unsubscribe from events
|
|
158
|
+
*
|
|
156
159
|
* @private
|
|
157
160
|
*/
|
|
158
161
|
addListeners() {
|
|
@@ -175,6 +178,7 @@ class ReconnectableStream extends EventEmitter {
|
|
|
175
178
|
|
|
176
179
|
/**
|
|
177
180
|
* stream.on('data') handler
|
|
181
|
+
*
|
|
178
182
|
* @param data
|
|
179
183
|
*/
|
|
180
184
|
dataHandler(data) {
|
|
@@ -183,6 +187,7 @@ class ReconnectableStream extends EventEmitter {
|
|
|
183
187
|
|
|
184
188
|
/**
|
|
185
189
|
* stream.on('end') handler
|
|
190
|
+
*
|
|
186
191
|
* @private
|
|
187
192
|
*/
|
|
188
193
|
endHandler() {
|
|
@@ -193,6 +198,7 @@ class ReconnectableStream extends EventEmitter {
|
|
|
193
198
|
|
|
194
199
|
/**
|
|
195
200
|
* stream.on('error') handler
|
|
201
|
+
*
|
|
196
202
|
* @private
|
|
197
203
|
* @param e
|
|
198
204
|
*/
|
|
@@ -209,6 +215,7 @@ class ReconnectableStream extends EventEmitter {
|
|
|
209
215
|
|
|
210
216
|
/**
|
|
211
217
|
* Manages retry logic
|
|
218
|
+
*
|
|
212
219
|
* @param e
|
|
213
220
|
*/
|
|
214
221
|
retryOnError(e) {
|
|
@@ -249,6 +256,7 @@ class ReconnectableStream extends EventEmitter {
|
|
|
249
256
|
|
|
250
257
|
/**
|
|
251
258
|
* Stops auto reconnect timeout
|
|
259
|
+
*
|
|
252
260
|
* @private
|
|
253
261
|
*/
|
|
254
262
|
stopAutoReconnect() {
|
|
@@ -262,6 +270,7 @@ class ReconnectableStream extends EventEmitter {
|
|
|
262
270
|
* Cancels stream.
|
|
263
271
|
* Returns `stream.cancel()` to handle it from parent if needed.
|
|
264
272
|
* (grpc-js cancel() is asynchronous and grpc-web is synchronous)
|
|
273
|
+
*
|
|
265
274
|
* @returns {*}
|
|
266
275
|
*/
|
|
267
276
|
cancel() {
|
package/lib/utils/wait.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Asynchronously wait for a specified number of milliseconds.
|
|
3
|
+
*
|
|
3
4
|
* @param {number} ms - Number of milliseconds to wait.
|
|
5
|
+
*
|
|
4
6
|
* @returns {Promise<void>} The promise to await on.
|
|
5
7
|
*/
|
|
6
8
|
async function wait(ms) {
|
|
7
|
-
return new Promise((resolve) =>
|
|
9
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
module.exports = wait;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-client",
|
|
3
|
-
"version": "0.25.16-pr.
|
|
3
|
+
"version": "0.25.16-pr.1574.2",
|
|
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": "0.25.16-pr.
|
|
30
|
-
"@dashevo/dash-spv": "0.25.16-pr.
|
|
29
|
+
"@dashevo/dapi-grpc": "0.25.16-pr.1574.2",
|
|
30
|
+
"@dashevo/dash-spv": "0.25.16-pr.1574.2",
|
|
31
31
|
"@dashevo/dashcore-lib": "~0.21.0",
|
|
32
|
-
"@dashevo/grpc-common": "0.25.16-pr.
|
|
33
|
-
"@dashevo/wasm-dpp": "0.25.16-pr.
|
|
32
|
+
"@dashevo/grpc-common": "0.25.16-pr.1574.2",
|
|
33
|
+
"@dashevo/wasm-dpp": "0.25.16-pr.1574.2",
|
|
34
34
|
"bs58": "^4.0.1",
|
|
35
35
|
"cbor": "^8.0.0",
|
|
36
36
|
"google-protobuf": "^3.12.2",
|
|
@@ -41,21 +41,21 @@
|
|
|
41
41
|
"winston": "^3.2.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "^7.
|
|
44
|
+
"@babel/core": "^7.15.5",
|
|
45
45
|
"assert-browserify": "^2.0.0",
|
|
46
|
-
"babel-loader": "^
|
|
46
|
+
"babel-loader": "^8.2.2",
|
|
47
47
|
"browserify-zlib": "^0.2.0",
|
|
48
48
|
"buffer": "^6.0.3",
|
|
49
|
-
"chai": "^4.3.
|
|
49
|
+
"chai": "^4.3.9",
|
|
50
50
|
"chai-as-promised": "^7.1.1",
|
|
51
51
|
"comment-parser": "^0.7.6",
|
|
52
|
-
"core-js": "^3.
|
|
52
|
+
"core-js": "^3.17.2",
|
|
53
53
|
"crypto-browserify": "^3.12.0",
|
|
54
54
|
"dirty-chai": "^2.0.1",
|
|
55
|
-
"eslint": "^
|
|
56
|
-
"eslint-config-airbnb-base": "^
|
|
57
|
-
"eslint-plugin-import": "^2.
|
|
58
|
-
"eslint-plugin-jsdoc": "^
|
|
55
|
+
"eslint": "^7.32.0",
|
|
56
|
+
"eslint-config-airbnb-base": "^14.2.1",
|
|
57
|
+
"eslint-plugin-import": "^2.24.2",
|
|
58
|
+
"eslint-plugin-jsdoc": "^27.0.0",
|
|
59
59
|
"events": "^3.3.0",
|
|
60
60
|
"karma": "^6.4.1",
|
|
61
61
|
"karma-chai": "^0.1.0",
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
"path-browserify": "^1.0.1",
|
|
71
71
|
"process": "^0.11.10",
|
|
72
72
|
"setimmediate": "^1.0.5",
|
|
73
|
-
"sinon": "^
|
|
73
|
+
"sinon": "^11.1.2",
|
|
74
74
|
"sinon-chai": "^3.7.0",
|
|
75
75
|
"stream-browserify": "^3.0.0",
|
|
76
76
|
"string_decoder": "^1.3.0",
|
|
77
|
-
"url": "^0.11.
|
|
77
|
+
"url": "^0.11.0",
|
|
78
78
|
"util": "^0.12.4",
|
|
79
79
|
"webpack": "^5.76.1",
|
|
80
80
|
"webpack-cli": "^4.9.1"
|