pub trait ContractSelfApi<BigInt, BigUint>: Sized
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; type BlockchainApi: BlockchainApi<BigUint> + Clone + 'static; type CryptoApi: CryptoApi + Clone + 'static; // Required methods fn get_storage_raw(&self) -> Self::Storage; fn call_value(&self) -> Self::CallValue; fn send(&self) -> Self::SendApi; fn blockchain(&self) -> Self::BlockchainApi; fn crypto(&self) -> Self::CryptoApi; // Provided method 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.

source

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

source

type CryptoApi: CryptoApi + Clone + 'static

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 blockchain(&self) -> Self::BlockchainApi

Gateway blockchain info related to the current transaction and to accounts.

source

fn crypto(&self) -> Self::CryptoApi

Stateless crypto functions provided by the Arwen VM.

Provided Methods§

source

fn storage_load_cumulated_validator_reward(&self) -> BigUint

Retrieves validator rewards, as set by the protocol. TODO: move to the storage API, once BigUint gets refactored

Object Safety§

This trait is not object safe.

Implementors§