interpreter

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const KEPT_ADDR = "<kept>"

Variables

This section is empty.

Functions

func CalculateMaxSafeWithdraw

func CalculateMaxSafeWithdraw(balance *big.Int, overdraft *big.Int) *big.Int

PRE: ovedraft != nil, balance != nil PRE: ovedraft >= 0 POST: $out >= 0

func CalculateSafeWithdraw

func CalculateSafeWithdraw(
	balance *big.Int,
	overdraft *big.Int,
	requestedAmount *big.Int,
) *big.Int

PRE: ovedraft != nil, balance != nil PRE: ovedraft >= 0 PRE: requestedAmount >= 0 POST: $out >= 0

func CompareBalances

func CompareBalances(b1 Balances, b2 Balances) bool

func CompareBalancesIncluding

func CompareBalancesIncluding(b1 Balances, b2 Balances) bool

Returns whether the first value is a subset of the second one

func NewAccountAddress

func NewAccountAddress(src string) (AccountAddress, InterpreterError)

func NewArgsParser

func NewArgsParser(args []Value) *argsParser

func NewAsset

func NewAsset(src string) (Asset, InterpreterError)

func PrettyPrintMeta

func PrettyPrintMeta(meta Metadata) string

func PrettyPrintPostings

func PrettyPrintPostings(postings []Posting) string

func RunProgram

func RunProgram(
	ctx context.Context,
	program parser.Program,
	vars map[string]string,
	store Store,
	featureFlags map[string]struct{},
) (*ExecutionResult, InterpreterError)

Types

type AccountAddress

type AccountAddress string

func (AccountAddress) String

func (v AccountAddress) String() string

type AccountBalance

type AccountBalance = map[string]*big.Int

type AccountMetadata

type AccountMetadata = map[string]string

type AccountsMetadata

type AccountsMetadata map[string]AccountMetadata

func (AccountsMetadata) DeepClone

func (m AccountsMetadata) DeepClone() AccountsMetadata

func (AccountsMetadata) Merge

func (m AccountsMetadata) Merge(update AccountsMetadata)

func (AccountsMetadata) PrettyPrint

func (m AccountsMetadata) PrettyPrint() string

type Asset

type Asset string

func (Asset) String

func (v Asset) String() string

type BadArityErr

type BadArityErr struct {
	parser.Range
	ExpectedArity  int
	GivenArguments int
}

func (BadArityErr) Error

func (e BadArityErr) Error() string

type BadPortionParsingErr

type BadPortionParsingErr struct {
	parser.Range
	Source string
	Reason string
}

func (BadPortionParsingErr) Error

func (e BadPortionParsingErr) Error() string

type BalanceQuery

type BalanceQuery map[string][]string

For each account, list of the needed assets

type Balances

type Balances map[string]AccountBalance

func (Balances) DeepClone

func (b Balances) DeepClone() Balances

func (Balances) Merge

func (b Balances) Merge(update Balances)

Merge balances by adding balances in the "update" arg

func (Balances) PrettyPrint

func (b Balances) PrettyPrint() string

type CannotCastToString

type CannotCastToString struct {
	parser.Range
	Value Value
}

func (CannotCastToString) Error

func (e CannotCastToString) Error() string

type DivideByZero

type DivideByZero struct {
	parser.Range
	Numerator *big.Int
}

func (DivideByZero) Error

func (e DivideByZero) Error() string

type ExecutionResult

type ExecutionResult struct {
	Postings []Posting `json:"postings"`

	Metadata Metadata `json:"txMeta"`

	AccountsMetadata AccountsMetadata `json:"accountsMeta"`
}

type ExperimentalFeature

type ExperimentalFeature struct {
	parser.Range
	FlagName string
}

func (ExperimentalFeature) Error

func (e ExperimentalFeature) Error() string

type InternalError

type InternalError struct {
	parser.Range
	Posting Posting
}

func (InternalError) Error

func (e InternalError) Error() string

type InterpreterError

type InterpreterError interface {
	error
	parser.Ranged
}

func ParsePortionSpecific

func ParsePortionSpecific(input string) (*big.Rat, InterpreterError)

type InvalidAccountName

type InvalidAccountName struct {
	parser.Range
	Name string
}

func (InvalidAccountName) Error

func (e InvalidAccountName) Error() string

type InvalidAllotmentInSendAll

type InvalidAllotmentInSendAll struct {
	parser.Range
}

func (InvalidAllotmentInSendAll) Error

type InvalidAllotmentSum

type InvalidAllotmentSum struct {
	parser.Range
	ActualSum big.Rat
}

func (InvalidAllotmentSum) Error

func (e InvalidAllotmentSum) Error() string

type InvalidAsset

type InvalidAsset struct {
	parser.Range
	Name string
}

func (InvalidAsset) Error

func (e InvalidAsset) Error() string

type InvalidColor

type InvalidColor struct {
	parser.Range
	Color string
}

func (InvalidColor) Error

func (e InvalidColor) Error() string

type InvalidFeature

type InvalidFeature struct {
	parser.Range
	Feature string
}

func (InvalidFeature) Error

func (e InvalidFeature) Error() string

type InvalidMonetaryLiteral

type InvalidMonetaryLiteral struct {
	parser.Range
	Source string
}

func (InvalidMonetaryLiteral) Error

func (e InvalidMonetaryLiteral) Error() string

type InvalidNestedMeta

