@dashevo/dapi-client 0.23.0-dev.2 → 0.23.0-dev.5
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/index.js +9 -0
- package/lib/methods/platform/PlatformMethodsFacade.js +0 -2
- package/lib/methods/platform/getIdentitiesByPublicKeyHashes/GetIdentitiesByPublicKeyHashesResponse.js +2 -10
- package/lib/test/fixtures/getMNListDiffsFixture.js +1066 -1068
- package/package.json +7 -7
- package/lib/methods/platform/getIdentityIdsByPublicKeyHashes/GetIdentityIdsByPublicKeyHashesResponse.js +0 -45
- package/lib/methods/platform/getIdentityIdsByPublicKeyHashes/getIdentityIdsByPublicKeyHashesFactory.js +0 -63
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-client",
|
|
3
|
-
"version": "0.23.0-dev.
|
|
3
|
+
"version": "0.23.0-dev.5",
|
|
4
4
|
"description": "Client library used to access Dash DAPI endpoints",
|
|
5
|
-
"main": "lib/
|
|
5
|
+
"main": "lib/index.js",
|
|
6
6
|
"contributors": [
|
|
7
7
|
{
|
|
8
8
|
"name": "Ivan Shumkov",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
}
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@dashevo/dapi-grpc": "~0.23.0-dev.
|
|
30
|
-
"@dashevo/dash-spv": "
|
|
31
|
-
"@dashevo/dashcore-lib": "
|
|
32
|
-
"@dashevo/dpp": "~0.23.0-dev.
|
|
33
|
-
"@dashevo/grpc-common": "~0.23.0-dev.
|
|
29
|
+
"@dashevo/dapi-grpc": "~0.23.0-dev.5",
|
|
30
|
+
"@dashevo/dash-spv": "~1.1.7-2",
|
|
31
|
+
"@dashevo/dashcore-lib": "~0.19.39",
|
|
32
|
+
"@dashevo/dpp": "~0.23.0-dev.5",
|
|
33
|
+
"@dashevo/grpc-common": "~0.23.0-dev.5",
|
|
34
34
|
"@grpc/grpc-js": "^1.3.7",
|
|
35
35
|
"axios": "^0.21.1",
|
|
36
36
|
"bs58": "^4.0.1",
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const cbor = require('cbor');
|
|
2
|
-
|
|
3
|
-
const AbstractResponse = require('../response/AbstractResponse');
|
|
4
|
-
|
|
5
|
-
class GetIdentityIdsByPublicKeyHashesResponse extends AbstractResponse {
|
|
6
|
-
/**
|
|
7
|
-
* @param {Buffer[]} identityIds
|
|
8
|
-
* @param {Metadata} metadata
|
|
9
|
-
* @param {Proof} [proof]
|
|
10
|
-
*/
|
|
11
|
-
constructor(identityIds, metadata, proof = undefined) {
|
|
12
|
-
super(metadata, proof);
|
|
13
|
-
|
|
14
|
-
this.identityIds = identityIds;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @returns {Array<Buffer[]>}
|
|
19
|
-
*/
|
|
20
|
-
getIdentityIds() {
|
|
21
|
-
return this.identityIds;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param proto
|
|
26
|
-
* @returns {GetIdentityIdsByPublicKeyHashesResponse}
|
|
27
|
-
*/
|
|
28
|
-
static createFromProto(proto) {
|
|
29
|
-
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(proto);
|
|
30
|
-
|
|
31
|
-
return new GetIdentityIdsByPublicKeyHashesResponse(
|
|
32
|
-
proto.getIdentityIdsList().map((identityIdsSerialized) => {
|
|
33
|
-
const identityIds = cbor.decode(identityIdsSerialized);
|
|
34
|
-
|
|
35
|
-
return identityIds.map((identityId) => (
|
|
36
|
-
(identityId.length > 0 ? Buffer.from(identityId) : null)
|
|
37
|
-
));
|
|
38
|
-
}),
|
|
39
|
-
metadata,
|
|
40
|
-
proof,
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
module.exports = GetIdentityIdsByPublicKeyHashesResponse;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
v0: {
|
|
3
|
-
PlatformPromiseClient,
|
|
4
|
-
GetIdentityIdsByPublicKeyHashesRequest,
|
|
5
|
-
},
|
|
6
|
-
} = require('@dashevo/dapi-grpc');
|
|
7
|
-
|
|
8
|
-
const GetIdentityIdsByPublicKeyHashesResponse = require('./GetIdentityIdsByPublicKeyHashesResponse');
|
|
9
|
-
const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @param {GrpcTransport} grpcTransport
|
|
13
|
-
* @returns {getIdentityIdsByPublicKeyHashes}
|
|
14
|
-
*/
|
|
15
|
-
function getIdentityIdsByPublicKeyHashesFactory(grpcTransport) {
|
|
16
|
-
/**
|
|
17
|
-
* Fetch the identities by public key hashes
|
|
18
|
-
*
|
|
19
|
-
* @typedef {getIdentityIdsByPublicKeyHashes}
|
|
20
|
-
* @param {Buffer[]} publicKeyHashes
|
|
21
|
-
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
|
22
|
-
* @returns {Promise<GetIdentityIdsByPublicKeyHashesResponse>}
|
|
23
|
-
*/
|
|
24
|
-
async function getIdentityIdsByPublicKeyHashes(publicKeyHashes, options = {}) {
|
|
25
|
-
const getIdentityIdsByPublicKeyHashesRequest = new GetIdentityIdsByPublicKeyHashesRequest();
|
|
26
|
-
getIdentityIdsByPublicKeyHashesRequest.setPublicKeyHashesList(
|
|
27
|
-
publicKeyHashes,
|
|
28
|
-
);
|
|
29
|
-
getIdentityIdsByPublicKeyHashesRequest.setProve(!!options.prove);
|
|
30
|
-
|
|
31
|
-
let lastError;
|
|
32
|
-
|
|
33
|
-
// TODO: simple retry before the dapi versioning is properly implemented
|
|
34
|
-
for (let i = 0; i < 3; i += 1) {
|
|
35
|
-
try {
|
|
36
|
-
// eslint-disable-next-line no-await-in-loop
|
|
37
|
-
const getIdentityIdsByPublicKeyHashesResponse = await grpcTransport.request(
|
|
38
|
-
PlatformPromiseClient,
|
|
39
|
-
'getIdentityIdsByPublicKeyHashes',
|
|
40
|
-
getIdentityIdsByPublicKeyHashesRequest,
|
|
41
|
-
options,
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
return GetIdentityIdsByPublicKeyHashesResponse
|
|
45
|
-
.createFromProto(getIdentityIdsByPublicKeyHashesResponse);
|
|
46
|
-
} catch (e) {
|
|
47
|
-
if (e instanceof InvalidResponseError) {
|
|
48
|
-
lastError = e;
|
|
49
|
-
} else {
|
|
50
|
-
throw e;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// If we made it past the cycle it means that the retry didn't work,
|
|
56
|
-
// and we're throwing the last error encountered
|
|
57
|
-
throw lastError;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return getIdentityIdsByPublicKeyHashes;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
module.exports = getIdentityIdsByPublicKeyHashesFactory;
|