timelock

package
v1.10.21-0...-113a02c Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 5 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

	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

	SwapPdaAddress string
	SwapPdaBump    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)

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

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

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