web

package
v0.0.0-...-3674750 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 91 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PaginationDefault is the number of records to supply from a paginated
	// request when no size param is supplied.
	PaginationDefault = 25

	// MediaType is the response header for JSONAPI documents.
	MediaType = "application/vnd.api+json"

	// KeyNextLink is the name of the key that contains the HREF for the next
	// document in a paginated response.
	KeyNextLink = "next"
	// KeyPreviousLink is the name of the key that contains the HREF for the
	// previous document in a paginated response.
	KeyPreviousLink = "prev"
)
View Source
const (
	HealthStatusPassing = "passing"
	HealthStatusFailing = "failing"
)
View Source
const (
	FeatureKeyCSA string = "csa"
)

Variables

View Source
var (
	ErrMissingChainID = errors.New("chain id does not match any local chains")
	ErrEmptyChainID   = errors.New("chainID is empty")
	ErrInvalidChainID = errors.New("invalid chain id")
	ErrMultipleChains = errors.New("more than one chain available, you must specify chain id parameter")
)
View Source
var ErrEVMNotEnabled = errChainDisabled{/* contains filtered or unexported fields */}

Functions

func FindSessionCookie

func FindSessionCookie(cookies []*http.Cookie) *http.Cookie

FindSessionCookie returns the cookie with the "clsession" name

func FindTxAttempt

func FindTxAttempt(ctx context.Context, timeout time.Duration, etx txmgr.Tx, FindTxWithAttempts func(int64) (txmgr.Tx, error)) (attempt txmgr.TxAttempt, err error)

func GzipFileServer

func GzipFileServer(root ServeFileSystem, lggr logger.Logger) http.Handler

GzipFileServer is a drop-in replacement for Go's standard http.FileServer which adds support for static resources precompressed with gzip, at the cost of removing the support for directory browsing.

func NewJSONAPIResponse

func NewJSONAPIResponse(resource interface{}) ([]byte, error)

NewJSONAPIResponse returns a JSONAPI response for a single resource.

func NewPaginatedResponse

func NewPaginatedResponse(url url.URL, size, page, count int, resource interface{}) ([]byte, error)

NewPaginatedResponse returns a jsonapi.Document with links to next and previous collection pages

func NewRouter

func NewRouter(app erinaceus.Application, prometheus *ginprom.Prometheus) (*gin.Engine, error)

NewRouter returns *gin.Engine router that listens and responds to requests to the node for valid paths.

func ParseJSONAPIResponse

func ParseJSONAPIResponse(input []byte, resource interface{}) error

ParseJSONAPIResponse parses the bytes of the root document and unmarshals it into the given resource.

func ParsePaginatedRequest

func ParsePaginatedRequest(sizeParam, pageParam string) (int, int, int, error)

ParsePaginatedRequest parses the parameters that control pagination for a collection request, returning the size and offset if specified, or a sensible default.

func ParsePaginatedResponse

func ParsePaginatedResponse(input []byte, resource interface{}, links *jsonapi.Links) error

ParsePaginatedResponse parse a JSONAPI response for a document with links

func Router

func Router(t testing.TB, app erinaceus.Application, prometheus *ginprom.Prometheus) *gin.Engine

func ServeGzippedAssets

func ServeGzippedAssets(urlPrefix string, fs ServeFileSystem, lggr logger.Logger) gin.HandlerFunc

ServeGzippedAssets returns a middleware handler that serves static files in the given directory.

func ValidateBridgeType

func ValidateBridgeType(bt *bridges.BridgeTypeRequest) error

ValidateBridgeType checks that the bridge type has the required field with valid values.

func ValidateBridgeTypeNotExist

func ValidateBridgeTypeNotExist(bt *bridges.BridgeTypeRequest, orm bridges.ORM) error

ValidateBridgeTypeNotExist checks that a bridge has not already been created

func ValidateEthBalanceForTransfer

func ValidateEthBalanceForTransfer(c *gin.Context, chain legacyevm.Chain, fromAddr common.Address, amount assets.Eth) error

ValidateEthBalanceForTransfer validates that the current balance can cover the transaction amount

func ValidateExternalInitiator

func ValidateExternalInitiator(
	exi *bridges.ExternalInitiatorRequest,
	orm bridges.ORM,
) error

ValidateExternalInitiator checks whether External Initiator parameters are safe for processing.

Types

type BridgeTypesController

