@dashevo/dapi-grpc 0.24.0-dev.6 → 0.25.0-dev.10
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/Cargo.toml +39 -0
- package/README.md +3 -3
- package/browser.js +13 -5
- package/build.rs +65 -0
- package/clients/core/v0/nodejs/CorePromiseClient.js +2 -1
- package/clients/core/v0/nodejs/core_protoc.js +33 -33
- package/clients/core/v0/rust/README.md +3 -0
- package/clients/core/v0/rust/core_example.rs +14 -0
- package/clients/core/v0/web/CorePromiseClient.js +159 -0
- package/clients/core/v0/web/core_pb.d.ts +783 -0
- package/clients/core/v0/web/core_pb.js +33 -33
- package/clients/core/v0/web/core_pb_service.d.ts +161 -0
- package/clients/core/v0/web/core_pb_service.js +317 -0
- package/clients/platform/v0/nodejs/PlatformPromiseClient.js +2 -1
- package/clients/platform/v0/nodejs/platform_pbjs.js +10012 -1472
- package/clients/platform/v0/nodejs/platform_protoc.js +6811 -1243
- package/clients/platform/v0/rust/README.md +3 -0
- package/clients/platform/v0/rust/platform_example.rs +15 -0
- package/clients/platform/v0/web/PlatformPromiseClient.js +130 -0
- package/clients/platform/v0/web/platform_pb.d.ts +1312 -0
- package/clients/platform/v0/web/platform_pb.js +6811 -1243
- package/clients/platform/v0/web/platform_pb_service.d.ts +272 -0
- package/clients/platform/v0/web/platform_pb_service.js +501 -0
- package/lib/utils/parseMetadata.js +27 -0
- package/node.js +4 -0
- package/package.json +15 -3
- package/protos/platform/v0/platform.proto +157 -8
- package/scripts/build.sh +85 -79
- package/scripts/patch-protobuf-js.sh +31 -0
- package/src/lib.rs +15 -0
- package/clients/core/v0/web/core_grpc_web_pb.js +0 -499
- package/clients/platform/v0/web/platform_grpc_web_pb.js +0 -509
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
// package: org.dash.platform.dapi.v0
|
|
2
|
+
// file: platform.proto
|
|
3
|
+
|
|
4
|
+
var platform_pb = require("./platform_pb");
|
|
5
|
+
var grpc = require("@improbable-eng/grpc-web").grpc;
|
|
6
|
+
|
|
7
|
+
var Platform = (function () {
|
|
8
|
+
function Platform() {}
|
|
9
|
+
Platform.serviceName = "org.dash.platform.dapi.v0.Platform";
|
|
10
|
+
return Platform;
|
|
11
|
+
}());
|
|
12
|
+
|
|
13
|
+
Platform.broadcastStateTransition = {
|
|
14
|
+
methodName: "broadcastStateTransition",
|
|
15
|
+
service: Platform,
|
|
16
|
+
requestStream: false,
|
|
17
|
+
responseStream: false,
|
|
18
|
+
requestType: platform_pb.BroadcastStateTransitionRequest,
|
|
19
|
+
responseType: platform_pb.BroadcastStateTransitionResponse
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
Platform.getIdentity = {
|
|
23
|
+
methodName: "getIdentity",
|
|
24
|
+
service: Platform,
|
|
25
|
+
requestStream: false,
|
|
26
|
+
responseStream: false,
|
|
27
|
+
requestType: platform_pb.GetIdentityRequest,
|
|
28
|
+
responseType: platform_pb.GetIdentityResponse
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
Platform.getIdentityKeys = {
|
|
32
|
+
methodName: "getIdentityKeys",
|
|
33
|
+
service: Platform,
|
|
34
|
+
requestStream: false,
|
|
35
|
+
responseStream: false,
|
|
36
|
+
requestType: platform_pb.GetIdentityKeysRequest,
|
|
37
|
+
responseType: platform_pb.GetIdentityKeysResponse
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
Platform.getIdentityBalance = {
|
|
41
|
+
methodName: "getIdentityBalance",
|
|
42
|
+
service: Platform,
|
|
43
|
+
requestStream: false,
|
|
44
|
+
responseStream: false,
|
|
45
|
+
requestType: platform_pb.GetIdentityRequest,
|
|
46
|
+
responseType: platform_pb.GetIdentityBalanceResponse
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
Platform.getIdentityBalanceAndRevision = {
|
|
50
|
+
methodName: "getIdentityBalanceAndRevision",
|
|
51
|
+
service: Platform,
|
|
52
|
+
requestStream: false,
|
|
53
|
+
responseStream: false,
|
|
54
|
+
requestType: platform_pb.GetIdentityRequest,
|
|
55
|
+
responseType: platform_pb.GetIdentityBalanceAndRevisionResponse
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Platform.getDataContract = {
|
|
59
|
+
methodName: "getDataContract",
|
|
60
|
+
service: Platform,
|
|
61
|
+
requestStream: false,
|
|
62
|
+
responseStream: false,
|
|
63
|
+
requestType: platform_pb.GetDataContractRequest,
|
|
64
|
+
responseType: platform_pb.GetDataContractResponse
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Platform.getDataContracts = {
|
|
68
|
+
methodName: "getDataContracts",
|
|
69
|
+
service: Platform,
|
|
70
|
+
requestStream: false,
|
|
71
|
+
responseStream: false,
|
|
72
|
+
requestType: platform_pb.GetDataContractsRequest,
|
|
73
|
+
responseType: platform_pb.GetDataContractsResponse
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
Platform.getDocuments = {
|
|
77
|
+
methodName: "getDocuments",
|
|
78
|
+
service: Platform,
|
|
79
|
+
requestStream: false,
|
|
80
|
+
responseStream: false,
|
|
81
|
+
requestType: platform_pb.GetDocumentsRequest,
|
|
82
|
+
responseType: platform_pb.GetDocumentsResponse
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
Platform.getIdentitiesByPublicKeyHashes = {
|
|
86
|
+
methodName: "getIdentitiesByPublicKeyHashes",
|
|
87
|
+
service: Platform,
|
|
88
|
+
requestStream: false,
|
|
89
|
+
responseStream: false,
|
|
90
|
+
requestType: platform_pb.GetIdentitiesByPublicKeyHashesRequest,
|
|
91
|
+
responseType: platform_pb.GetIdentitiesByPublicKeyHashesResponse
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
Platform.getIdentityByPublicKeyHashes = {
|
|
95
|
+
methodName: "getIdentityByPublicKeyHashes",
|
|
96
|
+
service: Platform,
|
|
97
|
+
requestStream: false,
|
|
98
|
+
responseStream: false,
|
|
99
|
+
requestType: platform_pb.GetIdentityByPublicKeyHashesRequest,
|
|
100
|
+
responseType: platform_pb.GetIdentityByPublicKeyHashesResponse
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
Platform.waitForStateTransitionResult = {
|
|
104
|
+
methodName: "waitForStateTransitionResult",
|
|
105
|
+
service: Platform,
|
|
106
|
+
requestStream: false,
|
|
107
|
+
responseStream: false,
|
|
108
|
+
requestType: platform_pb.WaitForStateTransitionResultRequest,
|
|
109
|
+
responseType: platform_pb.WaitForStateTransitionResultResponse
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
Platform.getConsensusParams = {
|
|
113
|
+
methodName: "getConsensusParams",
|
|
114
|
+
service: Platform,
|
|
115
|
+
requestStream: false,
|
|
116
|
+
responseStream: false,
|
|
117
|
+
requestType: platform_pb.GetConsensusParamsRequest,
|
|
118
|
+
responseType: platform_pb.GetConsensusParamsResponse
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
exports.Platform = Platform;
|
|
122
|
+
|
|
123
|
+
function PlatformClient(serviceHost, options) {
|
|
124
|
+
this.serviceHost = serviceHost;
|
|
125
|
+
this.options = options || {};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
PlatformClient.prototype.broadcastStateTransition = function broadcastStateTransition(requestMessage, metadata, callback) {
|
|
129
|
+
if (arguments.length === 2) {
|
|
130
|
+
callback = arguments[1];
|
|
131
|
+
}
|
|
132
|
+
var client = grpc.unary(Platform.broadcastStateTransition, {
|
|
133
|
+
request: requestMessage,
|
|
134
|
+
host: this.serviceHost,
|
|
135
|
+
metadata: metadata,
|
|
136
|
+
transport: this.options.transport,
|
|
137
|
+
debug: this.options.debug,
|
|
138
|
+
onEnd: function (response) {
|
|
139
|
+
if (callback) {
|
|
140
|
+
if (response.status !== grpc.Code.OK) {
|
|
141
|
+
var err = new Error(response.statusMessage);
|
|
142
|
+
err.code = response.status;
|
|
143
|
+
err.metadata = response.trailers;
|
|
144
|
+
callback(err, null);
|
|
145
|
+
} else {
|
|
146
|
+
callback(null, response.message);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
cancel: function () {
|
|
153
|
+
callback = null;
|
|
154
|
+
client.close();
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
PlatformClient.prototype.getIdentity = function getIdentity(requestMessage, metadata, callback) {
|
|
160
|
+
if (arguments.length === 2) {
|
|
161
|
+
callback = arguments[1];
|
|
162
|
+
}
|
|
163
|
+
var client = grpc.unary(Platform.getIdentity, {
|
|
164
|
+
request: requestMessage,
|
|
165
|
+
host: this.serviceHost,
|
|
166
|
+
metadata: metadata,
|
|
167
|
+
transport: this.options.transport,
|
|
168
|
+
debug: this.options.debug,
|
|
169
|
+
onEnd: function (response) {
|
|
170
|
+
if (callback) {
|
|
171
|
+
if (response.status !== grpc.Code.OK) {
|
|
172
|
+
var err = new Error(response.statusMessage);
|
|
173
|
+
err.code = response.status;
|
|
174
|
+
err.metadata = response.trailers;
|
|
175
|
+
callback(err, null);
|
|
176
|
+
} else {
|
|
177
|
+
callback(null, response.message);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
return {
|
|
183
|
+
cancel: function () {
|
|
184
|
+
callback = null;
|
|
185
|
+
client.close();
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
PlatformClient.prototype.getIdentityKeys = function getIdentityKeys(requestMessage, metadata, callback) {
|
|
191
|
+
if (arguments.length === 2) {
|
|
192
|
+
callback = arguments[1];
|
|
193
|
+
}
|
|
194
|
+
var client = grpc.unary(Platform.getIdentityKeys, {
|
|
195
|
+
request: requestMessage,
|
|
196
|
+
host: this.serviceHost,
|
|
197
|
+
metadata: metadata,
|
|
198
|
+
transport: this.options.transport,
|
|
199
|
+
debug: this.options.debug,
|
|
200
|
+
onEnd: function (response) {
|
|
201
|
+
if (callback) {
|
|
202
|
+
if (response.status !== grpc.Code.OK) {
|
|
203
|
+
var err = new Error(response.statusMessage);
|
|
204
|
+
err.code = response.status;
|
|
205
|
+
err.metadata = response.trailers;
|
|
206
|
+
callback(err, null);
|
|
207
|
+
} else {
|
|
208
|
+
callback(null, response.message);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return {
|
|
214
|
+
cancel: function () {
|
|
215
|
+
callback = null;
|
|
216
|
+
client.close();
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
PlatformClient.prototype.getIdentityBalance = function getIdentityBalance(requestMessage, metadata, callback) {
|
|
222
|
+
if (arguments.length === 2) {
|
|
223
|
+
callback = arguments[1];
|
|
224
|
+
}
|
|
225
|
+
var client = grpc.unary(Platform.getIdentityBalance, {
|
|
226
|
+
request: requestMessage,
|
|
227
|
+
host: this.serviceHost,
|
|
228
|
+
metadata: metadata,
|
|
229
|
+
transport: this.options.transport,
|
|
230
|
+
debug: this.options.debug,
|
|
231
|
+
onEnd: function (response) {
|
|
232
|
+
if (callback) {
|
|
233
|
+
if (response.status !== grpc.Code.OK) {
|
|
234
|
+
var err = new Error(response.statusMessage);
|
|
235
|
+
err.code = response.status;
|
|
236
|
+
err.metadata = response.trailers;
|
|
237
|
+
callback(err, null);
|
|
238
|
+
} else {
|
|
239
|
+
callback(null, response.message);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
return {
|
|
245
|
+
cancel: function () {
|
|
246
|
+
callback = null;
|
|
247
|
+
client.close();
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
PlatformClient.prototype.getIdentityBalanceAndRevision = function getIdentityBalanceAndRevision(requestMessage, metadata, callback) {
|
|
253
|
+
if (arguments.length === 2) {
|
|
254
|
+
callback = arguments[1];
|
|
255
|
+
}
|
|
256
|
+
var client = grpc.unary(Platform.getIdentityBalanceAndRevision, {
|
|
257
|
+
request: requestMessage,
|
|
258
|
+
host: this.serviceHost,
|
|
259
|
+
metadata: metadata,
|
|
260
|
+
transport: this.options.transport,
|
|
261
|
+
debug: this.options.debug,
|
|
262
|
+
onEnd: function (response) {
|
|
263
|
+
if (callback) {
|
|
264
|
+
if (response.status !== grpc.Code.OK) {
|
|
265
|
+
var err = new Error(response.statusMessage);
|
|
266
|
+
err.code = response.status;
|
|
267
|
+
err.metadata = response.trailers;
|
|
268
|
+
callback(err, null);
|
|
269
|
+
} else {
|
|
270
|
+
callback(null, response.message);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
return {
|
|
276
|
+
cancel: function () {
|
|
277
|
+
callback = null;
|
|
278
|
+
client.close();
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
PlatformClient.prototype.getDataContract = function getDataContract(requestMessage, metadata, callback) {
|
|
284
|
+
if (arguments.length === 2) {
|
|
285
|
+
callback = arguments[1];
|
|
286
|
+
}
|
|
287
|
+
var client = grpc.unary(Platform.getDataContract, {
|
|
288
|
+
request: requestMessage,
|
|
289
|
+
host: this.serviceHost,
|
|
290
|
+
metadata: metadata,
|
|
291
|
+
transport: this.options.transport,
|
|
292
|
+
debug: this.options.debug,
|
|
293
|
+
onEnd: function (response) {
|
|
294
|
+
if (callback) {
|
|
295
|
+
if (response.status !== grpc.Code.OK) {
|
|
296
|
+
var err = new Error(response.statusMessage);
|
|
297
|
+
err.code = response.status;
|
|
298
|
+
err.metadata = response.trailers;
|
|
299
|
+
callback(err, null);
|
|
300
|
+
} else {
|
|
301
|
+
callback(null, response.message);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
return {
|
|
307
|
+
cancel: function () {
|
|
308
|
+
callback = null;
|
|
309
|
+
client.close();
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
PlatformClient.prototype.getDataContracts = function getDataContracts(requestMessage, metadata, callback) {
|
|
315
|
+
if (arguments.length === 2) {
|
|
316
|
+
callback = arguments[1];
|
|
317
|
+
}
|
|
318
|
+
var client = grpc.unary(Platform.getDataContracts, {
|
|
319
|
+
request: requestMessage,
|
|
320
|
+
host: this.serviceHost,
|
|
321
|
+
metadata: metadata,
|
|
322
|
+
transport: this.options.transport,
|
|
323
|
+
debug: this.options.debug,
|
|
324
|
+
onEnd: function (response) {
|
|
325
|
+
if (callback) {
|
|
326
|
+
if (response.status !== grpc.Code.OK) {
|
|
327
|
+
var err = new Error(response.statusMessage);
|
|
328
|
+
err.code = response.status;
|
|
329
|
+
err.metadata = response.trailers;
|
|
330
|
+
callback(err, null);
|
|
331
|
+
} else {
|
|
332
|
+
callback(null, response.message);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
return {
|
|
338
|
+
cancel: function () {
|
|
339
|
+
callback = null;
|
|
340
|
+
client.close();
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
PlatformClient.prototype.getDocuments = function getDocuments(requestMessage, metadata, callback) {
|
|
346
|
+
if (arguments.length === 2) {
|
|
347
|
+
callback = arguments[1];
|
|
348
|
+
}
|
|
349
|
+
var client = grpc.unary(Platform.getDocuments, {
|
|
350
|
+
request: requestMessage,
|
|
351
|
+
host: this.serviceHost,
|
|
352
|
+
metadata: metadata,
|
|
353
|
+
transport: this.options.transport,
|
|
354
|
+
debug: this.options.debug,
|
|
355
|
+
onEnd: function (response) {
|
|
356
|
+
if (callback) {
|
|
357
|
+
if (response.status !== grpc.Code.OK) {
|
|
358
|
+
var err = new Error(response.statusMessage);
|
|
359
|
+
err.code = response.status;
|
|
360
|
+
err.metadata = response.trailers;
|
|
361
|
+
callback(err, null);
|
|
362
|
+
} else {
|
|
363
|
+
callback(null, response.message);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
return {
|
|
369
|
+
cancel: function () {
|
|
370
|
+
callback = null;
|
|
371
|
+
client.close();
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
PlatformClient.prototype.getIdentitiesByPublicKeyHashes = function getIdentitiesByPublicKeyHashes(requestMessage, metadata, callback) {
|
|
377
|
+
if (arguments.length === 2) {
|
|
378
|
+
callback = arguments[1];
|
|
379
|
+
}
|
|
380
|
+
var client = grpc.unary(Platform.getIdentitiesByPublicKeyHashes, {
|
|
381
|
+
request: requestMessage,
|
|
382
|
+
host: this.serviceHost,
|
|
383
|
+
metadata: metadata,
|
|
384
|
+
transport: this.options.transport,
|
|
385
|
+
debug: this.options.debug,
|
|
386
|
+
onEnd: function (response) {
|
|
387
|
+
if (callback) {
|
|
388
|
+
if (response.status !== grpc.Code.OK) {
|
|
389
|
+
var err = new Error(response.statusMessage);
|
|
390
|
+
err.code = response.status;
|
|
391
|
+
err.metadata = response.trailers;
|
|
392
|
+
callback(err, null);
|
|
393
|
+
} else {
|
|
394
|
+
callback(null, response.message);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
return {
|
|
400
|
+
cancel: function () {
|
|
401
|
+
callback = null;
|
|
402
|
+
client.close();
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
PlatformClient.prototype.getIdentityByPublicKeyHashes = function getIdentityByPublicKeyHashes(requestMessage, metadata, callback) {
|
|
408
|
+
if (arguments.length === 2) {
|
|
409
|
+
callback = arguments[1];
|
|
410
|
+
}
|
|
411
|
+
var client = grpc.unary(Platform.getIdentityByPublicKeyHashes, {
|
|
412
|
+
request: requestMessage,
|
|
413
|
+
host: this.serviceHost,
|
|
414
|
+
metadata: metadata,
|
|
415
|
+
transport: this.options.transport,
|
|
416
|
+
debug: this.options.debug,
|
|
417
|
+
onEnd: function (response) {
|
|
418
|
+
if (callback) {
|
|
419
|
+
if (response.status !== grpc.Code.OK) {
|
|
420
|
+
var err = new Error(response.statusMessage);
|
|
421
|
+
err.code = response.status;
|
|
422
|
+
err.metadata = response.trailers;
|
|
423
|
+
callback(err, null);
|
|
424
|
+
} else {
|
|
425
|
+
callback(null, response.message);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
return {
|
|
431
|
+
cancel: function () {
|
|
432
|
+
callback = null;
|
|
433
|
+
client.close();
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
PlatformClient.prototype.waitForStateTransitionResult = function waitForStateTransitionResult(requestMessage, metadata, callback) {
|
|
439
|
+
if (arguments.length === 2) {
|
|
440
|
+
callback = arguments[1];
|
|
441
|
+
}
|
|
442
|
+
var client = grpc.unary(Platform.waitForStateTransitionResult, {
|
|
443
|
+
request: requestMessage,
|
|
444
|
+
host: this.serviceHost,
|
|
445
|
+
metadata: metadata,
|
|
446
|
+
transport: this.options.transport,
|
|
447
|
+
debug: this.options.debug,
|
|
448
|
+
onEnd: function (response) {
|
|
449
|
+
if (callback) {
|
|
450
|
+
if (response.status !== grpc.Code.OK) {
|
|
451
|
+
var err = new Error(response.statusMessage);
|
|
452
|
+
err.code = response.status;
|
|
453
|
+
err.metadata = response.trailers;
|
|
454
|
+
callback(err, null);
|
|
455
|
+
} else {
|
|
456
|
+
callback(null, response.message);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
return {
|
|
462
|
+
cancel: function () {
|
|
463
|
+
callback = null;
|
|
464
|
+
client.close();
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
PlatformClient.prototype.getConsensusParams = function getConsensusParams(requestMessage, metadata, callback) {
|
|
470
|
+
if (arguments.length === 2) {
|
|
471
|
+
callback = arguments[1];
|
|
472
|
+
}
|
|
473
|
+
var client = grpc.unary(Platform.getConsensusParams, {
|
|
474
|
+
request: requestMessage,
|
|
475
|
+
host: this.serviceHost,
|
|
476
|
+
metadata: metadata,
|
|
477
|
+
transport: this.options.transport,
|
|
478
|
+
debug: this.options.debug,
|
|
479
|
+
onEnd: function (response) {
|
|
480
|
+
if (callback) {
|
|
481
|
+
if (response.status !== grpc.Code.OK) {
|
|
482
|
+
var err = new Error(response.statusMessage);
|
|
483
|
+
err.code = response.status;
|
|
484
|
+
err.metadata = response.trailers;
|
|
485
|
+
callback(err, null);
|
|
486
|
+
} else {
|
|
487
|
+
callback(null, response.message);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
return {
|
|
493
|
+
cancel: function () {
|
|
494
|
+
callback = null;
|
|
495
|
+
client.close();
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
exports.PlatformClient = PlatformClient;
|
|
501
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { Metadata: MetadataGrpcJS } = require('@grpc/grpc-js/build/src/metadata');
|
|
2
|
+
const { grpc: { Metadata: MetadataGrpcWeb } } = require('@improbable-eng/grpc-web');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {MetadataGrpcJS|MetadataGrpcWeb} metadata
|
|
7
|
+
* @return {{}|{[p: string]: string}}
|
|
8
|
+
*/
|
|
9
|
+
const parseMetadata = (metadata) => {
|
|
10
|
+
if (metadata instanceof MetadataGrpcJS) {
|
|
11
|
+
return metadata.getMap();
|
|
12
|
+
} if (metadata instanceof MetadataGrpcWeb) {
|
|
13
|
+
const parsedMetadata = {};
|
|
14
|
+
metadata.forEach((key, values) => {
|
|
15
|
+
// Mapping each key to the first value associated with it.
|
|
16
|
+
// This corresponds to the getMap() behaviour of the grpc-js Metadata class.
|
|
17
|
+
const [value] = values;
|
|
18
|
+
parsedMetadata[key] = value;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return parsedMetadata;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return metadata;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = parseMetadata;
|
package/node.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { Metadata } = require('@grpc/grpc-js/build/src/metadata');
|
|
1
2
|
const CorePromiseClient = require('./clients/core/v0/nodejs/CorePromiseClient');
|
|
2
3
|
const PlatformPromiseClient = require('./clients/platform/v0/nodejs/PlatformPromiseClient');
|
|
3
4
|
|
|
@@ -6,6 +7,7 @@ const protocPlatformMessages = require('./clients/platform/v0/nodejs/platform_pr
|
|
|
6
7
|
|
|
7
8
|
const getCoreDefinition = require('./lib/getCoreDefinition');
|
|
8
9
|
const getPlatformDefinition = require('./lib/getPlatformDefinition');
|
|
10
|
+
const parseMetadata = require('./lib/utils/parseMetadata');
|
|
9
11
|
|
|
10
12
|
const {
|
|
11
13
|
org: {
|
|
@@ -45,4 +47,6 @@ module.exports = {
|
|
|
45
47
|
...protocCoreMessages,
|
|
46
48
|
...protocPlatformMessages,
|
|
47
49
|
},
|
|
50
|
+
parseMetadata,
|
|
51
|
+
Metadata,
|
|
48
52
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-grpc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0-dev.10",
|
|
4
4
|
"description": "DAPI GRPC definition file and generated clients",
|
|
5
5
|
"browser": "browser.js",
|
|
6
6
|
"main": "node.js",
|
|
@@ -21,6 +21,18 @@
|
|
|
21
21
|
"name": "Anton Suprunchuk",
|
|
22
22
|
"email": "anton.suprunchuk@dash.org",
|
|
23
23
|
"url": "https://github.com/antouhou"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "Samuel Westrich",
|
|
27
|
+
"email": "sam@dash.org"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "Igor Markin",
|
|
31
|
+
"email": "igor.markin@dash.org"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "Łukasz Klimek",
|
|
35
|
+
"email": "lukasz.klimek@dash.org"
|
|
24
36
|
}
|
|
25
37
|
],
|
|
26
38
|
"repository": {
|
|
@@ -33,11 +45,11 @@
|
|
|
33
45
|
},
|
|
34
46
|
"homepage": "https://github.com/dashevo/dapi-grpc#readme",
|
|
35
47
|
"dependencies": {
|
|
36
|
-
"@dashevo/grpc-common": "0.
|
|
48
|
+
"@dashevo/grpc-common": "0.25.0-dev.10",
|
|
37
49
|
"@dashevo/protobufjs": "6.10.5",
|
|
38
50
|
"@grpc/grpc-js": "^1.3.7",
|
|
51
|
+
"@improbable-eng/grpc-web": "^0.15.0",
|
|
39
52
|
"google-protobuf": "^3.12.2",
|
|
40
|
-
"grpc-web": "1.2.1",
|
|
41
53
|
"long": "^5.2.0"
|
|
42
54
|
},
|
|
43
55
|
"devDependencies": {
|