aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-07-05 05:12:14 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-07 16:43:49 +0800
commitaa22cf323ef408f0562817352f68197f8b982f75 (patch)
tree59377ef29bed1157494dd2d9abf22a7f5c029506 /rpc/api
parent492e5049d7cfac3b172655ea25d9a03f91f76047 (diff)
downloaddexon-aa22cf323ef408f0562817352f68197f8b982f75.tar
dexon-aa22cf323ef408f0562817352f68197f8b982f75.tar.gz
dexon-aa22cf323ef408f0562817352f68197f8b982f75.tar.bz2
dexon-aa22cf323ef408f0562817352f68197f8b982f75.tar.lz
dexon-aa22cf323ef408f0562817352f68197f8b982f75.tar.xz
dexon-aa22cf323ef408f0562817352f68197f8b982f75.tar.zst
dexon-aa22cf323ef408f0562817352f68197f8b982f75.zip
fix js arguments and TestContract passes
Diffstat (limited to 'rpc/api')
-rw-r--r--rpc/api/admin_args.go32
-rw-r--r--rpc/api/admin_js.go4
2 files changed, 19 insertions, 17 deletions
diff --git a/rpc/api/admin_args.go b/rpc/api/admin_args.go
index e7548c7be..532907905 100644
--- a/rpc/api/admin_args.go
+++ b/rpc/api/admin_args.go
@@ -114,7 +114,7 @@ func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) {
args.ListenPort = 8545
args.Apis = "net,eth,web3"
- if len(obj) >= 1 {
+ if len(obj) >= 1 && obj[0] != nil {
if addr, ok := obj[0].(string); ok {
args.ListenAddress = addr
} else {
@@ -122,7 +122,7 @@ func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) {
}
}
- if len(obj) >= 2 {
+ if len(obj) >= 2 && obj[1] != nil {
if port, ok := obj[1].(float64); ok && port >= 0 && port <= 64*1024 {
args.ListenPort = uint(port)
} else {
@@ -130,7 +130,7 @@ func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) {
}
}
- if len(obj) >= 3 {
+ if len(obj) >= 3 && obj[2] != nil {
if corsDomain, ok := obj[2].(string); ok {
args.CorsDomain = corsDomain
} else {
@@ -138,7 +138,7 @@ func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) {
}
}
- if len(obj) >= 4 {
+ if len(obj) >= 4 && obj[3] != nil {
if apis, ok := obj[3].(string); ok {
args.Apis = apis
} else {
@@ -229,7 +229,7 @@ func (args *SetGlobalRegistrarArgs) UnmarshalJSON(b []byte) (err error) {
}
}
- if len(obj) >= 2 {
+ if len(obj) >= 2 && obj[1] != nil {
if addr, ok := obj[1].(string); ok {
args.ContractAddress = addr
} else {
@@ -251,7 +251,7 @@ func (args *SetHashRegArgs) UnmarshalJSON(b []byte) (err error) {
return shared.NewDecodeParamError(err.Error())
}
- if len(obj) >= 1 {
+ if len(obj) >= 1 && obj[0] != nil {
if hashreg, ok := obj[0].(string); ok {
args.HashReg = hashreg
} else {
@@ -259,7 +259,7 @@ func (args *SetHashRegArgs) UnmarshalJSON(b []byte) (err error) {
}
}
- if len(obj) >= 2 {
+ if len(obj) >= 2 && obj[1] != nil {
if sender, ok := obj[1].(string); ok {
args.Sender = sender
} else {
@@ -281,7 +281,7 @@ func (args *SetUrlHintArgs) UnmarshalJSON(b []byte) (err error) {
return shared.NewDecodeParamError(err.Error())
}
- if len(obj) >= 1 {
+ if len(obj) >= 1 && obj[0] != nil {
if urlhint, ok := obj[0].(string); ok {
args.UrlHint = urlhint
} else {
@@ -289,7 +289,7 @@ func (args *SetUrlHintArgs) UnmarshalJSON(b []byte) (err error) {
}
}
- if len(obj) >= 2 {
+ if len(obj) >= 2 && obj[1] != nil {
if sender, ok := obj[1].(string); ok {
args.Sender = sender
} else {
@@ -388,17 +388,19 @@ func (args *RegisterUrlArgs) UnmarshalJSON(b []byte) (err error) {
}
if len(obj) >= 1 {
- if sender, ok := obj[1].(string); ok {
+ if sender, ok := obj[0].(string); ok {
args.Sender = sender
} else {
return shared.NewInvalidTypeError("Sender", "not a string")
}
}
- if sender, ok := obj[1].(string); ok {
- args.ContentHash = sender
- } else {
- return shared.NewInvalidTypeError("ContentHash", "not a string")
+ if len(obj) >= 2 {
+ if sender, ok := obj[1].(string); ok {
+ args.ContentHash = sender
+ } else {
+ return shared.NewInvalidTypeError("ContentHash", "not a string")
+ }
}
if len(obj) >= 3 {
@@ -460,7 +462,7 @@ func (args *HttpGetArgs) UnmarshalJSON(b []byte) (err error) {
}
}
- if len(obj) >= 2 {
+ if len(obj) >= 2 && obj[1] != nil {
if path, ok := obj[1].(string); ok {
args.Path = path
} else {
diff --git a/rpc/api/admin_js.go b/rpc/api/admin_js.go
index 2a9197da7..40c029fd1 100644
--- a/rpc/api/admin_js.go
+++ b/rpc/api/admin_js.go
@@ -92,8 +92,8 @@ web3._extend({
new web3._extend.Method({
name: 'register',
call: 'admin_register',
- params: 2,
- inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString],
+ params: 3,
+ inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString,web3._extend.utils.formatInputString],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({