From 496b0c87d6f5d61d9ca87d9375e1350f61b1749b Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 15 Oct 2020 11:18:20 +0200 Subject: [PATCH] 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. --- tools/generators/ethereum/contract_parsing.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/generators/ethereum/contract_parsing.go b/tools/generators/ethereum/contract_parsing.go index cd49174..58230d9 100644 --- a/tools/generators/ethereum/contract_parsing.go +++ b/tools/generators/ethereum/contract_parsing.go @@ -278,6 +278,9 @@ func uppercaseFirst(str string) string { if len(str) == 0 { return str } + + str = strings.TrimPrefix(str, "_") + return strings.ToUpper(str[0:1]) + str[1:] } @@ -285,6 +288,9 @@ func lowercaseFirst(str string) string { if len(str) == 0 { return str } + + str = strings.TrimPrefix(str, "_") + return strings.ToLower(str[0:1]) + str[1:] }