Trait dharitri_wasm::api::CallValueApi
source · pub trait CallValueApi: ErrorApi + Sized {
type AmountType: BigUintApi + 'static;
// Required methods
fn check_not_payable(&self);
fn moax_value(&self) -> Self::AmountType;
fn dct_value(&self) -> Self::AmountType;
fn token(&self) -> TokenIdentifier;
fn dct_token_nonce(&self) -> u64;
fn dct_token_type(&self) -> DctTokenType;
// Provided methods
fn require_moax(&self) -> Self::AmountType { ... }
fn require_dct(&self, token: &[u8]) -> Self::AmountType { ... }
fn payment_token_pair(&self) -> (Self::AmountType, TokenIdentifier) { ... }
}
Required Associated Types§
sourcetype AmountType: BigUintApi + 'static
type AmountType: BigUintApi + 'static
The type of the payment arguments.
Not named BigUint
to avoid name collisions in types that implement multiple API traits.
Required Methods§
fn check_not_payable(&self)
sourcefn moax_value(&self) -> Self::AmountType
fn moax_value(&self) -> Self::AmountType
Retrieves the MOAX call value from the VM. Will return 0 in case of an DCT transfer (cannot have both MOAX and DCT transfer simultaneously).
sourcefn dct_value(&self) -> Self::AmountType
fn dct_value(&self) -> Self::AmountType
Retrieves the DCT call value from the VM. Will return 0 in case of an MOAX transfer (cannot have both MOAX and DCT transfer simultaneously).
sourcefn token(&self) -> TokenIdentifier
fn token(&self) -> TokenIdentifier
Returns the call value token identifier of the current call. The identifier is wrapped in a TokenIdentifier object, to hide underlying logic.
A note on implementation: even though the underlying api returns an empty name for MOAX,
but the MOAX TokenIdentifier is serialized as MOAX
.
sourcefn dct_token_nonce(&self) -> u64
fn dct_token_nonce(&self) -> u64
Returns the nonce of the received DCT token. Will return 0 in case of MOAX or fungible DCT transfer.
sourcefn dct_token_type(&self) -> DctTokenType
fn dct_token_type(&self) -> DctTokenType
Returns the DCT token type. Will return “Fungible” for MOAX.
Provided Methods§
sourcefn require_moax(&self) -> Self::AmountType
fn require_moax(&self) -> Self::AmountType
Will return the MOAX call value, but also fail with an error if DCT is sent. Especially used in the auto-generated call value processing.
sourcefn require_dct(&self, token: &[u8]) -> Self::AmountType
fn require_dct(&self, token: &[u8]) -> Self::AmountType
Will return the DCT call value, but also fail with an error if MOAX or the wrong DCT token is sent. Especially used in the auto-generated call value processing.
sourcefn payment_token_pair(&self) -> (Self::AmountType, TokenIdentifier)
fn payment_token_pair(&self) -> (Self::AmountType, TokenIdentifier)
Returns both the call value (either MOAX or DCT) and the token identifier. Especially used in the `#[payable(“*”)] auto-generated snippets. The method might seem redundant, but there is such a hook in Arwen that might be used in this scenario in the future.