interpreter

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewArgsParser

func NewArgsParser(args []Value) *argsParser

func Reconcile

func Reconcile(asset string, senders []Sender, receivers []Receiver) ([]Posting, InterpreterError)

func RunProgram

func RunProgram(
	ctx context.Context,
	program parser.Program,
	vars map[string]string,
	store Store,
) (*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 BalanceQuery

type BalanceQuery map[string][]string

For each account, list of the needed assets

type Balances

type Balances map[string]AccountBalance

type ExecutionResult

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

	Metadata Metadata `json:"txMeta"`

	AccountsMetadata AccountsMetadata `json:"accountsMeta"`
}

type InterpreterError

type InterpreterError interface {
	error
	parser.Ranged
}

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 InvalidMonetaryLiteral

type InvalidMonetaryLiteral struct {
	parser.Range
	Source string
}

func (InvalidMonetaryLiteral) Error

func (e InvalidMonetaryLiteral) 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 (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) MarshalJSON

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

func (MonetaryInt) String

func (v MonetaryInt) String() string

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 Receiver

type Receiver struct {
	Name     string
	Monetary *big.Int
}

type ReconcileError

type ReconcileError struct {
	Receiver  Receiver
	Receivers []Receiver
}

func (ReconcileError) Error

func (e ReconcileError) Error() string

type Sender

type Sender struct {
	Name     string
	Monetary *big.Int
}

type StaticStore

type StaticStore struct {
	Balances Balances
	Meta     AccountsMetadata
}

func (StaticStore) GetAccountsMetadata

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

func (StaticStore) GetBalances

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