@dashevo/dapi-grpc 0.25.0-dev.8 → 0.25.0-pr.1545.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +45 -0
- package/build.rs +69 -0
- package/clients/core/v0/rust/README.md +3 -0
- package/clients/core/v0/rust/core_example.rs +14 -0
- package/clients/platform/v0/nodejs/PlatformPromiseClient.js +163 -0
- package/clients/platform/v0/nodejs/platform_pbjs.js +23402 -1734
- package/clients/platform/v0/nodejs/platform_protoc.js +20140 -1970
- package/clients/platform/v0/rust/README.md +3 -0
- package/clients/platform/v0/rust/platform_example.rs +20 -0
- package/clients/platform/v0/web/PlatformPromiseClient.js +57 -0
- package/clients/platform/v0/web/platform_pb.d.ts +2739 -300
- package/clients/platform/v0/web/platform_pb.js +20140 -1970
- package/clients/platform/v0/web/platform_pb_service.d.ts +209 -0
- package/clients/platform/v0/web/platform_pb_service.js +440 -0
- package/package.json +16 -4
- package/protos/platform/v0/platform.proto +555 -51
- package/scripts/build.sh +91 -115
- package/scripts/patch-protobuf-js.sh +10 -9
- package/src/core/proto/org.dash.platform.dapi.v0.rs +666 -0
- package/src/lib.rs +15 -0
- package/src/platform/proto/org.dash.platform.dapi.v0.rs +2030 -0
- package/test/unit/clients/platform/v0/nodejs/PlatformPromiseClient.spec.js +32 -0
- package/clients/core/v0/rust/core.rs +0 -4956
- package/clients/core/v0/rust/core_grpc.rs +0 -223
- package/clients/core/v0/rust/mod.rs +0 -3
- package/clients/platform/v0/rust/mod.rs +0 -3
- package/clients/platform/v0/rust/platform.rs +0 -3555
- package/clients/platform/v0/rust/platform_grpc.rs +0 -223
package/Cargo.toml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "dapi-grpc"
|
|
3
|
+
description = "GRPC client for Dash Platform"
|
|
4
|
+
version = "0.25.0"
|
|
5
|
+
authors = [
|
|
6
|
+
"Samuel Westrich <sam@dash.org>",
|
|
7
|
+
"Igor Markin <igor.markin@dash.org>",
|
|
8
|
+
"Łukasz Klimek <lukasz.klimek@dash.org>",
|
|
9
|
+
"Anton Suprunchuk <anton.suprunchuk@dash.org>",
|
|
10
|
+
"Ivan Shumkov <shumkov@dash.org>",
|
|
11
|
+
]
|
|
12
|
+
edition = "2021"
|
|
13
|
+
rust-version = "1.73"
|
|
14
|
+
license = "MIT"
|
|
15
|
+
|
|
16
|
+
[dependencies]
|
|
17
|
+
prost = { version = "0.11.9" }
|
|
18
|
+
prost-types = { version = "0.11.9" }
|
|
19
|
+
tonic = { version = "0.9.2", features = [
|
|
20
|
+
"codegen",
|
|
21
|
+
"prost",
|
|
22
|
+
], default-features = false }
|
|
23
|
+
|
|
24
|
+
[build-dependencies]
|
|
25
|
+
tonic-build = { version = "0.9.2" }
|
|
26
|
+
|
|
27
|
+
[features]
|
|
28
|
+
default = ["core", "platform", "client"]
|
|
29
|
+
core = ["core_v0"]
|
|
30
|
+
platform = ["platform_v0"]
|
|
31
|
+
client = ["tonic/channel", "tonic/tls", "tonic/tls-roots", "platform"]
|
|
32
|
+
|
|
33
|
+
core_v0 = []
|
|
34
|
+
platform_v0 = []
|
|
35
|
+
|
|
36
|
+
[lib]
|
|
37
|
+
|
|
38
|
+
[[example]]
|
|
39
|
+
name = "core_example"
|
|
40
|
+
path = "clients/core/v0/rust/core_example.rs"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
[[example]]
|
|
44
|
+
name = "platform_example"
|
|
45
|
+
path = "clients/platform/v0/rust/platform_example.rs"
|
package/build.rs
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
use std::{
|
|
2
|
+
collections::HashMap,
|
|
3
|
+
fs::{create_dir_all, remove_dir_all},
|
|
4
|
+
path::PathBuf,
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
fn main() {
|
|
8
|
+
generate().expect("failed to compile protobuf definitions");
|
|
9
|
+
|
|
10
|
+
println!("cargo:rerun-if-changed=./protos");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/// Generate Rust definitions from Protobuf definitions
|
|
14
|
+
pub fn generate() -> Result<(), std::io::Error> {
|
|
15
|
+
// Mapping between protobuf files => output directory
|
|
16
|
+
let mut input = HashMap::<PathBuf, PathBuf>::new();
|
|
17
|
+
input.insert(
|
|
18
|
+
PathBuf::from("protos/core/v0/core.proto"),
|
|
19
|
+
PathBuf::from("src/core/proto"),
|
|
20
|
+
);
|
|
21
|
+
input.insert(
|
|
22
|
+
PathBuf::from("protos/platform/v0/platform.proto"),
|
|
23
|
+
PathBuf::from("src/platform/proto"),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
let proto_includes = vec![abs_path(&PathBuf::from("protos"))];
|
|
27
|
+
|
|
28
|
+
for (proto, dest) in input {
|
|
29
|
+
let proto = abs_path(&proto);
|
|
30
|
+
let dest = abs_path(&dest);
|
|
31
|
+
// Remove old compiled files; ignore errors
|
|
32
|
+
if dest.exists() {
|
|
33
|
+
remove_dir_all(&dest)?;
|
|
34
|
+
}
|
|
35
|
+
create_dir_all(&dest)?;
|
|
36
|
+
|
|
37
|
+
generate1(&[proto], &proto_includes, &dest)?;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Ok(())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// Run single generation process.
|
|
44
|
+
///
|
|
45
|
+
/// All paths must be absolute
|
|
46
|
+
fn generate1(
|
|
47
|
+
files: &[PathBuf],
|
|
48
|
+
proto_includes: &[PathBuf],
|
|
49
|
+
out_dir: &PathBuf,
|
|
50
|
+
) -> Result<(), std::io::Error> {
|
|
51
|
+
let pb = tonic_build::configure()
|
|
52
|
+
.build_server(false)
|
|
53
|
+
.out_dir(out_dir)
|
|
54
|
+
.protoc_arg("--experimental_allow_proto3_optional");
|
|
55
|
+
#[cfg(feature = "client")]
|
|
56
|
+
let pb = pb.build_client(true).build_transport(true);
|
|
57
|
+
#[cfg(not(feature = "client"))]
|
|
58
|
+
let pb = pb.build_client(false).build_transport(false);
|
|
59
|
+
|
|
60
|
+
pb.compile(files, proto_includes)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fn abs_path(path: &PathBuf) -> PathBuf {
|
|
64
|
+
if path.is_absolute() {
|
|
65
|
+
return path.to_owned();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(path)
|
|
69
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
use dapi_grpc::core::v0 as core;
|
|
2
|
+
use prost::Message;
|
|
3
|
+
|
|
4
|
+
fn main() {
|
|
5
|
+
let request = core::GetBlockRequest {
|
|
6
|
+
block: Some(core::get_block_request::Block::Height(123)),
|
|
7
|
+
};
|
|
8
|
+
let mut buffer = Vec::<u8>::new();
|
|
9
|
+
request.encode(&mut buffer).expect("failed to encode data");
|
|
10
|
+
|
|
11
|
+
let decoded = core::GetBlockRequest::decode(buffer.as_ref()).expect("failed to decode data");
|
|
12
|
+
|
|
13
|
+
assert_eq!(request, decoded);
|
|
14
|
+
}
|
|
@@ -30,6 +30,8 @@ const {
|
|
|
30
30
|
GetIdentityResponse: PBJSGetIdentityResponse,
|
|
31
31
|
GetDataContractRequest: PBJSGetDataContractRequest,
|
|
32
32
|
GetDataContractResponse: PBJSGetDataContractResponse,
|
|
33
|
+
GetDataContractHistoryRequest: PBJSGetDataContractHistoryRequest,
|
|
34
|
+
GetDataContractHistoryResponse: PBJSGetDataContractHistoryResponse,
|
|
33
35
|
GetDocumentsRequest: PBJSGetDocumentsRequest,
|
|
34
36
|
GetDocumentsResponse: PBJSGetDocumentsResponse,
|
|
35
37
|
GetIdentitiesByPublicKeyHashesRequest: PBJSGetIdentitiesByPublicKeyHashesRequest,
|
|
@@ -38,6 +40,14 @@ const {
|
|
|
38
40
|
WaitForStateTransitionResultResponse: PBJSWaitForStateTransitionResultResponse,
|
|
39
41
|
GetConsensusParamsRequest: PBJSGetConsensusParamsRequest,
|
|
40
42
|
GetConsensusParamsResponse: PBJSGetConsensusParamsResponse,
|
|
43
|
+
GetEpochsInfoRequest: PBJSGetEpochsInfoRequest,
|
|
44
|
+
GetEpochsInfoResponse: PBJSGetEpochsInfoResponse,
|
|
45
|
+
GetProtocolVersionUpgradeVoteStatusRequest:
|
|
46
|
+
PBJSGetProtocolVersionUpgradeVoteStatusRequest,
|
|
47
|
+
GetProtocolVersionUpgradeVoteStatusResponse:
|
|
48
|
+
PBJSGetProtocolVersionUpgradeVoteStatusResponse,
|
|
49
|
+
GetProtocolVersionUpgradeStateRequest: PBJSGetProtocolVersionUpgradeStateRequest,
|
|
50
|
+
GetProtocolVersionUpgradeStateResponse: PBJSGetProtocolVersionUpgradeStateResponse,
|
|
41
51
|
},
|
|
42
52
|
},
|
|
43
53
|
},
|
|
@@ -49,10 +59,14 @@ const {
|
|
|
49
59
|
BroadcastStateTransitionResponse: ProtocBroadcastStateTransitionResponse,
|
|
50
60
|
GetIdentityResponse: ProtocGetIdentityResponse,
|
|
51
61
|
GetDataContractResponse: ProtocGetDataContractResponse,
|
|
62
|
+
GetDataContractHistoryResponse: ProtocGetDataContractHistoryResponse,
|
|
52
63
|
GetDocumentsResponse: ProtocGetDocumentsResponse,
|
|
53
64
|
GetIdentitiesByPublicKeyHashesResponse: ProtocGetIdentitiesByPublicKeyHashesResponse,
|
|
54
65
|
WaitForStateTransitionResultResponse: ProtocWaitForStateTransitionResultResponse,
|
|
55
66
|
GetConsensusParamsResponse: ProtocGetConsensusParamsResponse,
|
|
67
|
+
GetEpochsInfoResponse: ProtocGetEpochsInfoResponse,
|
|
68
|
+
GetProtocolVersionUpgradeVoteStatusResponse: ProtocGetProtocolVersionUpgradeVoteStatusResponse,
|
|
69
|
+
GetProtocolVersionUpgradeStateResponse: ProtocGetProtocolVersionUpgradeStateResponse,
|
|
56
70
|
} = require('./platform_protoc');
|
|
57
71
|
|
|
58
72
|
const getPlatformDefinition = require('../../../../lib/getPlatformDefinition');
|
|
@@ -91,6 +105,10 @@ class PlatformPromiseClient {
|
|
|
91
105
|
this.client.getDataContract.bind(this.client),
|
|
92
106
|
);
|
|
93
107
|
|
|
108
|
+
this.client.getDataContractHistory = promisify(
|
|
109
|
+
this.client.getDataContractHistory.bind(this.client),
|
|
110
|
+
);
|
|
111
|
+
|
|
94
112
|
this.client.getDocuments = promisify(
|
|
95
113
|
this.client.getDocuments.bind(this.client),
|
|
96
114
|
);
|
|
@@ -107,6 +125,18 @@ class PlatformPromiseClient {
|
|
|
107
125
|
this.client.getConsensusParams.bind(this.client),
|
|
108
126
|
);
|
|
109
127
|
|
|
128
|
+
this.client.getEpochsInfo = promisify(
|
|
129
|
+
this.client.getEpochsInfo.bind(this.client),
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
this.client.getProtocolVersionUpgradeVoteStatus = promisify(
|
|
133
|
+
this.client.getProtocolVersionUpgradeVoteStatus.bind(this.client),
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
this.client.getProtocolVersionUpgradeState = promisify(
|
|
137
|
+
this.client.getProtocolVersionUpgradeState.bind(this.client),
|
|
138
|
+
);
|
|
139
|
+
|
|
110
140
|
this.protocolVersion = undefined;
|
|
111
141
|
}
|
|
112
142
|
|
|
@@ -204,6 +234,38 @@ class PlatformPromiseClient {
|
|
|
204
234
|
);
|
|
205
235
|
}
|
|
206
236
|
|
|
237
|
+
/**
|
|
238
|
+
*
|
|
239
|
+
* @param {!GetDataContractHistoryRequest} getDataContractHistoryRequest
|
|
240
|
+
* @param {?Object<string, string>} metadata
|
|
241
|
+
* @param {CallOptions} [options={}]
|
|
242
|
+
* @returns {Promise<!GetDataContractResponse>}
|
|
243
|
+
*/
|
|
244
|
+
getDataContractHistory(getDataContractHistoryRequest, metadata = {}, options = {}) {
|
|
245
|
+
if (!isObject(metadata)) {
|
|
246
|
+
throw new Error('metadata must be an object');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return this.client.getDataContractHistory(
|
|
250
|
+
getDataContractHistoryRequest,
|
|
251
|
+
convertObjectToMetadata(metadata),
|
|
252
|
+
{
|
|
253
|
+
interceptors: [
|
|
254
|
+
jsonToProtobufInterceptorFactory(
|
|
255
|
+
jsonToProtobufFactory(
|
|
256
|
+
ProtocGetDataContractHistoryResponse,
|
|
257
|
+
PBJSGetDataContractHistoryResponse,
|
|
258
|
+
),
|
|
259
|
+
protobufToJsonFactory(
|
|
260
|
+
PBJSGetDataContractHistoryRequest,
|
|
261
|
+
),
|
|
262
|
+
),
|
|
263
|
+
],
|
|
264
|
+
...options,
|
|
265
|
+
},
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
207
269
|
/**
|
|
208
270
|
*
|
|
209
271
|
* @param {!GetDocumentsRequest} getDocumentsRequest
|
|
@@ -335,6 +397,107 @@ class PlatformPromiseClient {
|
|
|
335
397
|
);
|
|
336
398
|
}
|
|
337
399
|
|
|
400
|
+
/**
|
|
401
|
+
* @param {!GetEpochsInfoRequest} getEpochsInfoRequest
|
|
402
|
+
* @param {?Object<string, string>} metadata
|
|
403
|
+
* @param {CallOptions} [options={}]
|
|
404
|
+
* @return {Promise<!GetEpochsInfoResponse>}
|
|
405
|
+
*/
|
|
406
|
+
getEpochsInfo(getEpochsInfoRequest, metadata = {}, options = {}) {
|
|
407
|
+
if (!isObject(metadata)) {
|
|
408
|
+
throw new Error('metadata must be an object');
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return this.client.getEpochsInfo(
|
|
412
|
+
getEpochsInfoRequest,
|
|
413
|
+
convertObjectToMetadata(metadata),
|
|
414
|
+
{
|
|
415
|
+
interceptors: [
|
|
416
|
+
jsonToProtobufInterceptorFactory(
|
|
417
|
+
jsonToProtobufFactory(
|
|
418
|
+
ProtocGetEpochsInfoResponse,
|
|
419
|
+
PBJSGetEpochsInfoResponse,
|
|
420
|
+
),
|
|
421
|
+
protobufToJsonFactory(
|
|
422
|
+
PBJSGetEpochsInfoRequest,
|
|
423
|
+
),
|
|
424
|
+
),
|
|
425
|
+
],
|
|
426
|
+
...options,
|
|
427
|
+
},
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* @param {!GetProtocolVersionUpgradeVoteStatusRequest} getProtocolVersionUpgradeVoteStatusRequest
|
|
433
|
+
* @param {?Object<string, string>} metadata
|
|
434
|
+
* @param {CallOptions} [options={}]
|
|
435
|
+
* @return {Promise<!GetProtocolVersionUpgradeVoteStatusResponse>}
|
|
436
|
+
*/
|
|
437
|
+
getProtocolVersionUpgradeVoteStatus(
|
|
438
|
+
getProtocolVersionUpgradeVoteStatusRequest,
|
|
439
|
+
metadata = {},
|
|
440
|
+
options = {},
|
|
441
|
+
) {
|
|
442
|
+
if (!isObject(metadata)) {
|
|
443
|
+
throw new Error('metadata must be an object');
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return this.client.getProtocolVersionUpgradeVoteStatus(
|
|
447
|
+
getProtocolVersionUpgradeVoteStatusRequest,
|
|
448
|
+
convertObjectToMetadata(metadata),
|
|
449
|
+
{
|
|
450
|
+
interceptors: [
|
|
451
|
+
jsonToProtobufInterceptorFactory(
|
|
452
|
+
jsonToProtobufFactory(
|
|
453
|
+
ProtocGetProtocolVersionUpgradeVoteStatusResponse,
|
|
454
|
+
PBJSGetProtocolVersionUpgradeVoteStatusResponse,
|
|
455
|
+
),
|
|
456
|
+
protobufToJsonFactory(
|
|
457
|
+
PBJSGetProtocolVersionUpgradeVoteStatusRequest,
|
|
458
|
+
),
|
|
459
|
+
),
|
|
460
|
+
],
|
|
461
|
+
...options,
|
|
462
|
+
},
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* @param {!GetProtocolVersionUpgradeStateRequest} getProtocolVersionUpgradeStateRequest
|
|
468
|
+
* @param {?Object<string, string>} metadata
|
|
469
|
+
* @param {CallOptions} [options={}]
|
|
470
|
+
* @return {Promise<!GetProtocolVersionUpgradeStateResponse>}
|
|
471
|
+
*/
|
|
472
|
+
getProtocolVersionUpgradeState(
|
|
473
|
+
getProtocolVersionUpgradeStateRequest,
|
|
474
|
+
metadata = {},
|
|
475
|
+
options = {},
|
|
476
|
+
) {
|
|
477
|
+
if (!isObject(metadata)) {
|
|
478
|
+
throw new Error('metadata must be an object');
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
return this.client.getProtocolVersionUpgradeState(
|
|
482
|
+
getProtocolVersionUpgradeStateRequest,
|
|
483
|
+
convertObjectToMetadata(metadata),
|
|
484
|
+
{
|
|
485
|
+
interceptors: [
|
|
486
|
+
jsonToProtobufInterceptorFactory(
|
|
487
|
+
jsonToProtobufFactory(
|
|
488
|
+
ProtocGetProtocolVersionUpgradeStateResponse,
|
|
489
|
+
PBJSGetProtocolVersionUpgradeStateResponse,
|
|
490
|
+
),
|
|
491
|
+
protobufToJsonFactory(
|
|
492
|
+
PBJSGetProtocolVersionUpgradeStateRequest,
|
|
493
|
+
),
|
|
494
|
+
),
|
|
495
|
+
],
|
|
496
|
+
...options,
|
|
497
|
+
},
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
|
|
338
501
|
/**
|
|
339
502
|
* @param {string} protocolVersion
|
|
340
503
|
*/
|