@dashevo/dapi-client 1.8.0 → 2.0.0-rc.1
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 -13
- package/lib/SimplifiedMasternodeListProvider/createMasternodeListStreamFactory.js +2 -3
- package/lib/methods/platform/getDataContractHistory/DataContractHistoryEntry.js +26 -0
- package/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.js +8 -14
- package/lib/methods/platform/getDataContractHistory/getDataContractHistoryFactory.js +3 -3
- package/lib/methods/platform/getEpochsInfo/EpochInfo.js +4 -4
- package/lib/methods/platform/getEpochsInfo/GetEpochsInfoResponse.js +2 -2
- package/lib/methods/platform/getIdentityBalance/GetIdentityBalanceResponse.js +3 -3
- package/lib/methods/platform/getIdentityContractNonce/GetIdentityContractNonceResponse.js +5 -5
- package/lib/methods/platform/getIdentityKeys/getIdentityKeysFactory.js +15 -6
- package/lib/methods/platform/getIdentityNonce/GetIdentityNonceResponse.js +5 -5
- package/lib/methods/platform/getStatus/ChainStatus.js +99 -0
- package/lib/methods/platform/getStatus/GetStatusResponse.js +164 -0
- package/lib/methods/platform/getStatus/NetworkStatus.js +35 -0
- package/lib/methods/platform/getStatus/NodeStatus.js +26 -0
- package/lib/methods/platform/getStatus/StateSyncStatus.js +89 -0
- package/lib/methods/platform/getStatus/TimeStatus.js +49 -0
- package/lib/methods/platform/getStatus/VersionStatus.js +79 -0
- package/lib/methods/platform/getStatus/getStatusFactory.js +6 -6
- package/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js +3 -3
- package/lib/methods/platform/response/AbstractResponse.js +6 -1
- package/lib/methods/platform/response/Metadata.js +6 -6
- package/lib/methods/platform/waitForStateTransitionResult/ErrorResult.js +2 -2
- package/lib/methods/platform/waitForStateTransitionResult/WaitForStateTransitionResultResponse.js +3 -5
- package/lib/test/fixtures/getMetadataFixture.js +6 -7
- package/lib/test/fixtures/getStatusFixture.js +62 -0
- package/package.json +8 -7
|
@@ -5,9 +5,10 @@ const BlockHeadersReader = require('./BlockHeadersReader');
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {BlockHeadersProviderOptions} BlockHeadersProviderOptions
|
|
8
|
-
* @property {string} [network=testnet]
|
|
8
|
+
* @property {string} [network='testnet'] network type
|
|
9
9
|
* @property {number} [maxParallelStreams=5] max parallel streams to read historical block headers
|
|
10
10
|
* @property {number} [targetBatchSize=100000] a target batch size per stream
|
|
11
|
+
* @property {number} [fromBlockHeight=1] a target batch size per stream
|
|
11
12
|
* @property {number} [maxRetries=10] max amount of retries per stream connection
|
|
12
13
|
*/
|
|
13
14
|
const defaultOptions = {
|
|
@@ -35,9 +36,9 @@ const STATES = {
|
|
|
35
36
|
|
|
36
37
|
class BlockHeadersProvider extends EventEmitter {
|
|
37
38
|
/**
|
|
38
|
-
* @param {BlockHeadersProviderOptions} options
|
|
39
|
-
* @param {Function} [createHistoricalSyncStream]
|
|
40
|
-
* @param {Function} [createContinuousSyncStream]
|
|
39
|
+
* @param {BlockHeadersProviderOptions} options for block headers
|
|
40
|
+
* @param {Function} [createHistoricalSyncStream] createHistoricalSyncStream
|
|
41
|
+
* @param {Function} [createContinuousSyncStream] createContinuousSyncStream
|
|
41
42
|
*/
|
|
42
43
|
// TODO move options to as last param
|
|
43
44
|
// eslint-disable-next-line default-param-last
|
|
@@ -60,7 +61,7 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
|
-
* @param {BlockHeadersReader} blockHeadersReader
|
|
64
|
+
* @param {BlockHeadersReader} blockHeadersReader instance
|
|
64
65
|
*/
|
|
65
66
|
setBlockHeadersReader(blockHeadersReader) {
|
|
66
67
|
this.blockHeadersReader = blockHeadersReader;
|
|
@@ -68,7 +69,7 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
71
|
*
|
|
71
|
-
* @param {SpvChain} spvChain
|
|
72
|
+
* @param {SpvChain} spvChain instance
|
|
72
73
|
*/
|
|
73
74
|
setSpvChain(spvChain) {
|
|
74
75
|
this.spvChain = spvChain;
|
|
@@ -104,8 +105,8 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
104
105
|
|
|
105
106
|
/**
|
|
106
107
|
* Initializes SPV chain with a list of headers and a known lastSyncedHeaderHeight
|
|
107
|
-
* @param headers
|
|
108
|
-
* @param firstHeaderHeight
|
|
108
|
+
* @param {BlockHeader[]} headers array of headers
|
|
109
|
+
* @param firstHeaderHeight {number} first block header height
|
|
109
110
|
*/
|
|
110
111
|
async initializeChainWith(headers, firstHeaderHeight) {
|
|
111
112
|
await SpvChain.wasmX11Ready();
|
|
@@ -122,7 +123,7 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
122
123
|
/**
|
|
123
124
|
* Checks whether spv chain has header at specified height and flushes chains if not
|
|
124
125
|
* @private
|
|
125
|
-
* @param height
|
|
126
|
+
* @param {number} height block height
|
|
126
127
|
*/
|
|
127
128
|
ensureChainRoot(height) {
|
|
128
129
|
// Flush spv chain in case header at specified height was not found
|
|
@@ -134,8 +135,8 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
134
135
|
|
|
135
136
|
/**
|
|
136
137
|
* Reads historical block headers
|
|
137
|
-
* @param fromBlockHeight
|
|
138
|
-
* @param toBlockHeight
|
|
138
|
+
* @param {number} fromBlockHeight height block height
|
|
139
|
+
* @param {number} toBlockHeight height block height
|
|
139
140
|
* @returns {Promise<void>}
|
|
140
141
|
*/
|
|
141
142
|
async readHistorical(fromBlockHeight, toBlockHeight) {
|
|
@@ -196,8 +197,8 @@ class BlockHeadersProvider extends EventEmitter {
|
|
|
196
197
|
|
|
197
198
|
/**
|
|
198
199
|
* @private
|
|
199
|
-
* @param headersData
|
|
200
|
-
* @param reject
|
|
200
|
+
* @param {object} headersData object with header and headHeight
|
|
201
|
+
* @param {function} reject callback function
|
|
201
202
|
*/
|
|
202
203
|
headersHandler(headersData, reject) {
|
|
203
204
|
const { headers, headHeight } = headersData;
|
|
@@ -11,11 +11,10 @@ const ReconnectableStream = require('../transport/ReconnectableStream');
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Creates continues masternode list stream
|
|
14
|
-
*
|
|
15
14
|
* @param {createDAPIAddressProviderFromOptions} createDAPIAddressProviderFromOptions
|
|
16
15
|
* @param {ListDAPIAddressProvider} listDAPIAddressProvider
|
|
17
|
-
* @param {
|
|
18
|
-
* @
|
|
16
|
+
* @param {object} options
|
|
17
|
+
* @returns {function(...[*]): Promise<ReconnectableStream>}
|
|
19
18
|
*/
|
|
20
19
|
function createMasternodeListStreamFactory(
|
|
21
20
|
createDAPIAddressProviderFromOptions,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class DataContractHistoryEntry {
|
|
2
|
+
/**
|
|
3
|
+
* @param {bigint} date - timestamp
|
|
4
|
+
* @param {Buffer} value - buffer value of the data contract
|
|
5
|
+
*/
|
|
6
|
+
constructor(date, value) {
|
|
7
|
+
this.date = date;
|
|
8
|
+
this.value = value;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @returns {bigint} - date
|
|
13
|
+
*/
|
|
14
|
+
getDate() {
|
|
15
|
+
return this.date;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @returns {Buffer} - raw binary value of the data contract
|
|
20
|
+
*/
|
|
21
|
+
getValue() {
|
|
22
|
+
return this.value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = DataContractHistoryEntry;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
const AbstractResponse = require('../response/AbstractResponse');
|
|
2
2
|
const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
3
|
+
const DataContractHistoryEntry = require('./DataContractHistoryEntry');
|
|
3
4
|
|
|
4
5
|
class GetDataContractHistoryResponse extends AbstractResponse {
|
|
5
6
|
/**
|
|
6
|
-
* @param {
|
|
7
|
+
* @param {DataContractHistoryEntry[]} dataContractHistory
|
|
7
8
|
* @param {Metadata} metadata
|
|
8
9
|
* @param {Proof} [proof]
|
|
9
10
|
*/
|
|
@@ -14,7 +15,7 @@ class GetDataContractHistoryResponse extends AbstractResponse {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
* @returns {
|
|
18
|
+
* @returns {DataContractHistoryEntry[]} array of data contract history entries
|
|
18
19
|
*/
|
|
19
20
|
getDataContractHistory() {
|
|
20
21
|
return this.dataContractHistory;
|
|
@@ -33,19 +34,12 @@ class GetDataContractHistoryResponse extends AbstractResponse {
|
|
|
33
34
|
throw new InvalidResponseError('DataContract is not defined');
|
|
34
35
|
}
|
|
35
36
|
|
|
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
37
|
return new GetDataContractHistoryResponse(
|
|
48
|
-
|
|
38
|
+
dataContractHistory ? dataContractHistory.getDataContractEntriesList()
|
|
39
|
+
.map((dataContractHistoryEntry) => new DataContractHistoryEntry(
|
|
40
|
+
BigInt(dataContractHistoryEntry.getDate()),
|
|
41
|
+
dataContractHistoryEntry.getValue(),
|
|
42
|
+
)) : null,
|
|
49
43
|
metadata,
|
|
50
44
|
proof,
|
|
51
45
|
);
|
|
@@ -18,7 +18,7 @@ function getDataContractHistoryFactory(grpcTransport) {
|
|
|
18
18
|
* Fetch Data Contract by id
|
|
19
19
|
* @typedef {getDataContractHistory}
|
|
20
20
|
* @param {Buffer} contractId
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {bigint} [startAtMs]
|
|
22
22
|
* @param {number} [limit]
|
|
23
23
|
* @param {number} [offset]
|
|
24
24
|
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
|
@@ -26,7 +26,7 @@ function getDataContractHistoryFactory(grpcTransport) {
|
|
|
26
26
|
*/
|
|
27
27
|
async function getDataContractHistory(
|
|
28
28
|
contractId,
|
|
29
|
-
startAtMs = 0,
|
|
29
|
+
startAtMs = BigInt(0),
|
|
30
30
|
limit = 10,
|
|
31
31
|
offset = 0,
|
|
32
32
|
options = {},
|
|
@@ -45,7 +45,7 @@ function getDataContractHistoryFactory(grpcTransport) {
|
|
|
45
45
|
getDataContractHistoryRequest.setV0(
|
|
46
46
|
new GetDataContractHistoryRequestV0()
|
|
47
47
|
.setId(contractId)
|
|
48
|
-
.setStartAtMs(startAtMs)
|
|
48
|
+
.setStartAtMs(startAtMs.toString())
|
|
49
49
|
.setLimit(new UInt32Value([limit]))
|
|
50
50
|
.setOffset(new UInt32Value([offset]))
|
|
51
51
|
.setProve(!!options.prove),
|
|
@@ -2,9 +2,9 @@ class EpochInfo {
|
|
|
2
2
|
/**
|
|
3
3
|
*
|
|
4
4
|
* @param {number} number
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {bigint} firstBlockHeight
|
|
6
6
|
* @param {number} firstCoreBlockHeight
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {bigint} startTime
|
|
8
8
|
* @param {number} feeMultiplier
|
|
9
9
|
*/
|
|
10
10
|
constructor(number, firstBlockHeight, firstCoreBlockHeight, startTime, feeMultiplier) {
|
|
@@ -23,7 +23,7 @@ class EpochInfo {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* @returns {
|
|
26
|
+
* @returns {bigint}
|
|
27
27
|
*/
|
|
28
28
|
getFirstBlockHeight() {
|
|
29
29
|
return this.firstBlockHeight;
|
|
@@ -37,7 +37,7 @@ class EpochInfo {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* @returns {
|
|
40
|
+
* @returns {bigint}
|
|
41
41
|
*/
|
|
42
42
|
getStartTime() {
|
|
43
43
|
return this.startTime;
|
|
@@ -41,9 +41,9 @@ class GetEpochsInfoResponse extends AbstractResponse {
|
|
|
41
41
|
if (epochsInfoList) {
|
|
42
42
|
epochsInfo = epochsInfoList.map((epoch) => new EpochInfo(
|
|
43
43
|
epoch.getNumber(),
|
|
44
|
-
epoch.getFirstBlockHeight(),
|
|
44
|
+
BigInt(epoch.getFirstBlockHeight()),
|
|
45
45
|
epoch.getFirstCoreBlockHeight(),
|
|
46
|
-
epoch.getStartTime(),
|
|
46
|
+
BigInt(epoch.getStartTime()),
|
|
47
47
|
epoch.getFeeMultiplier(),
|
|
48
48
|
));
|
|
49
49
|
}
|
|
@@ -3,7 +3,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
|
3
3
|
|
|
4
4
|
class GetIdentityBalanceResponse extends AbstractResponse {
|
|
5
5
|
/**
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {bigint} balance
|
|
7
7
|
* @param {Metadata} metadata
|
|
8
8
|
* @param {Proof} [proof]
|
|
9
9
|
*/
|
|
@@ -14,7 +14,7 @@ class GetIdentityBalanceResponse extends AbstractResponse {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* @returns {
|
|
17
|
+
* @returns {bigint}
|
|
18
18
|
*/
|
|
19
19
|
getBalance() {
|
|
20
20
|
return this.balance;
|
|
@@ -25,7 +25,7 @@ class GetIdentityBalanceResponse extends AbstractResponse {
|
|
|
25
25
|
* @returns {GetIdentityBalanceResponse}
|
|
26
26
|
*/
|
|
27
27
|
static createFromProto(proto) {
|
|
28
|
-
const balance = proto.getV0().getBalance();
|
|
28
|
+
const balance = BigInt(proto.getV0().getBalance());
|
|
29
29
|
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(proto);
|
|
30
30
|
|
|
31
31
|
if ((balance === null || balance === undefined) && !proof) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const AbstractResponse = require('../response/AbstractResponse');
|
|
2
2
|
const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
3
3
|
|
|
4
|
-
const IDENTITY_CONTRACT_NONCE_VALUE_FILTER = 0xFFFFFFFFFF;
|
|
4
|
+
const IDENTITY_CONTRACT_NONCE_VALUE_FILTER = BigInt(0xFFFFFFFFFF);
|
|
5
5
|
|
|
6
6
|
class GetIdentityContractNonceResponse extends AbstractResponse {
|
|
7
7
|
/**
|
|
8
|
-
* @param {
|
|
8
|
+
* @param {bigint} identityContractNonce
|
|
9
9
|
* @param {Metadata} metadata
|
|
10
10
|
* @param {Proof} [proof]
|
|
11
11
|
*/
|
|
@@ -16,7 +16,7 @@ class GetIdentityContractNonceResponse extends AbstractResponse {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @returns {
|
|
19
|
+
* @returns {bigint}
|
|
20
20
|
*/
|
|
21
21
|
getIdentityContractNonce() {
|
|
22
22
|
return this.identityContractNonce;
|
|
@@ -28,8 +28,8 @@ class GetIdentityContractNonceResponse extends AbstractResponse {
|
|
|
28
28
|
*/
|
|
29
29
|
static createFromProto(proto) {
|
|
30
30
|
// eslint-disable-next-line
|
|
31
|
-
const identityContractNonce = proto.getV0()
|
|
32
|
-
.getIdentityContractNonce() & IDENTITY_CONTRACT_NONCE_VALUE_FILTER;
|
|
31
|
+
const identityContractNonce = BigInt(proto.getV0()
|
|
32
|
+
.getIdentityContractNonce()) & IDENTITY_CONTRACT_NONCE_VALUE_FILTER;
|
|
33
33
|
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(
|
|
34
34
|
proto,
|
|
35
35
|
);
|
|
@@ -4,10 +4,14 @@ const {
|
|
|
4
4
|
GetIdentityKeysRequest,
|
|
5
5
|
KeyRequestType,
|
|
6
6
|
SpecificKeys,
|
|
7
|
+
AllKeys,
|
|
7
8
|
},
|
|
8
9
|
} = require('@dashevo/dapi-grpc');
|
|
10
|
+
|
|
9
11
|
const { UInt32Value } = require('google-protobuf/google/protobuf/wrappers_pb');
|
|
10
12
|
|
|
13
|
+
const { GetIdentityKeysRequestV0 } = GetIdentityKeysRequest;
|
|
14
|
+
|
|
11
15
|
const GetIdentityKeysResponse = require('./GetIdentityKeysResponse');
|
|
12
16
|
const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
13
17
|
|
|
@@ -20,25 +24,30 @@ function getIdentityKeysFactory(grpcTransport) {
|
|
|
20
24
|
* Fetch the version upgrade votes status
|
|
21
25
|
* @typedef {getIdentityKeys}
|
|
22
26
|
* @param {Buffer} identityId
|
|
23
|
-
* @param {number[]} keyIds
|
|
27
|
+
* @param {number[]=} keyIds
|
|
24
28
|
* @param {number} limit
|
|
25
29
|
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
|
26
30
|
* @returns {Promise<GetIdentityKeysResponse>}
|
|
27
31
|
*/
|
|
28
32
|
async function getIdentityKeys(identityId, keyIds, limit = 100, options = {}) {
|
|
29
|
-
const { GetIdentityKeysRequestV0 } = GetIdentityKeysRequest;
|
|
30
|
-
const getIdentityKeysRequest = new GetIdentityKeysRequest();
|
|
31
|
-
|
|
32
33
|
if (Buffer.isBuffer(identityId)) {
|
|
33
34
|
// eslint-disable-next-line no-param-reassign
|
|
34
35
|
identityId = Buffer.from(identityId);
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
const getIdentityKeysRequest = new GetIdentityKeysRequest();
|
|
39
|
+
const requestType = new KeyRequestType();
|
|
40
|
+
|
|
41
|
+
if (keyIds) {
|
|
42
|
+
requestType.setSpecificKeys(new SpecificKeys().setKeyIdsList(keyIds));
|
|
43
|
+
} else {
|
|
44
|
+
requestType.setAllKeys(new AllKeys());
|
|
45
|
+
}
|
|
46
|
+
|
|
37
47
|
getIdentityKeysRequest.setV0(
|
|
38
48
|
new GetIdentityKeysRequestV0()
|
|
39
49
|
.setIdentityId(identityId)
|
|
40
|
-
.setRequestType(
|
|
41
|
-
.setSpecificKeys(new SpecificKeys().setKeyIdsList(keyIds)))
|
|
50
|
+
.setRequestType(requestType)
|
|
42
51
|
.setLimit(new UInt32Value([limit]))
|
|
43
52
|
.setProve(!!options.prove),
|
|
44
53
|
);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const AbstractResponse = require('../response/AbstractResponse');
|
|
2
2
|
const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
3
3
|
|
|
4
|
-
const IDENTITY_NONCE_VALUE_FILTER = 0xFFFFFFFFFF;
|
|
4
|
+
const IDENTITY_NONCE_VALUE_FILTER = BigInt(0xFFFFFFFFFF);
|
|
5
5
|
|
|
6
6
|
class GetIdentityNonceResponse extends AbstractResponse {
|
|
7
7
|
/**
|
|
8
|
-
* @param {
|
|
8
|
+
* @param {bigint} identityNonce
|
|
9
9
|
* @param {Metadata} metadata
|
|
10
10
|
* @param {Proof} [proof]
|
|
11
11
|
*/
|
|
@@ -16,7 +16,7 @@ class GetIdentityNonceResponse extends AbstractResponse {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @returns {
|
|
19
|
+
* @returns {bigint}
|
|
20
20
|
*/
|
|
21
21
|
getIdentityNonce() {
|
|
22
22
|
return this.identityNonce;
|
|
@@ -28,8 +28,8 @@ class GetIdentityNonceResponse extends AbstractResponse {
|
|
|
28
28
|
*/
|
|
29
29
|
static createFromProto(proto) {
|
|
30
30
|
// eslint-disable-next-line
|
|
31
|
-
const identityNonce = proto.getV0()
|
|
32
|
-
.getIdentityNonce() & IDENTITY_NONCE_VALUE_FILTER;
|
|
31
|
+
const identityNonce = BigInt(proto.getV0()
|
|
32
|
+
.getIdentityNonce()) & IDENTITY_NONCE_VALUE_FILTER;
|
|
33
33
|
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(
|
|
34
34
|
proto,
|
|
35
35
|
);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
class ChainStatus {
|
|
2
|
+
/**
|
|
3
|
+
* @param {boolean} catchingUp - is node syncing?
|
|
4
|
+
* @param {string} latestBlockHash - latest block hash
|
|
5
|
+
* @param {string} latestAppHash - latest app hash
|
|
6
|
+
* @param {bigint} latestBlockHeight - latest block height
|
|
7
|
+
* @param {string} earliestBlockHash - earliest block hash
|
|
8
|
+
* @param {string} earliestAppHash - earliest app hash
|
|
9
|
+
* @param {bigint} earliestBlockHeight - earliest block height
|
|
10
|
+
* @param {bigint} maxPeerBlockHeight - max peer block height
|
|
11
|
+
* @param {number=} coreChainLockedHeight - core chain locked height
|
|
12
|
+
*/
|
|
13
|
+
constructor(
|
|
14
|
+
catchingUp,
|
|
15
|
+
latestBlockHash,
|
|
16
|
+
latestAppHash,
|
|
17
|
+
latestBlockHeight,
|
|
18
|
+
earliestBlockHash,
|
|
19
|
+
earliestAppHash,
|
|
20
|
+
earliestBlockHeight,
|
|
21
|
+
maxPeerBlockHeight,
|
|
22
|
+
coreChainLockedHeight,
|
|
23
|
+
) {
|
|
24
|
+
this.catchingUp = catchingUp;
|
|
25
|
+
this.latestBlockHash = latestBlockHash;
|
|
26
|
+
this.latestAppHash = latestAppHash;
|
|
27
|
+
this.latestBlockHeight = latestBlockHeight;
|
|
28
|
+
this.earliestBlockHash = earliestBlockHash;
|
|
29
|
+
this.earliestAppHash = earliestAppHash;
|
|
30
|
+
this.earliestBlockHeight = earliestBlockHeight;
|
|
31
|
+
this.maxPeerBlockHeight = maxPeerBlockHeight;
|
|
32
|
+
this.coreChainLockedHeight = coreChainLockedHeight || null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @returns {boolean} returns true if node is currently syncing
|
|
37
|
+
*/
|
|
38
|
+
isCatchingUp() {
|
|
39
|
+
return this.catchingUp;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @returns {string} latest block hash
|
|
44
|
+
*/
|
|
45
|
+
getLatestBlockHash() {
|
|
46
|
+
return this.latestBlockHash;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @returns {string} latest app hash
|
|
51
|
+
*/
|
|
52
|
+
getLatestAppHash() {
|
|
53
|
+
return this.latestAppHash;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @returns {bigint} latest block height
|
|
58
|
+
*/
|
|
59
|
+
getLatestBlockHeight() {
|
|
60
|
+
return this.latestBlockHeight;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @returns {string} earliest block hash
|
|
65
|
+
*/
|
|
66
|
+
getEarliestBlockHash() {
|
|
67
|
+
return this.earliestBlockHash;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @returns {string} earliest app hash
|
|
72
|
+
*/
|
|
73
|
+
getEarliestAppHash() {
|
|
74
|
+
return this.earliestAppHash;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @returns {bigint} earliest block height
|
|
79
|
+
*/
|
|
80
|
+
getEarliestBlockHeight() {
|
|
81
|
+
return this.earliestBlockHeight;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @returns {bigint} max peer block height
|
|
86
|
+
*/
|
|
87
|
+
getMaxPeerBlockHeight() {
|
|
88
|
+
return this.maxPeerBlockHeight;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @returns {number|null} core chain locked height
|
|
93
|
+
*/
|
|
94
|
+
getCoreChainLockedHeight() {
|
|
95
|
+
return this.coreChainLockedHeight;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = ChainStatus;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
const VersionStatus = require('./VersionStatus');
|
|
2
|
+
const NodeStatus = require('./NodeStatus');
|
|
3
|
+
const ChainStatus = require('./ChainStatus');
|
|
4
|
+
const TimeStatus = require('./TimeStatus');
|
|
5
|
+
const StateSyncStatus = require('./StateSyncStatus');
|
|
6
|
+
const NetworkStatus = require('./NetworkStatus');
|
|
7
|
+
|
|
8
|
+
class GetStatusResponse {
|
|
9
|
+
/**
|
|
10
|
+
* @param {VersionStatus} version - status versions
|
|
11
|
+
* @param {NodeStatus} node - node status
|
|
12
|
+
* @param {ChainStatus} chain - chain status
|
|
13
|
+
* @param {NetworkStatus} network - network status
|
|
14
|
+
* @param {StateSyncStatus} stateSync - state sync status
|
|
15
|
+
* @param {TimeStatus} time - time status
|
|
16
|
+
*/
|
|
17
|
+
constructor(version, node, chain, network, stateSync, time) {
|
|
18
|
+
this.version = version;
|
|
19
|
+
this.node = node;
|
|
20
|
+
this.chain = chain;
|
|
21
|
+
this.network = network;
|
|
22
|
+
this.stateSync = stateSync;
|
|
23
|
+
this.time = time;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @returns {VersionStatus} network versions status
|
|
28
|
+
*/
|
|
29
|
+
getVersionStatus() {
|
|
30
|
+
return this.version;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @returns {NodeStatus} node info status
|
|
35
|
+
*/
|
|
36
|
+
getNodeStatus() {
|
|
37
|
+
return this.node;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @returns {ChainStatus} chain status
|
|
42
|
+
*/
|
|
43
|
+
getChainStatus() {
|
|
44
|
+
return this.chain;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @returns {NetworkStatus} network status
|
|
49
|
+
*/
|
|
50
|
+
getNetworkStatus() {
|
|
51
|
+
return this.network;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @returns {StateSyncStatus} state sync status
|
|
56
|
+
*/
|
|
57
|
+
getStateSyncStatus() {
|
|
58
|
+
return this.stateSync;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @returns {TimeStatus} time status
|
|
63
|
+
*/
|
|
64
|
+
getTimeStatus() {
|
|
65
|
+
return this.time;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param {GetStatusResponse} proto GRPC GetStatusResponse
|
|
70
|
+
* @returns {GetStatusResponse} JS DAPI Client GetStatusResponse
|
|
71
|
+
*/
|
|
72
|
+
static createFromProto(proto) {
|
|
73
|
+
const v0 = proto.getV0();
|
|
74
|
+
|
|
75
|
+
const dapiVersion = v0.getVersion().getSoftware().getDapi();
|
|
76
|
+
const driveVersion = v0.getVersion().getSoftware().getDrive();
|
|
77
|
+
const tenderdashVersion = v0.getVersion().getSoftware().getTenderdash();
|
|
78
|
+
const tenderdashP2pProtocol = v0.getVersion().getProtocol().getTenderdash().getP2p();
|
|
79
|
+
const tenderdashBlockProtocol = v0.getVersion().getProtocol().getTenderdash().getBlock();
|
|
80
|
+
const driveCurrentProtocol = v0.getVersion().getProtocol().getDrive().getCurrent();
|
|
81
|
+
const driveLatestProtocol = v0.getVersion().getProtocol().getDrive().getLatest();
|
|
82
|
+
|
|
83
|
+
const version = new VersionStatus(
|
|
84
|
+
dapiVersion,
|
|
85
|
+
driveVersion,
|
|
86
|
+
tenderdashVersion,
|
|
87
|
+
tenderdashP2pProtocol,
|
|
88
|
+
tenderdashBlockProtocol,
|
|
89
|
+
driveCurrentProtocol,
|
|
90
|
+
driveLatestProtocol,
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const nodeId = Buffer.from(v0.getNode().getId()).toString('hex');
|
|
94
|
+
const proTxHash = Buffer.from(v0.getNode().getProTxHash()).toString('hex');
|
|
95
|
+
|
|
96
|
+
const node = new NodeStatus(nodeId, proTxHash);
|
|
97
|
+
|
|
98
|
+
const catchingUp = v0.getChain().getCatchingUp();
|
|
99
|
+
const latestBlockHash = Buffer.from(v0.getChain().getLatestBlockHash()).toString('hex');
|
|
100
|
+
const latestAppHash = Buffer.from(v0.getChain().getLatestAppHash()).toString('hex');
|
|
101
|
+
const latestBlockHeight = BigInt(v0.getChain().getLatestBlockHeight());
|
|
102
|
+
const earliestBlockHash = Buffer.from(v0.getChain().getEarliestBlockHash()).toString('hex');
|
|
103
|
+
const earliestAppHash = Buffer.from(v0.getChain().getEarliestAppHash()).toString('hex');
|
|
104
|
+
const earliestBlockHeight = BigInt(v0.getChain().getEarliestBlockHeight());
|
|
105
|
+
const maxPeerBlockHeight = BigInt(v0.getChain().getMaxPeerBlockHeight());
|
|
106
|
+
const coreChainLockedHeight = v0.getChain().getCoreChainLockedHeight();
|
|
107
|
+
|
|
108
|
+
const chain = new ChainStatus(
|
|
109
|
+
catchingUp,
|
|
110
|
+
latestBlockHash,
|
|
111
|
+
latestAppHash,
|
|
112
|
+
latestBlockHeight,
|
|
113
|
+
earliestBlockHash,
|
|
114
|
+
earliestAppHash,
|
|
115
|
+
earliestBlockHeight,
|
|
116
|
+
maxPeerBlockHeight,
|
|
117
|
+
coreChainLockedHeight,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const chainId = v0.getNetwork().getChainId();
|
|
121
|
+
const peersCount = v0.getNetwork().getPeersCount();
|
|
122
|
+
const isListening = v0.getNetwork().getListening();
|
|
123
|
+
|
|
124
|
+
const network = new NetworkStatus(chainId, peersCount, isListening);
|
|
125
|
+
|
|
126
|
+
const totalSyncedTime = BigInt(v0.getStateSync().getTotalSyncedTime());
|
|
127
|
+
const remainingTime = BigInt(v0.getStateSync().getRemainingTime());
|
|
128
|
+
const totalSnapshots = v0.getStateSync().getTotalSnapshots();
|
|
129
|
+
const chunkProcessAverageTime = BigInt(v0.getStateSync().getChunkProcessAvgTime());
|
|
130
|
+
const snapshotHeight = BigInt(v0.getStateSync().getSnapshotHeight());
|
|
131
|
+
const snapshotChunksCount = BigInt(v0.getStateSync().getSnapshotChunksCount());
|
|
132
|
+
const backfilledBlocks = BigInt(v0.getStateSync().getBackfilledBlocks());
|
|
133
|
+
const backfillBlocksTotal = BigInt(v0.getStateSync().getBackfillBlocksTotal());
|
|
134
|
+
|
|
135
|
+
const stateSync = new StateSyncStatus(
|
|
136
|
+
totalSyncedTime,
|
|
137
|
+
remainingTime,
|
|
138
|
+
totalSnapshots,
|
|
139
|
+
chunkProcessAverageTime,
|
|
140
|
+
snapshotHeight,
|
|
141
|
+
snapshotChunksCount,
|
|
142
|
+
backfilledBlocks,
|
|
143
|
+
backfillBlocksTotal,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const local = BigInt(v0.getTime().getLocal());
|
|
147
|
+
const block = BigInt(v0.getTime().getBlock());
|
|
148
|
+
const genesis = BigInt(v0.getTime().getGenesis());
|
|
149
|
+
const epoch = v0.getTime().getEpoch();
|
|
150
|
+
|
|
151
|
+
const time = new TimeStatus(local, block, genesis, epoch);
|
|
152
|
+
|
|
153
|
+
return new GetStatusResponse(
|
|
154
|
+
version,
|
|
155
|
+
node,
|
|
156
|
+
chain,
|
|
157
|
+
network,
|
|
158
|
+
stateSync,
|
|
159
|
+
time,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
module.exports = GetStatusResponse;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
class NetworkStatus {
|
|
2
|
+
/**
|
|
3
|
+
* @param {string} chainId - Chain id
|
|
4
|
+
* @param {number} peersCount - Peers count
|
|
5
|
+
* @param {boolean} listening - Is listening to P2P network
|
|
6
|
+
*/
|
|
7
|
+
constructor(chainId, peersCount, listening) {
|
|
8
|
+
this.chainId = chainId;
|
|
9
|
+
this.peersCount = peersCount;
|
|
10
|
+
this.listening = listening;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @returns {string} chain id
|
|
15
|
+
*/
|
|
16
|
+
getChainId() {
|
|
17
|
+
return this.chainId;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @returns {number} peers count
|
|
22
|
+
*/
|
|
23
|
+
getPeersCount() {
|
|
24
|
+
return this.peersCount;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @returns {boolean} is listening to p2p
|
|
29
|
+
*/
|
|
30
|
+
isListening() {
|
|
31
|
+
return this.listening;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = NetworkStatus;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class NodeStatus {
|
|
2
|
+
/**
|
|
3
|
+
* @param {string} nodeId - Node ID
|
|
4
|
+
* @param {string=} proTxHash - Node's proTxHash
|
|
5
|
+
*/
|
|
6
|
+
constructor(nodeId, proTxHash) {
|
|
7
|
+
this.nodeId = nodeId;
|
|
8
|
+
this.proTxHash = proTxHash || null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @returns {string} Node ID
|
|
13
|
+
*/
|
|
14
|
+
getNodeId() {
|
|
15
|
+
return this.nodeId;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @returns {string} Pro Tx Hash
|
|
20
|
+
*/
|
|
21
|
+
getProTxHash() {
|
|
22
|
+
return this.proTxHash;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = NodeStatus;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
class StateSyncStatus {
|
|
2
|
+
/**
|
|
3
|
+
* @param {bigint} totalSyncedTime - Total synced time
|
|
4
|
+
* @param {bigint} remainingTime - Remaining time to sync
|
|
5
|
+
* @param {number} totalSnapshots - Total snapshots count
|
|
6
|
+
* @param {bigint} chunkProcessAverageTime - Chunk process average time
|
|
7
|
+
* @param {bigint} snapshotHeight - Snapshot height
|
|
8
|
+
* @param {bigint} snapshotChunksCount - Snapshot chunks count
|
|
9
|
+
* @param {bigint} backfilledBlocks - Backfilled blocks
|
|
10
|
+
* @param {bigint} backfillBlocksTotal - Backfilled blocks total count
|
|
11
|
+
*/
|
|
12
|
+
constructor(
|
|
13
|
+
totalSyncedTime,
|
|
14
|
+
remainingTime,
|
|
15
|
+
totalSnapshots,
|
|
16
|
+
chunkProcessAverageTime,
|
|
17
|
+
snapshotHeight,
|
|
18
|
+
snapshotChunksCount,
|
|
19
|
+
backfilledBlocks,
|
|
20
|
+
backfillBlocksTotal,
|
|
21
|
+
) {
|
|
22
|
+
this.totalSyncedTime = totalSyncedTime;
|
|
23
|
+
this.remainingTime = remainingTime;
|
|
24
|
+
this.totalSnapshots = totalSnapshots;
|
|
25
|
+
this.chunkProcessAverageTime = chunkProcessAverageTime;
|
|
26
|
+
this.snapshotHeight = snapshotHeight;
|
|
27
|
+
this.snapshotChunksCount = snapshotChunksCount;
|
|
28
|
+
this.backfilledBlocks = backfilledBlocks;
|
|
29
|
+
this.backfillBlocksTotal = backfillBlocksTotal;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @returns {bigint} Total synced time
|
|
34
|
+
*/
|
|
35
|
+
getTotalSyncedTime() {
|
|
36
|
+
return this.totalSyncedTime;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @returns {bigint} Total synced time
|
|
41
|
+
*/
|
|
42
|
+
getRemainingTime() {
|
|
43
|
+
return this.remainingTime;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @returns {number} Total snapshots count
|
|
48
|
+
*/
|
|
49
|
+
getTotalSnapshots() {
|
|
50
|
+
return this.totalSnapshots;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @returns {bigint} Chunk process average time
|
|
55
|
+
*/
|
|
56
|
+
getChunkProcessAverageTime() {
|
|
57
|
+
return this.chunkProcessAverageTime;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @returns {bigint} Chunk process average time
|
|
62
|
+
*/
|
|
63
|
+
getSnapshotHeight() {
|
|
64
|
+
return this.snapshotHeight;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @returns {bigint} Chunk process average time
|
|
69
|
+
*/
|
|
70
|
+
getSnapshotChunkCount() {
|
|
71
|
+
return this.snapshotChunksCount;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @returns {bigint} Backfilled blocks
|
|
76
|
+
*/
|
|
77
|
+
getBackfilledBlocks() {
|
|
78
|
+
return this.backfilledBlocks;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @returns {bigint} Backfill blocks total
|
|
83
|
+
*/
|
|
84
|
+
getBackfilledBlockTotal() {
|
|
85
|
+
return this.backfillBlocksTotal;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = StateSyncStatus;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
class TimeStatus {
|
|
2
|
+
/**
|
|
3
|
+
* @param {bigint} local - Local system time
|
|
4
|
+
* @param {bigint=} block - Block time
|
|
5
|
+
* @param {bigint=} genesis - Genesis time
|
|
6
|
+
* @param {number=} epoch - Epoch number
|
|
7
|
+
*/
|
|
8
|
+
constructor(
|
|
9
|
+
local,
|
|
10
|
+
block,
|
|
11
|
+
genesis,
|
|
12
|
+
epoch,
|
|
13
|
+
) {
|
|
14
|
+
this.local = local;
|
|
15
|
+
this.block = typeof block === 'bigint' ? block : null;
|
|
16
|
+
this.genesis = typeof genesis === 'bigint' ? genesis : null;
|
|
17
|
+
this.epoch = epoch || null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @returns {bigint} Local system time
|
|
22
|
+
*/
|
|
23
|
+
getLocalTime() {
|
|
24
|
+
return this.local;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @returns {bigint|null} Block time
|
|
29
|
+
*/
|
|
30
|
+
getBlockTime() {
|
|
31
|
+
return this.block;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @returns {bigint|null} Genesis time
|
|
36
|
+
*/
|
|
37
|
+
getGenesisTime() {
|
|
38
|
+
return this.genesis;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @returns {number|null} Epoch number
|
|
43
|
+
*/
|
|
44
|
+
getEpochNumber() {
|
|
45
|
+
return this.epoch;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = TimeStatus;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
class VersionStatus {
|
|
2
|
+
/**
|
|
3
|
+
* @param {string} dapiVersion - DAPI version
|
|
4
|
+
* @param {string=} driveVersion - Drive ABCI version
|
|
5
|
+
* @param {string=} tenderdashVersion - Tenderdash version
|
|
6
|
+
* @param {number} tenderdashP2pProtocol - Tenderdash Protocol Version
|
|
7
|
+
* @param {number} tenderdashBlockProtocol - Tenderdash Block Version
|
|
8
|
+
* @param {number} driveCurrentProtocol - Current Dash Platform (Drive) protocol version
|
|
9
|
+
* @param {number} driveLatestProtocol - Next Dash Platform (Drive) protocol version
|
|
10
|
+
*/
|
|
11
|
+
constructor(
|
|
12
|
+
dapiVersion,
|
|
13
|
+
driveVersion,
|
|
14
|
+
tenderdashVersion,
|
|
15
|
+
tenderdashP2pProtocol,
|
|
16
|
+
tenderdashBlockProtocol,
|
|
17
|
+
driveCurrentProtocol,
|
|
18
|
+
driveLatestProtocol,
|
|
19
|
+
) {
|
|
20
|
+
this.dapiVersion = dapiVersion;
|
|
21
|
+
this.driveVersion = driveVersion || null;
|
|
22
|
+
this.tenderdashVersion = tenderdashVersion || null;
|
|
23
|
+
this.tenderdashP2pProtocol = tenderdashP2pProtocol;
|
|
24
|
+
this.tenderdashBlockProtocol = tenderdashBlockProtocol;
|
|
25
|
+
this.driveCurrentProtocol = driveCurrentProtocol;
|
|
26
|
+
this.driveLatestProtocol = driveLatestProtocol;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @returns {string|null} DAPI version
|
|
31
|
+
*/
|
|
32
|
+
getDapiVersion() {
|
|
33
|
+
return this.dapiVersion;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @returns {string|null} Drive ABCI version
|
|
38
|
+
*/
|
|
39
|
+
getDriveVersion() {
|
|
40
|
+
return this.driveVersion;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @returns {string|null} Tenderdash version
|
|
45
|
+
*/
|
|
46
|
+
getTenderdashVersion() {
|
|
47
|
+
return this.tenderdashVersion;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @returns {number} Tenderdash P2P protocol
|
|
52
|
+
*/
|
|
53
|
+
getTenderdashP2pProtocol() {
|
|
54
|
+
return this.tenderdashP2pProtocol;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @returns {number} Tenderdash Block protocol
|
|
59
|
+
*/
|
|
60
|
+
getTenderdashBlockProtocol() {
|
|
61
|
+
return this.tenderdashBlockProtocol;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @returns {number} Drive Current Protocol
|
|
66
|
+
*/
|
|
67
|
+
getDriveCurrentProtocol() {
|
|
68
|
+
return this.driveCurrentProtocol;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @returns {number} Drive Latest Protocol
|
|
73
|
+
*/
|
|
74
|
+
getDriveLatestProtocol() {
|
|
75
|
+
return this.driveLatestProtocol;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = VersionStatus;
|
|
@@ -6,18 +6,18 @@ const {
|
|
|
6
6
|
} = require('@dashevo/dapi-grpc');
|
|
7
7
|
|
|
8
8
|
const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
9
|
+
const GetStatusResponse = require('./GetStatusResponse');
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @param {GrpcTransport} grpcTransport
|
|
12
|
-
* @returns {
|
|
13
|
+
* @returns {getStatus}
|
|
13
14
|
*/
|
|
14
15
|
function getStatusFactory(grpcTransport) {
|
|
15
16
|
/**
|
|
16
|
-
* Fetch
|
|
17
|
-
* @typedef {
|
|
18
|
-
* @param {Buffer} id
|
|
17
|
+
* Fetch node status
|
|
18
|
+
* @typedef {getStatus}
|
|
19
19
|
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
|
20
|
-
* @returns {Promise<
|
|
20
|
+
* @returns {Promise<GetStatusResponse>}
|
|
21
21
|
*/
|
|
22
22
|
async function getStatus(options = {}) {
|
|
23
23
|
const { GetStatusRequestV0 } = GetStatusRequest;
|
|
@@ -45,7 +45,7 @@ function getStatusFactory(grpcTransport) {
|
|
|
45
45
|
throw new InvalidResponseError('GetStatusResponseV0 is not defined');
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
return
|
|
48
|
+
return GetStatusResponse.createFromProto(getStatusResponse);
|
|
49
49
|
} catch (e) {
|
|
50
50
|
if (e instanceof InvalidResponseError) {
|
|
51
51
|
lastError = e;
|
|
@@ -3,7 +3,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
|
3
3
|
|
|
4
4
|
class GetTotalCreditsInPlatformResponse extends AbstractResponse {
|
|
5
5
|
/**
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {bigint} totalCreditsInPlatform
|
|
7
7
|
* @param {Metadata} metadata
|
|
8
8
|
* @param {Proof} [proof]
|
|
9
9
|
*/
|
|
@@ -14,7 +14,7 @@ class GetTotalCreditsInPlatformResponse extends AbstractResponse {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* @returns {
|
|
17
|
+
* @returns {bigint}
|
|
18
18
|
*/
|
|
19
19
|
getTotalCreditsInPlatform() {
|
|
20
20
|
return this.totalCreditsInPlatform;
|
|
@@ -26,7 +26,7 @@ class GetTotalCreditsInPlatformResponse extends AbstractResponse {
|
|
|
26
26
|
*/
|
|
27
27
|
static createFromProto(proto) {
|
|
28
28
|
// eslint-disable-next-line
|
|
29
|
-
const totalCreditsInPlatform = proto.getV0().getCredits();
|
|
29
|
+
const totalCreditsInPlatform = BigInt(proto.getV0().getCredits());
|
|
30
30
|
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(
|
|
31
31
|
proto,
|
|
32
32
|
);
|
|
@@ -50,7 +50,12 @@ class AbstractResponse {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
return {
|
|
53
|
-
metadata: new Metadata(
|
|
53
|
+
metadata: new Metadata({
|
|
54
|
+
height: metadata.getHeight(),
|
|
55
|
+
coreChainLockedHeight: metadata.getCoreChainLockedHeight(),
|
|
56
|
+
timeMs: metadata.getTimeMs(),
|
|
57
|
+
protocolVersion: metadata.getProtocolVersion(),
|
|
58
|
+
}),
|
|
54
59
|
proof,
|
|
55
60
|
};
|
|
56
61
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
class Metadata {
|
|
2
2
|
/**
|
|
3
3
|
* @param {object} properties
|
|
4
|
-
* @param {
|
|
4
|
+
* @param {bigint|string} properties.height - block height
|
|
5
5
|
* @param {number} properties.coreChainLockedHeight - core chain locked height
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {bigint|string} properties.timeMs - block time
|
|
7
7
|
* @param {number} properties.protocolVersion - protocol version
|
|
8
8
|
*/
|
|
9
9
|
constructor(properties) {
|
|
10
|
-
this.height = properties.height;
|
|
10
|
+
this.height = BigInt(properties.height);
|
|
11
11
|
this.coreChainLockedHeight = properties.coreChainLockedHeight;
|
|
12
|
-
this.timeMs = properties.timeMs;
|
|
12
|
+
this.timeMs = BigInt(properties.timeMs);
|
|
13
13
|
this.protocolVersion = properties.protocolVersion;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Get height
|
|
18
|
-
* @returns {
|
|
18
|
+
* @returns {bigint} - block height
|
|
19
19
|
*/
|
|
20
20
|
getHeight() {
|
|
21
21
|
return this.height;
|
|
@@ -31,7 +31,7 @@ class Metadata {
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Get block time
|
|
34
|
-
* @returns {
|
|
34
|
+
* @returns {bigint}
|
|
35
35
|
*/
|
|
36
36
|
getTimeMs() {
|
|
37
37
|
return this.timeMs;
|
|
@@ -2,7 +2,7 @@ class ErrorResult {
|
|
|
2
2
|
/**
|
|
3
3
|
* @param {number} code
|
|
4
4
|
* @param {string} message
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {Buffer|undefined} data
|
|
6
6
|
*/
|
|
7
7
|
constructor(code, message, data) {
|
|
8
8
|
this.code = code;
|
|
@@ -25,7 +25,7 @@ class ErrorResult {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* @returns {
|
|
28
|
+
* @returns {Buffer|undefined}
|
|
29
29
|
*/
|
|
30
30
|
getData() {
|
|
31
31
|
return this.data;
|
package/lib/methods/platform/waitForStateTransitionResult/WaitForStateTransitionResultResponse.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const cbor = require('cbor');
|
|
2
|
-
|
|
3
1
|
const AbstractResponse = require('../response/AbstractResponse');
|
|
4
2
|
const Metadata = require('../response/Metadata');
|
|
5
3
|
const Proof = require('../response/Proof');
|
|
@@ -38,9 +36,9 @@ class WaitForStateTransitionResultResponse extends AbstractResponse {
|
|
|
38
36
|
|
|
39
37
|
if (proto.getV0().getError()) {
|
|
40
38
|
let data;
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
data =
|
|
39
|
+
|
|
40
|
+
if (proto.getV0().getError().getData()) {
|
|
41
|
+
data = Buffer.from(proto.getV0().getError().getData());
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
error = new ErrorResult(
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @returns {{
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* height: bigint,
|
|
4
|
+
* coreChainLockedHeight: string,
|
|
5
|
+
* timeMs: string,
|
|
6
6
|
* protocolVersion: number,
|
|
7
|
-
* timeMs: number,
|
|
8
7
|
* }}
|
|
9
8
|
*/
|
|
10
9
|
function getMetadataFixture() {
|
|
11
10
|
return {
|
|
12
|
-
height: 10,
|
|
13
|
-
coreChainLockedHeight: 42,
|
|
14
|
-
timeMs: new Date().getTime(),
|
|
11
|
+
height: BigInt(10),
|
|
12
|
+
coreChainLockedHeight: '42',
|
|
13
|
+
timeMs: new Date().getTime().toString(),
|
|
15
14
|
protocolVersion: 1,
|
|
16
15
|
};
|
|
17
16
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
*/
|
|
4
|
+
function getStatusFixture() {
|
|
5
|
+
return {
|
|
6
|
+
version: {
|
|
7
|
+
software: {
|
|
8
|
+
dapi: '1.8.0-rc.2',
|
|
9
|
+
drive: '1.8.0-rc.3',
|
|
10
|
+
tenderdash: '1.4.0',
|
|
11
|
+
},
|
|
12
|
+
protocol: {
|
|
13
|
+
tenderdash: {
|
|
14
|
+
p2p: 10,
|
|
15
|
+
block: 14,
|
|
16
|
+
},
|
|
17
|
+
drive: {
|
|
18
|
+
latest: 9,
|
|
19
|
+
current: 8,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
node: {
|
|
24
|
+
id: new Uint8Array(Buffer.from('QbMI9zfKnjn2e1UxWJAxmKiMUW4=', 'base64')),
|
|
25
|
+
proTxHash: new Uint8Array(Buffer.from('s7V0hXG2D+mtEScV1qUXJdblpSqcOvX9NqFyTPUNhi8=', 'base64')),
|
|
26
|
+
},
|
|
27
|
+
chain: {
|
|
28
|
+
catchingUp: false,
|
|
29
|
+
latestBlockHash: new Uint8Array(Buffer.from('mVDwGtY2oJSaLLgv3WpLp2dFDyFEtqhD4z1gl2OJceY=', 'base64')),
|
|
30
|
+
latestAppHash: new Uint8Array(Buffer.from('jHgEBK8aZ74TUKcUGN58EFzUNvNsLboOgYe6eH/JetU=', 'base64')),
|
|
31
|
+
latestBlockHeight: '94461',
|
|
32
|
+
earliestBlockHash: new Uint8Array(Buffer.from('CPoCwn7AOQujAeT8fj1+rbNQyBk+PmKgk2iXBuOiC/o=', 'base64')),
|
|
33
|
+
earliestAppHash: new Uint8Array(Buffer.from('vwzLnKBxugGubmegwJD5eAPSbVbWddzVExeBy8rI7I8=', 'base64')),
|
|
34
|
+
earliestBlockHeight: '1',
|
|
35
|
+
maxPeerBlockHeight: '94461',
|
|
36
|
+
coreChainLockedHeight: 1187358,
|
|
37
|
+
},
|
|
38
|
+
network: {
|
|
39
|
+
chainId: 'dash-testnet-51',
|
|
40
|
+
peersCount: 96,
|
|
41
|
+
listening: true,
|
|
42
|
+
},
|
|
43
|
+
stateSync: {
|
|
44
|
+
totalSyncedTime: '2312323',
|
|
45
|
+
remainingTime: '1337',
|
|
46
|
+
totalSnapshots: 300,
|
|
47
|
+
chunkProcessAverageTime: '213123',
|
|
48
|
+
snapshotHeight: '10000',
|
|
49
|
+
snapshotChunksCount: '1000',
|
|
50
|
+
backfilledBlocks: '1400',
|
|
51
|
+
backfillBlocksTotal: '2000',
|
|
52
|
+
},
|
|
53
|
+
time: {
|
|
54
|
+
local: '1738336806994',
|
|
55
|
+
block: '1738336736273',
|
|
56
|
+
genesis: '0',
|
|
57
|
+
epoch: 4717,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = getStatusFixture;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-rc.1",
|
|
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": "
|
|
29
|
+
"@dashevo/dapi-grpc": "2.0.0-rc.1",
|
|
30
30
|
"@dashevo/dash-spv": "2.8.0",
|
|
31
31
|
"@dashevo/dashcore-lib": "~0.22.0",
|
|
32
|
-
"@dashevo/grpc-common": "
|
|
33
|
-
"@dashevo/wasm-dpp": "
|
|
32
|
+
"@dashevo/grpc-common": "2.0.0-rc.1",
|
|
33
|
+
"@dashevo/wasm-dpp": "2.0.0-rc.1",
|
|
34
34
|
"bs58": "^4.0.1",
|
|
35
35
|
"cbor": "^8.0.0",
|
|
36
36
|
"google-protobuf": "^3.12.2",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"winston": "^3.2.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "^7.
|
|
44
|
+
"@babel/core": "^7.26.10",
|
|
45
45
|
"assert-browserify": "^2.0.0",
|
|
46
46
|
"babel-loader": "^9.1.3",
|
|
47
47
|
"browserify-zlib": "^0.2.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"karma-mocha": "^2.0.1",
|
|
65
65
|
"karma-mocha-reporter": "^2.2.5",
|
|
66
66
|
"karma-webpack": "^5.0.0",
|
|
67
|
-
"mocha": "^
|
|
67
|
+
"mocha": "^11.1.0",
|
|
68
68
|
"nyc": "^15.1.0",
|
|
69
69
|
"os-browserify": "^0.3.0",
|
|
70
70
|
"path-browserify": "^1.0.1",
|
|
@@ -82,7 +82,8 @@
|
|
|
82
82
|
"files": [
|
|
83
83
|
"docs",
|
|
84
84
|
"lib",
|
|
85
|
-
"polyfills"
|
|
85
|
+
"polyfills",
|
|
86
|
+
"dist"
|
|
86
87
|
],
|
|
87
88
|
"scripts": {
|
|
88
89
|
"build:web": "webpack",
|