pub trait MultiTokenPayModule: ContractBase + Sized {
fn accepted_tokens(
&self,
token: &EgldOrEsdtTokenIdentifier<Self::Api>
) -> SingleValueMapper<Self::Api, BigUint<Self::Api>>;
fn add_payment_token(
&self,
token: EgldOrEsdtTokenIdentifier<Self::Api>,
amount: BigUint<Self::Api>
) { ... }
fn remove_payment_token(&self, token: EgldOrEsdtTokenIdentifier<Self::Api>) { ... }
fn require_valid_payment(&self) { ... }
fn require_valid_payments<const X: usize>(&self) { ... }
}
Expand description
This module contains the logic for accepting multiple ESDT payments.
Required Methods§
sourcefn accepted_tokens(
&self,
token: &EgldOrEsdtTokenIdentifier<Self::Api>
) -> SingleValueMapper<Self::Api, BigUint<Self::Api>>
fn accepted_tokens(
&self,
token: &EgldOrEsdtTokenIdentifier<Self::Api>
) -> SingleValueMapper<Self::Api, BigUint<Self::Api>>
Storage mapper used for storing the accepted tokens. All tokens stored must contain the amount that is accepted for payment.
Provided Methods§
sourcefn add_payment_token(
&self,
token: EgldOrEsdtTokenIdentifier<Self::Api>,
amount: BigUint<Self::Api>
)
fn add_payment_token(
&self,
token: EgldOrEsdtTokenIdentifier<Self::Api>,
amount: BigUint<Self::Api>
)
Adds a payment token to the list of accepted tokens.
sourcefn remove_payment_token(&self, token: EgldOrEsdtTokenIdentifier<Self::Api>)
fn remove_payment_token(&self, token: EgldOrEsdtTokenIdentifier<Self::Api>)
Removes a payment token from the list of accepted tokens.
sourcefn require_valid_payment(&self)
fn require_valid_payment(&self)
Require clause used for validating a single ESDT payment. It checks if the payment received contains the correct token and amount.
sourcefn require_valid_payments<const X: usize>(&self)
fn require_valid_payments<const X: usize>(&self)
Require clause used for validating multiple ESDT payments. It checks if the payments received contain the correct tokens and amounts.
The generic parameter X is used to specify the maximum number of payments that can be received.
NOTE: This can be easily used for when the contract accepts NFT and ESDT payments as well.