Trait ChainBackend

Source
pub trait ChainBackend {
    type AccountId;
    type Balance: Send + From<u32>;
    type Error;
    type EventLog;

    // Required methods
    fn create_and_fund_account<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        origin: &'life1 Keypair,
        amount: Self::Balance,
    ) -> Pin<Box<dyn Future<Output = Keypair> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn free_balance<'life0, 'async_trait>(
        &'life0 mut self,
        account: Self::AccountId,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Balance, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn runtime_call<'a, 'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        origin: &'life1 Keypair,
        pallet_name: &'a str,
        call_name: &'a str,
        call_data: Vec<Value>,
    ) -> Pin<Box<dyn Future<Output = Result<Self::EventLog, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

General chain operations useful in contract testing.

Required Associated Types§

Source

type AccountId

Account type.

Source

type Balance: Send + From<u32>

Balance type.

Source

type Error

Error type.

Source

type EventLog

Event log type.

Required Methods§

Source

fn create_and_fund_account<'life0, 'life1, 'async_trait>( &'life0 mut self, origin: &'life1 Keypair, amount: Self::Balance, ) -> Pin<Box<dyn Future<Output = Keypair> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Generate a new account and fund it with the given amount of tokens from the origin.

Source

fn free_balance<'life0, 'async_trait>( &'life0 mut self, account: Self::AccountId, ) -> Pin<Box<dyn Future<Output = Result<Self::Balance, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the free balance of account.

Source

fn runtime_call<'a, 'life0, 'life1, 'async_trait>( &'life0 mut self, origin: &'life1 Keypair, pallet_name: &'a str, call_name: &'a str, call_data: Vec<Value>, ) -> Pin<Box<dyn Future<Output = Result<Self::EventLog, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Executes a runtime call call_name for the pallet_name. The call_data is a Vec<Value>.

Note:

  • pallet_name must be in camel case, for example Balances.
  • call_name must be snake case, for example force_transfer.
  • call_data is a Vec<subxt::dynamic::Value> that holds a representation of some value.

Returns when the transaction is included in a block. The return value contains all events that are associated with this transaction.

Since we might run node with an arbitrary runtime, this method inherently must support dynamic calls.

Implementors§

Source§

impl<AccountId: AsRef<[u8; 32]> + Send, S: Sandbox> ChainBackend for ink_e2e::SandboxClient<AccountId, S>
where S::Runtime: Config, AccountIdFor<S::Runtime>: From<[u8; 32]>,

Source§

type AccountId = AccountId

Source§

type Balance = <<S as Sandbox>::Runtime as Config>::Balance

Source§

type Error = SandboxErr

Source§

type EventLog = ()

Source§

impl<C, E> ChainBackend for ink_e2e::Client<C, E>
where C: Config + Send + Sync, C::AccountId: Clone + Debug + Send + Sync + Display + Codec + From<PublicKey> + DeserializeOwned, C::Address: From<PublicKey> + Send + Sync, C::Signature: From<Signature>, <C::ExtrinsicParams as ExtrinsicParams<C>>::Params: From<<DefaultExtrinsicParams<C> as ExtrinsicParams<C>>::Params>, E: Environment, E::AccountId: Debug + Send + Sync, E::Balance: Clone + Debug + Send + Sync + TryFrom<u128> + HasCompact + Serialize, E::EventRecord: Debug,

Source§

type AccountId = <E as Environment>::AccountId

Source§

type Balance = <E as Environment>::Balance

Source§

type Error = Error<DispatchError>

Source§

type EventLog = ExtrinsicEvents<C>