pub trait VMHooksContext: Debug {
Show 23 methods
// Required methods
unsafe fn memory_load(&self, offset: MemPtr, length: MemLength) -> Vec<u8> ⓘ;
unsafe fn memory_store(&self, mem_ptr: MemPtr, data: &[u8]);
fn m_types_lock(&self) -> MutexGuard<'_, ManagedTypeContainer>;
fn gas_schedule(&self) -> &GasSchedule;
fn use_gas(&mut self, gas: u64) -> Result<(), VMHooksEarlyExit>;
fn input_ref(&self) -> &TxInput;
fn random_next_bytes(&self, length: usize) -> Vec<u8> ⓘ;
fn result_lock(&self) -> MutexGuard<'_, TxResult>;
fn storage_read_any_address(
&self,
address: &VMAddress,
key: &[u8],
) -> Vec<u8> ⓘ;
fn storage_write(
&mut self,
key: &[u8],
value: &[u8],
) -> Result<(), VMHooksEarlyExit>;
fn get_block_config(&self) -> &BlockConfig;
fn back_transfers_lock(&self) -> MutexGuard<'_, BackTransfers>;
fn account_data(&self, address: &VMAddress) -> Option<AccountData>;
fn account_code(&self, address: &VMAddress) -> Vec<u8> ⓘ;
fn perform_async_call(
&mut self,
to: VMAddress,
egld_value: BigUint,
func_name: TxFunctionName,
args: Vec<Vec<u8>>,
) -> Result<(), VMHooksEarlyExit>;
fn perform_execute_on_dest_context(
&mut self,
to: VMAddress,
egld_value: BigUint,
func_name: TxFunctionName,
args: Vec<Vec<u8>>,
) -> Result<Vec<Vec<u8>>, VMHooksEarlyExit>;
fn perform_execute_on_dest_context_readonly(
&mut self,
to: VMAddress,
func_name: TxFunctionName,
arguments: Vec<Vec<u8>>,
) -> Result<Vec<Vec<u8>>, VMHooksEarlyExit>;
fn perform_deploy(
&mut self,
egld_value: BigUint,
contract_code: Vec<u8>,
code_metadata: VMCodeMetadata,
args: Vec<Vec<u8>>,
) -> Result<(VMAddress, Vec<Vec<u8>>), VMHooksEarlyExit>;
fn perform_transfer_execute(
&mut self,
to: VMAddress,
egld_value: BigUint,
func_name: TxFunctionName,
arguments: Vec<Vec<u8>>,
) -> Result<(), VMHooksEarlyExit>;
// Provided methods
fn current_address(&self) -> &VMAddress { ... }
fn tx_hash(&self) -> H256 { ... }
fn push_tx_log(&self, tx_log: TxLog) { ... }
fn storage_read(&self, key: &[u8]) -> Vec<u8> ⓘ { ... }
}
Expand description
Abstracts away the borrowing of a managed types structure.
Required Methods§
Sourceunsafe fn memory_load(&self, offset: MemPtr, length: MemLength) -> Vec<u8> ⓘ
unsafe fn memory_load(&self, offset: MemPtr, length: MemLength) -> Vec<u8> ⓘ
Loads a slice of memory from the instance.
§Safety
The offset and the length must point to valid instance memory.
Sourceunsafe fn memory_store(&self, mem_ptr: MemPtr, data: &[u8])
unsafe fn memory_store(&self, mem_ptr: MemPtr, data: &[u8])
fn m_types_lock(&self) -> MutexGuard<'_, ManagedTypeContainer>
fn gas_schedule(&self) -> &GasSchedule
fn use_gas(&mut self, gas: u64) -> Result<(), VMHooksEarlyExit>
fn input_ref(&self) -> &TxInput
Sourcefn random_next_bytes(&self, length: usize) -> Vec<u8> ⓘ
fn random_next_bytes(&self, length: usize) -> Vec<u8> ⓘ
Random number generator, based on the blockchain randomness source.
fn result_lock(&self) -> MutexGuard<'_, TxResult>
fn storage_read_any_address(&self, address: &VMAddress, key: &[u8]) -> Vec<u8> ⓘ
fn storage_write( &mut self, key: &[u8], value: &[u8], ) -> Result<(), VMHooksEarlyExit>
fn get_block_config(&self) -> &BlockConfig
fn back_transfers_lock(&self) -> MutexGuard<'_, BackTransfers>
Sourcefn account_data(&self, address: &VMAddress) -> Option<AccountData>
fn account_data(&self, address: &VMAddress) -> Option<AccountData>
For ownership reasons, needs to return a clone.
Can be optimized, but is not a priority right now.