base

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package base contains the base implementation for different sql driers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllModels

func GetAllModels() (allModels []interface{})

GetAllModels gets all models to migrate see: https://medium.com/@SaifAbid/slice-interfaces-8c78f8b6345d for an explanation of why we can't do this at initialization time

Types

type Rebalance added in v0.0.54

type Rebalance struct {
	CreatedAt    time.Time
	UpdatedAt    time.Time
	RebalanceID  sql.NullString
	Origin       uint64
	Destination  uint64
	OriginAmount string
	Status       reldb.RebalanceStatus
	OriginTxHash sql.NullString
	DestTxHash   sql.NullString
}

Rebalance is the event model for a rebalance action.

func FromRebalance added in v0.0.54

func FromRebalance(rebalance reldb.Rebalance) Rebalance

FromRebalance converts a rebalance to a db object.

func (Rebalance) ToRebalance added in v0.5.0

func (r Rebalance) ToRebalance() (*reldb.Rebalance, error)

ToRebalance converts a db object to a rebalance.

type RequestForQuote

type RequestForQuote struct {
	// CreatedAt is the creation time
	CreatedAt time.Time
	// UpdatedAt is the update time
	UpdatedAt time.Time
	// TransactionID is the transaction id of the event
	TransactionID string `gorm:"column:transaction_id;primaryKey"`
	// OriginChainID is the origin chain for the transactions
	OriginChainID uint32
	// DestChainID is the destination chain for the tx
	DestChainID uint32
	// OriginSender is the original sender
	OriginSender string
	// DestRecipient is the recipient of the destination tx
	DestRecipient string
	// OriginToken is the origin token address
	OriginToken string
	// OriginAmountOriginal is the origin amount used for preicison
	OriginAmountOriginal string
	// OriginTokenDecimals is the origin token decimals
	OriginTokenDecimals uint8
	// DestToken is the destination token address
	DestToken string
	// DestTokenDecimals is the destination token decimal count
	DestTokenDecimals uint8
	// OriginAmount is the origin amount stored for sorting.
	// This is not the source of truth, but is approximate
	OriginAmount decimal.Decimal `gorm:"index"`
	// OriginTxHash is the origin tx hash
	OriginTxHash sql.NullString
	// DestAmountOriginal is the original amount used for precision
	DestAmountOriginal string
	// DestAmountOriginal is the original destination amount
	DestAmount decimal.Decimal `gorm:"index"`
	// DestTxHash is the destination tx hash
	DestTxHash sql.NullString
	// Deadline is the deadline for the relay
	Deadline time.Time `gorm:"index"`
	// OriginNonce is the nonce on the origin chain in the app.
	// this is not effected by the message.sender nonce.
	OriginNonce int `gorm:"index"`
	// Status is the current status of the event
	Status reldb.QuoteRequestStatus
	// BlockNumber is the block number of the event
	BlockNumber uint64
	// RawRequest is the raw request, hex encoded.
	RawRequest string
	// SendChainGas is true if the chain should send gas
	SendChainGas bool
}

RequestForQuote is the primary event model.

func FromQuoteRequest

func FromQuoteRequest(request reldb.QuoteRequest) RequestForQuote

FromQuoteRequest converts a quote request to an object that can be stored in the db. TODO: add validation for deadline > uint64 TODO: roundtripper test.

func (RequestForQuote) ToQuoteRequest

func (r RequestForQuote) ToQuoteRequest() (*reldb.QuoteRequest, error)

ToQuoteRequest converts a db object to a quote request.

type Store

type Store struct {
	listenerDB.ChainListenerDB
	// contains filtered or unexported fields
}

Store implements the service.

func NewStore

func NewStore(db *gorm.DB, metrics metrics.Handler) *Store

NewStore creates a new store.

func (Store) DB

func (s Store) DB() *gorm.DB

DB gets the database object for mutation outside of the lib.

func (Store) GetQuoteRequestByID

func (s Store) GetQuoteRequestByID(ctx context.Context, id [32]byte) (*reldb.QuoteRequest, error)

GetQuoteRequestByID gets a quote request by id. Should return ErrNoQuoteForID if not found.

func (Store) GetQuoteRequestByOriginTxHash added in v0.0.15

func (s Store) GetQuoteRequestByOriginTxHash(ctx context.Context, txHash common.Hash) (*reldb.QuoteRequest, error)

GetQuoteRequestByOriginTxHash gets a quote request by tx hash. Should return ErrNoQuoteForID if not found.

func (Store) GetQuoteResultsByStatus

func (s Store) GetQuoteResultsByStatus(ctx context.Context, matchStatuses ...reldb.QuoteRequestStatus) (res []reldb.QuoteRequest, _ error)

GetQuoteResultsByStatus gets quote results by status.

func (Store) GetRebalanceByID added in v0.5.0

func (s Store) GetRebalanceByID(ctx context.Context, rebalanceID string) (*reldb.Rebalance, error)

GetRebalanceByID gets a rebalance by id. Should return ErrNoRebalanceForID if not found.

func (Store) HasPendingRebalance added in v0.0.54

func (s Store) HasPendingRebalance(ctx context.Context, chainIDs ...uint64) (bool, error)

HasPendingRebalance checks if there is a pending rebalance for the given chain ids.

func (Store) StoreQuoteRequest

func (s Store) StoreQuoteRequest(ctx context.Context, request reldb.QuoteRequest) error

StoreQuoteRequest stores a quote request.

func (Store) StoreRebalance added in v0.0.54

func (s Store) StoreRebalance(ctx context.Context, rebalance reldb.Rebalance) error

StoreRebalance stores a rebalance action.

func (Store) SubmitterDB

func (s Store) SubmitterDB() submitterDB.Service

SubmitterDB gets the submitter database object for mutation outside of the lib.

func (Store) UpdateDestTxHash

func (s Store) UpdateDestTxHash(ctx context.Context, id [32]byte, destTxHash common.Hash) error

UpdateDestTxHash todo: db test.

func (Store) UpdateQuoteRequestStatus

func (s Store) UpdateQuoteRequestStatus(ctx context.Context, id [32]byte, status reldb.QuoteRequestStatus) error

UpdateQuoteRequestStatus todo: db test.

func (Store) UpdateRebalance added in v0.5.0

func (s Store) UpdateRebalance(ctx context.Context, rebalance reldb.Rebalance, updateID bool) error

UpdateRebalance updates the rebalance status.

Jump to

Keyboard shortcuts

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