Skip to main content

BlockchainWrapper

Struct BlockchainWrapper 

Source
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 new() -> Self

Source§

impl<A> BlockchainWrapper<A>

Source

pub fn get_caller_legacy(&self) -> Address

👎Deprecated since 0.41.0: Please use method get_caller instead.
Source

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

Source

pub fn get_sc_address_legacy(&self) -> Address

👎Deprecated since 0.41.0: Please use method get_sc_address instead.
Source

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

Source

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

Source

pub fn check_caller_is_owner(&self)

Source

pub fn check_caller_is_user_account(&self)

Source

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

👎Deprecated since 0.41.0: Please use method get_shard_of_address instead.
Source

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

Source

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

👎Deprecated since 0.41.0: Please use method is_smart_contract instead.
Source

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

Source

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

👎Deprecated since 0.41.0: Please use method get_balance instead.
Source

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

Source

pub fn get_code_metadata(&self, address: &ManagedAddress<A>) -> CodeMetadata

Source

pub fn get_code_hash(&self, address: &ManagedAddress<A>) -> ManagedBuffer<A>

Source

pub fn is_builtin_function(&self, function_name: &ManagedBuffer<A>) -> bool

Source

pub fn get_sc_balance( &self, token_id: impl AsRef<TokenId<A>>, nonce: u64, ) -> BigUint<A>

Source

pub fn get_state_root_hash_legacy(&self) -> H256

👎Deprecated since 0.41.0: Please use method get_state_root_hash instead.
Source

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

Source

pub fn get_tx_hash_legacy(&self) -> H256

👎Deprecated since 0.41.0: Please use method get_tx_hash instead.
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

👎Deprecated since 0.63.0: Use get_block_timestamp_seconds instead, it returns a properly typed timestamps

Block timestamp, in seconds.

Source

pub fn get_block_timestamp_seconds(&self) -> TimestampSeconds

Block timestamp, in seconds.

Source

pub fn get_block_timestamp_ms(&self) -> u64

👎Deprecated since 0.63.0: Use get_block_timestamp_millis instead, it returns a properly typed timestamps

Block timestamp, in milliseconds.

Source

pub fn get_block_timestamp_millis(&self) -> TimestampMillis

Block timestamp, in milliseconds.

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_round_time_ms(&self) -> u64

👎Deprecated since 0.63.0: Use get_block_round_time_millis instead, it returns a properly typed duration

Block round time, in milliseconds.

Source

pub fn get_block_round_time_millis(&self) -> DurationMillis

Block round time, in milliseconds.

Source

pub fn epoch_start_block_timestamp_ms(&self) -> u64

👎Deprecated since 0.63.0: Use epoch_start_block_timestamp_millis instead, it returns a properly typed timestamps

Epoch start block timestamp, in milliseconds.

Source

pub fn epoch_start_block_timestamp_millis(&self) -> TimestampMillis

👎Deprecated since 0.63.1: Renamed to get_epoch_start_block_timestamp_millis
Source

pub fn get_epoch_start_block_timestamp_millis(&self) -> TimestampMillis

Epoch start block timestamp, in milliseconds.

Source

pub fn get_epoch_start_block_nonce(&self) -> u64

Source

pub fn epoch_start_block_nonce(&self) -> u64

👎Deprecated since 0.63.1: Renamed to get_epoch_start_block_nonce
Source

pub fn get_epoch_start_block_round(&self) -> u64

Source

pub fn epoch_start_block_round(&self) -> u64

👎Deprecated since 0.63.1: Renamed to get_epoch_start_block_round
Source

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

👎Deprecated since 0.41.0: Please use method get_block_random_seed instead.
Source

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

Source

pub fn get_prev_block_timestamp(&self) -> u64

👎Deprecated since 0.63.0: Use get_prev_block_timestamp_seconds instead, it returns a properly typed timestamps

Previous block timestamp, in seconds.

Source

