transaction

package
v1.10.7 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("no records could be found")
	ErrExists   = errors.New("the transaction already exists")
)

Functions

This section is empty.

Types

type Confirmation

type Confirmation uint
const (
	ConfirmationUnknown Confirmation = iota
	ConfirmationPending
	ConfirmationConfirmed
	ConfirmationFinalized
	ConfirmationFailed
)

type Record

type Record struct {
	Id        uint64
	Signature string

	Slot      uint64
	BlockTime time.Time
	Data      []byte

	TokenBalances []*TokenBalance // The set of pre/post token balances for this transaction
	HasErrors     bool            // Blockchain lookup required to find errors
	Fee           *uint64

	ConfirmationState Confirmation
	Confirmations     uint64
	CreatedAt         time.Time
}

An atomic transaction that contains a set of digital signatures of a serialized [`Message`], signed by the first `signatures.len()` keys of [`account_keys`].

https://docs.solana.com/developing/clients/jsonrpc-api#token-balances-structure

func FromBlockTransaction

func FromBlockTransaction(tx *solana.BlockTransaction, slot uint64, t time.Time) (*Record, error)

func FromConfirmedTransaction

func FromConfirmedTransaction(tx *solana.ConfirmedTransaction) (*Record, error)

func FromLocalSimulation

func FromLocalSimulation(tx *solana.Transaction, pre, post map[string]uint64) (*Record, error)

func FromTransaction

func FromTransaction(tx *solana.Transaction) (*Record, error)

func (*Record) GetTokenBalanceChanges

func (r *Record) GetTokenBalanceChanges(account string) (*TokenBalance, error)

func (*Record) String

func (r *Record) String() string

func (*Record) Unmarshal

func (r *Record) Unmarshal() (*solana.Transaction, error)

type Store

type Store interface {
	// Get returns a transaction record for the given signature.
	//
	// ErrNotFound is returned if no record is found.
	Get(ctx context.Context, txId string) (*Record, error)

	// Put saves transaction data to the store.
	//
	// ErrExists is returned if a transaction with the same signature already exists.
	Put(ctx context.Context, transaction *Record) error

	// GetAllByAddress returns a list of records that match a given address.
	//
	// ErrNotFound is returned if no records are found.
	GetAllByAddress(ctx context.Context, address string, cursor uint64, limit uint, ordering query.Ordering) ([]*Record, error)

	// GetLatestByState returns the latest record for a given state.
	//
	// ErrNotFound is returned if no records are found.
	GetLatestByState(ctx context.Context, address string, state Confirmation) (*Record, error)

	// GetFirstPending returns the latest record for a given state.
	//
	// ErrNotFound is returned if no records are found.
	GetFirstPending(ctx context.Context, address string) (*Record, error)

	// GetSignaturesByState returns a list of signatures that match given a confirmation state.
	//
	// ErrNotFound is returned if no records are found.
	GetSignaturesByState(ctx context.Context, filter Confirmation, limit uint, ordering query.Ordering) ([]string, error)
}

type TokenBalance

type TokenBalance struct {
	//	Id            uint64
	//	TransactionId string
	Account     string
	PreBalance  uint64
	PostBalance uint64
}

Token balance changes as a result of a transaction

Docs: https://docs.solana.com/developing/clients/jsonrpc-api#token-balances-structure Source: https://github.com/solana-labs/solana/blob/master/transaction-status/src/token_balances.rs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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