near_fetch

Struct Client

source
pub struct Client { /* private fields */ }
Expand description

Client that implements exponential retrying and caching of access key nonces.

Implementations§

source§

impl Client

source

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.

source

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

source

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.

source

pub fn view_code(&self, contract_id: &AccountId) -> Query<'_, ViewCode>

View the WASM code bytes of a contract on the network.

source

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.

source

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.

source

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.

source

pub fn view_access_key( &self, id: &AccountId, pk: &PublicKey, ) -> Query<'_, ViewAccessKey>

Views the AccessKey of the account specified by AccountId associated with the PublicKey

source

pub fn view_access_keys(&self, id: &AccountId) -> Query<'_, ViewAccessKeyList>

Views all the AccessKeys of the account specified by AccountId. This will return a list of AccessKeys along with the associated PublicKey.

source

pub fn view_account(&self, account_id: &AccountId) -> Query<'_, ViewAccount>

View account details of a specific account on the network.

source

pub fn gas_price(&self) -> Query<'_, GasPrice>

Fetches the latest gas price on the network.

source§

impl Client

source

pub fn new(rpc_addr: &str) -> Self

Construct a new Client with the given RPC address.

source

pub fn from_client(client: JsonRpcClient) -> Self

Construct a Client from an existing JsonRpcClient.

source

pub fn inner(&self) -> &JsonRpcClient

Internal reference to the JsonRpcClient that is utilized for all RPC calls.

source

pub fn inner_mut(&mut self) -> &mut JsonRpcClient

Internal mutable reference to the JsonRpcClient that is utilized for all RPC calls.

source

pub fn rpc_addr(&self) -> String

The RPC address the client is connected to.

source

pub fn send_tx<'a>( &self, signer: &'a dyn SignerExt, receiver_id: &AccountId, actions: Vec<Action>, ) -> RetryableTransaction<'a>

Send a series of Actions 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.

source

pub async fn send_tx_async( &self, signer: &dyn SignerExt, receiver_id: &AccountId, actions: Vec<Action>, ) -> Result<CryptoHash>

Send a series of Actions 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.

source

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.

source

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.

source

pub async fn check_and_invalidate_cache( &self, cache_key: &CacheKey, result: &Result<RpcTransactionResponse, JsonRpcError<RpcTransactionError>>, )

source

pub async fn invalidate_cache(&self, cache_key: &CacheKey)

source

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§

source§

impl Clone for Client

source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Client

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Client> for JsonRpcClient

source§

fn from(client: Client) -> Self

Converts to this type from the input type.

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> 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<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<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