Documentation
¶
Index ¶
- Constants
- Variables
- func AssetIsValid(v string) bool
- func ComputeMetadata(key, value string) metadata.Metadata
- func HydrateLog(_type LogType, data []byte) (any, error)
- func MarkReverts(m metadata.Metadata, txID *big.Int) metadata.Metadata
- func RevertMetadata(tx *big.Int) metadata.Metadata
- func RevertMetadataSpecKey() string
- func SpecMetadata(name string) string
- func ValidateAddress(addr string) bool
- type Account
- type AccountMetadata
- type Accounts
- type AccountsAssetsVolumes
- func (a *AccountsAssetsVolumes) AddInput(account, asset string, input *big.Int)
- func (a *AccountsAssetsVolumes) AddOutput(account, asset string, output *big.Int)
- func (a AccountsAssetsVolumes) Balances() BalancesByAssetsByAccounts
- func (a AccountsAssetsVolumes) Copy() AccountsAssetsVolumes
- func (a AccountsAssetsVolumes) GetVolumes(account, asset string) *Volumes
- func (a AccountsAssetsVolumes) HasAccount(account string) bool
- func (a AccountsAssetsVolumes) HasAccountAndAsset(account, asset string) bool
- func (a *AccountsAssetsVolumes) Scan(value interface{}) error
- func (a *AccountsAssetsVolumes) SetVolumes(account, asset string, volumes *Volumes)
- type BalancesByAssets
- type BalancesByAssetsByAccounts
- type ChainedLog
- type DeleteMetadataLogPayload
- type ExpandedAccount
- type ExpandedTransaction
- type Log
- func NewDeleteMetadataLog(at Time, payload DeleteMetadataLogPayload) *Log
- func NewRevertedTransactionLog(at Time, revertedTxID *big.Int, tx *Transaction) *Log
- func NewSetMetadataLog(at Time, metadata SetMetadataLogPayload) *Log
- func NewSetMetadataOnAccountLog(at Time, account string, metadata metadata.Metadata) *Log
- func NewSetMetadataOnTransactionLog(at Time, txID *big.Int, metadata metadata.Metadata) *Log
- func NewTransactionLog(tx *Transaction, accountMetadata map[string]metadata.Metadata) *Log
- func NewTransactionLogWithDate(tx *Transaction, accountMetadata map[string]metadata.Metadata, time Time) *Log
- type LogType
- type NewTransactionLogPayload
- type Posting
- type Postings
- type RevertedTransactionLogPayload
- type RunScript
- type Script
- type ScriptV1
- type SetMetadataLogPayload
- type Time
- func (t Time) Add(d time.Duration) Time
- func (t Time) After(t2 Time) bool
- func (t Time) Before(t2 Time) bool
- func (t Time) Equal(t2 Time) bool
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) Round(precision time.Duration) Time
- func (t *Time) Scan(src interface{}) (err error)
- func (t Time) Sub(t2 Time) time.Duration
- func (t Time) UTC() Time
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t Time) Value() (driver.Value, error)
- type Transaction
- func (t *Transaction) WithDate(ts Time) *Transaction
- func (t *Transaction) WithID(id *big.Int) *Transaction
- func (t *Transaction) WithIDUint64(id uint64) *Transaction
- func (t *Transaction) WithMetadata(m metadata.Metadata) *Transaction
- func (t *Transaction) WithPostings(postings ...Posting) *Transaction
- func (t *Transaction) WithReference(ref string) *Transaction
- type TransactionData
- type TransactionRequest
- type Transactions
- type Volumes
- func (v Volumes) Balance() *big.Int
- func (v Volumes) CopyWithZerosIfNeeded() *Volumes
- func (v Volumes) MarshalJSON() ([]byte, error)
- func (v Volumes) WithInput(input *big.Int) *Volumes
- func (v Volumes) WithInputInt64(value int64) *Volumes
- func (v Volumes) WithOutput(output *big.Int) *Volumes
- func (v Volumes) WithOutputInt64(value int64) *Volumes
- type VolumesByAssets
- type VolumesWithBalance
Constants ¶
View Source
const ( MetaTargetTypeAccount = "ACCOUNT" MetaTargetTypeTransaction = "TRANSACTION" )
View Source
const ( DatePrecision = time.Microsecond DateFormat = time.RFC3339Nano )
View Source
const AccountPattern = "^" + AccountSegmentRegex + "(:" + AccountSegmentRegex + ")*$"
View Source
const AccountSegmentRegex = "[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*"
View Source
const AssetPattern = `[A-Z][A-Z0-9]{0,16}(\/\d{1,6})?`
View Source
const (
WORLD = "world"
)
Variables ¶
View Source
var AccountRegexp = regexp.MustCompile(AccountPattern)
View Source
var AssetRegexp = regexp.MustCompile("^" + AssetPattern + "$")
View Source
var (
ErrNoPostings = errors.New("invalid payload: should contain either postings or script")
)
View Source
var Zero = big.NewInt(0)
Functions ¶
func AssetIsValid ¶
func ComputeMetadata ¶
func RevertMetadataSpecKey ¶
func RevertMetadataSpecKey() string
func SpecMetadata ¶
func ValidateAddress ¶
Types ¶
type Account ¶
type Account struct { bun.BaseModel `bun:"table:accounts,alias:accounts"` Address string `json:"address"` Metadata metadata.Metadata `json:"metadata"` }
func NewAccount ¶
type AccountMetadata ¶
type AccountsAssetsVolumes ¶
type AccountsAssetsVolumes map[string]VolumesByAssets
func (*AccountsAssetsVolumes) AddInput ¶
func (a *AccountsAssetsVolumes) AddInput(account, asset string, input *big.Int)
func (*AccountsAssetsVolumes) AddOutput ¶
func (a *AccountsAssetsVolumes) AddOutput(account, asset string, output *big.Int)
func (AccountsAssetsVolumes) Balances ¶
func (a AccountsAssetsVolumes) Balances() BalancesByAssetsByAccounts
func (AccountsAssetsVolumes) Copy ¶
func (a AccountsAssetsVolumes) Copy() AccountsAssetsVolumes
func (AccountsAssetsVolumes) GetVolumes ¶
func (a AccountsAssetsVolumes) GetVolumes(account, asset string) *Volumes
func (AccountsAssetsVolumes) HasAccount ¶
func (a AccountsAssetsVolumes) HasAccount(account string) bool
func (AccountsAssetsVolumes) HasAccountAndAsset ¶
func (a AccountsAssetsVolumes) HasAccountAndAsset(account, asset string) bool
func (*AccountsAssetsVolumes) Scan ¶
func (a *AccountsAssetsVolumes) Scan(value interface{}) error
Scan - Implement the database/sql scanner interface
func (*AccountsAssetsVolumes) SetVolumes ¶
func (a *AccountsAssetsVolumes) SetVolumes(account, asset string, volumes *Volumes)
type BalancesByAssets ¶
type BalancesByAssetsByAccounts ¶
type BalancesByAssetsByAccounts map[string]BalancesByAssets
type ChainedLog ¶
type ChainedLog struct { Log ID *big.Int `json:"id"` Projected bool `json:"-"` Hash []byte `json:"hash"` }
func ChainLogs ¶
func ChainLogs(logs ...*Log) []*ChainedLog
func (*ChainedLog) ComputeHash ¶
func (l *ChainedLog) ComputeHash(previous *ChainedLog)
func (*ChainedLog) UnmarshalJSON ¶
func (l *ChainedLog) UnmarshalJSON(data []byte) error
func (*ChainedLog) WithID ¶
func (l *ChainedLog) WithID(id uint64) *ChainedLog
type ExpandedAccount ¶
type ExpandedAccount struct { Account `bun:",extend"` Volumes VolumesByAssets `json:"volumes,omitempty" bun:"volumes,type:jsonb"` EffectiveVolumes VolumesByAssets `json:"effectiveVolumes,omitempty" bun:"effective_volumes,type:jsonb"` }
func NewExpandedAccount ¶
func NewExpandedAccount(address string) ExpandedAccount
func (ExpandedAccount) Copy ¶
func (v ExpandedAccount) Copy() ExpandedAccount
type ExpandedTransaction ¶
type ExpandedTransaction struct { Transaction PreCommitVolumes AccountsAssetsVolumes `json:"preCommitVolumes,omitempty"` PostCommitVolumes AccountsAssetsVolumes `json:"postCommitVolumes,omitempty"` PreCommitEffectiveVolumes AccountsAssetsVolumes `json:"preCommitEffectiveVolumes,omitempty"` PostCommitEffectiveVolumes AccountsAssetsVolumes `json:"postCommitEffectiveVolumes,omitempty"` }
func ExpandTransaction ¶
func ExpandTransaction(tx *Transaction, preCommitVolumes AccountsAssetsVolumes) ExpandedTransaction
func (*ExpandedTransaction) AppendPosting ¶
func (t *ExpandedTransaction) AppendPosting(p Posting)
type Log ¶
type Log struct { Type LogType `json:"type"` Data any `json:"data"` Date Time `json:"date"` IdempotencyKey string `json:"idempotencyKey"` }
func NewDeleteMetadataLog ¶
func NewDeleteMetadataLog(at Time, payload DeleteMetadataLogPayload) *Log
func NewRevertedTransactionLog ¶
func NewRevertedTransactionLog(at Time, revertedTxID *big.Int, tx *Transaction) *Log
func NewSetMetadataLog ¶
func NewSetMetadataLog(at Time, metadata SetMetadataLogPayload) *Log
func NewTransactionLog ¶
func NewTransactionLog(tx *Transaction, accountMetadata map[string]metadata.Metadata) *Log
func (*Log) ChainLog ¶
func (l *Log) ChainLog(previous *ChainedLog) *ChainedLog
func (*Log) WithIdempotencyKey ¶
type LogType ¶
type LogType int16
func LogTypeFromString ¶
func (LogType) MarshalJSON ¶
Needed in order to keep the compatibility with the openapi response for ListLogs.
func (*LogType) UnmarshalJSON ¶
type NewTransactionLogPayload ¶
type NewTransactionLogPayload struct { Transaction *Transaction `json:"transaction"` AccountMetadata AccountMetadata `json:"accountMetadata"` }
type Posting ¶
type Postings ¶
type Postings []Posting
type RevertedTransactionLogPayload ¶
type RevertedTransactionLogPayload struct { RevertedTransactionID *big.Int `json:"revertedTransactionID"` RevertTransaction *Transaction `json:"transaction"` }
type RunScript ¶
type RunScript struct { Script Timestamp Time `json:"timestamp"` Metadata metadata.Metadata `json:"metadata"` Reference string `json:"reference"` }
func TxToScriptData ¶
func TxToScriptData(txData TransactionData, allowUnboundedOverdrafts bool) RunScript
type SetMetadataLogPayload ¶
type SetMetadataLogPayload struct { TargetType string `json:"targetType"` TargetID any `json:"targetId"` Metadata metadata.Metadata `json:"metadata"` }
func (*SetMetadataLogPayload) UnmarshalJSON ¶
func (s *SetMetadataLogPayload) UnmarshalJSON(data []byte) error
type Transaction ¶
type Transaction struct { TransactionData ID *big.Int `json:"id"` Reverted bool `json:"reverted"` }
func NewTransaction ¶
func NewTransaction() *Transaction
func (*Transaction) WithDate ¶
func (t *Transaction) WithDate(ts Time) *Transaction
func (*Transaction) WithID ¶
func (t *Transaction) WithID(id *big.Int) *Transaction
func (*Transaction) WithIDUint64 ¶
func (t *Transaction) WithIDUint64(id uint64) *Transaction
func (*Transaction) WithMetadata ¶
func (t *Transaction) WithMetadata(m metadata.Metadata) *Transaction
func (*Transaction) WithPostings ¶
func (t *Transaction) WithPostings(postings ...Posting) *Transaction
func (*Transaction) WithReference ¶
func (t *Transaction) WithReference(ref string) *Transaction
type TransactionData ¶
type TransactionData struct { Postings Postings `json:"postings"` Metadata metadata.Metadata `json:"metadata"` Timestamp Time `json:"timestamp"` Reference string `json:"reference,omitempty"` }
func NewTransactionData ¶
func NewTransactionData() TransactionData
func (*TransactionData) Reverse ¶
func (t *TransactionData) Reverse() TransactionData
func (TransactionData) WithDate ¶
func (d TransactionData) WithDate(now Time) TransactionData
func (TransactionData) WithPostings ¶
func (d TransactionData) WithPostings(postings ...Posting) TransactionData
type TransactionRequest ¶
type TransactionRequest struct { Postings Postings `json:"postings"` Script ScriptV1 `json:"script"` Timestamp Time `json:"timestamp"` Reference string `json:"reference"` Metadata metadata.Metadata `json:"metadata" swaggertype:"object"` }
func (*TransactionRequest) ToRunScript ¶
func (req *TransactionRequest) ToRunScript() *RunScript
type Transactions ¶
type Transactions struct {
Transactions []TransactionData `json:"transactions"`
}
type Volumes ¶
func NewEmptyVolumes ¶
func NewEmptyVolumes() *Volumes
func NewVolumesInt64 ¶
func (Volumes) CopyWithZerosIfNeeded ¶
func (Volumes) MarshalJSON ¶
func (Volumes) WithInputInt64 ¶
func (Volumes) WithOutputInt64 ¶
type VolumesByAssets ¶
func (VolumesByAssets) Balances ¶
func (v VolumesByAssets) Balances() BalancesByAssets
Source Files
¶
Click to show internal directories.
Click to hide internal directories.