Skip to content

Commit

Permalink
Trim underscore prefix while generating event params
Browse files Browse the repository at this point in the history
Underscore prefixes should be trimmed while
capitalizing and uncapitalizing the first
letter of the event params. This change
is required because abigen does the same
while generating the underlying contract
binding so names must be aligned to
avoid compilation errors.
  • Loading branch information
lukasz-zimnoch committed Oct 15, 2020
1 parent e04cc57 commit 496b0c8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tools/generators/ethereum/contract_parsing.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,19 @@ func uppercaseFirst(str string) string {
if len(str) == 0 {
return str
}

str = strings.TrimPrefix(str, "_")

return strings.ToUpper(str[0:1]) + str[1:]
}

func lowercaseFirst(str string) string {
if len(str) == 0 {
return str
}

str = strings.TrimPrefix(str, "_")

return strings.ToLower(str[0:1]) + str[1:]
}

Expand Down

0 comments on commit 496b0c8

Please sign in to comment.