Documentation ¶
Overview ¶
Package base contains the base implementation for different sql driers.
Index ¶
- func GetAllModels() (allModels []interface{})
- type Rebalance
- type RequestForQuote
- type Store
- func (s Store) DB() *gorm.DB
- func (s Store) GetQuoteRequestByID(ctx context.Context, id [32]byte) (*reldb.QuoteRequest, error)
- func (s Store) GetQuoteRequestByOriginTxHash(ctx context.Context, txHash common.Hash) (*reldb.QuoteRequest, error)
- func (s Store) GetQuoteResultsByStatus(ctx context.Context, matchStatuses ...reldb.QuoteRequestStatus) (res []reldb.QuoteRequest, _ error)
- func (s Store) HasPendingRebalance(ctx context.Context, chainIDs ...uint64) (bool, error)
- func (s Store) StoreQuoteRequest(ctx context.Context, request reldb.QuoteRequest) error
- func (s Store) StoreRebalance(ctx context.Context, rebalance reldb.Rebalance) error
- func (s Store) SubmitterDB() submitterDB.Service
- func (s Store) UpdateDestTxHash(ctx context.Context, id [32]byte, destTxHash common.Hash) error
- func (s Store) UpdateQuoteRequestStatus(ctx context.Context, id [32]byte, status reldb.QuoteRequestStatus) error
- func (s Store) UpdateRebalanceStatus(ctx context.Context, id [32]byte, origin *uint64, status reldb.RebalanceStatus) error
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
FromRebalance converts a rebalance to a db object.
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 (Store) GetQuoteRequestByID ¶
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) HasPendingRebalance ¶ added in v0.0.54
HasPendingRebalance checks if there is a pending rebalance for the given chain ids.
func (Store) StoreQuoteRequest ¶
StoreQuoteRequest stores a quote request.
func (Store) StoreRebalance ¶ added in v0.0.54
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 ¶
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) UpdateRebalanceStatus ¶ added in v0.0.54
func (s Store) UpdateRebalanceStatus(ctx context.Context, id [32]byte, origin *uint64, status reldb.RebalanceStatus) error
UpdateRebalanceStatus updates the rebalance status.