Skip to content

Commit

Permalink
Add comment explaining how Geth translates Solidity field names to Go…
Browse files Browse the repository at this point in the history
… struct field names
  • Loading branch information
spooktheducks committed Mar 12, 2020
1 parent c251a14 commit c1a35b7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/eth/geth_copied.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit c1a35b7

Please sign in to comment.