pub trait BlockchainInteractor: Send + Sync {
    // Required methods
    fn new<'life0, 'async_trait>(
        gateway_url: &'life0 str
    ) -> Pin<Box<dyn Future<Output = Self> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn register_wallet(&mut self, wallet: Wallet) -> Address;
    fn sc_call<'life0, 'async_trait, S>(
        &'life0 mut self,
        sc_call_step: S
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where S: AsMut<ScCallStep> + Send + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn sc_deploy<'life0, 'async_trait, S>(
        &'life0 mut self,
        sc_deploy_step: S
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where S: AsMut<ScDeployStep> + Send + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A trait defining the interaction interface with the blockchain. This trait abstracts the blockchain interaction, enabling developers to either use the provided Interactor struct from the multiversx-sdk crate or mock it for testing purposes.

Required Methods§

source

fn new<'life0, 'async_trait>( gateway_url: &'life0 str ) -> Pin<Box<dyn Future<Output = Self> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Creates a new instance of a type implementing BlockchainInteractor, usually an Interactor.

Parameters
  • gateway_url: A string slice representing the URL of the blockchain gateway.
Returns
  • Self: A new instance of a type implementing BlockchainInteractor.
source

fn register_wallet(&mut self, wallet: Wallet) -> Address

Registers a wallet with the blockchain interactor, returning the associated blockchain address.

Parameters
  • wallet: A Wallet instance to be registered.
Returns
  • Address: The blockchain address associated with the registered wallet.
source

fn sc_call<'life0, 'async_trait, S>( &'life0 mut self, sc_call_step: S ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where S: AsMut<ScCallStep> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Executes a smart contract call on the blockchain.

Type Parameters
  • S: A type that implements AsMut<ScCallStep> and Send, representing the smart contract call step.
Parameters
  • sc_call_step: An instance of S representing the smart contract call step.
source

fn sc_deploy<'life0, 'async_trait, S>( &'life0 mut self, sc_deploy_step: S ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where S: AsMut<ScDeployStep> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Deploys a smart contract on the blockchain.

The sc_deploy method takes a sc_deploy_step parameter that encapsulates the information required for deploying a smart contract. The method is asynchronous and requires the tokio runtime, ensuring non-blocking operation and concurrency where needed.

Type Parameters
Parameters
  • &mut self: A mutable reference to the current BlockchainInteractor instance.
  • sc_deploy_step: The smart contract deployment step encapsulating the necessary information for deployment.
Returns

The method returns a Result indicating the success or failure of the operation. Successful operations will return Ok(()) while failures will return Err(BlockchainInteractorError).

Errors

Any errors that occur during the execution of this method will be encapsulated in a [BlockchainInteractorError] and returned.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl BlockchainInteractor for Interactor

Implementation of the BlockchainInteractor trait for the Interactor struct from the multiversx-sdk crate. This implementation allows for direct interaction with the blockchain via the provided methods.

source§

fn new<'life0, 'async_trait>( gateway_url: &'life0 str ) -> Pin<Box<dyn Future<Output = Self> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Asynchronously creates a new Interactor instance with the specified gateway URL.

Parameters
  • gateway_url: A string slice representing the URL of the blockchain gateway.
Returns
  • Self: A new Interactor instance.
source§

fn register_wallet(&mut self, wallet: Wallet) -> Address

Registers a wallet with the Interactor, returning the associated blockchain address.

Parameters
  • wallet: A Wallet instance to be registered.
Returns
  • Address: The blockchain address associated with the registered wallet.
source§

fn sc_call<'life0, 'async_trait, S>( &'life0 mut self, sc_call_step: S ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where S: AsMut<ScCallStep> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Asynchronously executes a smart contract call on the blockchain.

Type Parameters
  • S: A type that implements AsMut<ScCallStep> and Send, representing the smart contract call step.
Parameters
  • sc_call_step: An instance of S representing the smart contract call step.
source§

fn sc_deploy<'life0, 'async_trait, S>( &'life0 mut self, sc_deploy_step: S ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where S: AsMut<ScDeployStep> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Implements the sc_deploy method from the BlockchainInteractor trait.

The sc_deploy method of this implementation delegates the smart contract deployment process to the sc_deploy method of the current Interactor instance.

Type Parameters
Parameters
  • &mut self: A mutable reference to the current Interactor instance.
  • sc_deploy_step: The smart contract deployment step encapsulating the necessary information for deployment.
Returns

The method returns a Result indicating the success or failure of the operation. Successful operations will return Ok(()) while failures will return Err(BlockchainInteractorError).

Errors

Any errors that occur during the execution of this method will be encapsulated in a [BlockchainInteractorError] and returned.

Implementors§