NeoRuntime

Struct NeoRuntime 

Source
pub struct NeoRuntime {
    execution_context: ExecutionContext,
    state_manager: StateManager,
    storage_manager: StorageManager,
    vm_bridge: VMBridge,
    gas_tracker: GasTracker,
}
Expand description

Neo runtime for executing compiled Yul contracts

Fields§

§execution_context: ExecutionContext§state_manager: StateManager§storage_manager: StorageManager§vm_bridge: VMBridge§gas_tracker: GasTracker

Implementations§

§

impl NeoRuntime

pub fn override_block_height(&mut self, height: u64)

Override block height for the next execution.

pub fn override_timestamp(&mut self, timestamp: u64)

Override timestamp for the next execution.

pub fn override_caller_account( &mut self, account: &str, ) -> Result<(), RuntimeError>

Override caller script hash for the next execution.

pub fn execute_with_overrides( &mut self, bytecode: &[u8], input: &[u8], overrides: &ExecutionOverrides, ) -> Result<ExecutionResult, RuntimeError>

Execute bytecode with optional metadata overrides applied to this invocation.

pub fn new(config: RuntimeConfig) -> Result<Self, RuntimeError>

Create new runtime instance

fn capture_metadata(&self) -> ExecutionMetadata

pub fn execute( &mut self, bytecode: &[u8], input: &[u8], ) -> Result<ExecutionResult, RuntimeError>

Execute bytecode with given input

pub fn execute_with_tokens( &mut self, bytecode: &[u8], input: &[u8], tokens: &[MethodToken], ) -> Result<ExecutionResult, RuntimeError>

Execute bytecode with a NEF method token table.

This is required when the script contains the CALLT opcode (0x37).

pub fn call_function( &mut self, bytecode: &[u8], function_name: &str, args: &[StackItem], ) -> Result<ExecutionResult, RuntimeError>

Call specific function with arguments

§

impl NeoRuntime

pub fn deploy_contract( &mut self, bytecode: &[u8], constructor_args: &[u8], ) -> Result<String, RuntimeError>

Deploy contract and return address

fn generate_contract_address(&self) -> Result<String, RuntimeError>

§

impl NeoRuntime

pub fn get_state_snapshot(&self) -> StateSnapshot

Get current state of the runtime

pub fn restore_state( &mut self, snapshot: StateSnapshot, ) -> Result<(), RuntimeError>

Restore state from snapshot

pub fn get_storage( &mut self, account: &str, key: &[u8], ) -> Result<Option<Vec<u8>>, RuntimeError>

Get storage value for account and key

pub fn set_storage( &mut self, account: &str, key: &[u8], value: &[u8], ) -> Result<(), RuntimeError>

Set storage value for account and key

pub fn get_balance(&self, account: &str) -> Result<u64, RuntimeError>

Get account balance

pub fn set_balance( &mut self, account: &str, balance: u64, ) -> Result<(), RuntimeError>

Set account balance

pub fn get_statistics(&self) -> RuntimeStatistics

Get runtime statistics

§

impl NeoRuntime

pub fn enable_debugging(&mut self)

Enable debugging mode

pub fn disable_debugging(&mut self)

Disable debugging mode

pub fn set_breakpoint(&mut self, instruction_pointer: u32)

Set breakpoint at instruction

pub fn remove_breakpoint(&mut self, instruction_pointer: u32)

Remove breakpoint

pub fn step(&mut self) -> Result<StepResult, RuntimeError>

Step through execution

§

impl NeoRuntime

fn prepare_function_call( &self, function_name: &str, args: &[StackItem], ) -> Result<Vec<u8>, RuntimeError>

fn calculate_function_selector( &self, function_name: &str, ) -> Result<[u8; 4], RuntimeError>

Trait Implementations§

Source§

impl Debug for NeoRuntime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.