Skip to content

Commit

Permalink
eth/filters: improve error message for invalid filter topics (#17234)
Browse files Browse the repository at this point in the history
  • Loading branch information
macalinao authored and fjl committed Jul 24, 2018
1 parent 62467e4 commit d96ba77
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,15 +564,15 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
func decodeAddress(s string) (common.Address, error) {
b, err := hexutil.Decode(s)
if err == nil && len(b) != common.AddressLength {
err = fmt.Errorf("hex has invalid length %d after decoding", len(b))
err = fmt.Errorf("hex has invalid length %d after decoding; expected %d for address", len(b), common.AddressLength)
}
return common.BytesToAddress(b), err
}

func decodeTopic(s string) (common.Hash, error) {
b, err := hexutil.Decode(s)
if err == nil && len(b) != common.HashLength {
err = fmt.Errorf("hex has invalid length %d after decoding", len(b))
err = fmt.Errorf("hex has invalid length %d after decoding; expected %d for topic", len(b), common.HashLength)
}
return common.BytesToHash(b), err
}

0 comments on commit d96ba77

Please sign in to comment.