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:
RJ Catalano 2017-06-13 18:45:01 -05:00
parent c9920a7c6e
commit 6d9295ea67
No known key found for this signature in database
GPG key ID: D4AB109D9B5D6386

View file

@ -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