pub struct ContractCallHandler<T: Account, D> {
    pub contract_call: ContractCall,
    pub tx_parameters: TxParameters,
    pub account: T,
    pub datatype: PhantomData<D>,
    pub log_decoder: LogDecoder,
    /* private fields */
}
Expand description

Helper that handles submitting a call to a client and formatting the response

Fields§

§contract_call: ContractCall§tx_parameters: TxParameters§account: T§datatype: PhantomData<D>§log_decoder: LogDecoder

Implementations§

source§

impl<T, D> ContractCallHandler<T, D>where T: Account, D: Tokenizable + Debug,

source

pub fn set_contract_ids(self, contract_ids: &[Bech32ContractId]) -> Self

Sets external contracts as dependencies to this contract’s call. Effectively, this will be used to create fuel_tx::Input::Contract/fuel_tx::Output::Contract pairs and set them into the transaction. Note that this is a builder method, i.e. use it as a chain:

my_contract_instance.my_method(...).set_contract_ids(&[another_contract_id]).call()
source

pub fn set_contracts(self, contracts: &[&dyn SettableContract]) -> Self

Sets external contract instances as dependencies to this contract’s call. Effectively, this will be used to: merge LogDecoders and create fuel_tx::Input::Contract/fuel_tx::Output::Contract pairs and set them into the transaction. Note that this is a builder method, i.e. use it as a chain:

my_contract_instance.my_method(...).set_contracts(&[another_contract_instance]).call()
source

pub fn add_custom_asset( self, asset_id: AssetId, amount: u64, to: Option<Bech32Address> ) -> Self

Adds a custom asset_id with its amount and an optional address to be used for generating outputs to this contract’s call.

Parameters
  • asset_id: The unique identifier of the asset being added.
  • amount: The amount of the asset being added.
  • address: The optional account address that the output amount will be sent to. If not provided, the asset will be sent to the users account address. Note that this is a builder method, i.e. use it as a chain:
let asset_id = AssetId::from([3u8; 32]);
let amount = 5000;
my_contract_instance.my_method(...).add_custom_asset(asset_id, amount, None).call()
source

pub fn append_contract(self, contract_id: Bech32ContractId) -> Self

Appends additional external contracts as dependencies to this contract’s call. Effectively, this will be used to create additional fuel_tx::Input::Contract/fuel_tx::Output::Contract pairs and set them into the transaction. Note that this is a builder method, i.e. use it as a chain:

my_contract_instance.my_method(...).append_contracts(additional_contract_id).call()
source

pub fn is_payable(&self) -> bool

source

pub fn tx_params(self, params: TxParameters) -> Self

Sets the transaction parameters for a given transaction. Note that this is a builder method, i.e. use it as a chain:

let params = TxParameters { gas_price: 100, gas_limit: 1000000 };
my_contract_instance.my_method(...).tx_params(params).call()
source

pub fn call_params(self, params: CallParameters) -> Result<Self>

Sets the call parameters for a given contract call. Note that this is a builder method, i.e. use it as a chain:

let params = CallParameters { amount: 1, asset_id: BASE_ASSET_ID };
my_contract_instance.my_method(...).call_params(params).call()
source

pub fn append_variable_outputs(self, num: u64) -> Self

Appends num fuel_tx::Output::Variables to the transaction. Note that this is a builder method, i.e. use it as a chain:

my_contract_instance.my_method(...).add_variable_outputs(num).call()
source

pub async fn build_tx(&self) -> Result<ScriptTransaction>

Returns the script that executes the contract call

source

pub async fn call(self) -> Result<FuelCallResponse<D>>

Call a contract’s method on the node, in a state-modifying manner.

source

pub async fn simulate(&mut self) -> Result<FuelCallResponse<D>>

Call a contract’s method on the node, in a simulated manner, meaning the state of the blockchain is not modified but simulated.

source

pub async fn estimate_tx_dependencies( self, max_attempts: Option<u64> ) -> Result<Self>

Simulates the call and attempts to resolve missing tx dependencies. Forwards the received error if it cannot be fixed.

source

pub async fn estimate_transaction_cost( &self, tolerance: Option<f64> ) -> Result<TransactionCost>

Get a contract’s estimated cost

source

pub fn get_response( &self, receipts: Vec<Receipt> ) -> Result<FuelCallResponse<D>>

Create a FuelCallResponse from call receipts

Trait Implementations§

source§

impl<T: Debug + Account, D: Debug> Debug for ContractCallHandler<T, D>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, D> RefUnwindSafe for ContractCallHandler<T, D>where D: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, D> Send for ContractCallHandler<T, D>where D: Send,

§

impl<T, D> Sync for ContractCallHandler<T, D>where D: Sync,

§

impl<T, D> Unpin for ContractCallHandler<T, D>where D: Unpin, T: Unpin,

§

impl<T, D> UnwindSafe for ContractCallHandler<T, D>where D: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AnyDebug for Twhere T: Any + Debug,

source§

fn as_any_ref(&self) -> &(dyn Any + 'static)

Returns a reference to the underlying type as Any.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
§

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,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

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
§

impl<T> IsFieldType<T> for T