rpc: merge response and request under pkg/neorpc

Move result there also.
This commit is contained in:
Roman Khimov 2022-07-22 19:09:29 +03:00
parent 2e27c3d829
commit 1e0750e3cd
55 changed files with 462 additions and 466 deletions

View file

@ -19,7 +19,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef" "github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"

View file

@ -12,7 +12,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate" "github.com/nspcc-dev/neo-go/pkg/vm/vmstate"

View file

@ -17,7 +17,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "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/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm"

View file

@ -21,8 +21,8 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "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/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/rpcclient"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef" "github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"

View file

@ -15,7 +15,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/rpcclient"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"

View file

@ -19,7 +19,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/neorpc/result/subscriptions"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
uatomic "go.uber.org/atomic" uatomic "go.uber.org/atomic"

View file

@ -33,7 +33,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/neorpc/result/subscriptions"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag" "github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"

View file

@ -36,7 +36,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/neotest" "github.com/nspcc-dev/neo-go/pkg/neotest"
"github.com/nspcc-dev/neo-go/pkg/neotest/chain" "github.com/nspcc-dev/neo-go/pkg/neotest/chain"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/neorpc/result/subscriptions"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"

View file

@ -12,7 +12,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/neorpc/result/subscriptions"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
) )

View file

