swap

package
v1.10.21-0...-1aaa319 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FundingSourceUnknown = iota
	FundingSourceSubmitIntent
)

Variables

View Source
var (
	ErrNotFound     = errors.New("swap not found")
	ErrExists       = errors.New("swap already exists")
	ErrStaleVersion = errors.New("swap version is stale")
)

Functions

This section is empty.

Types

type FundingSource

type FundingSource uint8

type Record

type Record struct {
	Id uint64

	SwapId string

	Owner string

	FromMint string
	ToMint   string
	Amount   uint64

	FundingId     string
	FundingSource FundingSource

	Nonce     string
	Blockhash string

	ProofSignature string

	TransactionSignature *string
	TransactionBlob      []byte

	State State

	Version uint64

	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
	StateCreated
	StateFunding
	StateFunded
	StateSubmitting
	StateFinalized
	StateFailed
	StateCancelling
	StateCancelled
)

func (State) String

func (s State) String() string

type Store

type Store interface {
	// Save creates or updates a swap
	Save(ctx context.Context, record *Record) error

	// GetById gets a swap by ID
	GetById(ctx context.Context, id string) (*Record, error)

	// GetByFundingId gets a swap by the funding ID
	GetByFundingId(ctx context.Context, fundingId string) (*Record, error)

	// GetAllByOwnerAndState gets all swaps for an owner in a state
	GetAllByOwnerAndState(ctx context.Context, owner string, state State) ([]*Record, error)

	// GetAllByState gets all swaps by state
	GetAllByState(ctx context.Context, state State, cursor query.Cursor, limit uint64, direction query.Ordering) ([]*Record, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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