pub fn get_prev_block_timestamp_seconds(&self) -> TimestampSeconds

Previous block timestamp, in seconds.

Source

pub fn get_prev_block_timestamp_ms(&self) -> u64

👎Deprecated since 0.63.0: Use get_prev_block_timestamp_millis instead, it returns a properly typed timestamps

Previous block timestamp, in milliseconds.

Source

pub fn get_prev_block_timestamp_millis(&self) -> TimestampMillis

Previous block timestamp, in milliseconds.

Source

pub fn get_prev_block_nonce(&self) -> u64

Previous block nonce.

Source

pub fn get_prev_block_round(&self) -> u64

Previous block round.

Source

pub fn get_prev_block_epoch(&self) -> u64

Source

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

👎Deprecated since 0.41.0: Please use method get_prev_block_random_seed instead.
Source

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

Source

pub fn get_current_esdt_nft_nonce( &self, address: &ManagedAddress<A>, token_id: &EsdtTokenIdentifier<A>, ) -> u64

Source

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

Source§

impl<A> BlockchainWrapper<A>

Source

pub fn get_native_token(&self) -> ManagedRef<'static, A, TokenId<A>>

The native token of the given chain. It can currently only return EGLD-000000.

Source

pub fn is_native_token(&self, token_id: &TokenId<A>) -> bool

Checks if a token is the native one on the chain. Currently only returns true for EGLD-000000.

Source§

impl<A> BlockchainWrapper<A>

Source

pub fn get_esdt_token_type( &self, address: &ManagedAddress<A>, token_id: &EgldOrEsdtTokenIdentifier<A>, nonce: u64, ) -> EsdtTokenType

Source

pub fn get_esdt_token_data( &self, address: &ManagedAddress<A>, token_id: &EsdtTokenIdentifier<A>, nonce: u64, ) -> EsdtTokenData<A>

Source

pub fn get_back_transfers_legacy(&self) -> BackTransfersLegacy<A>

👎Deprecated since 0.59.0: Does not handle multi-transfers properly, use get_back_transfers instead

Retrieves back-transfers from the VM, after a contract call.

Works after:

  • synchronous calls
  • asynchronous calls too, in callbacks.
Source

pub fn get_back_transfers(&self) -> BackTransfers<A>

Retrieves all back-transfers as a collection of payments.

Covers all cases, including EGLD sent via multi-transfer.

Source

pub fn reset_back_transfers(&self)

Clears back transfers by retrieving current back transfers and ignoring result.

Source

pub fn get_token_attributes<T: TopDecode>( &self, token_id: &EsdtTokenIdentifier<A>, token_nonce: u64, ) -> T

Retrieves and deserializes token attributes from the SC account, with given token identifier and nonce.

Source

pub fn is_esdt_frozen( &self, address: &ManagedAddress<A>, token_id: &EsdtTokenIdentifier<A>, nonce: u64, ) -> bool

Source

pub fn is_esdt_paused(&self, token_id: &EsdtTokenIdentifier<A>) -> bool

Source

pub fn is_esdt_limited_transfer( &self, token_id: &EsdtTokenIdentifier<A>, ) -> bool

Source

pub fn get_esdt_local_roles( &self, token_id: &EsdtTokenIdentifier<A>, ) -> EsdtLocalRoleFlags

Source§

impl<A> BlockchainWrapper<A>

Source

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

Retrieves validator rewards, as set by the protocol.

Source

pub fn token_has_transfer_role( &self, token_identifier: EsdtTokenIdentifier<A>, ) -> bool

Trait Implementations§

Source§

impl<A> Default for BlockchainWrapper<A>

Source§

fn default() -> BlockchainWrapper<A>

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

Auto Trait Implementations§

§

impl<A> Freeze for BlockchainWrapper<A>

§

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> UnsafeUnpin for BlockchainWrapper<A>

§

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<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.
Source§

impl<T, U> TypeAbiFrom<TypeAbiUniversalInput<T>> for U