Skip to content

Commit 4a7f099

Browse files
committed
feat: Generated all proto definitions and cleaned the experimental codebase
Signed-off-by: gsstoykov <[email protected]>
1 parent 227e884 commit 4a7f099

File tree

6 files changed

+202
-424
lines changed

6 files changed

+202
-424
lines changed

Cargo.lock

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hedera-proto-wasm/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "hedera-proto-wasm"
33
version = "0.1.0"
44
edition = "2021"
5-
description = "Minimal Hedera protobuf definitions for WASM transaction serialization"
5+
description = "Complete Hedera protobuf definitions for WASM compiled with prost-build"
66

77
[lib]
88
crate-type = ["cdylib", "rlib"]
@@ -17,6 +17,11 @@ js-sys = "0.3"
1717
version = "0.3"
1818
features = ["console"]
1919

20+
[build-dependencies]
21+
anyhow = "1.0.99"
22+
prost-build = "0.13.5"
23+
walkdir = "2.5.0"
24+
2025
[features]
2126
default = ["wasm"]
2227
wasm = []

hedera-proto-wasm/build.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Build script for hedera-proto-wasm
2+
// This compiles ALL Hedera protobuf definitions using prost-build for WASM compatibility
3+
4+
use anyhow::Result;
5+
use std::path::Path;
6+
use walkdir::WalkDir;
7+
8+
fn main() -> Result<()> {
9+
println!("cargo:warning=Building COMPLETE Hedera protobufs for WASM using prost-build");
10+
11+
let proto_root = "../protobufs/services/hapi/hedera-protobuf-java-api/src/main/proto";
12+
13+
if !Path::new(proto_root).exists() {
14+
anyhow::bail!("Proto root directory not found: {}. Make sure git submodules are initialized.", proto_root);
15+
}
16+
17+
// Find all .proto files recursively
18+
let mut proto_files = Vec::new();
19+
for entry in WalkDir::new(proto_root).into_iter().filter_map(|e| e.ok()) {
20+
if entry.path().extension().and_then(|s| s.to_str()) == Some("proto") {
21+
proto_files.push(entry.path().to_string_lossy().to_string());
22+
}
23+
}
24+
25+
if proto_files.is_empty() {
26+
anyhow::bail!("No .proto files found in {}. Check your git submodules.", proto_root);
27+
}
28+
29+
println!("cargo:warning=Found {} proto files", proto_files.len());
30+
31+
// Brief summary of found files
32+
if proto_files.len() > 5 {
33+
println!("cargo:warning=Including {} proto files (showing first 5):", proto_files.len());
34+
for (i, file) in proto_files.iter().take(5).enumerate() {
35+
println!("cargo:warning= {}: {}", i + 1, file.split('/').last().unwrap_or(file));
36+
}
37+
} else {
38+
for file in &proto_files {
39+
println!("cargo:warning=Including: {}", file.split('/').last().unwrap_or(file));
40+
}
41+
}
42+
43+
// Configure prost-build
44+
let mut config = prost_build::Config::new();
45+
46+
// Set output file
47+
config.include_file("hedera_protos.rs");
48+
49+
// Configure prost for clean protobuf generation
50+
51+
// Compile all proto files
52+
config.compile_protos(&proto_files, &[proto_root])?;
53+
54+
println!("cargo:warning=Successfully compiled {} protobuf files for WASM", proto_files.len());
55+
56+
// Tell cargo to rerun if proto files change
57+
println!("cargo:rerun-if-changed={}", proto_root);
58+
59+
Ok(())
60+
}

0 commit comments

Comments
 (0)