payer

package
v0.0.0-...-b4d4280 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package payer defines the interfaces for actual payment transactions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auditor

type Auditor interface {

	// CheckTransactionState checks the transaction state of any transaction.
	CheckTransactionState(ctx context.Context, hash string) (pipelinedb.TxState, error)

	// CheckConfirmedTransactionState checks the state from the confirmation receipt.
	CheckConfirmedTransactionState(ctx context.Context, hash string) (pipelinedb.TxState, error)
}

Auditor helps to validate transaction created by the appropriate payer.

type Payer

type Payer interface {
	// Strings returns a string describing the payer type.
	String() string

	// NextNonce queries chain for the next available nonce value.
	NextNonce(ctx context.Context) (uint64, error)

	// CheckPreconditions checks if transaction can be initiated. If unmet preconditions are returned then pipeline will try again after a short sleep.
	CheckPreconditions(ctx context.Context) (unmet []string, err error)

	// GetTokenBalance returns with the available token balance in real value (with decimals).
	GetTokenBalance(ctx context.Context) (*big.Int, error)

	// GetTokenDecimals returns with the decimal precision of the token.
	GetTokenDecimals(ctx context.Context) (int32, error)

	// CreateRawTransaction creates the chain transaction which will be persisted to the db.
	CreateRawTransaction(ctx context.Context, log *zap.Logger, payouts []*pipelinedb.Payout, nonce uint64, storjPrice decimal.Decimal) (tx Transaction, from common.Address, err error)

	// SendTransaction submits the transaction created earlier.
	SendTransaction(ctx context.Context, log *zap.Logger, tx Transaction) error

	// CheckNonceGroup returns with the status of the submitted transactions.
	CheckNonceGroup(ctx context.Context, log *zap.Logger, nonceGroup *pipelinedb.NonceGroup, checkOnly bool) (pipelinedb.TxState, []*pipelinedb.TxStatus, error)

	// PrintEstimate prints out additional information about the planned actions.
	PrintEstimate(ctx context.Context, remaining int64) error
}

Payer is responsible for the final payment transfer.

type SimAuditor

type SimAuditor struct {
}

func NewSimAuditor

func NewSimAuditor() SimAuditor

NewSimAuditor creates a simulated auditor.

func (SimAuditor) CheckConfirmedTransactionState

func (s SimAuditor) CheckConfirmedTransactionState(ctx context.Context, hash string) (pipelinedb.TxState, error)

func (SimAuditor) CheckTransactionState

func (s SimAuditor) CheckTransactionState(ctx context.Context, hash string) (pipelinedb.TxState, error)

type SimPayer

type SimPayer struct {
	// contains filtered or unexported fields
}

func NewSimPayer

func NewSimPayer() (*SimPayer, error)

func (*SimPayer) CheckConfirmedTransactionState

func (s *SimPayer) CheckConfirmedTransactionState(ctx context.Context, hash string) (pipelinedb.TxState, error)

func (*SimPayer) CheckNonceGroup

func (s *SimPayer) CheckNonceGroup(ctx context.Context, log *zap.Logger, nonceGroup *pipelinedb.NonceGroup, checkOnly bool) (pipelinedb.TxState, []*pipelinedb.TxStatus, error)

func (*SimPayer) CheckPreconditions

func (s *SimPayer) CheckPreconditions(ctx context.Context) ([]string, error)

func (*SimPayer) CheckTransactionState

func (s *SimPayer) CheckTransactionState(ctx context.Context, hash string) (pipelinedb.TxState, error)

func (*SimPayer) CreateRawTransaction

func (s *SimPayer) CreateRawTransaction(ctx context.Context, log *zap.Logger, payouts []*pipelinedb.Payout, nonce uint64, storjPrice decimal.Decimal) (tx Transaction, from common.Address, err error)

func (*SimPayer) GetTokenBalance

func (s *SimPayer) GetTokenBalance(ctx context.Context) (*big.Int, error)

func (*SimPayer) GetTokenDecimals

func (s *SimPayer) GetTokenDecimals(ctx context.Context) (int32, error)

func (*SimPayer) NextNonce

func (s *SimPayer) NextNonce(ctx context.Context) (uint64, error)

func (*SimPayer) PrintEstimate

func (s *SimPayer) PrintEstimate(ctx context.Context, remaining int64) error

func (*SimPayer) SendTransaction

func (s *SimPayer) SendTransaction(ctx context.Context, log *zap.Logger, tx Transaction) error

func (*SimPayer) String

func (s *SimPayer) String() string

type Transaction

type Transaction struct {
	// Hash is the generic (unique) identifier of the transaction.
	Hash string

	// Nonce is the nonce from the group.
	Nonce uint64

	// Raw is the internal representation of transaction data.
	Raw any
}

Transaction is a generic representation of a payment.

type Type

type Type string

Type represents the payment method.

const (
	Eth       Type = "eth"
	Sim       Type = "sim"
	ZkSyncEra Type = "zksync-era"
	Polygon   Type = "polygon"
)

func TypeFromString

func TypeFromString(t string) (Type, error)

TypeFromString parses string to a Type const.

func (Type) String

func (pt Type) String() string

Jump to

Keyboard shortcuts

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