types

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MonitoredTxStatusCreated mean the tx was just added to the storage
	MonitoredTxStatusCreated = MonitoredTxStatus("created")

	// MonitoredTxStatusSent means that at least a eth tx was sent to the network
	MonitoredTxStatusSent = MonitoredTxStatus("sent")

	// MonitoredTxStatusFailed means the tx was already mined and failed with an
	// error that can't be recovered automatically, ex: the data in the tx is invalid
	// and the tx gets reverted
	MonitoredTxStatusFailed = MonitoredTxStatus("failed")

	// MonitoredTxStatusConfirmed means the tx was already mined and the receipt
	// status is Successful
	MonitoredTxStatusConfirmed = MonitoredTxStatus("confirmed")

	// MonitoredTxStatusReorged is used when a monitored tx was already confirmed but
	// the L1 block where this tx was confirmed has been reorged, in this situation
	// the caller needs to review this information and wait until it gets confirmed
	// again in a future block
	MonitoredTxStatusReorged = MonitoredTxStatus("reorged")

	// MonitoredTxStatusDone means the tx was set by the owner as done
	MonitoredTxStatusDone = MonitoredTxStatus("done")
)

Variables

View Source
var (
	// ErrNotFound when the object is not found
	ErrNotFound = errors.New("not found")
	// ErrAlreadyExists when the object already exists
	ErrAlreadyExists = errors.New("already exists")

	// ErrExecutionReverted returned when trying to get the revert message
	// but the call fails without revealing the revert reason
	ErrExecutionReverted = errors.New("execution reverted")
)

Functions

This section is empty.

Types

type EthermanInterface

type EthermanInterface interface {
	GetTx(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error)
	GetTxReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
	WaitTxToBeMined(ctx context.Context, tx *types.Transaction, timeout time.Duration) (bool, error)
	SendTx(ctx context.Context, tx *types.Transaction) error
	PendingNonce(ctx context.Context, account common.Address) (uint64, error)
	SuggestedGasPrice(ctx context.Context) (*big.Int, error)
	EstimateGas(ctx context.Context, from common.Address, to *common.Address, value *big.Int, data []byte) (uint64, error)
	CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error)
	SignTx(ctx context.Context, sender common.Address, tx *types.Transaction) (*types.Transaction, error)
	GetRevertMessage(ctx context.Context, tx *types.Transaction) (string, error)
}

type MonitoredTx

type MonitoredTx struct {
	// Owner is the common identifier among all the monitored tx to identify who
	// created this, it's a identification provided by the caller in order to be
	// used in the future to query the monitored tx by the Owner, this allows the
	// caller to be free of implementing a persistence layer to monitor the txs
	Owner string

	// ID is the tx identifier controller by the caller
	ID string

	// sender of the tx, used to identify which private key should be used to sing the tx
	From common.Address

	// receiver of the tx
	To *common.Address

	// Nonce used to create the tx
	Nonce uint64

	// tx Value
	Value *big.Int

	// tx Data
	Data []byte

	// tx Gas
	Gas uint64

	// tx gas offset
	GasOffset uint64

	// tx gas price
	GasPrice *big.Int

	// Status of this monitoring
	Status MonitoredTxStatus

	// BlockNumber represents the block where the tx was identified
	// to be mined, it's the same as the block number found in the
	// tx receipt, this is used to control reorged monitored txs
	BlockNumber *big.Int

	// History represent all transaction hashes from
	// transactions created using this struct data and
	// sent to the network
	History map[common.Hash]bool

	// CreatedAt date time it was created
	CreatedAt time.Time

	// UpdatedAt last date time it was updated
	UpdatedAt time.Time

	// NumRetries number of times tx was sent to the network
	NumRetries uint64
}

MonitoredTx represents a set of information used to build tx plus information to monitor if the transactions was sent successfully

func (*MonitoredTx) AddHistory

func (mTx *MonitoredTx) AddHistory(tx *types.Transaction) error

AddHistory adds a transaction to the monitoring history

func (*MonitoredTx) BlockNumberU64Ptr

func (mTx *MonitoredTx) BlockNumberU64Ptr() *uint64

BlockNumberU64Ptr returns the current blockNumber as a uint64 pointer

func (*MonitoredTx) DataStringPtr

func (mTx *MonitoredTx) DataStringPtr() *string

DataStringPtr returns the current data field as a string pointer

func (*MonitoredTx) HistoryHashSlice

func (mTx *MonitoredTx) HistoryHashSlice() []common.Hash

HistoryHashSlice returns the current history field as a string slice

func (*MonitoredTx) HistoryStringSlice

func (mTx *MonitoredTx) HistoryStringSlice() []string

HistoryStringSlice returns the current history field as a string slice

func (*MonitoredTx) ToStringPtr

func (mTx *MonitoredTx) ToStringPtr() *string

ToStringPtr returns the current to field as a string pointer

func (MonitoredTx) Tx

func (mTx MonitoredTx) Tx() *types.Transaction

Tx uses the current information to build a tx

func (*MonitoredTx) ValueU64Ptr

func (mTx *MonitoredTx) ValueU64Ptr() *uint64

ValueU64Ptr returns the current value field as a uint64 pointer

type MonitoredTxResult

type MonitoredTxResult struct {
	ID     string
	Status MonitoredTxStatus
	Txs    map[common.Hash]TxResult
}

MonitoredTxResult represents the result of a execution of a monitored tx

type MonitoredTxStatus

type MonitoredTxStatus string

MonitoredTxStatus represents the status of a monitored tx

func (MonitoredTxStatus) String

func (s MonitoredTxStatus) String() string

String returns a string representation of the status

type StateInterface

type StateInterface interface {
	GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*state.Block, error)
}

type StorageInterface

type StorageInterface interface {
	Add(ctx context.Context, mTx MonitoredTx, dbTx pgx.Tx) error
	Get(ctx context.Context, owner, id string, dbTx pgx.Tx) (MonitoredTx, error)
	GetByStatus(ctx context.Context, owner *string, statuses []MonitoredTxStatus, dbTx pgx.Tx) ([]MonitoredTx, error)
	GetBySenderAndStatus(ctx context.Context, sender common.Address, statuses []MonitoredTxStatus, dbTx pgx.Tx) ([]MonitoredTx, error)
	Update(ctx context.Context, mTx MonitoredTx, dbTx pgx.Tx) error
}

type TxResult

type TxResult struct {
	Tx            *types.Transaction
	Receipt       *types.Receipt
	RevertMessage string
}

TxResult represents the result of a execution of a ethereum transaction in the block chain

Jump to

Keyboard shortcuts

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