database

package
v0.0.0-...-d7f79cc Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PendingStatus = 0

	SuccessStatus = 2
	FailStatus    = 3
	StakingStatus = 9
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchMint

type BatchMint struct {
	GUID          uuid.UUID      `gorm:"primaryKey;DEFAULT replace(uuid_generate_v4()::text,'-','')" json:"guid"`
	StakerAddress common.Address `gorm:"column:staker_address;serializer:bytes" db:"staker_address" json:"staker_address" form:"staker_address"`
	SharesAmount  *big.Int       `gorm:"serializer:u256;column:shares_amount" db:"shares_amount" json:"shares_amount" form:"shares_amount"`
	Batch         *big.Int       `gorm:"serializer:u256;column:batch" db:"batch" json:"batch" form:"batch"`
	TxHash        common.Hash    `gorm:"column:tx_hash;serializer:bytes" db:"tx_hash" json:"tx_hash" form:"tx_hash"`
	Status        int8           `gorm:"column:status" db:"status" json:"status" form:"status"`
	Timestamp     int64          `gorm:"column:timestamp" db:"timestamp" json:"timestamp" form:"timestamp"`
}

func (BatchMint) TableName

func (BatchMint) TableName() string

type BatchMintDB

type BatchMintDB interface {
	BatchMintView
	StoreBatchMint([]BatchMint) error
	BuildBatchMint(in *pb.BatchMintRequest) []BatchMint
	ChangeBatchMintSentStatusByTxHash(txHash string) error
	UpdateBatchMintTransactionHash([]BatchMint) error
	UpdateBatchMintFailStatus(BatchMint) error
}

func NewBatchMintDB

func NewBatchMintDB(db *gorm.DB) BatchMintDB

type BatchMintView

type BatchMintView interface {
	BatchMintByBatch(batch uint64) (*BatchMint, error)
	BatchMintsByBatch(batch uint64) ([]BatchMint, error)
	BatchMintByTxHash(txHash string) (*BatchMint, error)
	OldestPendingSentTransaction() (*BatchMint, error)
	OldestPendingNoSentTransaction() (*BatchMint, error)
}

type CrossChainTransfer

type CrossChainTransfer struct {
	GUID                uuid.UUID      `gorm:"primaryKey;DEFAULT replace(uuid_generate_v4()::text,'-','')" json:"guid"`
	SourceChainId       *big.Int       `gorm:"serializer:u256;column:source_chain_id" db:"source_chain_id" json:"source_chain_id" form:"source_chain_id"`
	DestChainId         *big.Int       `gorm:"serializer:u256;column:dest_chain_id" db:"dest_chain_id" json:"dest_chain_id" form:"dest_chain_id"`
	Fee                 *big.Int       `gorm:"serializer:u256;column:fee" db:"fee" json:"fee" form:"fee"`
	Nonce               *big.Int       `gorm:"serializer:u256;column:nonce" db:"nonce" json:"nonce" form:"nonce"`
	SourceHash          common.Hash    `gorm:"column:source_hash;serializer:bytes" db:"source_hash" json:"source_hash" form:"source_hash"`
	TxHash              common.Hash    `gorm:"column:tx_hash;serializer:bytes" db:"tx_hash" json:"tx_hash" form:"tx_hash"`
	SourceSenderAddress common.Address `` /* 137-byte string literal not displayed */
	DestReceiveAddress  common.Address `` /* 133-byte string literal not displayed */
	TokenAddress        common.Address `gorm:"column:token_address;serializer:bytes" db:"token_address" json:"token_address" form:"token_address"`
	Amount              *big.Int       `gorm:"serializer:u256;column:amount" db:"amount" json:"amount" form:"amount"`
	Status              int8           `gorm:"column:status" db:"status" json:"status" form:"status"`
	Timestamp           int64          `gorm:"column:timestamp" db:"timestamp" json:"timestamp" form:"timestamp"`
}

func (CrossChainTransfer) TableName

func (CrossChainTransfer) TableName() string

type CrossChainTransferDB

type CrossChainTransferDB interface {
	CrossChainTransferView
	StoreBatchCrossChainTransfer([]CrossChainTransfer) error
	BuildCrossChainTransfer(in *pb.CrossChainTransferRequest, sourceHash common.Hash) CrossChainTransfer
	CrossChainTransferBySourceHash(sourceHash string) (*CrossChainTransfer, error)
	ChangeCrossChainTransferSentStatusByTxHash(txHash string) error
	ChangeCrossChainTransferSuccessStatueByTxHash(txHash string) error
	UpdateCrossChainTransferTransactionHash(CrossChainTransfer) error
	UpdateCrossChainTransferStakingTransactionHash(CrossChainTransfer) error
	UpdateCrossChainTransferFailStatus(CrossChainTransfer) error
}

