Documentation ¶
Overview ¶
Package base contains the base implementation for different sql driers.
Index ¶
- func GetAllModels() (allModels []interface{})
- type BridgeRequestModel
- type PendingProvenModel
- type Store
- func (s Store) DB() *gorm.DB
- func (s Store) GetBridgeRequestByID(ctx context.Context, id [32]byte) (*guarddb.BridgeRequest, error)
- func (s Store) GetPendingProvenByID(ctx context.Context, id [32]byte) (*guarddb.PendingProven, error)
- func (s Store) GetPendingProvensByStatus(ctx context.Context, matchStatuses ...guarddb.PendingProvenStatus) (res []*guarddb.PendingProven, _ error)
- func (s Store) StoreBridgeRequest(ctx context.Context, request guarddb.BridgeRequest) error
- func (s Store) StorePendingProven(ctx context.Context, proven guarddb.PendingProven) error
- func (s Store) SubmitterDB() submitterDB.Service
- func (s Store) UpdatePendingProvenStatus(ctx context.Context, id [32]byte, status guarddb.PendingProvenStatus) 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 BridgeRequestModel ¶
type BridgeRequestModel 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 // DestToken is the destination token address DestToken string // OriginAmount is the origin amount stored for sorting. // This is not the source of truth, but is approximate OriginAmount string // DestAmount is the destination amount stored for sorting. DestAmount string // 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"` // RawRequest is the raw request, hex encoded. RawRequest string // SendChainGas is true if the chain should send gas SendChainGas bool }
BridgeRequestModel is the primary event model.
func FromBridgeRequest ¶
func FromBridgeRequest(request guarddb.BridgeRequest) BridgeRequestModel
FromBridgeRequest converts a bridge request object to db model.
func (BridgeRequestModel) ToBridgeRequest ¶
func (b BridgeRequestModel) ToBridgeRequest() (*guarddb.BridgeRequest, error)
ToBridgeRequest converts the bridge request db model to object.
type PendingProvenModel ¶
type PendingProvenModel struct { // CreatedAt is the creation time CreatedAt time.Time // UpdatedAt is the update time UpdatedAt time.Time // Origin is the origin chain id Origin uint32 // RelayerAddress is the address of the relayer that called prove() RelayerAddress string // TransactionID is the transaction id of the event TransactionID string `gorm:"column:transaction_id;primaryKey"` // TxHash is the hash of the relay transaction on destination TxHash string // Status is the status of the event Status guarddb.PendingProvenStatus `gorm:"column:status;index:idx_guard_status_name"` // BlockNumber is the block number of the event BlockNumber uint64 }
PendingProvenModel is the primary event model.
func FromPendingProven ¶
func FromPendingProven(proven guarddb.PendingProven) PendingProvenModel
FromPendingProven converts a quote request to an object that can be stored in the db.
func (PendingProvenModel) ToPendingProven ¶
func (p PendingProvenModel) ToPendingProven() (*guarddb.PendingProven, error)
ToPendingProven converts a db object to a pending proven.
type Store ¶
type Store struct { listenerDB.ChainListenerDB // contains filtered or unexported fields }
Store implements the service.
func (Store) GetBridgeRequestByID ¶
func (s Store) GetBridgeRequestByID(ctx context.Context, id [32]byte) (*guarddb.BridgeRequest, error)
GetBridgeRequestByID gets a quote request by id. Should return ErrNoBridgeRequestForID if not found.
func (Store) GetPendingProvenByID ¶
func (s Store) GetPendingProvenByID(ctx context.Context, id [32]byte) (*guarddb.PendingProven, error)
GetPendingProvenByID gets a quote request by id. Should return ErrNoProvenForID if not found.
func (Store) GetPendingProvensByStatus ¶
func (s Store) GetPendingProvensByStatus(ctx context.Context, matchStatuses ...guarddb.PendingProvenStatus) (res []*guarddb.PendingProven, _ error)
GetPendingProvensByStatus gets pending provens by status.
func (Store) StoreBridgeRequest ¶
StoreBridgeRequest stores a quote request.
func (Store) StorePendingProven ¶
StorePendingProven stores a quote request.
func (Store) SubmitterDB ¶
func (s Store) SubmitterDB() submitterDB.Service
SubmitterDB gets the submitter database object for mutation outside of the lib.
func (Store) UpdatePendingProvenStatus ¶
func (s Store) UpdatePendingProvenStatus(ctx context.Context, id [32]byte, status guarddb.PendingProvenStatus) error
UpdatePendingProvenStatus updates the status of a pending proven.