From 4e25add079dd1703f53705314c3e77297b5f57b7 Mon Sep 17 00:00:00 2001 From: Wiktor Starczewski Date: Mon, 29 Jun 2026 18:39:03 +0200 Subject: [PATCH 1/2] feat(rpc): expose the configured node endpoint URL Add `NodeRpcClient::endpoint` (default `None`, overridden by `GrpcClient` to return its configured URL) and `Client::rpc_endpoint`, so consumers can read the endpoint a client is talking to without a network round-trip or threading the URL alongside the client. Motivating consumer: the web-sdk needs the React layer to derive the RPC endpoint from the WebClient itself rather than a separately-stored copy. --- CHANGELOG.md | 4 ++++ crates/rust-client/src/lib.rs | 6 ++++++ crates/rust-client/src/rpc/mod.rs | 8 ++++++++ crates/rust-client/src/rpc/tonic_client/mod.rs | 11 +++++++++++ 4 files changed, 29 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c10ba34f9..8f0eae62f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +* [FEATURE][rust] Added `NodeRpcClient::endpoint` and `Client::rpc_endpoint`, exposing the configured node endpoint URL without a network round-trip. ([#PR](https://github.com/0xMiden/miden-client/pull/PR)) + ### Fixes * [FIX][rust] RPC endpoint parsing now rejects endpoint strings that omit either the protocol or host. ([#2266](https://github.com/0xMiden/miden-client/pull/2266)) diff --git a/crates/rust-client/src/lib.rs b/crates/rust-client/src/lib.rs index 1609206ab2..aae6a3f190 100644 --- a/crates/rust-client/src/lib.rs +++ b/crates/rust-client/src/lib.rs @@ -498,6 +498,12 @@ impl Client { self.store.identifier() } + /// Returns the node endpoint URL the client's RPC transport is configured to talk to, if the + /// transport tracks one. + pub fn rpc_endpoint(&self) -> Option<&str> { + self.rpc_api.endpoint() + } + /// Registers a [`transaction::TransactionObserver`]. Per-observer failures are logged. pub fn with_transaction_observer( &mut self, diff --git a/crates/rust-client/src/rpc/mod.rs b/crates/rust-client/src/rpc/mod.rs index 8070c7a0b4..35a6d727d7 100644 --- a/crates/rust-client/src/rpc/mod.rs +++ b/crates/rust-client/src/rpc/mod.rs @@ -135,6 +135,14 @@ pub trait NodeRpcClient: Send + Sync { /// Returns the genesis commitment if it has been set, without fetching from the node. fn has_genesis_commitment(&self) -> Option; + /// Returns the node endpoint URL this client is configured to talk to, if it tracks one. + /// + /// Defaults to `None` for implementations that don't track an endpoint (e.g. test mocks); real + /// transports return their configured URL. + fn endpoint(&self) -> Option<&str> { + None + } + /// Given a Proven Transaction, send it to the node for it to be included in a future block /// using the `/SubmitProvenTransaction` RPC endpoint. /// diff --git a/crates/rust-client/src/rpc/tonic_client/mod.rs b/crates/rust-client/src/rpc/tonic_client/mod.rs index 905b1922b7..08d90b427d 100644 --- a/crates/rust-client/src/rpc/tonic_client/mod.rs +++ b/crates/rust-client/src/rpc/tonic_client/mod.rs @@ -372,6 +372,10 @@ impl NodeRpcClient for GrpcClient { *self.genesis_commitment.read() } + fn endpoint(&self) -> Option<&str> { + Some(&self.endpoint) + } + async fn set_genesis_commitment(&self, commitment: Word) -> Result<(), RpcError> { // Check if already set before doing anything else if self.genesis_commitment.read().is_some() { @@ -1177,6 +1181,13 @@ mod tests { tokio::task::spawn(async move { dyn_trait_send_fut(client).await }); } + #[test] + fn endpoint_returns_the_configured_url() { + let endpoint = Endpoint::devnet(); + let client = GrpcClient::new(&endpoint, 10000); + assert_eq!(client.endpoint(), Some(endpoint.to_string().as_str())); + } + #[tokio::test] async fn set_genesis_commitment_sets_the_commitment_when_its_not_already_set() { let endpoint = &Endpoint::devnet(); From db29e0aa1ee83f9246d0fe00e2042a8479a0d83c Mon Sep 17 00:00:00 2001 From: Wiktor Starczewski Date: Mon, 29 Jun 2026 18:39:35 +0200 Subject: [PATCH 2/2] docs(changelog): reference PR #2291 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f0eae62f6..002dc9996d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features -* [FEATURE][rust] Added `NodeRpcClient::endpoint` and `Client::rpc_endpoint`, exposing the configured node endpoint URL without a network round-trip. ([#PR](https://github.com/0xMiden/miden-client/pull/PR)) +* [FEATURE][rust] Added `NodeRpcClient::endpoint` and `Client::rpc_endpoint`, exposing the configured node endpoint URL without a network round-trip. ([#2291](https://github.com/0xMiden/miden-client/pull/2291)) ### Fixes