dash-platform-sdk 1.5.1 → 1.5.3
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 +15 -15
- package/bundle.min.js +1 -1
- package/package.json +1 -1
- package/src/contestedResources/getContestedResourceVoteState.js +1 -1
- package/src/dataContracts/getDataContractByIdentifier.js +1 -1
- package/src/documents/query.js +1 -1
- package/src/grpcConnectionPool.d.ts +6 -3
- package/src/grpcConnectionPool.js +150 -31
- package/src/identities/getIdentityBalance.js +1 -1
- package/src/identities/getIdentityByIdentifier.js +1 -1
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +1 -1
- package/src/identities/getIdentityByPublicKeyHash.js +1 -1
- package/src/identities/getIdentityContractNonce.js +1 -1
- package/src/identities/getIdentityNonce.js +1 -1
- package/src/identities/getIdentityPublicKeys.js +1 -1
- package/src/node/epochInfos.js +1 -1
- package/src/node/finalizedEpochInfos.js +1 -1
- package/src/node/getCurrentQuorumsInfo.js +1 -1
- package/src/node/status.js +1 -1
- package/src/node/totalCredits.js +1 -1
- package/src/platformAddresses/getAddressInfo.js +1 -1
- package/src/platformAddresses/getAddressesBranchState.js +1 -1
- package/src/platformAddresses/getAddressesInfos.js +1 -1
- package/src/platformAddresses/getAddressesTrunkState.js +1 -1
- package/src/platformAddresses/getRecentAddressBalanceChanges.js +1 -1
- package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.js +1 -1
- package/src/shielded/getMostRecentShieldedAnchor.js +1 -1
- package/src/shielded/getShieldedAnchors.js +1 -1
- package/src/shielded/getShieldedEncryptedNotes.js +1 -1
- package/src/shielded/getShieldedNotesCount.js +1 -1
- package/src/shielded/getShieldedNullifiers.js +1 -1
- package/src/shielded/getShieldedPoolState.js +1 -1
- package/src/stateTransitions/broadcast.js +1 -1
- package/src/stateTransitions/waitForStateTransitionResult.js +1 -1
- package/src/tokens/getIdentitiesTokenBalances.js +1 -1
- package/src/tokens/getIdentityTokensBalances.js +1 -1
- package/src/tokens/getTokenContractInfo.js +1 -1
- package/src/tokens/getTokenDirectPurchasePrices.js +1 -1
- package/src/tokens/getTokenTotalSupply.js +1 -1
- package/src/utils/verifyTenderdashProof.js +1 -1
- package/test/unit/ContestedResources.spec.js +1 -1
- package/test/unit/DataContract.spec.js +1 -1
- package/test/unit/Document.spec.js +1 -1
- package/test/unit/Identity.spec.js +1 -1
- package/test/unit/Names.spec.js +1 -1
- package/test/unit/Node.spec.js +1 -1
- package/test/unit/PlatformAddress.spec.js +1 -1
- package/test/unit/Tokens.spec.js +1 -1
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ export default async function getContestedResourceVoteState(grpcPool, contract,
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
const { response } = await grpcPool.getClient().getContestedResourceVoteState(getContestedResourceVoteStateRequest);
|
|
30
|
+
const { response } = await (await grpcPool.getClient()).getContestedResourceVoteState(getContestedResourceVoteStateRequest);
|
|
31
31
|
const { version } = response;
|
|
32
32
|
if (version.oneofKind !== 'v0') {
|
|
33
33
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -18,7 +18,7 @@ export default async function getByIdentifier(grpcPool, identifier) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
const { response } = await grpcPool.getClient().getDataContract(getDataContractRequest);
|
|
21
|
+
const { response } = await (await grpcPool.getClient()).getDataContract(getDataContractRequest);
|
|
22
22
|
const { version } = response;
|
|
23
23
|
if (version.oneofKind !== 'v0') {
|
|
24
24
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
package/src/documents/query.js
CHANGED
|
@@ -35,7 +35,7 @@ export default async function query(grpcPool, dataContractId, documentTypeName,
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
const dataContract = await getDataContractByIdentifier(grpcPool, dataContractId);
|
|
38
|
-
const { response } = await grpcPool.getClient().getDocuments(getDocumentsRequest);
|
|
38
|
+
const { response } = await (await grpcPool.getClient()).getDocuments(getDocumentsRequest);
|
|
39
39
|
const { version } = response;
|
|
40
40
|
if (version.oneofKind !== 'v0') {
|
|
41
41
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PlatformClient } from '../proto/generated/platform.client.js';
|
|
2
2
|
import { Network } from '../types.js';
|
|
3
|
-
export type MasternodeList = Record<string, MasternodeInfo>;
|
|
4
3
|
export interface GRPCOptions {
|
|
5
4
|
poolLimit?: number;
|
|
6
5
|
dapiUrl?: string | string[];
|
|
@@ -13,7 +12,7 @@ export interface GRPCOptions {
|
|
|
13
12
|
*/
|
|
14
13
|
export interface GRPCPool {
|
|
15
14
|
network: Network;
|
|
16
|
-
getClient: (abortController?: AbortController) => PlatformClient
|
|
15
|
+
getClient: (abortController?: AbortController) => PlatformClient | Promise<PlatformClient>;
|
|
17
16
|
}
|
|
18
17
|
export interface MasternodeInfo {
|
|
19
18
|
proTxHash: string;
|
|
@@ -35,9 +34,13 @@ export interface MasternodeInfo {
|
|
|
35
34
|
}
|
|
36
35
|
export declare const createClient: (url: string, abortController?: AbortController) => PlatformClient;
|
|
37
36
|
export default class GRPCConnectionPool implements GRPCPool {
|
|
37
|
+
#private;
|
|
38
38
|
dapiUrls: string[];
|
|
39
39
|
network: Network;
|
|
40
40
|
constructor(network: Network, grpcOptions?: GRPCOptions);
|
|
41
41
|
_initialize(network: Network, poolLimit: number, dapiUrl?: string | string[]): Promise<void>;
|
|
42
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Waits for the pool initialization and returns a client connected to a random healthy node
|
|
44
|
+
*/
|
|
45
|
+
getClient(abortController?: AbortController): Promise<PlatformClient>;
|
|
43
46
|
}
|
|
@@ -4,25 +4,47 @@ import { GetStatusRequest } from '../proto/generated/platform.js';
|
|
|
4
4
|
import getCurrentQuorumsInfo from './node/getCurrentQuorumsInfo.js';
|
|
5
5
|
import getRandomArrayItem from './utils/getRandomArrayItem.js';
|
|
6
6
|
import { fetchWithDetails } from './utils/fetchWithDetails.js';
|
|
7
|
-
|
|
7
|
+
import { LATEST_PLATFORM_VERSION } from './constants.js';
|
|
8
|
+
const GRPC_DEFAULT_POOL_LIMIT = 15;
|
|
8
9
|
const seedNodes = {
|
|
9
10
|
testnet: [
|
|
10
11
|
// seed-1.pshenmic.dev
|
|
11
|
-
'https://
|
|
12
|
+
'https://153.80.206.232:1443',
|
|
13
|
+
// DCG seed
|
|
14
|
+
'https://34.209.12.72:1443',
|
|
15
|
+
// Testnet validators (hp-masternode-1 -> hp-masternode-15)
|
|
16
|
+
'https://68.67.122.1:1443',
|
|
17
|
+
'https://68.67.122.2:1443',
|
|
18
|
+
'https://68.67.122.3:1443',
|
|
19
|
+
'https://68.67.122.4:1443',
|
|
20
|
+
'https://68.67.122.5:1443',
|
|
21
|
+
'https://68.67.122.6:1443',
|
|
22
|
+
'https://68.67.122.7:1443',
|
|
23
|
+
'https://68.67.122.8:1443',
|
|
24
|
+
'https://68.67.122.9:1443',
|
|
25
|
+
'https://68.67.122.10:1443',
|
|
26
|
+
'https://68.67.122.11:1443',
|
|
27
|
+
'https://68.67.122.12:1443',
|
|
28
|
+
'https://68.67.122.13:1443',
|
|
29
|
+
'https://68.67.122.14:1443',
|
|
30
|
+
'https://68.67.122.15:1443'
|
|
12
31
|
],
|
|
13
32
|
mainnet: [
|
|
14
33
|
// seed-1.pshenmic.dev
|
|
15
|
-
'https://
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
|
|
34
|
+
'https://153.80.206.97:443',
|
|
35
|
+
// DCG seed
|
|
36
|
+
'https://34.211.174.194:443',
|
|
37
|
+
// validator
|
|
38
|
+
'https://95.216.146.18:443'
|
|
20
39
|
]
|
|
21
40
|
};
|
|
22
41
|
const DAPI_PORTS = {
|
|
23
42
|
testnet: 1443,
|
|
24
43
|
mainnet: 443
|
|
25
44
|
};
|
|
45
|
+
const HEALTHCHECK_TIMEOUT_MS = 5000;
|
|
46
|
+
// platform produces empty blocks every 3 minutes, so a healthy chain is never older than that
|
|
47
|
+
const HEALTHCHECK_MAX_BLOCK_AGE_MS = 10 * 60 * 1000;
|
|
26
48
|
export const createClient = (url, abortController) => {
|
|
27
49
|
return new PlatformClient(new GrpcWebFetchTransport({
|
|
28
50
|
baseUrl: url,
|
|
@@ -30,13 +52,73 @@ export const createClient = (url, abortController) => {
|
|
|
30
52
|
fetch: fetchWithDetails
|
|
31
53
|
}));
|
|
32
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Runs a request with an AbortController that is aborted after the given timeout
|
|
57
|
+
*/
|
|
58
|
+
const withTimeout = async (request, timeoutMs = HEALTHCHECK_TIMEOUT_MS) => {
|
|
59
|
+
const abortController = new AbortController();
|
|
60
|
+
const timeout = setTimeout(() => abortController.abort(), timeoutMs);
|
|
61
|
+
try {
|
|
62
|
+
return await request(abortController);
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
clearTimeout(timeout);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const isNodeHealthy = async (url) => {
|
|
69
|
+
try {
|
|
70
|
+
const response = await withTimeout(async (abortController) => {
|
|
71
|
+
const { response } = await createClient(url, abortController).getStatus(GetStatusRequest.create({}));
|
|
72
|
+
return response;
|
|
73
|
+
});
|
|
74
|
+
if (response.version.oneofKind !== 'v0') {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const { version, chain, time } = response.version.v0;
|
|
78
|
+
// node is still syncing
|
|
79
|
+
if (chain == null || Boolean(chain.catchingUp)) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
// node runs a protocol version that is not supported by the SDK
|
|
83
|
+
// (e.g. newer software with incompatible proofs / responses)
|
|
84
|
+
const protocol = version?.protocol?.drive;
|
|
85
|
+
if (protocol == null || protocol.current !== Number(LATEST_PLATFORM_VERSION) || protocol?.latest !== Number(LATEST_PLATFORM_VERSION)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
// chain is stalled, last block is too old relative to the node's own clock
|
|
89
|
+
// (local time is in seconds, block time is in milliseconds)
|
|
90
|
+
if (time?.block == null || Number(time.local) * 1000 - Number(time.block) > HEALTHCHECK_MAX_BLOCK_AGE_MS) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
// Fisher–Yates shuffle
|
|
100
|
+
// Randomly shuffles the elements inside of array, having previously cloned it.
|
|
101
|
+
const shuffle = (array) => {
|
|
102
|
+
const result = [...array];
|
|
103
|
+
for (let i = result.length - 1; i > 0; i--) {
|
|
104
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
105
|
+
[result[i], result[j]] = [result[j], result[i]];
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
};
|
|
33
109
|
export default class GRPCConnectionPool {
|
|
34
|
-
dapiUrls;
|
|
110
|
+
dapiUrls = [];
|
|
35
111
|
network;
|
|
112
|
+
#poolLimit;
|
|
113
|
+
#dapiUrl;
|
|
114
|
+
#initialization;
|
|
36
115
|
constructor(network, grpcOptions) {
|
|
37
|
-
const grpcPoolLimit = grpcOptions?.poolLimit ?? GRPC_DEFAULT_POOL_LIMIT;
|
|
38
116
|
this.network = network;
|
|
39
|
-
this
|
|
117
|
+
this.#poolLimit = grpcOptions?.poolLimit ?? GRPC_DEFAULT_POOL_LIMIT;
|
|
118
|
+
this.#dapiUrl = grpcOptions?.dapiUrl;
|
|
119
|
+
// start initialization in the background, failures are reported on the first request
|
|
120
|
+
this.#initialization = this._initialize(network, this.#poolLimit, this.#dapiUrl);
|
|
121
|
+
this.#initialization.catch(() => { });
|
|
40
122
|
}
|
|
41
123
|
async _initialize(network, poolLimit, dapiUrl) {
|
|
42
124
|
if (typeof dapiUrl === 'string') {
|
|
@@ -44,38 +126,75 @@ export default class GRPCConnectionPool {
|
|
|
44
126
|
return;
|
|
45
127
|
}
|
|
46
128
|
if (Array.isArray(dapiUrl)) {
|
|
47
|
-
this.dapiUrls = dapiUrl;
|
|
129
|
+
this.dapiUrls = [...new Set(dapiUrl)];
|
|
130
|
+
if (this.dapiUrls.length === 0) {
|
|
131
|
+
throw new Error('DAPI URL list is empty');
|
|
132
|
+
}
|
|
48
133
|
return;
|
|
49
134
|
}
|
|
50
135
|
if (dapiUrl != null) {
|
|
51
136
|
throw new Error('Unrecognized DAPI URL');
|
|
52
137
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const { validatorSets } = await getCurrentQuorumsInfo(this);
|
|
57
|
-
// map it to array of dapiUrls
|
|
58
|
-
const networkDAPIUrls = [...new Set(validatorSets
|
|
59
|
-
.flatMap(validatorSet => validatorSet.members)
|
|
60
|
-
.filter(member => !member.isBanned)
|
|
61
|
-
.map(member => `https://${member.nodeIp}:${DAPI_PORTS[network]}`))];
|
|
62
|
-
// healthcheck nodes
|
|
63
|
-
for (const url of networkDAPIUrls) {
|
|
64
|
-
if (this.dapiUrls.length > poolLimit) {
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
138
|
+
let quorumsInfo;
|
|
139
|
+
const errors = [];
|
|
140
|
+
for (const seed of seedNodes[network]) {
|
|
67
141
|
try {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (response.version.oneofKind === 'v0' && response.version.v0.chain != null) {
|
|
71
|
-
this.dapiUrls.push(url);
|
|
72
|
-
}
|
|
142
|
+
quorumsInfo = await withTimeout(async (abortController) => await getCurrentQuorumsInfo({ network, getClient: () => createClient(seed, abortController) }));
|
|
143
|
+
break;
|
|
73
144
|
}
|
|
74
145
|
catch (e) {
|
|
146
|
+
errors.push(e);
|
|
75
147
|
}
|
|
76
148
|
}
|
|
149
|
+
if (quorumsInfo == null) {
|
|
150
|
+
throw new AggregateError(errors, `None of the ${network} seed nodes are available: ${errors.map(String).join('; ')}`);
|
|
151
|
+
}
|
|
152
|
+
// map it to array of dapiUrls
|
|
153
|
+
const networkDAPIUrls = shuffle([...new Set(quorumsInfo.validatorSets
|
|
154
|
+
.flatMap(validatorSet => validatorSet.members)
|
|
155
|
+
.filter(member => !member.isBanned)
|
|
156
|
+
.map(member => `https://${member.nodeIp}:${DAPI_PORTS[network]}`))])
|
|
157
|
+
.filter(url => !this.dapiUrls.includes(url));
|
|
158
|
+
// healthcheck nodes in parallel batches until the pool is full
|
|
159
|
+
for (let i = 0; i < networkDAPIUrls.length && this.dapiUrls.length < poolLimit; i += poolLimit) {
|
|
160
|
+
const batch = networkDAPIUrls.slice(i, i + poolLimit);
|
|
161
|
+
await Promise.all(batch.map(async (url) => {
|
|
162
|
+
if (await isNodeHealthy(url)) {
|
|
163
|
+
this.#addNode(url, poolLimit);
|
|
164
|
+
}
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
// fail the initialization, so it is retried on the next request
|
|
168
|
+
if (this.dapiUrls.length === 0) {
|
|
169
|
+
throw new Error(`None of the ${network} evonodes are available (${networkDAPIUrls.length} checked, ` +
|
|
170
|
+
`nodes must be synced and run protocol version ${Number(LATEST_PLATFORM_VERSION)})`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Adds a node to the pool, unless it is already there or the pool is full
|
|
175
|
+
*/
|
|
176
|
+
#addNode(url, poolLimit) {
|
|
177
|
+
if (!this.dapiUrls.includes(url) && this.dapiUrls.length < poolLimit) {
|
|
178
|
+
this.dapiUrls.push(url);
|
|
179
|
+
}
|
|
77
180
|
}
|
|
78
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Waits for the pool initialization and returns a client connected to a random healthy node
|
|
183
|
+
*/
|
|
184
|
+
async getClient(abortController) {
|
|
185
|
+
// retry initialization if the previous attempt failed
|
|
186
|
+
this.#initialization ??= this._initialize(this.network, this.#poolLimit, this.#dapiUrl);
|
|
187
|
+
const initialization = this.#initialization;
|
|
188
|
+
try {
|
|
189
|
+
await initialization;
|
|
190
|
+
}
|
|
191
|
+
catch (e) {
|
|
192
|
+
// other callers may have already started a new attempt
|
|
193
|
+
if (this.#initialization === initialization) {
|
|
194
|
+
this.#initialization = undefined;
|
|
195
|
+
}
|
|
196
|
+
throw e;
|
|
197
|
+
}
|
|
79
198
|
const dapiUrl = getRandomArrayItem(this.dapiUrls);
|
|
80
199
|
return createClient(dapiUrl, abortController);
|
|
81
200
|
}
|
|
@@ -15,7 +15,7 @@ export default async function getIdentityBalance(grpcPool, identifier) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getIdentityBalance(getIdentityBalanceRequest);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getIdentityBalance(getIdentityBalanceRequest);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -15,7 +15,7 @@ export default async function getIdentityByIdentifier(grpcPool, identifier) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getIdentity(getIdentityRequest);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getIdentity(getIdentityRequest);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -16,7 +16,7 @@ export default async function getIdentityByNonUniquePublicKeyHash(grpcPool, hex)
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
const { response } = await grpcPool.getClient().getIdentityByNonUniquePublicKeyHash(getIdentityByNonUniquePublicKeyHashRequest);
|
|
19
|
+
const { response } = await (await grpcPool.getClient()).getIdentityByNonUniquePublicKeyHash(getIdentityByNonUniquePublicKeyHashRequest);
|
|
20
20
|
const { version } = response;
|
|
21
21
|
if (version.oneofKind !== 'v0') {
|
|
22
22
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -15,7 +15,7 @@ export default async function getIdentityByPublicKeyHash(grpcPool, hex) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getIdentityByPublicKeyHash(getIdentityByPublicKeyHashRequest);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getIdentityByPublicKeyHash(getIdentityByPublicKeyHashRequest);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -18,7 +18,7 @@ export default async function getIdentityContractNonce(grpcPool, identity, dataC
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
const { response } = await grpcPool.getClient().getIdentityContractNonce(getIdentityContractNonceRequest);
|
|
21
|
+
const { response } = await (await grpcPool.getClient()).getIdentityContractNonce(getIdentityContractNonceRequest);
|
|
22
22
|
const { version } = response;
|
|
23
23
|
if (version.oneofKind !== 'v0') {
|
|
24
24
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -16,7 +16,7 @@ export default async function getIdentityNonce(grpcPool, identifier) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
const { response } = await grpcPool.getClient().getIdentityNonce(getIdentityNonceRequest);
|
|
19
|
+
const { response } = await (await grpcPool.getClient()).getIdentityNonce(getIdentityNonceRequest);
|
|
20
20
|
const { version } = response;
|
|
21
21
|
if (version.oneofKind !== 'v0') {
|
|
22
22
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -30,7 +30,7 @@ export default async function getIdentityPublicKeys(grpcPool, identifier, keyIds
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
const { response } = await grpcPool.getClient().getIdentityKeys(getIdentityKeysRequest);
|
|
33
|
+
const { response } = await (await grpcPool.getClient()).getIdentityKeys(getIdentityKeysRequest);
|
|
34
34
|
const { version } = response;
|
|
35
35
|
if (version.oneofKind !== 'v0') {
|
|
36
36
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
package/src/node/epochInfos.js
CHANGED
|
@@ -17,7 +17,7 @@ export default async function epochInfos(grpcPool, count, ascending, start) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
const { response } = await grpcPool.getClient().getEpochsInfo(getEpochsInfoRequest);
|
|
20
|
+
const { response } = await (await grpcPool.getClient()).getEpochsInfo(getEpochsInfoRequest);
|
|
21
21
|
const { version } = response;
|
|
22
22
|
if (version.oneofKind !== 'v0') {
|
|
23
23
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -17,7 +17,7 @@ export default async function getFinalizedEpochsInfo(grpcPool, startEpochIndex,
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
const { response } = await grpcPool.getClient().getFinalizedEpochInfos(getEpochsInfoRequest);
|
|
20
|
+
const { response } = await (await grpcPool.getClient()).getFinalizedEpochInfos(getEpochsInfoRequest);
|
|
21
21
|
const { version } = response;
|
|
22
22
|
if (version.oneofKind !== 'v0') {
|
|
23
23
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -7,7 +7,7 @@ export default async function getCurrentQuorumsInfo(grpcPool) {
|
|
|
7
7
|
v0: {}
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
|
-
const { response } = await grpcPool.getClient().getCurrentQuorumsInfo(getCurrentQuorumsInfoRequest);
|
|
10
|
+
const { response } = await (await grpcPool.getClient()).getCurrentQuorumsInfo(getCurrentQuorumsInfoRequest);
|
|
11
11
|
const { version } = response;
|
|
12
12
|
if (version.oneofKind !== 'v0') {
|
|
13
13
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
package/src/node/status.js
CHANGED
|
@@ -7,7 +7,7 @@ export default async function status(grpcPool) {
|
|
|
7
7
|
v0: {}
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
|
-
const { response } = await grpcPool.getClient().getStatus(getStatusRequest);
|
|
10
|
+
const { response } = await (await grpcPool.getClient()).getStatus(getStatusRequest);
|
|
11
11
|
const { version } = response;
|
|
12
12
|
if (version.oneofKind !== 'v0') {
|
|
13
13
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
package/src/node/totalCredits.js
CHANGED
|
@@ -11,7 +11,7 @@ export default async function totalCredits(grpcPool) {
|
|
|
11
11
|
v0: { prove: true }
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
const { response } = await grpcPool.getClient().getTotalCreditsInPlatform(getTotalCreditsInPlatformRequest);
|
|
14
|
+
const { response } = await (await grpcPool.getClient()).getTotalCreditsInPlatform(getTotalCreditsInPlatformRequest);
|
|
15
15
|
const { version } = response;
|
|
16
16
|
if (version.oneofKind !== 'v0') {
|
|
17
17
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -15,7 +15,7 @@ export async function getAddressInfo(grpcPool, platformAddress) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getAddressInfo(getAddressInfoRequest);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getAddressInfo(getAddressInfoRequest);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -12,7 +12,7 @@ export async function getAddressesBranchState(grpcPool, key, depth, checkpointHe
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
const { response } = await grpcPool.getClient().getAddressesBranchState(getAddressesBranchStateRequest);
|
|
15
|
+
const { response } = await (await grpcPool.getClient()).getAddressesBranchState(getAddressesBranchStateRequest);
|
|
16
16
|
const { version } = response;
|
|
17
17
|
if (version.oneofKind !== 'v0') {
|
|
18
18
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -15,7 +15,7 @@ export async function getAddressesInfos(grpcPool, platformAddresses) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getAddressesInfos(getAddressInfoRequest);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getAddressesInfos(getAddressInfoRequest);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -11,7 +11,7 @@ export async function getAddressesTrunkState(grpcPool) {
|
|
|
11
11
|
v0: {}
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
const { response } = await grpcPool.getClient().getAddressesTrunkState(getAddressesTrunkStateRequest);
|
|
14
|
+
const { response } = await (await grpcPool.getClient()).getAddressesTrunkState(getAddressesTrunkStateRequest);
|
|
15
15
|
const { version } = response;
|
|
16
16
|
if (version.oneofKind !== 'v0') {
|
|
17
17
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -15,7 +15,7 @@ export async function getRecentAddressBalanceChanges(grpcPool, startHeight, star
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getRecentAddressBalanceChanges(getRecentAddressBalanceChangesRequest);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getRecentAddressBalanceChanges(getRecentAddressBalanceChangesRequest);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -14,7 +14,7 @@ export async function getRecentCompactedAddressBalanceChanges(grpcPool, startBlo
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
-
const { response } = await grpcPool.getClient().getRecentCompactedAddressBalanceChanges(getRecentCompactedAddressBalanceChangesRequest);
|
|
17
|
+
const { response } = await (await grpcPool.getClient()).getRecentCompactedAddressBalanceChanges(getRecentCompactedAddressBalanceChangesRequest);
|
|
18
18
|
const { version } = response;
|
|
19
19
|
if (version.oneofKind !== 'v0') {
|
|
20
20
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -13,7 +13,7 @@ export default async function getMostRecentShieldedAnchor(grpcPool) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
const { response } = await grpcPool.getClient().getMostRecentShieldedAnchor(getMostRecentShieldedAnchorRequest);
|
|
16
|
+
const { response } = await (await grpcPool.getClient()).getMostRecentShieldedAnchor(getMostRecentShieldedAnchorRequest);
|
|
17
17
|
const { version } = response;
|
|
18
18
|
if (version.oneofKind !== 'v0') {
|
|
19
19
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -13,7 +13,7 @@ export default async function getShieldedAnchors(grpcPool) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
const { response } = await grpcPool.getClient().getShieldedAnchors(getShieldedAnchorsRequest);
|
|
16
|
+
const { response } = await (await grpcPool.getClient()).getShieldedAnchors(getShieldedAnchorsRequest);
|
|
17
17
|
const { version } = response;
|
|
18
18
|
if (version.oneofKind !== 'v0') {
|
|
19
19
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -15,7 +15,7 @@ export default async function getShieldedEncryptedNotes(grpcPool, startIndex, co
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getShieldedEncryptedNotes(getShieldedEncryptedNotesRequest);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getShieldedEncryptedNotes(getShieldedEncryptedNotesRequest);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -13,7 +13,7 @@ export default async function getShieldedNotesCount(grpcPool) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
const { response } = await grpcPool.getClient().getShieldedNotesCount(getShieldedNotesCountRequest);
|
|
16
|
+
const { response } = await (await grpcPool.getClient()).getShieldedNotesCount(getShieldedNotesCountRequest);
|
|
17
17
|
const { version } = response;
|
|
18
18
|
if (version.oneofKind !== 'v0') {
|
|
19
19
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -14,7 +14,7 @@ export default async function getShieldedNullifiers(grpcPool, nullifiers) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
-
const { response } = await grpcPool.getClient().getShieldedNullifiers(getShieldedNullifiersRequest);
|
|
17
|
+
const { response } = await (await grpcPool.getClient()).getShieldedNullifiers(getShieldedNullifiersRequest);
|
|
18
18
|
const { version } = response;
|
|
19
19
|
if (version.oneofKind !== 'v0') {
|
|
20
20
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -13,7 +13,7 @@ export default async function getShieldedPoolState(grpcPool) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
const { response } = await grpcPool.getClient().getShieldedPoolState(getShieldedPoolStateRequest);
|
|
16
|
+
const { response } = await (await grpcPool.getClient()).getShieldedPoolState(getShieldedPoolStateRequest);
|
|
17
17
|
const { version } = response;
|
|
18
18
|
if (version.oneofKind !== 'v0') {
|
|
19
19
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -8,7 +8,7 @@ export default async function broadcast(grpcPool, stateTransition) {
|
|
|
8
8
|
const broadcastStateTransitionRequest = BroadcastStateTransitionRequest.create({
|
|
9
9
|
stateTransition: stateTransition.bytes()
|
|
10
10
|
});
|
|
11
|
-
await grpcPool.getClient().broadcastStateTransition(broadcastStateTransitionRequest);
|
|
11
|
+
await (await grpcPool.getClient()).broadcastStateTransition(broadcastStateTransitionRequest);
|
|
12
12
|
}
|
|
13
13
|
catch (err) {
|
|
14
14
|
const errorBin = err.meta?.['dash-serialized-consensus-error-bin'];
|
|
@@ -18,7 +18,7 @@ export default async function waitForStateTransitionResult(grpcPool, stateTransi
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
const { response } = await grpcPool.getClient().waitForStateTransitionResult(waitForStateTransitionResultRequest);
|
|
21
|
+
const { response } = await (await grpcPool.getClient()).waitForStateTransitionResult(waitForStateTransitionResultRequest);
|
|
22
22
|
const { version } = response;
|
|
23
23
|
if (version.oneofKind !== 'v0') {
|
|
24
24
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -17,7 +17,7 @@ export default async function getIdentitiesTokenBalances(grpcPool, identifiers,
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
const { response } = await grpcPool.getClient().getIdentitiesTokenBalances(getIdentitiesTokenBalancesRequest);
|
|
20
|
+
const { response } = await (await grpcPool.getClient()).getIdentitiesTokenBalances(getIdentitiesTokenBalancesRequest);
|
|
21
21
|
const { version } = response;
|
|
22
22
|
if (version.oneofKind !== 'v0') {
|
|
23
23
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -17,7 +17,7 @@ export default async function getIdentityTokensBalances(grpcPool, identifier, to
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
const { response } = await grpcPool.getClient().getIdentityTokenBalances(getIdentityTokenBalancesRequest);
|
|
20
|
+
const { response } = await (await grpcPool.getClient()).getIdentityTokenBalances(getIdentityTokenBalancesRequest);
|
|
21
21
|
const { version } = response;
|
|
22
22
|
if (version.oneofKind !== 'v0') {
|
|
23
23
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -15,7 +15,7 @@ export default async function getTokenContractInfo(grpcPool, tokenIdentifier) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getTokenContractInfo(getTokenContractInfoRequest);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getTokenContractInfo(getTokenContractInfoRequest);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -15,7 +15,7 @@ export default async function getTokenDirectPurchasePrices(grpcPool, tokenIdenti
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getTokenDirectPurchasePrices(request);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getTokenDirectPurchasePrices(request);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -15,7 +15,7 @@ export default async function getTokenTotalSupply(grpcPool, tokenIdentifier) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getTokenTotalSupply(getTokenTotalSupplyRequest);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getTokenTotalSupply(getTokenTotalSupplyRequest);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -4,7 +4,7 @@ import { calculateStateIdHash } from './calculateStateIdHash.js';
|
|
|
4
4
|
import { verifySignatureDigest } from 'pshenmic-dpp';
|
|
5
5
|
import hexToBytes from './hexToBytes.js';
|
|
6
6
|
export default async function verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey) {
|
|
7
|
-
if (
|
|
7
|
+
if (Date.now() - Number(metadata.timeMs) > 15 * 60 * 1000) {
|
|
8
8
|
throw new Error('Request is stalled (over 15 minutes)');
|
|
9
9
|
}
|
|
10
10
|
const stateId = StateId.create({
|