core

package
v1.10.7 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const (
	MetaTargetTypeAccount     = "ACCOUNT"
	MetaTargetTypeTransaction = "TRANSACTION"
)
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})
)
View Source
const NewTransactionType = "NEW_TRANSACTION"
View Source
const SetMetadataType = "SET_METADATA"
View Source
const (
	WORLD = "world"
)

Variables

This section is empty.

Functions

func AssetIsValid

func AssetIsValid(v string) bool

func Hash

func Hash(t1, t2 interface{}) string

func HydrateLog added in v1.3.2

func HydrateLog(_type string, data string) (interface{}, error)

func ParseAccountAddress added in v1.10.0

func ParseAccountAddress(acc AccountAddress) error

func ParseAsset added in v1.10.0

func ParseAsset(ass Asset) error

func ParseMonetary added in v1.10.0

func ParseMonetary(mon Monetary) error

func RevertMetadataSpecKey added in v1.3.2

func RevertMetadataSpecKey() string

func RevertedMetadataSpecKey added in v1.3.2

func RevertedMetadataSpecKey() string

func SpecMetadata added in v1.3.2

func SpecMetadata(name string) string

func ValidateAddress

func ValidateAddress(addr string) bool

func ValidatePortionSpecific added in v1.10.0

func ValidatePortionSpecific(p Portion) error

func ValueEquals added in v1.10.0

func ValueEquals(lhs, rhs Value) bool

Types

type Account

type Account struct {
	Address  AccountAddress `json:"address" example:"users:001"`
	Metadata Metadata       `json:"metadata" swaggertype:"object"`
}

func (Account) Copy added in v1.10.6

func (v Account) Copy() *Account

type AccountAddress added in v1.10.0

type AccountAddress string

func (AccountAddress) GetType added in v1.10.0

func (AccountAddress) GetType() Type

func (AccountAddress) String added in v1.10.0

func (a AccountAddress) String() string

type AccountWithVolumes added in v1.6.0

type AccountWithVolumes struct {
	Account
	Volumes  AssetsVolumes  `json:"volumes"`
	Balances AssetsBalances `json:"balances" example:"COIN:100"`
}

func (AccountWithVolumes) Copy added in v1.10.6

type Accounts added in v1.8.0

type Accounts map[string]Account

type AccountsAssetsVolumes added in v1.6.0

type AccountsAssetsVolumes map[string]AssetsVolumes

func AggregatePostCommitVolumes added in v1.8.0

func AggregatePostCommitVolumes(txs ...ExpandedTransaction) AccountsAssetsVolumes

func AggregatePreCommitVolumes added in v1.9.0

func AggregatePreCommitVolumes(txs ...ExpandedTransaction) AccountsAssetsVolumes

func (*AccountsAssetsVolumes) AddInput added in v1.7.0

func (a *AccountsAssetsVolumes) AddInput(account, asset string, input *MonetaryInt)

func (*AccountsAssetsVolumes) AddOutput added in v1.7.0

func (a *AccountsAssetsVolumes) AddOutput(account, asset string, output *MonetaryInt)

func (AccountsAssetsVolumes) GetVolumes added in v1.7.0

func (a AccountsAssetsVolumes) GetVolumes(account, asset string) Volumes

func (AccountsAssetsVolumes) HasAccount added in v1.7.0

func (a AccountsAssetsVolumes) HasAccount(account string) bool

func (AccountsAssetsVolumes) HasAccountAndAsset added in v1.8.0

func (a AccountsAssetsVolumes) HasAccountAndAsset(account, asset string) bool

func (*AccountsAssetsVolumes) Scan added in v1.6.0

func (a *AccountsAssetsVolumes) Scan(value interface{}) error

Scan - Implement the database/sql scanner interface

func (*AccountsAssetsVolumes) SetVolumes added in v1.7.0

func (a *AccountsAssetsVolumes) SetVolumes(account, asset string, volumes Volumes)

type AccountsBalances added in v1.6.0

type AccountsBalances map[string]AssetsBalances

type AccountsMeta added in v1.9.0

type AccountsMeta map[string]Metadata

type AdditionalOperations added in v1.9.0

type AdditionalOperations struct {
	SetAccountMeta AccountsMeta `json:"set_account_meta,omitempty"`
}

type Address added in v1.10.0

type Address uint16

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

func NewAddress added in v1.10.0

func NewAddress(x uint16) Address

func (Address) ToBytes added in v1.10.0

func (a Address) ToBytes() []byte

type Allotment added in v1.10.0

type Allotment []big.Rat

func NewAllotment added in v1.10.0

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

func (Allotment) Allocate added in v1.10.0

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

func (Allotment) GetType added in v1.10.0

