Documentation ¶
Index ¶
- Constants
- func CORS(next http.Handler) http.Handler
- func PostRpcRequestMiddleware(h RPCHandler, stateService state.Service) http.Handler
- type GlobalRPCHandler
- func (h *GlobalRPCHandler) GetRPCProxyHandler() ProxyHandler
- func (h *GlobalRPCHandler) GetUniversalMintingRPCHandler() RPCUniversalHandler
- func (h *GlobalRPCHandler) HandleProxyRPC(r *http.Request, req JSONRPCRequest) RPCResponse
- func (h *GlobalRPCHandler) HandleUniversalMinting(r *http.Request, req JSONRPCRequest) RPCResponse
- func (h *GlobalRPCHandler) PostRPCRequestHandler(w http.ResponseWriter, r *http.Request)
- func (h *GlobalRPCHandler) SetStateService(stateService state.Service)
- type HTTPClientInterface
- type HTTPClientWrapper
- type HandlerOption
- type JSONRPCRequest
- type ProxyHandler
- type ProxyHandlerOption
- type ProxyRPCMethodManager
- func (b *ProxyRPCMethodManager) CheckBlockNumberFromResponseFromHashCalls(resp *RPCResponse, method RPCMethod, blockNumberUnode string) error
- func (b *ProxyRPCMethodManager) HasRPCMethodWithBlockNumber(methodName string) (RPCMethod, bool)
- func (b *ProxyRPCMethodManager) HasRPCMethodWithHash(methodName string) (RPCMethod, bool)
- func (b *ProxyRPCMethodManager) ReplaceBlockTag(req *JSONRPCRequest, method RPCMethod, blockNumberUnode string) error
- type RPCError
- type RPCHandler
- type RPCMethod
- type RPCMethodManager
- type RPCProxyHandler
- type RPCResponse
- type RPCUniversalHandler
- type Router
- type UniversalMintingRPCHandler
- func (h *UniversalMintingRPCHandler) GetHttpClient() HTTPClientInterface
- func (h *UniversalMintingRPCHandler) GetRpcUrl() string
- func (h *UniversalMintingRPCHandler) HandleUniversalMinting(r *http.Request, jsonRPCRequest JSONRPCRequest, stateService state.Service) RPCResponse
- func (h *UniversalMintingRPCHandler) SetHttpClient(client HTTPClientInterface)
- type UniversalMintingRPCHandlerOption
Constants ¶
View Source
const ( ErrMsgBadRequest = "Bad Request" ErrMsgInternalError = "Internal Server Error" ErrMsgBadGateway = "Bad Gateway" ErrMsgUniversalMintingNotReady = "universal minting not supported yet" )
View Source
const (
ErrorCodeInvalidRequest = -32600 // Invalid Request
)
Define error codes related to JSON-RPC responses
Variables ¶
This section is empty.
Functions ¶
func PostRpcRequestMiddleware ¶
func PostRpcRequestMiddleware(h RPCHandler, stateService state.Service) http.Handler
Types ¶
type GlobalRPCHandler ¶
type GlobalRPCHandler struct {
// contains filtered or unexported fields
}
func NewGlobalRPCHandler ¶
func NewGlobalRPCHandler(rpcUrl, evoRpcUrl string, opts ...HandlerOption) *GlobalRPCHandler
func (*GlobalRPCHandler) GetRPCProxyHandler ¶
func (h *GlobalRPCHandler) GetRPCProxyHandler() ProxyHandler
func (*GlobalRPCHandler) GetUniversalMintingRPCHandler ¶
func (h *GlobalRPCHandler) GetUniversalMintingRPCHandler() RPCUniversalHandler
func (*GlobalRPCHandler) HandleProxyRPC ¶
func (h *GlobalRPCHandler) HandleProxyRPC(r *http.Request, req JSONRPCRequest) RPCResponse
func (*GlobalRPCHandler) HandleUniversalMinting ¶
func (h *GlobalRPCHandler) HandleUniversalMinting(r *http.Request, req JSONRPCRequest) RPCResponse
func (*GlobalRPCHandler) PostRPCRequestHandler ¶
func (h *GlobalRPCHandler) PostRPCRequestHandler(w http.ResponseWriter, r *http.Request)
func (*GlobalRPCHandler) SetStateService ¶
func (h *GlobalRPCHandler) SetStateService(stateService state.Service)
type HTTPClientInterface ¶
Define an interface for HTTP client operations
type HTTPClientWrapper ¶
type HTTPClientWrapper struct {
// contains filtered or unexported fields
}
Create a wrapper for the net/http client
type HandlerOption ¶
type HandlerOption func(*GlobalRPCHandler)
func WithHttpClient ¶
func WithHttpClient(client HTTPClientInterface) HandlerOption
func WithRPCProxyHandler ¶
func WithRPCProxyHandler(handler ProxyHandler) HandlerOption
func WithUniversalMintingRPCHandler ¶
func WithUniversalMintingRPCHandler(handler RPCUniversalHandler) HandlerOption
type JSONRPCRequest ¶
type JSONRPCRequest struct { JSONRPC string `json:"jsonrpc"` Method string `json:"method"` Params []json.RawMessage `json:"params"` ID *json.RawMessage `json:"id,omitempty"` }
JSONRPCRequest represents the expected structure of a JSON-RPC request.
type ProxyHandler ¶
type ProxyHandler interface { HandleProxyRPC(r *http.Request, req JSONRPCRequest, stateService state.Service) RPCResponse GetRpcUrl() string GetHttpClient() HTTPClientInterface SetHttpClient(client HTTPClientInterface) }
func NewProxyHandler ¶
func NewProxyHandler(ops ...ProxyHandlerOption) ProxyHandler
type ProxyHandlerOption ¶
type ProxyHandlerOption func(*RPCProxyHandler)
func WithHttpClientProxyHandler ¶
func WithHttpClientProxyHandler(client HTTPClientInterface) ProxyHandlerOption
func WithProxyRPCMethodManager ¶
func WithProxyRPCMethodManager(proxyRPCMethodManager RPCMethodManager) ProxyHandlerOption
type ProxyRPCMethodManager ¶
type ProxyRPCMethodManager struct{}
func (*ProxyRPCMethodManager) CheckBlockNumberFromResponseFromHashCalls ¶
func (b *ProxyRPCMethodManager) CheckBlockNumberFromResponseFromHashCalls(resp *RPCResponse, method RPCMethod, blockNumberUnode string) error
func (*ProxyRPCMethodManager) HasRPCMethodWithBlockNumber ¶
func (b *ProxyRPCMethodManager) HasRPCMethodWithBlockNumber(methodName string) (RPCMethod, bool)
func (*ProxyRPCMethodManager) HasRPCMethodWithHash ¶
func (b *ProxyRPCMethodManager) HasRPCMethodWithHash(methodName string) (RPCMethod, bool)
func (*ProxyRPCMethodManager) ReplaceBlockTag ¶
func (b *ProxyRPCMethodManager) ReplaceBlockTag(req *JSONRPCRequest, method RPCMethod, blockNumberUnode string) error
type RPCHandler ¶
type RPCHandler interface { HandleProxyRPC(r *http.Request, req JSONRPCRequest) RPCResponse HandleUniversalMinting(r *http.Request, req JSONRPCRequest) RPCResponse PostRPCRequestHandler(w http.ResponseWriter, r *http.Request) SetStateService(stateService state.Service) }
type RPCMethod ¶
type RPCMethod int
const ( RPCMethodEthCall RPCMethod = iota RPCMethodEthGetBalance RPCMethodEthGetBlockByNumber RPCMethodEthGetBlockTransactionCountByNumber RPCMethodEthGetCode RPCMethodEthGetLogs RPCMethodEthGetStorageAt RPCMethodEthGetTransactionByBlockHashAndIndex RPCMethodEthGetTransactionByBlockNumberAndIndex RPCMethodEthGetTransactionCount RPCMethodEthGetUncleCountByBlockNumber RPCMethodEthNewFilter RPCMethodEthGetBlockByHash RPCMethodEthGetTransactionReceipt RPCMethodEthGetTransactionByHash RPCMethodEthGetUncleCountByBlockHash RPCMethodEthGetBlockTransactionCountByHash )
Constants for each RPC method
type RPCMethodManager ¶
type RPCMethodManager interface { HasRPCMethodWithBlockNumber(methodName string) (RPCMethod, bool) HasRPCMethodWithHash(methodName string) (RPCMethod, bool) CheckBlockNumberFromResponseFromHashCalls(resp *RPCResponse, method RPCMethod, blockNumberUnode string) error ReplaceBlockTag(req *JSONRPCRequest, method RPCMethod, blockNumberUnode string) error }
we don't handle these methods for now but we have to handle this in the future
var rpcMethodsWithCountByHash = map[string]RPCMethod{ "eth_getUncleCountByBlockHash": RPCMethodEthGetUncleCountByBlockHash, "eth_getBlockTransactionCountByHash": RPCMethodEthGetBlockTransactionCountByHash, }
func NewProxyRPCMethodManager ¶
func NewProxyRPCMethodManager() RPCMethodManager
type RPCProxyHandler ¶
type RPCProxyHandler struct {
// contains filtered or unexported fields
}
func (*RPCProxyHandler) GetHttpClient ¶
func (h *RPCProxyHandler) GetHttpClient() HTTPClientInterface
func (*RPCProxyHandler) GetRpcUrl ¶
func (h *RPCProxyHandler) GetRpcUrl() string
func (*RPCProxyHandler) HandleProxyRPC ¶
func (h *RPCProxyHandler) HandleProxyRPC(r *http.Request, req JSONRPCRequest, stateService state.Service) RPCResponse
RPCProxyHandler
func (*RPCProxyHandler) SetHttpClient ¶
func (h *RPCProxyHandler) SetHttpClient(client HTTPClientInterface)
type RPCResponse ¶
type RPCResponse struct { Jsonrpc string `json:"jsonrpc"` ID *json.RawMessage `json:"id"` Result *json.RawMessage `json:"result"` Error *RPCError `json:"error,omitempty"` }
func (RPCResponse) MarshalJSON ¶
func (r RPCResponse) MarshalJSON() ([]byte, error)
type RPCUniversalHandler ¶
type RPCUniversalHandler interface {
HandleUniversalMinting(r *http.Request, req JSONRPCRequest, stateService state.Service) RPCResponse
}
func NewUniversalMintingRPCHandler ¶
func NewUniversalMintingRPCHandler(ops ...UniversalMintingRPCHandlerOption) RPCUniversalHandler
type Router ¶
type UniversalMintingRPCHandler ¶
type UniversalMintingRPCHandler struct {
// contains filtered or unexported fields
}
func (*UniversalMintingRPCHandler) GetHttpClient ¶
func (h *UniversalMintingRPCHandler) GetHttpClient() HTTPClientInterface
func (*UniversalMintingRPCHandler) GetRpcUrl ¶
func (h *UniversalMintingRPCHandler) GetRpcUrl() string
func (*UniversalMintingRPCHandler) HandleUniversalMinting ¶
func (h *UniversalMintingRPCHandler) HandleUniversalMinting(r *http.Request, jsonRPCRequest JSONRPCRequest, stateService state.Service) RPCResponse
func (*UniversalMintingRPCHandler) SetHttpClient ¶
func (h *UniversalMintingRPCHandler) SetHttpClient(client HTTPClientInterface)
type UniversalMintingRPCHandlerOption ¶
type UniversalMintingRPCHandlerOption func(*UniversalMintingRPCHandler)
func WithEvoHttpClient ¶
func WithEvoHttpClient(client HTTPClientInterface) UniversalMintingRPCHandlerOption
func WithRPCMethodManager ¶
func WithRPCMethodManager(rpcMethodManager RPCMethodManager) UniversalMintingRPCHandlerOption
Source Files ¶
Click to show internal directories.
Click to hide internal directories.