Negative numbers not properly converted in ABI encoding

When converting a negative number e.g., -2, the resulting ABI
encoding should look as follows:

fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe

However, since the check of the type is for an uint instead of an int,
it results in the following ABI encoding:

0101010101010101010101010101010101010101010101010101010101010102
This commit is contained in:
Thomas Bocek 2016-06-02 17:47:50 +02:00
parent a269a713d6
commit 22c5f01950

View file

@ -96,7 +96,7 @@ func packNum(value reflect.Value, to byte) []byte {
return S2S256(int64(value.Uint()))
}
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
if to == UintTy {
if to == IntTy {
return U2U256(uint64(value.Int()))
} else {
return S2S256(value.Int())