mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
rpc: drop support for getassetstate
It's for UTXO assets and it's absent in Neo 3.
This commit is contained in:
parent
63eb6069b2
commit
232e1a2598
7 changed files with 0 additions and 138 deletions
|
@ -36,7 +36,6 @@ which would yield the response:
|
|||
| ------- |
|
||||
| `getaccountstate` |
|
||||
| `getapplicationlog` |
|
||||
| `getassetstate` |
|
||||
| `getbestblockhash` |
|
||||
| `getblock` |
|
||||
| `getblockcount` |
|
||||
|
|
|
@ -20,7 +20,6 @@ Supported methods
|
|||
|
||||
getaccountstate
|
||||
getapplicationlog
|
||||
getassetstate
|
||||
getbestblockhash
|
||||
getblock
|
||||
getblockcount
|
||||
|
|
|
@ -40,18 +40,6 @@ func (c *Client) GetApplicationLog(hash util.Uint256) (*result.ApplicationLog, e
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
// GetAssetState queries the asset information, based on the specified asset number.
|
||||
func (c *Client) GetAssetState(hash util.Uint256) (*result.AssetState, error) {
|
||||
var (
|
||||
params = request.NewRawParams(hash.StringLE())
|
||||
resp = &result.AssetState{}
|
||||
)
|
||||
if err := c.performRequest("getassetstate", params, resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// GetBestBlockHash returns the hash of the tallest block in the main chain.
|
||||
func (c *Client) GetBestBlockHash() (util.Uint256, error) {
|
||||
var resp = util.Uint256{}
|
||||
|
|
|
@ -204,30 +204,6 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
},
|
||||
},
|
||||
},
|
||||
"getassetstate": {
|
||||
{
|
||||
name: "positive",
|
||||
invoke: func(c *Client) (interface{}, error) {
|
||||
return c.GetAssetState(util.Uint256{})
|
||||
},
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"id":"0x1a5e0e3eac2abced7de9ee2de0820a5c85e63756fcdfc29b82fead86a7c07c78","type":0,"name":"NEO","amount":"100000000","available":"100000000","precision":0,"owner":"00","admin":"Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":4000000,"is_frozen":false}}`,
|
||||
result: func(c *Client) interface{} {
|
||||
return &result.AssetState{
|
||||
ID: core.GoverningTokenID(),
|
||||
AssetType: 0,
|
||||
Name: "NEO",
|
||||
Amount: util.Fixed8FromInt64(100000000),
|
||||
Available: util.Fixed8FromInt64(100000000),
|
||||
Precision: 0,
|
||||
Owner: "00",
|
||||
Admin: "Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt",
|
||||
Issuer: "AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM",
|
||||
Expiration: 4000000,
|
||||
IsFrozen: false,
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
"getbestblockhash": {
|
||||
{
|
||||
name: "positive",
|
||||
|
@ -981,12 +957,6 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
|
|||
return c.GetApplicationLog(util.Uint256{})
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "getassetstate_invalid_params_error",
|
||||
invoke: func(c *Client) (interface{}, error) {
|
||||
return c.GetAssetState(core.GoverningTokenID())
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "getbestblockhash_invalid_params_error",
|
||||
invoke: func(c *Client) (interface{}, error) {
|
||||
|
@ -1145,12 +1115,6 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
|
|||
return c.GetApplicationLog(util.Uint256{})
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "getassetstate_unmarshalling_error",
|
||||
invoke: func(c *Client) (interface{}, error) {
|
||||
return c.GetAssetState(core.GoverningTokenID())
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "getbestblockhash_unmarshalling_error",
|
||||
invoke: func(c *Client) (interface{}, error) {
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package result
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
)
|
||||
|
||||
// AssetState wrapper used for the representation of
|
||||
// state.Asset on the RPC Server.
|
||||
type AssetState struct {
|
||||
ID util.Uint256 `json:"id"`
|
||||
AssetType transaction.AssetType `json:"type"`
|
||||
Name string `json:"name"`
|
||||
Amount util.Fixed8 `json:"amount"`
|
||||
Available util.Fixed8 `json:"available"`
|
||||
Precision uint8 `json:"precision"`
|
||||
Owner string `json:"owner"`
|
||||
Admin string `json:"admin"`
|
||||
Issuer string `json:"issuer"`
|
||||
Expiration uint32 `json:"expiration"`
|
||||
IsFrozen bool `json:"is_frozen"`
|
||||
}
|
||||
|
||||
// NewAssetState creates a new Asset wrapper.
|
||||
func NewAssetState(a *state.Asset) AssetState {
|
||||
return AssetState{
|
||||
ID: a.ID,
|
||||
AssetType: a.AssetType,
|
||||
Name: a.GetName(),
|
||||
Amount: a.Amount,
|
||||
Available: a.Available,
|
||||
Precision: a.Precision,
|
||||
Owner: a.Owner.String(),
|
||||
Admin: address.Uint160ToString(a.Admin),
|
||||
Issuer: address.Uint160ToString(a.Issuer),
|
||||
Expiration: a.Expiration,
|
||||
IsFrozen: a.IsFrozen,
|
||||
}
|
||||
}
|
|
@ -81,7 +81,6 @@ const (
|
|||
var rpcHandlers = map[string]func(*Server, request.Params) (interface{}, *response.Error){
|
||||
"getaccountstate": (*Server).getAccountState,
|
||||
"getapplicationlog": (*Server).getApplicationLog,
|
||||
"getassetstate": (*Server).getAssetState,
|
||||
"getbestblockhash": (*Server).getBestBlockHash,
|
||||
"getblock": (*Server).getBlock,
|
||||
"getblockcount": (*Server).getBlockCount,
|
||||
|
@ -469,24 +468,6 @@ func (s *Server) validateAddress(reqParams request.Params) (interface{}, *respon
|
|||
return validateAddress(param.Value), nil
|
||||
}
|
||||
|
||||
func (s *Server) getAssetState(reqParams request.Params) (interface{}, *response.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.
|
||||
func (s *Server) getApplicationLog(reqParams request.Params) (interface{}, *response.Error) {
|
||||
param, ok := reqParams.Value(0)
|
||||
|
|
|
@ -299,34 +299,6 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
fail: true,
|
||||
},
|
||||
},
|
||||
"getassetstate": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["f882fb865bab84b99623f21eedd902286af7da8d8a4609d7acefce04c851dc1c"]`,
|
||||
result: func(e *executor) interface{} { return &result.AssetState{} },
|
||||
check: func(t *testing.T, e *executor, as interface{}) {
|
||||
res, ok := as.(*result.AssetState)
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, "00", res.Owner)
|
||||
assert.Equal(t, "AWKECj9RD8rS8RPcpCgYVjk1DeYyHwxZm3", res.Admin)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "negative",
|
||||
params: `["602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de2"]`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
name: "no params",
|
||||
params: `[]`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
name: "invalid hash",
|
||||
params: `["notahex"]`,
|
||||
fail: true,
|
||||
},
|
||||
},
|
||||
"getbestblockhash": {
|
||||
{
|
||||
params: "[]",
|
||||
|
|
Loading…
Reference in a new issue