timelock

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimelockNotFound   = errors.New("no records could be found")
	ErrInvalidTimelock    = errors.New("invalid timelock")
	ErrStaleTimelockState = errors.New("timelock state is stale")
)

Functions

This section is empty.

Types

type Record

type Record struct {
	Id uint64

	DataVersion timelock_token_v1.TimelockDataVersion

	Address string
	Bump    uint8

	VaultAddress string
	VaultBump    uint8
	VaultOwner   string
	VaultState   timelock_token_v1.TimelockState

	TimeAuthority  string
	CloseAuthority string

	NumDaysLocked uint8
	UnlockAt      *uint64

	Block uint64

	LastUpdatedAt time.Time
}

Based off of https://github.com/code-payments/code-program-library/blob/main/timelock-token/programs/timelock-token/src/state.rs

This record supports both the legacy 2022 (pre-privacy) and v1 versions of the timelock program, since they're easily interchangeable. All legacy fields will be converted accordingly, or dropped if never used.

func (*Record) Clone

func (r *Record) Clone() *Record

func (*Record) CopyTo

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

func (*Record) ExistsOnBlockchain

func (r *Record) ExistsOnBlockchain() bool

func (*Record) IsClosed

func (r *Record) IsClosed() bool

func (*Record) IsLocked

func (r *Record) IsLocked() bool

func (*Record) UpdateFromLegacy2022ProgramAccount

func (r *Record) UpdateFromLegacy2022ProgramAccount(data *timelock_token_legacy.TimelockAccount, block uint64) error

func (*Record) UpdateFromV1ProgramAccount

func (r *Record) UpdateFromV1ProgramAccount(data *timelock_token_v1.TimelockAccount, block uint64) error

func (*Record) Validate

func (r *Record) Validate() error

type Store

type Store interface {
	// Save saves a timelock account's state
	Save(ctx context.Context, record *Record) error

	// GetByAddress gets a timelock account's state by the state address
	GetByAddress(ctx context.Context, address string) (*Record, error)

	// GetByVault gets a timelock account's state by the vault address it's locking
	GetByVault(ctx context.Context, vault string) (*Record, error)

	// GetByVaultBatch is like GetByVault, but for multiple accounts. If any one account
	// is missing, ErrTimelockNotFound is returned.
	GetByVaultBatch(ctx context.Context, vaults ...string) (map[string]*Record, error)

	// GetAllByState gets all timelock accounts in the provided state
	GetAllByState(ctx context.Context, state timelock_token.TimelockState, cursor query.Cursor, limit uint64, direction query.Ordering) ([]*Record, error)

	// GetCountByState gets the count of records in the provided state
	GetCountByState(ctx context.Context, state timelock_token.TimelockState) (uint64, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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