account

package
v1.10.21-0...-6d4d443 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountInfoNotFound = errors.New("account info not found")
	ErrAccountInfoExists   = errors.New("account info already exists")
	ErrInvalidAccountInfo  = errors.New("invalid account info")
)

Functions

This section is empty.

Types

type Record

type Record struct {
	Id uint64

	OwnerAccount     string
	AuthorityAccount string
	TokenAccount     string
	MintAccount      string

	AccountType commonpb.AccountType
	Index       uint64

	RequiresDepositSync  bool
	DepositsLastSyncedAt time.Time

	RequiresAutoReturnCheck bool

	RequiresSwapRetry bool
	LastSwapRetryAt   time.Time

	CreatedAt time.Time
}

func (*Record) Clone

func (r *Record) Clone() Record

func (*Record) CopyTo

func (r *Record) CopyTo(dst *Record)

func (*Record) IsTimelock added in v1.3.0

func (r *Record) IsTimelock() bool

func (*Record) Validate

func (r *Record) Validate() error

type Store

type Store interface {
	// Put creates a new account info object
	Put(ctx context.Context, record *Record) error

	// Update updates an account info object
	Update(ctx context.Context, record *Record) error

	// GetByTokenAddress finds the record for a given token account address
	GetByTokenAddress(ctx context.Context, address string) (*Record, error)

	// GetByTokenAddressBatch is like GetByTokenAddress, but for multiple accounts.
	// If any one account is missing, ErrAccountInfoNotFound is returned.
	GetByTokenAddressBatch(ctx context.Context, addresses ...string) (map[string]*Record, error)

	// GetByAuthorityAddress finds the record for a given authority account address
	// keyed by mint
	GetByAuthorityAddress(ctx context.Context, address string) (map[string]*Record, error)

	// GetLatestByOwnerAddress gets the latest accounts for an owner keyed by mint
	// and type
	//
	// For account types where only 1 account can exist, the record with the latest index is returned.
	// For account types where more than 1 account can exist, all records are returend.
	GetLatestByOwnerAddress(ctx context.Context, address string) (map[string]map[commonpb.AccountType][]*Record, error)

	// GetLatestByOwnerAddressAndType gets the latest account for an owner and account type
	// keyed by mint
	//
	// Regardless if more than 1 account for the given type can exist, only the record with
	// the largest index is returned
	GetLatestByOwnerAddressAndType(ctx context.Context, address string, accountType commonpb.AccountType) (map[string]*Record, error)

	// GetPrioritizedRequiringDepositSync gets a set of account info objects where
	// RequiresDepositSync is true that's prioritized by DepositsLastSyncedAt
	GetPrioritizedRequiringDepositSync(ctx context.Context, limit uint64) ([]*Record, error)

	// CountRequiringDepositSync counts the number of account info objects where
	// RequiresDepositSync is true
	CountRequiringDepositSync(ctx context.Context) (uint64, error)

	// GetPrioritizedRequiringAutoReturnCheck gets a set of account info objects where
	// RequiresAutoReturnCheck is true and older than minAge that's prioritized by CreatedAt
	GetPrioritizedRequiringAutoReturnCheck(ctx context.Context, minAge time.Duration, limit uint64) ([]*Record, error)

	// CountRequiringAutoReturnCheck counts the number of account info objects where
	// RequiresAutoReturnCheck is true
	CountRequiringAutoReturnCheck(ctx context.Context) (uint64, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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