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, S> Client<H, S>
impl<H: Http, S> Client<H, S>
Sourcepub fn new(http: H, network: Network, clock: Clock, signer: S) -> Self
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.
Sourcepub fn acting_for(self, vault: Address) -> Self
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.
pub const fn network(&self) -> Network
pub const fn http(&self) -> &H
pub const fn signer(&self) -> &S
Sourcepub fn spent(&self) -> Spent
pub fn spent(&self) -> Spent
What went out over the last minute, and whether the gate is closed.
Sourcepub fn next_nonce(&self) -> u64
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.
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.
Sourcepub async fn send(&self, action: &impl L1Action) -> Result<Accepted, SendError>
pub async fn send(&self, action: &impl L1Action) -> Result<Accepted, SendError>
Signs an L1 action at the next nonce and sends it once.
Sourcepub async fn send_at(
&self,
action: &impl L1Action,
nonce: u64,
) -> Result<Accepted, SendError>
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.
Sourcepub async fn send_user(
&self,
action: &impl UserAction,
) -> Result<Accepted, SendError>
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.