Trait novax_executor::BlockchainInteractor
source · 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§
sourcefn 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 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 implementingBlockchainInteractor.
sourcefn register_wallet(&mut self, wallet: Wallet) -> Address
fn register_wallet(&mut self, wallet: Wallet) -> Address
Registers a wallet with the blockchain interactor, returning the associated blockchain address.
Parameters
wallet: AWalletinstance to be registered.
Returns
Address: The blockchain address associated with the registered wallet.
sourcefn 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_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 implementsAsMut<ScCallStep>andSend, representing the smart contract call step.
Parameters
sc_call_step: An instance ofSrepresenting the smart contract call step.
sourcefn 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,
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
S: A type that implementsAsMut<ScDeployStep>trait, allowing for a mutable reference to anScDeployStepinstance to be obtained.
Parameters
&mut self: A mutable reference to the currentBlockchainInteractorinstance.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§
Implementations on Foreign Types§
source§impl BlockchainInteractor for Interactor
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,
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 newInteractorinstance.
source§fn register_wallet(&mut self, wallet: Wallet) -> Address
fn register_wallet(&mut self, wallet: Wallet) -> Address
Registers a wallet with the Interactor, returning the associated blockchain address.
Parameters
wallet: AWalletinstance 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,
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 implementsAsMut<ScCallStep>andSend, representing the smart contract call step.
Parameters
sc_call_step: An instance ofSrepresenting 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,
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
S: A type that implementsAsMut<ScDeployStep>trait, allowing for a mutable reference to anScDeployStepinstance to be obtained.
Parameters
&mut self: A mutable reference to the currentInteractorinstance.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.