core

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TypeAccount   = Type(iota + 1) // address of an account
	TypeAsset                      // name of an asset
	TypeNumber                     // 64bit unsigned integer
	TypeString                     // string
	TypeMonetary                   // [asset number]
	TypePortion                    // rational number between 0 and 1 both exclusive
	TypeAllotment                  // list of portions
	TypeAmount                     // either ALL or a SPECIFIC number
	TypeFunding                    // (asset, []{amount, account})
)

Variables

This section is empty.

Functions

func ParseAccount added in v1.4.1

func ParseAccount(acc Account) error

func ParseAsset added in v1.4.1

func ParseAsset(ass Asset) error

func ParseMonetary added in v1.4.1

func ParseMonetary(mon Monetary) error

func ValidatePortionSpecific added in v1.4.1

func ValidatePortionSpecific(p Portion) error

func ValueEquals

func ValueEquals(lhs, rhs Value) bool

Types

type Account

type Account string

func (Account) GetType

func (Account) GetType() Type

func (Account) String

func (a Account) String() string

type Address

type Address uint16

Address represents an address in the machine's resources, which include constants (literals) and variables passed to the program

func NewAddress

func NewAddress(x uint16) Address

func (Address) ToBytes

func (a Address) ToBytes() []byte

type Allotment

type Allotment []big.Rat

func NewAllotment

func NewAllotment(portions []Portion) (*Allotment, error)

func (Allotment) Allocate

func (a Allotment) Allocate(amount *MonetaryInt) []*MonetaryInt

func (Allotment) GetType

func (Allotment) GetType() Type

func (Allotment) String

func (a Allotment) String() string

type Asset

type Asset string

func (Asset) GetAsset

func (a Asset) GetAsset() Asset

func (Asset) GetType

func (Asset) GetType() Type

func (Asset) String

func (a Asset) String() string

type Funding

type Funding struct {
	Asset Asset
	Parts []FundingPart
}

func (Funding) Concat

func (f Funding) Concat(other Funding) (Funding, error)

func (Funding) Equals

func (lhs Funding) Equals(rhs Funding) bool

func (Funding) GetAsset

func (f Funding) GetAsset() Asset

func (Funding) GetType

func (Funding) GetType() Type

func (Funding) Reverse

func (f Funding) Reverse() Funding

func (Funding) String

func (f Funding) String() string

func (Funding) Take

func (f Funding) Take(amount *MonetaryInt) (Funding, Funding, error)

func (Funding) TakeMax

func (f Funding) TakeMax(amount *MonetaryInt) (Funding, Funding)

func (Funding) Total

func (f Funding) Total() *MonetaryInt

type FundingPart

type FundingPart struct {
	Amount  *MonetaryInt
	Account Account
}

func (FundingPart) Equals

func (lhs FundingPart) Equals(rhs FundingPart) bool

type HasAsset

type HasAsset interface {
	GetAsset() Asset
}

type Monetary

type Monetary struct {
	Asset  Asset        `json:"asset"`
	Amount *MonetaryInt `json:"amount"`
}

func (Monetary) GetAsset

func (m Monetary) GetAsset() Asset

func (Monetary) GetType

func (Monetary) GetType() Type

func (Monetary) String

func (m Monetary) String() string

type MonetaryInt

type MonetaryInt big.Int

func NewMonetaryInt

func NewMonetaryInt(i int64) *MonetaryInt

func ParseMonetaryInt

func ParseMonetaryInt(s string) (*MonetaryInt, error)

func (*MonetaryInt) Add

func (a *MonetaryInt) Add(b *MonetaryInt) *MonetaryInt

func (*MonetaryInt) Cmp

func (a *MonetaryInt) Cmp(b *MonetaryInt) int

func (*MonetaryInt) Eq

func (a *MonetaryInt) Eq(b *MonetaryInt) bool

func (*MonetaryInt) Equal

func (a *MonetaryInt) Equal(b *MonetaryInt) bool

func (MonetaryInt) GetType

func (MonetaryInt) GetType() Type

func (*MonetaryInt) Gt

func (a *MonetaryInt) Gt(b *MonetaryInt) bool

func (*MonetaryInt) Gte

func (a *MonetaryInt) Gte(b *MonetaryInt) bool

func (*MonetaryInt) Lt

func (a *MonetaryInt) Lt(b *MonetaryInt) bool

func (*MonetaryInt) Lte

func (a *MonetaryInt) Lte(b *MonetaryInt) bool

func (*MonetaryInt) Ltz

func (a *MonetaryInt) Ltz() bool

func (*MonetaryInt) MarshalJSON

func (a *MonetaryInt) MarshalJSON() ([]byte, error)

func (*MonetaryInt) MarshalText

func (a *MonetaryInt) MarshalText() ([]byte, error)

func (*MonetaryInt) Neg

func (a *MonetaryInt) Neg() *MonetaryInt

func (*MonetaryInt) OrZero

func (a *MonetaryInt) OrZero() *MonetaryInt

func (*MonetaryInt) String

func (a *MonetaryInt) String() string

func (*MonetaryInt) Sub

func (a *MonetaryInt) Sub(b *MonetaryInt) *MonetaryInt

func (*MonetaryInt) Uint64

func (a *MonetaryInt) Uint64() uint64

func (*MonetaryInt) UnmarshalJSON

func (a *MonetaryInt) UnmarshalJSON(b []byte) error

func (*MonetaryInt) UnmarshalText

func (a *MonetaryInt) UnmarshalText(b []byte) error

type Number

type Number = *MonetaryInt

func NewNumber

func NewNumber(i int64) Number

func ParseNumber

func ParseNumber(s string) (Number, error)

type Portion

type Portion struct {
	Remaining bool     `json:"remaining"`
	Specific  *big.Rat `json:"specific"`
}

func NewPortionRemaining

func NewPortionRemaining() Portion

func NewPortionSpecific

func NewPortionSpecific(r big.Rat) (*Portion, error)

func ParsePortionSpecific

func ParsePortionSpecific(input string) (*Portion, error)

func (Portion) Equals

func (lhs Portion) Equals(rhs Portion) bool

func (Portion) GetType

func (Portion) GetType() Type

func (Portion) String

func (p Portion) String() string

type String

type String string

func (String) GetType

func (String) GetType() Type

func (String) String

func (s String) String() string

type Type

type Type byte

func TypeFromName added in v1.4.1

func TypeFromName(name string) (Type, bool)

func (Type) String

func (t Type) String() string

type Value

type Value interface {
	GetType() Type
}

func NewValueFromJSON

func NewValueFromJSON(typ Type, data json.RawMessage) (*Value, error)

func NewValueFromTypedJSON

func NewValueFromTypedJSON(rawInput json.RawMessage) (*Value, error)

type ValueJSON

type ValueJSON struct {
	Type  string          `json:"type"`
	Value json.RawMessage `json:"value"`
}

Jump to

Keyboard shortcuts

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