Skip to content

Commit

Permalink
Add WASM support to lightwalletd-tonic feature flag (#1270)
Browse files Browse the repository at this point in the history
The transport-specific code is moved behind a new `lightwalletd-tonic-transport` feature flag.
  • Loading branch information
willemolding authored Mar 15, 2024
1 parent 50a4ce3 commit 1775f65
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ jobs:
run: cargo add --no-default-features --path ../crates/zcash_proofs
- name: Add zcash_client_backend as a dependency of the synthetic crate
working-directory: ./ci-build
run: cargo add --no-default-features --path ../crates/zcash_client_backend
run: cargo add --features lightwalletd-tonic --path ../crates/zcash_client_backend
- name: Copy pinned dependencies into synthetic crate
run: cp crates/Cargo.lock ci-build/
- name: Add target
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ rayon = "1.5"

# Protobuf and gRPC
prost = "0.12"
tonic = "0.10"
tonic-build = "0.10"
tonic = { version = "0.10", default-features = false }
tonic-build = { version = "0.10", default-features = false }

# Secret management
secrecy = "0.8"
Expand Down
7 changes: 5 additions & 2 deletions zcash_client_backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ tracing.workspace = true
# - Protobuf interfaces and gRPC bindings
hex.workspace = true
prost.workspace = true
tonic = { workspace = true, optional = true }
tonic = { workspace = true, optional = true, features = ["prost", "codegen"]}

# - Secret management
secrecy.workspace = true
Expand Down Expand Up @@ -102,7 +102,7 @@ crossbeam-channel.workspace = true
rayon.workspace = true

[build-dependencies]
tonic-build.workspace = true
tonic-build = { workspace = true, features = ["prost"]}
which = "4"

[dev-dependencies]
Expand All @@ -123,6 +123,9 @@ time = ">=0.3.22, <0.3.24" # time 0.3.24 has MSRV 1.67
## Enables the `tonic` gRPC client bindings for connecting to a `lightwalletd` server.
lightwalletd-tonic = ["dep:tonic"]

## Enables the `transport` feature of `tonic` producing a fully-featured client and server implementation
lightwalletd-tonic-transport = ["lightwalletd-tonic", "tonic?/transport"]

## Enables receiving transparent funds and shielding them.
transparent-inputs = [
"dep:hdwallet",
Expand Down
13 changes: 13 additions & 0 deletions zcash_client_backend/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,3 +779,16 @@ impl proposal::Proposal {
}
}
}

#[cfg(feature = "lightwalletd-tonic-transport")]
impl service::compact_tx_streamer_client::CompactTxStreamerClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<tonic::codegen::StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
11 changes: 0 additions & 11 deletions zcash_client_backend/src/proto/service.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1775f65

Please sign in to comment.