@dashevo/dapi-grpc 4.1.1 → 4.2.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.
package/Cargo.toml CHANGED
@@ -26,12 +26,30 @@ tenderdash-proto = []
26
26
  # Client support.
27
27
  client = ["platform"]
28
28
 
29
+ # Networked tonic client: `connect()` on generated clients, TLS roots.
30
+ # Deliberately NOT in the default set: cargo features are not target-scoped,
31
+ # so a default-on transport would force tonic's transport stack onto wasm32
32
+ # consumers riding defaults, where it does not build. Without this feature
33
+ # the crate provides message types and transport-generic client stubs only.
34
+ # Tonic's codegen graph still includes tokio-stream and a minimal Tokio
35
+ # slice, but its hyper/rustls transport stack is not enabled. Native
36
+ # networked consumers enable this explicitly (rs-dapi-client does so through
37
+ # its non-wasm dependency); the wasm codegen path never emits `connect()`.
38
+ transport = [
39
+ "tonic/channel",
40
+ "tonic/transport",
41
+ "tonic/tls-native-roots",
42
+ "tonic/tls-webpki-roots",
43
+ "tonic/tls-ring",
44
+ ]
45
+
29
46
  # Build tonic server code. Includes all client features and adds server-specific dependencies.
30
47
  server = [
31
48
  "platform",
32
49
  "tenderdash-proto/server",
33
50
  "client",
34
51
  "drive",
52
+ "transport",
35
53
  "tonic/router",
36
54
  ]
37
55
 
@@ -55,14 +73,7 @@ tonic = { version = "0.14.2", features = ["codegen"], default-features = false }
55
73
  getrandom = { version = "0.2", features = ["js"] }
56
74
 
57
75
  [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
58
- tonic = { version = "0.14.2", features = [
59
- "codegen",
60
- "channel",
61
- "transport",
62
- "tls-native-roots",
63
- "tls-webpki-roots",
64
- "tls-ring",
65
- ], default-features = false }
76
+ tonic = { version = "0.14.2", features = ["codegen"], default-features = false }
66
77
 
67
78
  [build-dependencies]
68
79
  tonic-prost-build = { version = "0.14.2" }
package/build.rs CHANGED
@@ -10,6 +10,7 @@ use tonic_prost_build::Builder;
10
10
  const SERDE_WITH_BYTES: &str = r#"#[cfg_attr(feature = "serde", serde(with = "serde_bytes"))]"#;
11
11
  const SERDE_WITH_BASE64: &str =
12
12
  r#"#[cfg_attr(feature = "serde", serde(with = "crate::deserialization::vec_base64string"))]"#;
13
+ const SERDE_DEFAULT: &str = r#"#[cfg_attr(feature = "serde", serde(default))]"#;
13
14
  const SERDE_WITH_STRING: &str =
14
15
  r#"#[cfg_attr(feature = "serde", serde(with = "crate::deserialization::from_to_string"))]"#;
15
16
 
@@ -69,6 +70,7 @@ fn generate_code(typ: ImplType, output_base: &Path) {
69
70
 
70
71
  println!("cargo:rerun-if-changed=./protos");
71
72
  println!("cargo:rerun-if-env-changed=CARGO_FEATURE_SERDE");
73
+ println!("cargo:rerun-if-env-changed=CARGO_FEATURE_TRANSPORT");
72
74
  println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ARCH");
73
75
  println!("cargo:rerun-if-env-changed=DAPI_GRPC_OUT_DIR");
74
76
  }
@@ -334,6 +336,16 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
334
336
  .field_attribute("id", SERDE_WITH_BYTES)
335
337
  .field_attribute("identity_id", SERDE_WITH_BYTES)
336
338
  .field_attribute("ids", SERDE_WITH_BASE64)
339
+ // Wire-format compat for mock vectors captured before the chained
340
+ // surface existed: the field deserializes to its default when
341
+ // absent (same pattern DocumentQuery's own serde defaults follow
342
+ // for pre-SQL-surface fixtures).
343
+ .field_attribute("GetDocumentsRequestV1.chained", SERDE_DEFAULT)
344
+ .field_attribute("GetDocumentsRequestV1.sub_queries", SERDE_DEFAULT)
345
+ // Same compat rule for the typed IN_TIME_RANGE operand: mock
346
+ // vectors captured while the operand still rode `value` carry no
347
+ // `time_range` key.
348
+ .field_attribute("GetDocumentsRequest.WhereClause.time_range", SERDE_DEFAULT)
337
349
  .field_attribute("ResponseMetadata.height", SERDE_WITH_STRING)
338
350
  .field_attribute("ResponseMetadata.time_ms", SERDE_WITH_STRING)
339
351
  .field_attribute("start_at_ms", SERDE_WITH_STRING)
@@ -416,15 +428,23 @@ enum ImplType {
416
428
  impl ImplType {
417
429
  // Configure the builder based on the implementation type.
418
430
  pub fn configure(&self, builder: Builder) -> Builder {
431
+ // The `transport` cargo feature controls whether generated clients get
432
+ // the `connect()` convenience impls over tonic's own channel. Without
433
+ // it, clients are still generated but stay generic over the caller's
434
+ // transport. Never enabled for wasm32, where tonic transport does not
435
+ // build. Note: cfg!(target_arch) in a build script reflects the HOST,
436
+ // so the target must be read from CARGO_CFG_TARGET_ARCH.
437
+ let transport = std::env::var("CARGO_FEATURE_TRANSPORT").is_ok()
438
+ && std::env::var("CARGO_CFG_TARGET_ARCH").map(|arch| arch != "wasm32") == Ok(true);
419
439
  match self {
420
440
  Self::Server => builder
421
441
  .build_client(true)
422
442
  .build_server(true)
423
- .build_transport(true),
443
+ .build_transport(transport),
424
444
  Self::Client => builder
425
445
  .build_client(true)
426
446
  .build_server(false)
427
- .build_transport(true),
447
+ .build_transport(transport),
428
448
  Self::Wasm => builder
429
449
  .build_client(true)
430
450
  .build_server(false)