pub struct TempoRpcClient { /* private fields */ }Expand description
Thin JSON-RPC client over reqwest. One instance = one RPC endpoint.
Implementations§
Source§impl TempoRpcClient
impl TempoRpcClient
Sourcepub fn new(http: Client, url: impl Into<String>) -> Self
pub fn new(http: Client, url: impl Into<String>) -> Self
Build from an existing reqwest client (share connection pool with the TaskFast API client) plus the Tempo RPC URL.
Sourcepub fn with_default_client(url: impl Into<String>) -> Self
pub fn with_default_client(url: impl Into<String>) -> Self
Convenience: build with a fresh reqwest client. Tests use this.
Sourcepub async fn chain_id(&self) -> Result<u64, RpcError>
pub async fn chain_id(&self) -> Result<u64, RpcError>
eth_chainId → u64. Hex-prefixed-hex decode.
Sourcepub async fn pending_nonce(&self, addr: Address) -> Result<u64, RpcError>
pub async fn pending_nonce(&self, addr: Address) -> Result<u64, RpcError>
eth_getTransactionCount(address, "pending") → nonce.
Uses pending not latest so a second tx from the same signer doesn’t
collide on nonce if the first hasn’t been mined yet.
Sourcepub async fn estimate_gas(
&self,
from: Address,
to: Address,
data: &Bytes,
) -> Result<u64, RpcError>
pub async fn estimate_gas( &self, from: Address, to: Address, data: &Bytes, ) -> Result<u64, RpcError>
eth_estimateGas({from, to, data}) → gas units.
Called before every ERC-20 transfer so we size gas_limit to actual
chain state (Tempo testnet’s canonical USDC transfer lands around
307k; a different token or recipient-with-no-prior-balance can push
higher). A revert here means the tx would fail on-chain — callers
should surface the error rather than broadcast a doomed tx.
Sourcepub async fn eth_call(
&self,
to: Address,
data: &Bytes,
) -> Result<Vec<u8>, RpcError>
pub async fn eth_call( &self, to: Address, data: &Bytes, ) -> Result<Vec<u8>, RpcError>
eth_call({to, data}, "latest") → returned bytes.
Used for view-only calls (ERC-20 allowance / balanceOf, etc.) where
we need to read chain state without broadcasting a tx.
Sourcepub async fn eth_call_from(
&self,
from: Address,
to: Address,
data: &Bytes,
) -> Result<Vec<u8>, RpcError>
pub async fn eth_call_from( &self, from: Address, to: Address, data: &Bytes, ) -> Result<Vec<u8>, RpcError>
eth_call({from, to, data}, "latest") → returned bytes.
Like Self::eth_call but with an explicit sender. Tempo Zone TIP-20s
enforce balance privacy — balanceOf(X)/allowance(X, …) revert
Unauthorized unless msg.sender is a party — so self-reads must
impersonate the queried address (needs no signature; a no-op on L1).
Sourcepub async fn transaction_receipt_status(
&self,
tx_hash: TxHash,
) -> Result<Option<bool>, RpcError>
pub async fn transaction_receipt_status( &self, tx_hash: TxHash, ) -> Result<Option<bool>, RpcError>
eth_getTransactionReceipt(tx_hash) → Some(status_ok) once mined,
None if still pending.
Returns Ok(Some(true)) when the receipt’s status field is 0x1,
Ok(Some(false)) on 0x0 (reverted), Ok(None) if the receipt is
not yet available.
Sourcepub async fn wait_for_receipt(
&self,
tx_hash: TxHash,
timeout: Duration,
interval: Duration,
) -> Result<bool, RpcError>
pub async fn wait_for_receipt( &self, tx_hash: TxHash, timeout: Duration, interval: Duration, ) -> Result<bool, RpcError>
Poll eth_getTransactionReceipt until mined or timeout elapses.
Returns Ok(true) on status == 0x1, Ok(false) on revert, and
Err(RpcError::Decode) on timeout. Caller maps the timeout to the
command-level error variant (poster path wants CmdError::Server).
Sourcepub async fn send_raw_transaction(
&self,
raw_tx: &[u8],
) -> Result<TxHash, RpcError>
pub async fn send_raw_transaction( &self, raw_tx: &[u8], ) -> Result<TxHash, RpcError>
eth_sendRawTransaction(0x<rlp>) → tx hash.
Sourcepub async fn raw_call(
&self,
method: &str,
params: Value,
) -> Result<Value, RpcError>
pub async fn raw_call( &self, method: &str, params: Value, ) -> Result<Value, RpcError>
Raw JSON-RPC passthrough: method + params in, untyped result out.
Backs taskfast cast rpc (gh#101) — arbitrary methods (tempo_*
faucets, debug namespaces) that the typed wrappers above don’t cover.
Deliberately non-generic so the public surface stays a single stable
signature; typed decoding remains internal via the private call.
Trait Implementations§
Source§impl Clone for TempoRpcClient
impl Clone for TempoRpcClient
Auto Trait Implementations§
impl !RefUnwindSafe for TempoRpcClient
impl !UnwindSafe for TempoRpcClient
impl Forget for TempoRpcClient
impl Freeze for TempoRpcClient
impl Move for TempoRpcClient
impl Send for TempoRpcClient
impl Sync for TempoRpcClient
impl Unpin for TempoRpcClient
impl UnsafeUnpin for TempoRpcClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more