common

package
v0.73.0-preview.16 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: AGPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SignerPubKeyPrepend = 0x00
	ETHAddressPrepend   = 0x01
)

Variables

This section is empty.

Functions

func SignersIntoProto

func SignersIntoProto(s []*Signer) []*datapb.Signer

SignersIntoProto returns a list of signers after checking the list length.

func SignersToStringList

func SignersToStringList(s []*Signer) []string

func SpecPropertyKeyIsEmpty

func SpecPropertyKeyIsEmpty(key *SpecPropertyKey) bool

func ToBoolean

func ToBoolean(value string) (bool, error)

func ToDecimal

func ToDecimal(value string) (num.Decimal, error)

func ToInteger

func ToInteger(value string) (*num.Int, error)

func ToTimestamp

func ToTimestamp(value string) (int64, error)

Types

type Data

type Data struct {
	// EthKey is currently just the spec id, which is suboptimal as multiple specs calling the same
	// contracts at the same time will duplicate data. This is a temporary solution until we have
	// a better method of making a key of (contract address, args, block height/time + previous height/time)
	// 'previous' being required so that receivers can check if the their trigger would have fired.
	EthKey   string
	Signers  []*Signer
	Data     map[string]string
	MetaData map[string]string
}

Data holds normalized data coming from an oracle.

func (Data) Debug

func (d Data) Debug() []zap.Field

func (Data) FromInternalOracle

func (d Data) FromInternalOracle() bool

FromInternalOracle returns true if the oracle data has been emitted by an internal oracle.

func (Data) GetBoolean

func (d Data) GetBoolean(propertyName string) (bool, error)

GetBoolean converts the value associated to propertyName into a boolean.

func (Data) GetDecimal

func (d Data) GetDecimal(propertyName string) (num.Decimal, error)

GetDecimal converts the value associated to propertyName into a decimal.

func (Data) GetInteger

func (d Data) GetInteger(propertyName string) (*num.Int, error)

GetInteger converts the value associated to propertyName into an integer.

func (Data) GetString

func (d Data) GetString(propertyName string) (string, error)

GetString returns the value associated to propertyName.

func (Data) GetTimestamp

func (d Data) GetTimestamp(propertyName string) (int64, error)

GetTimestamp converts the value associated to propertyName into a timestamp.

func (Data) GetUint

func (d Data) GetUint(name string) (*num.Uint, error)

type DataSourceType

type DataSourceType interface {
	String() string
	DeepClone() DataSourceType
	ToDefinitionProto() (*vegapb.DataSourceDefinition, error)
	GetFilters() []*SpecFilter
}

type ETHAddress

type ETHAddress struct {
	Address string
}

ETHAddress.

func (ETHAddress) DeepClone

func (e ETHAddress) DeepClone() *ETHAddress

func (ETHAddress) IntoProto

func (e ETHAddress) IntoProto() *datapb.ETHAddress

func (ETHAddress) String

func (e ETHAddress) String() string

type Filters

type Filters struct {
	// contains filtered or unexported fields
}

func NewFilters

func NewFilters(filtersFromSpec []*SpecFilter, isExtType bool) (Filters, error)

func (Filters) EnsureBoundableProperty

func (f Filters) EnsureBoundableProperty(property string, propType datapb.PropertyKey_Type) error

func (Filters) Match

func (f Filters) Match(data map[string]string) (bool, error)

type InternalTimeTrigger

type InternalTimeTrigger struct {
	// This is optional to reflect the proto, but it will always be set by the governance
	Initial *time.Time
	Every   int64
	// contains filtered or unexported fields
}

func InternalTimeTriggerFromProto

func InternalTimeTriggerFromProto(
	protoTrigger *datapb.InternalTimeTrigger,
) *InternalTimeTrigger

func (InternalTimeTrigger) DeepClone

func (InternalTimeTrigger) IntoProto

func (InternalTimeTrigger) IsTriggered

func (i InternalTimeTrigger) IsTriggered(timeNow time.Time) bool

func (*InternalTimeTrigger) SetInitial

func (i *InternalTimeTrigger) SetInitial(initial, timeNow time.Time)

func (*InternalTimeTrigger) SetNextTrigger

func (i *InternalTimeTrigger) SetNextTrigger(timeNow time.Time)