func NewCrossChainTransferDB

func NewCrossChainTransferDB(db *gorm.DB) CrossChainTransferDB

type CrossChainTransferView

type CrossChainTransferView interface {
	CrossChainTransferByTxHash(txHash string) (*CrossChainTransfer, error)
	OldestPendingSentTransaction() ([]CrossChainTransfer, error)
	OldestPendingNoSentTransaction() ([]CrossChainTransfer, error)
	GetPeriodTotalFee(startTimestamp uint64, endTimeStamp uint64, tokenAddress common.Address) (*big.Int, error)
}

type DB

type DB struct {
	CrossChainTransfer               CrossChainTransferDB
	UpdateDepositFundingPoolBalance  UpdateDepositFundingPoolBalanceDB
	UpdateWithdrawFundingPoolBalance UpdateWithdrawFundingPoolBalanceDB
	UnstakeBatch                     UnstakeBatchDB
	MigrateL1Shares                  MigrateL1SharesDB
	TransferToL2Bridge               TransferToL2BridgeDB
	BatchMint                        BatchMintDB
	TransferL2Share                  TransferL2ShareDB
	// contains filtered or unexported fields
}

func NewDB

func NewDB(ctx context.Context, dbConfig config.DB) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) ExecuteSQLMigration

func (db *DB) ExecuteSQLMigration(migrationsFolder string) error

func (*DB) Transaction

func (db *DB) Transaction(fn func(db *DB) error) error

type MigrateL1Shares

type MigrateL1Shares struct {
	GUID              uuid.UUID      `gorm:"primaryKey;DEFAULT replace(uuid_generate_v4()::text,'-','')" json:"guid"`
	UnstakerAddress   common.Address `gorm:"column:unstaker_address;serializer:bytes" db:"unstaker_address" json:"unstaker_address" form:"unstaker_address"`
	StrategyAddress   common.Address `gorm:"column:strategy_address;serializer:bytes" db:"strategy_address" json:"strategy_address" form:"strategy_address"`
	SharesAmount      *big.Int       `gorm:"serializer:u256;column:shares_amount" db:"shares_amount" json:"shares_amount" form:"shares_amount"`
	L1UnstakeMsgNonce *big.Int       `` /* 132-byte string literal not displayed */
	ChainId           *big.Int       `gorm:"serializer:u256;column:chain_id" db:"chain_id" json:"chain_id" form:"chain_id"`
	MTxHash           common.Hash    `gorm:"column:m_tx_hash;serializer:bytes" db:"m_tx_hash" json:"m_tx_hash" form:"m_tx_hash"`
	QTxHash           common.Hash    `gorm:"column:q_tx_hash;serializer:bytes" db:"q_tx_hash" json:"q_tx_hash" form:"q_tx_hash"`
	SourceHash        common.Hash    `gorm:"column:source_hash;serializer:bytes" db:"source_hash" json:"source_hash" form:"source_hash"`
	Status            int8           `gorm:"column:status" db:"status" json:"status" form:"status"`
	Timestamp         int64          `gorm:"column:timestamp" db:"timestamp" json:"timestamp" form:"timestamp"`
}

func (MigrateL1Shares) TableName

func (MigrateL1Shares) TableName() string

type MigrateL1SharesDB

type MigrateL1SharesDB interface {
	MigrateL1SharesView
	StoreMigrateL1Shares([]MigrateL1Shares) error
	BuildMigrateL1Shares(in *pb.MigrateL1SharesRequest, sourceHash common.Hash) MigrateL1Shares
	MigrateL1SharesBySourceHash(SourceHash string) (*MigrateL1Shares, error)
	ChangeMigrateL1SharesSentStatusByTxHash(txHash string) error
	ChangeQueueWithdrawalsSentStatusByTxHash(txHash string) error
	UpdateMigrateL1SharesTransactionHash(MigrateL1Shares) error
	UpdateQueueWithdrawalsTransactionHash(update MigrateL1Shares) error
}

func NewMigrateL1SharesDB

func NewMigrateL1SharesDB(db *gorm.DB) MigrateL1SharesDB

type MigrateL1SharesView

