machine

package
v1.10.0-beta.2....-1a3534f Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 10 Imported by: 0

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 inclusive
	TypeAllotment                  // list of portions
	TypeAmount                     // either ALL or a SPECIFIC number
	TypeFunding                    // (asset, []{amount, account})
)

Variables

View Source
var (
	ErrScriptFailed            = errors.New("script exited with error code")
	ErrResourcesNotInitialized = errors.New("resources not initialized")
	ErrBalancesNotInitialized  = errors.New("balances not initialized")
	ErrResourceNotFound        = errors.New("resource not found")
)
View Source
var Zero = NewMonetaryInt(0)

Functions

func IsInsufficientFundError

func IsInsufficientFundError(err error) bool

func IsMetadataOverride

func IsMetadataOverride(err error) bool

func NewStringFromValue

func NewStringFromValue(value Value) (string, error)

func ParseMonetary

func ParseMonetary(mon Monetary) error

func ValidateAccountAddress

func ValidateAccountAddress(acc AccountAddress) error

func ValidateAsset

func ValidateAsset(ass Asset) error

func ValidatePortionSpecific

func ValidatePortionSpecific(p Portion) error

func ValueEquals

func ValueEquals(lhs, rhs Value) bool

Types

type AccountAddress

type AccountAddress string

func (AccountAddress) GetType

func (AccountAddress) GetType() Type

func (AccountAddress) String

func (a AccountAddress) 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 Addresses

type Addresses []Address

func (Addresses) Len

func (a Addresses) Len() int

func (Addresses) Less

func (a Addresses) Less(i, j int) bool

func (Addresses) Swap

func (a Addresses) Swap(i, j int)

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 ErrInsufficientFund

type ErrInsufficientFund struct {
	// contains filtered or unexported fields
}

func NewErrInsufficientFund

func NewErrInsufficientFund(f string, args ...any) *ErrInsufficientFund

func (*ErrInsufficientFund) Error

func (e *ErrInsufficientFund) Error() string

func (*ErrInsufficientFund) Is

func (e *ErrInsufficientFund) Is(err error) bool

type ErrInvalidScript

type ErrInvalidScript struct {
	// contains filtered or unexported fields
}

func NewErrInvalidScript

func NewErrInvalidScript(f string, args ...any) *ErrInvalidScript

func (*ErrInvalidScript) Error

func (e *ErrInvalidScript) Error() string

func (*ErrInvalidScript) Is

func (e *ErrInvalidScript) Is(err error) bool

type ErrInvalidVars

type ErrInvalidVars struct {
	// contains filtered or unexported fields
}

func NewErrInvalidVars

func NewErrInvalidVars(f string, args ...any) *ErrInvalidVars

func (*ErrInvalidVars) Error

func (e *ErrInvalidVars) Error() string

func (*ErrInvalidVars) Is

func (e *ErrInvalidVars) Is(err error) bool

type ErrMetadataOverride

type ErrMetadataOverride struct {
	// contains filtered or unexported fields
}

func NewErrMetadataOverride

func NewErrMetadataOverride(key string) *ErrMetadataOverride

func (*ErrMetadataOverride) Error

func (e *ErrMetadataOverride) Error() string

func (*ErrMetadataOverride) Is

func (e *ErrMetadataOverride) Is(err error) bool

type ErrMissingMetadata

type ErrMissingMetadata struct {
	// contains filtered or unexported fields
}

func NewErrMissingMetadata

func NewErrMissingMetadata(f string, args ...any) *ErrMissingMetadata

func (*ErrMissingMetadata) Error

func (e *ErrMissingMetadata) Error() string

func (*ErrMissingMetadata) Is

func (e *ErrMissingMetadata) Is(err error) bool

type ErrNegativeAmount

type ErrNegativeAmount struct {
	// contains filtered or unexported fields
}

func NewErrNegativeAmount

func NewErrNegativeAmount(f string, args ...any) *ErrNegativeAmount

func (*ErrNegativeAmount) Error

func (e *ErrNegativeAmount) Error() string

func (*ErrNegativeAmount) Is

func (e *ErrNegativeAmount) Is(err error) bool

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 AccountAddress
}

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 NewMonetaryIntFromBigInt

func NewMonetaryIntFromBigInt(v *big.Int) *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 (Type) String

func (t Type) String() string

type Value

type Value interface {
	GetType() Type
}

func NewValueFromString

func NewValueFromString(typ Type, data string) (Value, error)

type ValueJSON

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

Directories

Path Synopsis
vm
Provides `Machine`, which executes programs and outputs postings.
Provides `Machine`, which executes programs and outputs postings.

Jump to

Keyboard shortcuts

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