@@ -99,6 +99,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
9999 // Normalize the method for capital cases and non-anonymous inputs/outputs
100100 normalized := original
101101 normalizedName := methodNormalizer [lang ](alias (aliases , original .Name ))
102+
102103 // Ensure there is no duplicated identifier
103104 var identifiers = callIdentifiers
104105 if ! original .IsConstant () {
@@ -108,6 +109,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
108109 return "" , fmt .Errorf ("duplicated identifier \" %s\" (normalized \" %s\" ), use --alias for renaming" , original .Name , normalizedName )
109110 }
110111 identifiers [normalizedName ] = true
112+
111113 normalized .Name = normalizedName
112114 normalized .Inputs = make ([]abi.Argument , len (original .Inputs ))
113115 copy (normalized .Inputs , original .Inputs )
@@ -152,12 +154,22 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
152154 eventIdentifiers [normalizedName ] = true
153155 normalized .Name = normalizedName
154156
157+ used := make (map [string ]bool )
155158 normalized .Inputs = make ([]abi.Argument , len (original .Inputs ))
156159 copy (normalized .Inputs , original .Inputs )
157160 for j , input := range normalized .Inputs {
158161 if input .Name == "" {
159162 normalized .Inputs [j ].Name = fmt .Sprintf ("arg%d" , j )
160163 }
164+ // Event is a bit special, we need to define event struct in binding,
165+ // ensure there is no camel-case-style name conflict.
166+ for index := 0 ; ; index ++ {
167+ if ! used [capitalise (normalized .Inputs [j ].Name )] {
168+ used [capitalise (normalized .Inputs [j ].Name )] = true
169+ break
170+ }
171+ normalized .Inputs [j ].Name = fmt .Sprintf ("%s%d" , normalized .Inputs [j ].Name , index )
172+ }
161173 if hasStruct (input .Type ) {
162174 bindStructType [lang ](input .Type , structs )
163175 }
@@ -432,15 +444,22 @@ func bindStructTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
432444 if s , exist := structs [id ]; exist {
433445 return s .Name
434446 }
435- var fields []* tmplField
447+ var (
448+ names = make (map [string ]bool )
449+ fields []* tmplField
450+ )
436451 for i , elem := range kind .TupleElems {
437- field := bindStructTypeGo (* elem , structs )
438- fields = append (fields , & tmplField {Type : field , Name : capitalise (kind .TupleRawNames [i ]), SolKind : * elem })
452+ name := capitalise (kind .TupleRawNames [i ])
453+ name = abi .ResolveNameConflict (name , func (s string ) bool { return names [s ] })
454+ names [name ] = true
455+ fields = append (fields , & tmplField {Type : bindStructTypeGo (* elem , structs ), Name : name , SolKind : * elem })
439456 }
440457 name := kind .TupleRawName
441458 if name == "" {
442459 name = fmt .Sprintf ("Struct%d" , len (structs ))
443460 }
461+ name = capitalise (name )
462+
444463 structs [id ] = & tmplStruct {
445464 Name : name ,
446465 Fields : fields ,
0 commit comments