@dashevo/dapi-grpc 0.23.0 → 0.23.2

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.
@@ -0,0 +1,130 @@
1
+ const { PlatformClient } = require('./platform_pb_service');
2
+ const { promisify } = require('util');
3
+
4
+ class PlatformPromiseClient {
5
+ /**
6
+ * @param {string} hostname
7
+ * @param {?Object} credentials
8
+ * @param {?Object} options
9
+ */
10
+ constructor(hostname, credentials , options = {}) {
11
+ this.client = new PlatformClient(hostname, options)
12
+
13
+ this.protocolVersion = undefined;
14
+ }
15
+
16
+ /**
17
+ * @param {!BroadcastStateTransitionRequest} broadcastStateTransitionRequest
18
+ * @param {?Object<string, string>} metadata
19
+ * @return {Promise<!BroadcastStateTransitionResponse>}
20
+ */
21
+ broadcastStateTransition(broadcastStateTransitionRequest, metadata = {}) {
22
+ return promisify(
23
+ this.client.broadcastStateTransition.bind(this.client),
24
+ )(
25
+ broadcastStateTransitionRequest,
26
+ metadata,
27
+ );
28
+ }
29
+
30
+ /**
31
+ * @param {!GetIdentityRequest} getIdentityRequest
32
+ * @param {?Object<string, string>} metadata
33
+ * @return {Promise<!GetIdentityResponse>}
34
+ */
35
+ getIdentity(getIdentityRequest, metadata = {}) {
36
+ return promisify(
37
+ this.client.getIdentity.bind(this.client),
38
+ )(
39
+ getIdentityRequest,
40
+ metadata,
41
+ );
42
+ }
43
+
44
+ /**
45
+ *
46
+ * @param {!GetDataContractRequest} getDataContractRequest
47
+ * @param {?Object<string, string>} metadata
48
+ * @returns {Promise<!GetDataContractResponse>}
49
+ */
50
+ getDataContract(getDataContractRequest, metadata = {}) {
51
+ return promisify(
52
+ this.client.getDataContract.bind(this.client),
53
+ )(
54
+ getDataContractRequest,
55
+ metadata,
56
+ );
57
+ }
58
+
59
+ /**
60
+ *
61
+ * @param {!GetDocumentsRequest} getDocumentsRequest
62
+ * @param {?Object<string, string>} metadata
63
+ * @returns {Promise<!GetDocumentsResponse>}
64
+ */
65
+ getDocuments(getDocumentsRequest, metadata = {}) {
66
+ return promisify(
67
+ this.client.getDocuments.bind(this.client),
68
+ )(
69
+ getDocumentsRequest,
70
+ metadata,
71
+ );
72
+ }
73
+
74
+ /**
75
+ * @param {!GetIdentitiesByPublicKeyHashesRequest} getIdentitiesByPublicKeyHashesRequest
76
+ * @param {?Object<string, string>} metadata
77
+ * @returns {Promise<!GetIdentitiesByPublicKeyHashesResponse>}
78
+ */
79
+ getIdentitiesByPublicKeyHashes(
80
+ getIdentitiesByPublicKeyHashesRequest, metadata = {}
81
+ ) {
82
+ return promisify(
83
+ this.client.getIdentitiesByPublicKeyHashes.bind(this.client),
84
+ )(
85
+ getIdentitiesByPublicKeyHashesRequest,
86
+ metadata,
87
+ );
88
+ }
89
+
90
+ /**
91
+ * @param {!WaitForStateTransitionResultRequest} waitForStateTransitionResultRequest
92
+ * @param {?Object<string, string>} metadata
93
+ * @returns {Promise<!WaitForStateTransitionResultResponse>}
94
+ */
95
+ waitForStateTransitionResult(
96
+ waitForStateTransitionResultRequest, metadata = {}
97
+ ) {
98
+ return promisify(
99
+ this.client.waitForStateTransitionResult.bind(this.client),
100
+ )(
101
+ waitForStateTransitionResultRequest,
102
+ metadata,
103
+ );
104
+ }
105
+
106
+ /**
107
+ * @param {!GetConsensusParamsRequest} getConsensusParamsRequest
108
+ * @param {?Object<string, string>} metadata
109
+ * @returns {Promise<!GetConsensusParamsResponse>}
110
+ */
111
+ getConsensusParams(
112
+ getConsensusParamsRequest, metadata = {}
113
+ ) {
114
+ return promisify(
115
+ this.client.getConsensusParams.bind(this.client),
116
+ )(
117
+ getConsensusParamsRequest,
118
+ metadata,
119
+ );
120
+ }
121
+
122
+ /**
123
+ * @param {string} protocolVersion
124
+ */
125
+ setProtocolVersion(protocolVersion) {
126
+ this.setProtocolVersion = protocolVersion;
127
+ }
128
+ }
129
+
130
+ module.exports = PlatformPromiseClient;