Struct elrond_wasm::contract_base::CallValueWrapper
source · pub struct CallValueWrapper<A>where
A: CallValueApi + ErrorApi + ManagedTypeApi,{ /* private fields */ }
Implementations§
source§impl<A> CallValueWrapper<A>where
A: CallValueApi + ErrorApi + ManagedTypeApi,
impl<A> CallValueWrapper<A>where
A: CallValueApi + ErrorApi + ManagedTypeApi,
pub fn new() -> Self
sourcepub fn egld_value(&self) -> BigUint<A>
pub fn egld_value(&self) -> BigUint<A>
Retrieves the EGLD call value from the VM. Will return 0 in case of an ESDT transfer (cannot have both EGLD and ESDT transfer simultaneously).
sourcepub fn all_esdt_transfers(&self) -> ManagedVec<A, EsdtTokenPayment<A>>
pub fn all_esdt_transfers(&self) -> ManagedVec<A, EsdtTokenPayment<A>>
Returns all ESDT transfers that accompany this SC call. Will return 0 results if nothing was transfered, or just EGLD. Fully managed underlying types, very efficient.
sourcepub fn multi_esdt<const N: usize>(&self) -> [EsdtTokenPayment<A>; N]
pub fn multi_esdt<const N: usize>(&self) -> [EsdtTokenPayment<A>; N]
Verify and casts the received multi ESDT transfer in to an array.
Can be used to extract all payments in one line like this:
let [payment_a, payment_b, payment_c] = self.call_value().multi_esdt();
.
sourcepub fn single_esdt(&self) -> EsdtTokenPayment<A>
pub fn single_esdt(&self) -> EsdtTokenPayment<A>
Expects precisely one ESDT token transfer, fungible or not.
Will return the received ESDT payment.
The amount cannot be 0, since that would not qualify as an ESDT transfer.
sourcepub fn single_fungible_esdt(&self) -> (TokenIdentifier<A>, BigUint<A>)
pub fn single_fungible_esdt(&self) -> (TokenIdentifier<A>, BigUint<A>)
Expects precisely one fungible ESDT token transfer.
Returns the token ID and the amount for fungible ESDT transfers.
The amount cannot be 0, since that would not qualify as an ESDT transfer.
sourcepub fn esdt_value(&self) -> BigUint<A>
pub fn esdt_value(&self) -> BigUint<A>
Retrieves the ESDT call value from the VM. Will return 0 in case of an EGLD transfer (cannot have both EGLD and ESDT transfer simultaneously).
sourcepub fn egld_or_single_esdt(&self) -> EgldOrEsdtTokenPayment<A>
pub fn egld_or_single_esdt(&self) -> EgldOrEsdtTokenPayment<A>
Accepts and returns either an EGLD payment, or a single ESDT token.
Will halt execution if more than one ESDT transfer was received.
In case no transfer of value happen, it will return a payment of 0 EGLD.
sourcepub fn egld_or_single_fungible_esdt(
&self
) -> (EgldOrEsdtTokenIdentifier<A>, BigUint<A>)
pub fn egld_or_single_fungible_esdt(
&self
) -> (EgldOrEsdtTokenIdentifier<A>, BigUint<A>)
Accepts and returns either an EGLD payment, or a single fungible ESDT token.
Will halt execution if more than one ESDT transfer was received, or if the received ESDT is non- or semi-fungible.
Works similar to egld_or_single_esdt
,
but checks the nonce to be 0 and returns a tuple of just token identifier and amount, for convenience.
In case no transfer of value happen, it will return a payment of 0 EGLD.