core

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BundlerTimeout   = 2 * time.Second
	SignatoryTimeout = 2 * time.Second

	// Channels
	ChannelSolver    = "solver"
	ChannelBundler   = "bundler"
	ChannelSignatory = "signatory"

	// Methods
	MethodPing                  = "ping"
	MethodSubscribe             = "subscribe"
	MethodUnsubscribe           = "unsubscribe"
	MethodSubmitSolverOperation = "submitSolverOperation"
	MethodSolverOperationStatus = "solverOperationStatus"

	// Subscriptions topics
	TopicNewUserOperations = "newUserOperations"

	// Events
	EventUpdate              = "update"
	EventNewBundle           = "newBundle"
	EventNewSignatoryRequest = "newSignatoryRequest"

	// Messages
	ConnUpgradeFailed      = "failed upgrading connection"
	Pong                   = "pong"
	Subscribed             = "subscribed"
	Unsubscribed           = "unsubscribed"
	AlreadySubscribed      = "already subscribed"
	NotSubscribed          = "not subscribed"
	InvalidMessage         = "invalid message"
	InvalidChannel         = "invalid channel"
	InvalidMethod          = "invalid method"
	InvalidTopic           = "invalid topic"
	InvalidSolverOperation = "invalid solver operation"
	RateLimitExceeded      = "rate limit exceeded"
)
View Source
const (
	BundleSuccessfullySubmitted = "bundle successfully submitted"
)

Variables

View Source
var (
	ErrMalformedRequest    = relayerror.NewError(3000, "malformed request")
	ErrMalformedJson       = relayerror.NewError(3001, "malformed json")
	ErrInvalidParameter    = relayerror.NewError(3002, "invalid parameter")
	ErrServerCorruptedData = relayerror.NewError(3003, "server corrupted data")
	ErrInvalidOpHash       = relayerror.NewError(3004, "invalid operation hash")
	ErrInvalidAddress      = relayerror.NewError(3005, "invalid address")
	ErrInvalidTimestamp    = relayerror.NewError(3006, "invalid timestamp")
	ErrExpiredSignature    = relayerror.NewError(3007, "expired signature")
	ErrBadSignature        = relayerror.NewError(3008, "bad signature (decode/recover error)")
	ErrSignatureMismatch   = relayerror.NewError(3009, "signature mismatch")
)
View Source
var (
	ErrForwardBundle          = relayerror.NewError(3100, "failed to forward bundle")
	ErrCantGetDAppSignatories = relayerror.NewError(3101, "failed to get dapp signatories")
	ErrCantGetBondedBalance   = relayerror.NewError(3102, "failed to get atlEth bonded balance")
	ErrRelayIsOffline         = relayerror.NewError(3103, "relay is offline")
)
View Source
var (
	Channels = map[string]struct{}{
		ChannelSolver:    {},
		ChannelBundler:   {},
		ChannelSignatory: {},
	}

	Methods = map[string]map[string]struct{}{
		ChannelSolver:    {MethodPing: {}, MethodSubscribe: {}, MethodUnsubscribe: {}, MethodSubmitSolverOperation: {}, MethodSolverOperationStatus: {}},
		ChannelBundler:   {MethodPing: {}},
		ChannelSignatory: {MethodPing: {}},
	}

	Topics = map[string]struct{}{
		TopicNewUserOperations: {},
	}
)
View Source
var (
	ErrBundlerOffline    = relayerror.NewError(3200, "bundler is offline")
	ErrCloggedConnection = relayerror.NewError(3201, "clogged connection")
	ErrBundlingFailure   = relayerror.NewError(3202, "bundling failure")
	ErrSignatoryOffline  = relayerror.NewError(3203, "signatory is offline")
	ErrSigningFailure    = relayerror.NewError(3204, "auctioneer signing failure")
)

Functions

func NewRouter

func NewRouter(api *Api) *mux.Router

func StartRelay

func StartRelay(conf *config.Config, serverReadyChan chan struct{})

Types

type Api

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

func NewApi

func NewApi(relay *Relay) *Api

func (*Api) GetBundleHash

func (api *Api) GetBundleHash(w http.ResponseWriter, r *http.Request)

func (*Api) GetSolverOperationStatus added in v1.0.3

func (api *Api) GetSolverOperationStatus(w http.ResponseWriter, r *http.Request)

func (*Api) GetSolverOperations

func (api *Api) GetSolverOperations(w http.ResponseWriter, r *http.Request)

func (*Api) Ping

func (api *Api) Ping(w http.ResponseWriter, r *http.Request)

func (*Api) SubmitBundleOperations

func (api *Api) SubmitBundleOperations(w http.ResponseWriter, r *http.Request)

func (*Api) SubmitSolverOperation

func (api *Api) SubmitSolverOperation(w http.ResponseWriter, r *http.Request)

func (*Api) SubmitUserOperation

func (api *Api) SubmitUserOperation(w http.ResponseWriter, r *http.Request)

func (*Api) WebsocketBundler

func (api *Api) WebsocketBundler(w http.ResponseWriter, r *http.Request)

func (*Api) WebsocketSignatory added in v1.0.4

