serde

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const JsonRpcVersion = "2.0"

Variables

View Source
var (
	ParseError            = JsonRpcError{Code: -32700, Message: "Parse error"}
	InvalidRequestError   = JsonRpcError{Code: -32600, Message: "Invalid Request"}
	MethodNotFoundError   = JsonRpcError{Code: -32601, Message: "Method not found"}
	InvalidParamsError    = JsonRpcError{Code: -32602, Message: "Invalid params"}
	InternalServerError   = JsonRpcError{Code: -32603, Message: "Internal error"}
	RequestUnmarshalError = JsonRpcError{Code: -32010, Message: "Could not unmarshal request object"}
	ParamsUnmarshalError  = JsonRpcError{Code: -32009, Message: "Could not unmarshal params object"}
	InvalidAuthTokenError = JsonRpcError{Code: -32008, Message: "Invalid auth token"}
)

Functions

func ValidateGetPaymentChannelRequest

func ValidateGetPaymentChannelRequest(req GetPaymentChannelRequest) error

func ValidateGetPaymentChannelsByLedgerRequest

func ValidateGetPaymentChannelsByLedgerRequest(req GetPaymentChannelsByLedgerRequest) error

func ValidatePaymentRequest

func ValidatePaymentRequest(req PaymentRequest) error

Types

type AuthRequest

type AuthRequest struct {
	Id string
}

type GetAllLedgersResponse

type GetAllLedgersResponse = []query.LedgerChannelInfo

type GetLedgerChannelRequest

type GetLedgerChannelRequest struct {
	Id types.Destination
}

type GetPaymentChannelRequest

type GetPaymentChannelRequest struct {
	Id types.Destination
}

type GetPaymentChannelsByLedgerRequest

type GetPaymentChannelsByLedgerRequest struct {
	LedgerId types.Destination
}

type GetPaymentChannelsByLedgerResponse

type GetPaymentChannelsByLedgerResponse = []query.PaymentChannelInfo

type JsonRpcError

type JsonRpcError struct {
	Code    int64       `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func (JsonRpcError) Error

func (e JsonRpcError) Error() string

type JsonRpcErrorResponse

type JsonRpcErrorResponse struct {
	Jsonrpc string       `json:"jsonrpc"`
	Id      uint64       `json:"id"`
	Error   JsonRpcError `json:"error"`
}

func NewJsonRpcErrorResponse

func NewJsonRpcErrorResponse(requestId uint64, error JsonRpcError) *JsonRpcErrorResponse

type JsonRpcGeneralRequest

type JsonRpcGeneralRequest struct {
	Jsonrpc string      `json:"jsonrpc"`
	Id      uint64      `json:"id"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params"`
}

type JsonRpcGeneralResponse

type JsonRpcGeneralResponse struct {
	Jsonrpc string       `json:"jsonrpc"`
	Id      uint64       `json:"id"`
	Error   JsonRpcError `json:"error"`
	Result  interface{}  `json:"result"`
}

type JsonRpcSpecificRequest

type JsonRpcSpecificRequest[T RequestPayload | NotificationPayload] struct {
	Jsonrpc string    `json:"jsonrpc"`
	Id      uint64    `json:"id"`
	Method  string    `json:"method"`
	Params  Params[T] `json:"params"`
}

func NewJsonRpcSpecificRequest

func NewJsonRpcSpecificRequest[T RequestPayload | NotificationPayload, U RequestMethod | NotificationMethod](requestId uint64, method U, objectiveRequest T, authToken string) *JsonRpcSpecificRequest[T]

type JsonRpcSuccessResponse

type JsonRpcSuccessResponse[T ResponsePayload] struct {
	Jsonrpc string `json:"jsonrpc"`
	Id      uint64 `json:"id"`
	Result  T      `json:"result"`
}

func NewJsonRpcResponse

func NewJsonRpcResponse[T ResponsePayload](requestId uint64, objectiveResponse T) *JsonRpcSuccessResponse[T]

type NoPayloadRequest

type NoPayloadRequest = struct{}

type NotificationMethod

type NotificationMethod string
const (
	ObjectiveCompleted    NotificationMethod = "objective_completed"
	LedgerChannelUpdated  NotificationMethod = "ledger_channel_updated"
	PaymentChannelUpdated NotificationMethod = "payment_channel_updated"
)

type NotificationOrRequest

type NotificationOrRequest interface {
	RequestMethod | NotificationMethod
}

type Params

type Params[T RequestPayload | NotificationPayload] struct {
	AuthToken string `json:"authtoken"`
	Payload   T      `json:"payload"`
}

type PaymentRequest

type PaymentRequest struct {
	Amount  uint64
	Channel types.Destination
}

type RequestMethod

type RequestMethod string
const (
	GetAuthTokenMethod                RequestMethod = "get_auth_token"
	GetAddressMethod                  RequestMethod = "get_address"
	VersionMethod                     RequestMethod = "version"
	CreateLedgerChannelRequestMethod  RequestMethod = "create_ledger_channel"
	CloseLedgerChannelRequestMethod   RequestMethod = "close_ledger_channel"
	CreatePaymentChannelRequestMethod RequestMethod = "create_payment_channel"
	ClosePaymentChannelRequestMethod  RequestMethod = "close_payment_channel"
	PayRequestMethod                  RequestMethod = "pay"
	GetPaymentChannelRequestMethod    RequestMethod = "get_payment_channel"
	GetLedgerChannelRequestMethod     RequestMethod = "get_ledger_channel"
	GetPaymentChannelsByLedgerMethod  RequestMethod = "get_payment_channels_by_ledger"
	GetAllLedgerChannelsMethod        RequestMethod = "get_all_ledger_channels"
	CreateVoucherRequestMethod        RequestMethod = "create_voucher"
	ReceiveVoucherRequestMethod       RequestMethod = "receive_voucher"
)

Jump to

Keyboard shortcuts

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