bridges

package
v1.10.17 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthenticateBridgeType

func AuthenticateBridgeType(bt *BridgeType, token string) (bool, error)

AuthenticateBridgeType returns true if the passed token matches its IncomingToken, or returns false with an error.

func AuthenticateExternalInitiator

func AuthenticateExternalInitiator(eia *auth.Token, ea *ExternalInitiator) (bool, error)

AuthenticateExternalInitiator compares an auth against an initiator and returns true if the password hashes match

func MarshalBridgeMetaData

func MarshalBridgeMetaData(latestAnswer *big.Int, updatedAt *big.Int) (map[string]interface{}, error)

func NewBridgeType

NewBridgeType returns a bridge bridge type authentication (with plaintext password) and a bridge type (with hashed password, for persisting)

Types

type BridgeMetaData

type BridgeMetaData struct {
	LatestAnswer *big.Int `json:"latestAnswer"`
	UpdatedAt    *big.Int `json:"updatedAt"` // A unix timestamp
}

NOTE: latestAnswer and updatedAt is the only metadata used. Currently market closer adapter and outlier detection depend latestAnswer. https://github.com/smartcontractkit/external-adapters-js/tree/f474bd2e2de13ebe5c9dc3df36ebb7018817005e/composite/market-closure https://github.com/smartcontractkit/external-adapters-js/tree/5abb8e5ec2024f724fd39122897baa63c3cd0167/composite/outlier-detection

type BridgeMetaDataJSON

type BridgeMetaDataJSON struct {
	Meta BridgeMetaData
}

type BridgeType

type BridgeType struct {
	Name                   TaskType `gorm:"primary_key"`
	URL                    models.WebURL
	Confirmations          uint32
	IncomingTokenHash      string
	Salt                   string
	OutgoingToken          string
	MinimumContractPayment *assets.Link `gorm:"type:varchar(255)"`
	CreatedAt              time.Time
	UpdatedAt              time.Time
}

BridgeType is used for external adapters and has fields for the name of the adapter and its URL.

type BridgeTypeAuthentication

type BridgeTypeAuthentication struct {
	Name                   TaskType
	URL                    models.WebURL
	Confirmations          uint32
	IncomingToken          string
	OutgoingToken          string
	MinimumContractPayment *assets.Link
}

BridgeTypeAuthentication is the record returned in response to a request to create a BridgeType

type BridgeTypeRequest

type BridgeTypeRequest struct {
	Name                   TaskType      `json:"name"`
	URL                    models.WebURL `json:"url"`
	Confirmations          uint32        `json:"confirmations"`
	MinimumContractPayment *assets.Link  `json:"minimumContractPayment"`
}

BridgeTypeRequest is the incoming record used to create a BridgeType

func (BridgeTypeRequest) GetID

func (bt BridgeTypeRequest) GetID() string

GetID returns the ID of this structure for jsonapi serialization.

func (BridgeTypeRequest) GetName

func (bt BridgeTypeRequest) GetName() string

GetName returns the pluralized "type" of this structure for jsonapi serialization.

func (*BridgeTypeRequest) SetID

func (bt *BridgeTypeRequest) SetID(value string) error

SetID is used to set the ID of this structure when deserializing from jsonapi documents.

type ExternalInitiator

type ExternalInitiator struct {
	ID             int64          `gorm:"primary_key"`
	Name           string         `gorm:"not null;unique"`
	URL            *models.WebURL `gorm:"url,omitempty"`
	AccessKey      string         `gorm:"not null"`
	Salt           string         `gorm:"not null"`
	HashedSecret   string         `gorm:"not null"`
	OutgoingSecret string         `gorm:"not null"`
	OutgoingToken  string         `gorm:"not null"`

	CreatedAt time.Time
	UpdatedAt time.Time
}

ExternalInitiator represents a user that can initiate runs remotely

func NewExternalInitiator

func NewExternalInitiator(
	eia *auth.Token,
	eir *ExternalInitiatorRequest,
) (*ExternalInitiator, error)

NewExternalInitiator generates an ExternalInitiator from an auth.Token, hashing the password for storage

type ExternalInitiatorRequest

type ExternalInitiatorRequest struct {
	Name string         `json:"name"`
	URL  *models.WebURL `json:"url,omitempty"`
}

ExternalInitiatorRequest is the incoming record used to create an ExternalInitiator.

type ORM

type ORM interface {
	FindBridge(name TaskType) (bt BridgeType, err error)
	DeleteBridgeType(bt *BridgeType) error
	BridgeTypes(offset int, limit int) ([]BridgeType, int, error)
	CreateBridgeType(bt *BridgeType) error
	UpdateBridgeType(bt *BridgeType, btr *BridgeTypeRequest) error

	ExternalInitiators(offset int, limit int) ([]ExternalInitiator, int, error)
	CreateExternalInitiator(externalInitiator *ExternalInitiator) error
	DeleteExternalInitiator(name string) error
	FindExternalInitiator(eia *auth.Token) (*ExternalInitiator, error)
	FindExternalInitiatorByName(iname string) (exi ExternalInitiator, err error)
}

func NewORM

func NewORM(db *sqlx.DB) ORM

type TaskType

type TaskType string

TaskType defines what Adapter a TaskSpec will use.

func MustNewTaskType

func MustNewTaskType(val string) TaskType

MustNewTaskType instantiates a new TaskType, and panics if a bad input is provided.

func NewTaskType

func NewTaskType(val string) (TaskType, error)

NewTaskType returns a formatted Task type.

func (TaskType) MarshalJSON

func (t TaskType) MarshalJSON() ([]byte, error)

MarshalJSON converts a TaskType to a JSON byte slice.

func (*TaskType) Scan

func (t *TaskType) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (TaskType) String

func (t TaskType) String() string

String returns this TaskType as a string.

func (*TaskType) UnmarshalJSON

func (t *TaskType) UnmarshalJSON(input []byte) error

UnmarshalJSON converts a bytes slice of JSON to a TaskType.

func (TaskType) Value

func (t TaskType) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

Jump to

Keyboard shortcuts

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