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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
use fuels_code_gen::Abigen;
use proc_macro::TokenStream;
use syn::{parse_macro_input, DeriveInput};
use crate::{
abigen::MacroAbigenTargets,
derive::{
parameterize::generate_parameterize_impl, tokenizable::generate_tokenizable_impl,
try_from::generate_try_from_impl,
},
setup_contract_test::{generate_setup_contract_test_code, TestContractCommands},
};
mod abigen;
mod derive;
mod parse_utils;
mod setup_contract_test;
mod utils;
#[proc_macro]
pub fn abigen(input: TokenStream) -> TokenStream {
let targets = parse_macro_input!(input as MacroAbigenTargets);
Abigen::generate(targets.into(), false).unwrap().into()
}
#[proc_macro]
pub fn wasm_abigen(input: TokenStream) -> TokenStream {
let targets = parse_macro_input!(input as MacroAbigenTargets);
Abigen::generate(targets.into(), true).unwrap().into()
}
#[proc_macro]
pub fn setup_contract_test(input: TokenStream) -> TokenStream {
let test_contract_commands = parse_macro_input!(input as TestContractCommands);
generate_setup_contract_test_code(test_contract_commands)
.unwrap_or_else(|e| e.to_compile_error())
.into()
}
#[proc_macro_derive(Parameterize, attributes(FuelsTypesPath, NoStd))]
pub fn parameterize(stream: TokenStream) -> TokenStream {
let input = parse_macro_input!(stream as DeriveInput);
generate_parameterize_impl(input)
.unwrap_or_else(|e| e.to_compile_error())
.into()
}
#[proc_macro_derive(Tokenizable, attributes(FuelsTypesPath, NoStd))]
pub fn tokenizable(stream: TokenStream) -> TokenStream {
let input = parse_macro_input!(stream as DeriveInput);
generate_tokenizable_impl(input)
.unwrap_or_else(|e| e.to_compile_error())
.into()
}
#[proc_macro_derive(TryFrom, attributes(FuelsCorePath, NoStd))]
pub fn try_from(stream: TokenStream) -> TokenStream {
let input = parse_macro_input!(stream as DeriveInput);
generate_try_from_impl(input)
.unwrap_or_else(|e| e.to_compile_error())
.into()
}