Skip to content

Commit

Permalink
Do not decode To if it doesn't exist (umbracle#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Castell authored Apr 25, 2022
1 parent bffbef0 commit ca02305
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions structs_unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ func (t *Transaction) unmarshalJSON(v *fastjson.Value) error {
}
t.Type = typ

// 'to' must exists
if err := exists("to"); err != nil {
return err
}

var err error
if err := decodeHash(&t.Hash, v, "hash"); err != nil {
return err
Expand All @@ -169,12 +164,15 @@ func (t *Transaction) unmarshalJSON(v *fastjson.Value) error {
}

{
if v.Get("to").String() != "null" {
var to Address
if err = decodeAddr(&to, v, "to"); err != nil {
return err
// Do not decode 'to' if it doesn't exist.
if err := exists("to"); err == nil {
if v.Get("to").String() != "null" {
var to Address
if err = decodeAddr(&to, v, "to"); err != nil {
return err
}
t.To = &to
}
t.To = &to
}
}

Expand Down

0 comments on commit ca02305

Please sign in to comment.