@dashevo/dapi-client 0.25.22 → 1.0.0-beta.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.
Files changed (40) hide show
  1. package/docs/_sidebar.md +3 -1
  2. package/docs/usage/application/core/getBestBlockHeight.md +10 -0
  3. package/docs/usage/application/core/subscribeToBlockHeadersWithChainLocks.md +39 -0
  4. package/docs/usage/application/core/subscribeToMasternodeList.md +24 -0
  5. package/docs/usage/{utils → application/core}/subscribeToTransactionsWithProofs.md +13 -10
  6. package/lib/BlockHeadersProvider/createBlockHeadersProviderFromOptions.js +4 -2
  7. package/lib/DAPIClient.js +19 -1
  8. package/lib/SimplifiedMasternodeListProvider/SimplifiedMasternodeListProvider.js +174 -65
  9. package/lib/SimplifiedMasternodeListProvider/createMasternodeListStreamFactory.js +49 -0
  10. package/lib/dapiAddressProvider/createDAPIAddressProviderFromOptions.js +4 -9
  11. package/lib/methods/core/CoreMethodsFacade.js +10 -6
  12. package/lib/methods/core/getBestBlockHeightFactory.js +34 -0
  13. package/lib/methods/core/getBlockchainStatusFactory.js +59 -0
  14. package/lib/methods/core/getMasternodeStatusFactory.js +45 -0
  15. package/lib/methods/core/subscribeToMasternodeListFactory.js +46 -0
  16. package/lib/methods/core/subscribeToTransactionsWithProofsFactory.js +1 -1
  17. package/lib/methods/platform/PlatformMethodsFacade.js +10 -2
  18. package/lib/methods/platform/getIdentitiesContractKeys/GetIdentitiesContractKeysResponse.js +65 -0
  19. package/lib/methods/platform/getIdentitiesContractKeys/getIdentitiesContractKeysFactory.js +93 -0
  20. package/lib/methods/platform/getIdentityByPublicKeyHash/GetIdentityByPublicKeyHashResponse.js +40 -0
  21. package/lib/methods/platform/getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory.js +64 -0
  22. package/lib/methods/platform/getIdentityContractNonce/GetIdentityContractNonceResponse.js +49 -0
  23. package/lib/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.js +81 -0
  24. package/lib/methods/platform/getIdentityKeys/GetIdentityKeysResponse.js +52 -0
  25. package/lib/methods/platform/getIdentityKeys/getIdentityKeysFactory.js +78 -0
  26. package/lib/methods/platform/getIdentityNonce/GetIdentityNonceResponse.js +49 -0
  27. package/lib/methods/platform/getIdentityNonce/getIdentityNonceFactory.js +74 -0
  28. package/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.js +1 -1
  29. package/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js +1 -1
  30. package/lib/transport/GrpcTransport/GrpcTransport.js +7 -1
  31. package/lib/transport/GrpcTransport/createGrpcTransportError.js +1 -1
  32. package/lib/transport/ReconnectableStream.js +48 -6
  33. package/package.json +8 -8
  34. package/docs/usage/application/core/generateToAddress.md +0 -13
  35. package/docs/usage/application/core/getMnListDiff.md +0 -12
  36. package/lib/methods/core/generateToAddressFactory.js +0 -25
  37. package/lib/methods/core/getMnListDiffFactory.js +0 -21
  38. package/lib/methods/core/getStatusFactory.js +0 -68
  39. package/lib/methods/platform/getIdentitiesByPublicKeyHashes/GetIdentitiesByPublicKeyHashesResponse.js +0 -46
  40. package/lib/methods/platform/getIdentitiesByPublicKeyHashes/getIdentitiesByPublicKeyHashesFactory.js +0 -65
@@ -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;