aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/numbers.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-06-10 15:35:10 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-06-10 17:32:08 +0800
commit0f9539e1e3e77bb181d67591cfbb77f6a17e5537 (patch)
treecb957cfbcf678ebc5919727109e8f0015ee4a055 /accounts/abi/numbers.go
parent63d1d145e2b2c8db4106d87767842019492e0aea (diff)
downloadgo-tangerine-0f9539e1e3e77bb181d67591cfbb77f6a17e5537.tar
go-tangerine-0f9539e1e3e77bb181d67591cfbb77f6a17e5537.tar.gz
go-tangerine-0f9539e1e3e77bb181d67591cfbb77f6a17e5537.tar.bz2
go-tangerine-0f9539e1e3e77bb181d67591cfbb77f6a17e5537.tar.lz
go-tangerine-0f9539e1e3e77bb181d67591cfbb77f6a17e5537.tar.xz
go-tangerine-0f9539e1e3e77bb181d67591cfbb77f6a17e5537.tar.zst
go-tangerine-0f9539e1e3e77bb181d67591cfbb77f6a17e5537.zip
accounts/abi: fix uint64 upper range encoding.
Diffstat (limited to 'accounts/abi/numbers.go')
-rw-r--r--accounts/abi/numbers.go12
1 files changed, 3 insertions, 9 deletions
diff --git a/accounts/abi/numbers.go b/accounts/abi/numbers.go
index 06c4422f9..3d5842292 100644
--- a/accounts/abi/numbers.go
+++ b/accounts/abi/numbers.go
@@ -56,27 +56,21 @@ var (
big_ts = reflect.TypeOf([]*big.Int(nil))
)
-// U256 will ensure unsigned 256bit on big nums
+// U256 converts a big Int into a 256bit EVM number.
func U256(n *big.Int) []byte {
return common.LeftPadBytes(common.U256(n).Bytes(), 32)
}
-// S256 will ensure signed 256bit on big nums
-func U2U256(n uint64) []byte {
- return U256(big.NewInt(int64(n)))
-}
-
// packNum packs the given number (using the reflect value) and will cast it to appropriate number representation
func packNum(value reflect.Value) []byte {
switch kind := value.Kind(); kind {
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
- return U2U256(value.Uint())
+ return U256(new(big.Int).SetUint64(value.Uint()))
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return U2U256(uint64(value.Int()))
+ return U256(big.NewInt(value.Int()))
case reflect.Ptr:
return U256(value.Interface().(*big.Int))
}
-
return nil
}