aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-10 09:38:37 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-10 09:38:37 +0800
commit3de51f76eea87f8e8a4b8a7277cd294529e28491 (patch)
treeac66ab30e460fdab050b3aab2add66b972010935 /rpc
parenta7538d0020d3a51ab3b25997b3c4f01db87d4c7a (diff)
downloadgo-tangerine-3de51f76eea87f8e8a4b8a7277cd294529e28491.tar.gz
go-tangerine-3de51f76eea87f8e8a4b8a7277cd294529e28491.tar.zst
go-tangerine-3de51f76eea87f8e8a4b8a7277cd294529e28491.zip
Allow integers for BlockNumber
If parsing fails, fall back to hex decoding
Diffstat (limited to 'rpc')
-rw-r--r--rpc/args.go27
1 files changed, 21 insertions, 6 deletions
diff --git a/rpc/args.go b/rpc/args.go
index 63969e598..9735feb62 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -47,7 +47,12 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
if len(obj) < 1 {
return errArguments
}
- args.BlockNumber = ethutil.Big(obj[0].(string)).Int64()
+
+ if v, ok := obj[0].(float64); ok {
+ args.BlockNumber = int64(v)
+ } else {
+ args.BlockNumber = ethutil.Big(obj[0].(string)).Int64()
+ }
if len(obj) > 1 {
args.Transactions = obj[1].(bool)
@@ -110,7 +115,9 @@ func (args *GetStorageArgs) UnmarshalJSON(b []byte) (err error) {
args.Address = obj[0].(string)
if len(obj) > 1 {
- if obj[1].(string) == "latest" {
+ if v, ok := obj[1].(float64); ok {
+ args.BlockNumber = int64(v)
+ } else if obj[1].(string) == "latest" {
args.BlockNumber = -1
} else {
args.BlockNumber = ethutil.Big(obj[1].(string)).Int64()
@@ -147,7 +154,9 @@ func (args *GetStorageAtArgs) UnmarshalJSON(b []byte) (err error) {
args.Key = obj[1].(string)
if len(obj) > 2 {
- if obj[2].(string) == "latest" {
+ if v, ok := obj[2].(float64); ok {
+ args.BlockNumber = int64(v)
+ } else if obj[2].(string) == "latest" {
args.BlockNumber = -1
} else {
args.BlockNumber = ethutil.Big(obj[2].(string)).Int64()
@@ -187,7 +196,9 @@ func (args *GetTxCountArgs) UnmarshalJSON(b []byte) (err error) {
args.Address = obj[0].(string)
if len(obj) > 1 {
- if obj[1].(string) == "latest" {
+ if v, ok := obj[1].(float64); ok {
+ args.BlockNumber = int64(v)
+ } else if obj[1].(string) == "latest" {
args.BlockNumber = -1
} else {
args.BlockNumber = ethutil.Big(obj[1].(string)).Int64()
@@ -222,7 +233,9 @@ func (args *GetBalanceArgs) UnmarshalJSON(b []byte) (err error) {
args.Address = obj[0].(string)
if len(obj) > 1 {
- if obj[1].(string) == "latest" {
+ if v, ok := obj[1].(float64); ok {
+ args.BlockNumber = int64(v)
+ } else if obj[1].(string) == "latest" {
args.BlockNumber = -1
} else {
args.BlockNumber = ethutil.Big(obj[1].(string)).Int64()
@@ -257,7 +270,9 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
args.Address = obj[0].(string)
if len(obj) > 1 {
- if obj[1].(string) == "latest" {
+ if v, ok := obj[1].(float64); ok {
+ args.BlockNumber = int64(v)
+ } else if obj[1].(string) == "latest" {
args.BlockNumber = -1
} else {
args.BlockNumber = ethutil.Big(obj[1].(string)).Int64()