@dashevo/dapi-client 0.22.13 → 0.23.0-dev.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 CHANGED
@@ -1,8 +1,8 @@
1
1
  # DAPI Client
2
2
 
3
3
  [![NPM Version](https://img.shields.io/npm/v/@dashevo/dapi-client)](https://www.npmjs.com/package/@dashevo/dapi-client)
4
- [![Build Status](https://github.com/dashevo/js-dapi-client/actions/workflows/test_and_release.yml/badge.svg)](https://github.com/dashevo/js-dapi-client/actions/workflows/test_and_release.yml)
5
- [![Release Date](https://img.shields.io/github/release-date/dashevo/js-dapi-client)](https://github.com/dashevo/js-dapi-client/releases/latest)
4
+ [![Build Status](https://github.com/dashevo/platform/actions/workflows/release.yml/badge.svg)](https://github.com/dashevo/platform/actions/workflows/release.yml)
5
+ [![Release Date](https://img.shields.io/github/release-date/dashevo/platform)](https://github.com/dashevo/platform/releases/latest)
6
6
  [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen)](https://github.com/RichardLitt/standard-readme)
7
7
 
8
8
  Client library used to access Dash DAPI endpoints
@@ -2,7 +2,6 @@ const broadcastStateTransitionFactory = require('./broadcastStateTransition/broa
2
2
  const getDataContractFactory = require('./getDataContract/getDataContractFactory');
3
3
  const getDocumentsFactory = require('./getDocuments/getDocumentsFactory');
4
4
  const getIdentityFactory = require('./getIdentity/getIdentityFactory');
5
- const getIdentityIdsByPublicKeyHashesFactory = require('./getIdentityIdsByPublicKeyHashes/getIdentityIdsByPublicKeyHashesFactory');
6
5
  const getIdentitiesByPublicKeyHashesFactory = require('./getIdentitiesByPublicKeyHashes/getIdentitiesByPublicKeyHashesFactory');
7
6
  const waitForStateTransitionResultFactory = require('./waitForStateTransitionResult/waitForStateTransitionResultFactory');
8
7
  const getConsensusParamsFactory = require('./getConsensusParams/getConsensusParamsFactory');
@@ -16,7 +15,6 @@ class PlatformMethodsFacade {
16
15
  this.getDataContract = getDataContractFactory(grpcTransport);
17
16
  this.getDocuments = getDocumentsFactory(grpcTransport);
18
17
  this.getIdentity = getIdentityFactory(grpcTransport);
19
- this.getIdentityIdsByPublicKeyHashes = getIdentityIdsByPublicKeyHashesFactory(grpcTransport);
20
18
  this.getIdentitiesByPublicKeyHashes = getIdentitiesByPublicKeyHashesFactory(grpcTransport);
21
19
  this.waitForStateTransitionResult = waitForStateTransitionResultFactory(grpcTransport);
22
20
  this.getConsensusParams = getConsensusParamsFactory(grpcTransport);
@@ -1,5 +1,3 @@
1
- const cbor = require('cbor');
2
-
3
1
  const AbstractResponse = require('../response/AbstractResponse');
4
2
 
5
3
  class GetIdentitiesByPublicKeyHashesResponse extends AbstractResponse {
@@ -15,7 +13,7 @@ class GetIdentitiesByPublicKeyHashesResponse extends AbstractResponse {
15
13
  }
16
14
 
17
15
  /**
18
- * @returns {Array<Buffer[]>}
16
+ * @returns {Buffer[]}
19
17
  */
20
18
  getIdentities() {
21
19
  return this.identities;
@@ -29,13 +27,7 @@ class GetIdentitiesByPublicKeyHashesResponse extends AbstractResponse {
29
27
  const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(proto);
30
28
 
31
29
  return new GetIdentitiesByPublicKeyHashesResponse(
32
- proto.getIdentitiesList().map((identitiesSerialized) => {
33
- const identities = cbor.decode(identitiesSerialized);
34
-
35
- return identities.map((identity) => (
36
- (identity.length > 0 ? Buffer.from(identity) : null)
37
- ));
38
- }),
30
+ proto.getIdentitiesList_asU8().map((identity) => Buffer.from(identity)),
39
31
  metadata,
40
32
  proof,
41
33
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/dapi-client",
3
- "version": "0.22.13",
3
+ "version": "0.23.0-dev.3",
4
4
  "description": "Client library used to access Dash DAPI endpoints",
5
5
  "main": "lib/index.js",
6
6
  "contributors": [
@@ -26,11 +26,11 @@
26
26
  }
27
27
  ],
28
28
  "dependencies": {
29
- "@dashevo/dapi-grpc": "~0.22.13",
30
- "@dashevo/dash-spv": "github:dashevo/dash-spv",
29
+ "@dashevo/dapi-grpc": "~0.23.0-dev.3",
30
+ "@dashevo/dash-spv": "~1.1.7-0",
31
31
  "@dashevo/dashcore-lib": "~0.19.39",
32
- "@dashevo/dpp": "~0.22.13",
33
- "@dashevo/grpc-common": "~0.22.13",
32
+ "@dashevo/dpp": "~0.23.0-dev.3",
33
+ "@dashevo/grpc-common": "~0.23.0-dev.3",
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;