pub trait PrecompileHandle {
    // Required methods
    fn call(
        &mut self,
        to: H160,
        transfer: Option<Transfer>,
        input: Vec<u8, Global>,
        gas_limit: Option<u64>,
        is_static: bool,
        context: &Context
    ) -> (ExitReason, Vec<u8, Global>);
    fn record_cost(&mut self, cost: u64) -> Result<(), ExitError>;
    fn record_external_cost(
        &mut self,
        ref_time: Option<u64>,
        proof_size: Option<u64>
    ) -> Result<(), ExitError>;
    fn refund_external_cost(
        &mut self,
        ref_time: Option<u64>,
        proof_size: Option<u64>
    );
    fn remaining_gas(&self) -> u64;
    fn log(
        &mut self,
        address: H160,
        topics: Vec<H256, Global>,
        data: Vec<u8, Global>
    ) -> Result<(), ExitError>;
    fn code_address(&self) -> H160;
    fn input(&self) -> &[u8] ;
    fn context(&self) -> &Context;
    fn is_static(&self) -> bool;
    fn gas_limit(&self) -> Option<u64>;
}
Expand description

Handle provided to a precompile to interact with the EVM.

Required Methods§

fn call( &mut self, to: H160, transfer: Option<Transfer>, input: Vec<u8, Global>, gas_limit: Option<u64>, is_static: bool, context: &Context ) -> (ExitReason, Vec<u8, Global>)

Perform subcall in provided context. Precompile specifies in which context the subcall is executed.

fn record_cost(&mut self, cost: u64) -> Result<(), ExitError>

Record cost to the Runtime gasometer.

fn record_external_cost( &mut self, ref_time: Option<u64>, proof_size: Option<u64> ) -> Result<(), ExitError>

Record Substrate specific cost.

fn refund_external_cost( &mut self, ref_time: Option<u64>, proof_size: Option<u64> )

Refund Substrate specific cost.

fn remaining_gas(&self) -> u64

Retreive the remaining gas.

fn log( &mut self, address: H160, topics: Vec<H256, Global>, data: Vec<u8, Global> ) -> Result<(), ExitError>

Record a log.

fn code_address(&self) -> H160

Retreive the code address (what is the address of the precompile being called).

fn input(&self) -> &[u8]

Retreive the input data the precompile is called with.

fn context(&self) -> &Context

Retreive the context in which the precompile is executed.

fn is_static(&self) -> bool

Is the precompile call is done statically.

fn gas_limit(&self) -> Option<u64>

Retreive the gas limit of this call.

Implementations on Foreign Types§

§

impl PrecompileHandle for MockHandle

§

fn call( &mut self, address: H160, transfer: Option<Transfer>, input: Vec<u8, Global>, target_gas: Option<u64>, is_static: bool, context: &Context ) -> (ExitReason, Vec<u8, Global>)

Perform subcall in provided context. Precompile specifies in which context the subcall is executed.

§

fn code_address(&self) -> H160

Retreive the code address (what is the address of the precompile being called).

§

fn input(&self) -> &[u8]

Retreive the input data the precompile is called with.

§

fn context(&self) -> &Context

Retreive the context in which the precompile is executed.

§

fn is_static(&self) -> bool

Is the precompile call is done statically.

§

fn gas_limit(&self) -> Option<u64>

Retreive the gas limit of this call.

§

fn record_cost(&mut self, cost: u64) -> Result<(), ExitError>

§

fn record_external_cost( &mut self, _ref_time: Option<u64>, _proof_size: Option<u64> ) -> Result<(), ExitError>

§

fn refund_external_cost( &mut self, _ref_time: Option<u64>, _proof_size: Option<u64> )

§

fn remaining_gas(&self) -> u64

§

fn log( &mut self, address: H160, topics: Vec<H256, Global>, data: Vec<u8, Global> ) -> Result<(), ExitError>

Implementors§