type MigrateL1SharesView interface {
	MigrateL1SharesByTxHash(txHash string) (*MigrateL1Shares, error)
	OldestMPendingSentTransaction() (*MigrateL1Shares, error)
	OldestQPendingSentTransaction() (*MigrateL1Shares, error)
	OldestPendingNoSentTransaction() (*MigrateL1Shares, error)
}

type TransferL2Share

type TransferL2Share struct {
	GUID              uuid.UUID      `gorm:"primaryKey;DEFAULT replace(uuid_generate_v4()::text,'-','')" json:"guid"`
	StrategyAddress   common.Address `gorm:"column:strategy_address;serializer:bytes" db:"strategy_address" json:"strategy_address" form:"strategy_address"`
	SharesAmount      *big.Int       `gorm:"serializer:u256;column:shares_amount" db:"shares_amount" json:"shares_amount" form:"shares_amount"`
	ChainID           *big.Int       `gorm:"serializer:u256;column:chain_id" db:"chain_id" json:"chain_id" form:"chain_id"`
	FromAddress       common.Address `gorm:"column:from_address;serializer:bytes" db:"from_address" json:"from_address" form:"from_address"`
	ToAddress         common.Address `gorm:"column:to_address;serializer:bytes" db:"to_address" json:"to_address" form:"to_address"`
	StakeMessageNonce *big.Int       `` /* 128-byte string literal not displayed */
	TxHash            common.Hash    `gorm:"column:tx_hash;serializer:bytes" db:"tx_hash" json:"tx_hash" form:"tx_hash"`
	Status            int8           `gorm:"column:status" db:"status" json:"status" form:"status"`
	Timestamp         int64          `gorm:"column:timestamp" db:"timestamp" json:"timestamp" form:"timestamp"`
}

func (TransferL2Share) TableName

func (TransferL2Share) TableName() string

type TransferL2ShareDB

type TransferL2ShareDB interface {
	TransferL2ShareView
	StoreTransferL2Share([]TransferL2Share) error
	BuildTransferL2Share(in *pb.TransferL2ShareRequest) []TransferL2Share
	ChangeTransferL2ShareSentStatusByTxHash(txHash string) error
	UpdateTransferL2ShareTransactionHash(TransferL2Share) error
	UpdateTransferL2ShareFailStatus(TransferL2Share) error
}

func NewTransferL2ShareDB

func NewTransferL2ShareDB(db *gorm.DB) TransferL2ShareDB

type TransferL2ShareView

type TransferL2ShareView interface {
	TransferL2ShareByNonce(nonce uint64) (*TransferL2Share, error)
	TransferL2ShareByTxHash(txHash string) (*TransferL2Share, error)
	OldestPendingSentTransaction() (*TransferL2Share, error)
	OldestPendingNoSentTransaction() (*TransferL2Share, error)
}

type TransferToL2Bridge

type TransferToL2Bridge struct {
	GUID            uuid.UUID      `gorm:"primaryKey;DEFAULT replace(uuid_generate_v4()::text,'-','')" json:"guid"`
	Batch           *big.Int       `gorm:"serializer:u256;column:batch" db:"batch" json:"batch" form:"batch"`
	ChainId         *big.Int       `gorm:"serializer:u256;column:chain_id" db:"chain_id" json:"chain_id" form:"chain_id"`
	StrategyAddress common.Address `gorm:"column:strategy_address;serializer:bytes" db:"strategy_address" json:"strategy_address" form:"strategy_address"`
	TxHash          common.Hash    `gorm:"column:tx_hash;serializer:bytes" db:"tx_hash" json:"tx_hash" form:"tx_hash"`
	Status          int8           `gorm:"column:status" db:"status" json:"status" form:"status"`
	Timestamp       int64          `gorm:"column:timestamp" db:"timestamp" json:"timestamp" form:"timestamp"`
}

func (TransferToL2Bridge) TableName

func (TransferToL2Bridge) TableName() string

type TransferToL2BridgeDB

type TransferToL2BridgeDB interface {
	TransferToL2BridgeView
	StoreTransferToL2Bridge([]TransferToL2Bridge) error
	BuildTransferToL2Bridge(in *pb.TransferToL2DappLinkBridgeRequest) TransferToL2Bridge
	ChangeTransferToL2BridgeSentStatusByTxHash(txHash string) error
	UpdateTransferToL2BridgeTransactionHash(TransferToL2Bridge) error
}

func NewTransferToL2BridgeDB

func NewTransferToL2BridgeDB(db *gorm.DB) TransferToL2BridgeDB

type TransferToL2BridgeView