type BridgeTypesController struct {
	App erinaceus.Application
}

BridgeTypesController manages BridgeType requests in the node.

func (*BridgeTypesController) Create

func (btc *BridgeTypesController) Create(c *gin.Context)

Create adds the BridgeType to the given context.

func (*BridgeTypesController) Destroy

func (btc *BridgeTypesController) Destroy(c *gin.Context)

Destroy removes a specific Bridge.

func (*BridgeTypesController) Index

func (btc *BridgeTypesController) Index(c *gin.Context, size, page, offset int)

Index lists Bridges, one page at a time.

func (*BridgeTypesController) Show

func (btc *BridgeTypesController) Show(c *gin.Context)

Show returns the details of a specific Bridge.

func (*BridgeTypesController) Update

func (btc *BridgeTypesController) Update(c *gin.Context)

Update can change the restricted attributes for a bridge

type BuildInfoController

type BuildInfoController struct {
	App erinaceus.Application
}

BuildVersonController has the build_info endpoint.

func (*BuildInfoController) Show

func (eic *BuildInfoController) Show(c *gin.Context)

Show returns the build info.

type CSAKeysController

type CSAKeysController struct {
	App erinaceus.Application
}

CSAKeysController manages CSA keys

func (*CSAKeysController) Create

func (ctrl *CSAKeysController) Create(c *gin.Context)

Create and return a CSA key Example: "POST <application>/keys/csa"

func (*CSAKeysController) Export

func (ctrl *CSAKeysController) Export(c *gin.Context)

Export exports a key

func (*CSAKeysController) Import

func (ctrl *CSAKeysController) Import(c *gin.Context)

Import imports a CSA key

func (*CSAKeysController) Index

func (ctrl *CSAKeysController) Index(c *gin.Context)

Index lists CSA keys Example: "GET <application>/keys/csa"

type ChainsController

type ChainsController interface {
	// Index lists chains.
	Index(c *gin.Context, size, page, offset int)
	// Show gets a chain by id.
	Show(*gin.Context)
}

func NewEVMChainsController

func NewEVMChainsController(app erinaceus.Application) ChainsController

type ConfigController

type ConfigController struct {
	App erinaceus.Application
}

ConfigController manages config variables

func (*ConfigController) Show

func (cc *ConfigController) Show(c *gin.Context)

Show returns the whitelist of config variables Example:

"<application>/config"

type ConfigV2Resource

type ConfigV2Resource struct {
	Config string `json:"config"`
}

func (ConfigV2Resource) GetID

func (c ConfigV2Resource) GetID() string

func (*ConfigV2Resource) SetID

func (c *ConfigV2Resource) SetID(string) error

type CreateJobRequest

type CreateJobRequest struct {
	TOML string `json:"toml"`
}

CreateJobRequest represents a request to create and start a job (V2).

type ETHKeysController

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

ETHKeysController manages account keys

func NewETHKeysController

func NewETHKeysController(app erinaceus.Application) *ETHKeysController

func (*ETHKeysController) Chain

func (ekc *ETHKeysController) Chain(c *gin.Context)

Chain updates settings for a given chain for the key

func (*ETHKeysController) Create

func (ekc *ETHKeysController) Create(c *gin.Context)

Create adds a new account Example:

"<application>/keys/eth"

func (*ETHKeysController) Delete

func (ekc *ETHKeysController) Delete(c *gin.Context)

Delete an ETH key bundle (irreversible!) Example: "DELETE <application>/keys/eth/:keyID"

func (*ETHKeysController) Export

func (ekc *ETHKeysController) Export(c *gin.Context)

func (*ETHKeysController) Import

func (ekc *ETHKeysController) Import(c *gin.Context)

Import imports a key

func (*ETHKeysController) Index

func (ekc *ETHKeysController) Index(c *gin.Context)

Index returns the node's Ethereum keys and the account balances of ETH & LINK. Example:

"<application>/keys/eth"

type EVMTransfersController

type EVMTransfersController struct {
	App erinaceus.Application
}

EVMTransfersController can send LINK tokens to another address

func (*EVMTransfersController) Create

func (tc *EVMTransfersController) Create(c *gin.Context)

Create sends ETH from the Chainlink's account to a specified address.

Example: "<application>/withdrawals"

type EmbedFileSystem

type EmbedFileSystem struct {
	embed.FS
	http.FileSystem
	// contains filtered or unexported fields
}