@ -1,4 +1,4 @@
package response package neorpc
import ( import (
"fmt" "fmt"

View file

@ -1,4 +1,4 @@
package response package neorpc
import ( import (
"encoding/json" "encoding/json"

View file

@ -1,4 +1,9 @@
package request /*
Package neorpc contains a set of types used for JSON-RPC communication with Neo servers.
It defines basic request/response types as well as a set of errors and additional
parameters used for specific requests/responses.
*/
package neorpc
import ( import (
"encoding/json" "encoding/json"
@ -17,10 +22,10 @@ const (
) )
type ( type (
// Raw represents JSON-RPC request. It's generic enough to be used in many // Request represents JSON-RPC request. It's generic enough to be used in many
// generic JSON-RPC communication scenarios, yet at the same time it's // generic JSON-RPC communication scenarios, yet at the same time it's
// tailored for NeoGo RPC Client needs. // tailored for NeoGo RPC Client needs.
Raw struct { Request struct {
// JSONRPC is the protocol version, only valid when it contains JSONRPCVersion. // JSONRPC is the protocol version, only valid when it contains JSONRPCVersion.
JSONRPC string `json:"jsonrpc"` JSONRPC string `json:"jsonrpc"`
// Method is the method being called. // Method is the method being called.
@ -37,6 +42,35 @@ type (
ID uint64 `json:"id"` ID uint64 `json:"id"`
} }
// Header is a generic JSON-RPC 2.0 response header (ID and JSON-RPC version).
Header struct {
ID json.RawMessage `json:"id"`
JSONRPC string `json:"jsonrpc"`
}
// HeaderAndError adds an Error (that can be empty) to the Header, it's used
// to construct type-specific responses.
HeaderAndError struct {
Header
Error *Error `json:"error,omitempty"`
}
// Raw represents a standard raw JSON-RPC 2.0
// response: http://www.jsonrpc.org/specification#response_object.
Response struct {
HeaderAndError
Result json.RawMessage `json:"result,omitempty"`
}
// Notification is a type used to represent wire format of events, they're
// special in that they look like requests but they don't have IDs and their
// "method" is actually an event name.
Notification struct {
JSONRPC string `json:"jsonrpc"`
Event EventID `json:"method"`
Payload []interface{} `json:"params"`
}
// BlockFilter is a wrapper structure for the block event filter. The only // BlockFilter is a wrapper structure for the block event filter. The only
// allowed filter is primary index. // allowed filter is primary index.
BlockFilter struct { BlockFilter struct {

View file

@ -1,34 +0,0 @@
package response
import (
"encoding/json"
)
// Header is a generic JSON-RPC 2.0 response header (ID and JSON-RPC version).
type Header struct {
ID json.RawMessage `json:"id"`
JSONRPC string `json:"jsonrpc"`
}
// HeaderAndError adds an Error (that can be empty) to the Header, it's used
// to construct type-specific responses.
type HeaderAndError struct {
Header
Error *Error `json:"error,omitempty"`
}
// Raw represents a standard raw JSON-RPC 2.0
// response: http://www.jsonrpc.org/specification#response_object.
type Raw struct {
HeaderAndError
Result json.RawMessage `json:"result,omitempty"`
}
// Notification is a type used to represent wire format of events, they're
// special in that they look like requests but they don't have IDs and their
// "method" is actually an event name.
type Notification struct {
JSONRPC string `json:"jsonrpc"`
Event EventID `json:"method"`
Payload []interface{} `json:"params"`
}

View file

@ -13,8 +13,7 @@ import (
"time" "time"
"github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/config/netmode"
"github.com/nspcc-dev/neo-go/pkg/rpc/request" "github.com/nspcc-dev/neo-go/pkg/neorpc"
"github.com/nspcc-dev/neo-go/pkg/rpc/response"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"go.uber.org/atomic" "go.uber.org/atomic"
) )
@ -34,7 +33,7 @@ type Client struct {
endpoint *url.URL endpoint *url.URL
ctx context.Context ctx context.Context
opts Options opts Options
requestF func(*request.Raw) (*response.Raw, error) requestF func(*neorpc.Request) (*neorpc.Response, error)
cacheLock sync.RWMutex cacheLock sync.RWMutex
// cache stores RPC node related information the client is bound to. // cache stores RPC node related information the client is bound to.
@ -176,8 +175,8 @@ func (c *Client) performRequest(method string, p []interface{}, v interface{}) e
if p == nil { if p == nil {
p = []interface{}{} // neo-project/neo-modules#742 p = []interface{}{} // neo-project/neo-modules#742
} }
var r = request.Raw{ var r = neorpc.Request{
JSONRPC: request.JSONRPCVersion, JSONRPC: neorpc.JSONRPCVersion,
Method: method, Method: method,
Params: p, Params: p,
ID: c.getNextRequestID(), ID: c.getNextRequestID(),
@ -195,10 +194,10 @@ func (c *Client) performRequest(method string, p []interface{}, v interface{}) e
return json.Unmarshal(raw.Result, v) return json.Unmarshal(raw.Result, v)
} }
func (c *Client) makeHTTPRequest(r *request.Raw) (*response.Raw, error) { func (c *Client) makeHTTPRequest(r *neorpc.Request) (*neorpc.Response, error) {
var ( var (
buf = new(bytes.Buffer) buf = new(bytes.Buffer)
raw = new(response.Raw) raw = new(neorpc.Response)
) )
if err := json.NewEncoder(buf).Encode(r); err != nil { if err := json.NewEncoder(buf).Encode(r); err != nil {

View file

@ -10,8 +10,8 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nns" "github.com/nspcc-dev/neo-go/pkg/rpcclient/nns"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag" "github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"

View file

@ -11,8 +11,8 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles" "github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nns" "github.com/nspcc-dev/neo-go/pkg/rpcclient/nns"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
) )

View file

@ -7,7 +7,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "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/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag" "github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"

View file

@ -20,9 +20,9 @@ import (
"github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/neorpc"
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/network/payload" "github.com/nspcc-dev/neo-go/pkg/network/payload"
"github.com/nspcc-dev/neo-go/pkg/rpc/request"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
@ -694,9 +694,9 @@ func (c *Client) invokeSomething(method string, p []interface{}, signers []trans
if len(witnesses) != len(signers) { if len(witnesses) != len(signers) {
return nil, fmt.Errorf("number of witnesses should match number of signers, got %d vs %d", len(witnesses), len(signers)) return nil, fmt.Errorf("number of witnesses should match number of signers, got %d vs %d", len(witnesses), len(signers))
} }
signersWithWitnesses := make([]request.SignerWithWitness, len(signers)) signersWithWitnesses := make([]neorpc.SignerWithWitness, len(signers))
for i := range signersWithWitnesses { for i := range signersWithWitnesses {
signersWithWitnesses[i] = request.SignerWithWitness{ signersWithWitnesses[i] = neorpc.SignerWithWitness{
Signer: signers[i], Signer: signers[i],
Witness: witnesses[i], Witness: witnesses[i],
} }

View file

@ -27,7 +27,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params" "github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"

View file

@ -13,9 +13,8 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/core/state" "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/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/rpc/request" "github.com/nspcc-dev/neo-go/pkg/neorpc"
"github.com/nspcc-dev/neo-go/pkg/rpc/response" "github.com/nspcc-dev/neo-go/pkg/neorpc/result/subscriptions"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"go.uber.org/atomic" "go.uber.org/atomic"
) )
@ -38,7 +37,7 @@ type WSClient struct {
ws *websocket.Conn ws *websocket.Conn
done chan struct{} done chan struct{}
requests chan *request.Raw requests chan *neorpc.Request
shutdown chan struct{} shutdown chan struct{}
closeCalled atomic.Bool closeCalled atomic.Bool
@ -49,21 +48,21 @@ type WSClient struct {
subscriptions map[string]bool subscriptions map[string]bool
respLock sync.RWMutex respLock sync.RWMutex
respChannels map[uint64]chan *response.Raw respChannels map[uint64]chan *neorpc.Response
} }
// Notification represents a server-generated notification for client subscriptions. // Notification represents a server-generated notification for client subscriptions.
// Value can be one of block.Block, state.AppExecResult, subscriptions.NotificationEvent // Value can be one of block.Block, state.AppExecResult, subscriptions.NotificationEvent
// transaction.Transaction or subscriptions.NotaryRequestEvent based on Type. // transaction.Transaction or subscriptions.NotaryRequestEvent based on Type.
type Notification struct { type Notification struct {
Type response.EventID Type neorpc.EventID
Value interface{} Value interface{}
} }
// requestResponse is a combined type for request and response since we can get // requestResponse is a combined type for request and response since we can get
// any of them here. // any of them here.
type requestResponse struct { type requestResponse struct {
response.Raw neorpc.Response
Method string `json:"method"` Method string `json:"method"`
RawParams []json.RawMessage `json:"params,omitempty"` RawParams []json.RawMessage `json:"params,omitempty"`
} }
@ -103,8 +102,8 @@ func NewWS(ctx context.Context, endpoint string, opts Options) (*WSClient, error
shutdown: make(chan struct{}), shutdown: make(chan struct{}),
done: make(chan struct{}), done: make(chan struct{}),
closeCalled: *atomic.NewBool(false), closeCalled: *atomic.NewBool(false),
respChannels: make(map[uint64]chan *response.Raw), respChannels: make(map[uint64]chan *neorpc.Response),
requests: make(chan *request.Raw), requests: make(chan *neorpc.Request),
subscriptions: make(map[string]bool), subscriptions: make(map[string]bool),
} }
@ -159,20 +158,20 @@ readloop:
break readloop break readloop
} }
if rr.ID == nil && rr.Method != "" { if rr.ID == nil && rr.Method != "" {
event, err := response.GetEventIDFromString(rr.Method) event, err := neorpc.GetEventIDFromString(rr.Method)
if err != nil { if err != nil {
// Bad event received. // Bad event received.
connCloseErr = fmt.Errorf("failed to perse event ID from string %s: %w", rr.Method, err) connCloseErr = fmt.Errorf("failed to perse event ID from string %s: %w", rr.Method, err)
break readloop break readloop
} }
if event != response.MissedEventID && len(rr.RawParams) != 1 { if event != neorpc.MissedEventID && len(rr.RawParams) != 1 {
// Bad event received. // Bad event received.
connCloseErr = fmt.Errorf("bad event received: %s / %d", event, len(rr.RawParams)) connCloseErr = fmt.Errorf("bad event received: %s / %d", event, len(rr.RawParams))
break readloop break readloop
} }
var val interface{} var val interface{}
switch event { switch event {
case response.BlockEventID: case neorpc.BlockEventID:
sr, err := c.StateRootInHeader() sr, err := c.StateRootInHeader()
if err != nil { if err != nil {
// Client is not initialized. // Client is not initialized.
@ -180,22 +179,22 @@ readloop:
break readloop break readloop
} }
val = block.New(sr) val = block.New(sr)
case response.TransactionEventID: case neorpc.TransactionEventID:
val = &transaction.Transaction{} val = &transaction.Transaction{}
case response.NotificationEventID: case neorpc.NotificationEventID:
val = new(subscriptions.NotificationEvent) val = new(subscriptions.NotificationEvent)
case response.ExecutionEventID: case neorpc.ExecutionEventID:
val = new(state.AppExecResult) val = new(state.AppExecResult)
case response.NotaryRequestEventID: case neorpc.NotaryRequestEventID:
val = new(subscriptions.NotaryRequestEvent) val = new(subscriptions.NotaryRequestEvent)
case response.MissedEventID: case neorpc.MissedEventID:
// No value. // No value.
default: default:
// Bad event received. // Bad event received.
connCloseErr = fmt.Errorf("unknown event received: %d", event) connCloseErr = fmt.Errorf("unknown event received: %d", event)
break readloop break readloop
} }
if event != response.MissedEventID { if event != neorpc.MissedEventID {
err = json.Unmarshal(rr.RawParams[0], val) err = json.Unmarshal(rr.RawParams[0], val)
if err != nil { if err != nil {
// Bad event received. // Bad event received.
@ -215,7 +214,7 @@ readloop:
connCloseErr = fmt.Errorf("unknown response channel for response %d", id) connCloseErr = fmt.Errorf("unknown response channel for response %d", id)
break readloop // Unknown response (unexpected response ID). break readloop // Unknown response (unexpected response ID).
} }
ch <- &rr.Raw ch <- &rr.Response
} else { } else {
// Malformed response, neither valid request, nor valid response. // Malformed response, neither valid request, nor valid response.
connCloseErr = fmt.Errorf("malformed response") connCloseErr = fmt.Errorf("malformed response")
@ -284,14 +283,14 @@ func (c *WSClient) unregisterRespChannel(id uint64) {
} }
} }
func (c *WSClient) getResponseChannel(id uint64) chan *response.Raw { func (c *WSClient) getResponseChannel(id uint64) chan *neorpc.Response {
c.respLock.RLock() c.respLock.RLock()
defer c.respLock.RUnlock() defer c.respLock.RUnlock()
return c.respChannels[id] return c.respChannels[id]
} }
func (c *WSClient) makeWsRequest(r *request.Raw) (*response.Raw, error) { func (c *WSClient) makeWsRequest(r *neorpc.Request) (*neorpc.Response, error) {
ch := make(chan *response.Raw) ch := make(chan *neorpc.Response)
c.respLock.Lock() c.respLock.Lock()
select { select {
case <-c.done: case <-c.done:
@ -354,7 +353,7 @@ func (c *WSClient) performUnsubscription(id string) error {
func (c *WSClient) SubscribeForNewBlocks(primary *int) (string, error) { func (c *WSClient) SubscribeForNewBlocks(primary *int) (string, error) {
params := []interface{}{"block_added"} params := []interface{}{"block_added"}
if primary != nil { if primary != nil {
params = append(params, request.BlockFilter{Primary: *primary}) params = append(params, neorpc.BlockFilter{Primary: *primary})
} }
return c.performSubscription(params) return c.performSubscription(params)
} }
@ -365,7 +364,7 @@ func (c *WSClient) SubscribeForNewBlocks(primary *int) (string, error) {
func (c *WSClient) SubscribeForNewTransactions(sender *util.Uint160, signer *util.Uint160) (string, error) { func (c *WSClient) SubscribeForNewTransactions(sender *util.Uint160, signer *util.Uint160) (string, error) {
params := []interface{}{"transaction_added"} params := []interface{}{"transaction_added"}
if sender != nil || signer != nil { if sender != nil || signer != nil {
params = append(params, request.TxFilter{Sender: sender, Signer: signer}) params = append(params, neorpc.TxFilter{Sender: sender, Signer: signer})
} }
return c.performSubscription(params) return c.performSubscription(params)
} }
@ -377,7 +376,7 @@ func (c *WSClient) SubscribeForNewTransactions(sender *util.Uint160, signer *uti
func (c *WSClient) SubscribeForExecutionNotifications(contract *util.Uint160, name *string) (string, error) { func (c *WSClient) SubscribeForExecutionNotifications(contract *util.Uint160, name *string) (string, error) {
params := []interface{}{"notification_from_execution"} params := []interface{}{"notification_from_execution"}
if contract != nil || name != nil { if contract != nil || name != nil {
params = append(params, request.NotificationFilter{Contract: contract, Name: name}) params = append(params, neorpc.NotificationFilter{Contract: contract, Name: name})
} }
return c.performSubscription(params) return c.performSubscription(params)
} }
@ -392,7 +391,7 @@ func (c *WSClient) SubscribeForTransactionExecutions(state *string) (string, err
if *state != "HALT" && *state != "FAULT" { if *state != "HALT" && *state != "FAULT" {
return "", errors.New("bad state parameter") return "", errors.New("bad state parameter")
} }
params = append(params, request.ExecutionFilter{State: *state}) params = append(params, neorpc.ExecutionFilter{State: *state})
} }
return c.performSubscription(params) return c.performSubscription(params)
} }
@ -404,7 +403,7 @@ func (c *WSClient) SubscribeForTransactionExecutions(state *string) (string, err
func (c *WSClient) SubscribeForNotaryRequests(sender *util.Uint160, mainSigner *util.Uint160) (string, error) { func (c *WSClient) SubscribeForNotaryRequests(sender *util.Uint160, mainSigner *util.Uint160) (string, error) {
params := []interface{}{"notary_request_event"} params := []interface{}{"notary_request_event"}
if sender != nil { if sender != nil {
params = append(params, request.TxFilter{Sender: sender, Signer: mainSigner}) params = append(params, neorpc.TxFilter{Sender: sender, Signer: mainSigner})
} }
return c.performSubscription(params) return c.performSubscription(params)
} }

View file

@ -16,8 +16,8 @@ import (
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/config/netmode"
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/neorpc"
"github.com/nspcc-dev/neo-go/pkg/network/payload" "github.com/nspcc-dev/neo-go/pkg/network/payload"
"github.com/nspcc-dev/neo-go/pkg/rpc/request"
"github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params" "github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -200,7 +200,7 @@ func TestWSFilteredSubscriptions(t *testing.T) {
}, },
func(t *testing.T, p *params.Params) { func(t *testing.T, p *params.Params) {
param := p.Value(1) param := p.Value(1)
filt := new(request.BlockFilter) filt := new(neorpc.BlockFilter)
require.NoError(t, json.Unmarshal(param.RawMessage, filt)) require.NoError(t, json.Unmarshal(param.RawMessage, filt))
require.Equal(t, 3, filt.Primary) require.Equal(t, 3, filt.Primary)
}, },
@ -213,7 +213,7 @@ func TestWSFilteredSubscriptions(t *testing.T) {
}, },
func(t *testing.T, p *params.Params) { func(t *testing.T, p *params.Params) {
param := p.Value(1) param := p.Value(1)
filt := new(request.TxFilter) filt := new(neorpc.TxFilter)
require.NoError(t, json.Unmarshal(param.RawMessage, filt)) require.NoError(t, json.Unmarshal(param.RawMessage, filt))
require.Equal(t, util.Uint160{1, 2, 3, 4, 5}, *filt.Sender) require.Equal(t, util.Uint160{1, 2, 3, 4, 5}, *filt.Sender)
require.Nil(t, filt.Signer) require.Nil(t, filt.Signer)
@ -227,7 +227,7 @@ func TestWSFilteredSubscriptions(t *testing.T) {
}, },
func(t *testing.T, p *params.Params) { func(t *testing.T, p *params.Params) {
param := p.Value(1) param := p.Value(1)
filt := new(request.TxFilter) filt := new(neorpc.TxFilter)
require.NoError(t, json.Unmarshal(param.RawMessage, filt)) require.NoError(t, json.Unmarshal(param.RawMessage, filt))
require.Nil(t, filt.Sender) require.Nil(t, filt.Sender)
require.Equal(t, util.Uint160{0, 42}, *filt.Signer) require.Equal(t, util.Uint160{0, 42}, *filt.Signer)
@ -242,7 +242,7 @@ func TestWSFilteredSubscriptions(t *testing.T) {
}, },
func(t *testing.T, p *params.Params) { func(t *testing.T, p *params.Params) {
param := p.Value(1) param := p.Value(1)
filt := new(request.TxFilter) filt := new(neorpc.TxFilter)
require.NoError(t, json.Unmarshal(param.RawMessage, filt)) require.NoError(t, json.Unmarshal(param.RawMessage, filt))
require.Equal(t, util.Uint160{1, 2, 3, 4, 5}, *filt.Sender) require.Equal(t, util.Uint160{1, 2, 3, 4, 5}, *filt.Sender)
require.Equal(t, util.Uint160{0, 42}, *filt.Signer) require.Equal(t, util.Uint160{0, 42}, *filt.Signer)
@ -256,7 +256,7 @@ func TestWSFilteredSubscriptions(t *testing.T) {
}, },
func(t *testing.T, p *params.Params) { func(t *testing.T, p *params.Params) {
param := p.Value(1) param := p.Value(1)
filt := new(request.NotificationFilter) filt := new(neorpc.NotificationFilter)
require.NoError(t, json.Unmarshal(param.RawMessage, filt)) require.NoError(t, json.Unmarshal(param.RawMessage, filt))
require.Equal(t, util.Uint160{1, 2, 3, 4, 5}, *filt.Contract) require.Equal(t, util.Uint160{1, 2, 3, 4, 5}, *filt.Contract)
require.Nil(t, filt.Name) require.Nil(t, filt.Name)
@ -270,7 +270,7 @@ func TestWSFilteredSubscriptions(t *testing.T) {
}, },
func(t *testing.T, p *params.Params) { func(t *testing.T, p *params.Params) {
param := p.Value(1) param := p.Value(1)
filt := new(request.NotificationFilter) filt := new(neorpc.NotificationFilter)
require.NoError(t, json.Unmarshal(param.RawMessage, filt)) require.NoError(t, json.Unmarshal(param.RawMessage, filt))
require.Equal(t, "my_pretty_notification", *filt.Name) require.Equal(t, "my_pretty_notification", *filt.Name)
require.Nil(t, filt.Contract) require.Nil(t, filt.Contract)
@ -285,7 +285,7 @@ func TestWSFilteredSubscriptions(t *testing.T) {
}, },
func(t *testing.T, p *params.Params) { func(t *testing.T, p *params.Params) {
param := p.Value(1) param := p.Value(1)
filt := new(request.NotificationFilter) filt := new(neorpc.NotificationFilter)
require.NoError(t, json.Unmarshal(param.RawMessage, filt)) require.NoError(t, json.Unmarshal(param.RawMessage, filt))
require.Equal(t, util.Uint160{1, 2, 3, 4, 5}, *filt.Contract) require.Equal(t, util.Uint160{1, 2, 3, 4, 5}, *filt.Contract)
require.Equal(t, "my_pretty_notification", *filt.Name) require.Equal(t, "my_pretty_notification", *filt.Name)
@ -299,7 +299,7 @@ func TestWSFilteredSubscriptions(t *testing.T) {
}, },
func(t *testing.T, p *params.Params) { func(t *testing.T, p *params.Params) {
param := p.Value(1) param := p.Value(1)
filt := new(request.ExecutionFilter) filt := new(neorpc.ExecutionFilter)
require.NoError(t, json.Unmarshal(param.RawMessage, filt)) require.NoError(t, json.Unmarshal(param.RawMessage, filt))
require.Equal(t, "FAULT", filt.State) require.Equal(t, "FAULT", filt.State)
}, },

View file

@ -26,8 +26,8 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/network" "github.com/nspcc-dev/neo-go/pkg/network"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
"github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/rpcclient"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nns" "github.com/nspcc-dev/neo-go/pkg/rpcclient/nns"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"

View file

@ -3,25 +3,25 @@ package rpcsrv
import ( import (
"net/http" "net/http"
"github.com/nspcc-dev/neo-go/pkg/rpc/response" "github.com/nspcc-dev/neo-go/pkg/neorpc"
) )
// abstractResult is an interface which represents either single JSON-RPC 2.0 response // abstractResult is an interface which represents either single JSON-RPC 2.0 response
// or batch JSON-RPC 2.0 response. // or batch JSON-RPC 2.0 response.
type abstractResult interface { type abstractResult interface {
RunForErrors(f func(jsonErr *response.Error)) RunForErrors(f func(jsonErr *neorpc.Error))
} }
// abstract represents abstract JSON-RPC 2.0 response. It is used as a server-side response // abstract represents abstract JSON-RPC 2.0 response. It is used as a server-side response
// representation. // representation.
type abstract struct { type abstract struct {
response.Header neorpc.Header
Error *response.Error `json:"error,omitempty"` Error *neorpc.Error `json:"error,omitempty"`
Result interface{} `json:"result,omitempty"` Result interface{} `json:"result,omitempty"`
} }
// RunForErrors implements abstractResult interface. // RunForErrors implements abstractResult interface.
func (a abstract) RunForErrors(f func(jsonErr *response.Error)) { func (a abstract) RunForErrors(f func(jsonErr *neorpc.Error)) {
if a.Error != nil { if a.Error != nil {
f(a.Error) f(a.Error)
} }
@ -31,7 +31,7 @@ func (a abstract) RunForErrors(f func(jsonErr *response.Error)) {
type abstractBatch []abstract type abstractBatch []abstract
// RunForErrors implements abstractResult interface. // RunForErrors implements abstractResult interface.
func (ab abstractBatch) RunForErrors(f func(jsonErr *response.Error)) { func (ab abstractBatch) RunForErrors(f func(jsonErr *neorpc.Error)) {
for _, a := range ab { for _, a := range ab {
if a.Error != nil { if a.Error != nil {
f(a.Error) f(a.Error)
@ -39,16 +39,16 @@ func (ab abstractBatch) RunForErrors(f func(jsonErr *response.Error)) {
} }
} }
func getHTTPCodeForError(respErr *response.Error) int { func getHTTPCodeForError(respErr *neorpc.Error) int {
var httpCode int var httpCode int
switch respErr.Code { switch respErr.Code {
case response.BadRequestCode: case neorpc.BadRequestCode:
httpCode = http.StatusBadRequest httpCode = http.StatusBadRequest
case response.InvalidRequestCode, response.RPCErrorCode, response.InvalidParamsCode: case neorpc.InvalidRequestCode, neorpc.RPCErrorCode, neorpc.InvalidParamsCode:
httpCode = http.StatusUnprocessableEntity httpCode = http.StatusUnprocessableEntity
case response.MethodNotFoundCode: case neorpc.MethodNotFoundCode:
httpCode = http.StatusMethodNotAllowed httpCode = http.StatusMethodNotAllowed
case response.InternalServerErrorCode: case neorpc.InternalServerErrorCode:
httpCode = http.StatusInternalServerError httpCode = http.StatusInternalServerError
default: default:
httpCode = http.StatusUnprocessableEntity httpCode = http.StatusUnprocessableEntity

View file

@ -14,7 +14,7 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "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/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/rpc/request" "github.com/nspcc-dev/neo-go/pkg/neorpc"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
) )
@ -380,13 +380,13 @@ func (p *Param) GetBytesBase64() ([]byte, error) {
return base64.StdEncoding.DecodeString(s) return base64.StdEncoding.DecodeString(s)
} }
// GetSignerWithWitness returns a request.SignerWithWitness value of the parameter. // GetSignerWithWitness returns a neorpc.SignerWithWitness value of the parameter.
func (p *Param) GetSignerWithWitness() (request.SignerWithWitness, error) { func (p *Param) GetSignerWithWitness() (neorpc.SignerWithWitness, error) {
// This one doesn't need to be cached, it's used only once. // This one doesn't need to be cached, it's used only once.
c := request.SignerWithWitness{} c := neorpc.SignerWithWitness{}
err := json.Unmarshal(p.RawMessage, &c) err := json.Unmarshal(p.RawMessage, &c)
if err != nil { if err != nil {
return request.SignerWithWitness{}, fmt.Errorf("not a signer: %w", err) return neorpc.SignerWithWitness{}, fmt.Errorf("not a signer: %w", err)
} }
return c, nil return c, nil
} }

View file

@ -12,7 +12,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "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/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/rpc/request" "github.com/nspcc-dev/neo-go/pkg/neorpc"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -155,7 +155,7 @@ func TestParam_UnmarshalJSON(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
expectedAcc, err := util.Uint160DecodeStringLE("cadb3dc2faa3ef14a13b619c9a43124755aa2569") expectedAcc, err := util.Uint160DecodeStringLE("cadb3dc2faa3ef14a13b619c9a43124755aa2569")
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, request.SignerWithWitness{Signer: transaction.Signer{Account: expectedAcc}}, actual) require.Equal(t, neorpc.SignerWithWitness{Signer: transaction.Signer{Account: expectedAcc}}, actual)
}, },
expectedRawMessage: []byte(`{"account": "0xcadb3dc2faa3ef14a13b619c9a43124755aa2569"}`), expectedRawMessage: []byte(`{"account": "0xcadb3dc2faa3ef14a13b619c9a43124755aa2569"}`),
}, },
@ -165,7 +165,7 @@ func TestParam_UnmarshalJSON(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
expectedAcc, err := address.StringToUint160("NYxb4fSZVKAz8YsgaPK2WkT3KcAE9b3Vag") expectedAcc, err := address.StringToUint160("NYxb4fSZVKAz8YsgaPK2WkT3KcAE9b3Vag")
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, request.SignerWithWitness{Signer: transaction.Signer{Account: expectedAcc, Scopes: transaction.Global}}, actual) require.Equal(t, neorpc.SignerWithWitness{Signer: transaction.Signer{Account: expectedAcc, Scopes: transaction.Global}}, actual)
}, },
expectedRawMessage: []byte(`{"account": "NYxb4fSZVKAz8YsgaPK2WkT3KcAE9b3Vag", "scopes": "Global"}`), expectedRawMessage: []byte(`{"account": "NYxb4fSZVKAz8YsgaPK2WkT3KcAE9b3Vag", "scopes": "Global"}`),
}, },
@ -244,21 +244,21 @@ func TestGetWitness(t *testing.T) {
testCases := []struct { testCases := []struct {
raw string raw string
expected request.SignerWithWitness expected neorpc.SignerWithWitness
}{ }{
{`{"account": "0xcadb3dc2faa3ef14a13b619c9a43124755aa2569"}`, request.SignerWithWitness{ {`{"account": "0xcadb3dc2faa3ef14a13b619c9a43124755aa2569"}`, neorpc.SignerWithWitness{
Signer: transaction.Signer{ Signer: transaction.Signer{
Account: accountHash, Account: accountHash,
Scopes: transaction.None, Scopes: transaction.None,
}}, }},
}, },
{`{"account": "NYxb4fSZVKAz8YsgaPK2WkT3KcAE9b3Vag", "scopes": "Global"}`, request.SignerWithWitness{ {`{"account": "NYxb4fSZVKAz8YsgaPK2WkT3KcAE9b3Vag", "scopes": "Global"}`, neorpc.SignerWithWitness{
Signer: transaction.Signer{ Signer: transaction.Signer{
Account: addrHash, Account: addrHash,
Scopes: transaction.Global, Scopes: transaction.Global,
}}, }},
}, },
{`{"account": "0xcadb3dc2faa3ef14a13b619c9a43124755aa2569", "scopes": "Global"}`, request.SignerWithWitness{ {`{"account": "0xcadb3dc2faa3ef14a13b619c9a43124755aa2569", "scopes": "Global"}`, neorpc.SignerWithWitness{
Signer: transaction.Signer{ Signer: transaction.Signer{
Account: accountHash, Account: accountHash,
Scopes: transaction.Global, Scopes: transaction.Global,
@ -405,7 +405,7 @@ func TestParamGetBytesBase64(t *testing.T) {
} }
func TestParamGetSigner(t *testing.T) { func TestParamGetSigner(t *testing.T) {
c := request.SignerWithWitness{ c := neorpc.SignerWithWitness{
Signer: transaction.Signer{ Signer: transaction.Signer{
Account: util.Uint160{1, 2, 3, 4}, Account: util.Uint160{1, 2, 3, 4},
Scopes: transaction.Global, Scopes: transaction.Global,

View file

@ -7,7 +7,7 @@ import (
"fmt" "fmt"
"io" "io"
"github.com/nspcc-dev/neo-go/pkg/rpc/request" "github.com/nspcc-dev/neo-go/pkg/neorpc"
) )
const ( const (
@ -106,6 +106,6 @@ func NewRequest() *Request {
// NewIn creates a new In struct. // NewIn creates a new In struct.
func NewIn() *In { func NewIn() *In {
return &In{ return &In{
JSONRPC: request.JSONRPCVersion, JSONRPC: neorpc.JSONRPCVersion,
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -33,12 +33,12 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/neorpc"
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/network" "github.com/nspcc-dev/neo-go/pkg/network"
"github.com/nspcc-dev/neo-go/pkg/network/payload" "github.com/nspcc-dev/neo-go/pkg/network/payload"
"github.com/nspcc-dev/neo-go/pkg/rpc/response"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
"github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params"
rpc2 "github.com/nspcc-dev/neo-go/pkg/services/oracle/broadcaster" rpc2 "github.com/nspcc-dev/neo-go/pkg/services/oracle/broadcaster"
"github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/emit"
@ -1928,11 +1928,11 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
} }
resultRPC = `[` + resultRPC[:len(resultRPC)-1] + `]` resultRPC = `[` + resultRPC[:len(resultRPC)-1] + `]`
body := doRPCCall(resultRPC, httpSrv.URL, t) body := doRPCCall(resultRPC, httpSrv.URL, t)
var responses []response.Raw var responses []neorpc.Response
err := json.Unmarshal(body, &responses) err := json.Unmarshal(body, &responses)
require.Nil(t, err) require.Nil(t, err)
for i, tc := range cases { for i, tc := range cases {
var resp response.Raw var resp neorpc.Response
for _, r := range responses { for _, r := range responses {
if bytes.Equal(r.ID, []byte(strconv.Itoa(i))) { if bytes.Equal(r.ID, []byte(strconv.Itoa(i))) {
resp = r resp = r
@ -2478,7 +2478,7 @@ func (tc rpcTestCase) getResultPair(e *executor) (expected interface{}, res inte
} }
func checkErrGetResult(t *testing.T, body []byte, expectingFail bool, expectedErr ...string) json.RawMessage { func checkErrGetResult(t *testing.T, body []byte, expectingFail bool, expectedErr ...string) json.RawMessage {
var resp response.Raw var resp neorpc.Response
err := json.Unmarshal(body, &resp) err := json.Unmarshal(body, &resp)
require.Nil(t, err) require.Nil(t, err)
if expectingFail { if expectingFail {
@ -2495,7 +2495,7 @@ func checkErrGetResult(t *testing.T, body []byte, expectingFail bool, expectedEr
} }
func checkErrGetBatchResult(t *testing.T, body []byte, expectingFail bool) json.RawMessage { func checkErrGetBatchResult(t *testing.T, body []byte, expectingFail bool) json.RawMessage {
var resp []response.Raw var resp []neorpc.Response
err := json.Unmarshal(body, &resp) err := json.Unmarshal(body, &resp)
require.Nil(t, err) require.Nil(t, err)
require.Equal(t, 1, len(resp)) require.Equal(t, 1, len(resp))

View file

@ -5,9 +5,8 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/core/state" "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/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/rpc/request" "github.com/nspcc-dev/neo-go/pkg/neorpc"
"github.com/nspcc-dev/neo-go/pkg/rpc/response" "github.com/nspcc-dev/neo-go/pkg/neorpc/result/subscriptions"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
"go.uber.org/atomic" "go.uber.org/atomic"
) )
@ -24,7 +23,7 @@ type (
feeds [maxFeeds]feed feeds [maxFeeds]feed
} }
feed struct { feed struct {
event response.EventID event neorpc.EventID
filter interface{} filter interface{}
} }
) )
@ -44,7 +43,7 @@ const (
notificationBufSize = 1024 notificationBufSize = 1024
) )
func (f *feed) Matches(r *response.Notification) bool { func (f *feed) Matches(r *neorpc.Notification) bool {
if r.Event != f.event { if r.Event != f.event {
return false return false
} }
@ -52,12 +51,12 @@ func (f *feed) Matches(r *response.Notification) bool {
return true return true
} }
switch f.event { switch f.event {
case response.BlockEventID: case neorpc.BlockEventID:
filt := f.filter.(request.BlockFilter) filt := f.filter.(neorpc.BlockFilter)
b := r.Payload[0].(*block.Block) b := r.Payload[0].(*block.Block)
return int(b.PrimaryIndex) == filt.Primary return int(b.PrimaryIndex) == filt.Primary
case response.TransactionEventID: case neorpc.TransactionEventID:
filt := f.filter.(request.TxFilter) filt := f.filter.(neorpc.TxFilter)
tx := r.Payload[0].(*transaction.Transaction) tx := r.Payload[0].(*transaction.Transaction)
senderOK := filt.Sender == nil || tx.Sender().Equals(*filt.Sender) senderOK := filt.Sender == nil || tx.Sender().Equals(*filt.Sender)
signerOK := true signerOK := true
@ -71,18 +70,18 @@ func (f *feed) Matches(r *response.Notification) bool {
} }
} }
return senderOK && signerOK return senderOK && signerOK
case response.NotificationEventID: case neorpc.NotificationEventID:
filt := f.filter.(request.NotificationFilter) filt := f.filter.(neorpc.NotificationFilter)
notification := r.Payload[0].(*subscriptions.NotificationEvent) notification := r.Payload[0].(*subscriptions.NotificationEvent)
hashOk := filt.Contract == nil || notification.ScriptHash.Equals(*filt.Contract) hashOk := filt.Contract == nil || notification.ScriptHash.Equals(*filt.Contract)
nameOk := filt.Name == nil || notification.Name == *filt.Name nameOk := filt.Name == nil || notification.Name == *filt.Name
return hashOk && nameOk return hashOk && nameOk
case response.ExecutionEventID: case neorpc.ExecutionEventID:
filt := f.filter.(request.ExecutionFilter) filt := f.filter.(neorpc.ExecutionFilter)
applog := r.Payload[0].(*state.AppExecResult) applog := r.Payload[0].(*state.AppExecResult)
return applog.VMState.String() == filt.State return applog.VMState.String() == filt.State
case response.NotaryRequestEventID: case neorpc.NotaryRequestEventID:
filt := f.filter.(request.TxFilter) filt := f.filter.(neorpc.TxFilter)
req := r.Payload[0].(*subscriptions.NotaryRequestEvent) req := r.Payload[0].(*subscriptions.NotaryRequestEvent)
senderOk := filt.Sender == nil || req.NotaryRequest.FallbackTransaction.Signers[1].Account == *filt.Sender senderOk := filt.Sender == nil || req.NotaryRequest.FallbackTransaction.Signers[1].Account == *filt.Sender
signerOK := true signerOK := true

View file

@ -11,7 +11,7 @@ import (
"github.com/nspcc-dev/neo-go/internal/testchain" "github.com/nspcc-dev/neo-go/internal/testchain"
"github.com/nspcc-dev/neo-go/pkg/core" "github.com/nspcc-dev/neo-go/pkg/core"
"github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/rpc/response" "github.com/nspcc-dev/neo-go/pkg/neorpc"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.uber.org/atomic" "go.uber.org/atomic"
) )
@ -36,8 +36,8 @@ func wsReader(t *testing.T, ws *websocket.Conn, msgCh chan<- []byte, isFinished
} }
} }
func callWSGetRaw(t *testing.T, ws *websocket.Conn, msg string, respCh <-chan []byte) *response.Raw { func callWSGetRaw(t *testing.T, ws *websocket.Conn, msg string, respCh <-chan []byte) *neorpc.Response {
var resp = new(response.Raw) var resp = new(neorpc.Response)
require.NoError(t, ws.SetWriteDeadline(time.Now().Add(time.Second))) require.NoError(t, ws.SetWriteDeadline(time.Now().Add(time.Second)))
require.NoError(t, ws.WriteMessage(websocket.TextMessage, []byte(msg))) require.NoError(t, ws.WriteMessage(websocket.TextMessage, []byte(msg)))
@ -47,8 +47,8 @@ func callWSGetRaw(t *testing.T, ws *websocket.Conn, msg string, respCh <-chan []
return resp return resp
} }
func getNotification(t *testing.T, respCh <-chan []byte) *response.Notification { func getNotification(t *testing.T, respCh <-chan []byte) *neorpc.Notification {
var resp = new(response.Notification) var resp = new(neorpc.Notification)
body := <-respCh body := <-respCh
require.NoError(t, json.Unmarshal(body, resp)) require.NoError(t, json.Unmarshal(body, resp))
return resp return resp
@ -107,10 +107,10 @@ func TestSubscriptions(t *testing.T) {
for _, b := range getTestBlocks(t) { for _, b := range getTestBlocks(t) {
require.NoError(t, chain.AddBlock(b)) require.NoError(t, chain.AddBlock(b))
resp := getNotification(t, respMsgs) resp := getNotification(t, respMsgs)
require.Equal(t, response.ExecutionEventID, resp.Event) require.Equal(t, neorpc.ExecutionEventID, resp.Event)
for { for {
resp = getNotification(t, respMsgs) resp = getNotification(t, respMsgs)
if resp.Event != response.NotificationEventID { if resp.Event != neorpc.NotificationEventID {
break break
} }
} }
@ -118,25 +118,25 @@ func TestSubscriptions(t *testing.T) {
if i > 0 { if i > 0 {
resp = getNotification(t, respMsgs) resp = getNotification(t, respMsgs)
} }
require.Equal(t, response.ExecutionEventID, resp.Event) require.Equal(t, neorpc.ExecutionEventID, resp.Event)
for { for {
resp := getNotification(t, respMsgs) resp := getNotification(t, respMsgs)
if resp.Event == response.NotificationEventID { if resp.Event == neorpc.NotificationEventID {
continue continue
} }
require.Equal(t, response.TransactionEventID, resp.Event) require.Equal(t, neorpc.TransactionEventID, resp.Event)
break break
} }
} }
resp = getNotification(t, respMsgs) resp = getNotification(t, respMsgs)
require.Equal(t, response.ExecutionEventID, resp.Event) require.Equal(t, neorpc.ExecutionEventID, resp.Event)
for { for {
resp = getNotification(t, respMsgs) resp = getNotification(t, respMsgs)
if resp.Event != response.NotificationEventID { if resp.Event != neorpc.NotificationEventID {
break break
} }
} }
require.Equal(t, response.BlockEventID, resp.Event) require.Equal(t, neorpc.BlockEventID, resp.Event)
} }
// We should manually add NotaryRequest to test notification. // We should manually add NotaryRequest to test notification.
@ -145,7 +145,7 @@ func TestSubscriptions(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
for { for {
resp := getNotification(t, respMsgs) resp := getNotification(t, respMsgs)
if resp.Event == response.NotaryRequestEventID { if resp.Event == neorpc.NotaryRequestEventID {
break break
} }
} }
@ -163,22 +163,22 @@ func TestFilteredSubscriptions(t *testing.T) {
var cases = map[string]struct { var cases = map[string]struct {
params string params string
check func(*testing.T, *response.Notification) check func(*testing.T, *neorpc.Notification)
}{ }{
"tx matching sender": { "tx matching sender": {
params: `["transaction_added", {"sender":"` + goodSender.StringLE() + `"}]`, params: `["transaction_added", {"sender":"` + goodSender.StringLE() + `"}]`,
check: func(t *testing.T, resp *response.Notification) { check: func(t *testing.T, resp *neorpc.Notification) {
rmap := resp.Payload[0].(map[string]interface{}) rmap := resp.Payload[0].(map[string]interface{})
require.Equal(t, response.TransactionEventID, resp.Event) require.Equal(t, neorpc.TransactionEventID, resp.Event)
sender := rmap["sender"].(string) sender := rmap["sender"].(string)
require.Equal(t, address.Uint160ToString(goodSender), sender) require.Equal(t, address.Uint160ToString(goodSender), sender)
}, },
}, },
"tx matching signer": { "tx matching signer": {
params: `["transaction_added", {"signer":"` + goodSender.StringLE() + `"}]`, params: `["transaction_added", {"signer":"` + goodSender.StringLE() + `"}]`,
check: func(t *testing.T, resp *response.Notification) { check: func(t *testing.T, resp *neorpc.Notification) {
rmap := resp.Payload[0].(map[string]interface{}) rmap := resp.Payload[0].(map[string]interface{})
require.Equal(t, response.TransactionEventID, resp.Event) require.Equal(t, neorpc.TransactionEventID, resp.Event)
signers := rmap["signers"].([]interface{}) signers := rmap["signers"].([]interface{})
signer0 := signers[0].(map[string]interface{}) signer0 := signers[0].(map[string]interface{})
signer0acc := signer0["account"].(string) signer0acc := signer0["account"].(string)
@ -187,9 +187,9 @@ func TestFilteredSubscriptions(t *testing.T) {
}, },
"tx matching sender and signer": { "tx matching sender and signer": {
params: `["transaction_added", {"sender":"` + goodSender.StringLE() + `", "signer":"` + goodSender.StringLE() + `"}]`, params: `["transaction_added", {"sender":"` + goodSender.StringLE() + `", "signer":"` + goodSender.StringLE() + `"}]`,
check: func(t *testing.T, resp *response.Notification) { check: func(t *testing.T, resp *neorpc.Notification) {
rmap := resp.Payload[0].(map[string]interface{}) rmap := resp.Payload[0].(map[string]interface{})
require.Equal(t, response.TransactionEventID, resp.Event) require.Equal(t, neorpc.TransactionEventID, resp.Event)
sender := rmap["sender"].(string) sender := rmap["sender"].(string)
require.Equal(t, address.Uint160ToString(goodSender), sender) require.Equal(t, address.Uint160ToString(goodSender), sender)
signers := rmap["signers"].([]interface{}) signers := rmap["signers"].([]interface{})
@ -200,27 +200,27 @@ func TestFilteredSubscriptions(t *testing.T) {
}, },
"notification matching contract hash": { "notification matching contract hash": {
params: `["notification_from_execution", {"contract":"` + testContractHash + `"}]`, params: `["notification_from_execution", {"contract":"` + testContractHash + `"}]`,
check: func(t *testing.T, resp *response.Notification) { check: func(t *testing.T, resp *neorpc.Notification) {
rmap := resp.Payload[0].(map[string]interface{}) rmap := resp.Payload[0].(map[string]interface{})
require.Equal(t, response.NotificationEventID, resp.Event) require.Equal(t, neorpc.NotificationEventID, resp.Event)
c := rmap["contract"].(string) c := rmap["contract"].(string)
require.Equal(t, "0x"+testContractHash, c) require.Equal(t, "0x"+testContractHash, c)
}, },
}, },
"notification matching name": { "notification matching name": {
params: `["notification_from_execution", {"name":"my_pretty_notification"}]`, params: `["notification_from_execution", {"name":"my_pretty_notification"}]`,
check: func(t *testing.T, resp *response.Notification) { check: func(t *testing.T, resp *neorpc.Notification) {
rmap := resp.Payload[0].(map[string]interface{}) rmap := resp.Payload[0].(map[string]interface{})
require.Equal(t, response.NotificationEventID, resp.Event) require.Equal(t, neorpc.NotificationEventID, resp.Event)
n := rmap["name"].(string) n := rmap["name"].(string)
require.Equal(t, "my_pretty_notification", n) require.Equal(t, "my_pretty_notification", n)
}, },
}, },
"notification matching contract hash and name": { "notification matching contract hash and name": {
params: `["notification_from_execution", {"contract":"` + testContractHash + `", "name":"my_pretty_notification"}]`, params: `["notification_from_execution", {"contract":"` + testContractHash + `", "name":"my_pretty_notification"}]`,
check: func(t *testing.T, resp *response.Notification) { check: func(t *testing.T, resp *neorpc.Notification) {
rmap := resp.Payload[0].(map[string]interface{}) rmap := resp.Payload[0].(map[string]interface{})
require.Equal(t, response.NotificationEventID, resp.Event) require.Equal(t, neorpc.NotificationEventID, resp.Event)
c := rmap["contract"].(string) c := rmap["contract"].(string)
require.Equal(t, "0x"+testContractHash, c) require.Equal(t, "0x"+testContractHash, c)
n := rmap["name"].(string) n := rmap["name"].(string)
@ -229,28 +229,28 @@ func TestFilteredSubscriptions(t *testing.T) {
}, },
"execution matching": { "execution matching": {
params: `["transaction_executed", {"state":"HALT"}]`, params: `["transaction_executed", {"state":"HALT"}]`,
check: func(t *testing.T, resp *response.Notification) { check: func(t *testing.T, resp *neorpc.Notification) {
rmap := resp.Payload[0].(map[string]interface{}) rmap := resp.Payload[0].(map[string]interface{})
require.Equal(t, response.ExecutionEventID, resp.Event) require.Equal(t, neorpc.ExecutionEventID, resp.Event)
st := rmap["vmstate"].(string) st := rmap["vmstate"].(string)
require.Equal(t, "HALT", st) require.Equal(t, "HALT", st)
}, },
}, },
"tx non-matching": { "tx non-matching": {
params: `["transaction_added", {"sender":"00112233445566778899aabbccddeeff00112233"}]`, params: `["transaction_added", {"sender":"00112233445566778899aabbccddeeff00112233"}]`,
check: func(t *testing.T, _ *response.Notification) { check: func(t *testing.T, _ *neorpc.Notification) {
t.Fatal("unexpected match for EnrollmentTransaction") t.Fatal("unexpected match for EnrollmentTransaction")
}, },
}, },
"notification non-matching": { "notification non-matching": {
params: `["notification_from_execution", {"contract":"00112233445566778899aabbccddeeff00112233"}]`, params: `["notification_from_execution", {"contract":"00112233445566778899aabbccddeeff00112233"}]`,
check: func(t *testing.T, _ *response.Notification) { check: func(t *testing.T, _ *neorpc.Notification) {
t.Fatal("unexpected match for contract 00112233445566778899aabbccddeeff00112233") t.Fatal("unexpected match for contract 00112233445566778899aabbccddeeff00112233")
}, },
}, },
"execution non-matching": { "execution non-matching": {
params: `["transaction_executed", {"state":"FAULT"}]`, params: `["transaction_executed", {"state":"FAULT"}]`,
check: func(t *testing.T, _ *response.Notification) { check: func(t *testing.T, _ *neorpc.Notification) {
t.Fatal("unexpected match for faulted execution") t.Fatal("unexpected match for faulted execution")
}, },
}, },
@ -276,7 +276,7 @@ func TestFilteredSubscriptions(t *testing.T) {
for { for {
resp := getNotification(t, respMsgs) resp := getNotification(t, respMsgs)
rmap := resp.Payload[0].(map[string]interface{}) rmap := resp.Payload[0].(map[string]interface{})
if resp.Event == response.BlockEventID { if resp.Event == neorpc.BlockEventID {
index := rmap["index"].(float64) index := rmap["index"].(float64)
if uint32(index) == lastBlock { if uint32(index) == lastBlock {
break break
@ -302,13 +302,13 @@ func TestFilteredNotaryRequestSubscriptions(t *testing.T) {
var cases = map[string]struct { var cases = map[string]struct {
params string params string
check func(*testing.T, *response.Notification) check func(*testing.T, *neorpc.Notification)
}{ }{
"matching sender": { "matching sender": {
params: `["notary_request_event", {"sender":"` + goodSender.StringLE() + `"}]`, params: `["notary_request_event", {"sender":"` + goodSender.StringLE() + `"}]`,
check: func(t *testing.T, resp *response.Notification) { check: func(t *testing.T, resp *neorpc.Notification) {
rmap := resp.Payload[0].(map[string]interface{}) rmap := resp.Payload[0].(map[string]interface{})
require.Equal(t, response.NotaryRequestEventID, resp.Event) require.Equal(t, neorpc.NotaryRequestEventID, resp.Event)
require.Equal(t, "added", rmap["type"].(string)) require.Equal(t, "added", rmap["type"].(string))
req := rmap["notaryrequest"].(map[string]interface{}) req := rmap["notaryrequest"].(map[string]interface{})
fbTx := req["fallbacktx"].(map[string]interface{}) fbTx := req["fallbacktx"].(map[string]interface{})
@ -318,9 +318,9 @@ func TestFilteredNotaryRequestSubscriptions(t *testing.T) {
}, },
"matching signer": { "matching signer": {
params: `["notary_request_event", {"signer":"` + goodSender.StringLE() + `"}]`, params: `["notary_request_event", {"signer":"` + goodSender.StringLE() + `"}]`,
check: func(t *testing.T, resp *response.Notification) { check: func(t *testing.T, resp *neorpc.Notification) {
rmap := resp.Payload[0].(map[string]interface{}) rmap := resp.Payload[0].(map[string]interface{})
require.Equal(t, response.NotaryRequestEventID, resp.Event) require.Equal(t, neorpc.NotaryRequestEventID, resp.Event)
require.Equal(t, "added", rmap["type"].(string)) require.Equal(t, "added", rmap["type"].(string))
req := rmap["notaryrequest"].(map[string]interface{}) req := rmap["notaryrequest"].(map[string]interface{})
mainTx := req["maintx"].(map[string]interface{}) mainTx := req["maintx"].(map[string]interface{})
@ -332,9 +332,9 @@ func TestFilteredNotaryRequestSubscriptions(t *testing.T) {
}, },
"matching sender and signer": { "matching sender and signer": {
params: `["notary_request_event", {"sender":"` + goodSender.StringLE() + `", "signer":"` + goodSender.StringLE() + `"}]`, params: `["notary_request_event", {"sender":"` + goodSender.StringLE() + `", "signer":"` + goodSender.StringLE() + `"}]`,
check: func(t *testing.T, resp *response.Notification) { check: func(t *testing.T, resp *neorpc.Notification) {
rmap := resp.Payload[0].(map[string]interface{}) rmap := resp.Payload[0].(map[string]interface{})
require.Equal(t, response.NotaryRequestEventID, resp.Event) require.Equal(t, neorpc.NotaryRequestEventID, resp.Event)
require.Equal(t, "added", rmap["type"].(string)) require.Equal(t, "added", rmap["type"].(string))
req := rmap["notaryrequest"].(map[string]interface{}) req := rmap["notaryrequest"].(map[string]interface{})
mainTx := req["maintx"].(map[string]interface{}) mainTx := req["maintx"].(map[string]interface{})
@ -370,7 +370,7 @@ func TestFilteredNotaryRequestSubscriptions(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
nonce++ nonce++
var resp = new(response.Notification) var resp = new(neorpc.Notification)
select { select {
case body := <-respMsgs: case body := <-respMsgs:
require.NoError(t, json.Unmarshal(body, resp)) require.NoError(t, json.Unmarshal(body, resp))
@ -378,7 +378,7 @@ func TestFilteredNotaryRequestSubscriptions(t *testing.T) {
t.Fatal("timeout waiting for event") t.Fatal("timeout waiting for event")
} }
require.Equal(t, response.NotaryRequestEventID, resp.Event) require.Equal(t, neorpc.NotaryRequestEventID, resp.Event)
this.check(t, resp) this.check(t, resp)
callUnsubscribe(t, c, respMsgs, subID) callUnsubscribe(t, c, respMsgs, subID)
@ -410,7 +410,7 @@ func TestFilteredBlockSubscriptions(t *testing.T) {
} }
for i := 0; i < expectedCnt; i++ { for i := 0; i < expectedCnt; i++ {
var resp = new(response.Notification) var resp = new(neorpc.Notification)
select { select {
case body := <-respMsgs: case body := <-respMsgs:
require.NoError(t, json.Unmarshal(body, resp)) require.NoError(t, json.Unmarshal(body, resp))
@ -418,7 +418,7 @@ func TestFilteredBlockSubscriptions(t *testing.T) {
t.Fatal("timeout waiting for event") t.Fatal("timeout waiting for event")
} }
require.Equal(t, response.BlockEventID, resp.Event) require.Equal(t, neorpc.BlockEventID, resp.Event)
rmap := resp.Payload[0].(map[string]interface{}) rmap := resp.Payload[0].(map[string]interface{})
primary := rmap["primary"].(float64) primary := rmap["primary"].(float64)
require.Equal(t, 3, int(primary)) require.Equal(t, 3, int(primary))
@ -565,8 +565,8 @@ func TestSubscriptionOverflow(t *testing.T) {
} }
for i := 0; i < blockCnt; i++ { for i := 0; i < blockCnt; i++ {
resp := getNotification(t, respMsgs) resp := getNotification(t, respMsgs)
if resp.Event != response.BlockEventID { if resp.Event != neorpc.BlockEventID {
require.Equal(t, response.MissedEventID, resp.Event) require.Equal(t, neorpc.MissedEventID, resp.Event)
receivedMiss = true receivedMiss = true
break break
} }

View file

@ -1,7 +1,7 @@
package rpcsrv package rpcsrv
import ( import (
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/neorpc/result"
) )
// tokenTransfers is a generic type used to represent NEP-11 and NEP-17 transfers. // tokenTransfers is a generic type used to represent NEP-11 and NEP-17 transfers.