@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.
Files changed (32) hide show
  1. package/Cargo.toml +39 -0
  2. package/README.md +3 -3
  3. package/browser.js +13 -5
  4. package/build.rs +65 -0
  5. package/clients/core/v0/nodejs/CorePromiseClient.js +2 -1
  6. package/clients/core/v0/nodejs/core_protoc.js +33 -33
  7. package/clients/core/v0/rust/README.md +3 -0
  8. package/clients/core/v0/rust/core_example.rs +14 -0
  9. package/clients/core/v0/web/CorePromiseClient.js +159 -0
  10. package/clients/core/v0/web/core_pb.d.ts +783 -0
  11. package/clients/core/v0/web/core_pb.js +33 -33
  12. package/clients/core/v0/web/core_pb_service.d.ts +161 -0
  13. package/clients/core/v0/web/core_pb_service.js +317 -0
  14. package/clients/platform/v0/nodejs/PlatformPromiseClient.js +2 -1
  15. package/clients/platform/v0/nodejs/platform_pbjs.js +10012 -1472
  16. package/clients/platform/v0/nodejs/platform_protoc.js +6811 -1243
  17. package/clients/platform/v0/rust/README.md +3 -0
  18. package/clients/platform/v0/rust/platform_example.rs +15 -0
  19. package/clients/platform/v0/web/PlatformPromiseClient.js +130 -0
  20. package/clients/platform/v0/web/platform_pb.d.ts +1312 -0
  21. package/clients/platform/v0/web/platform_pb.js +6811 -1243
  22. package/clients/platform/v0/web/platform_pb_service.d.ts +272 -0
  23. package/clients/platform/v0/web/platform_pb_service.js +501 -0
  24. package/lib/utils/parseMetadata.js +27 -0
  25. package/node.js +4 -0
  26. package/package.json +15 -3
  27. package/protos/platform/v0/platform.proto +157 -8
  28. package/scripts/build.sh +85 -79
  29. package/scripts/patch-protobuf-js.sh +31 -0
  30. package/src/lib.rs +15 -0
  31. package/clients/core/v0/web/core_grpc_web_pb.js +0 -499
  32. package/clients/platform/v0/web/platform_grpc_web_pb.js +0 -509
@@ -13,39 +13,39 @@
13
13
 
14
14
  var jspb = require('google-protobuf');
15
15
  var goog = jspb;
