|
|
@ -108,8 +108,8 @@ func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
return NewDecodeParamError(err.Error()) |
|
|
|
return NewDecodeParamError(err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(obj) < 1 { |
|
|
|
if len(obj) < 2 { |
|
|
|
return NewInsufficientParamsError(len(obj), 1) |
|
|
|
return NewInsufficientParamsError(len(obj), 2) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
argstr, ok := obj[0].(string) |
|
|
|
argstr, ok := obj[0].(string) |
|
|
@ -118,9 +118,7 @@ func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
} |
|
|
|
} |
|
|
|
args.BlockHash = argstr |
|
|
|
args.BlockHash = argstr |
|
|
|
|
|
|
|
|
|
|
|
if len(obj) > 1 { |
|
|
|
args.IncludeTxs = obj[1].(bool) |
|
|
|
args.IncludeTxs = obj[1].(bool) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
@ -136,8 +134,8 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
return NewDecodeParamError(err.Error()) |
|
|
|
return NewDecodeParamError(err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(obj) < 1 { |
|
|
|
if len(obj) < 2 { |
|
|
|
return NewInsufficientParamsError(len(obj), 1) |
|
|
|
return NewInsufficientParamsError(len(obj), 2) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if v, ok := obj[0].(float64); ok { |
|
|
|
if v, ok := obj[0].(float64); ok { |
|
|
@ -148,9 +146,7 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
return NewInvalidTypeError("blockNumber", "not a number or string") |
|
|
|
return NewInvalidTypeError("blockNumber", "not a number or string") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(obj) > 1 { |
|
|
|
args.IncludeTxs = obj[1].(bool) |
|
|
|
args.IncludeTxs = obj[1].(bool) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
@ -202,7 +198,7 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
|
|
|
|
|
|
|
|
var num int64 |
|
|
|
var num int64 |
|
|
|
if ext.Value == nil { |
|
|
|
if ext.Value == nil { |
|
|
|
return NewValidationError("value", "is required") |
|
|
|
num = 0 |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if err := numString(ext.Value, &num); err != nil { |
|
|
|
if err := numString(ext.Value, &num); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
@ -211,7 +207,7 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
args.Value = big.NewInt(num) |
|
|
|
args.Value = big.NewInt(num) |
|
|
|
|
|
|
|
|
|
|
|
if ext.Gas == nil { |
|
|
|
if ext.Gas == nil { |
|
|
|
return NewValidationError("gas", "is required") |
|
|
|
num = 0 |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if err := numString(ext.Gas, &num); err != nil { |
|
|
|
if err := numString(ext.Gas, &num); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
@ -220,7 +216,7 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
args.Gas = big.NewInt(num) |
|
|
|
args.Gas = big.NewInt(num) |
|
|
|
|
|
|
|
|
|
|
|
if ext.GasPrice == nil { |
|
|
|
if ext.GasPrice == nil { |
|
|
|
return NewValidationError("gasprice", "is required") |
|
|
|
num = 0 |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if err := numString(ext.GasPrice, &num); err != nil { |
|
|
|
if err := numString(ext.GasPrice, &num); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
@ -233,6 +229,8 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
if err := blockHeightFromJson(obj[1], &args.BlockNumber); err != nil { |
|
|
|
if err := blockHeightFromJson(obj[1], &args.BlockNumber); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
args.BlockNumber = -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
@ -320,6 +318,8 @@ func (args *CallArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
if err := blockHeightFromJson(obj[1], &args.BlockNumber); err != nil { |
|
|
|
if err := blockHeightFromJson(obj[1], &args.BlockNumber); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
args.BlockNumber = -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
@ -350,6 +350,8 @@ func (args *GetStorageArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
if err := blockHeight(obj[1], &args.BlockNumber); err != nil { |
|
|
|
if err := blockHeight(obj[1], &args.BlockNumber); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
args.BlockNumber = -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
@ -387,6 +389,8 @@ func (args *GetStorageAtArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
if err := blockHeight(obj[2], &args.BlockNumber); err != nil { |
|
|
|
if err := blockHeight(obj[2], &args.BlockNumber); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
args.BlockNumber = -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
@ -417,6 +421,8 @@ func (args *GetTxCountArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
if err := blockHeight(obj[1], &args.BlockNumber); err != nil { |
|
|
|
if err := blockHeight(obj[1], &args.BlockNumber); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
args.BlockNumber = -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
@ -447,6 +453,8 @@ func (args *GetBalanceArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
if err := blockHeight(obj[1], &args.BlockNumber); err != nil { |
|
|
|
if err := blockHeight(obj[1], &args.BlockNumber); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
args.BlockNumber = -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
@ -477,6 +485,29 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
if err := blockHeight(obj[1], &args.BlockNumber); err != nil { |
|
|
|
if err := blockHeight(obj[1], &args.BlockNumber); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
args.BlockNumber = -1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type BlockNumArg struct { |
|
|
|
|
|
|
|
BlockNumber int64 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (args *BlockNumArg) UnmarshalJSON(b []byte) (err error) { |
|
|
|
|
|
|
|
var obj []interface{} |
|
|
|
|
|
|
|
if err := json.Unmarshal(b, &obj); err != nil { |
|
|
|
|
|
|
|
return NewDecodeParamError(err.Error()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(obj) < 1 { |
|
|
|
|
|
|
|
return NewInsufficientParamsError(len(obj), 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err := blockHeight(obj[0], &args.BlockNumber); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
@ -493,21 +524,42 @@ func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
return NewDecodeParamError(err.Error()) |
|
|
|
return NewDecodeParamError(err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(obj) < 1 { |
|
|
|
if len(obj) < 2 { |
|
|
|
return NewInsufficientParamsError(len(obj), 1) |
|
|
|
return NewInsufficientParamsError(len(obj), 2) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := blockHeight(obj[0], &args.BlockNumber); err != nil { |
|
|
|
if err := blockHeight(obj[0], &args.BlockNumber); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(obj) > 1 { |
|
|
|
arg1, ok := obj[1].(string) |
|
|
|
arg1, ok := obj[1].(string) |
|
|
|
if !ok { |
|
|
|
if !ok { |
|
|
|
return NewInvalidTypeError("index", "not a string") |
|
|
|
return NewInvalidTypeError("index", "not a string") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
args.Index = common.Big(arg1).Int64() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
args.Index = common.Big(arg1).Int64() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type HashArgs struct { |
|
|
|
|
|
|
|
Hash string |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (args *HashArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
|
|
|
|
var obj []interface{} |
|
|
|
|
|
|
|
if err := json.Unmarshal(b, &obj); err != nil { |
|
|
|
|
|
|
|
return NewDecodeParamError(err.Error()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(obj) < 1 { |
|
|
|
|
|
|
|
return NewInsufficientParamsError(len(obj), 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
arg0, ok := obj[0].(string) |
|
|
|
|
|
|
|
if !ok { |
|
|
|
|
|
|
|
return NewInvalidTypeError("hash", "not a string") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
args.Hash = arg0 |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
@ -523,8 +575,8 @@ func (args *HashIndexArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
return NewDecodeParamError(err.Error()) |
|
|
|
return NewDecodeParamError(err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(obj) < 1 { |
|
|
|
if len(obj) < 2 { |
|
|
|
return NewInsufficientParamsError(len(obj), 1) |
|
|
|
return NewInsufficientParamsError(len(obj), 2) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
arg0, ok := obj[0].(string) |
|
|
|
arg0, ok := obj[0].(string) |
|
|
@ -533,13 +585,11 @@ func (args *HashIndexArgs) UnmarshalJSON(b []byte) (err error) { |
|
|
|
} |
|
|
|
} |
|
|
|
args.Hash = arg0 |
|
|
|
args.Hash = arg0 |
|
|
|
|
|
|
|
|
|
|
|
if len(obj) > 1 { |
|
|
|
arg1, ok := obj[1].(string) |
|
|
|
arg1, ok := obj[1].(string) |
|
|
|
if !ok { |
|
|
|
if !ok { |
|
|
|
return NewInvalidTypeError("index", "not a string") |
|
|
|
return NewInvalidTypeError("index", "not a string") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
args.Index = common.Big(arg1).Int64() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
args.Index = common.Big(arg1).Int64() |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|