pub struct GrpcClient { /* private fields */ }Expand description
gRPC client for the Celestia network
Under the hood, this struct wraps tonic and does type conversion
Implementations§
Source§impl GrpcClient
impl GrpcClient
Sourcepub fn builder() -> GrpcClientBuilder
pub fn builder() -> GrpcClientBuilder
Create a builder for GrpcClient connected to url
Sourcepub fn get_auth_params(&self) -> AsyncGrpcCall<AuthParams>
pub fn get_auth_params(&self) -> AsyncGrpcCall<AuthParams>
Get auth params
Sourcepub fn get_account(&self, account: &AccAddress) -> AsyncGrpcCall<Account>
pub fn get_account(&self, account: &AccAddress) -> AsyncGrpcCall<Account>
Get account
Sourcepub fn get_accounts(&self) -> AsyncGrpcCall<Vec<Account>>
pub fn get_accounts(&self) -> AsyncGrpcCall<Vec<Account>>
Get accounts
Sourcepub fn get_verified_balance(
&self,
address: &Address,
header: &ExtendedHeader,
) -> AsyncGrpcCall<Coin>
pub fn get_verified_balance( &self, address: &Address, header: &ExtendedHeader, ) -> AsyncGrpcCall<Coin>
Retrieves the verified Celestia coin balance for the address.
§Notes
This returns the verified balance which is the one that was reported by
the previous network block. In other words, if you transfer some coins,
you need to wait 1 more block in order to see the new balance. If you want
something more immediate then use GrpcClient::get_balance.
Sourcepub fn get_balance(
&self,
address: &Address,
denom: impl Into<String>,
) -> AsyncGrpcCall<Coin>
pub fn get_balance( &self, address: &Address, denom: impl Into<String>, ) -> AsyncGrpcCall<Coin>
Retrieves the Celestia coin balance for the given address.
Sourcepub fn get_all_balances(&self, address: &Address) -> AsyncGrpcCall<Vec<Coin>>
pub fn get_all_balances(&self, address: &Address) -> AsyncGrpcCall<Vec<Coin>>
Get balance of all coins
Sourcepub fn get_spendable_balances(
&self,
address: &Address,
) -> AsyncGrpcCall<Vec<Coin>>
pub fn get_spendable_balances( &self, address: &Address, ) -> AsyncGrpcCall<Vec<Coin>>
Get balance of all spendable coins
Sourcepub fn get_total_supply(&self) -> AsyncGrpcCall<Vec<Coin>>
pub fn get_total_supply(&self) -> AsyncGrpcCall<Vec<Coin>>
Get total supply
Sourcepub fn get_node_config(&self) -> AsyncGrpcCall<ConfigResponse>
pub fn get_node_config(&self) -> AsyncGrpcCall<ConfigResponse>
Get node configuration
Sourcepub fn get_latest_block(&self) -> AsyncGrpcCall<Block>
pub fn get_latest_block(&self) -> AsyncGrpcCall<Block>
Get latest block
Sourcepub fn get_block_by_height(&self, height: i64) -> AsyncGrpcCall<Block>
pub fn get_block_by_height(&self, height: i64) -> AsyncGrpcCall<Block>
Get block by height
Sourcepub fn abci_query(
&self,
data: impl AsRef<[u8]>,
path: impl Into<String>,
height: u64,
prove: bool,
) -> AsyncGrpcCall<AbciQueryResponse>
pub fn abci_query( &self, data: impl AsRef<[u8]>, path: impl Into<String>, height: u64, prove: bool, ) -> AsyncGrpcCall<AbciQueryResponse>
Issue a direct ABCI query to the application
Sourcepub fn broadcast_tx(
&self,
tx_bytes: Vec<u8>,
mode: BroadcastMode,
) -> AsyncGrpcCall<TxResponse>
pub fn broadcast_tx( &self, tx_bytes: Vec<u8>, mode: BroadcastMode, ) -> AsyncGrpcCall<TxResponse>
Broadcast prepared and serialised transaction
Sourcepub fn get_tx(&self, hash: Hash) -> AsyncGrpcCall<GetTxResponse>
pub fn get_tx(&self, hash: Hash) -> AsyncGrpcCall<GetTxResponse>
Get Tx
Sourcepub fn simulate(&self, tx_bytes: Vec<u8>) -> AsyncGrpcCall<GasInfo>
pub fn simulate(&self, tx_bytes: Vec<u8>) -> AsyncGrpcCall<GasInfo>
Broadcast prepared and serialised transaction
Sourcepub fn query_delegation(
&self,
delegator_address: &AccAddress,
validator_address: &ValAddress,
) -> AsyncGrpcCall<QueryDelegationResponse>
pub fn query_delegation( &self, delegator_address: &AccAddress, validator_address: &ValAddress, ) -> AsyncGrpcCall<QueryDelegationResponse>
Retrieves the delegation information between a delegator and a validator
Sourcepub fn query_unbonding(
&self,
delegator_address: &AccAddress,
validator_address: &ValAddress,
) -> AsyncGrpcCall<QueryUnbondingDelegationResponse>
pub fn query_unbonding( &self, delegator_address: &AccAddress, validator_address: &ValAddress, ) -> AsyncGrpcCall<QueryUnbondingDelegationResponse>
Retrieves the unbonding status between a delegator and a validator
Sourcepub fn query_redelegations(
&self,
delegator_address: &AccAddress,
src_validator_address: &ValAddress,
dest_validator_address: &ValAddress,
pagination: Option<PageRequest>,
) -> AsyncGrpcCall<QueryRedelegationsResponse>
pub fn query_redelegations( &self, delegator_address: &AccAddress, src_validator_address: &ValAddress, dest_validator_address: &ValAddress, pagination: Option<PageRequest>, ) -> AsyncGrpcCall<QueryRedelegationsResponse>
Retrieves the status of the redelegations between a delegator and a validator
Sourcepub fn get_blob_params(&self) -> AsyncGrpcCall<BlobParams>
pub fn get_blob_params(&self) -> AsyncGrpcCall<BlobParams>
Get blob params
Sourcepub fn tx_status(&self, hash: Hash) -> AsyncGrpcCall<TxStatusResponse>
pub fn tx_status(&self, hash: Hash) -> AsyncGrpcCall<TxStatusResponse>
Get status of the transaction
Sourcepub fn estimate_gas_price(&self, priority: TxPriority) -> AsyncGrpcCall<f64>
pub fn estimate_gas_price(&self, priority: TxPriority) -> AsyncGrpcCall<f64>
Estimate gas price for given transaction priority based on the gas prices of the transactions in the last five blocks.
If no transaction is found in the last five blocks, return the network min gas price.
Sourcepub fn estimate_gas_price_and_usage(
&self,
priority: TxPriority,
tx_bytes: Vec<u8>,
) -> AsyncGrpcCall<GasEstimate>
pub fn estimate_gas_price_and_usage( &self, priority: TxPriority, tx_bytes: Vec<u8>, ) -> AsyncGrpcCall<GasEstimate>
Estimate gas price for transaction with given priority and estimate gas usage for the provided serialised transaction.
The gas price estimation is based on the gas prices of the transactions in the last five blocks. If no transaction is found in the last five blocks, return the network min gas price.
The gas used is estimated using the state machine simulation.
Sourcepub fn submit_message<M>(
&self,
message: M,
cfg: TxConfig,
) -> AsyncGrpcCall<TxInfo>where
M: IntoProtobufAny + Send + 'static,
pub fn submit_message<M>(
&self,
message: M,
cfg: TxConfig,
) -> AsyncGrpcCall<TxInfo>where
M: IntoProtobufAny + Send + 'static,
Submit given message to celestia network.
§Example
use celestia_grpc::{GrpcClient, TxConfig};
use celestia_proto::cosmos::bank::v1beta1::MsgSend;
use celestia_types::state::{Address, Coin};
use tendermint::crypto::default::ecdsa_secp256k1::SigningKey;
let signing_key = SigningKey::random(&mut rand::rngs::OsRng);
let address = Address::from_account_verifying_key(*signing_key.verifying_key());
let grpc_url = "public-celestia-mocha4-consensus.numia.xyz:9090";
let tx_client = GrpcClient::builder()
.url(grpc_url)
.signer_keypair(signing_key)
.build()
.unwrap();
let msg = MsgSend {
from_address: address.to_string(),
to_address: "celestia169s50psyj2f4la9a2235329xz7rk6c53zhw9mm".to_string(),
amount: vec![Coin::utia(12345).into()],
};
tx_client
.submit_message(msg.clone(), TxConfig::default())
.await
.unwrap();Sourcepub fn submit_blobs(
&self,
blobs: &[Blob],
cfg: TxConfig,
) -> AsyncGrpcCall<TxInfo>
pub fn submit_blobs( &self, blobs: &[Blob], cfg: TxConfig, ) -> AsyncGrpcCall<TxInfo>
Submit given blobs to celestia network.
§Example
use celestia_grpc::{GrpcClient, TxConfig};
use celestia_types::state::{Address, Coin};
use celestia_types::{AppVersion, Blob};
use celestia_types::nmt::Namespace;
use tendermint::crypto::default::ecdsa_secp256k1::SigningKey;
let signing_key = SigningKey::random(&mut rand::rngs::OsRng);
let address = Address::from_account_verifying_key(*signing_key.verifying_key());
let grpc_url = "public-celestia-mocha4-consensus.numia.xyz:9090";
let tx_client = GrpcClient::builder()
.url(grpc_url)
.signer_keypair(signing_key)
.build()
.unwrap();
let ns = Namespace::new_v0(b"abcd").unwrap();
let blob = Blob::new(ns, "some data".into(), None, AppVersion::V3).unwrap();
tx_client
.submit_blobs(&[blob], TxConfig::default())
.await
.unwrap();Sourcepub fn app_version(&self) -> AsyncGrpcCall<AppVersion>
pub fn app_version(&self) -> AsyncGrpcCall<AppVersion>
Get client’s app version
Sourcepub fn chain_id(&self) -> AsyncGrpcCall<Id>
pub fn chain_id(&self) -> AsyncGrpcCall<Id>
Get client’s chain id
Sourcepub fn get_account_pubkey(&self) -> Option<VerifyingKey>
pub fn get_account_pubkey(&self) -> Option<VerifyingKey>
Get client’s account public key if the signer is set
Sourcepub fn get_account_address(&self) -> Option<AccAddress>
pub fn get_account_address(&self) -> Option<AccAddress>
Get client’s account address if the signer is set
Trait Implementations§
Source§impl Clone for GrpcClient
impl Clone for GrpcClient
Source§fn clone(&self) -> GrpcClient
fn clone(&self) -> GrpcClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for GrpcClient
impl !RefUnwindSafe for GrpcClient
impl Send for GrpcClient
impl Sync for GrpcClient
impl Unpin for GrpcClient
impl !UnwindSafe for GrpcClient
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§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> 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.