Struct fuels_accounts::provider::Provider
source · pub struct Provider { /* private fields */ }
Expand description
Encapsulates common client operations in the SDK.
Note that you may also use client
, which is an instance
of FuelClient
, directly, which provides a broader API.
Implementations§
source§impl Provider
impl Provider
pub async fn from(addr: impl Into<SocketAddr>) -> Result<Self>
pub async fn healthy(&self) -> Result<bool>
sourcepub async fn connect(url: impl AsRef<str>) -> Result<Provider>
pub async fn connect(url: impl AsRef<str>) -> Result<Provider>
Connects to an existing node at the given address.
pub fn url(&self) -> &str
sourcepub async fn send_transaction_and_await_commit<T: Transaction>(
&self,
tx: T,
) -> Result<TxStatus>
pub async fn send_transaction_and_await_commit<T: Transaction>( &self, tx: T, ) -> Result<TxStatus>
Sends a transaction to the underlying Provider’s client.
pub async fn send_transaction<T: Transaction>(&self, tx: T) -> Result<TxId>
pub async fn await_transaction_commit<T: Transaction>( &self, id: TxId, ) -> Result<TxStatus>
pub async fn tx_status(&self, tx_id: &TxId) -> Result<TxStatus>
pub async fn chain_info(&self) -> Result<ChainInfo>
pub fn consensus_parameters(&self) -> &ConsensusParameters
pub fn base_asset_id(&self) -> &AssetId
pub fn chain_id(&self) -> ChainId
pub async fn node_info(&self) -> Result<NodeInfo>
pub async fn latest_gas_price(&self) -> Result<LatestGasPrice>
pub async fn estimate_gas_price( &self, block_horizon: u32, ) -> Result<EstimateGasPrice>
pub async fn dry_run(&self, tx: impl Transaction) -> Result<TxStatus>
pub async fn dry_run_multiple( &self, transactions: Transactions, ) -> Result<Vec<(TxId, TxStatus)>>
pub async fn dry_run_opt( &self, tx: impl Transaction, utxo_validation: bool, gas_price: Option<u64>, ) -> Result<TxStatus>
pub async fn dry_run_opt_multiple( &self, transactions: Transactions, utxo_validation: bool, gas_price: Option<u64>, ) -> Result<Vec<(TxId, TxStatus)>>
sourcepub async fn get_coins(
&self,
from: &Bech32Address,
asset_id: AssetId,
) -> Result<Vec<Coin>>
pub async fn get_coins( &self, from: &Bech32Address, asset_id: AssetId, ) -> Result<Vec<Coin>>
Gets all unspent coins owned by address from
, with asset ID asset_id
.
sourcepub async fn get_spendable_resources(
&self,
filter: ResourceFilter,
) -> Result<Vec<CoinType>>
pub async fn get_spendable_resources( &self, filter: ResourceFilter, ) -> Result<Vec<CoinType>>
Get some spendable coins of asset asset_id
for address from
that add up at least to
amount amount
. The returned coins (UTXOs) are actual coins that can be spent. The number
of coins (UXTOs) is optimized to prevent dust accumulation.
sourcepub async fn get_asset_balance(
&self,
address: &Bech32Address,
asset_id: AssetId,
) -> Result<u64>
pub async fn get_asset_balance( &self, address: &Bech32Address, asset_id: AssetId, ) -> Result<u64>
Get the balance of all spendable coins asset_id
for address address
. This is different
from getting coins because we are just returning a number (the sum of UTXOs amount) instead
of the UTXOs.
sourcepub async fn get_contract_asset_balance(
&self,
contract_id: &Bech32ContractId,
asset_id: AssetId,
) -> Result<u64>
pub async fn get_contract_asset_balance( &self, contract_id: &Bech32ContractId, asset_id: AssetId, ) -> Result<u64>
Get the balance of all spendable coins asset_id
for contract with id contract_id
.
sourcepub async fn get_balances(
&self,
address: &Bech32Address,
) -> Result<HashMap<String, u64>>
pub async fn get_balances( &self, address: &Bech32Address, ) -> Result<HashMap<String, u64>>
Get all the spendable balances of all assets for address address
. This is different from
getting the coins because we are only returning the numbers (the sum of UTXOs coins amount
for each asset id) and not the UTXOs coins themselves
sourcepub async fn get_contract_balances(
&self,
contract_id: &Bech32ContractId,
) -> Result<HashMap<AssetId, u64>>
pub async fn get_contract_balances( &self, contract_id: &Bech32ContractId, ) -> Result<HashMap<AssetId, u64>>
Get all balances of all assets for the contract with id contract_id
.
pub async fn get_transaction_by_id( &self, tx_id: &TxId, ) -> Result<Option<TransactionResponse>>
pub async fn get_transactions( &self, request: PaginationRequest<String>, ) -> Result<PaginatedResult<TransactionResponse, String>>
pub async fn get_transactions_by_owner( &self, owner: &Bech32Address, request: PaginationRequest<String>, ) -> Result<PaginatedResult<TransactionResponse, String>>
pub async fn latest_block_height(&self) -> Result<u32>
pub async fn latest_block_time(&self) -> Result<Option<DateTime<Utc>>>
pub async fn produce_blocks( &self, blocks_to_produce: u32, start_time: Option<DateTime<Utc>>, ) -> Result<u32>
pub async fn block(&self, block_id: &Bytes32) -> Result<Option<Block>>
pub async fn block_by_height( &self, height: BlockHeight, ) -> Result<Option<Block>>
pub async fn get_blocks( &self, request: PaginationRequest<String>, ) -> Result<PaginatedResult<Block, String>>
pub async fn estimate_transaction_cost<T: Transaction>( &self, tx: T, tolerance: Option<f64>, block_horizon: Option<u32>, ) -> Result<TransactionCost>
pub async fn get_messages(&self, from: &Bech32Address) -> Result<Vec<Message>>
pub async fn get_message_proof( &self, tx_id: &TxId, nonce: &Nonce, commit_block_id: Option<&Bytes32>, commit_block_height: Option<u32>, ) -> Result<Option<MessageProof>>
pub fn with_retry_config(self, retry_config: RetryConfig) -> Self
Trait Implementations§
source§impl DryRunner for Provider
impl DryRunner for Provider
fn dry_run<'life0, 'async_trait>(
&'life0 self,
tx: FuelTransaction,
) -> Pin<Box<dyn Future<Output = Result<DryRun>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn estimate_gas_price<'life0, 'async_trait>(
&'life0 self,
block_horizon: u32,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn consensus_parameters(&self) -> &ConsensusParameters
fn maybe_estimate_predicates<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: &'life1 FuelTransaction,
latest_chain_executor_version: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Option<FuelTransaction>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for Provider
impl !RefUnwindSafe for Provider
impl Send for Provider
impl Sync for Provider
impl Unpin for Provider
impl !UnwindSafe for Provider
Blanket Implementations§
source§impl<T> AnyDebug for T
impl<T> AnyDebug for T
source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
Any
.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> 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 moresource§impl<S> IteratorOverTable for S
impl<S> IteratorOverTable for S
source§fn iter_all<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
source§fn iter_all_by_prefix<M, P>(
&self,
prefix: Option<P>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
fn iter_all_by_prefix<M, P>( &self, prefix: Option<P>, ) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
source§fn iter_all_by_start<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all_by_start<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
source§fn iter_all_filtered<M, P>(
&self,
prefix: Option<P>,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
fn iter_all_filtered<M, P>( &self, prefix: Option<P>, start: Option<&<M as Mappable>::Key>, direction: Option<IterDirection>, ) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
source§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> StorageAsMut for T
impl<T> StorageAsMut for T
fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
source§impl<T> StorageAsRef for T
impl<T> StorageAsRef for T
fn storage<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
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.