EmbedFileSystem implements the ServeFileSystem interface using an embed.FS object.

func (*EmbedFileSystem) Exists

func (e *EmbedFileSystem) Exists(prefix string, filepath string) bool

Exists implements the ServeFileSystem interface.

func (*EmbedFileSystem) Open

func (e *EmbedFileSystem) Open(name string) (http.File, error)

Open implements the http.FileSystem interface.

type ExternalInitiatorsController

type ExternalInitiatorsController struct {
	App erinaceus.Application
}

ExternalInitiatorsController manages external initiators

func (*ExternalInitiatorsController) Create

func (eic *ExternalInitiatorsController) Create(c *gin.Context)

Create builds and saves a new external initiator

func (*ExternalInitiatorsController) Destroy

func (eic *ExternalInitiatorsController) Destroy(c *gin.Context)

Destroy deletes an ExternalInitiator

func (*ExternalInitiatorsController) Index

func (eic *ExternalInitiatorsController) Index(c *gin.Context, size, page, offset int)

type FeaturesController

type FeaturesController struct {
	App erinaceus.Application
}

FeaturesController manages the feature flags

func (*FeaturesController) Index

func (fc *FeaturesController) Index(c *gin.Context)

Index retrieves the features Example: "GET <application>/features"

type HealthController

type HealthController struct {
	App erinaceus.Application
}

func (*HealthController) Health

func (hc *HealthController) Health(c *gin.Context)

func (*HealthController) Readyz

func (hc *HealthController) Readyz(c *gin.Context)

NOTE: We only implement the k8s readiness check, *not* the liveness check. Liveness checks are only recommended in cases where the app doesn't crash itself on panic, and if implemented incorrectly can cause cascading failures. See the following for more information: - https://srcco.de/posts/kubernetes-liveness-probes-are-dangerous.html

type JobsController

type JobsController struct {
	App erinaceus.Application
}

JobsController manages jobs

func (*JobsController) Create

func (jc *JobsController) Create(c *gin.Context)

Create validates, saves and starts a new job. Example: "POST <application>/jobs"

func (*JobsController) Delete

func (jc *JobsController) Delete(c *gin.Context)

Delete hard deletes a job spec. Example: "DELETE <application>/specs/:ID"

func (*JobsController) Index

func (jc *JobsController) Index(c *gin.Context, size, page, offset int)

Index lists all jobs Example: "GET <application>/jobs"

func (*JobsController) Show

func (jc *JobsController) Show(c *gin.Context)

Show returns the details of a job :ID could be both job ID and external job ID Example: "GET <application>/jobs/:ID"

func (*JobsController) Update

func (jc *JobsController) Update(c *gin.Context)

Update validates a new TOML for an existing job, stops and deletes existing job, saves and starts a new job. Example: "PUT <application>/jobs/:ID"

type KeysController

type KeysController interface {
	// Index lists keys
	Index(*gin.Context)
	// Create and return a key
	Create(*gin.Context)
	// Delete a key
	Delete(*gin.Context)
	// Import imports a key
	Import(*gin.Context)
	// Export exports a key
	Export(*gin.Context)
}

func NewDKGEncryptKeysController

func NewDKGEncryptKeysController(app erinaceus.Application) KeysController

func NewDKGSignKeysController

func NewDKGSignKeysController(app erinaceus.Application) KeysController

func NewKeysController

func NewKeysController[K keystore.Key, R jsonapi.EntityNamer](ks Keystore[K], lggr logger.Logger, auditLogger audit.AuditLogger, resourceName string,
	newResource func(K) *R, newResources func([]K) []R) KeysController

type Keystore

type Keystore[K keystore.Key] interface {
	Get(id string) (K, error)
	GetAll() ([]K, error)
	Create() (K, error)
	Delete(id string) (K, error)
	Import(keyJSON []byte, password string) (K, error)
	Export(id string, password string) ([]byte, error)
}

type LogController

type LogController struct {
	App erinaceus.Application
}

LogController manages the logger config

func (*LogController) Get

func (cc *LogController) Get(c *gin.Context)

Get retrieves the current log config settings

func (*LogController) Patch

func (cc *LogController) Patch(c *gin.Context)

Patch sets a log level and enables sql logging for the logger

type LogPatchRequest

type LogPatchRequest struct {
	Level      string `json:"level"`
	SqlEnabled *bool  `json:"sqlEnabled"`
}

