pub struct StateApi { /* private fields */ }Expand description
State API for quering and submiting TXs to a consensus node.
Implementations§
Source§impl StateApi
impl StateApi
Sourcepub fn balance(&self) -> AsyncGrpcCall<u64>
pub fn balance(&self) -> AsyncGrpcCall<u64>
Retrieves the Celestia coin balance for the signer. To query balance without
adding signer to the client, see StateApi::balance_for_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 StateApi::balance_unverified.
Sourcepub fn balance_unverified(&self) -> AsyncGrpcCall<u64>
pub fn balance_unverified(&self) -> AsyncGrpcCall<u64>
Retrieves the Celestia coin balance for the signer. To query balance without
adding signer to the client, see StateApi::balance_for_address_unverified.
Sourcepub fn balance_for_address(&self, address: &AccAddress) -> AsyncGrpcCall<u64>
pub fn balance_for_address(&self, address: &AccAddress) -> AsyncGrpcCall<u64>
Retrieves the Celestia coin balance for the given 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 StateApi::balance_for_address_unverified.
This is the only method of StateApi that fallbacks to RPC endpoint
when gRPC endpoint wasn’t set.
Sourcepub fn balance_for_address_unverified(
&self,
address: &AccAddress,
) -> AsyncGrpcCall<u64>
pub fn balance_for_address_unverified( &self, address: &AccAddress, ) -> AsyncGrpcCall<u64>
Retrieves the Celestia coin balance for the given address.
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, it returns 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 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, it returns 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_proto::cosmos::bank::v1beta1::MsgSend;
use celestia_types::state::{Address, Coin};
let client = Client::builder()
.rpc_url("ws://localhost:26658")
.grpc_url("http://localhost:9090")
.private_key_hex("393fdb5def075819de55756b45c9e2c8531a8c78dd6eede483d3440e9457d839")
.build()
.await?;
let msg = MsgSend {
from_address: client.address()?.to_string(),
to_address: "celestia169s50psyj2f4la9a2235329xz7rk6c53zhw9mm".to_string(),
amount: vec![Coin::utia(12345).into()],
};
client
.state()
.submit_message(msg, TxConfig::default())
.await?;Sourcepub fn transfer(
&self,
to_address: &AccAddress,
amount: u64,
cfg: TxConfig,
) -> AsyncGrpcCall<TxInfo>
pub fn transfer( &self, to_address: &AccAddress, amount: u64, cfg: TxConfig, ) -> AsyncGrpcCall<TxInfo>
Sends the given amount of coins from signer’s wallet to the given account address.
Sourcepub fn submit_pay_for_blob(
&self,
blobs: &[Blob],
cfg: TxConfig,
) -> AsyncGrpcCall<TxInfo>
pub fn submit_pay_for_blob( &self, blobs: &[Blob], cfg: TxConfig, ) -> AsyncGrpcCall<TxInfo>
Builds, signs and submits a PayForBlob transaction.
§Note
This is the same as BlobApi::submit.
§Example
use celestia_types::nmt::Namespace;
use celestia_types::state::{Address, Coin};
use celestia_types::Blob;
let client = Client::builder()
.rpc_url("ws://localhost:26658")
.grpc_url("http://localhost:9090")
.private_key_hex("393fdb5def075819de55756b45c9e2c8531a8c78dd6eede483d3440e9457d839")
.build()
.await?;
let ns = Namespace::new_v0(b"abcd").unwrap();
let blob = Blob::new(ns, "some data".into(), None).unwrap();
client
.state()
.submit_pay_for_blob(&[blob], TxConfig::default())
.await?;Sourcepub fn cancel_unbonding_delegation(
&self,
validator_address: &ValAddress,
amount: u64,
creation_height: u64,
cfg: TxConfig,
) -> AsyncGrpcCall<TxInfo>
pub fn cancel_unbonding_delegation( &self, validator_address: &ValAddress, amount: u64, creation_height: u64, cfg: TxConfig, ) -> AsyncGrpcCall<TxInfo>
Cancels signer’s pending undelegation from a validator.
Sourcepub fn begin_redelegate(
&self,
src_validator_address: &ValAddress,
dest_validator_address: &ValAddress,
amount: u64,
cfg: TxConfig,
) -> AsyncGrpcCall<TxInfo>
pub fn begin_redelegate( &self, src_validator_address: &ValAddress, dest_validator_address: &ValAddress, amount: u64, cfg: TxConfig, ) -> AsyncGrpcCall<TxInfo>
Sends signer’s delegated tokens to a new validator for redelegation.
Sourcepub fn undelegate(
&self,
validator_address: &ValAddress,
amount: u64,
cfg: TxConfig,
) -> AsyncGrpcCall<TxInfo>
pub fn undelegate( &self, validator_address: &ValAddress, amount: u64, cfg: TxConfig, ) -> AsyncGrpcCall<TxInfo>
Undelegates signer’s delegated tokens, unbonding them from the current validator.
Sourcepub fn delegate(
&self,
validator_address: &ValAddress,
amount: u64,
cfg: TxConfig,
) -> AsyncGrpcCall<TxInfo>
pub fn delegate( &self, validator_address: &ValAddress, amount: u64, cfg: TxConfig, ) -> AsyncGrpcCall<TxInfo>
Sends signer’s liquid tokens to a validator for delegation.
Sourcepub fn query_delegation(
&self,
validator_address: &ValAddress,
) -> AsyncGrpcCall<QueryDelegationResponse>
pub fn query_delegation( &self, validator_address: &ValAddress, ) -> AsyncGrpcCall<QueryDelegationResponse>
Retrieves the delegation information between signer and a validator.
Sourcepub fn query_unbonding(
&self,
validator_address: &ValAddress,
) -> AsyncGrpcCall<QueryUnbondingDelegationResponse>
pub fn query_unbonding( &self, validator_address: &ValAddress, ) -> AsyncGrpcCall<QueryUnbondingDelegationResponse>
Retrieves the unbonding status between signer and a validator.
Sourcepub fn query_redelegations(
&self,
src_validator_address: &ValAddress,
dest_validator_address: &ValAddress,
) -> AsyncGrpcCall<QueryRedelegationsResponse>
pub fn query_redelegations( &self, src_validator_address: &ValAddress, dest_validator_address: &ValAddress, ) -> AsyncGrpcCall<QueryRedelegationsResponse>
Retrieves the status of the redelegations between signer and a validator.
Auto Trait Implementations§
impl Freeze for StateApi
impl !RefUnwindSafe for StateApi
impl Send for StateApi
impl Sync for StateApi
impl Unpin for StateApi
impl UnsafeUnpin for StateApi
impl !UnwindSafe for StateApi
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> 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.