Skip to main content

TempoRpcClient

Struct TempoRpcClient 

Source
pub struct TempoRpcClient { /* private fields */ }
Expand description

Thin JSON-RPC client over reqwest. One instance = one RPC endpoint.

Implementations§

Source§

impl TempoRpcClient

Source

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.

Source

pub fn with_default_client(url: impl Into<String>) -> Self

Convenience: build with a fresh reqwest client. Tests use this.

Source

pub async fn chain_id(&self) -> Result<u64, RpcError>

eth_chainId → u64. Hex-prefixed-hex decode.

Source

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.

Source

pub async fn gas_price(&self) -> Result<u128, RpcError>

eth_gasPrice → u128. Wei.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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).

Source

pub async fn send_raw_transaction( &self, raw_tx: &[u8], ) -> Result<TxHash, RpcError>

eth_sendRawTransaction(0x<rlp>) → tx hash.

Source

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

Source§

fn clone(&self) -> TempoRpcClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TempoRpcClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more