diff options
author | Robert Zaremba <robert.zaremba@scale-it.pl> | 2017-11-10 07:08:28 +0800 |
---|---|---|
committer | Martin Holst Swende <martin@swende.se> | 2017-12-21 22:14:50 +0800 |
commit | 9becba5540540bc37d4ad5eaaf7e4c1937a6542f (patch) | |
tree | c9aa8a4a4c2887fbf00278735b416871d7ce9cb4 /accounts/abi/event.go | |
parent | 3511904aad5e492b271c68db36730d88cab46911 (diff) | |
download | dexon-9becba5540540bc37d4ad5eaaf7e4c1937a6542f.tar.gz dexon-9becba5540540bc37d4ad5eaaf7e4c1937a6542f.tar.zst dexon-9becba5540540bc37d4ad5eaaf7e4c1937a6542f.zip |
accounts/abi: fix event tupleUnpack
Event.tupleUnpack doesn't handle correctly Indexed arguments,
hence it can't unpack an event with indexed arguments.
Diffstat (limited to 'accounts/abi/event.go')
-rw-r--r-- | accounts/abi/event.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/accounts/abi/event.go b/accounts/abi/event.go index bd1098d87..0d3c3c4fa 100644 --- a/accounts/abi/event.go +++ b/accounts/abi/event.go @@ -65,13 +65,13 @@ func (e Event) tupleUnpack(v interface{}, output []byte) error { return fmt.Errorf("abi: cannot unmarshal tuple in to %v", typ) } - j := 0 - for i := 0; i < len(e.Inputs); i++ { - input := e.Inputs[i] + i, j := -1, 0 + for _, input := range e.Inputs { if input.Indexed { // can't read, continue continue } + i++ marshalledValue, err := toGoType((i+j)*32, input.Type, output) if err != nil { return err @@ -88,22 +88,22 @@ func (e Event) tupleUnpack(v interface{}, output []byte) error { for j := 0; j < typ.NumField(); j++ { field := typ.Field(j) // TODO read tags: `abi:"fieldName"` - if field.Name == strings.ToUpper(e.Inputs[i].Name[:1])+e.Inputs[i].Name[1:] { - if err := set(value.Field(j), reflectValue, e.Inputs[i]); err != nil { + if field.Name == strings.ToUpper(input.Name[:1])+input.Name[1:] { + if err := set(value.Field(j), reflectValue, input); err != nil { return err } } } case reflect.Slice, reflect.Array: if value.Len() < i { - return fmt.Errorf("abi: insufficient number of arguments for unpack, want %d, got %d", len(e.Inputs), value.Len()) + return fmt.Errorf("abi: insufficient number of arguments for unpack, want %d, got %d", i, value.Len()) } v := value.Index(i) if v.Kind() != reflect.Ptr && v.Kind() != reflect.Interface { return fmt.Errorf("abi: cannot unmarshal %v in to %v", v.Type(), reflectValue.Type()) } reflectValue := reflect.ValueOf(marshalledValue) - if err := set(v.Elem(), reflectValue, e.Inputs[i]); err != nil { + if err := set(v.Elem(), reflectValue, input); err != nil { return err } default: |