type LoopRegistryServer

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

func NewLoopRegistryServer

func NewLoopRegistryServer(app erinaceus.Application) *LoopRegistryServer

type NetworkScopedNodeStatuser

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

func (*NetworkScopedNodeStatuser) NodeStatuses

func (n *NetworkScopedNodeStatuser) NodeStatuses(ctx context.Context, offset, limit int, relayIDs ...relay.ID) (nodes []types.NodeStatus, count int, err error)

type NodesController

type NodesController interface {
	// Index lists nodes, and optionally filters by chain id.
	Index(c *gin.Context, size, page, offset int)
}

func NewEVMNodesController

func NewEVMNodesController(app erinaceus.Application) NodesController

type PingController

type PingController struct {
	App erinaceus.Application
}

PingController has the ping endpoint.

func (*PingController) Show

func (eic *PingController) Show(c *gin.Context)

Show returns pong.

type PipelineJobSpecErrorsController

type PipelineJobSpecErrorsController struct {
	App erinaceus.Application
}

PipelineJobSpecErrorsController manages PipelineJobSpecError requests

func (*PipelineJobSpecErrorsController) Destroy

func (psec *PipelineJobSpecErrorsController) Destroy(c *gin.Context)

Destroy deletes a PipelineJobSpecError record from the database, effectively silencing the error notification

type PipelineRunsController

type PipelineRunsController struct {
	App erinaceus.Application
}

PipelineRunsController manages V2 job run requests.

func (*PipelineRunsController) Create

func (prc *PipelineRunsController) Create(c *gin.Context)

Create triggers a pipeline run for a job. Example: "POST <application>/jobs/:ID/runs"

func (*PipelineRunsController) Index

func (prc *PipelineRunsController) Index(c *gin.Context, size, page, offset int)

Index returns all pipeline runs for a job. Example: "GET <application>/jobs/:ID/runs"

func (*PipelineRunsController) Resume

func (prc *PipelineRunsController) Resume(c *gin.Context)

Resume finishes a task and resumes the pipeline run. Example: "PATCH <application>/jobs/:ID/runs/:runID"

func (*PipelineRunsController) Show

func (prc *PipelineRunsController) Show(c *gin.Context)

Show returns a specified pipeline run. Example: "GET <application>/jobs/:ID/runs/:runID"

type ReplayController

type ReplayController struct {
	App erinaceus.Application
}

func (*ReplayController) ReplayFromBlock

func (bdc *ReplayController) ReplayFromBlock(c *gin.Context)

ReplayFromBlock causes the node to process blocks again from the given block number Example:

"<application>/v2/replay_from_block/:number"

type ReplayResponse

type ReplayResponse struct {
	Message    string   `json:"message"`
	EVMChainID *big.Big `json:"evmChainID"`
}

func (ReplayResponse) GetID

func (s ReplayResponse) GetID() string

GetID returns the jsonapi ID.

func (ReplayResponse) GetName

func (ReplayResponse) GetName() string

GetName returns the collection name for jsonapi.

func (*ReplayResponse) SetID

func (*ReplayResponse) SetID(string) error

SetID is used to conform to the UnmarshallIdentifier interface for deserializing from jsonapi documents.

type ServeFileSystem

type ServeFileSystem interface {
	http.FileSystem
	Exists(prefix string, path string) bool
}

ServeFileSystem wraps a http.FileSystem with an additional file existence check

func NewEmbedFileSystem

func NewEmbedFileSystem(efs embed.FS, pathPrefix string) ServeFileSystem

type Session

type Session struct {
	Authenticated bool `json:"authenticated"`
}

func (Session) GetID

func (s Session) GetID() string

GetID returns the jsonapi ID.

func (Session) GetName

func (Session) GetName() string

GetName returns the collection name for jsonapi.

func (*Session) SetID

func (*Session) SetID(string) error

SetID is used to conform to the UnmarshallIdentifier interface for deserializing from jsonapi documents.

type SessionsController

type SessionsController struct {
	App erinaceus.Application
	// contains filtered or unexported fields
}

SessionsController manages session requests.

func NewSessionsController

func NewSessionsController(app erinaceus.Application) *SessionsController

func (*SessionsController) Create

func (sc *SessionsController) Create(c *gin.Context)

Create creates a session ID for the given user credentials, and returns it in a cookie.

