pub trait ExtWithInfo: PrecompileExt {
// Required methods
fn get_storage(&mut self, key: &Key) -> Option<Vec<u8>>;
fn get_storage_size(&mut self, key: &Key) -> Option<u32>;
fn set_storage(
&mut self,
key: &Key,
value: Option<Vec<u8>>,
take_old: bool,
) -> Result<WriteOutcome, DispatchError>;
fn charge_storage(&mut self, diff: &Diff);
fn instantiate(
&mut self,
gas_limit: Weight,
deposit_limit: U256,
code: Code,
value: U256,
input_data: Vec<u8>,
salt: Option<&[u8; 32]>,
) -> Result<H160, ExecError>;
}Expand description
Environment functions which are available to pre-compiles with HAS_CONTRACT_INFO = true.
Required Methods§
Sourcefn get_storage(&mut self, key: &Key) -> Option<Vec<u8>>
fn get_storage(&mut self, key: &Key) -> Option<Vec<u8>>
Returns the storage entry of the executing account by the given key.
Returns None if the key wasn’t previously set by set_storage or
was deleted.
Sourcefn get_storage_size(&mut self, key: &Key) -> Option<u32>
fn get_storage_size(&mut self, key: &Key) -> Option<u32>
Returns Some(len) (in bytes) if a storage item exists at key.
Returns None if the key wasn’t previously set by set_storage or
was deleted.
Sourcefn set_storage(
&mut self,
key: &Key,
value: Option<Vec<u8>>,
take_old: bool,
) -> Result<WriteOutcome, DispatchError>
fn set_storage( &mut self, key: &Key, value: Option<Vec<u8>>, take_old: bool, ) -> Result<WriteOutcome, DispatchError>
Sets the storage entry by the given key to the specified value. If value is None then
the storage entry is deleted.
Sourcefn charge_storage(&mut self, diff: &Diff)
fn charge_storage(&mut self, diff: &Diff)
Charges diff from the meter.
Sourcefn instantiate(
&mut self,
gas_limit: Weight,
deposit_limit: U256,
code: Code,
value: U256,
input_data: Vec<u8>,
salt: Option<&[u8; 32]>,
) -> Result<H160, ExecError>
fn instantiate( &mut self, gas_limit: Weight, deposit_limit: U256, code: Code, value: U256, input_data: Vec<u8>, salt: Option<&[u8; 32]>, ) -> Result<H160, ExecError>
Instantiate a contract from the given code.
Returns the original code size of the called contract.
The newly created account will be associated with code. value specifies the amount of
value transferred from the caller to the newly created account.