Trait raiden_blockchain::transactions::Transaction

source ·
pub trait Transaction {
    type Output: Send + Sync;
    type Params: Clone + Send + Sync;
    type Data: Clone + Send + Sync;

    // Required methods
    fn onchain_data<'life0, 'async_trait>(
        &'life0 self,
        params: Self::Params,
        at_block_hash: H256
    ) -> Pin<Box<dyn Future<Output = Result<Self::Data, ProxyError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn validate_preconditions<'life0, 'async_trait>(
        &'life0 self,
        params: Self::Params,
        data: Self::Data,
        at_block_hash: H256
    ) -> Pin<Box<dyn Future<Output = Result<(), ProxyError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn submit<'life0, 'async_trait>(
        &'life0 self,
        params: Self::Params,
        data: Self::Data,
        gas_estimate: U256,
        gas_price: U256
    ) -> Pin<Box<dyn Future<Output = Result<Self::Output, ProxyError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn validate_postconditions<'life0, 'async_trait>(
        &'life0 self,
        params: Self::Params,
        at_block_hash: H256
    ) -> Pin<Box<dyn Future<Output = Result<Self::Output, ProxyError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn estimate_gas<'life0, 'async_trait>(
        &'life0 self,
        params: Self::Params,
        data: Self::Data
    ) -> Pin<Box<dyn Future<Output = Result<(U256, U256), ProxyError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn execute_prerequisite<'life0, 'async_trait>(
        &'life0 self,
        _params: Self::Params,
        _data: Self::Data
    ) -> Pin<Box<dyn Future<Output = Result<(), ProxyError>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        params: Self::Params,
        at_block_hash: H256
    ) -> Pin<Box<dyn Future<Output = Result<Self::Output, ProxyError>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
    fn acquire_lock<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Option<RwLockWriteGuard<'_, bool>>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A trait to be implemented by on-chain transactions.

Required Associated Types§

source

type Output: Send + Sync

The type which is returned as a result of a successful transaction execution.

source

type Params: Clone + Send + Sync

The params type to be passed down to transaction.

source

type Data: Clone + Send + Sync

The on-chain data placeholder.

Required Methods§

source

fn onchain_data<'life0, 'async_trait>( &'life0 self, params: Self::Params, at_block_hash: H256 ) -> Pin<Box<dyn Future<Output = Result<Self::Data, ProxyError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch data residing on-chain for validation prior / post execution.

source

fn validate_preconditions<'life0, 'async_trait>( &'life0 self, params: Self::Params, data: Self::Data, at_block_hash: H256 ) -> Pin<Box<dyn Future<Output = Result<(), ProxyError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Validate pre-conditions needed to execute the transaction.

source

fn submit<'life0, 'async_trait>( &'life0 self, params: Self::Params, data: Self::Data, gas_estimate: U256, gas_price: U256 ) -> Pin<Box<dyn Future<Output = Result<Self::Output, ProxyError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Submit transaction on-chain.

source

fn validate_postconditions<'life0, 'async_trait>( &'life0 self, params: Self::Params, at_block_hash: H256 ) -> Pin<Box<dyn Future<Output = Result<Self::Output, ProxyError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Validate conditions after the execution of the transaction in case the execution failed.

source

fn estimate_gas<'life0, 'async_trait>( &'life0 self, params: Self::Params, data: Self::Data ) -> Pin<Box<dyn Future<Output = Result<(U256, U256), ProxyError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Estimate gas for the transaction.

Provided Methods§

source

fn execute_prerequisite<'life0, 'async_trait>( &'life0 self, _params: Self::Params, _data: Self::Data ) -> Pin<Box<dyn Future<Output = Result<(), ProxyError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Execute transactions that are required prior to executing the current one.

Some transactions like deposit might need an approve call before.

source

fn execute<'life0, 'async_trait>( &'life0 self, params: Self::Params, at_block_hash: H256 ) -> Pin<Box<dyn Future<Output = Result<Self::Output, ProxyError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Validate preconditions, execute the transaction and if failed, validate post conditions.

source

fn acquire_lock<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Option<RwLockWriteGuard<'_, bool>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Acquire lock, if needed.

Implementors§

source§

impl<T> Transaction for ChannelCloseTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,

source§

impl<T> Transaction for ChannelCoopSettleTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,

source§

impl<T> Transaction for ChannelOpenTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,

source§

impl<T> Transaction for ChannelSetTotalDepositTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,

source§

impl<T> Transaction for ChannelSetTotalWithdrawTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,

source§

impl<T> Transaction for ChannelSettleTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,

source§

impl<T> Transaction for ChannelUnlockTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,

source§

impl<T> Transaction for ChannelUpdateTransferTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,

source§

impl<T> Transaction for DepositTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,

source§

impl<T> Transaction for PlanWithdrawTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,

source§

impl<T> Transaction for RegisterSecretTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,

source§

impl<T> Transaction for RegisterTokenTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,

source§

impl<T> Transaction for WithdrawTransaction<T>
where T: Transport + Send + Sync, T::Out: Send,