Trait ContractsBackend

Source
pub trait ContractsBackend<E: Environment> {
    type Error;
    type EventLog;

    // Provided methods
    fn instantiate<'a, Contract: Clone, Args: Send + Clone + AbiEncodeWith<Abi> + Sync, R, Abi: Send + Sync + Clone>(
        &'a mut self,
        contract_name: &'a str,
        caller: &'a Keypair,
        constructor: &'a mut CreateBuilder<E, Contract, Set<LimitParamsV2>, Set<ExecutionInput<Args, Abi>>, Set<ReturnType<R>>>,
    ) -> InstantiateBuilder<'a, E, Contract, Args, R, Self, Abi>
       where Self: Sized + BuilderClient<E> { ... }
    fn upload<'a>(
        &'a mut self,
        contract_name: &'a str,
        caller: &'a Keypair,
    ) -> UploadBuilder<'a, E, Self>
       where Self: Sized + BuilderClient<E> { ... }
    fn remove_code<'a>(
        &'a mut self,
        caller: &'a Keypair,
        code_hash: H256,
    ) -> RemoveCodeBuilder<'a, E, Self>
       where Self: Sized + BuilderClient<E> { ... }
    fn call<'a, Args: Sync + AbiEncodeWith<Abi> + Clone, RetType: Send + AbiDecodeWith<Abi>, Abi: Sync + Clone>(
        &'a mut self,
        caller: &'a Keypair,
        message: &'a CallBuilderFinal<E, Args, RetType, Abi>,
    ) -> CallBuilder<'a, E, Args, RetType, Self, Abi>
       where Self: Sized + BuilderClient<E> { ... }
}
Expand description

Contract-specific operations.

Required Associated Types§

Source

type Error

Error type.

Source

type EventLog

Event log type.

Provided Methods§

Source

fn instantiate<'a, Contract: Clone, Args: Send + Clone + AbiEncodeWith<Abi> + Sync, R, Abi: Send + Sync + Clone>( &'a mut self, contract_name: &'a str, caller: &'a Keypair, constructor: &'a mut CreateBuilder<E, Contract, Set<LimitParamsV2>, Set<ExecutionInput<Args, Abi>>, Set<ReturnType<R>>>, ) -> InstantiateBuilder<'a, E, Contract, Args, R, Self, Abi>
where Self: Sized + BuilderClient<E>,

Start building an instantiate call using a builder pattern.

§Example
// Constructor method
let mut constructor = FlipperRef::new(false);
let contract = client
    .instantiate("flipper", &ink_e2e::alice(), &mut constructor)
    // Optional arguments
    // Send 100 units with the call.
    .value(100)
    // Add 10% margin to the gas limit
    .extra_gas_portion(10)
    .storage_deposit_limit(100)
    // Submit the call for on-chain execution.
    .submit()
    .await
    .expect("instantiate failed");
Source

fn upload<'a>( &'a mut self, contract_name: &'a str, caller: &'a Keypair, ) -> UploadBuilder<'a, E, Self>
where Self: Sized + BuilderClient<E>,

Start building an upload call.

§Example
let contract = client
    .upload("flipper", &ink_e2e::alice())
    // Optional arguments
    .storage_deposit_limit(100)
    // Submit the call for on-chain execution.
    .submit()
    .await
    .expect("upload failed");
Source

fn remove_code<'a>( &'a mut self, caller: &'a Keypair, code_hash: H256, ) -> RemoveCodeBuilder<'a, E, Self>
where Self: Sized + BuilderClient<E>,

Start building a remove code call.

§Example
let contract = client
    .remove_code(&ink_e2e::alice(), code_hash)
    // Submit the call for on-chain execution.
    .submit()
    .await
    .expect("remove failed");
Source

fn call<'a, Args: Sync + AbiEncodeWith<Abi> + Clone, RetType: Send + AbiDecodeWith<Abi>, Abi: Sync + Clone>( &'a mut self, caller: &'a Keypair, message: &'a CallBuilderFinal<E, Args, RetType, Abi>, ) -> CallBuilder<'a, E, Args, RetType, Self, Abi>
where Self: Sized + BuilderClient<E>,

Start building a call using a builder pattern.

§Example
// Message method
let get = call_builder.get();
let get_res = client
   .call(&ink_e2e::bob(), &get)
    // Optional arguments
    // Send 100 units with the call.
    .value(100)
    // Add 10% margin to the gas limit
    .extra_gas_portion(10)
    .storage_deposit_limit(100)
    // Submit the call for on-chain execution.
    .submit()
    .await
    .expect("instantiate failed");

Implementors§

Source§

impl<AccountId: Clone + Send + Sync + From<[u8; 32]> + AsRef<[u8; 32]>, S: Sandbox, E: Environment<AccountId = AccountId, Balance = <<S::Runtime as Config>::Currency as Inspect<AccountIdFor<S::Runtime>>>::Balance> + 'static> ContractsBackend<E> for ink_e2e::SandboxClient<AccountId, S>
where S::Runtime: Config + Config, AccountIdFor<S::Runtime>: From<[u8; 32]> + AsRef<[u8; 32]>,

Source§

type Error = SandboxErr

Source§

type EventLog = ()

Source§

impl<C, E> ContractsBackend<E> 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>, E: Environment, E::AccountId: Debug + Send + Sync, E::Balance: Clone + Debug + Send + Sync + From<u128> + HasCompact + Serialize, H256: Debug + Send + Encode,

Source§

type Error = Error<DispatchError>

Source§

type EventLog = ExtrinsicEvents<C>