Skip to content

Commit fec25e3

Browse files
author
Erichin
committed
bugfix
1 parent 0056658 commit fec25e3

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

accounts/abi/event.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ func (e Event) singleUnpack(v interface{}, output []byte) error {
130130
if err != nil {
131131
return err
132132
}
133+
134+
// if we reach this part, there is only one output member from the contract event.
135+
// for mobile, the result type is always a slice.
136+
if reflect.Slice == value.Kind() && value.Len() >= 1 {
137+
//check if it's not a byte slice
138+
if reflect.TypeOf([]byte{}) != value.Type() {
139+
value = value.Index(0).Elem()
140+
}
141+
}
142+
133143
if err := set(value, reflect.ValueOf(marshalledValue), e.Inputs[0]); err != nil {
134144
return err
135145
}

accounts/abi/method.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ func (method Method) singleUnpack(v interface{}, output []byte) error {
150150
if err != nil {
151151
return err
152152
}
153+
154+
// if we reach this part, there is only one output member from the contract method.
155+
// for mobile, the result type is always a slice.
156+
if reflect.Slice == value.Kind() && value.Len() >= 1 {
157+
//check if it's not a byte slice
158+
if reflect.TypeOf([]byte{}) != value.Type() {
159+
value = value.Index(0).Elem()
160+
}
161+
}
162+
153163
if err := set(value, reflect.ValueOf(marshalledValue), method.Outputs[0]); err != nil {
154164
return err
155165
}

0 commit comments

Comments
 (0)