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
86
87
88
89
#[macro_export]
macro_rules! rust_biguint {
($value:expr) => {{
elrond_wasm_debug::num_bigint::BigUint::from($value as u64)
}};
}
#[macro_export]
macro_rules! managed_biguint {
($value:expr) => {{
elrond_wasm::types::BigUint::from($value as u64)
}};
}
#[macro_export]
macro_rules! managed_buffer {
($value:expr) => {{
elrond_wasm::types::ManagedBuffer::new_from_bytes($value)
}};
}
#[macro_export]
macro_rules! managed_address {
($address:expr) => {{
elrond_wasm::types::ManagedAddress::from_address($address)
}};
}
#[macro_export]
macro_rules! managed_token_id {
($bytes:expr) => {{
elrond_wasm::types::TokenIdentifier::from_esdt_bytes($bytes)
}};
}
#[macro_export]
macro_rules! managed_token_id_wrapped {
($bytes:expr) => {{
let ___esdt_token_id___ = elrond_wasm::types::TokenIdentifier::from_esdt_bytes($bytes);
elrond_wasm::types::EgldOrEsdtTokenIdentifier::esdt(___esdt_token_id___)
}};
}
#[macro_export]
macro_rules! managed_egld_token_id {
() => {{
elrond_wasm::types::EgldOrEsdtTokenIdentifier::egld()
}};
}
#[macro_export]
macro_rules! assert_sc_error {
($sc_result:expr, $expected_string:expr) => {{
match $sc_result {
elrond_wasm::types::SCResult::Ok(t) => {
panic!("Expected SCError, but got SCResult::Ok: {:?}", t)
},
elrond_wasm::types::SCResult::Err(err) => {
let as_str = String::from_utf8(err.as_bytes().to_vec()).unwrap();
assert_eq!(as_str, $expected_string);
},
}
}};
}
#[macro_export]
macro_rules! assert_values_eq {
($left:expr, $right:expr) => {{
assert!(
$left == $right,
"Assert mismatch: \n Left: {:?} \n Right: {:?}",
$left,
$right
)
}};
}
#[macro_export]
macro_rules! unwrap_or_panic {
($sc_result:expr) => {{
match $sc_result {
elrond_wasm::types::SCResult::Ok(t) => t,
elrond_wasm::types::SCResult::Err(err) => {
let as_str = String::from_utf8(err.as_bytes().to_vec()).unwrap();
panic!("{}", as_str);
},
}
}};
}