rpc: move ValidateAddress to the result package

Because it is a result of the RPC call.
This commit is contained in:
Roman Khimov 2020-01-13 11:33:04 +03:00
parent bfa2d54e16
commit c189062f40
4 changed files with 10 additions and 10 deletions

View file

@ -1,9 +1,9 @@
package wrappers package result
// ValidateAddressResponse represents response to validate address call. Notice // ValidateAddress represents result of the `validateaddress` call. Notice that
// Address is an interface{} here because server echoes back whatever address // Address is an interface{} here because server echoes back whatever address
// value user has sent to it, even if it's not a string. // value user has sent to it, even if it's not a string.
type ValidateAddressResponse struct { type ValidateAddress struct {
Address interface{} `json:"address"` Address interface{} `json:"address"`
IsValid bool `json:"isvalid"` IsValid bool `json:"isvalid"`
} }

View file

@ -555,8 +555,8 @@ func (s *Server) blockHeightFromParam(param *Param) (int, error) {
// validateAddress verifies that the address is a correct NEO address // validateAddress verifies that the address is a correct NEO address
// see https://docs.neo.org/en-us/node/cli/2.9.4/api/validateaddress.html // see https://docs.neo.org/en-us/node/cli/2.9.4/api/validateaddress.html
func validateAddress(addr interface{}) wrappers.ValidateAddressResponse { func validateAddress(addr interface{}) result.ValidateAddress {
resp := wrappers.ValidateAddressResponse{Address: addr} resp := result.ValidateAddress{Address: addr}
if addr, ok := addr.(string); ok { if addr, ok := addr.(string); ok {
_, err := address.StringToUint160(addr) _, err := address.StringToUint160(addr)
resp.IsValid = (err == nil) resp.IsValid = (err == nil)

View file

@ -50,9 +50,9 @@ type InvokeFunctionResponse struct {
// ValidateAddrResponse struct for testing. // ValidateAddrResponse struct for testing.
type ValidateAddrResponse struct { type ValidateAddrResponse struct {
Jsonrpc string `json:"jsonrpc"` Jsonrpc string `json:"jsonrpc"`
Result wrappers.ValidateAddressResponse `json:"result"` Result result.ValidateAddress `json:"result"`
ID int `json:"id"` ID int `json:"id"`
} }
// GetPeersResponse struct for testing. // GetPeersResponse struct for testing.

View file

@ -14,7 +14,7 @@ import (
"github.com/CityOfZion/neo-go/pkg/core" "github.com/CityOfZion/neo-go/pkg/core"
"github.com/CityOfZion/neo-go/pkg/core/transaction" "github.com/CityOfZion/neo-go/pkg/core/transaction"
"github.com/CityOfZion/neo-go/pkg/rpc/wrappers" "github.com/CityOfZion/neo-go/pkg/rpc/result"
"github.com/CityOfZion/neo-go/pkg/util" "github.com/CityOfZion/neo-go/pkg/util"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -527,7 +527,7 @@ var rpcTestCases = map[string][]rpcTestCase{
result: func(*executor) interface{} { result: func(*executor) interface{} {
return &ValidateAddrResponse{ return &ValidateAddrResponse{
Jsonrpc: defaultJSONRPC, Jsonrpc: defaultJSONRPC,
Result: wrappers.ValidateAddressResponse{ Result: result.ValidateAddress{
Address: float64(1), Address: float64(1),
IsValid: false, IsValid: false,
}, },