Struct TxBuilder
pub struct TxBuilder<'a> {Show 16 fields
pub querier: &'a QueryClient,
pub signer: &'a dyn TxSigner,
pub sender: Option<Address>,
pub tx_timeout_blocks: Option<u64>,
pub sequence_strategy: Option<SequenceStrategy>,
pub account_number: Option<u64>,
pub memo: Option<String>,
pub gas_coin: Option<Coin>,
pub gas_units_or_simulate: Option<u64>,
pub gas_simulate_multiplier: Option<f32>,
pub broadcast_mode: Option<BroadcastMode>,
pub broadcast_poll: bool,
pub broadcast_poll_sleep_duration: Option<Duration>,
pub broadcast_poll_timeout_duration: Option<Duration>,
pub middleware_map_body: Option<Arc<Vec<SigningMiddlewareMapBody>>>,
pub middleware_map_resp: Option<Arc<Vec<SigningMiddlewareMapResp>>>,
}
Fields§
§querier: &'a QueryClient
§signer: &'a dyn TxSigner
§sender: Option<Address>
Must be set if not providing a sequence
or account_number
tx_timeout_blocks: Option<u64>
how many blocks until a tx is considered invalid if not set, the default is 10 blocks
sequence_strategy: Option<SequenceStrategy>
for manually overriding the sequence number, e.g. parallel transactions (multiple messages in a tx do not need this)
account_number: Option<u64>
The account number of the sender. If not set, it will be derived from the sender’s account
memo: Option<String>
§gas_coin: Option<Coin>
The gas coin to use. Gas price (in gas_coin.denom) = gas_coin.amount * gas_units If not set, it will be derived from querier.chain_config (without hitting the network)
gas_units_or_simulate: Option<u64>
The maximum gas units. Gas price (in gas_coin.denom) = gas_coin.amount * gas_units
If not set, it will be derived from running an on-chain simulation multiplied by gas_multiplier
gas_simulate_multiplier: Option<f32>
A multiplier to use for simulated gas units. If not set, a default of 1.5 will be used.
broadcast_mode: Option<BroadcastMode>
The broadcast mode to use. If not set, the default is Sync
broadcast_poll: bool
Whether broadcasting should poll for the tx landing on chain before returning default is true
broadcast_poll_sleep_duration: Option<Duration>
The duration to sleep between polling for the tx landing on chain If not set, the default is 1 second
broadcast_poll_timeout_duration: Option<Duration>
The duration to wait before giving up on polling for the tx landing on chain If not set, the default is 30 seconds
middleware_map_body: Option<Arc<Vec<SigningMiddlewareMapBody>>>
Middleware to run before the tx is broadcast
middleware_map_resp: Option<Arc<Vec<SigningMiddlewareMapResp>>>
Middleware to run after the tx is broadcast
Implementations§
§impl<'a> TxBuilder<'a>
impl<'a> TxBuilder<'a>
pub fn new(querier: &'a QueryClient, signer: &'a dyn TxSigner) -> TxBuilder<'a>
pub fn set_tx_timeout_blocks( &mut self, tx_timeout_blocks: u64, ) -> &mut TxBuilder<'a>
pub fn set_memo(&mut self, memo: impl Into<String>) -> &mut TxBuilder<'a>
pub fn set_sequence_strategy( &mut self, sequence_strategy: SequenceStrategy, ) -> &mut TxBuilder<'a>
pub fn set_sender(&mut self, sender: Address) -> &mut TxBuilder<'a>
pub fn set_gas_coin(&mut self, gas_coin: Coin) -> &mut TxBuilder<'a>
pub fn set_gas_units_or_simulate( &mut self, gas_units: Option<u64>, ) -> &mut TxBuilder<'a>
pub fn set_gas_simulate_multiplier( &mut self, gas_multiplier: f32, ) -> &mut TxBuilder<'a>
pub fn set_account_number(&mut self, account_number: u64) -> &mut TxBuilder<'a>
pub fn set_broadcast_mode( &mut self, broadcast_mode: BroadcastMode, ) -> &mut TxBuilder<'a>
pub fn set_broadcast_poll(&mut self, broadcast_poll: bool) -> &mut TxBuilder<'a>
pub fn set_broadcast_poll_sleep_duration( &mut self, broadcast_poll_sleep_duration: Duration, ) -> &mut TxBuilder<'a>
pub fn set_broadcast_poll_timeout_duration( &mut self, broadcast_poll_timeout_duration: Duration, ) -> &mut TxBuilder<'a>
pub fn set_middleware_map_body( &mut self, middleware_map_body: Arc<Vec<SigningMiddlewareMapBody>>, ) -> &mut TxBuilder<'a>
pub fn set_middleware_map_resp( &mut self, middleware_map_resp: Arc<Vec<SigningMiddlewareMapResp>>, ) -> &mut TxBuilder<'a>
pub async fn broadcast( self, messages: impl IntoIterator<Item = Any>, ) -> Result<TxResponse, Error>
pub async fn simulate_gas( &self, signer_info: SignerInfo, account_number: u64, tx_body: &TxBody, ) -> Result<GasInfo, Error>
pub async fn broadcast_raw(
self,
messages: Vec<Any>,
) -> Result<AnyTxResponse, Error>
pub async fn broadcast_raw( self, messages: Vec<Any>, ) -> Result<AnyTxResponse, Error>
Typically do not want to do this directly, use broadcast
instead
however, in a case where you do not want to wait for the tx to be committed, you can use this
(and if the original tx response is AnyTxResponse::Rpc, it will stay that way)
Auto Trait Implementations§
impl<'a> Freeze for TxBuilder<'a>
impl<'a> !RefUnwindSafe for TxBuilder<'a>
impl<'a> Send for TxBuilder<'a>
impl<'a> Sync for TxBuilder<'a>
impl<'a> Unpin for TxBuilder<'a>
impl<'a> !UnwindSafe for TxBuilder<'a>
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self
to type T
. The semantics of numeric casting with the as
operator are followed, so <T as As>::as_::<U>
can be used in the same way as T as U
for numeric conversions. Read moreSource§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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered
].