@dashevo/dapi-grpc 1.0.0-dev.4 → 1.0.0-dev.5
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 +3 -1
- package/build.rs +39 -17
- package/clients/core/v0/rust/core_example.rs +1 -1
- package/clients/platform/v0/nodejs/PlatformPromiseClient.js +78 -0
- package/clients/platform/v0/nodejs/platform_pbjs.js +3000 -1060
- package/clients/platform/v0/nodejs/platform_protoc.js +2609 -748
- package/clients/platform/v0/rust/platform_example.rs +1 -1
- package/clients/platform/v0/web/PlatformPromiseClient.js +28 -0
- package/clients/platform/v0/web/platform_pb.d.ts +253 -0
- package/clients/platform/v0/web/platform_pb.js +2609 -748
- package/clients/platform/v0/web/platform_pb_service.d.ts +38 -0
- package/clients/platform/v0/web/platform_pb_service.js +80 -0
- package/package.json +2 -2
- package/protos/platform/v0/platform.proto +51 -0
- package/src/core/proto/org.dash.platform.dapi.v0.rs +55 -0
- package/src/lib.rs +6 -0
- package/src/mock.rs +68 -0
- package/src/platform/proto/org.dash.platform.dapi.v0.rs +337 -0
- package/test/unit/clients/platform/v0/nodejs/PlatformPromiseClient.spec.js +22 -0
|
@@ -40,6 +40,24 @@ type PlatformgetIdentityKeys = {
|
|
|
40
40
|
readonly responseType: typeof platform_pb.GetIdentityKeysResponse;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
type PlatformgetIdentityNonce = {
|
|
44
|
+
readonly methodName: string;
|
|
45
|
+
readonly service: typeof Platform;
|
|
46
|
+
readonly requestStream: false;
|
|
47
|
+
readonly responseStream: false;
|
|
48
|
+
readonly requestType: typeof platform_pb.GetIdentityNonceRequest;
|
|
49
|
+
readonly responseType: typeof platform_pb.GetIdentityNonceResponse;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type PlatformgetIdentityContractNonce = {
|
|
53
|
+
readonly methodName: string;
|
|
54
|
+
readonly service: typeof Platform;
|
|
55
|
+
readonly requestStream: false;
|
|
56
|
+
readonly responseStream: false;
|
|
57
|
+
readonly requestType: typeof platform_pb.GetIdentityContractNonceRequest;
|
|
58
|
+
readonly responseType: typeof platform_pb.GetIdentityContractNonceResponse;
|
|
59
|
+
};
|
|
60
|
+
|
|
43
61
|
type PlatformgetIdentityBalance = {
|
|
44
62
|
readonly methodName: string;
|
|
45
63
|
readonly service: typeof Platform;
|
|
@@ -172,6 +190,8 @@ export class Platform {
|
|
|
172
190
|
static readonly getIdentity: PlatformgetIdentity;
|
|
173
191
|
static readonly getIdentities: PlatformgetIdentities;
|
|
174
192
|
static readonly getIdentityKeys: PlatformgetIdentityKeys;
|
|
193
|
+
static readonly getIdentityNonce: PlatformgetIdentityNonce;
|
|
194
|
+
static readonly getIdentityContractNonce: PlatformgetIdentityContractNonce;
|
|
175
195
|
static readonly getIdentityBalance: PlatformgetIdentityBalance;
|
|
176
196
|
static readonly getIdentityBalanceAndRevision: PlatformgetIdentityBalanceAndRevision;
|
|
177
197
|
static readonly getProofs: PlatformgetProofs;
|
|
@@ -256,6 +276,24 @@ export class PlatformClient {
|
|
|
256
276
|
requestMessage: platform_pb.GetIdentityKeysRequest,
|
|
257
277
|
callback: (error: ServiceError|null, responseMessage: platform_pb.GetIdentityKeysResponse|null) => void
|
|
258
278
|
): UnaryResponse;
|
|
279
|
+
getIdentityNonce(
|
|
280
|
+
requestMessage: platform_pb.GetIdentityNonceRequest,
|
|
281
|
+
metadata: grpc.Metadata,
|
|
282
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetIdentityNonceResponse|null) => void
|
|
283
|
+
): UnaryResponse;
|
|
284
|
+
getIdentityNonce(
|
|
285
|
+
requestMessage: platform_pb.GetIdentityNonceRequest,
|
|
286
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetIdentityNonceResponse|null) => void
|
|
287
|
+
): UnaryResponse;
|
|
288
|
+
getIdentityContractNonce(
|
|
289
|
+
requestMessage: platform_pb.GetIdentityContractNonceRequest,
|
|
290
|
+
metadata: grpc.Metadata,
|
|
291
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetIdentityContractNonceResponse|null) => void
|
|
292
|
+
): UnaryResponse;
|
|
293
|
+
getIdentityContractNonce(
|
|
294
|
+
requestMessage: platform_pb.GetIdentityContractNonceRequest,
|
|
295
|
+
callback: (error: ServiceError|null, responseMessage: platform_pb.GetIdentityContractNonceResponse|null) => void
|
|
296
|
+
): UnaryResponse;
|
|
259
297
|
getIdentityBalance(
|
|
260
298
|
requestMessage: platform_pb.GetIdentityBalanceRequest,
|
|
261
299
|
metadata: grpc.Metadata,
|
|
@@ -46,6 +46,24 @@ Platform.getIdentityKeys = {
|
|
|
46
46
|
responseType: platform_pb.GetIdentityKeysResponse
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
Platform.getIdentityNonce = {
|
|
50
|
+
methodName: "getIdentityNonce",
|
|
51
|
+
service: Platform,
|
|
52
|
+
requestStream: false,
|
|
53
|
+
responseStream: false,
|
|
54
|
+
requestType: platform_pb.GetIdentityNonceRequest,
|
|
55
|
+
responseType: platform_pb.GetIdentityNonceResponse
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Platform.getIdentityContractNonce = {
|
|
59
|
+
methodName: "getIdentityContractNonce",
|
|
60
|
+
service: Platform,
|
|
61
|
+
requestStream: false,
|
|
62
|
+
responseStream: false,
|
|
63
|
+
requestType: platform_pb.GetIdentityContractNonceRequest,
|
|
64
|
+
responseType: platform_pb.GetIdentityContractNonceResponse
|
|
65
|
+
};
|
|
66
|
+
|
|
49
67
|
Platform.getIdentityBalance = {
|
|
50
68
|
methodName: "getIdentityBalance",
|
|
51
69
|
service: Platform,
|
|
@@ -303,6 +321,68 @@ PlatformClient.prototype.getIdentityKeys = function getIdentityKeys(requestMessa
|
|
|
303
321
|
};
|
|
304
322
|
};
|
|
305
323
|
|
|
324
|
+
PlatformClient.prototype.getIdentityNonce = function getIdentityNonce(requestMessage, metadata, callback) {
|
|
325
|
+
if (arguments.length === 2) {
|
|
326
|
+
callback = arguments[1];
|
|
327
|
+
}
|
|
328
|
+
var client = grpc.unary(Platform.getIdentityNonce, {
|
|
329
|
+
request: requestMessage,
|
|
330
|
+
host: this.serviceHost,
|
|
331
|
+
metadata: metadata,
|
|
332
|
+
transport: this.options.transport,
|
|
333
|
+
debug: this.options.debug,
|
|
334
|
+
onEnd: function (response) {
|
|
335
|
+
if (callback) {
|
|
336
|
+
if (response.status !== grpc.Code.OK) {
|
|
337
|
+
var err = new Error(response.statusMessage);
|
|
338
|
+
err.code = response.status;
|
|
339
|
+
err.metadata = response.trailers;
|
|
340
|
+
callback(err, null);
|
|
341
|
+
} else {
|
|
342
|
+
callback(null, response.message);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
return {
|
|
348
|
+
cancel: function () {
|
|
349
|
+
callback = null;
|
|
350
|
+
client.close();
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
PlatformClient.prototype.getIdentityContractNonce = function getIdentityContractNonce(requestMessage, metadata, callback) {
|
|
356
|
+
if (arguments.length === 2) {
|
|
357
|
+
callback = arguments[1];
|
|
358
|
+
}
|
|
359
|
+
var client = grpc.unary(Platform.getIdentityContractNonce, {
|
|
360
|
+
request: requestMessage,
|
|
361
|
+
host: this.serviceHost,
|
|
362
|
+
metadata: metadata,
|
|
363
|
+
transport: this.options.transport,
|
|
364
|
+
debug: this.options.debug,
|
|
365
|
+
onEnd: function (response) {
|
|
366
|
+
if (callback) {
|
|
367
|
+
if (response.status !== grpc.Code.OK) {
|
|
368
|
+
var err = new Error(response.statusMessage);
|
|
369
|
+
err.code = response.status;
|
|
370
|
+
err.metadata = response.trailers;
|
|
371
|
+
callback(err, null);
|
|
372
|
+
} else {
|
|
373
|
+
callback(null, response.message);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
return {
|
|
379
|
+
cancel: function () {
|
|
380
|
+
callback = null;
|
|
381
|
+
client.close();
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
|
|
306
386
|
PlatformClient.prototype.getIdentityBalance = function getIdentityBalance(requestMessage, metadata, callback) {
|
|
307
387
|
if (arguments.length === 2) {
|
|
308
388
|
callback = arguments[1];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-grpc",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.5",
|
|
4
4
|
"description": "DAPI GRPC definition file and generated clients",
|
|
5
5
|
"browser": "browser.js",
|
|
6
6
|
"main": "node.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://github.com/dashevo/dapi-grpc#readme",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@dashevo/grpc-common": "1.0.0-dev.
|
|
48
|
+
"@dashevo/grpc-common": "1.0.0-dev.5",
|
|
49
49
|
"@dashevo/protobufjs": "6.10.5",
|
|
50
50
|
"@grpc/grpc-js": "1.4.4",
|
|
51
51
|
"@improbable-eng/grpc-web": "^0.15.0",
|
|
@@ -12,6 +12,8 @@ service Platform {
|
|
|
12
12
|
rpc getIdentity(GetIdentityRequest) returns (GetIdentityResponse);
|
|
13
13
|
rpc getIdentities(GetIdentitiesRequest) returns (GetIdentitiesResponse);
|
|
14
14
|
rpc getIdentityKeys(GetIdentityKeysRequest) returns (GetIdentityKeysResponse);
|
|
15
|
+
rpc getIdentityNonce(GetIdentityNonceRequest) returns (GetIdentityNonceResponse);
|
|
16
|
+
rpc getIdentityContractNonce(GetIdentityContractNonceRequest) returns (GetIdentityContractNonceResponse);
|
|
15
17
|
rpc getIdentityBalance(GetIdentityBalanceRequest)
|
|
16
18
|
returns (GetIdentityBalanceResponse);
|
|
17
19
|
rpc getIdentityBalanceAndRevision(GetIdentityBalanceAndRevisionRequest)
|
|
@@ -74,6 +76,28 @@ message GetIdentityRequest {
|
|
|
74
76
|
oneof version { GetIdentityRequestV0 v0 = 1; }
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
message GetIdentityNonceRequest {
|
|
80
|
+
|
|
81
|
+
message GetIdentityNonceRequestV0 {
|
|
82
|
+
bytes identity_id = 1;
|
|
83
|
+
bool prove = 2;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
oneof version { GetIdentityNonceRequestV0 v0 = 1; }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
message GetIdentityContractNonceRequest {
|
|
91
|
+
|
|
92
|
+
message GetIdentityContractNonceRequestV0 {
|
|
93
|
+
bytes identity_id = 1;
|
|
94
|
+
bytes contract_id = 2;
|
|
95
|
+
bool prove = 3;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
oneof version { GetIdentityContractNonceRequestV0 v0 = 1; }
|
|
99
|
+
}
|
|
100
|
+
|
|
77
101
|
message GetIdentityBalanceRequest {
|
|
78
102
|
|
|
79
103
|
message GetIdentityBalanceRequestV0 {
|
|
@@ -139,6 +163,32 @@ message GetIdentitiesResponse {
|
|
|
139
163
|
oneof version { GetIdentitiesResponseV0 v0 = 1; }
|
|
140
164
|
}
|
|
141
165
|
|
|
166
|
+
message GetIdentityNonceResponse {
|
|
167
|
+
|
|
168
|
+
message GetIdentityNonceResponseV0 {
|
|
169
|
+
oneof result {
|
|
170
|
+
uint64 identity_nonce = 1;
|
|
171
|
+
Proof proof = 2;
|
|
172
|
+
}
|
|
173
|
+
ResponseMetadata metadata = 3;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
oneof version { GetIdentityNonceResponseV0 v0 = 1; }
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
message GetIdentityContractNonceResponse {
|
|
180
|
+
|
|
181
|
+
message GetIdentityContractNonceResponseV0 {
|
|
182
|
+
oneof result {
|
|
183
|
+
uint64 identity_contract_nonce = 1;
|
|
184
|
+
Proof proof = 2;
|
|
185
|
+
}
|
|
186
|
+
ResponseMetadata metadata = 3;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
oneof version { GetIdentityContractNonceResponseV0 v0 = 1; }
|
|
190
|
+
}
|
|
191
|
+
|
|
142
192
|
message GetIdentityBalanceResponse {
|
|
143
193
|
|
|
144
194
|
message GetIdentityBalanceResponseV0 {
|
|
@@ -234,6 +284,7 @@ message GetProofsRequest {
|
|
|
234
284
|
FULL_IDENTITY = 0;
|
|
235
285
|
BALANCE = 1;
|
|
236
286
|
KEYS = 2;
|
|
287
|
+
REVISION = 3;
|
|
237
288
|
}
|
|
238
289
|
bytes identity_id = 1;
|
|
239
290
|
Type request_type = 2;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
2
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
1
3
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
2
4
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
3
5
|
pub struct GetStatusRequest {}
|
|
6
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
7
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
4
8
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
5
9
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
6
10
|
pub struct GetStatusResponse {
|
|
@@ -21,6 +25,8 @@ pub struct GetStatusResponse {
|
|
|
21
25
|
}
|
|
22
26
|
/// Nested message and enum types in `GetStatusResponse`.
|
|
23
27
|
pub mod get_status_response {
|
|
28
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
29
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
24
30
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
25
31
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
26
32
|
pub struct Version {
|
|
@@ -31,6 +37,8 @@ pub mod get_status_response {
|
|
|
31
37
|
#[prost(string, tag = "3")]
|
|
32
38
|
pub agent: ::prost::alloc::string::String,
|
|
33
39
|
}
|
|
40
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
41
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
34
42
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
35
43
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
36
44
|
pub struct Time {
|
|
@@ -41,6 +49,8 @@ pub mod get_status_response {
|
|
|
41
49
|
#[prost(uint32, tag = "3")]
|
|
42
50
|
pub median: u32,
|
|
43
51
|
}
|
|
52
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
53
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
44
54
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
45
55
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
46
56
|
pub struct Chain {
|
|
@@ -61,6 +71,8 @@ pub mod get_status_response {
|
|
|
61
71
|
#[prost(double, tag = "8")]
|
|
62
72
|
pub sync_progress: f64,
|
|
63
73
|
}
|
|
74
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
75
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
64
76
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
65
77
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
66
78
|
pub struct Masternode {
|
|
@@ -77,6 +89,7 @@ pub mod get_status_response {
|
|
|
77
89
|
}
|
|
78
90
|
/// Nested message and enum types in `Masternode`.
|
|
79
91
|
pub mod masternode {
|
|
92
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
80
93
|
#[derive(
|
|
81
94
|
Clone,
|
|
82
95
|
Copy,
|
|
@@ -132,6 +145,8 @@ pub mod get_status_response {
|
|
|
132
145
|
}
|
|
133
146
|
}
|
|
134
147
|
}
|
|
148
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
149
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
135
150
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
136
151
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
137
152
|
pub struct NetworkFee {
|
|
@@ -140,6 +155,8 @@ pub mod get_status_response {
|
|
|
140
155
|
#[prost(double, tag = "2")]
|
|
141
156
|
pub incremental: f64,
|
|
142
157
|
}
|
|
158
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
159
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
143
160
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
144
161
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
145
162
|
pub struct Network {
|
|
@@ -148,6 +165,7 @@ pub mod get_status_response {
|
|
|
148
165
|
#[prost(message, optional, tag = "2")]
|
|
149
166
|
pub fee: ::core::option::Option<NetworkFee>,
|
|
150
167
|
}
|
|
168
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
151
169
|
#[derive(
|
|
152
170
|
Clone,
|
|
153
171
|
Copy,
|
|
@@ -191,6 +209,8 @@ pub mod get_status_response {
|
|
|
191
209
|
}
|
|
192
210
|
}
|
|
193
211
|
}
|
|
212
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
213
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
194
214
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
195
215
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
196
216
|
pub struct GetBlockRequest {
|
|
@@ -199,6 +219,7 @@ pub struct GetBlockRequest {
|
|
|
199
219
|
}
|
|
200
220
|
/// Nested message and enum types in `GetBlockRequest`.
|
|
201
221
|
pub mod get_block_request {
|
|
222
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
202
223
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
203
224
|
#[derive(Clone, PartialEq, ::prost::Oneof)]
|
|
204
225
|
pub enum Block {
|
|
@@ -208,12 +229,16 @@ pub mod get_block_request {
|
|
|
208
229
|
Hash(::prost::alloc::string::String),
|
|
209
230
|
}
|
|
210
231
|
}
|
|
232
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
233
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
211
234
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
212
235
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
213
236
|
pub struct GetBlockResponse {
|
|
214
237
|
#[prost(bytes = "vec", tag = "1")]
|
|
215
238
|
pub block: ::prost::alloc::vec::Vec<u8>,
|
|
216
239
|
}
|
|
240
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
241
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
217
242
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
218
243
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
219
244
|
pub struct BroadcastTransactionRequest {
|
|
@@ -224,18 +249,24 @@ pub struct BroadcastTransactionRequest {
|
|
|
224
249
|
#[prost(bool, tag = "3")]
|
|
225
250
|
pub bypass_limits: bool,
|
|
226
251
|
}
|
|
252
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
253
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
227
254
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
228
255
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
229
256
|
pub struct BroadcastTransactionResponse {
|
|
230
257
|
#[prost(string, tag = "1")]
|
|
231
258
|
pub transaction_id: ::prost::alloc::string::String,
|
|
232
259
|
}
|
|
260
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
261
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
233
262
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
234
263
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
235
264
|
pub struct GetTransactionRequest {
|
|
236
265
|
#[prost(string, tag = "1")]
|
|
237
266
|
pub id: ::prost::alloc::string::String,
|
|
238
267
|
}
|
|
268
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
269
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
239
270
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
240
271
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
241
272
|
pub struct GetTransactionResponse {
|
|
@@ -252,6 +283,8 @@ pub struct GetTransactionResponse {
|
|
|
252
283
|
#[prost(bool, tag = "6")]
|
|
253
284
|
pub is_chain_locked: bool,
|
|
254
285
|
}
|
|
286
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
287
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
255
288
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
256
289
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
257
290
|
pub struct BlockHeadersWithChainLocksRequest {
|
|
@@ -264,6 +297,7 @@ pub struct BlockHeadersWithChainLocksRequest {
|
|
|
264
297
|
}
|
|
265
298
|
/// Nested message and enum types in `BlockHeadersWithChainLocksRequest`.
|
|
266
299
|
pub mod block_headers_with_chain_locks_request {
|
|
300
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
267
301
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
268
302
|
#[derive(Clone, PartialEq, ::prost::Oneof)]
|
|
269
303
|
pub enum FromBlock {
|
|
@@ -273,6 +307,8 @@ pub mod block_headers_with_chain_locks_request {
|
|
|
273
307
|
FromBlockHeight(u32),
|
|
274
308
|
}
|
|
275
309
|
}
|
|
310
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
311
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
276
312
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
277
313
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
278
314
|
pub struct BlockHeadersWithChainLocksResponse {
|
|
@@ -283,6 +319,7 @@ pub struct BlockHeadersWithChainLocksResponse {
|
|
|
283
319
|
}
|
|
284
320
|
/// Nested message and enum types in `BlockHeadersWithChainLocksResponse`.
|
|
285
321
|
pub mod block_headers_with_chain_locks_response {
|
|
322
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
286
323
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
287
324
|
#[derive(Clone, PartialEq, ::prost::Oneof)]
|
|
288
325
|
pub enum Responses {
|
|
@@ -292,24 +329,32 @@ pub mod block_headers_with_chain_locks_response {
|
|
|
292
329
|
ChainLock(::prost::alloc::vec::Vec<u8>),
|
|
293
330
|
}
|
|
294
331
|
}
|
|
332
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
333
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
295
334
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
296
335
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
297
336
|
pub struct BlockHeaders {
|
|
298
337
|
#[prost(bytes = "vec", repeated, tag = "1")]
|
|
299
338
|
pub headers: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
|
|
300
339
|
}
|
|
340
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
341
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
301
342
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
302
343
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
303
344
|
pub struct GetEstimatedTransactionFeeRequest {
|
|
304
345
|
#[prost(uint32, tag = "1")]
|
|
305
346
|
pub blocks: u32,
|
|
306
347
|
}
|
|
348
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
349
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
307
350
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
308
351
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
309
352
|
pub struct GetEstimatedTransactionFeeResponse {
|
|
310
353
|
#[prost(double, tag = "1")]
|
|
311
354
|
pub fee: f64,
|
|
312
355
|
}
|
|
356
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
357
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
313
358
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
314
359
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
315
360
|
pub struct TransactionsWithProofsRequest {
|
|
@@ -324,6 +369,7 @@ pub struct TransactionsWithProofsRequest {
|
|
|
324
369
|
}
|
|
325
370
|
/// Nested message and enum types in `TransactionsWithProofsRequest`.
|
|
326
371
|
pub mod transactions_with_proofs_request {
|
|
372
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
327
373
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
328
374
|
#[derive(Clone, PartialEq, ::prost::Oneof)]
|
|
329
375
|
pub enum FromBlock {
|
|
@@ -333,6 +379,8 @@ pub mod transactions_with_proofs_request {
|
|
|
333
379
|
FromBlockHeight(u32),
|
|
334
380
|
}
|
|
335
381
|
}
|
|
382
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
383
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
336
384
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
337
385
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
338
386
|
pub struct BloomFilter {
|
|
@@ -345,6 +393,8 @@ pub struct BloomFilter {
|
|
|
345
393
|
#[prost(uint32, tag = "4")]
|
|
346
394
|
pub n_flags: u32,
|
|
347
395
|
}
|
|
396
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
397
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
348
398
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
349
399
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
350
400
|
pub struct TransactionsWithProofsResponse {
|
|
@@ -353,6 +403,7 @@ pub struct TransactionsWithProofsResponse {
|
|
|
353
403
|
}
|
|
354
404
|
/// Nested message and enum types in `TransactionsWithProofsResponse`.
|
|
355
405
|
pub mod transactions_with_proofs_response {
|
|
406
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
356
407
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
357
408
|
#[derive(Clone, PartialEq, ::prost::Oneof)]
|
|
358
409
|
pub enum Responses {
|
|
@@ -364,12 +415,16 @@ pub mod transactions_with_proofs_response {
|
|
|
364
415
|
RawMerkleBlock(::prost::alloc::vec::Vec<u8>),
|
|
365
416
|
}
|
|
366
417
|
}
|
|
418
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
419
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
367
420
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
368
421
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
369
422
|
pub struct RawTransactions {
|
|
370
423
|
#[prost(bytes = "vec", repeated, tag = "1")]
|
|
371
424
|
pub transactions: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
|
|
372
425
|
}
|
|
426
|
+
#[derive(::serde::Serialize, ::serde::Deserialize)]
|
|
427
|
+
#[derive(::dapi_grpc_macros::Mockable)]
|
|
373
428
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
|
374
429
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
|
375
430
|
pub struct InstantSendLockMessages {
|
package/src/lib.rs
CHANGED
|
@@ -22,3 +22,9 @@ pub mod platform {
|
|
|
22
22
|
#[cfg(feature = "serde")]
|
|
23
23
|
// Serde deserialization logic
|
|
24
24
|
pub mod deserialization;
|
|
25
|
+
|
|
26
|
+
// We need mock module even if the feature is disabled
|
|
27
|
+
pub mod mock;
|
|
28
|
+
|
|
29
|
+
// Re-export tonic to ensure everyone uses the same version
|
|
30
|
+
pub use tonic;
|
package/src/mock.rs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//! Mocking support for messages.
|
|
2
|
+
//!
|
|
3
|
+
//! Contains [Mockable] trait that should be implemented by any object that can be used in the DAPI.
|
|
4
|
+
//!
|
|
5
|
+
//! Note that this trait is defined even if mocks are not supported, but it should always return `None` on serialization.
|
|
6
|
+
use tonic::Streaming;
|
|
7
|
+
|
|
8
|
+
/// Mocking support for messages.
|
|
9
|
+
///
|
|
10
|
+
/// This trait should be implemented by any object that can be used in the DAPI.
|
|
11
|
+
///
|
|
12
|
+
/// We use serde_json to serialize/deserialize messages.
|
|
13
|
+
// TODO: Move to a different crate where it can be easily shared by dapi-grpc, dash-platform-sdk, and rs-dapi-client.
|
|
14
|
+
pub trait Mockable
|
|
15
|
+
where
|
|
16
|
+
Self: std::marker::Sized,
|
|
17
|
+
{
|
|
18
|
+
/// Serialize the message to bytes for mocking purposes.
|
|
19
|
+
///
|
|
20
|
+
/// Returns None if the message is not serializable or mocking is disabled.
|
|
21
|
+
///
|
|
22
|
+
/// # Panics
|
|
23
|
+
///
|
|
24
|
+
/// Panics on any error.
|
|
25
|
+
fn mock_serialize(&self) -> Option<Vec<u8>> {
|
|
26
|
+
None
|
|
27
|
+
}
|
|
28
|
+
/// Deserialize the message serialized with [mock_serialize()].
|
|
29
|
+
///
|
|
30
|
+
/// Returns None if the message is not serializable or mocking is disabled.
|
|
31
|
+
///
|
|
32
|
+
/// # Panics
|
|
33
|
+
///
|
|
34
|
+
/// Panics on any error.
|
|
35
|
+
fn mock_deserialize(_data: &[u8]) -> Option<Self> {
|
|
36
|
+
None
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
impl<T: Mockable> Mockable for Option<T> {
|
|
41
|
+
#[cfg(feature = "mocks")]
|
|
42
|
+
fn mock_serialize(&self) -> Option<Vec<u8>> {
|
|
43
|
+
self.as_ref().and_then(|value| value.mock_serialize())
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#[cfg(feature = "mocks")]
|
|
47
|
+
fn mock_deserialize(data: &[u8]) -> Option<Self> {
|
|
48
|
+
T::mock_deserialize(data).map(Some)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
impl Mockable for Vec<u8> {
|
|
53
|
+
#[cfg(feature = "mocks")]
|
|
54
|
+
fn mock_serialize(&self) -> Option<Vec<u8>> {
|
|
55
|
+
serde_json::to_vec(self).ok()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#[cfg(feature = "mocks")]
|
|
59
|
+
fn mock_deserialize(data: &[u8]) -> Option<Self> {
|
|
60
|
+
serde_json::from_slice(data).ok()
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// Mocking of gRPC streaming responses is not supported.
|
|
65
|
+
///
|
|
66
|
+
/// This will return `None` on serialization,
|
|
67
|
+
/// effectively disabling mocking of streaming responses.
|
|
68
|
+
impl<T: Mockable> Mockable for Streaming<T> {}
|