timelock

package
v0.0.0-...-c6effd4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

	Address string
	Bump    uint8

	VaultAddress string
	VaultBump    uint8
	VaultOwner   string
	VaultState   timelock_token_v1.TimelockState // Uses the original Timelock account state since the CVM only defines enum states for unlock

	DepositPdaAddress string
	DepositPdaBump    uint8

	UnlockAt *uint64

	Block uint64

	LastUpdatedAt time.Time
}

Time/close authorities and lock duration are configured at the VM level

todo: Assumes a single VM.

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) 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)

	// GetByDepositPda gets a timelock account's state by the deposit PDA address
	GetByDepositPda(ctx context.Context, depositPda 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