func (Allotment) GetType() Type

func (Allotment) String added in v1.10.0

func (a Allotment) String() string

type Asset added in v1.10.0

type Asset string

func (Asset) GetAsset added in v1.10.0

func (a Asset) GetAsset() Asset

func (Asset) GetType added in v1.10.0

func (Asset) GetType() Type

func (Asset) String added in v1.10.0

func (a Asset) String() string

type AssetsBalances added in v1.6.0

type AssetsBalances map[string]*MonetaryInt

type AssetsVolumes added in v1.6.0

type AssetsVolumes map[string]Volumes

func (AssetsVolumes) Balances added in v1.6.0

func (v AssetsVolumes) Balances() AssetsBalances

type ConstantExpr

type ConstantExpr struct {
	Value interface{}
}

func (ConstantExpr) MarshalJSON

func (e ConstantExpr) MarshalJSON() ([]byte, error)

type Contract

type Contract struct {
	Name    string `json:"name"`
	Account string `json:"account"`
	Expr    Expr   `json:"expr"`
}

func (Contract) Match

func (c Contract) Match(addr string) bool

func (*Contract) UnmarshalJSON

func (c *Contract) UnmarshalJSON(data []byte) error

type EvalContext

type EvalContext struct {
	Variables map[string]interface{}
	Metadata  Metadata
	Asset     string
}

type ExpandedTransaction added in v1.8.0

type ExpandedTransaction struct {
	Transaction
	PreCommitVolumes  AccountsAssetsVolumes `json:"preCommitVolumes,omitempty"`
	PostCommitVolumes AccountsAssetsVolumes `json:"postCommitVolumes,omitempty"`
}

func (*ExpandedTransaction) AppendPosting added in v1.8.0

func (t *ExpandedTransaction) AppendPosting(p Posting)

func (*ExpandedTransaction) IsReverted added in v1.8.0

func (t *ExpandedTransaction) IsReverted() bool

func (ExpandedTransaction) MarshalJSON added in v1.8.0

func (t ExpandedTransaction) MarshalJSON() ([]byte, error)

type Expr

type Expr interface {
	Eval(EvalContext) bool
}

func ParseRuleExpr

func ParseRuleExpr(v map[string]interface{}) (Expr, error)

type ExprAnd

type ExprAnd []Expr

func (ExprAnd) Eval

func (o ExprAnd) Eval(ctx EvalContext) bool

func (ExprAnd) MarshalJSON

func (e ExprAnd) MarshalJSON() ([]byte, error)

type ExprEq

type ExprEq struct {
	Op1 ExprValue
	Op2 ExprValue
}

func (*ExprEq) Eval

func (o *ExprEq) Eval(ctx EvalContext) bool

func (ExprEq) MarshalJSON

func (e ExprEq) MarshalJSON() ([]byte, error)

type ExprGt

type ExprGt struct {
	Op1 ExprValue
	Op2 ExprValue
}

func (*ExprGt) Eval

func (o *ExprGt) Eval(ctx EvalContext) bool

func (ExprGt) MarshalJSON

func (e ExprGt) MarshalJSON() ([]byte, error)

type ExprGte

type ExprGte struct {
	Op1 ExprValue
	Op2 ExprValue
}

func (*ExprGte) Eval

func (o *ExprGte) Eval(ctx EvalContext) bool

func (ExprGte) MarshalJSON

func (e ExprGte) MarshalJSON() ([]byte, error)

type ExprLt

type ExprLt struct {
	Op1 ExprValue
	Op2 ExprValue
}

func (*ExprLt) Eval

func (o *ExprLt) Eval(ctx EvalContext) bool

func (ExprLt) MarshalJSON

func (e ExprLt) MarshalJSON() ([]byte, error)

type ExprLte

type ExprLte struct {
	Op1 ExprValue
	Op2 ExprValue
}

func (*ExprLte) Eval

func (o *ExprLte) Eval(ctx EvalContext) bool

func (ExprLte) MarshalJSON

func (e ExprLte) MarshalJSON() ([]byte, error)

type ExprOr

type ExprOr []Expr

func (ExprOr) Eval

func (o ExprOr) Eval(ctx EvalContext) bool

func (ExprOr) MarshalJSON

func (e ExprOr) MarshalJSON() ([]byte, error)

type ExprValue added in v1.10.0

type ExprValue interface {
	// contains filtered or unexported methods
}

type Funding added in v1.10.0

type Funding struct {
	Asset Asset
	Parts []FundingPart
}

func (Funding) Concat added in v1.10.0

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

func (Funding) Equals added in v1.10.0

func (lhs Funding) Equals(rhs Funding) bool

func (Funding) GetAsset added in v1.10.0

func (f Funding) GetAsset() Asset

