pub struct BlockchainWrapper<A>{ /* private fields */ }
Expand description

Interface to be used by the actual smart contract code.

Note: contracts and the api are not mutable. They simply pass on/retrieve data to/from the protocol. When mocking the blockchain state, we use the Rc/RefCell pattern to isolate mock state mutability from the contract interface.

Implementations§

source§

impl<A> BlockchainWrapper<A>

source

pub fn get_caller_legacy(&self) -> Address

source

pub fn get_caller(&self) -> ManagedAddress<A>

source

pub fn get_sc_address_legacy(&self) -> Address

source

pub fn get_sc_address(&self) -> ManagedAddress<A>

source

pub fn get_owner_address_legacy(&self) -> Address

source

pub fn get_owner_address(&self) -> ManagedAddress<A>

source

pub fn check_caller_is_owner(&self)

source

pub fn get_shard_of_address_legacy(&self, address: &Address) -> u32

source

pub fn get_shard_of_address(&self, address: &ManagedAddress<A>) -> u32

source

pub fn is_smart_contract_legacy(&self, address: &Address) -> bool

source

pub fn is_smart_contract(&self, address: &ManagedAddress<A>) -> bool

source

pub fn get_balance_legacy(&self, address: &Address) -> BigUint<A>

source

pub fn get_balance(&self, address: &ManagedAddress<A>) -> BigUint<A>

source

pub fn get_sc_balance( &self, token: &TokenIdentifier<A>, nonce: u64 ) -> BigUint<A>

source

pub fn get_state_root_hash_legacy(&self) -> H256

source

pub fn get_state_root_hash(&self) -> ManagedByteArray<A, 32>

source

pub fn get_tx_hash_legacy(&self) -> H256

source

pub fn get_tx_hash(&self) -> ManagedByteArray<A, 32>

source

pub fn get_gas_left(&self) -> u64

source

pub fn get_block_timestamp(&self) -> u64

source

pub fn get_block_nonce(&self) -> u64

source

pub fn get_block_round(&self) -> u64

source

pub fn get_block_epoch(&self) -> u64

source

pub fn get_block_random_seed_legacy(&self) -> Box<[u8; 48]>

source

pub fn get_block_random_seed(&self) -> ManagedByteArray<A, 48>

source

pub fn get_prev_block_timestamp(&self) -> u64

source

pub fn get_prev_block_nonce(&self) -> u64

source

pub fn get_prev_block_round(&self) -> u64

source

pub fn get_prev_block_epoch(&self) -> u64

source

pub fn get_prev_block_random_seed_legacy(&self) -> Box<[u8; 48]>

source

pub fn get_prev_block_random_seed(&self) -> ManagedByteArray<A, 48>

source

pub fn get_current_dct_nft_nonce( &self, address: &Address, token_id: &TokenIdentifier<A> ) -> u64

source

pub fn get_dct_balance( &self, address: &ManagedAddress<A>, token_id: &TokenIdentifier<A>, nonce: u64 ) -> BigUint<A>

source

pub fn get_dct_token_data( &self, address: &ManagedAddress<A>, token_id: &TokenIdentifier<A>, nonce: u64 ) -> DctTokenData<A>

source

pub fn get_cumulated_validator_rewards(&self) -> BigUint<A>

Retrieves validator rewards, as set by the protocol.

source

pub fn get_dct_local_roles( &self, token_id: &TokenIdentifier<A> ) -> Vec<DctLocalRole>

Retrieves local roles for the token, by reading protected storage. TODO: rewrite using managed types

Auto Trait Implementations§

§

impl<A> RefUnwindSafe for BlockchainWrapper<A>
where A: RefUnwindSafe,

§

impl<A> Send for BlockchainWrapper<A>
where A: Send,

§

impl<A> Sync for BlockchainWrapper<A>
where A: Sync,

§

impl<A> Unpin for BlockchainWrapper<A>
where A: Unpin,

§

impl<A> UnwindSafe for BlockchainWrapper<A>
where A: UnwindSafe,

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<M, F> ManagedFrom<M, F> for F
where M: ManagedTypeApi,

source§

fn managed_from(_: M, t: F) -> F

source§

impl<M, F, T> ManagedInto<M, T> for F
where T: ManagedFrom<M, F>, M: ManagedTypeApi,

source§

fn managed_into(self, api: M) -> T

source§

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

§

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>,

§

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.