Skip to content

Commit

Permalink
Merge pull request #52 from keep-network/trim-underscore
Browse files Browse the repository at this point in the history
Trim underscore prefix while generating event params

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
pdyraga authored Oct 15, 2020
2 parents e04cc57 + 496b0c8 commit 397dbfe
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 397dbfe

Please sign in to comment.