16
- var global = Function('return this')();
17
-
18
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.BlockHeaders', null, global);
19
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.BlockHeadersWithChainLocksRequest', null, global);
20
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.BlockHeadersWithChainLocksRequest.FromBlockCase', null, global);
21
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.BlockHeadersWithChainLocksResponse', null, global);
22
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.BlockHeadersWithChainLocksResponse.ResponsesCase', null, global);
23
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.BloomFilter', null, global);
24
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.BroadcastTransactionRequest', null, global);
25
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.BroadcastTransactionResponse', null, global);
26
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetBlockRequest', null, global);
27
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetBlockRequest.BlockCase', null, global);
28
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetBlockResponse', null, global);
29
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetEstimatedTransactionFeeRequest', null, global);
30
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetEstimatedTransactionFeeResponse', null, global);
31
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusRequest', null, global);
32
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse', null, global);
33
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Chain', null, global);
34
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Masternode', null, global);
35
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Masternode.Status', null, global);
36
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Network', null, global);
37
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.NetworkFee', null, global);
38
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Status', null, global);
39
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Time', null, global);
40
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Version', null, global);
41
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTransactionRequest', null, global);
42
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTransactionResponse', null, global);
43
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.InstantSendLockMessages', null, global);
44
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.RawTransactions', null, global);
45
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.TransactionsWithProofsRequest', null, global);
46
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.TransactionsWithProofsRequest.FromBlockCase', null, global);
47
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.TransactionsWithProofsResponse', null, global);
48
- goog.exportSymbol('proto.org.dash.platform.dapi.v0.TransactionsWithProofsResponse.ResponsesCase', null, global);
16
+ const proto = {};
17
+
18
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.BlockHeaders', null, { proto });
19
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.BlockHeadersWithChainLocksRequest', null, { proto });
20
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.BlockHeadersWithChainLocksRequest.FromBlockCase', null, { proto });
21
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.BlockHeadersWithChainLocksResponse', null, { proto });
22
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.BlockHeadersWithChainLocksResponse.ResponsesCase', null, { proto });
23
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.BloomFilter', null, { proto });
24
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.BroadcastTransactionRequest', null, { proto });
25
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.BroadcastTransactionResponse', null, { proto });
26
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetBlockRequest', null, { proto });
27
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetBlockRequest.BlockCase', null, { proto });
28
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetBlockResponse', null, { proto });
29
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetEstimatedTransactionFeeRequest', null, { proto });
30
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetEstimatedTransactionFeeResponse', null, { proto });
31
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusRequest', null, { proto });
32
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse', null, { proto });
33
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Chain', null, { proto });
34
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Masternode', null, { proto });
35
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Masternode.Status', null, { proto });
36
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Network', null, { proto });
37
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.NetworkFee', null, { proto });
38
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Status', null, { proto });
39
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Time', null, { proto });
40
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetStatusResponse.Version', null, { proto });
41
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTransactionRequest', null, { proto });
42
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTransactionResponse', null, { proto });
43
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.InstantSendLockMessages', null, { proto });
44
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.RawTransactions', null, { proto });
45
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.TransactionsWithProofsRequest', null, { proto });
46
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.TransactionsWithProofsRequest.FromBlockCase', null, { proto });
47
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.TransactionsWithProofsResponse', null, { proto });
48
+ goog.exportSymbol('proto.org.dash.platform.dapi.v0.TransactionsWithProofsResponse.ResponsesCase', null, { proto });
49
49
  /**
50
50
  * Generated by JsPbCodeGenerator.
51
51
  * @param {Array=} opt_data Optional initial data array, typically from a
@@ -0,0 +1,161 @@
1
+ // package: org.dash.platform.dapi.v0
2
+ // file: core.proto
3
+
4
+ import * as core_pb from "./core_pb";
5
+ import {grpc} from "@improbable-eng/grpc-web";
6
+
7
+ type CoregetStatus = {
8
+ readonly methodName: string;
9
+ readonly service: typeof Core;
10
+ readonly requestStream: false;
11
+ readonly responseStream: false;
12
+ readonly requestType: typeof core_pb.GetStatusRequest;
13
+ readonly responseType: typeof core_pb.GetStatusResponse;
14
+ };
15
+
16
+ type CoregetBlock = {
17
+ readonly methodName: string;
18
+ readonly service: typeof Core;
19
+ readonly requestStream: false;
20
+ readonly responseStream: false;
21
+ readonly requestType: typeof core_pb.GetBlockRequest;
22
+ readonly responseType: typeof core_pb.GetBlockResponse;
23
+ };
24
+
25
+ type CorebroadcastTransaction = {
26
+ readonly methodName: string;
27
+ readonly service: typeof Core;
28
+ readonly requestStream: false;
29
+ readonly responseStream: false;
30
+ readonly requestType: typeof core_pb.BroadcastTransactionRequest;
31
+ readonly responseType: typeof core_pb.BroadcastTransactionResponse;
32
+ };
33
+
34
+ type CoregetTransaction = {
35
+ readonly methodName: string;
36
+ readonly service: typeof Core;
37
+ readonly requestStream: false;
38
+ readonly responseStream: false;
39
+ readonly requestType: typeof core_pb.GetTransactionRequest;
40
+ readonly responseType: typeof core_pb.GetTransactionResponse;
41
+ };
42
+
43
+ type CoregetEstimatedTransactionFee = {
44
+ readonly methodName: string;
45
+ readonly service: typeof Core;
46
+ readonly requestStream: false;
47
+ readonly responseStream: false;
48
+ readonly requestType: typeof core_pb.GetEstimatedTransactionFeeRequest;
49
+ readonly responseType: typeof core_pb.GetEstimatedTransactionFeeResponse;
50
+ };
51
+
52
+ type CoresubscribeToBlockHeadersWithChainLocks = {
53
+ readonly methodName: string;
54
+ readonly service: typeof Core;
55
+ readonly requestStream: false;
56
+ readonly responseStream: true;
57
+ readonly requestType: typeof core_pb.BlockHeadersWithChainLocksRequest;
58
+ readonly responseType: typeof core_pb.BlockHeadersWithChainLocksResponse;
59
+ };
60
+
61
+ type CoresubscribeToTransactionsWithProofs = {
62
+ readonly methodName: string;
63
+ readonly service: typeof Core;
64
+ readonly requestStream: false;
65
+ readonly responseStream: true;
66
+ readonly requestType: typeof core_pb.TransactionsWithProofsRequest;
67
+ readonly responseType: typeof core_pb.TransactionsWithProofsResponse;
68
+ };
69
+
70
+ export class Core {
71
+ static readonly serviceName: string;
72
+ static readonly getStatus: CoregetStatus;
73
+ static readonly getBlock: CoregetBlock;
74
+ static readonly broadcastTransaction: CorebroadcastTransaction;
75
+ static readonly getTransaction: CoregetTransaction;
76
+ static readonly getEstimatedTransactionFee: CoregetEstimatedTransactionFee;
77
+ static readonly subscribeToBlockHeadersWithChainLocks: CoresubscribeToBlockHeadersWithChainLocks;
78
+ static readonly subscribeToTransactionsWithProofs: CoresubscribeToTransactionsWithProofs;
79
+ }
80
+
81
+ export type ServiceError = { message: string, code: number; metadata: grpc.Metadata }
82
+ export type Status = { details: string, code: number; metadata: grpc.Metadata }
83
+
84
+ interface UnaryResponse {
85
+ cancel(): void;
86
+ }
87
+ interface ResponseStream<T> {
88
+ cancel(): void;
89
+ on(type: 'data', handler: (message: T) => void): ResponseStream<T>;
90
+ on(type: 'end', handler: (status?: Status) => void): ResponseStream<T>;
91
+ on(type: 'status', handler: (status: Status) => void): ResponseStream<T>;
92
+ }
93
+ interface RequestStream<T> {
94
+ write(message: T): RequestStream<T>;
95
+ end(): void;
96
+ cancel(): void;
97
+ on(type: 'end', handler: (status?: Status) => void): RequestStream<T>;
98
+ on(type: 'status', handler: (status: Status) => void): RequestStream<T>;
99
+ }
100
+ interface BidirectionalStream<ReqT, ResT> {
101
+ write(message: ReqT): BidirectionalStream<ReqT, ResT>;
102
+ end(): void;
103
+ cancel(): void;
104
+ on(type: 'data', handler: (message: ResT) => void): BidirectionalStream<ReqT, ResT>;
105
+ on(type: 'end', handler: (status?: Status) => void): BidirectionalStream<ReqT, ResT>;
106
+ on(type: 'status', handler: (status: Status) => void): BidirectionalStream<ReqT, ResT>;
107
+ }
108
+
109
+ export class CoreClient {
110
+ readonly serviceHost: string;
111
+
112
+ constructor(serviceHost: string, options?: grpc.RpcOptions);
113
+ getStatus(
114
+ requestMessage: core_pb.GetStatusRequest,
115
+ metadata: grpc.Metadata,
116
+ callback: (error: ServiceError|null, responseMessage: core_pb.GetStatusResponse|null) => void
117
+ ): UnaryResponse;
118
+ getStatus(
119
+ requestMessage: core_pb.GetStatusRequest,
120
+ callback: (error: ServiceError|null, responseMessage: core_pb.GetStatusResponse|null) => void
121
+ ): UnaryResponse;
122
+ getBlock(
123
+ requestMessage: core_pb.GetBlockRequest,
124
+ metadata: grpc.Metadata,
125
+ callback: (error: ServiceError|null, responseMessage: core_pb.GetBlockResponse|null) => void
126
+ ): UnaryResponse;
127
+ getBlock(
128
+ requestMessage: core_pb.GetBlockRequest,
129
+ callback: (error: ServiceError|null, responseMessage: core_pb.GetBlockResponse|null) => void
130
+ ): UnaryResponse;
131
+ broadcastTransaction(
132
+ requestMessage: core_pb.BroadcastTransactionRequest,
133
+ metadata: grpc.Metadata,
134
+ callback: (error: ServiceError|null, responseMessage: core_pb.BroadcastTransactionResponse|null) => void
135
+ ): UnaryResponse;
136
+ broadcastTransaction(
137
+ requestMessage: core_pb.BroadcastTransactionRequest,
138
+ callback: (error: ServiceError|null, responseMessage: core_pb.BroadcastTransactionResponse|null) => void
139
+ ): UnaryResponse;
140
+ getTransaction(
141
+ requestMessage: core_pb.GetTransactionRequest,
142
+ metadata: grpc.Metadata,
143
+ callback: (error: ServiceError|null, responseMessage: core_pb.GetTransactionResponse|null) => void
144
+ ): UnaryResponse;
145
+ getTransaction(
146
+ requestMessage: core_pb.GetTransactionRequest,
147
+ callback: (error: ServiceError|null, responseMessage: core_pb.GetTransactionResponse|null) => void
148
+ ): UnaryResponse;
149
+ getEstimatedTransactionFee(
150
+ requestMessage: core_pb.GetEstimatedTransactionFeeRequest,
151
+ metadata: grpc.Metadata,
152
+ callback: (error: ServiceError|null, responseMessage: core_pb.GetEstimatedTransactionFeeResponse|null) => void
153
+ ): UnaryResponse;
154
+ getEstimatedTransactionFee(
155
+ requestMessage: core_pb.GetEstimatedTransactionFeeRequest,
156
+ callback: (error: ServiceError|null, responseMessage: core_pb.GetEstimatedTransactionFeeResponse|null) => void
157
+ ): UnaryResponse;
158
+ subscribeToBlockHeadersWithChainLocks(requestMessage: core_pb.BlockHeadersWithChainLocksRequest, metadata?: grpc.Metadata): ResponseStream<core_pb.BlockHeadersWithChainLocksResponse>;
159
+ subscribeToTransactionsWithProofs(requestMessage: core_pb.TransactionsWithProofsRequest, metadata?: grpc.Metadata): ResponseStream<core_pb.TransactionsWithProofsResponse>;
160
+ }
161
+
@@ -0,0 +1,317 @@
1
+ // package: org.dash.platform.dapi.v0
2
+ // file: core.proto
3
+
4
+ var core_pb = require("./core_pb");
5
+ var grpc = require("@improbable-eng/grpc-web").grpc;
6
+
7
+ var Core = (function () {
8
+ function Core() {}
9
+ Core.serviceName = "org.dash.platform.dapi.v0.Core";
10
+ return Core;
11
+ }());
12
+
13
+ Core.getStatus = {
14
+ methodName: "getStatus",
15
+ service: Core,
16
+ requestStream: false,
17
+ responseStream: false,
18
+ requestType: core_pb.GetStatusRequest,
19
+ responseType: core_pb.GetStatusResponse
20
+ };
21
+
22
+ Core.getBlock = {
23
+ methodName: "getBlock",
24
+ service: Core,
25
+ requestStream: false,
26
+ responseStream: false,
27
+ requestType: core_pb.GetBlockRequest,
28
+ responseType: core_pb.GetBlockResponse
29
+ };
30
+
31
+ Core.broadcastTransaction = {
32
+ methodName: "broadcastTransaction",
33
+ service: Core,
34
+ requestStream: false,
35
+ responseStream: false,
36
+ requestType: core_pb.BroadcastTransactionRequest,
37
+ responseType: core_pb.BroadcastTransactionResponse
38
+ };
39
+
40
+ Core.getTransaction = {
41
+ methodName: "getTransaction",
42
+ service: Core,
43
+ requestStream: false,
44
+ responseStream: false,
45
+ requestType: core_pb.GetTransactionRequest,
46
+ responseType: core_pb.GetTransactionResponse
47
+ };
48
+
49
+ Core.getEstimatedTransactionFee = {
50
+ methodName: "getEstimatedTransactionFee",
51
+ service: Core,
52
+ requestStream: false,
53
+ responseStream: false,
54
+ requestType: core_pb.GetEstimatedTransactionFeeRequest,
55
+ responseType: core_pb.GetEstimatedTransactionFeeResponse
56
+ };
57
+
58
+ Core.subscribeToBlockHeadersWithChainLocks = {
59
+ methodName: "subscribeToBlockHeadersWithChainLocks",
60
+ service: Core,
61
+ requestStream: false,
62
+ responseStream: true,
63
+ requestType: core_pb.BlockHeadersWithChainLocksRequest,
64
+ responseType: core_pb.BlockHeadersWithChainLocksResponse
65
+ };
66
+
67
+ Core.subscribeToTransactionsWithProofs = {
68
+ methodName: "subscribeToTransactionsWithProofs",
69
+ service: Core,
70
+ requestStream: false,
71
+ responseStream: true,
72
+ requestType: core_pb.TransactionsWithProofsRequest,
73
+ responseType: core_pb.TransactionsWithProofsResponse
74
+ };
75
+
76
+ exports.Core = Core;
77
+
78
+ function CoreClient(serviceHost, options) {
79
+ this.serviceHost = serviceHost;
80
+ this.options = options || {};
81
+ }
82
+
83
+ CoreClient.prototype.getStatus = function getStatus(requestMessage, metadata, callback) {
84
+ if (arguments.length === 2) {
85
+ callback = arguments[1];
86
+ }
87
+ var client = grpc.unary(Core.getStatus, {
88
+ request: requestMessage,
89
+ host: this.serviceHost,
90
+ metadata: metadata,
91
+ transport: this.options.transport,
92
+ debug: this.options.debug,
93
+ onEnd: function (response) {
94
+ if (callback) {
95
+ if (response.status !== grpc.Code.OK) {
96
+ var err = new Error(response.statusMessage);
97
+ err.code = response.status;
98
+ err.metadata = response.trailers;
99
+ callback(err, null);
100
+ } else {
101
+ callback(null, response.message);
102
+ }
103
+ }
104
+ }
105
+ });
106
+ return {
107
+ cancel: function () {
108
+ callback = null;
109
+ client.close();
110
+ }
111
+ };
112
+ };
113
+
114
+ CoreClient.prototype.getBlock = function getBlock(requestMessage, metadata, callback) {
115
+ if (arguments.length === 2) {
116
+ callback = arguments[1];
117
+ }
118
+ var client = grpc.unary(Core.getBlock, {
119
+ request: requestMessage,
120
+ host: this.serviceHost,
121
+ metadata: metadata,
122
+ transport: this.options.transport,
123
+ debug: this.options.debug,
124
+ onEnd: function (response) {
125
+ if (callback) {
126
+ if (response.status !== grpc.Code.OK) {
127
+ var err = new Error(response.statusMessage);
128
+ err.code = response.status;
129
+ err.metadata = response.trailers;
130
+ callback(err, null);
131
+ } else {
132
+ callback(null, response.message);
133
+ }
134
+ }
135
+ }
136
+ });
137
+ return {
138
+ cancel: function () {
139
+ callback = null;
140
+ client.close();
141
+ }
142
+ };
143
+ };
144
+
145
+ CoreClient.prototype.broadcastTransaction = function broadcastTransaction(requestMessage, metadata, callback) {
146
+ if (arguments.length === 2) {
147
+ callback = arguments[1];
148
+ }
149
+ var client = grpc.unary(Core.broadcastTransaction, {
150
+ request: requestMessage,
151
+ host: this.serviceHost,
152
+ metadata: metadata,
153
+ transport: this.options.transport,
154
+ debug: this.options.debug,
155
+ onEnd: function (response) {
156
+ if (callback) {
157
+ if (response.status !== grpc.Code.OK) {
158
+ var err = new Error(response.statusMessage);
159
+ err.code = response.status;
160
+ err.metadata = response.trailers;
161
+ callback(err, null);
162
+ } else {
163
+ callback(null, response.message);
164
+ }
165
+ }
166
+ }
167
+ });
168
+ return {
169
+ cancel: function () {
170
+ callback = null;
171
+ client.close();
172
+ }
173
+ };
174
+ };
175
+
176
+ CoreClient.prototype.getTransaction = function getTransaction(requestMessage, metadata, callback) {
177
+ if (arguments.length === 2) {
178
+ callback = arguments[1];
179
+ }
180
+ var client = grpc.unary(Core.getTransaction, {
181
+ request: requestMessage,
182
+ host: this.serviceHost,
183
+ metadata: metadata,
184
+ transport: this.options.transport,
185
+ debug: this.options.debug,
186
+ onEnd: function (response) {
187
+ if (callback) {
188
+ if (response.status !== grpc.Code.OK) {
189
+ var err = new Error(response.statusMessage);
190
+ err.code = response.status;
191
+ err.metadata = response.trailers;
192
+ callback(err, null);
193
+ } else {
194
+ callback(null, response.message);
195
+ }
196
+ }
197
+ }
198
+ });
199
+ return {
200
+ cancel: function () {
201
+ callback = null;
202
+ client.close();
203
+ }
204
+ };
205
+ };
206
+
207
+ CoreClient.prototype.getEstimatedTransactionFee = function getEstimatedTransactionFee(requestMessage, metadata, callback) {
208
+ if (arguments.length === 2) {
209
+ callback = arguments[1];
210
+ }
211
+ var client = grpc.unary(Core.getEstimatedTransactionFee, {
212
+ request: requestMessage,
213
+ host: this.serviceHost,
214
+ metadata: metadata,
215
+ transport: this.options.transport,
216
+ debug: this.options.debug,
217
+ onEnd: function (response) {
218
+ if (callback) {
219
+ if (response.status !== grpc.Code.OK) {
220
+ var err = new Error(response.statusMessage);
221
+ err.code = response.status;
222
+ err.metadata = response.trailers;
223
+ callback(err, null);
224
+ } else {
225
+ callback(null, response.message);
226
+ }
227
+ }
228
+ }
229
+ });
230
+ return {
231
+ cancel: function () {
232
+ callback = null;
233
+ client.close();
234
+ }
235
+ };
236
+ };
237
+
238
+ CoreClient.prototype.subscribeToBlockHeadersWithChainLocks = function subscribeToBlockHeadersWithChainLocks(requestMessage, metadata) {
239
+ var listeners = {
240
+ data: [],
241
+ end: [],
242
+ status: []
243
+ };
244
+ var client = grpc.invoke(Core.subscribeToBlockHeadersWithChainLocks, {
245
+ request: requestMessage,
246
+ host: this.serviceHost,
247
+ metadata: metadata,
248
+ transport: this.options.transport,
249
+ debug: this.options.debug,
250
+ onMessage: function (responseMessage) {
251
+ listeners.data.forEach(function (handler) {
252
+ handler(responseMessage);
253
+ });
254
+ },
255
+ onEnd: function (status, statusMessage, trailers) {
256
+ listeners.status.forEach(function (handler) {
257
+ handler({ code: status, details: statusMessage, metadata: trailers });
258
+ });
259
+ listeners.end.forEach(function (handler) {
260
+ handler({ code: status, details: statusMessage, metadata: trailers });
261
+ });
262
+ listeners = null;
263
+ }
264
+ });
265
+ return {
266
+ on: function (type, handler) {
267
+ listeners[type].push(handler);
268
+ return this;
269
+ },
270
+ cancel: function () {
271
+ listeners = null;
272
+ client.close();
273
+ }
274
+ };
275
+ };
276
+
277
+ CoreClient.prototype.subscribeToTransactionsWithProofs = function subscribeToTransactionsWithProofs(requestMessage, metadata) {
278
+ var listeners = {
279
+ data: [],
280
+ end: [],
281
+ status: []
282
+ };
283
+ var client = grpc.invoke(Core.subscribeToTransactionsWithProofs, {
284
+ request: requestMessage,
285
+ host: this.serviceHost,
286
+ metadata: metadata,
287
+ transport: this.options.transport,
288
+ debug: this.options.debug,
289
+ onMessage: function (responseMessage) {
290
+ listeners.data.forEach(function (handler) {
291
+ handler(responseMessage);
292
+ });
293
+ },
294
+ onEnd: function (status, statusMessage, trailers) {
295
+ listeners.status.forEach(function (handler) {
296
+ handler({ code: status, details: statusMessage, metadata: trailers });
297
+ });
298
+ listeners.end.forEach(function (handler) {
299
+ handler({ code: status, details: statusMessage, metadata: trailers });
300
+ });
301
+ listeners = null;
302
+ }
303
+ });
304
+ return {
305
+ on: function (type, handler) {
306
+ listeners[type].push(handler);
307
+ return this;
308
+ },
309
+ cancel: function () {
310
+ listeners = null;
311
+ client.close();
312
+ }
313
+ };
314
+ };
315
+
316
+ exports.CoreClient = CoreClient;
317
+
@@ -73,8 +73,9 @@ class PlatformPromiseClient {
73
73
  const url = new URL(hostname);
74
74
  const { protocol, host: strippedHostname } = url;
75
75
 
76
+ // See this issue https://github.com/nodejs/node/issues/3176
76
77
  // eslint-disable-next-line no-param-reassign
77
- credentials = protocol === 'https' ? grpc.credentials.createSsl() : grpc.credentials.createInsecure();
78
+ credentials = protocol.replace(':', '') === 'https' ? grpc.credentials.createSsl() : grpc.credentials.createInsecure();
78
79
 
79
80
  this.client = new PlatformNodeJSClient(strippedHostname, credentials, options);
80
81