func (InternalTimeTrigger) String

func (i InternalTimeTrigger) String() string

type InternalTimeTriggers

type InternalTimeTriggers [1]*InternalTimeTrigger

func InternalTimeTriggersFromProto

func InternalTimeTriggersFromProto(protoTriggers []*datapb.InternalTimeTrigger) InternalTimeTriggers

func (InternalTimeTriggers) DeepClone

func (InternalTimeTriggers) Empty

func (i InternalTimeTriggers) Empty() error

func (InternalTimeTriggers) IntoProto

func (InternalTimeTriggers) IsTriggered

func (i InternalTimeTriggers) IsTriggered(now time.Time) bool

func (InternalTimeTriggers) String

func (i InternalTimeTriggers) String() string

type PubKey

type PubKey struct {
	Key string
}

PubKey.

func (PubKey) DeepClone

func (p PubKey) DeepClone() *PubKey

func (PubKey) IntoProto

func (p PubKey) IntoProto() *datapb.PubKey

func (PubKey) String

func (p PubKey) String() string

type Signer

type Signer struct {
	Signer signer
}

func CreateSignerFromString

func CreateSignerFromString(s string, t SignerType) *Signer

func DeserializeSigner

func DeserializeSigner(content []byte) *Signer

func NewSigner

func NewSigner(t SignerType) *Signer

func SignerAsHex

func SignerAsHex(signer *Signer) (*Signer, error)

SignerAsHex represents the signer as a hex encoded string. We export this function as a standalone option because there are cases when we are not sure what is the signer type we deal with.

func SignerAsString

func SignerAsString(signer *Signer) (*Signer, error)

SignerAsString represents the Signer content as a string.

func SignerFromProto

func SignerFromProto(s *datapb.Signer) *Signer

func SignersFromProto

func SignersFromProto(s []*datapb.Signer) []*Signer

SignersFromProto returns a list of signers. The list is allowed to be empty.

func (Signer) DeepClone

func (s Signer) DeepClone() *Signer

func (Signer) GetSignerETHAddress

func (s Signer) GetSignerETHAddress() *ETHAddress

func (Signer) GetSignerPubKey

func (s Signer) GetSignerPubKey() *PubKey

func (Signer) GetSignerType

func (s Signer) GetSignerType() SignerType

func (Signer) IntoProto

func (s Signer) IntoProto() *datapb.Signer

IntoProto will always return a `datapb.Signer` that needs to be checked if it has any content afterwards.

func (Signer) IsEmpty

func (s Signer) IsEmpty() bool

func (*Signer) Serialize

func (s *Signer) Serialize() ([]byte, error)

SerializeSigner deserializes the signer to a byte slice - we use that type top insert it into the database. The deserialization prepends the slice with two bytes as signer type indicator - that is used when the Signer is serialized back.

func (Signer) String

func (s Signer) String() string

type SignerETHAddress

type SignerETHAddress struct {
	ETHAddress *ETHAddress
}

func DeserializeETHAddress

func DeserializeETHAddress(data []byte) *SignerETHAddress

func ETHAddressFromProto

func ETHAddressFromProto(s *datapb.Signer_EthAddress) *SignerETHAddress

func (SignerETHAddress) AsHex

func (s SignerETHAddress) AsHex(prepend bool) (signer, error)

func (SignerETHAddress) AsString

func (s SignerETHAddress) AsString() (signer, error)

func (SignerETHAddress) DeepClone

func (s SignerETHAddress) DeepClone() signer

func (SignerETHAddress) GetSignerType

func (s SignerETHAddress) GetSignerType() SignerType

func (SignerETHAddress) IntoProto

func (s SignerETHAddress) IntoProto() *datapb.Signer_EthAddress

func (SignerETHAddress) IsEmpty

func (s SignerETHAddress) IsEmpty() bool

func (SignerETHAddress) Serialize

func (s SignerETHAddress) Serialize() []byte

func (SignerETHAddress) String

func (s SignerETHAddress) String() string

type SignerPubKey

type SignerPubKey struct {
	PubKey *PubKey
}

func DeserializePubKey

func DeserializePubKey(data []byte) *SignerPubKey

func PubKeyFromProto

func PubKeyFromProto(s *datapb.Signer_PubKey) *SignerPubKey

