Struct BaseClient

Source
pub struct BaseClient {
    pub auth_client: QueryClient<Channel>,
    pub bank_client: QueryClient<Channel>,
    pub gevulot_client: QueryClient<Channel>,
    pub gov_client: QueryClient<Channel>,
    pub tendermint_client: ServiceClient<Channel>,
    pub tx_client: ServiceClient<Channel>,
    pub address: Option<String>,
    pub pub_key: Option<PublicKey>,
    pub account_sequence: Option<u64>,
    /* private fields */
}
Expand description

BaseClient is a struct that provides various functionalities to interact with the blockchain.

Fields§

§auth_client: QueryClient<Channel>§bank_client: QueryClient<Channel>§gevulot_client: QueryClient<Channel>§gov_client: QueryClient<Channel>§tendermint_client: ServiceClient<Channel>§tx_client: ServiceClient<Channel>§address: Option<String>§pub_key: Option<PublicKey>§account_sequence: Option<u64>

Implementations§

Source§

impl BaseClient

Source

pub async fn new( endpoint: &str, gas_price: f64, gas_multiplier: f64, ) -> Result<Self>

Creates a new instance of BaseClient.

§Arguments
  • endpoint - The endpoint URL to connect to.
  • gas_price - The gas price to be used.
  • gas_multiplier - The gas multiplier to be used.
§Returns

A Result containing the new instance of BaseClient or an error.

Source

pub fn set_signer(&mut self, signer: GevulotSigner)

Sets the signer for the client.

§Arguments
  • signer - The GevulotSigner to be set.
Source

pub fn set_mnemonic( &mut self, mnemonic: &str, password: Option<&str>, ) -> Result<()>

Sets the mnemonic for the client and initializes the signer.

§Arguments
  • mnemonic - The mnemonic string to be used.
§Returns

A Result indicating success or failure.

Source

pub async fn get_account(&mut self, address: &str) -> Result<BaseAccount>

Retrieves the account information for a given address.

§Arguments
  • address - The address of the account to be retrieved.
§Returns

A Result containing the BaseAccount or an error.

Source

pub async fn get_account_balance(&mut self, address: &str) -> Result<Coin>

Retrieves the account balance for a given address.

§Arguments
  • address - The address of the account, which balance to get.
§Returns

A Result containing the balance or an error.

Source

pub async fn token_transfer( &mut self, to_address: &str, amount: u128, ) -> Result<()>

Transfer tokens to a given address.

§Arguments
  • to_address - The address of the receiving account.
  • amount - Amount of coins to transfer.
§Returns

An empty result or an error.

Source

pub async fn simulate_msg<M: Message + Name>( &mut self, msg: M, memo: &str, account_number: u64, sequence: u64, ) -> Result<SimulateResponse>

Simulates a message to estimate gas usage.

§Arguments
  • msg - The message to be simulated.
  • memo - The memo to be included in the transaction.
  • account_number - The account number.
  • sequence - The sequence number.
§Returns

A Result containing the SimulateResponse or an error.

Source

pub async fn send_msg<M: Message + Name + Clone>( &mut self, msg: M, memo: &str, ) -> Result<String>

Sends a message and returns the transaction hash.

§Arguments
  • msg - The message to be sent.
  • memo - The memo to be included in the transaction.
§Returns

A Result containing the transaction hash or an error.

Source

pub async fn send_msg_sync<M: Message + Name + Clone, R: Message + Default>( &mut self, msg: M, memo: &str, ) -> Result<R>

Sends a message and waits for the transaction to be included in a block.

§Arguments
  • msg - The message to be sent.
  • memo - The memo to be included in the transaction.
§Returns

A Result containing the response message or an error.

Source

pub async fn current_block(&mut self) -> Result<Block>

Retrieves the latest block from the blockchain.

§Returns

A Result containing the latest Block or an error.

Source

pub async fn get_block_by_height(&mut self, height: i64) -> Result<Block>

Retrieves a block by its height.

§Arguments
  • height - The height of the block to be retrieved.
§Returns

A Result containing the Block or an error.

Source

pub async fn wait_for_block(&mut self, height: i64) -> Result<Block>

Waits for a block to be produced at a specific height.

§Arguments
  • height - The height of the block to wait for.
§Returns

A Result containing the Block or an error.

Source

pub async fn get_tx(&mut self, tx_hash: &str) -> Result<Tx>

Retrieves a transaction by its hash.

§Arguments
  • tx_hash - The hash of the transaction to be retrieved.
§Returns

A Result containing the Tx or an error.

Source

pub async fn get_tx_response(&mut self, tx_hash: &str) -> Result<TxResponse>

Retrieves the transaction respotransport::httpnse by its hash.

§Arguments
  • tx_hash - The hash of the transaction to be retrieved.
§Returns

A Result containing the TxResponse or an error.

Source

pub async fn wait_for_tx( &mut self, tx_hash: &str, timeout: Option<Duration>, ) -> Result<Tx>

Waits for a transaction to be included in a block.

§Arguments
  • tx_hash - The hash of the transaction to wait for.
  • timeout - An optional timeout duration.
§Returns

A Result containing the Tx or an error.

Trait Implementations§

Source§

impl Debug for BaseClient

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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