interpreter

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const KEPT_ADDR = "<kept>"

Variables

View Source
var Regexp = regexp.MustCompile(accountPattern)

Functions

func CalculateMaxSafeWithdraw added in v0.0.17

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

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

func CalculateSafeWithdraw added in v0.0.17

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 NewAccountAddress added in v0.0.12

func NewAccountAddress(src string) (AccountAddress, InterpreterError)

func NewArgsParser

func NewArgsParser(args []Value) *argsParser

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

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 added in v0.0.10

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

func (BadPortionParsingErr) Error added in v0.0.10

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

type CannotCastToString added in v0.0.12

type CannotCastToString struct {
	parser.Range
	Value Value
}

func (CannotCastToString) Error added in v0.0.12

func (e CannotCastToString) Error() string

type DivideByZero added in v0.0.11

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

func (DivideByZero) Error added in v0.0.11

func (e DivideByZero) Error() string

type ExecutionResult

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

	Metadata Metadata `json:"txMeta"`

	AccountsMetadata AccountsMetadata `json:"accountsMeta"`
}

type ExperimentalFeature added in v0.0.10

type ExperimentalFeature struct {
	parser.Range
	FlagName string
}

func (ExperimentalFeature) Error added in v0.0.10

func (e ExperimentalFeature) Error() string

type InterpreterError

type InterpreterError interface {
	error
	parser.Ranged
}

func ParsePortionSpecific added in v0.0.10

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

type InvalidAccountName added in v0.0.12

type InvalidAccountName struct {
	parser.Range
	Name string
}

func (InvalidAccountName) Error added in v0.0.12

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 InvalidColor added in v0.0.17

type InvalidColor struct {
	parser.Range
	Color string
}

func (InvalidColor) Error added in v0.0.17

func (e InvalidColor) Error() string

type InvalidMonetaryLiteral

type InvalidMonetaryLiteral struct {
	parser.Range
	Source string
}

func (InvalidMonetaryLiteral) Error

func (e InvalidMonetaryLiteral) Error() string

type InvalidNestedMeta added in v0.0.15

type InvalidNestedMeta struct {
	parser.Range
}

func (InvalidNestedMeta) Error added in v0.0.15

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

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 added in v0.0.15

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 added in v0.0.10

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 added in v0.0.10

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