func (SignerPubKey) AsHex

func (s SignerPubKey) AsHex(prepend bool) (signer, error)

func (SignerPubKey) AsString

func (s SignerPubKey) AsString() (signer, error)

func (SignerPubKey) DeepClone

func (s SignerPubKey) DeepClone() signer

func (SignerPubKey) GetSignerType

func (s SignerPubKey) GetSignerType() SignerType

func (SignerPubKey) IntoProto

func (s SignerPubKey) IntoProto() *datapb.Signer_PubKey

func (SignerPubKey) IsEmpty

func (s SignerPubKey) IsEmpty() bool

func (SignerPubKey) Serialize

func (s SignerPubKey) Serialize() []byte

func (SignerPubKey) String

func (s SignerPubKey) String() string

type SignerType

type SignerType int
const (
	SignerTypeUnspecified SignerType = iota
	SignerTypePubKey
	SignerTypeEthAddress
)

type SpecCondition

type SpecCondition struct {
	Operator SpecConditionOperator
	Value    string
}

SpecCondition mirrors datapb.Condition type.

func DeepCloneSpecConditions

func DeepCloneSpecConditions(conditions []*SpecCondition) []*SpecCondition

func SpecConditionFromProto

func SpecConditionFromProto(protoCondition *datapb.Condition) *SpecCondition

func SpecConditionsFromProto

func SpecConditionsFromProto(protoConditions []*datapb.Condition) []*SpecCondition

func (*SpecCondition) DeepClone

func (c *SpecCondition) DeepClone() *SpecCondition

func (SpecCondition) IntoProto

func (c SpecCondition) IntoProto() *datapb.Condition

func (SpecCondition) String

func (c SpecCondition) String() string

type SpecConditionOperator

type SpecConditionOperator = datapb.Condition_Operator

type SpecConditions

type SpecConditions []*SpecCondition

func (SpecConditions) IntoProto

func (sc SpecConditions) IntoProto() []*datapb.Condition

func (SpecConditions) String

func (sc SpecConditions) String() string

type SpecFilter

type SpecFilter struct {
	Key        *SpecPropertyKey
	Conditions []*SpecCondition
}

func DeepCloneSpecFilters

func DeepCloneSpecFilters(filters []*SpecFilter) []*SpecFilter

func SpecFilterFromProto

func SpecFilterFromProto(protoFilter *datapb.Filter) *SpecFilter

func SpecFiltersFromProto

func SpecFiltersFromProto(protoFilters []*datapb.Filter) []*SpecFilter

func (*SpecFilter) DeepClone

func (f *SpecFilter) DeepClone() *SpecFilter

DeepClone clones the filter receiver taking into account if its fields are empty.

func (*SpecFilter) IntoProto

func (f *SpecFilter) IntoProto() *datapb.Filter

IntoProto return proto version of the filter receiver taking into account if its fields are empty.

func (SpecFilter) String

func (f SpecFilter) String() string

type SpecFilters

type SpecFilters []*SpecFilter

func (SpecFilters) IntoProto

func (df SpecFilters) IntoProto() []*datapb.Filter

func (SpecFilters) String

func (df SpecFilters) String() string

type SpecPropertyKey

type SpecPropertyKey struct {
	Name                string
	Type                SpecPropertyKeyType
	NumberDecimalPlaces *uint64
}

func SpecPropertyKeyFromProto

func SpecPropertyKeyFromProto(protoKey *datapb.PropertyKey) *SpecPropertyKey

func (*SpecPropertyKey) DeepClone

func (k *SpecPropertyKey) DeepClone() *SpecPropertyKey

func (SpecPropertyKey) IntoProto

func (k SpecPropertyKey) IntoProto() *datapb.PropertyKey

func (SpecPropertyKey) String

func (k SpecPropertyKey) String() string

type SpecPropertyKeyType

type SpecPropertyKeyType = datapb.PropertyKey_Type

type SpecSigners

type SpecSigners []*Signer

func (SpecSigners) String

func (s SpecSigners) String() string

type SpecStatus

type SpecStatus = vegapb.DataSourceSpec_Status

type Timer

type Timer interface {
	DataSourceType
	IsTriggered(time.Time) bool
	GetTimeTriggers() InternalTimeTriggers
}

Jump to

Keyboard shortcuts

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