pub trait ContractHookApi<BigInt, BigUint>: Sized + CryptoApi
where BigInt: BigIntApi<BigUint> + 'static, BigUint: BigUintApi + 'static,
{ type Storage: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static; type CallValue: CallValueApi<BigUint> + ErrorApi + Clone + 'static; type SendApi: SendApi<BigUint> + Clone + 'static;
Show 26 methods // Required methods fn get_storage_raw(&self) -> Self::Storage; fn call_value(&self) -> Self::CallValue; fn send(&self) -> Self::SendApi; fn get_sc_address(&self) -> Address; fn get_owner_address(&self) -> Address; fn get_shard_of_address(&self, address: &Address) -> u32; fn is_smart_contract(&self, address: &Address) -> bool; fn get_caller(&self) -> Address; fn get_balance(&self, address: &Address) -> BigUint; fn get_tx_hash(&self) -> H256; fn get_gas_left(&self) -> u64; fn get_block_timestamp(&self) -> u64; fn get_block_nonce(&self) -> u64; fn get_block_round(&self) -> u64; fn get_block_epoch(&self) -> u64; fn get_block_random_seed(&self) -> Box<[u8; 48]>; fn get_prev_block_timestamp(&self) -> u64; fn get_prev_block_nonce(&self) -> u64; fn get_prev_block_round(&self) -> u64; fn get_prev_block_epoch(&self) -> u64; fn get_prev_block_random_seed(&self) -> Box<[u8; 48]>; fn get_current_dct_nft_nonce(&self, address: &Address, token: &[u8]) -> u64; fn get_dct_balance( &self, address: &Address, token: &[u8], nonce: u64 ) -> BigUint; fn get_dct_token_data( &self, address: &Address, token: &[u8], nonce: u64 ) -> DctTokenData<BigUint>; // Provided methods fn get_sc_balance(&self) -> BigUint { ... } fn storage_load_cumulated_validator_reward(&self) -> BigUint { ... }
}
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.

Required Associated Types§

source

type Storage: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static

Abstracts the lower-level storage functionality.

source

type CallValue: CallValueApi<BigUint> + ErrorApi + Clone + 'static

Abstracts the call value handling at the beginning of a function call.

source

type SendApi: SendApi<BigUint> + Clone + 'static

Abstracts the sending of MOAX & DCT transactions, as well as async calls.

Required Methods§

source

fn get_storage_raw(&self) -> Self::Storage

Gateway into the lower-level storage functionality. Storage related annotations make use of this. Using it directly is not recommended.

source

fn call_value(&self) -> Self::CallValue

Gateway into the call value retrieval functionality. The payment annotations should normally be the ones to handle this, but the developer is also given direct access to the API.

source

fn send(&self) -> Self::SendApi

Gateway to the functionality related to sending transactions from the current contract.

source

fn get_sc_address(&self) -> Address

source

fn get_owner_address(&self) -> Address

source

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

source

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

source

fn get_caller(&self) -> Address

source

fn get_balance(&self, address: &Address) -> BigUint

source

fn get_tx_hash(&self) -> H256

source

fn get_gas_left(&self) -> u64

source

fn get_block_timestamp(&self) -> u64

source

fn get_block_nonce(&self) -> u64

source

fn get_block_round(&self) -> u64

source

fn get_block_epoch(&self) -> u64

source

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

source

fn get_prev_block_timestamp(&self) -> u64

source

fn get_prev_block_nonce(&self) -> u64

source

fn get_prev_block_round(&self) -> u64

source

fn get_prev_block_epoch(&self) -> u64

source

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

source

fn get_current_dct_nft_nonce(&self, address: &Address, token: &[u8]) -> u64

source

fn get_dct_balance( &self, address: &Address, token: &[u8], nonce: u64 ) -> BigUint

source

fn get_dct_token_data( &self, address: &Address, token: &[u8], nonce: u64 ) -> DctTokenData<BigUint>

Provided Methods§

Object Safety§

This trait is not object safe.

Implementors§