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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
use odra_mock_vm_types::{Address, Balance, BlockTime, MockVMType, OdraType};
use odra_types::{event::OdraEvent, ExecutionError};
use crate::{borrow_env, native_token::NativeTokenMetadata};
pub fn get_block_time() -> BlockTime {
    borrow_env().get_block_time()
}
pub fn caller() -> Address {
    borrow_env().caller()
}
pub fn self_address() -> Address {
    borrow_env().callee()
}
pub fn set_var<T: MockVMType>(key: &str, value: T) {
    borrow_env().set_var(key, value)
}
pub fn get_var<T: OdraType>(key: &str) -> Option<T> {
    borrow_env().get_var(key)
}
pub fn set_dict_value<K: MockVMType, V: MockVMType>(dict: &str, key: &K, value: V) {
    borrow_env().set_dict_value(dict, key.ser().unwrap().as_slice(), value)
}
pub fn get_dict_value<K: MockVMType, T: MockVMType>(dict: &str, key: &K) -> Option<T> {
    let key = key.ser().unwrap();
    let key = key.as_slice();
    borrow_env().get_dict_value(dict, key)
}
pub fn revert<E>(error: E) -> !
where
    E: Into<ExecutionError>
{
    let execution_error: ExecutionError = error.into();
    borrow_env().revert(execution_error.into());
    panic!("OdraRevert")
}
pub fn emit_event<T: OdraType + OdraEvent>(event: T) {
    let event_data = event.ser().unwrap();
    borrow_env().emit_event(&event_data);
}
pub fn attached_value() -> Balance {
    borrow_env().attached_value()
}
pub fn one_token() -> Balance {
    Balance::one()
}
pub fn transfer_tokens<B: Into<Balance>>(to: Address, amount: B) -> bool {
    let callee = borrow_env().callee();
    borrow_env().transfer_tokens(callee, to, amount.into())
}
pub fn self_balance() -> Balance {
    borrow_env().self_balance()
}
pub fn native_token_metadata() -> NativeTokenMetadata {
    NativeTokenMetadata::new()
}