@dashevo/dapi-grpc 0.25.0-dev.14 → 0.25.0-dev.16

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 CHANGED
@@ -15,14 +15,19 @@ license = "MIT"
15
15
  [dependencies]
16
16
  prost = { version = "0.11.9" }
17
17
  prost-types = { version = "0.11.9" }
18
+ tonic = { version = "0.9.2", features = [
19
+ "codegen",
20
+ "prost",
21
+ ], default-features = false }
18
22
 
19
23
  [build-dependencies]
20
- prost-build = { version = "0.11" }
24
+ tonic-build = { version = "0.9.2" }
21
25
 
22
26
  [features]
23
- default = ["core", "platform"]
27
+ default = ["core", "platform", "client"]
24
28
  core = ["core_v0"]
25
29
  platform = ["platform_v0"]
30
+ client = ["tonic/channel", "tonic/tls", "tonic/tls-roots", "platform"]
26
31
 
27
32
  core_v0 = []
28
33
  platform_v0 = []
package/build.rs CHANGED
@@ -8,8 +8,6 @@ fn main() {
8
8
  generate().expect("failed to compile protobuf definitions");
9
9
 
10
10
  println!("cargo:rerun-if-changed=./protos");
11
- println!("cargo:rerun-if-changed=./src/core/proto");
12
- println!("cargo:rerun-if-changed=./src/platform/proto");
13
11
  }
14
12
 
15
13
  /// Generate Rust definitions from Protobuf definitions
@@ -50,10 +48,16 @@ fn generate1(
50
48
  proto_includes: &[PathBuf],
51
49
  out_dir: &PathBuf,
52
50
  ) -> Result<(), std::io::Error> {
53
- let mut pb = prost_build::Config::new();
54
- pb.out_dir(out_dir);
55
- pb.format(true);
56
- pb.compile_protos(files, proto_includes)
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)
57
61
  }
58
62
 
59
63
  fn abs_path(path: &PathBuf) -> PathBuf {
@@ -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,
@@ -49,6 +51,7 @@ const {
49
51
  BroadcastStateTransitionResponse: ProtocBroadcastStateTransitionResponse,
50
52
  GetIdentityResponse: ProtocGetIdentityResponse,
51
53
  GetDataContractResponse: ProtocGetDataContractResponse,
54
+ GetDataContractHistoryResponse: ProtocGetDataContractHistoryResponse,
52
55
  GetDocumentsResponse: ProtocGetDocumentsResponse,
53
56
  GetIdentitiesByPublicKeyHashesResponse: ProtocGetIdentitiesByPublicKeyHashesResponse,
54
57
  WaitForStateTransitionResultResponse: ProtocWaitForStateTransitionResultResponse,
@@ -91,6 +94,10 @@ class PlatformPromiseClient {
91
94
  this.client.getDataContract.bind(this.client),
92
95
  );
93
96
 
97
+ this.client.getDataContractHistory = promisify(
98
+ this.client.getDataContractHistory.bind(this.client),
99
+ );
100
+
94
101
  this.client.getDocuments = promisify(
95
102
  this.client.getDocuments.bind(this.client),
96
103
  );
@@ -204,6 +211,38 @@ class PlatformPromiseClient {
204
211
  );
205
212
  }
206
213
 
214
+ /**
215
+ *
216
+ * @param {!GetDataContractHistoryRequest} getDataContractHistoryRequest
217
+ * @param {?Object<string, string>} metadata
218
+ * @param {CallOptions} [options={}]
219
+ * @returns {Promise<!GetDataContractResponse>}
220
+ */
221
+ getDataContractHistory(getDataContractHistoryRequest, metadata = {}, options = {}) {
222
+ if (!isObject(metadata)) {
223
+ throw new Error('metadata must be an object');
224
+ }
225
+
226
+ return this.client.getDataContractHistory(
227
+ getDataContractHistoryRequest,
228
+ convertObjectToMetadata(metadata),
229
+ {
230
+ interceptors: [
231
+ jsonToProtobufInterceptorFactory(
232
+ jsonToProtobufFactory(
233
+ ProtocGetDataContractHistoryResponse,
234
+ PBJSGetDataContractHistoryResponse,
235
+ ),
236
+ protobufToJsonFactory(
237
+ PBJSGetDataContractHistoryRequest,
238
+ ),
239
+ ),
240
+ ],
241
+ ...options,
242
+ },
243
+ );
244
+ }
245
+
207
246
  /**
208
247
  *
209
248
  * @param {!GetDocumentsRequest} getDocumentsRequest