type TransferToL2BridgeView interface {
	TransferToL2BridgeByBatch(batch uint64) (*TransferToL2Bridge, error)
	TransferToL2BridgeByTxHash(txHash string) (*TransferToL2Bridge, error)
	OldestPendingSentTransaction() (*TransferToL2Bridge, error)
	OldestPendingNoSentTransaction() (*TransferToL2Bridge, error)
}

type UnstakeBatch

type UnstakeBatch struct {
	GUID            uuid.UUID      `gorm:"primaryKey;DEFAULT replace(uuid_generate_v4()::text,'-','')" json:"guid"`
	StrategyAddress common.Address `gorm:"column:strategy_address;serializer:bytes" db:"strategy_address" json:"strategy_address" form:"strategy_address"`
	MsgNonce        *big.Int       `gorm:"serializer:u256;column:msg_nonce" db:"msg_nonce" json:"msg_nonce" form:"msg_nonce"`
	SourceChainId   *big.Int       `gorm:"serializer:u256;column:source_chain_id" db:"source_chain_id" json:"source_chain_id" form:"source_chain_id"`
	DestChainId     *big.Int       `gorm:"serializer:u256;column:dest_chain_id" db:"dest_chain_id" json:"dest_chain_id" form:"dest_chain_id"`
	TxHash          common.Hash    `gorm:"column:tx_hash;serializer:bytes" db:"tx_hash" json:"tx_hash" form:"tx_hash"`
	GasLimit        *big.Int       `gorm:"serializer:u256;column:gas_limit" db:"gas_limit" json:"gas_limit" form:"gas_limit"`
	SourceHash      common.Hash    `gorm:"column:source_hash;serializer:bytes" db:"source_hash" json:"source_hash" form:"source_hash"`
	Status          int8           `gorm:"column:status" db:"status" json:"status" form:"status"`
	Timestamp       int64          `gorm:"column:timestamp" db:"timestamp" json:"timestamp" form:"timestamp"`
}

func (UnstakeBatch) TableName

func (UnstakeBatch) TableName() string

type UnstakeBatchDB

type UnstakeBatchDB interface {
	UnstakeBatchView
	StoreUnstakeBatch([]UnstakeBatch) error
	BuildUnstakeBatch(in *pb.UnstakeBatchRequest, sourceHash common.Hash) []UnstakeBatch
	ChangeUnstakeBatchSentStatusByTxHash(txHash string) error
	UpdateUnstakeBatchTransactionHash(UnstakeBatch) error
}

func NewUnstakeBatchDB

func NewUnstakeBatchDB(db *gorm.DB) UnstakeBatchDB

type UnstakeBatchView

type UnstakeBatchView interface {
	UnstakeBatchByTxHash(txHash string) (*UnstakeBatch, error)
	UnstakeBatchBySourceHash(sourceHash string) (*UnstakeBatch, error)
	UnstakeBatchsBySourceHash(sourceHash string) ([]UnstakeBatch, error)
	OldestPendingSentTransaction() (*UnstakeBatch, error)
	OldestPendingNoSentTransaction() (*UnstakeBatch, error)
}

type UpdateDepositFundingPoolBalance

type UpdateDepositFundingPoolBalance struct {
	GUID           uuid.UUID      `gorm:"primaryKey;DEFAULT replace(uuid_generate_v4()::text,'-','')" json:"guid"`
	SourceChainId  *big.Int       `gorm:"serializer:u256;column:source_chain_id" db:"source_chain_id" json:"source_chain_id" form:"source_chain_id"`
	DestChainId    *big.Int       `gorm:"serializer:u256;column:dest_chain_id" db:"dest_chain_id" json:"dest_chain_id" form:"dest_chain_id"`
	SourceHash     common.Hash    `gorm:"column:source_hash;serializer:bytes" db:"source_hash" json:"source_hash" form:"source_hash"`
	TxHash         common.Hash    `gorm:"column:tx_hash;serializer:bytes" db:"tx_hash" json:"tx_hash" form:"tx_hash"`
	ReceiveAddress common.Address `gorm:"column:receive_address;serializer:bytes" db:"receive_address" json:"receive_address" form:"receive_address"`
	TokenAddress   common.Address `gorm:"column:token_address;serializer:bytes" db:"token_address" json:"token_address" form:"token_address"`
	Amount         *big.Int       `gorm:"serializer:u256;column:amount" db:"amount" json:"amount" form:"amount"`
	Status         int8           `gorm:"column:status" db:"status" json:"status" form:"status"`
	Timestamp      int64          `gorm:"column:timestamp" db:"timestamp" json:"timestamp" form:"timestamp"`
}

