Struct evm_exec_utils::exec::Executor
source · [−]pub struct Executor<'v> { /* private fields */ }Expand description
Stateful EVM executor backed by an in-memory storage.
Implementations
sourceimpl<'v> Executor<'v>
impl<'v> Executor<'v>
sourcepub fn storage(&self) -> &MemoryBackend<'v>
pub fn storage(&self) -> &MemoryBackend<'v>
Return a reference to the in-memory storage backend.
sourcepub fn account_balance(&self, address: H160) -> Option<U256>
pub fn account_balance(&self, address: H160) -> Option<U256>
Return the balance of the account at the specified address if one exists.
sourcepub fn mint(&mut self, address: H160, eth_amount: U256) -> Result<(), MintError>
pub fn mint(&mut self, address: H160, eth_amount: U256) -> Result<(), MintError>
Add balance to the specified account. Intended to used for testing.
Note: this will create a new account at the given address if one does not exist.
sourcepub fn new(vicinity: &'v MemoryVicinity) -> Self
pub fn new(vicinity: &'v MemoryVicinity) -> Self
Create a new Executor with an empty in-memory storage backend.
sourcepub fn create_contract(
&mut self,
caller_address: H160,
contract_code: Vec<u8>
) -> Result<H160, ExitReason>
pub fn create_contract(
&mut self,
caller_address: H160,
contract_code: Vec<u8>
) -> Result<H160, ExitReason>
Create a contract and return the contract address if successful.
sourcepub fn transfer_eth(
&mut self,
sender_address: H160,
receipient_address: H160,
eth_amount: U256
) -> Result<(), ExitReason>
pub fn transfer_eth(
&mut self,
sender_address: H160,
receipient_address: H160,
eth_amount: U256
) -> Result<(), ExitReason>
Transfer some ETH from one account to another.
sourcepub fn call_function(
&mut self,
caller_address: H160,
contract_address: H160,
eth_amount: U256,
method_sig: &str,
method_args: &[u8]
) -> (ExitReason, Vec<u8>)
pub fn call_function(
&mut self,
caller_address: H160,
contract_address: H160,
eth_amount: U256,
method_sig: &str,
method_args: &[u8]
) -> (ExitReason, Vec<u8>)
Call a contract method with the given signature.
The signature is represented by a string consisting of the name of the method and
a list of parameter types (e.g. foo(uint256,uint256)).
sourcepub fn execute_custom_code(
&mut self,
caller_address: H160,
contract_address: H160,
code: Vec<u8>,
data: Vec<u8>
) -> ExecuteResult
pub fn execute_custom_code(
&mut self,
caller_address: H160,
contract_address: H160,
code: Vec<u8>,
data: Vec<u8>
) -> ExecuteResult
Execute custom EVM opecodes. You are still required to specify a caller address and a contract address, even though a contract may not exist at the specified address.
Auto Trait Implementations
impl<'v> RefUnwindSafe for Executor<'v>
impl<'v> Send for Executor<'v>
impl<'v> Sync for Executor<'v>
impl<'v> Unpin for Executor<'v>
impl<'v> UnwindSafe for Executor<'v>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more