pub struct Client { /* private fields */ }
Expand description
Client that implements exponential retrying and caching of access key nonces.
Implementations§
Source§impl Client
impl Client
Sourcepub fn call<'a>(
&self,
signer: &'a dyn SignerExt,
contract_id: &AccountId,
function: &str,
) -> FunctionCallTransaction<'a>
pub fn call<'a>( &self, signer: &'a dyn SignerExt, contract_id: &AccountId, function: &str, ) -> FunctionCallTransaction<'a>
Start calling into a contract on a specific function. Returns a FunctionCallTransaction
object where we can use to add more parameters such as the arguments, deposit, and gas.
Sourcepub fn batch<'a>(
&self,
signer: &'a dyn SignerExt,
receiver_id: &AccountId,
) -> Transaction<'a>
pub fn batch<'a>( &self, signer: &'a dyn SignerExt, receiver_id: &AccountId, ) -> Transaction<'a>
Start a batch transaction. Returns a Transaction
object that we can
use to add Actions to the batched transaction. Call transact
to send
the batched transaction to the network.
Source§impl Client
impl Client
Sourcepub fn view(
&self,
contract_id: &AccountId,
function: &str,
) -> Query<'_, ViewFunction>
pub fn view( &self, contract_id: &AccountId, function: &str, ) -> Query<'_, ViewFunction>
Call into a contract’s view function. Returns a Query
which allows us
to specify further details like the arguments of the view call, or at what
point in the chain we want to view.
Sourcepub fn view_code(&self, contract_id: &AccountId) -> Query<'_, ViewCode>
pub fn view_code(&self, contract_id: &AccountId) -> Query<'_, ViewCode>
View the WASM code bytes of a contract on the network.
Sourcepub fn view_state(&self, contract_id: &AccountId) -> Query<'_, ViewState>
pub fn view_state(&self, contract_id: &AccountId) -> Query<'_, ViewState>
View the state of a account/contract on the network. This will return the internal state of the account in the form of a map of key-value pairs; where STATE contains info on a contract’s internal data.
Sourcepub fn view_block(&self) -> Query<'_, ViewBlock>
pub fn view_block(&self) -> Query<'_, ViewBlock>
View the block from the network. Supply additional parameters such as block_height
or block_hash
to get the block.
Sourcepub fn view_chunk(&self) -> QueryChunk<'_>
pub fn view_chunk(&self) -> QueryChunk<'_>
View the chunk from the network once awaited. Supply additional parameters such as
block_hash_and_shard
, block_height_and_shard
or chunk_hash
to get the
chunk at a specific reference point. If none of those are supplied, the default
reference point will be used, which will be the latest block_hash with a shard_id
of 0.
Sourcepub fn view_access_key(
&self,
id: &AccountId,
pk: &PublicKey,
) -> Query<'_, ViewAccessKey>
pub fn view_access_key( &self, id: &AccountId, pk: &PublicKey, ) -> Query<'_, ViewAccessKey>
Sourcepub fn view_access_keys(&self, id: &AccountId) -> Query<'_, ViewAccessKeyList>
pub fn view_access_keys(&self, id: &AccountId) -> Query<'_, ViewAccessKeyList>
Sourcepub fn view_account(&self, account_id: &AccountId) -> Query<'_, ViewAccount>
pub fn view_account(&self, account_id: &AccountId) -> Query<'_, ViewAccount>
View account details of a specific account on the network.
Source§impl Client
impl Client
Sourcepub fn from_client(client: JsonRpcClient) -> Self
pub fn from_client(client: JsonRpcClient) -> Self
Construct a Client
from an existing JsonRpcClient
.
Sourcepub fn inner(&self) -> &JsonRpcClient
pub fn inner(&self) -> &JsonRpcClient
Internal reference to the JsonRpcClient
that is utilized for all RPC calls.
Sourcepub fn inner_mut(&mut self) -> &mut JsonRpcClient
pub fn inner_mut(&mut self) -> &mut JsonRpcClient
Internal mutable reference to the JsonRpcClient
that is utilized for all RPC calls.
Sourcepub fn send_tx<'a>(
&self,
signer: &'a dyn SignerExt,
receiver_id: &AccountId,
actions: Vec<Action>,
) -> RetryableTransaction<'a>
pub fn send_tx<'a>( &self, signer: &'a dyn SignerExt, receiver_id: &AccountId, actions: Vec<Action>, ) -> RetryableTransaction<'a>
Send a series of Action
s as a SignedTransaction
to the network.
This gives us a transaction is that retryable. To retry, simply add in a .retry_*
method call to the end of the chain before an .await
gets invoked.
Sourcepub async fn send_tx_async(
&self,
signer: &dyn SignerExt,
receiver_id: &AccountId,
actions: Vec<Action>,
) -> Result<CryptoHash>
pub async fn send_tx_async( &self, signer: &dyn SignerExt, receiver_id: &AccountId, actions: Vec<Action>, ) -> Result<CryptoHash>
Send a series of Action
s as a SignedTransaction
to the network. This is an async
operation, where a hash is returned to reference the transaction in the future and check
its status.
Sourcepub async fn fetch_nonce(
&self,
account_id: &AccountId,
public_key: &PublicKey,
) -> Result<(Nonce, CryptoHash, BlockHeight)>
pub async fn fetch_nonce( &self, account_id: &AccountId, public_key: &PublicKey, ) -> Result<(Nonce, CryptoHash, BlockHeight)>
Fetches the nonce associated to the account id and public key, which essentially is the access key for the given account ID and public key. Utilize caching underneath to prevent querying for the same access key multiple times.
Sourcepub async fn access_key(
&self,
account_id: &AccountId,
public_key: &PublicKey,
) -> Result<(AccessKeyView, CryptoHash, BlockHeight)>
pub async fn access_key( &self, account_id: &AccountId, public_key: &PublicKey, ) -> Result<(AccessKeyView, CryptoHash, BlockHeight)>
Fetches the access key for the given account ID and public key.
pub async fn check_and_invalidate_cache( &self, cache_key: &CacheKey, result: &Result<RpcTransactionResponse, JsonRpcError<RpcTransactionError>>, )
pub async fn invalidate_cache(&self, cache_key: &CacheKey)
Sourcepub async fn status_tx_async(
&self,
sender_id: &AccountId,
tx_hash: CryptoHash,
wait_until: TxExecutionStatus,
) -> Result<FinalExecutionOutcomeView, Error>
pub async fn status_tx_async( &self, sender_id: &AccountId, tx_hash: CryptoHash, wait_until: TxExecutionStatus, ) -> Result<FinalExecutionOutcomeView, Error>
Fetches the status of a transaction given the transaction hash.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.