orm

package
v0.0.0-...-2740610 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CrossMessage

type CrossMessage struct {
	ID                 uint64     `json:"id" gorm:"column:id;primary_key;autoIncrement"` // primary key in the database
	MessageType        int        `json:"message_type" gorm:"column:message_type"`       //0:MessageTypeUnknown, 1: MessageTypeL1SentMessage, 2: MessageTypeL2SentMessage
	TxStatus           int        `json:"tx_status" gorm:"column:tx_status"`
	TokenType          int        `json:"token_type" gorm:"column:token_type"` // 0: ETH, 1: ERC20, 2: ERC721, 3: ERC1155, 4: RED
	TxType             int        `json:"tx_type" gorm:"column:tx_type"`       // 0: Unknown, 1: Deposit, 2: Withdraw, 3: Refund
	Sender             string     `json:"sender" gorm:"column:sender"`         // sender address
	Receiver           string     `json:"receiver" gorm:"column:receiver"`
	L1TxHash           string     `json:"l1_tx_hash" gorm:"column:l1_tx_hash"` // initial tx hash, if MessageType is MessageTypeL1SentMessage.
	L2TxHash           string     `json:"l2_tx_hash" gorm:"column:l2_tx_hash"` // initial tx hash, if MessageType is MessageTypeL2SentMessage.
	L1BlockNumber      uint64     `json:"l1_block_number" gorm:"column:l1_block_number"`
	L2BlockNumber      uint64     `json:"l2_block_number" gorm:"column:l2_block_number"`
	L1TokenAddress     string     `json:"l1_token_address" gorm:"column:l1_token_address"`
	L2TokenAddress     string     `json:"l2_token_address" gorm:"column:l2_token_address"`
	TokenIDs           string     `json:"token_ids" gorm:"column:token_ids"`
	TokenAmounts       string     `json:"token_amounts" gorm:"column:token_amounts"`
	BlockTimestamp     uint64     `json:"block_timestamp" gorm:"column:block_timestamp"`
	MessageHash        string     `json:"message_hash" gorm:"column:message_hash;type:varchar(256);uniqueIndex"` // unique message hash
	MessagePayloadType int        `json:"message_payloadtype" gorm:"column:message_payloadtype"`
	MessagePayload     string     `json:"message_payload" gorm:"column:message_payload"`
	MessageFrom        string     `json:"message_from" gorm:"column:message_from;index"`
	MessageTo          string     `json:"message_to" gorm:"column:message_to"`
	MessageValue       string     `json:"message_value" gorm:"column:message_value"`
	MessageNonce       string     `json:"message_nonce" gorm:"column:message_nonce"`
	MultiSignProof     string     `json:"multisign_proof" gorm:"column:multisign_proof"`
	RefundTxHash       string     `json:"refund_address" gorm:"column:refund_tx_hash"`
	CreatedAt          time.Time  `json:"created_at" gorm:"column:created_at"`
	UpdatedAt          time.Time  `json:"updated_at" gorm:"column:updated_at"`
	DeletedAt          *time.Time `json:"deleted_at" gorm:"column:deleted_at"`
	Remark             string     `json:"remark" gorm:"column:remark"`
	RetryCount         int        `json:"retry_count" gorm:"column:retry_count"`
	// contains filtered or unexported fields
}

CrossMessage represents a cross message.

func NewCrossMessage

func NewCrossMessage(db *gorm.DB) *CrossMessage

NewCrossMessage returns a new instance of CrossMessage.

func (*CrossMessage) GetL2UnclaimedWithdrawalsByAddress

func (c *CrossMessage) GetL2UnclaimedWithdrawalsByAddress(ctx context.Context, sender string, page, pageSize uint64) ([]*CrossMessage, uint64, error)

GetL2UnclaimedWithdrawalsByAddress retrieves all L2 unclaimed withdrawal messages for a given sender address with pagination.

func (*CrossMessage) GetTxsByAddress

func (c *CrossMessage) GetTxsByAddress(ctx context.Context, sender string, page, pageSize uint64) ([]*CrossMessage, uint64, error)

GetTxsByAddress retrieves all txs for a given sender address.

func (*CrossMessage) InsertOrUpdateL2Messages

func (c *CrossMessage) InsertOrUpdateL2Messages(ctx context.Context, messages []*CrossMessage) error

InsertOrUpdateL2Messages inserts or updates a list of L2 cross messages into the database.

func (*CrossMessage) QueryL1UnConsumedMessages

func (c *CrossMessage) QueryL1UnConsumedMessages(ctx context.Context, tx_type btypes.TxType) ([]*CrossMessage, error)

func (*CrossMessage) QueryL2UnConsumedMessages

func (c *CrossMessage) QueryL2UnConsumedMessages(ctx context.Context, tx_type btypes.TxType) ([]*CrossMessage, error)

func (*CrossMessage) QueryUnConsumedMessages

func (c *CrossMessage) QueryUnConsumedMessages(ctx context.Context, tx_type btypes.TxType) ([]*CrossMessage, error)

func (*CrossMessage) TableName

func (*CrossMessage) TableName() string

TableName returns the table name for the CrossMessage model.

func (*CrossMessage) UpdateL1Message

func (c *CrossMessage) UpdateL1Message(ctx context.Context, message_hash string, txStatus int, l2BlockNumber uint64) error

func (*CrossMessage) UpdateL2Message

func (c *CrossMessage) UpdateL2Message(ctx context.Context, l1RelayedMessages []*CrossMessage) error

Jump to

Keyboard shortcuts

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