pub struct FaucetClient { /* private fields */ }Implementations§
Source§impl FaucetClient
impl FaucetClient
Sourcepub fn new(faucet_url: &str) -> Self
pub fn new(faucet_url: &str) -> Self
Construct a new FaucetClient with the given faucet service URL. This
FaucetClient expects that the service provides two endpoints:
/v1/gas and /v1/status. As such, do not provide the request
endpoint, just the top level service endpoint.
- /v1/gas is used to request gas
- /v1/status/taks-uuid is used to check the status of the request
Sourcepub fn new_testnet() -> Self
pub fn new_testnet() -> Self
Create a new Faucet client connected to the testnet faucet.
Sourcepub fn new_devnet() -> Self
pub fn new_devnet() -> Self
Create a new Faucet client connected to the devnet faucet.
Sourcepub fn new_localnet() -> Self
pub fn new_localnet() -> Self
Create a new Faucet client connected to a localnet faucet.
Sourcepub async fn request(&self, address: Address) -> Result<Option<String>>
pub async fn request(&self, address: Address) -> Result<Option<String>>
Request gas from the faucet. Note that this will return the UUID of the
request and not wait until the token is received. Use
request_and_wait to wait for the token.
Sourcepub async fn request_and_wait(
&self,
address: Address,
) -> Result<Option<FaucetReceipt>>
pub async fn request_and_wait( &self, address: Address, ) -> Result<Option<FaucetReceipt>>
Request gas from the faucet and wait until the request is completed and
token is transferred. Returns FaucetReceipt if the request is
successful, which contains the list of tokens transferred, and the
transaction digest.
Note that the faucet is heavily rate-limited, so calling repeatedly the faucet would likely result in a 429 code or 502 code.
Sourcepub async fn request_status(
&self,
id: String,
) -> Result<Option<BatchSendStatus>>
pub async fn request_status( &self, id: String, ) -> Result<Option<BatchSendStatus>>
Check the faucet request status.
Possible statuses are defined in: BatchSendStatusType
Auto Trait Implementations§
impl Freeze for FaucetClient
impl !RefUnwindSafe for FaucetClient
impl Send for FaucetClient
impl Sync for FaucetClient
impl Unpin for FaucetClient
impl !UnwindSafe for FaucetClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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