func (*SessionsController) Destroy

func (sc *SessionsController) Destroy(c *gin.Context)

Destroy removes the specified session ID from the database.

type TransactionsController

type TransactionsController struct {
	App erinaceus.Application
}

TransactionsController displays Ethereum transactions requests.

func (*TransactionsController) Index

func (tc *TransactionsController) Index(c *gin.Context, size, page, offset int)

Index returns paginated transactions

func (*TransactionsController) Show

func (tc *TransactionsController) Show(c *gin.Context)

Show returns the details of a Ethereum Transaction details. Example:

"<application>/transactions/:TxHash"

type TxAttemptsController

type TxAttemptsController struct {
	App erinaceus.Application
}

TxAttemptsController lists TxAttempts requests.

func (*TxAttemptsController) Index

func (tac *TxAttemptsController) Index(c *gin.Context, size, page, offset int)

Index returns paginated transaction attempts

type UpdateJobRequest

type UpdateJobRequest struct {
	TOML string `json:"toml"`
}

UpdateJobRequest represents a request to update a job with new toml and start a job (V2).

type UpdatePasswordRequest

type UpdatePasswordRequest struct {
	OldPassword string `json:"oldPassword"`
	NewPassword string `json:"newPassword"`
}

UpdatePasswordRequest defines the request to set a new password for the current session's User.

type UserController

type UserController struct {
	App erinaceus.Application
}

UserController manages the current Session's User.

func (*UserController) Create

func (c *UserController) Create(ctx *gin.Context)

Create creates a new API user with provided context arguments.

func (*UserController) Delete

func (c *UserController) Delete(ctx *gin.Context)

Delete deletes an API user and any sessions by email

func (*UserController) DeleteAPIToken

func (c *UserController) DeleteAPIToken(ctx *gin.Context)

DeleteAPIToken deletes and disables a user's API token.

func (*UserController) Index

func (c *UserController) Index(ctx *gin.Context)

Index lists all API users

func (*UserController) NewAPIToken

func (c *UserController) NewAPIToken(ctx *gin.Context)

NewAPIToken generates a new API token for a user overwriting any pre-existing one set.

func (*UserController) UpdatePassword

func (c *UserController) UpdatePassword(ctx *gin.Context)

UpdatePassword changes the password for the current User.

func (*UserController) UpdateRole

func (c *UserController) UpdateRole(ctx *gin.Context)

UpdateRole changes role field of a specified API user.

type VRFKeysController

type VRFKeysController struct {
	App erinaceus.Application
}

VRFKeysController manages VRF keys

func (*VRFKeysController) Create

func (vrfkc *VRFKeysController) Create(c *gin.Context)

Create and return a VRF key Example: "POST <application>/keys/vrf"

func (*VRFKeysController) Delete

func (vrfkc *VRFKeysController) Delete(c *gin.Context)

Delete a VRF key Example: "DELETE <application>/keys/vrf/:keyID" "DELETE <application>/keys/vrf/:keyID?hard=true"

func (*VRFKeysController) Export

func (vrfkc *VRFKeysController) Export(c *gin.Context)

Export exports a VRF key Example: "Post <application>/keys/vrf/export/:keyID"

func (*VRFKeysController) Import

func (vrfkc *VRFKeysController) Import(c *gin.Context)

Import imports a VRF key Example: "Post <application>/keys/vrf/import"

func (*VRFKeysController) Index

func (vrfkc *VRFKeysController) Index(c *gin.Context)

Index lists VRF keys Example: "GET <application>/keys/vrf"

type WebAuthnController

type WebAuthnController struct {
	App erinaceus.Application
	// contains filtered or unexported fields
}

WebAuthnController manages registers new keys as well as authentication with those keys

func NewWebAuthnController

func NewWebAuthnController(app erinaceus.Application) WebAuthnController

func (*WebAuthnController) BeginRegistration

func (c *WebAuthnController) BeginRegistration(ctx *gin.Context)

func (*WebAuthnController) FinishRegistration

func (c *WebAuthnController) FinishRegistration(ctx *gin.Context)

Directories

Path Synopsis
Package schema is used to read schema files go:generate go-bindata -ignore=\.go -pkg=schema -o=bindata.go ./...
Package schema is used to read schema files go:generate go-bindata -ignore=\.go -pkg=schema -o=bindata.go ./...

Jump to

Keyboard shortcuts

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