diff options
Diffstat (limited to 'rpc/shared/types.go')
-rw-r--r-- | rpc/shared/types.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/rpc/shared/types.go b/rpc/shared/types.go new file mode 100644 index 000000000..46fd5552c --- /dev/null +++ b/rpc/shared/types.go @@ -0,0 +1,38 @@ +package shared + +import "encoding/json" + +// RPC request +type Request struct { + Id interface{} `json:"id"` + Jsonrpc string `json:"jsonrpc"` + Method string `json:"method"` + Params json.RawMessage `json:"params"` +} + +// RPC response +type Response struct { + Id interface{} `json:"id"` + Jsonrpc string `json:"jsonrpc"` +} + +// RPC success response +type SuccessResponse struct { + Id interface{} `json:"id"` + Jsonrpc string `json:"jsonrpc"` + Result interface{} `json:"result"` +} + +// RPC error response +type ErrorResponse struct { + Id interface{} `json:"id"` + Jsonrpc string `json:"jsonrpc"` + Error *ErrorObject `json:"error"` +} + +// RPC error response details +type ErrorObject struct { + Code int `json:"code"` + Message string `json:"message"` + // Data interface{} `json:"data"` +} |