core

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 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 Asset

type Asset struct {
	ID      string        `json:"id,omitempty"`
	Hash    mixinnet.Hash `json:"hash,omitempty"`
	ChainID string        `json:"chain_id,omitempty"`
	Symbol  string        `json:"symbol,omitempty"`
	Name    string        `json:"name,omitempty"`
}

type AssetService

type AssetService interface {
	Find(ctx context.Context, id string) (*Asset, error)
	FindHash(ctx context.Context, hash mixinnet.Hash) (*Asset, error)
}

type Balance

type Balance struct {
	AssetID string          `json:"asset_id,omitempty"`
	Amount  decimal.Decimal `json:"amount"`
}

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"`
	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, error)
}

type OutputStore

type OutputStore interface {
	GetOffset(ctx context.Context) (uint64, error)
	Save(ctx context.Context, outputs []*Output) error
	List(ctx context.Context, offset uint64, assetID string, target decimal.Decimal, limit int) ([]*Output, error)
	ListRange(ctx context.Context, assetID string, from, to uint64) ([]*Output, error)
	SumBalance(ctx context.Context, asset string) (*Balance, error)
	SumBalances(ctx context.Context) ([]*Balance, 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"`
	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 {
	Find(ctx context.Context, traceID string) (*Transfer, error)
	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, assetID string) (uint64, error)
}

Jump to

Keyboard shortcuts

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