core

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	UserID  string          `json:"user_id,omitempty"`
	AssetID string          `json:"asset_id,omitempty"`
	Amount  decimal.Decimal `json:"amount"`
	Count   int             `json:"count"`
}

type Output

type Output struct {
	Sequence  uint64          `json:"sequence,omitempty"`
	CreatedAt time.Time       `json:"created_at"`
	Hash      mixinnet.Hash   `json:"hash,omitempty"`
	Index     uint8           `json:"index,omitempty"`
	UserID    string          `json:"user_id,omitempty"`
	AssetID   string          `json:"asset_id,omitempty"`
	Amount    decimal.Decimal `json:"amount"`
}

type OutputService

type OutputService interface {
	Pull(ctx context.Context, offset uint64, limit int) ([]*Output, uint64, error)
	ListRange(ctx context.Context, assetID string, from, to uint64) ([]*Output, error)
}

type OutputStore

type OutputStore interface {
	Save(ctx context.Context, outputs []*Output) error
	List(ctx context.Context, userID string, offset uint64, limit int) ([]*Output, error)
	ListTarget(ctx context.Context, userID, assetID string, offset uint64, target decimal.Decimal, limit int) ([]*Output, error)
	ListRange(ctx context.Context, userID, assetID string, from, to uint64) ([]*Output, error)
	Delete(ctx context.Context, sequence uint64) error
	SumBalances(ctx context.Context, userID, assetID string) ([]*Balance, error)
}

type PropertyStore added in v1.1.0

type PropertyStore interface {
	Get(ctx context.Context, key string, value any) error
	Set(ctx context.Context, key string, value any) error
}

type ServiceLoader added in v1.1.0

type ServiceLoader interface {
	LoadOutput(ctx context.Context, userID string) (OutputService, error)
	LoadTransfer(ctx context.Context, userID string) (TransferService, error)
}

type Transfer

type Transfer struct {
	ID          uint64            `json:"id,omitempty"`
	CreatedAt   time.Time         `json:"created_at,omitempty"`
	TraceID     string            `json:"trace_id,omitempty"`
	Status      TransferStatus    `json:"state,omitempty"`
	UserID      string            `json:"user_id,omitempty"`
	AssetID     string            `json:"asset_id,omitempty"`
	Amount      decimal.Decimal   `json:"amount,omitempty"`
	Memo        string            `json:"memo,omitempty"`
	Opponent    *mixin.MixAddress `json:"opponent,omitempty"`
	AssignRange [2]uint64         `json:"assign_range,omitempty"`
}

type TransferService

type TransferService interface {
	Spend(ctx context.Context, transfer *Transfer, outputs []*Output) error
}

type TransferStatus

type TransferStatus uint8
const (
	TransferStatusPending TransferStatus
	TransferStatusAssigned
	TransferStatusHandled
)

func TransferStatusString

func TransferStatusString(s string) (TransferStatus, error)

TransferStatusString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func TransferStatusValues

func TransferStatusValues() []TransferStatus

TransferStatusValues returns all values of the enum

func (TransferStatus) IsATransferStatus

func (i TransferStatus) IsATransferStatus() bool

IsATransferStatus returns "true" if the value is listed in the enum definition. "false" otherwise

func (TransferStatus) MarshalJSON

func (i TransferStatus) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for TransferStatus

func (TransferStatus) String

func (i TransferStatus) String() string

func (*TransferStatus) UnmarshalJSON

func (i *TransferStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for TransferStatus

type TransferStore

type TransferStore interface {
	Create(ctx context.Context, transfer *Transfer) error
	Assign(ctx context.Context, transfer *Transfer, offset uint64) error
	UpdateStatus(ctx context.Context, transfer *Transfer, to TransferStatus) error
	FindTrace(ctx context.Context, traceID string) (*Transfer, error)
	ListStatus(ctx context.Context, status TransferStatus, limit int) ([]*Transfer, error)
	GetAssignOffset(ctx context.Context, userID, assetID string) (uint64, error)
}

type Wallet added in v1.1.0

type Wallet struct {
	UserID     string `json:"user_id"`
	Label      string `json:"label"`
	SessionID  string `json:"session_id"`
	PrivateKey string `json:"private_key"`
	PinToken   string `json:"pin_token"`
	Pin        string `json:"pin"`
	SpendKey   string `json:"spend_key"`
}

type WalletService added in v1.1.0

type WalletService interface {
	Create(ctx context.Context, label string) (*Wallet, error)
}

type WalletStore added in v1.1.0

type WalletStore interface {
	Create(ctx context.Context, wallet *Wallet) error
	Find(ctx context.Context, userID string) (*Wallet, error)
}

Jump to

Keyboard shortcuts

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