func (Funding) GetType added in v1.10.0

func (Funding) GetType() Type

func (Funding) Reverse added in v1.10.0

func (f Funding) Reverse() Funding

func (Funding) String added in v1.10.0

func (f Funding) String() string

func (Funding) Take added in v1.10.0

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

func (Funding) TakeMax added in v1.10.0

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

func (Funding) Total added in v1.10.0

func (f Funding) Total() *MonetaryInt

type FundingPart added in v1.10.0

type FundingPart struct {
	Amount  *MonetaryInt
	Account AccountAddress
}

func (FundingPart) Equals added in v1.10.0

func (lhs FundingPart) Equals(rhs FundingPart) bool

type HasAsset added in v1.10.0

type HasAsset interface {
	GetAsset() Asset
}

type Log added in v1.3.2

type Log struct {
	ID   uint64      `json:"id"`
	Type string      `json:"type"`
	Data interface{} `json:"data"`
	Hash string      `json:"hash"`
	Date time.Time   `json:"date"`
}

func NewSetMetadataLog added in v1.3.2

func NewSetMetadataLog(previousLog *Log, at time.Time, metadata SetMetadata) Log

func NewTransactionLog added in v1.3.2

func NewTransactionLog(previousLog *Log, tx Transaction) Log

func NewTransactionLogWithDate added in v1.3.2

func NewTransactionLogWithDate(previousLog *Log, tx Transaction, time time.Time) Log

type LogProcessor added in v1.8.0

type LogProcessor struct {
	Transactions []*ExpandedTransaction
	Accounts     Accounts
	Volumes      AccountsAssetsVolumes
}

func NewLogProcessor added in v1.8.0

func NewLogProcessor() *LogProcessor

func (*LogProcessor) ProcessNextLog added in v1.8.0

func (m *LogProcessor) ProcessNextLog(logs ...Log)

type Mapping

type Mapping struct {
	Contracts []Contract `json:"contracts"`
}

type MetaExpr

type MetaExpr struct {
	Name string
}

func (MetaExpr) MarshalJSON

func (e MetaExpr) MarshalJSON() ([]byte, error)

type Metadata

type Metadata map[string]any

func ComputeMetadata added in v1.3.2

func ComputeMetadata(key string, value interface{}) Metadata

func RevertMetadata added in v1.3.2

func RevertMetadata(tx uint64) Metadata

func RevertedMetadata added in v1.3.2

func RevertedMetadata(by uint64) Metadata

func (Metadata) ConvertValue added in v1.3.2

func (m Metadata) ConvertValue(v interface{}) (driver.Value, error)

func (Metadata) IsEquivalentTo added in v1.6.0

func (m1 Metadata) IsEquivalentTo(m2 Metadata) bool

IsEquivalentTo allow to compare to metadata object.

func (Metadata) IsReverted

func (m Metadata) IsReverted() bool

func (Metadata) MarkReverts added in v1.1.0

func (m Metadata) MarkReverts(txID uint64)

func (Metadata) Merge added in v1.3.2

func (m1 Metadata) Merge(m2 Metadata) Metadata

func (*Metadata) Scan added in v1.3.2

func (m *Metadata) Scan(value interface{}) error

Scan - Implement the database/sql scanner interface

type MigrationInfo added in v1.9.0

type MigrationInfo struct {
	Version string    `json:"version"`
	Name    string    `json:"name"`
	State   string    `json:"state,omitempty"`
	Date    time.Time `json:"date,omitempty"`
}

type Monetary added in v1.10.0

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

func (Monetary) GetAsset added in v1.10.0

func (m Monetary) GetAsset() Asset

func (Monetary) GetType added in v1.10.0

func (Monetary) GetType() Type

func (Monetary) String added in v1.10.0

func (m Monetary) String() string

type MonetaryInt added in v1.8.0

type MonetaryInt big.Int

func NewMonetaryInt added in v1.8.0

func NewMonetaryInt(i int64) *MonetaryInt

func ParseMonetaryInt added in v1.8.0

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

func (*MonetaryInt) Add added in v1.8.0

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

func (*MonetaryInt) Cmp added in v1.8.0

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

func (*MonetaryInt) Eq added in v1.8.0

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

func (*MonetaryInt) Equal added in v1.8.0

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

func (MonetaryInt) GetType added in v1.10.0

func (MonetaryInt) GetType() Type

func (*MonetaryInt) Gt added in v1.8.0

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

func (*MonetaryInt) Gte added in v1.8.0

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

func (*MonetaryInt) Lt added in v1.8.0

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

func (*MonetaryInt) Lte added in v1.8.0

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

func (*MonetaryInt) Ltz added in v1.8.0