func (UpdateDepositFundingPoolBalance) TableName

type UpdateDepositFundingPoolBalanceDB

type UpdateDepositFundingPoolBalanceDB interface {
	UpdateDepositFundingPoolBalanceView
	StoreBatchUpdateFundingPoolBalance([]UpdateDepositFundingPoolBalance) error
	BuildUpdateFundingPoolBalance(in *pb.UpdateDepositFundingPoolBalanceRequest, sourceHash common.Hash) UpdateDepositFundingPoolBalance
	UpdateFundingPoolBalanceBySourceHash(sourceHash string) (*UpdateDepositFundingPoolBalance, error)
	ChangeUpdateFundingPoolBalanceSentStatusByTxHash(txHash string) error
	UpdateFundingPoolBalanceTransactionHash(UpdateDepositFundingPoolBalance) error
}

func NewDepositUpdateFundingPoolBalanceDB

func NewDepositUpdateFundingPoolBalanceDB(db *gorm.DB) UpdateDepositFundingPoolBalanceDB

type UpdateDepositFundingPoolBalanceView

type UpdateDepositFundingPoolBalanceView interface {
	UpdateFundingPoolBalanceByTxHash(txHash string) (*UpdateDepositFundingPoolBalance, error)
	OldestPendingSentTransaction() (*UpdateDepositFundingPoolBalance, error)
	OldestPendingNoSentTransaction() (*UpdateDepositFundingPoolBalance, error)
}

type UpdateWithdrawFundingPoolBalance

type UpdateWithdrawFundingPoolBalance struct {
	GUID           uuid.UUID      `gorm:"primaryKey;DEFAULT replace(uuid_generate_v4()::text,'-','')" json:"guid"`
	SourceChainId  *big.Int       `gorm:"serializer:u256;column:source_chain_id" db:"source_chain_id" json:"source_chain_id" form:"source_chain_id"`
	DestChainId    *big.Int       `gorm:"serializer:u256;column:dest_chain_id" db:"dest_chain_id" json:"dest_chain_id" form:"dest_chain_id"`
	SourceHash     common.Hash    `gorm:"column:source_hash;serializer:bytes" db:"source_hash" json:"source_hash" form:"source_hash"`
	TxHash         common.Hash    `gorm:"column:tx_hash;serializer:bytes" db:"tx_hash" json:"tx_hash" form:"tx_hash"`
	ReceiveAddress common.Address `gorm:"column:receive_address;serializer:bytes" db:"receive_address" json:"receive_address" form:"receive_address"`
	TokenAddress   common.Address `gorm:"column:token_address;serializer:bytes" db:"token_address" json:"token_address" form:"token_address"`
	Amount         *big.Int       `gorm:"serializer:u256;column:amount" db:"amount" json:"amount" form:"amount"`
	Status         int8           `gorm:"column:status" db:"status" json:"status" form:"status"`
	Timestamp      int64          `gorm:"column:timestamp" db:"timestamp" json:"timestamp" form:"timestamp"`
}

func (UpdateWithdrawFundingPoolBalance) TableName

type UpdateWithdrawFundingPoolBalanceDB

type UpdateWithdrawFundingPoolBalanceDB interface {
	UpdateWithdrawFundingPoolBalanceView
	StoreBatchUpdateFundingPoolBalance([]UpdateWithdrawFundingPoolBalance) error
	BuildUpdateFundingPoolBalance(in *pb.UpdateWithdrawFundingPoolBalanceRequest, sourceHash common.Hash) UpdateWithdrawFundingPoolBalance
	UpdateFundingPoolBalanceBySourceHash(sourceHash string) (*UpdateWithdrawFundingPoolBalance, error)
	ChangeUpdateFundingPoolBalanceSentStatusByTxHash(txHash string) error
	UpdateFundingPoolBalanceTransactionHash(UpdateWithdrawFundingPoolBalance) error
}

func NewWithdrawUpdateFundingPoolBalanceDB

func NewWithdrawUpdateFundingPoolBalanceDB(db *gorm.DB) UpdateWithdrawFundingPoolBalanceDB

type UpdateWithdrawFundingPoolBalanceView

type UpdateWithdrawFundingPoolBalanceView interface {
	UpdateFundingPoolBalanceByTxHash(txHash string) (*UpdateWithdrawFundingPoolBalance, error)
	OldestPendingSentTransaction() (*UpdateWithdrawFundingPoolBalance, error)
	OldestPendingNoSentTransaction() (*UpdateWithdrawFundingPoolBalance, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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