1use proc_macro2::TokenStream;
2#[derive(Debug, Default)]
4pub struct RustGenerator {
5 contracts: Vec<ContractGenerator>,
6}
7
8impl RustGenerator {
9 pub(crate) fn new_contract(&mut self, name: &str) {
11 self.contracts.push(ContractGenerator::new(name))
12 }
13
14 pub(crate) fn current_contract(&mut self) -> &mut ContractGenerator {
16 self.contracts.last_mut().expect("Call new_contract first")
17 }
18
19 pub(crate) fn to_runtime_type_token_stream<R: ethbind_gen::RuntimeBinder>(
20 &self,
21 runtime_binder: &mut R,
22 name: &str,
23 ) -> anyhow::Result<TokenStream> {
24 Ok(runtime_binder
25 .get(name)?
26 .parse()
27 .map_err(|e| anyhow::format_err!("{}", e))?)
28 }
29}
30
31mod generator;
32pub use generator::*;
33
34mod function;
35pub use function::*;
36
37mod contract;
38use contract::*;
39
40mod event;
41pub use event::*;