Struct Client

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

Client defines functions to communicate with ParallelChain RPC endpoints. Users are required to provide corresponding request specified in pchain_types in order to get a correct response.

Implementations§

Source§

impl Client

Source

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

new creates a new instance of a pchain_client given a network provider.

§Arguments
  • rpc_base_url - base URL of Parallelchain RPC endpoints
Source

pub fn set_provider(&mut self, rpc_base_url: &str)

set_provider assigns new network provider for Client.

§Arguments
  • rpc_base_url - base URL of Parallelchain RPC endpoints
Source

pub async fn is_provider_up(&self) -> (String, bool)

is_provider_up returns the current network provider for Client, and check if the current provider is up.

§Return

Tuple of (provider url, boolean). Returns true if server is up, otherwise returns false.

Source

pub async fn submit_transaction( &self, signed_tx: &Transaction, ) -> Result<SubmitTransactionResponse, String>

submit_transaction sends request to submit a transaction.

Source

pub async fn state( &self, request: &StateRequest, ) -> Result<StateResponse, String>

state sends request to query account data from world state.

Source

pub async fn view(&self, request: &ViewRequest) -> Result<ViewResponse, String>

view sends request to execute a contract view call.

Source

pub async fn validator_sets( &self, request: &ValidatorSetsRequest, ) -> Result<ValidatorSetsResponse, String>

validator_sets sends request to query previous / current / next validator and delegator sets

Source

pub async fn pools( &self, request: &PoolsRequest, ) -> Result<PoolsResponse, String>

pools sends request to query pools with a set of operator address, with or without stakes of each pool

Source

pub async fn stakes( &self, request: &StakesRequest, ) -> Result<StakesResponse, String>

stakes sends request to query stakes with a set of (operator address, owner address)

Source

pub async fn deposits( &self, request: &DepositsRequest, ) -> Result<DepositsResponse, String>

deposits sends request to query deposits with a set of (operator address, owner address)

Source

pub async fn block( &self, request: &BlockRequest, ) -> Result<BlockResponse, String>

block sends request to get full block data starting from specified block hash.

Source

pub async fn block_header( &self, request: &BlockHeaderRequest, ) -> Result<BlockHeaderResponse, String>

block_header sends request to get block header starting from specified block hash.

Source

pub async fn block_height_by_hash( &self, request: &BlockHeightByHashRequest, ) -> Result<BlockHeightByHashResponse, String>

block_height_by_hash sends request to get block height by specified block hash.

Source

pub async fn block_hash_by_height( &self, request: &BlockHashByHeightRequest, ) -> Result<BlockHashByHeightResponse, String>

block_hash_by_height sends request to get block hash by specified block height.

Source

pub async fn highest_committed_block( &self, ) -> Result<HighestCommittedBlockResponse, String>

highest_committed_block sends request to get the latest block on ParallelChain.

Source

pub async fn transaction( &self, request: &TransactionRequest, ) -> Result<TransactionResponse, String>

transaction sends request to get transaction by specified tx hash.

Source

pub async fn receipt( &self, request: &ReceiptRequest, ) -> Result<ReceiptResponse, String>

receipt sends request to get receipt with transaction, block hash and position by specified tx hash.

Source

pub async fn transaction_position( &self, request: &TransactionPositionRequest, ) -> Result<TransactionPositionResponse, String>

transaction_position sends request to get transaction position in block by specified tx hash.

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

Source§

type Output = T

Should always be Self
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,