pub struct RpcApiClient { /* private fields */ }Expand description
JSON-RPC client for the Tooling Access endpoint.
Implementations§
Source§impl RpcApiClient
impl RpcApiClient
pub fn new(config: SdkConfig, rpc_config: Option<&RpcConfig>) -> Self
Sourcepub fn set_networks(&self, networks: HashMap<String, String>)
pub fn set_networks(&self, networks: HashMap<String, String>)
Seeds (or replaces) the per-network URL map used for multichain routing.
The map is network key -> full http_url, typically built from
admin.get_endpoint_urls(endpoint_id).multichain_urls. A host that
didn’t seed it via RpcConfig can install it here before calling with
a network.
Sourcepub fn current_token(&self) -> Option<CachedToken>
pub fn current_token(&self) -> Option<CachedToken>
Returns a snapshot of the current cached token, if any. Hosts use this to
persist the token between processes. Returns None if no token has been
minted (or seeded) yet.
Sourcepub fn clear_cached_token(&self)
pub fn clear_cached_token(&self)
Discards the in-memory cached token, forcing the next call to mint a fresh one. Use when the cached token is known stale beyond expiry — e.g. the endpoint was disabled and re-enabled out of band.
Sourcepub async fn call(
&self,
method: &str,
params: Option<Value>,
network: Option<String>,
endpoint_url: Option<String>,
) -> Result<Value, SdkError>
pub async fn call( &self, method: &str, params: Option<Value>, network: Option<String>, endpoint_url: Option<String>, ) -> Result<Value, SdkError>
Makes a JSON-RPC call. params defaults to an empty array when None;
it accepts both a positional array and a by-name object.
endpoint_url sends this call to a custom HTTP URL, bypassing the
Tooling Access endpoint and the session JWT entirely — the URL is treated
as self-authenticating and gets no Authorization header. It overrides the
client-wide RpcConfig::endpoint_url default for this call. Because a
custom URL is not multichain-routed, passing both endpoint_url and
network is a SdkError::Config error.
network selects which chain to route to on a multichain endpoint: it
is a key in the seeded network map (e.g. "solana-mainnet", "polygon").
When None, the call goes to the endpoint’s default network. When Some,
the map must be seeded (via RpcConfig or Self::set_networks) and
contain the key, otherwise a SdkError::Config is returned.
Returns the unwrapped result. A JSON-RPC error member is surfaced as
SdkError::Rpc.
Trait Implementations§
Source§impl Clone for RpcApiClient
impl Clone for RpcApiClient
Source§fn clone(&self) -> RpcApiClient
fn clone(&self) -> RpcApiClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more