feat(web,react): derive the RPC endpoint from the client#212
Open
WiktorStarczewski wants to merge 4 commits into
Open
feat(web,react): derive the RPC endpoint from the client#212WiktorStarczewski wants to merge 4 commits into
WiktorStarczewski wants to merge 4 commits into
Conversation
Add `WebClient.endpoint()` and `RpcClient.endpoint()` (backed by miden-client's new `NodeRpcClient::endpoint` / `Client::rpc_endpoint`), returning the node URL the client is configured to talk to. `WebClient` caches it at creation so it can be read synchronously without locking the async `inner` cell. The React SDK now derives the RPC endpoint from the live client instead of a separately-stored `config.rpcUrl` copy: `useAssetMetadata` and `accountBech32` read `client.endpoint()`. `client` exists only once the provider has finished initializing, so a configured (e.g. devnet) app no longer reads an unset URL and falls back to testnet during the init window; addresses are tagged for the right network, falling back to the raw id when the network can't be confirmed. Supersedes the gating approach in #189 (addresses the reviewer's "derive the RPC from the client" feedback). Requires miden-client 0xMiden/rust-sdk#2291.
|
🔗 Linked client PR:
This run is testing against the linked PR's head. The published artifact will use the canonical Local-dev parity: |
…point Provide a client (with endpoint()) in the useAssetMetadata test and the shared createMockWebClient mock so hooks that derive the RPC endpoint from the live client fetch as expected; add a test that no RPC fires before a client exists.
WiktorStarczewski
marked this pull request as ready for review
June 29, 2026 17:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #188. Addresses the review feedback on #189 (supersedes its
isReady-gating approach with the "derive the RPC from the client" direction @igamigo suggested).Client PR: 0xMiden/rust-sdk#2291
Problem
On a non-testnet (e.g. devnet) configuration, page-side React code could hit the testnet default during the window before
MidenProviderwrites the resolved endpoint into the store:useAssetMetadatafired RPC at testnet andaccountBech32tagged addresses for testnet, even though the worker/sync correctly used devnet. The underlying issue (per the review on #189) is that the RPC config is kept in the store as a separate copy of what the client already knows.Change
Derive the RPC endpoint from the client itself — single source of truth:
NodeRpcClient::endpoint()(defaultNone, overridden byGrpcClient) +Client::rpc_endpoint().WebClient.endpoint()andRpcClient.endpoint().WebClientcaches the endpoint at creation (from the RPC client) so it's readable synchronously, without locking the asyncinnercell.useAssetMetadataandaccountBech32readclient.endpoint()instead ofconfig.rpcUrl.clientexists only after init completes, so there's no pre-config window; addresses fall back to the raw id when the network can't be confirmed.Verification
useAssetMetadata/accountBech32and the shared mock updated to the client-endpoint sourcing; added a test that no RPC fires before a client exists.next(the linked-client gate stays pending until then). CI auto-injects the client patch from theClient PR:marker above.accountBech32test run in CI against the freshly-built WASM (not built locally).