func (api *Api) WebsocketSignatory(w http.ResponseWriter, r *http.Request)

func (*Api) WebsocketSolver

func (api *Api) WebsocketSolver(w http.ResponseWriter, r *http.Request)

type BareRequest added in v1.0.1

type BareRequest struct {
	Id string `json:"id" validate:"required"`
}

type Broadcast

type Broadcast struct {
	Event string           `json:"event"`
	Topic string           `json:"topic"`
	Data  *BroadcastParams `json:"data"`
}

func (*Broadcast) Marshal

func (bc *Broadcast) Marshal() []byte

type BroadcastParams

type BroadcastParams struct {
	UserOperationPartial *operation.UserOperationPartialRaw `json:"userOperation,omitempty"`
}

type BundleRequest

type BundleRequest struct {
	Id     string                         `json:"id"`
	Event  string                         `json:"event"`
	Bundle *operation.BundleOperationsRaw `json:"bundle"`
}

func (*BundleRequest) Marshal

func (br *BundleRequest) Marshal() []byte

type BundleResponse

type BundleResponse struct {
	Id     string      `json:"id" validate:"required"`
	Result common.Hash `json:"result,omitempty"`
	Error  string      `json:"error,omitempty"`
}

func (*BundleResponse) Marshal added in v1.0.1

func (br *BundleResponse) Marshal() []byte

type Conn

type Conn struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

func NewConn

func NewConn(conn *websocket.Conn, channel string, bundler common.Address, signatory common.Address) *Conn

type Marshaler

type Marshaler interface {
	Marshal() []byte
}

type Relay

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

func NewRelay

func NewRelay(ethClient *ethclient.Client, config *config.Config) *Relay

func (*Relay) Run

func (r *Relay) Run(serverReadyChan chan struct{})

type Request

type Request struct {
	Id     string         `json:"id" validate:"required"`
	Method string         `json:"method" validate:"required"`
	Params *RequestParams `json:"params" validate:"required"`
}

type RequestParams

type RequestParams struct {
	Topic           string                         `json:"topic"`
	SolverOperation *operation.SolverOperationRaw  `json:"solverOperation"`
	OpHash          common.Hash                    `json:"operationHash"`
	Bundle          *operation.BundleOperationsRaw `json:"bundle"`
}

type Response

type Response struct {
	Id     string      `json:"id"`
	Result interface{} `json:"result,omitempty"`
	Error  string      `json:"error,omitempty"`
}

func (*Response) Marshal

func (r *Response) Marshal() []byte

type RetrieveRequest

type RetrieveRequest struct {
	OpHash common.Hash
	Wait   bool
}

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

type Server

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

func NewServer

func NewServer(router *mux.Router, newSolverOperation newSolverOperationFn, getSolverOperationStatus getSolverOperationStatusFn, getDAppSignatories getDAppSignatoriesFn) *Server

func (*Server) BroadcastUserOperationPartial

func (s *Server) BroadcastUserOperationPartial(userOperationPartialRaw *operation.UserOperationPartialRaw)

func (*Server) ForwardBundle

func (s *Server) ForwardBundle(bundleOps *operation.BundleOperations, setAtlasTxHash setAtlasTxHashFn, setRelayError setRelayErrorFn, notifyCompletionSubs notifyCompletionSubsFn) *relayerror.Error

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(serverReadyChan chan struct{})

func (*Server) NewSignatoryRequest added in v1.0.4

func (s *Server) NewSignatoryRequest(userOpHash common.Hash, userOp *operation.UserOperation, solverOps []*operation.SolverOperation, signatories []common.Address, submitBundleOperations submitBundleOperationsFn, registerBundleError registerBundleErrorFn)

func (*Server) ServeWs

func (s *Server) ServeWs(w http.ResponseWriter, r *http.Request, channel string, bundler common.Address, signatory common.Address) (*Conn, error)

func (*Server) ServeWsBundler

func (s *Server) ServeWsBundler(w http.ResponseWriter, r *http.Request, bundler common.Address)

func (*Server) ServeWsSignatory added in v1.0.4

func (s *Server) ServeWsSignatory(w http.ResponseWriter, r *http.Request, signatory common.Address)

func (*Server) ServeWsSolver

func (s *Server) ServeWsSolver(w http.ResponseWriter, r *http.Request)

type SignatoryRequest added in v1.0.4

type SignatoryRequest struct {
	Id               string                          `json:"id"`
	Event            string                          `json:"event"`
	UserOperation    *operation.UserOperationRaw     `json:"userOperation"`
	SolverOperations []*operation.SolverOperationRaw `json:"solverOperations"`
}

func (*SignatoryRequest) Marshal added in v1.0.4

func (sr *SignatoryRequest) Marshal() []byte

type SignatoryResponse added in v1.0.4

type SignatoryResponse struct {
	Id     string                      `json:"id" validate:"required"`
	Result *operation.DAppOperationRaw `json:"result,omitempty"`
	Error  string                      `json:"error,omitempty"`
}

func (*SignatoryResponse) Marshal added in v1.0.4

func (sr *SignatoryResponse) Marshal() []byte

type SigningRequest added in v1.0.4

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

Jump to

Keyboard shortcuts

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