forked from TrueCloudLab/neoneo-go
rpc: handlers parameters audit
Make them compatible with C#.
This commit is contained in:
parent
867bb708fc
commit
4072c2fa90
2 changed files with 40 additions and 44 deletions
|
@ -95,10 +95,17 @@ it only works for native contracts.
|
||||||
VM state is included to verbose response along with other transaction fields if
|
VM state is included to verbose response along with other transaction fields if
|
||||||
the transaction is already on chain.
|
the transaction is already on chain.
|
||||||
|
|
||||||
|
##### `getstateroot`
|
||||||
|
|
||||||
|
This method is able to accept state root hash instead of index, unlike the C# node
|
||||||
|
where only index is accepted.
|
||||||
|
|
||||||
##### `getstorage`
|
##### `getstorage`
|
||||||
|
|
||||||
This method doesn't work for the Ledger contract, you can get data via regular
|
This method doesn't work for the Ledger contract, you can get data via regular
|
||||||
`getblock` and `getrawtransaction` calls.
|
`getblock` and `getrawtransaction` calls. This method is able to get storage of
|
||||||
|
the native contract by its name (case-insensitive), unlike the C# node where
|
||||||
|
it only possible for index or hash.
|
||||||
|
|
||||||
#### `getnep17balances`
|
#### `getnep17balances`
|
||||||
|
|
||||||
|
|
|
@ -459,22 +459,18 @@ func (s *Server) getConnectionCount(_ request.Params) (interface{}, *response.Er
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) blockHashFromParam(param *request.Param) (util.Uint256, *response.Error) {
|
func (s *Server) blockHashFromParam(param *request.Param) (util.Uint256, *response.Error) {
|
||||||
var hash util.Uint256
|
var (
|
||||||
|
hash util.Uint256
|
||||||
|
err error
|
||||||
|
)
|
||||||
if param == nil {
|
if param == nil {
|
||||||
return hash, response.ErrInvalidParams
|
return hash, response.ErrInvalidParams
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := param.GetStringStrict(); err == nil {
|
if hash, err = param.GetUint256(); err != nil {
|
||||||
var err error
|
num, respErr := s.blockHeightFromParam(param)
|
||||||
hash, err = param.GetUint256()
|
if respErr != nil {
|
||||||
if err != nil {
|
return hash, respErr
|
||||||
return hash, response.ErrInvalidParams
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
num, err := s.blockHeightFromParam(param)
|
|
||||||
if err != nil {
|
|
||||||
return hash, response.ErrInvalidParams
|
|
||||||
}
|
}
|
||||||
hash = s.chain.GetHeaderHash(num)
|
hash = s.chain.GetHeaderHash(num)
|
||||||
}
|
}
|
||||||
|
@ -921,32 +917,28 @@ func (s *Server) contractScriptHashFromParam(param *request.Param) (util.Uint160
|
||||||
if param == nil {
|
if param == nil {
|
||||||
return result, response.ErrInvalidParams
|
return result, response.ErrInvalidParams
|
||||||
}
|
}
|
||||||
if _, err := param.GetStringStrict(); err == nil {
|
nameOrHashOrIndex, err := param.GetString()
|
||||||
var err error
|
if err != nil {
|
||||||
result, err = param.GetUint160FromAddressOrHex()
|
return result, response.ErrInvalidParams
|
||||||
if err == nil {
|
}
|
||||||
return result, nil
|
result, err = param.GetUint160FromAddressOrHex()
|
||||||
}
|
if err == nil {
|
||||||
name, err := param.GetString()
|
return result, nil
|
||||||
if err != nil {
|
}
|
||||||
return result, response.ErrInvalidParams
|
result, err = s.chain.GetNativeContractScriptHash(nameOrHashOrIndex)
|
||||||
}
|
if err == nil {
|
||||||
result, err = s.chain.GetNativeContractScriptHash(name)
|
return result, nil
|
||||||
if err != nil {
|
}
|
||||||
return result, response.NewRPCError("Unknown contract: querying by name is supported for native contracts only", "", nil)
|
id, err := strconv.Atoi(nameOrHashOrIndex)
|
||||||
}
|
if err != nil {
|
||||||
} else {
|
return result, response.NewRPCError("Unknown contract", "", err)
|
||||||
id, err := param.GetInt()
|
}
|
||||||
if err != nil {
|
if err := checkInt32(id); err != nil {
|
||||||
return result, response.ErrInvalidParams
|
return result, response.WrapErrorWithData(response.ErrInvalidParams, err)
|
||||||
}
|
}
|
||||||
if err := checkInt32(id); err != nil {
|
result, err = s.chain.GetContractScriptHash(int32(id))
|
||||||
return result, response.WrapErrorWithData(response.ErrInvalidParams, err)
|
if err != nil {
|
||||||
}
|
return result, response.NewRPCError("Unknown contract", "", err)
|
||||||
result, err = s.chain.GetContractScriptHash(int32(id))
|
|
||||||
if err != nil {
|
|
||||||
return result, response.NewRPCError("Unknown contract", "", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
@ -1176,7 +1168,7 @@ func (s *Server) getStateRoot(ps request.Params) (interface{}, *response.Error)
|
||||||
}
|
}
|
||||||
var rt *state.MPTRoot
|
var rt *state.MPTRoot
|
||||||
var h util.Uint256
|
var h util.Uint256
|
||||||
height, err := p.GetInt()
|
height, err := p.GetIntStrict()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if err := checkUint32(height); err != nil {
|
if err := checkUint32(height); err != nil {
|
||||||
return nil, response.WrapErrorWithData(response.ErrInvalidParams, err)
|
return nil, response.WrapErrorWithData(response.ErrInvalidParams, err)
|
||||||
|
@ -1557,10 +1549,7 @@ func (s *Server) submitNotaryRequest(ps request.Params) (interface{}, *response.
|
||||||
return nil, response.NewInternalServerError("P2PNotaryRequest was received, but P2PSignatureExtensions are disabled", nil)
|
return nil, response.NewInternalServerError("P2PNotaryRequest was received, but P2PSignatureExtensions are disabled", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ps) < 1 {
|
bytePayload, err := ps.Value(0).GetBytesBase64()
|
||||||
return nil, response.NewInvalidParamsError("not enough parameters", nil)
|
|
||||||
}
|
|
||||||
bytePayload, err := ps[0].GetBytesBase64()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, response.NewInvalidParamsError("not base64", err)
|
return nil, response.NewInvalidParamsError("not base64", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue