jsonrpc

package
v1.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 21 Imported by: 7

Documentation

Index

Constants

View Source
const (
	Version           = "2.0"
	DefaultBatchLimit = 10
)
View Source
const (
	HeaderKeyIconOptions = "Icon-Options"
	IconOptionsDebug     = "debug"
	IconOptionsTimeout   = "timeout"
)
View Source
const (
	UnmarshalFailPrefix = "fail to unmarshal, "
	ValidateFailPrefix  = "fail to validate, "
	JsonErrorPrefix     = "json: "
)

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(re *Error, c echo.Context)

func UnmarshalWithValidate added in v0.9.10

func UnmarshalWithValidate(data []byte, v interface{}, vd echo.Validator) error

Types

type Address

type Address string

func (Address) Address

func (addr Address) Address() module.Address

type Context

type Context struct {
	echo.Context
	// contains filtered or unexported fields
}

func NewContext

func NewContext(c echo.Context) *Context

func (*Context) BatchLimit added in v1.2.0

func (ctx *Context) BatchLimit() int

func (*Context) Chain

func (ctx *Context) Chain() (module.Chain, error)

func (*Context) GetTimeout

func (ctx *Context) GetTimeout(t time.Duration) time.Duration

func (*Context) IncludeDebug

func (ctx *Context) IncludeDebug() bool

func (*Context) MetricContext added in v1.2.0

func (ctx *Context) MetricContext() context.Context

func (*Context) Validator added in v0.9.10

func (ctx *Context) Validator() echo.Validator

type Error

type Error struct {
	Code    ErrorCode   `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

func ErrInvalidParams

func ErrInvalidParams(message ...interface{}) *Error

func ErrInvalidRequest

func ErrInvalidRequest(message ...interface{}) *Error

func ErrMethodNotFound

func ErrMethodNotFound(message ...interface{}) *Error

func ErrParse

func ErrParse(message ...interface{}) *Error

func ErrScore

func ErrScore(err error, debug bool) *Error

func ErrScoreWithStatus

func ErrScoreWithStatus(s module.Status) *Error

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode int
const (
	ErrorCodeJsonParse      ErrorCode = -32700
	ErrorCodeInvalidRequest ErrorCode = -32600
	ErrorCodeMethodNotFound ErrorCode = -32601
	ErrorCodeInvalidParams  ErrorCode = -32602
	ErrorCodeInternal       ErrorCode = -32603
	ErrorCodeServer         ErrorCode = -32000
	ErrorCodeSystem         ErrorCode = -31000
	ErrorCodeScore          ErrorCode = -30000
)
const (
	ErrorCodeTxPoolOverflow ErrorCode = -31001
	ErrorCodePending        ErrorCode = -31002
	ErrorCodeExecuting      ErrorCode = -31003
	ErrorCodeNotFound       ErrorCode = -31004
	ErrorLackOfResource     ErrorCode = -31005
	ErrorCodeTimeout        ErrorCode = -31006
	ErrorCodeSystemTimeout  ErrorCode = -31007
)

func (ErrorCode) Errorf

func (c ErrorCode) Errorf(f string, args ...interface{}) *Error

func (ErrorCode) New

func (c ErrorCode) New(msg string, data ...interface{}) *Error

func (ErrorCode) NewWithData

func (c ErrorCode) NewWithData(data interface{}) *Error

func (ErrorCode) String added in v0.9.10

func (c ErrorCode) String() string

func (ErrorCode) Wrap

func (c ErrorCode) Wrap(err error, debug bool) *Error

type Handler

type Handler func(ctx *Context, params *Params) (result interface{}, err error)

type HexBool added in v1.3.3

type HexBool string

func (HexBool) Bool added in v1.3.3

func (b HexBool) Bool() (bool, error)

type HexBytes

type HexBytes string

func (HexBytes) Bytes

func (hs HexBytes) Bytes() []byte

type HexInt

type HexInt string

func HexIntFromBigInt added in v1.3.9

func HexIntFromBigInt(v *big.Int) HexInt

func HexIntFromInt64 added in v1.3.9

func HexIntFromInt64(v int64) HexInt

func (HexInt) BigInt added in v0.9.6

func (i HexInt) BigInt() (*big.Int, error)

func (HexInt) Int64 added in v0.9.6

func (i HexInt) Int64() (int64, error)

func (HexInt) ParseInt

func (i HexInt) ParseInt(bits int) (int64, error)

func (HexInt) Value

func (i HexInt) Value() int64

type IconOptions

type IconOptions map[string]string

func NewIconOptionsByHeader

func NewIconOptionsByHeader(h http.Header) IconOptions

func (IconOptions) Del

func (opts IconOptions) Del(key string)

func (IconOptions) Get

func (opts IconOptions) Get(key string) string

func (IconOptions) GetBool

func (opts IconOptions) GetBool(key string) (bool, error)

func (IconOptions) GetInt

func (opts IconOptions) GetInt(key string) (int64, error)

func (IconOptions) Set

func (opts IconOptions) Set(key, value string)

func (IconOptions) SetBool

func (opts IconOptions) SetBool(key string, value bool)

func (IconOptions) SetInt

func (opts IconOptions) SetInt(key string, v int64)

func (IconOptions) ToHeaderValue

func (opts IconOptions) ToHeaderValue() string

type MethodRepository

type MethodRepository struct {
	// contains filtered or unexported fields
}

func NewMethodRepository

func NewMethodRepository(mtr *metric.JsonrpcMetric) *MethodRepository

func (*MethodRepository) GetMethod added in v0.9.10

func (mr *MethodRepository) GetMethod(method string) Handler

func (*MethodRepository) Handle

func (mr *MethodRepository) Handle(c echo.Context) error

func (*MethodRepository) IsAllowedNotification added in v0.9.10

func (mr *MethodRepository) IsAllowedNotification(method string) bool

func (*MethodRepository) RegisterMethod

func (mr *MethodRepository) RegisterMethod(method string, handler Handler)

func (*MethodRepository) SetAllowedNotification added in v0.9.10

func (mr *MethodRepository) SetAllowedNotification(method string)

func (*MethodRepository) Validator added in v1.3.0

func (mr *MethodRepository) Validator() *Validator

type Params

type Params struct {
	// contains filtered or unexported fields
}

func (*Params) Convert

func (p *Params) Convert(v interface{}) error

func (*Params) IsEmpty

func (p *Params) IsEmpty() bool

func (*Params) RawMessage

func (p *Params) RawMessage() []byte

type Request

type Request struct {
	Version string          `json:"jsonrpc" validate:"required,version"`
	Method  *string         `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
	ID      interface{}     `json:"id" validate:"optional,id"`
}

type Response

type Response struct {
	Version string      `json:"jsonrpc"`
	Result  interface{} `json:"result,omitempty"`
	Error   *Error      `json:"error,omitempty"`
	ID      interface{} `json:"id"`
}

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func NewValidator

func NewValidator() *Validator

func (*Validator) RegisterAlias

func (v *Validator) RegisterAlias(alias string, tags string)

func (*Validator) RegisterStructValidation

func (v *Validator) RegisterStructValidation(fn validator.StructLevelFunc, types ...interface{})

func (*Validator) RegisterValidation

func (v *Validator) RegisterValidation(tag string, fn validator.Func)

func (*Validator) Validate

func (v *Validator) Validate(i interface{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL