mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-14 16:03:45 +00:00
accounts/abi: fix for the array set and for creating a bool
Signed-off-by: RJ Catalano <rj@monax.io>
This commit is contained in:
parent
c9920a7c6e
commit
6d9295ea67
1 changed files with 9 additions and 2 deletions
|
|
@ -111,13 +111,17 @@ func toGoSlice(i int, t Argument, output []byte) (interface{}, error) {
|
||||||
var (
|
var (
|
||||||
inter interface{} // interface type
|
inter interface{} // interface type
|
||||||
returnOutput = slice[i*32 : i*32+32] // the return output
|
returnOutput = slice[i*32 : i*32+32] // the return output
|
||||||
|
err error
|
||||||
)
|
)
|
||||||
// set inter to the correct type (cast)
|
// set inter to the correct type (cast)
|
||||||
switch elem.T {
|
switch elem.T {
|
||||||
case IntTy, UintTy:
|
case IntTy, UintTy:
|
||||||
inter = readInteger(t.Type.Kind, returnOutput)
|
inter = readInteger(t.Type.Kind, returnOutput)
|
||||||
case BoolTy:
|
case BoolTy:
|
||||||
inter = !allZero(returnOutput)
|
inter, err = getBoolValue(returnOutput)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
case AddressTy:
|
case AddressTy:
|
||||||
inter = common.BytesToAddress(returnOutput)
|
inter = common.BytesToAddress(returnOutput)
|
||||||
case HashTy:
|
case HashTy:
|
||||||
|
|
@ -162,7 +166,10 @@ func getBoolValue(b []byte) (bool, error) {
|
||||||
return false, fmt.Errorf("abi: Improperly encoded boolean value.")
|
return false, fmt.Errorf("abi: Improperly encoded boolean value.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bool(b[31]), nil
|
if uint(b[31]) == 1 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// toGoType parses the input and casts it to the proper type defined by the ABI
|
// toGoType parses the input and casts it to the proper type defined by the ABI
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue