commitment

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCommitmentNotFound = errors.New("commitment not found")
	ErrInvalidCommitment  = errors.New("commitment record is invalid")
)

Functions

This section is empty.

Types

type Record

type Record struct {
	Id uint64

	DataVersion splitter_token.DataVersion

	Address string
	Bump    uint8

	Pool       string
	PoolBump   uint8
	RecentRoot string
	Transcript string

	Destination string
	Amount      uint64

	Vault     string
	VaultBump uint8

	Intent   string
	ActionId uint32

	Owner string

	// Has the treasury been repaid for advancing Record.Amount to Record.Destination?
	// Not to be confused with payments being diverted to this commitment and then
	// being closed.
	TreasuryRepaid bool
	// The commitment vault where repayment for Record.Amount will be diverted to.
	RepaymentDivertedTo *string

	State State

	CreatedAt time.Time
}

func (*Record) Clone

func (r *Record) Clone() *Record

func (*Record) CopyTo

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

func (*Record) Validate

func (r *Record) Validate() error

type State

type State uint8
const (
	StateUnknown State = iota
	StatePayingDestination
	StateReadyToOpen
	StateOpening
	StateOpen
	StateClosing
	StateClosed

	// Theoretical states that don't have any logic right now, but will be needed
	// later for GC.
	StateReadyToRemoveFromMerkleTree
	StateRemovedFromMerkleTree
)

func (State) String

func (s State) String() string

type Store

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

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

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

	// GetByAction gets a commitment account's state by the action it's involved in
	GetByAction(ctx context.Context, intentId string, actionId uint32) (*Record, error)

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

	// GetUpgradeableByOwner gets commitment records that are upgradeable and owned
	// by a provided owner account.
	GetUpgradeableByOwner(ctx context.Context, owner string, limit uint64) ([]*Record, error)

	// GetUsedTreasuryPoolDeficit gets the used deficit, in Kin quarks, to a treasury
	// pool given the associated commitments
	GetUsedTreasuryPoolDeficit(ctx context.Context, pool string) (uint64, error)

	// GetTotalTreasuryPoolDeficit gets the total deficit, in Kin quarks, to a treasury
	// pool given the associated commitments
	GetTotalTreasuryPoolDeficit(ctx context.Context, pool string) (uint64, error)

	// CountByState counts the number of commitment records in a given state
	CountByState(ctx context.Context, state State) (uint64, error)

	// CountRepaymentsDivertedToVault counts the number of commitments whose repayments
	// are diverted to the provided vault.
	CountRepaymentsDivertedToVault(ctx context.Context, vault string) (uint64, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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