MockedExternal

Struct MockedExternal 

Source
pub struct MockedExternal {
    pub fake_trie: HashMap<Vec<u8>, Vec<u8>>,
    pub validators: HashMap<AccountId, Balance>,
    /* private fields */
}
Expand description

Emulates the trie and the mock handling code.

Fields§

§fake_trie: HashMap<Vec<u8>, Vec<u8>>§validators: HashMap<AccountId, Balance>

Implementations§

Source§

impl MockedExternal

Source

pub fn new() -> Self

Source

pub fn get_receipt_create_calls(&self) -> &Vec<Receipt>

Get calls to receipt create that were performed during contract call.

Trait Implementations§

Source§

impl Clone for MockedExternal

Source§

fn clone(&self) -> MockedExternal

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for MockedExternal

Source§

fn default() -> MockedExternal

Returns the “default value” for a type. Read more
Source§

impl External for MockedExternal

Source§

fn storage_set(&mut self, key: &[u8], value: &[u8]) -> Result<(), VMLogicError>

Write to the storage trie of the current account Read more
Source§

fn storage_get( &self, key: &[u8], ) -> Result<Option<Box<dyn ValuePtr>>, VMLogicError>

Reads from the storage trie of the current account Read more
Source§

fn storage_remove(&mut self, key: &[u8]) -> Result<(), VMLogicError>

Removes the key from the storage Read more
Source§

fn storage_remove_subtree(&mut self, prefix: &[u8]) -> Result<(), VMLogicError>

Removes all keys under given suffix in the storage. Read more
Source§

fn storage_has_key(&mut self, key: &[u8]) -> Result<bool, VMLogicError>

Check whether key exists. Returns Ok(true) if key exists or Ok(false) otherwise Read more
Source§

fn create_receipt( &mut self, receipt_indices: Vec<u64>, receiver_id: String, ) -> Result<u64, VMLogicError>

Creates a receipt which will be executed after receipt_indices Read more
Source§

fn append_action_create_account( &mut self, receipt_index: u64, ) -> Result<(), VMLogicError>

Attaches an Action::CreateAccount action to an existing receipt Read more
Source§

fn append_action_deploy_contract( &mut self, receipt_index: u64, code: Vec<u8>, ) -> Result<(), VMLogicError>

Attaches an Action::DeployContract action to an existing receipt Read more
Source§

fn append_action_function_call( &mut self, receipt_index: u64, method_name: Vec<u8>, arguments: Vec<u8>, attached_deposit: u128, prepaid_gas: u64, ) -> Result<(), VMLogicError>

Attaches an Action::FunctionCall action to an existing receipt Read more
Source§

fn append_action_transfer( &mut self, receipt_index: u64, amount: u128, ) -> Result<(), VMLogicError>

Attaches an TransferAction action to an existing receipt Read more
Source§

fn append_action_stake( &mut self, receipt_index: u64, stake: u128, public_key: Vec<u8>, ) -> Result<(), VMLogicError>

Attaches an StakeAction action to an existing receipt Read more
Source§

fn append_action_add_key_with_full_access( &mut self, receipt_index: u64, public_key: Vec<u8>, nonce: u64, ) -> Result<(), VMLogicError>

Attaches an AddKeyAction action to an existing receipt Read more
Source§

fn append_action_add_key_with_function_call( &mut self, receipt_index: u64, public_key: Vec<u8>, nonce: u64, allowance: Option<u128>, receiver_id: String, method_names: Vec<Vec<u8>>, ) -> Result<(), VMLogicError>

Attaches an AddKeyAction action to an existing receipt with AccessKeyPermission::FunctionCall Read more
Source§

fn append_action_delete_key( &mut self, receipt_index: u64, public_key: Vec<u8>, ) -> Result<(), VMLogicError>

Attaches an DeleteKeyAction action to an existing receipt Read more
Source§

fn append_action_delete_account( &mut self, receipt_index: u64, beneficiary_id: String, ) -> Result<(), VMLogicError>

Attaches an DeleteAccountAction action to an existing receipt Read more
Source§

fn get_touched_nodes_count(&self) -> u64

Returns amount of touched trie nodes by storage operations
Source§

fn reset_touched_nodes_counter(&mut self)

Resets amount of touched trie nodes by storage operations
Source§

fn validator_stake( &self, account_id: &AccountId, ) -> Result<Option<Balance>, VMLogicError>

Returns the validator stake for given account in the current epoch. If the account is not a validator, returns None.
Source§

fn validator_total_stake(&self) -> Result<Balance, VMLogicError>

Returns total stake of validators in the current epoch.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.