@dashevo/dapi-grpc 0.23.0-dev.9 → 0.23.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.
- package/README.md +3 -3
- package/browser.js +13 -5
- package/clients/core/v0/nodejs/core_protoc.js +1 -7
- 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 +1 -7
- 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/platform_protoc.js +1 -7
- package/clients/platform/v0/web/PlatformPromiseClient.js +130 -0
- package/clients/platform/v0/web/platform_pb.d.ts +595 -0
- package/clients/platform/v0/web/platform_pb.js +1 -7
- package/clients/platform/v0/web/platform_pb_service.d.ts +177 -0
- package/clients/platform/v0/web/platform_pb_service.js +301 -0
- package/lib/utils/parseMetadata.js +27 -0
- package/node.js +4 -0
- package/package.json +3 -3
- package/scripts/build.sh +11 -10
- package/clients/core/v0/web/core_grpc_web_pb.js +0 -495
- package/clients/platform/v0/web/platform_grpc_web_pb.js +0 -505
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// package: org.dash.platform.dapi.v0
|
|
2
|
+
// file: platform.proto
|
|
3
|
+
|
|
4
|
+
import * as platform_pb from "./platform_pb";
|
|
5
|
+
import {grpc} from "@improbable-eng/grpc-web";
|
|
6
|
+
|
|
7
|
+
type PlatformbroadcastStateTransition = {
|
|
8
|
+
readonly methodName: string;
|
|
9
|
+
readonly service: typeof Platform;
|
|
10
|
+
readonly requestStream: false;
|
|
11
|
+
readonly responseStream: false;
|
|
12
|
+
readonly requestType: typeof platform_pb.BroadcastStateTransitionRequest;
|
|
13
|
+
readonly responseType: typeof platform_pb.BroadcastStateTransitionResponse;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type PlatformgetIdentity = {
|
|
17
|
+
readonly methodName: string;
|
|
18
|
+
readonly service: typeof Platform;
|
|
19
|
+
readonly requestStream: false;
|
|
20
|
+
readonly responseStream: false;
|
|
21
|
+
readonly requestType: typeof platform_pb.GetIdentityRequest;
|
|
22
|
+
readonly responseType: typeof platform_pb.GetIdentityResponse;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type PlatformgetDataContract = {
|
|
26
|
+
readonly methodName: string;
|
|
27
|
+
readonly service: typeof Platform;
|
|
28
|
+
readonly requestStream: false;
|
|
29
|
+
readonly responseStream: false;
|
|
30
|
+
readonly requestType: typeof platform_pb.GetDataContractRequest;
|
|
31
|
+
readonly responseType: typeof platform_pb.GetDataContractResponse;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type PlatformgetDocuments = {
|
|
35
|
+
readonly methodName: string;
|
|
36
|
+
readonly service: typeof Platform;
|
|
37
|
+
readonly requestStream: false;
|
|
38
|
+
readonly responseStream: false;
|
|
39
|
+
readonly requestType: typeof platform_pb.GetDocumentsRequest;
|
|
40
|
+
readonly responseType: typeof platform_pb.GetDocumentsResponse;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type PlatformgetIdentitiesByPublicKeyHashes = {
|
|
44
|
+
readonly methodName: string;
|
|
45
|
+
readonly service: typeof Platform;
|
|
46
|
+
readonly requestStream: false;
|
|
47
|
+
readonly responseStream: false;
|
|
48
|
+
readonly requestType: typeof platform_pb.GetIdentitiesByPublicKeyHashesRequest;
|
|
49
|
+
readonly responseType: typeof platform_pb.GetIdentitiesByPublicKeyHashesResponse;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type PlatformwaitForStateTransitionResult = {
|
|
53
|
+
readonly methodName: string;
|
|
54
|
+
readonly service: typeof Platform;
|
|
55
|
+
readonly requestStream: false;
|
|
56
|
+
readonly responseStream: false;
|
|
57
|
+
readonly requestType: typeof platform_pb.WaitForStateTransitionResultRequest;
|
|
58
|
+
readonly responseType: typeof platform_pb.WaitForStateTransitionResultResponse;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type PlatformgetConsensusParams = {
|
|
62
|
+
readonly methodName: string;
|
|
63
|
+
readonly service: typeof Platform;
|
|
64
|
+
readonly requestStream: false;
|
|
65
|
+
readonly responseStream: false;
|
|
66
|
+
readonly requestType: typeof platform_pb.GetConsensusParamsRequest;
|
|
67
|
+
readonly responseType: typeof platform_pb.GetConsensusParamsResponse;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export class Platform {
|
|
71
|
+
static readonly serviceName: string;
|
|
72
|
+
static readonly broadcastStateTransition: PlatformbroadcastStateTransition;
|
|
73
|
+
static readonly getIdentity: PlatformgetIdentity;
|
|
74
|
+
static readonly getDataContract: PlatformgetDataContract;
|
|
75
|
+
static readonly getDocuments: PlatformgetDocuments;
|
|
76
|
+
static readonly getIdentitiesByPublicKeyHashes: PlatformgetIdentitiesByPublicKeyHashes;
|
|
77
|
+
static readonly waitForStateTransitionResult: PlatformwaitForStateTransitionResult;
|
|
78
|
+
static readonly getConsensusParams: PlatformgetConsensusParams;
|
|
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 PlatformClient {
|
|
110
|
+
readonly serviceHost: string;
|
|
111
|
+
|
|
112
|
+
constructor(serviceHost: string, options?: grpc.RpcOptions);
|
|
113
|
+
broadcastStateTransition(
|
|
114
|
+
requestMessage: platform_pb.BroadcastStateTransitionRequest,
|
|
115
|
+
metadata: grpc.Metadata,
|
|
116
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.BroadcastStateTransitionResponse|null) => void
|
|
117
|
+
): UnaryResponse;
|
|
118
|
+
broadcastStateTransition(
|
|
119
|
+
requestMessage: platform_pb.BroadcastStateTransitionRequest,
|
|
120
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.BroadcastStateTransitionResponse|null) => void
|
|
121
|
+
): UnaryResponse;
|
|
122
|
+
getIdentity(
|
|
123
|
+
requestMessage: platform_pb.GetIdentityRequest,
|
|
124
|
+
metadata: grpc.Metadata,
|
|
125
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetIdentityResponse|null) => void
|
|
126
|
+
): UnaryResponse;
|
|
127
|
+
getIdentity(
|
|
128
|
+
requestMessage: platform_pb.GetIdentityRequest,
|
|
129
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetIdentityResponse|null) => void
|
|
130
|
+
): UnaryResponse;
|
|
131
|
+
getDataContract(
|
|
132
|
+
requestMessage: platform_pb.GetDataContractRequest,
|
|
133
|
+
metadata: grpc.Metadata,
|
|
134
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetDataContractResponse|null) => void
|
|
135
|
+
): UnaryResponse;
|
|
136
|
+
getDataContract(
|
|
137
|
+
requestMessage: platform_pb.GetDataContractRequest,
|
|
138
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetDataContractResponse|null) => void
|
|
139
|
+
): UnaryResponse;
|
|
140
|
+
getDocuments(
|
|
141
|
+
requestMessage: platform_pb.GetDocumentsRequest,
|
|
142
|
+
metadata: grpc.Metadata,
|
|
143
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetDocumentsResponse|null) => void
|
|
144
|
+
): UnaryResponse;
|
|
145
|
+
getDocuments(
|
|
146
|
+
requestMessage: platform_pb.GetDocumentsRequest,
|
|
147
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetDocumentsResponse|null) => void
|
|
148
|
+
): UnaryResponse;
|
|
149
|
+
getIdentitiesByPublicKeyHashes(
|
|
150
|
+
requestMessage: platform_pb.GetIdentitiesByPublicKeyHashesRequest,
|
|
151
|
+
metadata: grpc.Metadata,
|
|
152
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetIdentitiesByPublicKeyHashesResponse|null) => void
|
|
153
|
+
): UnaryResponse;
|
|
154
|
+
getIdentitiesByPublicKeyHashes(
|
|
155
|
+
requestMessage: platform_pb.GetIdentitiesByPublicKeyHashesRequest,
|
|
156
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetIdentitiesByPublicKeyHashesResponse|null) => void
|
|
157
|
+
): UnaryResponse;
|
|
158
|
+
waitForStateTransitionResult(
|
|
159
|
+
requestMessage: platform_pb.WaitForStateTransitionResultRequest,
|
|
160
|
+
metadata: grpc.Metadata,
|
|
161
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.WaitForStateTransitionResultResponse|null) => void
|
|
162
|
+
): UnaryResponse;
|
|
163
|
+
waitForStateTransitionResult(
|
|
164
|
+
requestMessage: platform_pb.WaitForStateTransitionResultRequest,
|
|
165
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.WaitForStateTransitionResultResponse|null) => void
|
|
166
|
+
): UnaryResponse;
|
|
167
|
+
getConsensusParams(
|
|
168
|
+
requestMessage: platform_pb.GetConsensusParamsRequest,
|
|
169
|
+
metadata: grpc.Metadata,
|
|
170
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetConsensusParamsResponse|null) => void
|
|
171
|
+
): UnaryResponse;
|
|
172
|
+
getConsensusParams(
|
|
173
|
+
requestMessage: platform_pb.GetConsensusParamsRequest,
|
|
174
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetConsensusParamsResponse|null) => void
|
|
175
|
+
): UnaryResponse;
|
|
176
|
+
}
|
|
177
|
+
|
|
@@ -0,0 +1,301 @@
|
|
|
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.getDataContract = {
|
|
32
|
+
methodName: "getDataContract",
|
|
33
|
+
service: Platform,
|
|
34
|
+
requestStream: false,
|
|
35
|
+
responseStream: false,
|
|
36
|
+
requestType: platform_pb.GetDataContractRequest,
|
|
37
|
+
responseType: platform_pb.GetDataContractResponse
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
Platform.getDocuments = {
|
|
41
|
+
methodName: "getDocuments",
|
|
42
|
+
service: Platform,
|
|
43
|
+
requestStream: false,
|
|
44
|
+
responseStream: false,
|
|
45
|
+
requestType: platform_pb.GetDocumentsRequest,
|
|
46
|
+
responseType: platform_pb.GetDocumentsResponse
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
Platform.getIdentitiesByPublicKeyHashes = {
|
|
50
|
+
methodName: "getIdentitiesByPublicKeyHashes",
|
|
51
|
+
service: Platform,
|
|
52
|
+
requestStream: false,
|
|
53
|
+
responseStream: false,
|
|
54
|
+
requestType: platform_pb.GetIdentitiesByPublicKeyHashesRequest,
|
|
55
|
+
responseType: platform_pb.GetIdentitiesByPublicKeyHashesResponse
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Platform.waitForStateTransitionResult = {
|
|
59
|
+
methodName: "waitForStateTransitionResult",
|
|
60
|
+
service: Platform,
|
|
61
|
+
requestStream: false,
|
|
62
|
+
responseStream: false,
|
|
63
|
+
requestType: platform_pb.WaitForStateTransitionResultRequest,
|
|
64
|
+
responseType: platform_pb.WaitForStateTransitionResultResponse
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Platform.getConsensusParams = {
|
|
68
|
+
methodName: "getConsensusParams",
|
|
69
|
+
service: Platform,
|
|
70
|
+
requestStream: false,
|
|
71
|
+
responseStream: false,
|
|
72
|
+
requestType: platform_pb.GetConsensusParamsRequest,
|
|
73
|
+
responseType: platform_pb.GetConsensusParamsResponse
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
exports.Platform = Platform;
|
|
77
|
+
|
|
78
|
+
function PlatformClient(serviceHost, options) {
|
|
79
|
+
this.serviceHost = serviceHost;
|
|
80
|
+
this.options = options || {};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
PlatformClient.prototype.broadcastStateTransition = function broadcastStateTransition(requestMessage, metadata, callback) {
|
|
84
|
+
if (arguments.length === 2) {
|
|
85
|
+
callback = arguments[1];
|
|
86
|
+
}
|
|
87
|
+
var client = grpc.unary(Platform.broadcastStateTransition, {
|
|
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
|
+
PlatformClient.prototype.getIdentity = function getIdentity(requestMessage, metadata, callback) {
|
|
115
|
+
if (arguments.length === 2) {
|
|
116
|
+
callback = arguments[1];
|
|
117
|
+
}
|
|
118
|
+
var client = grpc.unary(Platform.getIdentity, {
|
|
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
|
+
PlatformClient.prototype.getDataContract = function getDataContract(requestMessage, metadata, callback) {
|
|
146
|
+
if (arguments.length === 2) {
|
|
147
|
+
callback = arguments[1];
|
|
148
|
+
}
|
|
149
|
+
var client = grpc.unary(Platform.getDataContract, {
|
|
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
|
+
PlatformClient.prototype.getDocuments = function getDocuments(requestMessage, metadata, callback) {
|
|
177
|
+
if (arguments.length === 2) {
|
|
178
|
+
callback = arguments[1];
|
|
179
|
+
}
|
|
180
|
+
var client = grpc.unary(Platform.getDocuments, {
|
|
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
|
+
PlatformClient.prototype.getIdentitiesByPublicKeyHashes = function getIdentitiesByPublicKeyHashes(requestMessage, metadata, callback) {
|
|
208
|
+
if (arguments.length === 2) {
|
|
209
|
+
callback = arguments[1];
|
|
210
|
+
}
|
|
211
|
+
var client = grpc.unary(Platform.getIdentitiesByPublicKeyHashes, {
|
|
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
|
+
PlatformClient.prototype.waitForStateTransitionResult = function waitForStateTransitionResult(requestMessage, metadata, callback) {
|
|
239
|
+
if (arguments.length === 2) {
|
|
240
|
+
callback = arguments[1];
|
|
241
|
+
}
|
|
242
|
+
var client = grpc.unary(Platform.waitForStateTransitionResult, {
|
|
243
|
+
request: requestMessage,
|
|
244
|
+
host: this.serviceHost,
|
|
245
|
+
metadata: metadata,
|
|
246
|
+
transport: this.options.transport,
|
|
247
|
+
debug: this.options.debug,
|
|
248
|
+
onEnd: function (response) {
|
|
249
|
+
if (callback) {
|
|
250
|
+
if (response.status !== grpc.Code.OK) {
|
|
251
|
+
var err = new Error(response.statusMessage);
|
|
252
|
+
err.code = response.status;
|
|
253
|
+
err.metadata = response.trailers;
|
|
254
|
+
callback(err, null);
|
|
255
|
+
} else {
|
|
256
|
+
callback(null, response.message);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
return {
|
|
262
|
+
cancel: function () {
|
|
263
|
+
callback = null;
|
|
264
|
+
client.close();
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
PlatformClient.prototype.getConsensusParams = function getConsensusParams(requestMessage, metadata, callback) {
|
|
270
|
+
if (arguments.length === 2) {
|
|
271
|
+
callback = arguments[1];
|
|
272
|
+
}
|
|
273
|
+
var client = grpc.unary(Platform.getConsensusParams, {
|
|
274
|
+
request: requestMessage,
|
|
275
|
+
host: this.serviceHost,
|
|
276
|
+
metadata: metadata,
|
|
277
|
+
transport: this.options.transport,
|
|
278
|
+
debug: this.options.debug,
|
|
279
|
+
onEnd: function (response) {
|
|
280
|
+
if (callback) {
|
|
281
|
+
if (response.status !== grpc.Code.OK) {
|
|
282
|
+
var err = new Error(response.statusMessage);
|
|
283
|
+
err.code = response.status;
|
|
284
|
+
err.metadata = response.trailers;
|
|
285
|
+
callback(err, null);
|
|
286
|
+
} else {
|
|
287
|
+
callback(null, response.message);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
return {
|
|
293
|
+
cancel: function () {
|
|
294
|
+
callback = null;
|
|
295
|
+
client.close();
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
exports.PlatformClient = PlatformClient;
|
|
301
|
+
|
|
@@ -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.23.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "DAPI GRPC definition file and generated clients",
|
|
5
5
|
"browser": "browser.js",
|
|
6
6
|
"main": "node.js",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/dashevo/dapi-grpc#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@dashevo/grpc-common": "
|
|
36
|
+
"@dashevo/grpc-common": "0.23.1",
|
|
37
37
|
"@dashevo/protobufjs": "6.10.5",
|
|
38
38
|
"@grpc/grpc-js": "^1.3.7",
|
|
39
|
+
"@improbable-eng/grpc-web": "^0.15.0",
|
|
39
40
|
"google-protobuf": "^3.12.2",
|
|
40
|
-
"grpc-web": "1.2.1",
|
|
41
41
|
"long": "^5.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
package/scripts/build.sh
CHANGED
|
@@ -18,8 +18,7 @@ PLATFORM_OBJ_C_OUT_PATH="$PLATFORM_CLIENTS_PATH/objective-c"
|
|
|
18
18
|
CORE_PYTHON_OUT_PATH="$CORE_CLIENTS_PATH/python"
|
|
19
19
|
PLATFORM_PYTHON_OUT_PATH="$PLATFORM_CLIENTS_PATH/python"
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
PROTOC_IMAGE="strophy/protoc:3.3.2"
|
|
21
|
+
PROTOC_IMAGE="rvolosatovs/protoc:4.0.0"
|
|
23
22
|
|
|
24
23
|
#################################################
|
|
25
24
|
# Generate JavaScript client for `Core` service #
|
|
@@ -30,10 +29,11 @@ rm -rf "$CORE_WEB_OUT_PATH/*"
|
|
|
30
29
|
docker run -v "$CORE_PROTO_PATH:$CORE_PROTO_PATH" \
|
|
31
30
|
-v "$CORE_WEB_OUT_PATH:$CORE_WEB_OUT_PATH" \
|
|
32
31
|
--rm \
|
|
33
|
-
"$
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
"$PROTOC_IMAGE" \
|
|
33
|
+
--js_out="import_style=commonjs:$CORE_WEB_OUT_PATH" \
|
|
34
|
+
--ts_out="service=grpc-web:$CORE_WEB_OUT_PATH" \
|
|
35
|
+
-I="$CORE_PROTO_PATH" \
|
|
36
|
+
"core.proto"
|
|
37
37
|
|
|
38
38
|
# Clean node message classes
|
|
39
39
|
|
|
@@ -61,10 +61,11 @@ rm -rf "$PLATFORM_WEB_OUT_PATH/*"
|
|
|
61
61
|
docker run -v "$PLATFORM_PROTO_PATH:$PLATFORM_PROTO_PATH" \
|
|
62
62
|
-v "$PLATFORM_WEB_OUT_PATH:$PLATFORM_WEB_OUT_PATH" \
|
|
63
63
|
--rm \
|
|
64
|
-
"$
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
"$PROTOC_IMAGE" \
|
|
65
|
+
--js_out="import_style=commonjs:$PLATFORM_WEB_OUT_PATH" \
|
|
66
|
+
--ts_out="service=grpc-web:$PLATFORM_WEB_OUT_PATH" \
|
|
67
|
+
-I="$PLATFORM_PROTO_PATH" \
|
|
68
|
+
"platform.proto"
|
|
68
69
|
|
|
69
70
|
# Clean node message classes
|
|
70
71
|
|