pub trait ContractBase: Sized {
    type BigUint: BigUintApi + 'static;
    type BigInt: BigIntApi + 'static;
    type EllipticCurve: EllipticCurveApi<BigUint = Self::BigUint> + 'static;
    type Storage: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static;
    type CallValue: CallValueApi<AmountType = Self::BigUint> + ErrorApi + Clone + 'static;
    type SendApi: SendApi<AmountType = Self::BigUint, ProxyBigInt = Self::BigInt, ProxyEllipticCurve = Self::EllipticCurve, ProxyStorage = Self::Storage> + Clone + 'static;
    type BlockchainApi: BlockchainApi<BalanceType = Self::BigUint> + Clone + 'static;
    type CryptoApi: CryptoApi<BigUint = Self::BigUint> + Clone + 'static;
    type LogApi: LogApi + ErrorApi + Clone + 'static;
    type ErrorApi: ErrorApi + 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;
    fn log_api_raw(&self) -> Self::LogApi;
    fn error_api(&self) -> Self::ErrorApi;

    // Provided method
    fn proxy<P: ProxyObjApi<SendApi = Self::SendApi>>(
        &self,
        address: Address
    ) -> P { ... }
}
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 BigUint: BigUintApi + 'static

source

type BigInt: BigIntApi + 'static

source

type EllipticCurve: EllipticCurveApi<BigUint = Self::BigUint> + 'static

source

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

Abstracts the lower-level storage functionality.

source

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

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

source

type SendApi: SendApi<AmountType = Self::BigUint, ProxyBigInt = Self::BigInt, ProxyEllipticCurve = Self::EllipticCurve, ProxyStorage = Self::Storage> + Clone + 'static

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

source

type BlockchainApi: BlockchainApi<BalanceType = Self::BigUint> + Clone + 'static

source

type CryptoApi: CryptoApi<BigUint = Self::BigUint> + Clone + 'static

source

type LogApi: LogApi + ErrorApi + Clone + 'static

source

type ErrorApi: ErrorApi + 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.

source

fn log_api_raw(&self) -> Self::LogApi

Gateway into the lower-level event log functionality. Gets called in auto-generated Using it directly is not recommended. TODO: consider moving to ContractPrivateApi.

source

fn error_api(&self) -> Self::ErrorApi

Currently for some auto-generated code involving callbacks. Please avoid using it directly. TODO: find a way to hide this API.

Provided Methods§

source

fn proxy<P: ProxyObjApi<SendApi = Self::SendApi>>(&self, address: Address) -> P

Object Safety§

This trait is not object safe.

Implementors§