@@ -48,12 +48,16 @@ const (
4848// enforces compile time type safety and naming convention opposed to having to
4949// manually maintain hard coded strings that break on runtime.
5050func Bind (types []string , abis []string , bytecodes []string , fsigs []map [string ]string , pkg string , lang Lang , libs map [string ]string , aliases map [string ]string ) (string , error ) {
51- // Process each individual contract requested binding
52- contracts := make (map [string ]* tmplContract )
51+ var (
52+ // contracts is the map of each individual contract requested binding
53+ contracts = make (map [string ]* tmplContract )
5354
54- // Map used to flag each encountered library as such
55- isLib : = make (map [string ]struct {} )
55+ // structs is the map of all reclared structs shared by passed contracts.
56+ structs = make (map [string ]* tmplStruct )
5657
58+ // isLib is the map used to flag each encountered library as such
59+ isLib = make (map [string ]struct {})
60+ )
5761 for i := 0 ; i < len (types ); i ++ {
5862 // Parse the actual ABI to generate the binding for
5963 evmABI , err := abi .JSON (strings .NewReader (abis [i ]))
@@ -73,7 +77,6 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
7377 calls = make (map [string ]* tmplMethod )
7478 transacts = make (map [string ]* tmplMethod )
7579 events = make (map [string ]* tmplEvent )
76- structs = make (map [string ]* tmplStruct )
7780
7881 // identifiers are used to detect duplicated identifier of function
7982 // and event. For all calls, transacts and events, abigen will generate
@@ -168,7 +171,6 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
168171 Transacts : transacts ,
169172 Events : events ,
170173 Libraries : make (map [string ]string ),
171- Structs : structs ,
172174 }
173175 // Function 4-byte signatures are stored in the same sequence
174176 // as types, if available.
@@ -200,6 +202,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
200202 Package : pkg ,
201203 Contracts : contracts ,
202204 Libraries : libs ,
205+ Structs : structs ,
203206 }
204207 buffer := new (bytes.Buffer )
205208
0 commit comments