Skip to main content

Client

Struct Client 

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

Reads for any module (markets::perps::meta(&client)) and, with a Signer, actions. S is () for a client that only reads.

Implementations§

Source§

impl<H: Http> Client<H>

Source

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

A client that reads and never signs.

Source§

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

Source

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

One network, through http, signing with signer: the account’s own key or wallet, or an agent for the actions an agent may sign.

Source

pub fn acting_for(self, vault: Address) -> Self

Acts for a subaccount or vault: its L1 actions name it as vaultAddress, and are still signed by this client’s signer.

Source

pub const fn network(&self) -> Network

Source

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

Source

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

Source

pub fn spent(&self) -> Spent

What went out over the last minute, and whether the gate is closed.

Source

pub fn next_nonce(&self) -> u64

The next nonce: the clock, or one past the last if the clock has not moved. Each client keeps its own, so give every signer one client.

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 posted, since a wallet can sign as a different account than expected.

Source

pub async fn send(&self, action: &impl L1Action) -> Result<Accepted, SendError>

Signs an L1 action at the next nonce and sends it once.

Source

pub async fn send_at( &self, action: &impl L1Action, nonce: u64, ) -> Result<Accepted, SendError>

Signs an L1 action at nonce and sends it once. The nonce must be new for this signer; Client::send takes care of that.

Source

pub async fn send_user( &self, action: &impl UserAction, ) -> Result<Accepted, SendError>

Signs a user-signed action under this network’s chain and sends it once. Its nonce is the one it was built with (Client::next_nonce gives one). Only the account’s own key may sign these.

Trait Implementations§

Source§

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

Source§

fn post( &self, path: &str, body: String, ) -> impl Future<Output = Result<String, TransportError>>

Auto Trait Implementations§

§

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

§

impl<H, S> RefUnwindSafe for Client<H, S>
where Api<H>: RefUnwindSafe, S: RefUnwindSafe,

§

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

§

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

§

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

§

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

§

impl<H, S> UnwindSafe for Client<H, S>
where Api<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