@dashevo/dapi-client 1.0.0-pr.1825.9 → 1.0.0-pr.1902.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/methods/platform/PlatformMethodsFacade.js +4 -2
- package/lib/methods/platform/getIdentitiesContractKeys/GetIdentitiesContractKeysResponse.js +65 -0
- package/lib/methods/platform/getIdentitiesContractKeys/getIdentitiesContractKeysFactory.js +93 -0
- package/lib/methods/platform/getIdentityByPublicKeyHash/GetIdentityByPublicKeyHashResponse.js +40 -0
- package/lib/methods/platform/getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory.js +64 -0
- package/lib/transport/GrpcTransport/GrpcTransport.js +7 -1
- package/package.json +6 -6
- package/lib/methods/platform/getIdentitiesByPublicKeyHashes/GetIdentitiesByPublicKeyHashesResponse.js +0 -46
- package/lib/methods/platform/getIdentitiesByPublicKeyHashes/getIdentitiesByPublicKeyHashesFactory.js +0 -65
|
@@ -3,7 +3,8 @@ const getDataContractFactory = require('./getDataContract/getDataContractFactory
|
|
|
3
3
|
const getDataContractHistoryFactory = require('./getDataContractHistory/getDataContractHistoryFactory');
|
|
4
4
|
const getDocumentsFactory = require('./getDocuments/getDocumentsFactory');
|
|
5
5
|
const getIdentityFactory = require('./getIdentity/getIdentityFactory');
|
|
6
|
-
const
|
|
6
|
+
const getIdentityByPublicKeyHashFactory = require('./getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory');
|
|
7
|
+
const getIdentitiesContractKeysFactory = require('./getIdentitiesContractKeys/getIdentitiesContractKeysFactory');
|
|
7
8
|
const waitForStateTransitionResultFactory = require('./waitForStateTransitionResult/waitForStateTransitionResultFactory');
|
|
8
9
|
const getConsensusParamsFactory = require('./getConsensusParams/getConsensusParamsFactory');
|
|
9
10
|
const getEpochsInfoFactory = require('./getEpochsInfo/getEpochsInfoFactory');
|
|
@@ -23,7 +24,8 @@ class PlatformMethodsFacade {
|
|
|
23
24
|
this.getDataContractHistory = getDataContractHistoryFactory(grpcTransport);
|
|
24
25
|
this.getDocuments = getDocumentsFactory(grpcTransport);
|
|
25
26
|
this.getIdentity = getIdentityFactory(grpcTransport);
|
|
26
|
-
this.
|
|
27
|
+
this.getIdentityByPublicKeyHash = getIdentityByPublicKeyHashFactory(grpcTransport);
|
|
28
|
+
this.getIdentitiesContractKeys = getIdentitiesContractKeysFactory(grpcTransport);
|
|
27
29
|
this.waitForStateTransitionResult = waitForStateTransitionResultFactory(grpcTransport);
|
|
28
30
|
this.getConsensusParams = getConsensusParamsFactory(grpcTransport);
|
|
29
31
|
this.getEpochsInfo = getEpochsInfoFactory(grpcTransport);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const { Identifier } = require('@dashevo/wasm-dpp');
|
|
2
|
+
const AbstractResponse = require('../response/AbstractResponse');
|
|
3
|
+
|
|
4
|
+
class GetIdentitiesContractKeysResponse extends AbstractResponse {
|
|
5
|
+
/**
|
|
6
|
+
* @param {object} identitiesKeys
|
|
7
|
+
* @param {Metadata} metadata
|
|
8
|
+
* @param {Proof} [proof]
|
|
9
|
+
*/
|
|
10
|
+
constructor(identitiesKeys, metadata, proof = undefined) {
|
|
11
|
+
super(metadata, proof);
|
|
12
|
+
|
|
13
|
+
this.identitiesKeys = identitiesKeys;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @returns {object}
|
|
18
|
+
*/
|
|
19
|
+
getIdentitiesKeys() {
|
|
20
|
+
return this.identitiesKeys;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param proto
|
|
25
|
+
* @returns {GetIdentitiesContractKeysResponse}
|
|
26
|
+
*/
|
|
27
|
+
static createFromProto(proto) {
|
|
28
|
+
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(proto);
|
|
29
|
+
|
|
30
|
+
const identitiesKeys = proto.getV0().getIdentitiesKeys();
|
|
31
|
+
|
|
32
|
+
let identitiesKeysMap = {};
|
|
33
|
+
if (identitiesKeys) {
|
|
34
|
+
const keysEntries = identitiesKeys.getEntriesList();
|
|
35
|
+
|
|
36
|
+
identitiesKeysMap = keysEntries.reduce((acc, entry) => {
|
|
37
|
+
const identityId = Identifier.from(Buffer.from(entry.getIdentityId())).toString();
|
|
38
|
+
if (!acc[identityId]) {
|
|
39
|
+
acc[identityId] = {};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
entry.getKeysList().forEach((key) => {
|
|
43
|
+
const purpose = key.getPurpose();
|
|
44
|
+
if (!acc[identityId][purpose]) {
|
|
45
|
+
// eslint-disable-next-line no-param-reassign
|
|
46
|
+
acc[identityId][purpose] = [];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// eslint-disable-next-line no-param-reassign
|
|
50
|
+
acc[identityId][purpose] = acc[identityId][purpose].concat(key.getKeysBytesList());
|
|
51
|
+
}, {});
|
|
52
|
+
|
|
53
|
+
return acc;
|
|
54
|
+
}, {});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return new GetIdentitiesContractKeysResponse(
|
|
58
|
+
identitiesKeysMap,
|
|
59
|
+
metadata,
|
|
60
|
+
proof,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = GetIdentitiesContractKeysResponse;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const {
|
|
2
|
+
v0: {
|
|
3
|
+
PlatformPromiseClient,
|
|
4
|
+
GetIdentitiesContractKeysRequest,
|
|
5
|
+
},
|
|
6
|
+
} = require('@dashevo/dapi-grpc');
|
|
7
|
+
const { IdentityPublicKey } = require('@dashevo/wasm-dpp');
|
|
8
|
+
|
|
9
|
+
const GetIdentitiesContractKeysResponse = require('./GetIdentitiesContractKeysResponse');
|
|
10
|
+
const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {GrpcTransport} grpcTransport
|
|
14
|
+
* @returns {getIdentitiesContractKeys}
|
|
15
|
+
*/
|
|
16
|
+
function getIdentitiesContractKeysFactory(grpcTransport) {
|
|
17
|
+
/**
|
|
18
|
+
* Fetch the identities by public key hashes
|
|
19
|
+
* @typedef {getIdentitiesContractKeys}
|
|
20
|
+
* @param {Buffer[]} identitiesIds
|
|
21
|
+
* @param {Buffer} contractId
|
|
22
|
+
* @param {IdentityPublicKey.PURPOSES[]} keyPurposes
|
|
23
|
+
* @param {string | null} documentTypeName
|
|
24
|
+
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
|
25
|
+
* @returns {Promise<GetIdentitiesContractKeysResponse>}
|
|
26
|
+
*/
|
|
27
|
+
async function getIdentitiesContractKeys(
|
|
28
|
+
identitiesIds,
|
|
29
|
+
contractId,
|
|
30
|
+
keyPurposes,
|
|
31
|
+
documentTypeName = null,
|
|
32
|
+
options = {},
|
|
33
|
+
) {
|
|
34
|
+
const { GetIdentitiesContractKeysRequestV0 } = GetIdentitiesContractKeysRequest;
|
|
35
|
+
const getIdentitiesContractKeysRequest = new GetIdentitiesContractKeysRequest();
|
|
36
|
+
|
|
37
|
+
// eslint-disable-next-line no-param-reassign
|
|
38
|
+
identitiesIds = identitiesIds.map((id) => {
|
|
39
|
+
if (Buffer.isBuffer(id)) {
|
|
40
|
+
// eslint-disable-next-line no-param-reassign
|
|
41
|
+
id = Buffer.from(id);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return id;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (Buffer.isBuffer(contractId)) {
|
|
48
|
+
// eslint-disable-next-line no-param-reassign
|
|
49
|
+
contractId = Buffer.from(contractId);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getIdentitiesContractKeysRequest.setV0(
|
|
53
|
+
new GetIdentitiesContractKeysRequestV0()
|
|
54
|
+
.setProve(!!options.prove)
|
|
55
|
+
.setIdentitiesIdsList(identitiesIds)
|
|
56
|
+
.setContractId(contractId)
|
|
57
|
+
.setPurposesList(keyPurposes)
|
|
58
|
+
.setDocumentTypeName(documentTypeName),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
let lastError;
|
|
62
|
+
|
|
63
|
+
// TODO: simple retry before the dapi versioning is properly implemented
|
|
64
|
+
for (let i = 0; i < 3; i += 1) {
|
|
65
|
+
try {
|
|
66
|
+
// eslint-disable-next-line no-await-in-loop
|
|
67
|
+
const getIdentitiesContractKeysResponse = await grpcTransport.request(
|
|
68
|
+
PlatformPromiseClient,
|
|
69
|
+
'getIdentitiesContractKeys',
|
|
70
|
+
getIdentitiesContractKeysRequest,
|
|
71
|
+
options,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return GetIdentitiesContractKeysResponse
|
|
75
|
+
.createFromProto(getIdentitiesContractKeysResponse);
|
|
76
|
+
} catch (e) {
|
|
77
|
+
if (e instanceof InvalidResponseError) {
|
|
78
|
+
lastError = e;
|
|
79
|
+
} else {
|
|
80
|
+
throw e;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// If we made it past the cycle it means that the retry didn't work,
|
|
86
|
+
// and we're throwing the last error encountered
|
|
87
|
+
throw lastError;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return getIdentitiesContractKeys;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module.exports = getIdentitiesContractKeysFactory;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const AbstractResponse = require('../response/AbstractResponse');
|
|
2
|
+
|
|
3
|
+
class GetIdentityByPublicKeyHashResponse extends AbstractResponse {
|
|
4
|
+
/**
|
|
5
|
+
* @param {Buffer} identities
|
|
6
|
+
* @param identity
|
|
7
|
+
* @param {Metadata} metadata
|
|
8
|
+
* @param {Proof} [proof]
|
|
9
|
+
*/
|
|
10
|
+
constructor(identity, metadata, proof = undefined) {
|
|
11
|
+
super(metadata, proof);
|
|
12
|
+
|
|
13
|
+
this.identity = identity;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @returns {Buffer[]}
|
|
18
|
+
*/
|
|
19
|
+
getIdentity() {
|
|
20
|
+
return this.identity;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param proto
|
|
25
|
+
* @returns {GetIdentityByPublicKeyHashResponse}
|
|
26
|
+
*/
|
|
27
|
+
static createFromProto(proto) {
|
|
28
|
+
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(proto);
|
|
29
|
+
|
|
30
|
+
const identity = proto.getV0().getIdentity();
|
|
31
|
+
|
|
32
|
+
return new GetIdentityByPublicKeyHashResponse(
|
|
33
|
+
Buffer.from(identity),
|
|
34
|
+
metadata,
|
|
35
|
+
proof,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = GetIdentityByPublicKeyHashResponse;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const {
|
|
2
|
+
v0: {
|
|
3
|
+
PlatformPromiseClient,
|
|
4
|
+
GetIdentityByPublicKeyHashRequest,
|
|
5
|
+
},
|
|
6
|
+
} = require('@dashevo/dapi-grpc');
|
|
7
|
+
|
|
8
|
+
const GetIdentityByPublicKeyHashResponse = require('./GetIdentityByPublicKeyHashResponse');
|
|
9
|
+
const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {GrpcTransport} grpcTransport
|
|
13
|
+
* @returns {getIdentityByPublicKeyHash}
|
|
14
|
+
*/
|
|
15
|
+
function getIdentityByPublicKeyHashFactory(grpcTransport) {
|
|
16
|
+
/**
|
|
17
|
+
* Fetch the identity by public key hash
|
|
18
|
+
* @typedef {getIdentityByPublicKeyHash}
|
|
19
|
+
* @param {Buffer} publicKeyHash
|
|
20
|
+
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
|
21
|
+
* @returns {Promise<GetIdentityByPublicKeyHashResponse>}
|
|
22
|
+
*/
|
|
23
|
+
async function getIdentityByPublicKeyHash(publicKeyHash, options = {}) {
|
|
24
|
+
const { GetIdentityByPublicKeyHashRequestV0 } = GetIdentityByPublicKeyHashRequest;
|
|
25
|
+
const getIdentityByPublicKeyHashRequest = new GetIdentityByPublicKeyHashRequest();
|
|
26
|
+
getIdentityByPublicKeyHashRequest.setV0(
|
|
27
|
+
new GetIdentityByPublicKeyHashRequestV0()
|
|
28
|
+
.setPublicKeyHash(publicKeyHash)
|
|
29
|
+
.setProve(!!options.prove),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
let lastError;
|
|
33
|
+
|
|
34
|
+
// TODO: simple retry before the dapi versioning is properly implemented
|
|
35
|
+
for (let i = 0; i < 3; i += 1) {
|
|
36
|
+
try {
|
|
37
|
+
// eslint-disable-next-line no-await-in-loop
|
|
38
|
+
const getIdentityByPublicKeyHashResponse = await grpcTransport.request(
|
|
39
|
+
PlatformPromiseClient,
|
|
40
|
+
'getIdentityByPublicKeyHash',
|
|
41
|
+
getIdentityByPublicKeyHashRequest,
|
|
42
|
+
options,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return GetIdentityByPublicKeyHashResponse
|
|
46
|
+
.createFromProto(getIdentityByPublicKeyHashResponse);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
if (e instanceof InvalidResponseError) {
|
|
49
|
+
lastError = e;
|
|
50
|
+
} else {
|
|
51
|
+
throw e;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// If we made it past the cycle it means that the retry didn't work,
|
|
57
|
+
// and we're throwing the last error encountered
|
|
58
|
+
throw lastError;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return getIdentityByPublicKeyHash;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = getIdentityByPublicKeyHashFactory;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const GrpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes');
|
|
1
2
|
const logger = require('../../logger');
|
|
2
3
|
|
|
3
4
|
const MaxRetriesReachedError = require('../errors/response/MaxRetriesReachedError');
|
|
@@ -81,7 +82,12 @@ class GrpcTransport {
|
|
|
81
82
|
} catch (error) {
|
|
82
83
|
this.lastUsedAddress = address;
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
// Show NOT_FOUND errors only in debug mode
|
|
86
|
+
if (error.code !== GrpcErrorCodes.NOT_FOUND) {
|
|
87
|
+
this.logger.error(`GRPC Request ${method} to ${address.toString()} failed with error: ${error.message}`);
|
|
88
|
+
} else {
|
|
89
|
+
this.logger.debug(`GRPC Request ${method} to ${address.toString()} failed with error: ${error.message}`);
|
|
90
|
+
}
|
|
85
91
|
|
|
86
92
|
// for unknown errors
|
|
87
93
|
if (error.code === undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-client",
|
|
3
|
-
"version": "1.0.0-pr.
|
|
3
|
+
"version": "1.0.0-pr.1902.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": "1.0.0-pr.
|
|
30
|
-
"@dashevo/dash-spv": "1.0.0-pr.
|
|
29
|
+
"@dashevo/dapi-grpc": "1.0.0-pr.1902.1",
|
|
30
|
+
"@dashevo/dash-spv": "1.0.0-pr.1902.1",
|
|
31
31
|
"@dashevo/dashcore-lib": "~0.21.1",
|
|
32
|
-
"@dashevo/grpc-common": "1.0.0-pr.
|
|
33
|
-
"@dashevo/wasm-dpp": "1.0.0-pr.
|
|
32
|
+
"@dashevo/grpc-common": "1.0.0-pr.1902.1",
|
|
33
|
+
"@dashevo/wasm-dpp": "1.0.0-pr.1902.1",
|
|
34
34
|
"bs58": "^4.0.1",
|
|
35
35
|
"cbor": "^8.0.0",
|
|
36
36
|
"google-protobuf": "^3.12.2",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"test:integration": "mocha './test/integration/**/*.spec.js'",
|
|
93
93
|
"test:node": "NODE_ENV=test mocha",
|
|
94
94
|
"test:browsers": "karma start ./karma.conf.js --single-run",
|
|
95
|
-
"test:coverage": "NODE_ENV=test nyc --check-coverage --stmts=98 --branch=98 --funcs=98 --lines=
|
|
95
|
+
"test:coverage": "NODE_ENV=test nyc --check-coverage --stmts=98 --branch=98 --funcs=98 --lines=94.99 yarn run mocha 'test/unit/**/*.spec.js' 'test/integration/**/*.spec.js'",
|
|
96
96
|
"prepublishOnly": "yarn run build:web"
|
|
97
97
|
},
|
|
98
98
|
"ultra": {
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const AbstractResponse = require('../response/AbstractResponse');
|
|
2
|
-
|
|
3
|
-
class GetIdentitiesByPublicKeyHashesResponse extends AbstractResponse {
|
|
4
|
-
/**
|
|
5
|
-
* @param {Buffer[]} identities
|
|
6
|
-
* @param {Metadata} metadata
|
|
7
|
-
* @param {Proof} [proof]
|
|
8
|
-
*/
|
|
9
|
-
constructor(identities, metadata, proof = undefined) {
|
|
10
|
-
super(metadata, proof);
|
|
11
|
-
|
|
12
|
-
this.identities = identities;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @returns {Buffer[]}
|
|
17
|
-
*/
|
|
18
|
-
getIdentities() {
|
|
19
|
-
return this.identities;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @param proto
|
|
24
|
-
* @returns {GetIdentitiesByPublicKeyHashesResponse}
|
|
25
|
-
*/
|
|
26
|
-
static createFromProto(proto) {
|
|
27
|
-
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(proto);
|
|
28
|
-
|
|
29
|
-
const identitiesList = proto.getV0().getIdentities();
|
|
30
|
-
|
|
31
|
-
return new GetIdentitiesByPublicKeyHashesResponse(
|
|
32
|
-
identitiesList !== undefined
|
|
33
|
-
? identitiesList.getIdentityEntriesList()
|
|
34
|
-
.map((identity) => {
|
|
35
|
-
const value = identity.getValue();
|
|
36
|
-
// TODO: rework to return whole `identity.getValue()` instead of inner getValue()
|
|
37
|
-
return value && Buffer.from(value.getValue());
|
|
38
|
-
})
|
|
39
|
-
: [],
|
|
40
|
-
metadata,
|
|
41
|
-
proof,
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
module.exports = GetIdentitiesByPublicKeyHashesResponse;
|
package/lib/methods/platform/getIdentitiesByPublicKeyHashes/getIdentitiesByPublicKeyHashesFactory.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
v0: {
|
|
3
|
-
PlatformPromiseClient,
|
|
4
|
-
GetIdentitiesByPublicKeyHashesRequest,
|
|
5
|
-
},
|
|
6
|
-
} = require('@dashevo/dapi-grpc');
|
|
7
|
-
|
|
8
|
-
const GetIdentitiesByPublicKeyHashesResponse = require('./GetIdentitiesByPublicKeyHashesResponse');
|
|
9
|
-
const InvalidResponseError = require('../response/errors/InvalidResponseError');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @param {GrpcTransport} grpcTransport
|
|
13
|
-
* @returns {getIdentitiesByPublicKeyHashes}
|
|
14
|
-
*/
|
|
15
|
-
function getIdentitiesByPublicKeyHashesFactory(grpcTransport) {
|
|
16
|
-
/**
|
|
17
|
-
* Fetch the identities by public key hashes
|
|
18
|
-
* @typedef {getIdentitiesByPublicKeyHashes}
|
|
19
|
-
* @param {Buffer[]} publicKeyHashes
|
|
20
|
-
* @param {DAPIClientOptions & {prove: boolean}} [options]
|
|
21
|
-
* @returns {Promise<GetIdentitiesByPublicKeyHashesResponse>}
|
|
22
|
-
*/
|
|
23
|
-
async function getIdentitiesByPublicKeyHashes(publicKeyHashes, options = {}) {
|
|
24
|
-
const { GetIdentitiesByPublicKeyHashesRequestV0 } = GetIdentitiesByPublicKeyHashesRequest;
|
|
25
|
-
const getIdentitiesByPublicKeyHashesRequest = new GetIdentitiesByPublicKeyHashesRequest();
|
|
26
|
-
getIdentitiesByPublicKeyHashesRequest.setV0(
|
|
27
|
-
new GetIdentitiesByPublicKeyHashesRequestV0()
|
|
28
|
-
.setPublicKeyHashesList(
|
|
29
|
-
publicKeyHashes,
|
|
30
|
-
).setProve(!!options.prove),
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
let lastError;
|
|
34
|
-
|
|
35
|
-
// TODO: simple retry before the dapi versioning is properly implemented
|
|
36
|
-
for (let i = 0; i < 3; i += 1) {
|
|
37
|
-
try {
|
|
38
|
-
// eslint-disable-next-line no-await-in-loop
|
|
39
|
-
const getIdentitiesByPublicKeyHashesResponse = await grpcTransport.request(
|
|
40
|
-
PlatformPromiseClient,
|
|
41
|
-
'getIdentitiesByPublicKeyHashes',
|
|
42
|
-
getIdentitiesByPublicKeyHashesRequest,
|
|
43
|
-
options,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
return GetIdentitiesByPublicKeyHashesResponse
|
|
47
|
-
.createFromProto(getIdentitiesByPublicKeyHashesResponse);
|
|
48
|
-
} catch (e) {
|
|
49
|
-
if (e instanceof InvalidResponseError) {
|
|
50
|
-
lastError = e;
|
|
51
|
-
} else {
|
|
52
|
-
throw e;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// If we made it past the cycle it means that the retry didn't work,
|
|
58
|
-
// and we're throwing the last error encountered
|
|
59
|
-
throw lastError;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return getIdentitiesByPublicKeyHashes;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
module.exports = getIdentitiesByPublicKeyHashesFactory;
|