@@ -34,8 +34,15 @@ impl Abigen {
3434 /// for, and of what nature (Contract, Script or Predicate).
3535 /// * `no_std`: don't use the Rust std library.
3636 pub fn generate ( targets : Vec < AbigenTarget > , no_std : bool ) -> Result < TokenStream > {
37+ // eprintln!("{:#?}", targets);
38+
3739 let generated_code = Self :: generate_code ( no_std, targets) ?;
3840
41+ eprintln ! (
42+ "========================== CODE: \n {:#}" ,
43+ generated_code. code( )
44+ ) ;
45+
3946 let use_statements = generated_code. use_statements_for_uniquely_named_types ( ) ;
4047
4148 let code = if no_std {
@@ -67,10 +74,18 @@ impl Abigen {
6774
6875 fn generate_code ( no_std : bool , parsed_targets : Vec < AbigenTarget > ) -> Result < GeneratedCode > {
6976 let custom_types = Self :: filter_custom_types ( & parsed_targets) ;
70- let shared_types = Self :: filter_shared_types ( custom_types) ;
77+ let mut shared_types = Self :: filter_shared_types ( custom_types) ;
78+
79+ let alias_types = Self :: filter_alias_types ( & parsed_targets)
80+ . cloned ( )
81+ . collect :: < Vec < _ > > ( ) ;
82+ shared_types. clear ( ) ;
83+ shared_types. extend ( alias_types) ;
7184
7285 let bindings = Self :: generate_all_bindings ( parsed_targets, no_std, & shared_types) ?;
86+ eprintln ! ( "bindings {:#}" , bindings. code( ) . to_string( ) ) ;
7387 let shared_types = Self :: generate_shared_types ( shared_types, no_std) ?;
88+ eprintln ! ( "shared_types {:#}" , shared_types. code( ) . to_string( ) ) ;
7489
7590 let mod_name = ident ( "abigen_bindings" ) ;
7691 Ok ( shared_types. merge ( bindings) . wrap_in_mod ( mod_name) )
@@ -94,11 +109,14 @@ impl Abigen {
94109 no_std : bool ,
95110 shared_types : & HashSet < FullTypeDeclaration > ,
96111 ) -> Result < GeneratedCode > {
112+ eprintln ! ( "generate_bindings shared_types {:#?}" , shared_types) ;
97113 let mod_name = ident ( & format ! ( "{}_mod" , & target. name. to_snake_case( ) ) ) ;
98114
99115 let recompile_trigger =
100116 Self :: generate_macro_recompile_trigger ( target. source . path . as_ref ( ) , no_std) ;
101117 let types = generate_types ( & target. source . abi . types , shared_types, no_std) ?;
118+ eprintln ! ( "generate_bindings types {:#?}" , types) ;
119+
102120 let bindings = generate_bindings ( target, no_std) ?;
103121 Ok ( recompile_trigger
104122 . merge ( types)
@@ -145,6 +163,15 @@ impl Abigen {
145163 . filter ( |ttype| ttype. is_custom_type ( ) )
146164 }
147165
166+ fn filter_alias_types (
167+ all_types : & [ AbigenTarget ] ,
168+ ) -> impl Iterator < Item = & FullTypeDeclaration > {
169+ all_types
170+ . iter ( )
171+ . flat_map ( |target| & target. source . abi . types )
172+ . filter ( |ttype| ttype. is_alias_type ( ) )
173+ }
174+
148175 /// A type is considered "shared" if it appears at least twice in
149176 /// `all_custom_types`.
150177 ///
0 commit comments