Trait dharitri_wasm::api::ContractBase
source · 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§
type BigUint: BigUintApi + 'static
type BigInt: BigIntApi + 'static
type EllipticCurve: EllipticCurveApi<BigUint = Self::BigUint> + 'static
sourcetype Storage: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static
type Storage: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static
Abstracts the lower-level storage functionality.
sourcetype CallValue: CallValueApi<AmountType = Self::BigUint> + ErrorApi + Clone + 'static
type CallValue: CallValueApi<AmountType = Self::BigUint> + ErrorApi + Clone + 'static
Abstracts the call value handling at the beginning of a function call.
sourcetype SendApi: SendApi<AmountType = Self::BigUint, ProxyBigInt = Self::BigInt, ProxyEllipticCurve = Self::EllipticCurve, ProxyStorage = Self::Storage> + Clone + 'static
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.
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§
sourcefn get_storage_raw(&self) -> Self::Storage
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.
sourcefn call_value(&self) -> Self::CallValue
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.
sourcefn send(&self) -> Self::SendApi
fn send(&self) -> Self::SendApi
Gateway to the functionality related to sending transactions from the current contract.
sourcefn blockchain(&self) -> Self::BlockchainApi
fn blockchain(&self) -> Self::BlockchainApi
Gateway blockchain info related to the current transaction and to accounts.
sourcefn log_api_raw(&self) -> Self::LogApi
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
.