Documentation
¶
Index ¶
- Constants
- type Client
- type ClientOption
- type Error
- type Request
- func NewRequest(method string, params ...interface{}) (req *Request)
- func NewRequestWithNamedParams(method string, params map[string]interface{}) (req *Request)
- func NewRequestWithObject(method string, params interface{}) (req *Request)
- func NewRequestWithRawParams(method string, params json.RawMessage) (req *Request)
- type RequestId
- type Response
- type WarpedError
Constants ¶
View Source
const ( JSON_RPC_VERSION_1_0 = "1.0" JSON_RPC_VERSION_2_0 = "2.0" ERROR_CODE_PARSE_ERROR = -32700 ERROR_MESSAGE_PARSE_ERROR = "Parse error" ERROR_CODE_INVALID_REQUEST = -32600 ERROR_MESSAGE_INVALID_REQUEST = "invalid request" ERROR_CODE_METHOD_NOT_FOUND = -32601 ERROR_MESSAGE_METHOD_NOT_FOUND = "method not found" ERROR_CODE_SERVER_ERROR = -32000 ERROR_MESSAGE_SERVER_ERROR = "server error" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(options ...ClientOption) *Client
type ClientOption ¶
type ClientOption func(client *Client)
func WithHTTPRest ¶
func WithHTTPRest(url string, headers map[string]string) ClientOption
WithHTTPRest sets the URL of the REST server for http network requests This is used for RESTful like API requests for TRON and similar networks
func WithHTTPRpc ¶
func WithHTTPRpc(url string, headers map[string]string) ClientOption
WithHTTPRpc sets the URL of the RPC server for http network requests
func WithRpcIPCSocket ¶
func WithRpcIPCSocket(socketPath string) ClientOption
WithRpcIPCSocket sets the RPC client for use unix socket interactions Please note, may not work on Windows (differences between Unix sockets and Windows named pipes)
type Request ¶
type Request struct {
Id RequestId `json:"id"`
JsonRpc string `json:"jsonrpc"`
Method string `json:"method"`
ParamsNamed map[string]interface{} `json:"paramsN,omitempty"`
ParamsArray []interface{} `json:"paramsA,omitempty"`
Params json.RawMessage `json:"params,omitempty"`
ParamsObject interface{} `json:"paramsO,omitempty"`
// contains filtered or unexported fields
}
func NewRequest ¶
func NewRequestWithObject ¶
func NewRequestWithRawParams ¶
func NewRequestWithRawParams(method string, params json.RawMessage) (req *Request)
func (*Request) MarshalJSON ¶
func (*Request) SetNamedParam ¶
type RequestId ¶
type RequestId string
func (RequestId) MarshalJSON ¶
func (*RequestId) UnmarshalJSON ¶
type Response ¶
type Response struct {
Id RequestId `json:"id"`
JsonRpc string `json:"jsonrpc"`
Error *Error `json:"error,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
}
func NewResponse ¶
func NewResponse() *Response
func (*Response) ParseError ¶
func (*Response) ParseResult ¶
type WarpedError ¶
func (*WarpedError) Error ¶
func (err *WarpedError) Error() string
Click to show internal directories.
Click to hide internal directories.