mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
accounts/abi: fix singleUnpack for mobile
until now calling a contract function with a single result failed this commit fixes #15387 #14832
This commit is contained in:
parent
dd8a62683e
commit
f31713c1df
2 changed files with 24 additions and 2 deletions
|
|
@ -130,7 +130,18 @@ func (e Event) singleUnpack(v interface{}, output []byte) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := set(value, reflect.ValueOf(marshalledValue), e.Inputs[0]); err != nil {
|
|
||||||
|
// if we reach this part, there is only one output member from the contract event.
|
||||||
|
// for mobile, the result type is always a slice.
|
||||||
|
var firstValue reflect.Value
|
||||||
|
if reflect.Slice == value.Kind() {
|
||||||
|
// take the first element
|
||||||
|
firstValue = value.Index(0).Elem()
|
||||||
|
} else {
|
||||||
|
firstValue = value
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := set(firstValue, reflect.ValueOf(marshalledValue), e.Inputs[0]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,18 @@ func (method Method) singleUnpack(v interface{}, output []byte) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := set(value, reflect.ValueOf(marshalledValue), method.Outputs[0]); err != nil {
|
|
||||||
|
// if we reach this part, there is only one output member from the contract method.
|
||||||
|
// for mobile, the result type is always a slice.
|
||||||
|
var firstValue reflect.Value
|
||||||
|
if reflect.Slice == value.Kind() {
|
||||||
|
// take the first element
|
||||||
|
firstValue = value.Index(0).Elem()
|
||||||
|
} else {
|
||||||
|
firstValue = value
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := set(firstValue, reflect.ValueOf(marshalledValue), method.Outputs[0]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue