forked from TrueCloudLab/neoneo-go
rpc: move getassetstate RPC to a separate func
This commit is contained in:
parent
9e6785bed9
commit
70eb0b175a
1 changed files with 19 additions and 18 deletions
|
@ -277,24 +277,7 @@ Methods:
|
||||||
results = validateAddress(param.Value)
|
results = validateAddress(param.Value)
|
||||||
|
|
||||||
case "getassetstate":
|
case "getassetstate":
|
||||||
param, ok := reqParams.ValueWithType(0, request.StringT)
|
results, resultsErr = s.getAssetState(reqParams)
|
||||||
if !ok {
|
|
||||||
resultsErr = response.ErrInvalidParams
|
|
||||||
break Methods
|
|
||||||
}
|
|
||||||
|
|
||||||
paramAssetID, err := param.GetUint256()
|
|
||||||
if err != nil {
|
|
||||||
resultsErr = response.ErrInvalidParams
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
as := s.chain.GetAssetState(paramAssetID)
|
|
||||||
if as != nil {
|
|
||||||
results = result.NewAssetState(as)
|
|
||||||
} else {
|
|
||||||
resultsErr = response.NewRPCError("Unknown asset", "", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
case "getaccountstate":
|
case "getaccountstate":
|
||||||
results, resultsErr = s.getAccountState(reqParams, false)
|
results, resultsErr = s.getAccountState(reqParams, false)
|
||||||
|
@ -344,6 +327,24 @@ Methods:
|
||||||
s.WriteResponse(req, w, results)
|
s.WriteResponse(req, w, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) getAssetState(reqParams request.Params) (interface{}, error) {
|
||||||
|
param, ok := reqParams.ValueWithType(0, request.StringT)
|
||||||
|
if !ok {
|
||||||
|
return nil, response.ErrInvalidParams
|
||||||
|
}
|
||||||
|
|
||||||
|
paramAssetID, err := param.GetUint256()
|
||||||
|
if err != nil {
|
||||||
|
return nil, response.ErrInvalidParams
|
||||||
|
}
|
||||||
|
|
||||||
|
as := s.chain.GetAssetState(paramAssetID)
|
||||||
|
if as != nil {
|
||||||
|
return result.NewAssetState(as), nil
|
||||||
|
}
|
||||||
|
return nil, response.NewRPCError("Unknown asset", "", nil)
|
||||||
|
}
|
||||||
|
|
||||||
// getApplicationLog returns the contract log based on the specified txid.
|
// getApplicationLog returns the contract log based on the specified txid.
|
||||||
func (s *Server) getApplicationLog(reqParams request.Params) (interface{}, error) {
|
func (s *Server) getApplicationLog(reqParams request.Params) (interface{}, error) {
|
||||||
param, ok := reqParams.Value(0)
|
param, ok := reqParams.Value(0)
|
||||||
|
|
Loading…
Reference in a new issue