referrerpolicy=no-referrer-when-downgrade

Trait Ext

Source
pub trait Ext: Sealed {
    type T: Config;

Show 37 methods // Required methods fn call( &mut self, gas_limit: Weight, deposit_limit: U256, to: &H160, value: U256, input_data: Vec<u8>, allows_reentry: bool, read_only: bool, ) -> Result<(), ExecError>; fn get_transient_storage(&self, key: &Key) -> Option<Vec<u8>>; fn get_transient_storage_size(&self, key: &Key) -> Option<u32>; fn set_transient_storage( &mut self, key: &Key, value: Option<Vec<u8>>, take_old: bool, ) -> Result<WriteOutcome, DispatchError>; fn caller(&self) -> Origin<Self::T>; fn origin(&self) -> &Origin<Self::T>; fn code_hash(&self, address: &H160) -> H256; fn code_size(&self, address: &H160) -> u64; fn caller_is_origin(&self) -> bool; fn caller_is_root(&self) -> bool; fn account_id(&self) -> &<Self::T as Config>::AccountId; fn balance(&self) -> U256; fn balance_of(&self, address: &H160) -> U256; fn value_transferred(&self) -> U256; fn now(&self) -> U256; fn minimum_balance(&self) -> U256; fn deposit_event(&mut self, topics: Vec<H256>, data: Vec<u8>); fn block_number(&self) -> U256; fn block_hash(&self, block_number: U256) -> Option<H256>; fn block_author(&self) -> Option<H160>; fn gas_limit(&self) -> u64; fn chain_id(&self) -> u64; fn max_value_size(&self) -> u32; fn get_weight_price(&self, weight: Weight) -> U256; fn gas_meter(&self) -> &GasMeter<Self::T>; fn gas_meter_mut(&mut self) -> &mut GasMeter<Self::T>; fn ecdsa_recover( &self, signature: &[u8; 65], message_hash: &[u8; 32], ) -> Result<[u8; 33], ()>; fn sr25519_verify( &self, signature: &[u8; 64], message: &[u8], pub_key: &[u8; 32], ) -> bool; fn ecdsa_to_eth_address(&self, pk: &[u8; 33]) -> Result<[u8; 20], ()>; fn contract_info(&mut self) -> &mut ContractInfo<Self::T>; fn transient_storage(&mut self) -> &mut TransientStorage<Self::T>; fn is_read_only(&self) -> bool; fn last_frame_output(&self) -> &ExecReturnValue; fn last_frame_output_mut(&mut self) -> &mut ExecReturnValue; // Provided methods fn charge(&mut self, weight: Weight) -> Result<ChargedAmount, DispatchError> { ... } fn adjust_gas(&mut self, charged: ChargedAmount, actual_weight: Weight) { ... } fn address(&self) -> H160 { ... }
}
Expand description

Environment functions which are available to all pre-compiles.

Required Associated Types§

Required Methods§

Source

fn call( &mut self, gas_limit: Weight, deposit_limit: U256, to: &H160, value: U256, input_data: Vec<u8>, allows_reentry: bool, read_only: bool, ) -> Result<(), ExecError>

Call (possibly transferring some amount of funds) into the specified account.

Returns the code size of the called contract.

Source

fn get_transient_storage(&self, key: &Key) -> Option<Vec<u8>>

Returns the transient storage entry of the executing account for the given key.

Returns None if the key wasn’t previously set by set_transient_storage or was deleted.

Source

fn get_transient_storage_size(&self, key: &Key) -> Option<u32>

Returns Some(len) (in bytes) if a transient storage item exists at key.

Returns None if the key wasn’t previously set by set_transient_storage or was deleted.

Source

fn set_transient_storage( &mut self, key: &Key, value: Option<Vec<u8>>, take_old: bool, ) -> Result<WriteOutcome, DispatchError>

Sets the transient storage entry for the given key to the specified value. If value is None then the storage entry is deleted.

Source

fn caller(&self) -> Origin<Self::T>

Returns the caller.

Source

fn origin(&self) -> &Origin<Self::T>

Return the origin of the whole call stack.

Source

fn code_hash(&self, address: &H160) -> H256

Returns the code hash of the contract for the given address. If not a contract but account exists then keccak_256([]) is returned, otherwise zero.

Source

fn code_size(&self, address: &H160) -> u64

Returns the code size of the contract at the given address or zero.

Source

fn caller_is_origin(&self) -> bool

Check if the caller of the current contract is the origin of the whole call stack.

Source

fn caller_is_root(&self) -> bool

Check if the caller is origin, and this origin is root.

Source

fn account_id(&self) -> &<Self::T as Config>::AccountId

Returns a reference to the account id of the current contract.

Source

fn balance(&self) -> U256

Returns the balance of the current contract.

The value_transferred is already added.

Source

fn balance_of(&self, address: &H160) -> U256

Returns the balance of the supplied account.

The value_transferred is already added.

Source

fn value_transferred(&self) -> U256

Returns the value transferred along with this call.

Source

fn now(&self) -> U256

Returns the timestamp of the current block in seconds.

Source

fn minimum_balance(&self) -> U256

Returns the minimum balance that is required for creating an account.

Source

fn deposit_event(&mut self, topics: Vec<H256>, data: Vec<u8>)

Deposit an event with the given topics.

There should not be any duplicates in topics.

Source

fn block_number(&self) -> U256

Returns the current block number.

Source

fn block_hash(&self, block_number: U256) -> Option<H256>

Returns the block hash at the given block_number or None if block_number isn’t within the range of the previous 256 blocks.

Source

fn block_author(&self) -> Option<H160>

Returns the author of the current block.

Source

fn gas_limit(&self) -> u64

Returns the block gas limit.

Source

fn chain_id(&self) -> u64

Returns the chain id.

Source

fn max_value_size(&self) -> u32

Returns the maximum allowed size of a storage item.

Source

fn get_weight_price(&self, weight: Weight) -> U256

Returns the price for the specified amount of weight.

Source

fn gas_meter(&self) -> &GasMeter<Self::T>

Get an immutable reference to the nested gas meter.

Source

fn gas_meter_mut(&mut self) -> &mut GasMeter<Self::T>

Get a mutable reference to the nested gas meter.

Source

fn ecdsa_recover( &self, signature: &[u8; 65], message_hash: &[u8; 32], ) -> Result<[u8; 33], ()>

Recovers ECDSA compressed public key based on signature and message hash.

Source

fn sr25519_verify( &self, signature: &[u8; 64], message: &[u8], pub_key: &[u8; 32], ) -> bool

Verify a sr25519 signature.

Source

fn ecdsa_to_eth_address(&self, pk: &[u8; 33]) -> Result<[u8; 20], ()>

Returns Ethereum address from the ECDSA compressed public key.

Source

fn contract_info(&mut self) -> &mut ContractInfo<Self::T>

Tests sometimes need to modify and inspect the contract info directly.

Source

fn transient_storage(&mut self) -> &mut TransientStorage<Self::T>

Get a mutable reference to the transient storage. Useful in benchmarks when it is sometimes necessary to modify and inspect the transient storage directly.

Source

fn is_read_only(&self) -> bool

Check if running in read-only context.

Source

fn last_frame_output(&self) -> &ExecReturnValue

Returns an immutable reference to the output of the last executed call frame.

Source

fn last_frame_output_mut(&mut self) -> &mut ExecReturnValue

Returns a mutable reference to the output of the last executed call frame.

Provided Methods§

Source

fn charge(&mut self, weight: Weight) -> Result<ChargedAmount, DispatchError>

Charges the gas meter with the given weight.

Source

fn adjust_gas(&mut self, charged: ChargedAmount, actual_weight: Weight)

Source

fn address(&self) -> H160

Returns a reference to the H160 address of the current contract.

Implementors§