Skip to main content

Client

Struct Client 

Source
pub struct Client<H, S = ()> { /* private fields */ }
Expand description

Reads for any module (nitro::sys::arb_os_version() through Client::read) and, with a Signer, transactions. S is () for a client that only reads.

Client::parent is the same client on HyperEVM, Elysium’s parent, for the bridge’s calls there: deposits, retryable tickets and claims.

Implementations§

Source§

impl<H: Http> Client<H>

Source

pub fn reader(http: H, network: Network) -> Self

A client that reads and never signs, through Kinetiq’s public node.

Source§

impl<H: Http, S> Client<H, S>

Source

pub fn new(http: H, network: Network, signer: S) -> Self

One network through Kinetiq’s public node (Network::rpc_url), signing with signer.

Source

pub fn at(http: H, url: impl Into<String>, network: Network, signer: S) -> Self

One network through another node: Conduit’s, or a provider’s with its key in the URL.

Source

pub fn parent(http: H, network: Network, signer: S) -> Self

The network’s parent, HyperEVM, through its own node (df_hyperliquid_core::Network::evm_rpc_url), signing for its chain (Network::parent_chain_id): for the bridge’s calls there. Sends and Ethereum’s reads work as on Elysium, and receipts and transactions read; Nitro’s own (blocks, Client::estimate) are Elysium’s, so read HyperEVM’s blocks through Client::rpc.

Source

pub const fn network(&self) -> Network

Source

pub const fn chain(&self) -> u64

The chain this client signs for: Elysium’s, or HyperEVM’s for Client::parent.

Source

pub const fn rpc(&self) -> &Rpc<H>

The node, for any of df-hyperliquid-core’s eth_ reads.

Source

pub const fn http(&self) -> &H

Source

pub const fn signer(&self) -> &S

Source

pub const fn nonces(&self) -> &Nonces

The nonce kept between sends.

Source

pub async fn run<T>(&self, query: Query<T>) -> Result<T, RpcError>

Any query, sent once.

Source

pub async fn read<T>(&self, read: &Read<T>) -> Result<T, ReadError>

A typed read at the latest block.

Source

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

Source

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

Source

pub async fn balance(&self, owner: Address) -> Result<U256, RpcError>

An address’s HYPE in wei, at the latest block.

Source

pub async fn hype(&self, owner: Address) -> Result<Dec, RpcError>

An address’s HYPE, exactly.

Source

pub async fn nonce(&self, owner: Address) -> Result<u64, RpcError>

The next nonce owner may use, counting what the sequencer has taken.

Source

pub async fn code(&self, at: Address) -> Result<Vec<u8>, RpcError>

Empty for an account that is not a contract; 0xfe for a precompile.

Source

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

What one unit of gas costs now, in wei: the base fee. There is no tip to add.

Source

pub async fn estimate( &self, from: Option<Address>, call: &Call, ) -> Result<Estimate, ReadError>

The gas call takes when from sends it, split into Elysium’s execution and HyperEVM’s data, at the base fees it would pay (crate::nitro::node::gas_estimate_components).

Source

pub async fn receipt(&self, hash: B256) -> Result<Option<Receipt>, RpcError>

Source

pub async fn transaction( &self, hash: B256, ) -> Result<Option<Transaction>, RpcError>

Source

pub async fn block( &self, block: BlockTag, full: bool, ) -> Result<Option<Block>, RpcError>

Source

pub async fn block_by_hash( &self, hash: B256, full: bool, ) -> Result<Option<Block>, RpcError>

Source

pub async fn block_receipts( &self, block: BlockTag, ) -> Result<Option<Vec<Receipt>>, RpcError>

Source

pub async fn logs(&self, filter: &LogFilter) -> Result<Vec<Log>, RpcError>

The logs filter matches. A filter that names no address and no topic is sent in windows of Network::log_span blocks, its tags read as the head; any other is sent whole.

Source§

impl<H: Http, S: Signer> Client<H, S>

Sending needs the sign feature: each signature is recovered and must match the signer before anything is sent, since a remote signer can sign as another address.

Source

pub fn address(&self) -> Address

The address this client sends from.

Source

pub async fn prepare(&self, call: Call) -> Result<Eip1559, SendError>

The transaction that makes call: this client’s chain, the next nonce, the node’s gas estimate with with_headroom, and fees over the current base fee (gas::fees).

Source

pub async fn sign(&self, tx: &Eip1559) -> Result<Vec<u8>, SignError>

The bytes a node is sent: signed by the signer, the signature recovered and checked.

Source

pub async fn send(&self, call: Call) -> Result<B256, SendError>

Prepares, signs and sends call once; the hash the node took it under.

Source

pub async fn send_prepared(&self, tx: &Eip1559) -> Result<B256, SendError>

Signs and sends a prepared transaction once.

Source

pub async fn send_sync( &self, call: Call, timeout_ms: Option<u64>, ) -> Result<Receipt, SendError>

Prepares, signs and sends call once with eth_sendRawTransactionSync: the answer is its receipt, a reverted one included. The node gives up after timeout_ms (its own default when None); then the transaction may still land.

Source

pub async fn send_prepared_sync( &self, tx: &Eip1559, timeout_ms: Option<u64>, ) -> Result<Receipt, SendError>

Signs and sends a prepared transaction once, answering with its receipt.

Trait Implementations§

Source§

impl<H: Http, S> Debug for Client<H, S>

Its network, chain and node; never its signer or its wire.

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<H, S = ()> !Freeze for Client<H, S>

§

impl<H, S> RefUnwindSafe for Client<H, S>

§

impl<H, S> Send for Client<H, S>
where Rpc<H>: Send, S: Send,

§

impl<H, S> Sync for Client<H, S>
where Rpc<H>: Sync, S: Sync,

§

impl<H, S> Unpin for Client<H, S>
where Rpc<H>: Unpin, S: Unpin,

§

impl<H, S> UnsafeUnpin for Client<H, S>
where Rpc<H>: UnsafeUnpin, S: UnsafeUnpin,

§

impl<H, S> UnwindSafe for Client<H, S>
where Rpc<H>: UnwindSafe, S: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
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