Trait noble_contracts::chain_extension::ChainExtension[][src]

pub trait ChainExtension {
    fn call<E: Ext>(
        func_id: u32,
        env: Environment<'_, '_, E, InitState>
    ) -> Result<RetVal>
    where
        <E::T as SysConfig>::AccountId: UncheckedFrom<<E::T as SysConfig>::Hash> + AsRef<[u8]>
; fn enabled() -> bool { ... } }

A trait used to extend the set of contract callable functions.

In order to create a custom chain extension this trait must be implemented and supplied to the noble contracts configuration trait as the associated type of the same name. Consult the module documentation for a general explanation of chain extensions.

Required methods

fn call<E: Ext>(
    func_id: u32,
    env: Environment<'_, '_, E, InitState>
) -> Result<RetVal> where
    <E::T as SysConfig>::AccountId: UncheckedFrom<<E::T as SysConfig>::Hash> + AsRef<[u8]>, 
[src]

Call the chain extension logic.

This is the only function that needs to be implemented in order to write a chain extensions. It is called whenever a contract calls the seal_call_chain_extension imported wasm function.

Parameters

  • func_id: The first argument to seal_call_chain_extension. Usually used to determine which function to realize.
  • env: Access to the remaining arguments and the execution environment.

Return

In case of Err the contract execution is immediatly suspended and the passed error is returned to the caller. Otherwise the value of RetVal determines the exit behaviour.

Loading content...

Provided methods

fn enabled() -> bool[src]

Determines whether chain extensions are enabled for this chain.

The default implementation returns true. Therefore it is not necessary to overwrite this function when implementing a chain extension. In case of false the deployment of a contract that references seal_call_chain_extension will be denied and calling this function will return NoChainExtension without first calling into call.

Loading content...

Implementations on Foreign Types

impl ChainExtension for ()[src]

Implementation that indicates that no chain extension is available.

Loading content...

Implementors

Loading content...