[ioctl] fix contract parse int type
@@ -169,6 +169,7 @@ func parseInputArgument(t *abi.Type, arg interface{}) (interface{}, error) {
return nil, ErrInvalidArg
}
+ var value int64
switch t.Size {
default:
if k == reflect.String {
@@ -181,19 +182,22 @@ func parseInputArgument(t *abi.Type, arg interface{}) (interface{}, error) {
}
case 8:
if k == reflect.String {
- arg, err = strconv.ParseInt(arg.(string), 10, 8)
+ value, err = strconv.ParseInt(arg.(string), 10, 8)
+ arg = int8(value)
} else {
arg = int8(arg.(float64))
}
case 16:
if k == reflect.String {
- arg, err = strconv.ParseInt(arg.(string), 10, 16)
+ value, err = strconv.ParseInt(arg.(string), 10, 16)
+ arg = int16(value)
} else {
arg = int16(arg.(float64))
}
case 32:
if k == reflect.String {
- arg, err = strconv.ParseInt(arg.(string), 10, 32)
+ value, err = strconv.ParseInt(arg.(string), 10, 32)
+ arg = int32(value)
} else {
arg = int32(arg.(float64))
}
@@ -219,6 +223,7 @@ func parseInputArgument(t *abi.Type, arg interface{}) (interface{}, error) {
return nil, ErrInvalidArg
}
+ var value uint64
switch t.Size {
default:
if k == reflect.String {
@@ -235,19 +240,22 @@ func parseInputArgument(t *abi.Type, arg interface{}) (interface{}, error) {
}
case 8:
if k == reflect.String {
- arg, err = strconv.ParseUint(arg.(string), 10, 8)
+ value, err = strconv.ParseUint(arg.(string), 10, 8)
+ arg = uint8(value)
} else {
arg = uint8(arg.(float64))
}
case 16:
if k == reflect.String {
- arg, err = strconv.ParseUint(arg.(string), 10, 16)
+ value, err = strconv.ParseUint(arg.(string), 10, 16)
+ arg = uint16(value)
} else {
arg = uint16(arg.(float64))
}
case 32:
if k == reflect.String {
- arg, err = strconv.ParseUint(arg.(string), 10, 32)
+ value, err = strconv.ParseUint(arg.(string), 10, 32)
+ arg = uint32(value)
} else {
arg = uint32(arg.(float64))
}