func (a *MonetaryInt) Ltz() bool

func (*MonetaryInt) MarshalJSON added in v1.8.0

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

func (*MonetaryInt) MarshalText added in v1.8.0

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

func (*MonetaryInt) Neg added in v1.8.0

func (a *MonetaryInt) Neg() *MonetaryInt

func (*MonetaryInt) OrZero added in v1.8.0

func (a *MonetaryInt) OrZero() *MonetaryInt

func (*MonetaryInt) String added in v1.8.0

func (a *MonetaryInt) String() string

func (*MonetaryInt) Sub added in v1.8.0

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

func (*MonetaryInt) Uint64 added in v1.8.0

func (a *MonetaryInt) Uint64() uint64

func (*MonetaryInt) UnmarshalJSON added in v1.8.0

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

func (*MonetaryInt) UnmarshalText added in v1.8.0

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

type Number added in v1.10.0

type Number = *MonetaryInt

func NewNumber added in v1.10.0

func NewNumber(i int64) Number

func ParseNumber added in v1.10.0

func ParseNumber(s string) (Number, error)

type Portion added in v1.10.0

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

func NewPortionRemaining added in v1.10.0

func NewPortionRemaining() Portion

func NewPortionSpecific added in v1.10.0

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

func ParsePortionSpecific added in v1.10.0

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

func (Portion) Equals added in v1.10.0

func (lhs Portion) Equals(rhs Portion) bool

func (Portion) GetType added in v1.10.0

func (Portion) GetType() Type

func (Portion) String added in v1.10.0

func (p Portion) String() string

type Posting

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

type Postings

type Postings []Posting

func (Postings) Reverse

func (p Postings) Reverse()

func (*Postings) Scan added in v1.3.2

func (p *Postings) Scan(value interface{}) error

Scan - Implement the database/sql scanner interface

func (Postings) Validate added in v1.9.0

func (p Postings) Validate() (int, error)

type RevertedMetadataSpecValue added in v1.3.2

type RevertedMetadataSpecValue struct {
	By string `json:"by"`
}

type Script

type Script struct {
	Plain string                     `json:"plain"`
	Vars  map[string]json.RawMessage `json:"vars" swaggertype:"object"`
}

type ScriptData added in v1.9.0

type ScriptData struct {
	Script
	Timestamp time.Time `json:"timestamp"`
	Reference string    `json:"reference"`
	Metadata  Metadata  `json:"metadata"`
}

type SetMetadata added in v1.3.2

type SetMetadata struct {
	TargetType string      `json:"targetType"`
	TargetID   interface{} `json:"targetId"`
	Metadata   Metadata    `json:"metadata"`
}

func (*SetMetadata) UnmarshalJSON added in v1.3.2

func (s *SetMetadata) UnmarshalJSON(data []byte) error

type String added in v1.10.0

type String string

func (String) GetType added in v1.10.0

func (String) GetType() Type

func (String) String added in v1.10.0

func (s String) String() string

type Transaction

type Transaction struct {
	TransactionData
	ID uint64 `json:"txid"`
}

type TransactionData

type TransactionData struct {
	Postings  Postings  `json:"postings"`
	Reference string    `json:"reference"`
	Metadata  Metadata  `json:"metadata" swaggertype:"object"`
	Timestamp time.Time `json:"timestamp"`
}

func (*TransactionData) Reverse added in v1.3.2

func (t *TransactionData) Reverse() TransactionData

type Transactions

type Transactions struct {
	Transactions []TransactionData `json:"transactions" binding:"required,dive"`
}

type Type added in v1.10.0

type Type byte

func TypeFromName added in v1.10.0

func TypeFromName(name string) (Type, bool)

func (Type) String added in v1.10.0

func (t Type) String() string

type Value

type Value interface {
	GetType() Type
}

func NewValueFromJSON added in v1.10.0

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

func NewValueFromTypedJSON added in v1.10.0

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

type ValueJSON added in v1.10.0

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

type VariableExpr

type VariableExpr struct {
	Name string
}

func (VariableExpr) MarshalJSON

func (e VariableExpr) MarshalJSON() ([]byte, error)

type Volumes added in v1.3.2

type Volumes struct {
	Input  *MonetaryInt `json:"input"`
	Output *MonetaryInt `json:"output"`
}

func (Volumes) Balance added in v1.6.0

func (v Volumes) Balance() *MonetaryInt

func (Volumes) MarshalJSON added in v1.6.0

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

type VolumesWithBalance added in v1.6.0

type VolumesWithBalance struct {
	Input   *MonetaryInt `json:"input"`
	Output  *MonetaryInt `json:"output"`
	Balance *MonetaryInt `json:"balance"`
}

Jump to

Keyboard shortcuts

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