type InvalidNestedMeta struct {
	parser.Range
}

func (InvalidNestedMeta) Error

func (InvalidNestedMeta) Error() string

type InvalidNumberLiteral

type InvalidNumberLiteral struct {
	parser.Range
	Source string
}

func (InvalidNumberLiteral) Error

func (e InvalidNumberLiteral) Error() string

type InvalidTypeErr

type InvalidTypeErr struct {
	parser.Range
	Name string
}

func (InvalidTypeErr) Error

func (e InvalidTypeErr) Error() string

type InvalidUnboundedAddressInScalingAddress

type InvalidUnboundedAddressInScalingAddress struct {
	parser.Range
}

func (InvalidUnboundedAddressInScalingAddress) Error

type InvalidUnboundedInSendAll

type InvalidUnboundedInSendAll struct {
	parser.Range
	Name string
}

func (InvalidUnboundedInSendAll) Error

type Metadata

type Metadata = map[string]Value

type MetadataNotFound

type MetadataNotFound struct {
	parser.Range
	Account string
	Key     string
}

func (MetadataNotFound) Error

func (e MetadataNotFound) Error() string

type MetadataQuery

type MetadataQuery map[string][]string

For each account, list of the needed keys

type MismatchedCurrencyError

type MismatchedCurrencyError struct {
	parser.Range
	Expected string
	Got      string
}

func (MismatchedCurrencyError) Error

func (e MismatchedCurrencyError) Error() string

type MissingFundsErr

type MissingFundsErr struct {
	parser.Range
	Asset     string
	Needed    big.Int
	Available big.Int
}

func (MissingFundsErr) Error

func (e MissingFundsErr) Error() string

func (MissingFundsErr) Is

func (e MissingFundsErr) Is(target error) bool

type MissingVariableErr

type MissingVariableErr struct {
	parser.Range
	Name string
}

func (MissingVariableErr) Error

func (e MissingVariableErr) Error() string

type Monetary

type Monetary struct {
	Amount MonetaryInt
	Asset  Asset
}

func NewMonetary

func NewMonetary(asset string, n int64) Monetary

func (Monetary) MarshalJSON

func (v Monetary) MarshalJSON() ([]byte, error)

func (Monetary) String

func (v Monetary) String() string

type MonetaryInt

type MonetaryInt big.Int

func NewMonetaryInt

func NewMonetaryInt(n int64) MonetaryInt

func (MonetaryInt) Add

func (m MonetaryInt) Add(other MonetaryInt) MonetaryInt

func (MonetaryInt) MarshalJSON

func (v MonetaryInt) MarshalJSON() ([]byte, error)

func (MonetaryInt) String

func (v MonetaryInt) String() string

func (MonetaryInt) Sub

func (m MonetaryInt) Sub(other MonetaryInt) MonetaryInt

type NegativeAmountErr

type NegativeAmountErr struct {
	parser.Range
	Amount MonetaryInt
}

func (NegativeAmountErr) Error

func (e NegativeAmountErr) Error() string

type NegativeBalanceError

type NegativeBalanceError struct {
	parser.Range
	Account string
	Amount  big.Int
}

func (NegativeBalanceError) Error

func (e NegativeBalanceError) Error() string

type Portion

type Portion big.Rat

func (Portion) MarshalJSON

func (v Portion) MarshalJSON() ([]byte, error)

func (Portion) String

func (p Portion) String() string

type Posting

type Posting struct {
	Source      string   `json:"source"`
	Destination string   `json:"destination"`
	Amount      *big.Int `json:"amount"`
	Asset       string   `json:"asset"`
}

type QueryBalanceError

type QueryBalanceError struct {
	parser.Range
	WrappedError error
}

func (QueryBalanceError) Error

func (e QueryBalanceError) Error() string

type QueryMetadataError

type QueryMetadataError struct {
	parser.Range
	WrappedError error
}

func (QueryMetadataError) Error

func (e QueryMetadataError) Error() string

type Sender

type Sender struct {
	Name   string
	Amount *big.Int
	Color  string
}

type StaticStore

type StaticStore struct {
	Balances Balances
	Meta     AccountsMetadata
}

func (StaticStore) GetAccountsMetadata

func (s StaticStore) GetAccountsMetadata(context.Context, MetadataQuery) (AccountsMetadata, error)

func (StaticStore) GetBalances

func (s StaticStore) GetBalances(_ context.Context, q BalanceQuery) (Balances, error)

type Store

type Store interface {
	GetBalances(context.Context, BalanceQuery) (Balances, error)
	GetAccountsMetadata(context.Context, MetadataQuery) (AccountsMetadata, error)
}

type String

type String string

func (String) String

func (v String) String() string

type TypeError

type TypeError struct {
	parser.Range
	Expected string
	Value    Value
}

func (TypeError) Error

func (e TypeError) Error() string

type UnboundFunctionErr

type UnboundFunctionErr struct {
	parser.Range
	Name string
}

func (UnboundFunctionErr) Error

func (e UnboundFunctionErr) Error() string

type UnboundVariableErr

type UnboundVariableErr struct {
	parser.Range
	Name string
}

func (UnboundVariableErr) Error

func (e UnboundVariableErr) Error() string

type Value

type Value interface {
	String() string
	// contains filtered or unexported methods
}

type VariablesMap

type VariablesMap map[string]string

Jump to

Keyboard shortcuts

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