Sandbox

Struct Sandbox 

Source
pub struct Sandbox {
    pub input: Option<Vec<u8>>,
    pub ret: Option<Vec<u8>>,
    pub ext: Ext,
    pub tx: Transaction,
    pub cache: Rc<RefCell<dyn Frame<Memory>>>,
    pub events: Vec<(Vec<[u8; 32]>, Vec<u8>)>,
    pub ri: Vec<SealCall<Self>>,
}
Expand description

The runtime of ink! machine

Fields§

§input: Option<Vec<u8>>§ret: Option<Vec<u8>>§ext: Ext§tx: Transaction§cache: Rc<RefCell<dyn Frame<Memory>>>§events: Vec<(Vec<[u8; 32]>, Vec<u8>)>§ri: Vec<SealCall<Self>>

Implementations§

Source§

impl Sandbox

Source

pub fn deposit_event(&mut self, topics: Vec<[u8; 32]>, data: Vec<u8>)

Source

pub fn block_number(&self) -> [u8; 32]

Source

pub fn max_value_size(&self) -> u32

Source

pub fn get_weight_price(&self, weight: u64) -> Vec<u8>

Source§

impl Sandbox

Source

pub fn tombstone_deposit(&self) -> [u8; 32]

Source

pub fn rent_allowance(&self) -> [u8; 32]

Source

pub fn set_rent_allowance(&mut self, rent_allowence: [u8; 32])

Source

pub fn rent_params(&self) -> Vec<u8>

Source§

impl Sandbox

Source

pub fn invoke( &mut self, code_hash: [u8; 32], method: &str, data: Vec<u8>, ) -> Result<([u8; 32], ReturnData)>

Source

pub fn instantiate( &mut self, code_hash: [u8; 32], gas_meter: &mut GasMeter, data: Vec<u8>, salt: &[u8], ) -> Result<([u8; 32], ReturnData)>

Source

pub fn call(&mut self, code_hash: [u8; 32], data: Vec<u8>) -> Result<ReturnData>

Call other contract

Source§

impl Sandbox

Source

pub fn read_sandbox_memory(&self, ptr: u32, len: u32) -> Result<Vec<u8>>

Read designated chunk from the sandbox memory.

Source

pub fn read_sandbox_memory_into_buf( &self, ptr: u32, buf: &mut [u8], ) -> Result<()>

Read designated chunk from the sandbox into the supplied buffer

Source

pub fn read_sandbox_memory_as<D: Decode>( &mut self, ptr: u32, len: u32, ) -> Result<D>

Read designated chunk from the sandbox memory and attempt to decode into the specified type.

Source

pub fn write_sandbox_memory(&mut self, ptr: u32, buf: &[u8]) -> Result<()>

Write the given buffer to the designated location in the sandbox memory.

Source

pub fn write_sandbox_output( &mut self, out_ptr: u32, out_len_ptr: u32, buf: &[u8], ) -> Result<()>

Write the given buffer and its length to the designated locations in sandbox memory

buf -> memory

Source§

impl Sandbox

Source

pub fn restore_to( &mut self, dest: [u8; 32], code_hash: [u8; 32], rent_allowance: u64, delta: Vec<[u8; 32]>, ) -> Result<(u32, u32)>

Source§

impl Sandbox

Source

pub fn schedule(&self) -> Vec<u8>

Source§

impl Sandbox

Source

pub fn get_storage(&self, key: &StorageKey) -> Result<Option<Vec<u8>>>

Get storage

Source

pub fn set_storage(&mut self, key: StorageKey, value: Vec<u8>) -> Result<()>

Get storage

Source§

impl Sandbox

Source

pub fn terminate(&mut self, beneficiary: [u8; 32]) -> Result<u32>

Source§

impl Sandbox

Source

pub fn transfer(&mut self, to: [u8; 32], value: u64) -> Result<()>

Transfer value to account

Source

pub fn caller(&self) -> [u8; 32]

Source

pub fn address(&self) -> [u8; 32]

Source

pub fn balance(&self) -> Vec<u8>

Source

pub fn value_transferred(&self) -> Vec<u8>

Source

pub fn now(&self) -> [u8; 32]

Source

pub fn minimum_balance(&self) -> Vec<u8>

Source§

impl Sandbox

Source

pub fn new( cache: Rc<RefCell<impl Frame<Memory> + 'static>>, ri: Vec<SealCall<Self>>, ) -> Sandbox

New sandbox

Source

pub fn prepare(&mut self, code_hash: [u8; 32]) -> Result<()>

Preare a new frame

Source

pub fn load_metadata(&mut self, meta: &Metadata) -> Result<[u8; 32]>

Load metadata to cache

Trait Implementations§

Source§

impl Ext<Memory, Vec<(&'static str, &'static str, fn(&mut Sandbox, &[Value]) -> Result<Option<Value>, Error>)>> for Sandbox

Source§

fn code(&self, hash: [u8; 32]) -> Option<Vec<u8>>

Source§

fn memory(&self) -> Option<Memory>

Provide memory
Source§

fn seal_call(&self) -> Vec<SealCall<Self>>

Provide seal calls

Auto Trait Implementations§

§

impl Freeze for Sandbox

§

impl !RefUnwindSafe for Sandbox

§

impl !Send for Sandbox

§

impl !Sync for Sandbox

§

impl Unpin for Sandbox

§

impl !UnwindSafe for Sandbox

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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, 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.