1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use super::RustBigUint;
use crate::{TxContext, TxPanic};
use elrond_wasm::api::CallValueApi;
use elrond_wasm::err_msg;
use elrond_wasm::types::{EsdtTokenType, TokenIdentifier};
impl CallValueApi for TxContext {
type AmountType = RustBigUint;
fn check_not_payable(&self) {
if self.egld_value() > 0 {
std::panic::panic_any(TxPanic {
status: 10,
message: err_msg::NON_PAYABLE_FUNC_EGLD.to_vec(),
});
}
if self.esdt_value() > 0 {
std::panic::panic_any(TxPanic {
status: 10,
message: err_msg::NON_PAYABLE_FUNC_ESDT.to_vec(),
});
}
}
#[inline]
fn egld_value(&self) -> RustBigUint {
self.tx_input_box.call_value.clone().into()
}
#[inline]
fn esdt_value(&self) -> RustBigUint {
self.tx_input_box.esdt_value.clone().into()
}
#[inline]
fn token(&self) -> TokenIdentifier {
TokenIdentifier::from(self.tx_input_box.esdt_token_identifier.as_slice())
}
#[inline]
fn esdt_token_nonce(&self) -> u64 {
0u64
}
#[inline]
fn esdt_token_type(&self) -> EsdtTokenType {
EsdtTokenType::Fungible
}
}