pub struct Client { /* private fields */ }Expand description
A connection to one Worgl server, which may host many mints.
Every call is a single request with no retry. Transfers and burns are
idempotent, so resending one after an Error::is_transient failure is
safe; a Purse does that itself. Cloning is cheap and
shares the connection pool.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(base_url: &str) -> Result<Self, Error>
pub fn new(base_url: &str) -> Result<Self, Error>
A client for the server at base_url, such as
https://mint.example.com. Requests time out after 30 seconds.
Sourcepub fn with_http(http: Client, base_url: &str) -> Result<Self, Error>
pub fn with_http(http: Client, base_url: &str) -> Result<Self, Error>
A client that sends its requests through http, for custom timeouts,
proxies or certificates.
Sourcepub async fn info_and_time(
&self,
mint: &PublicKey,
) -> Result<(Info, u64), Error>
pub async fn info_and_time( &self, mint: &PublicKey, ) -> Result<(Info, u64), Error>
info, with the time the server answered: Unix seconds
by its clock, from the answer’s Date header, or by this machine’s
if the answer has no Date it can read.
Sourcepub async fn view_and_time(
&self,
mint: &PublicKey,
) -> Result<(MintView, u64), Error>
pub async fn view_and_time( &self, mint: &PublicKey, ) -> Result<(MintView, u64), Error>
view, with the time the server answered, as
info_and_time reads it. Plan the transfers
due before the mint’s next rotation from it, as in
Holder::refresh: the mint rotates by
its server’s clock, and planning by this machine’s, if it runs slow
by more than the margin, can put
them past the rotation.
Sourcepub async fn keys(&self, mint: &PublicKey) -> Result<KeySet, Error>
pub async fn keys(&self, mint: &PublicKey) -> Result<KeySet, Error>
GET /v1/mints/{mint}/keys: the keys that sign the mint’s live
generations, each certified by the issuer key. Fails with
Error::Keys if the set is another issuer’s.
Sourcepub async fn verify(&self, note: &Note) -> Result<Verified, Error>
pub async fn verify(&self, note: &Note) -> Result<Verified, Error>
POST /v1/verify: what the note’s mint says about it.
Sourcepub async fn transfer(
&self,
request: &TransferRequest,
) -> Result<Vec<Note>, Error>
pub async fn transfer( &self, request: &TransferRequest, ) -> Result<Vec<Note>, Error>
POST /v1/transfer: the new notes, in the order of the outputs.
Sourcepub async fn burn(&self, request: &BurnRequest) -> Result<u128, Error>
pub async fn burn(&self, request: &BurnRequest) -> Result<u128, Error>
POST /v1/burn: the value destroyed.
Sourcepub async fn mint(
&self,
mint: &PublicKey,
request: &MintRequest,
) -> Result<Note, Error>
pub async fn mint( &self, mint: &PublicKey, request: &MintRequest, ) -> Result<Note, Error>
POST /v1/mints/{mint}/mint: a new note, for a request signed by one
of the mint’s authorities.
Sourcepub async fn faucet(&self) -> Result<FaucetInfo, Error>
pub async fn faucet(&self) -> Result<FaucetInfo, Error>
GET /v1/faucet, from a playground faucet: its mint and limits. The
faucet is worgl-faucet, at this client’s URL, which may be its
mint’s server with the faucet behind the same proxy.
Sourcepub async fn ask_faucet(&self, holder: &PublicKey) -> Result<Note, Error>
pub async fn ask_faucet(&self, holder: &PublicKey) -> Result<Note, Error>
POST /v1/faucet: a note of the faucet’s mint, bound to holder.
Past the faucet’s limits it answers 429 with the code
rate_limited or exhausted.
Sourcepub async fn rotate(
&self,
mint: &PublicKey,
token: &str,
) -> Result<RotationReport, Error>
pub async fn rotate( &self, mint: &PublicKey, token: &str, ) -> Result<RotationReport, Error>
POST /v1/mints/{mint}/rotate, with the mint’s admin token.