From c1a35b7a83f4ad5157e9696a35b48b92f42d01c8 Mon Sep 17 00:00:00 2001 From: spooktheducks Date: Thu, 12 Mar 2020 11:31:03 -0500 Subject: [PATCH] Add comment explaining how Geth translates Solidity field names to Go struct field names --- core/eth/geth_copied.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/eth/geth_copied.go b/core/eth/geth_copied.go index 15a0c7f0880..3f77939b3f8 100644 --- a/core/eth/geth_copied.go +++ b/core/eth/geth_copied.go @@ -48,6 +48,13 @@ func parseTopics(out interface{}, fields abi.Arguments, topics []common.Hash) er return errors.New("non-indexed field in topic reconstruction") } + // If Go structs aren't kept correctly in sync with log fields defined in Solidity, this error will be returned. + // The name convention is to remove underscores, capitalize all characters following them, and capitalize the + // first letter of the field: + // + // round_id => RoundId + // roundId => RoundId + // _roundId => RoundId _, exists := reflect.TypeOf(out).Elem().FieldByName(capitalise(arg.Name)) if !exists { return errors.Errorf(`can't find matching struct field for log "%T", field "%v" (expected "%v")`, out, arg.Name, capitalise(arg.Name))