query

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 3 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolExpression

type BoolExpression struct {
	// should have minimum length of two
	Expressions []Expression
	BoolOperator
}

BoolExpression allows nesting of boolean expressions with different BoolOperator's.

type BoolOperator

type BoolOperator int
const (
	AND BoolOperator = iota
	OR
)

func (BoolOperator) String

func (op BoolOperator) String() string

type CursorDirection

type CursorDirection int32
const (
	CursorPrevious CursorDirection = iota + 1
	CursorFollowing
)

type Expression

type Expression struct {
	Primitive      primitives.Primitive
	BoolExpression BoolExpression
}

Expression contains either a Primitive or a BoolExpression.

func And

func And(expressions ...Expression) Expression

func Block

func Block(block string, operator primitives.ComparisonOperator) Expression

func Comparator

func Comparator(name string, valueComparators ...primitives.ValueComparator) Expression

Comparator is used for filtering through specific key values. e.g. of filtering for key that belongs to a token transfer by values: Comparator("transferValue", [{"150",LTE}, {"300",GTE}])

func Confidence

func Confidence(confLevel primitives.ConfidenceLevel) Expression

func Or

func Or(expressions ...Expression) Expression

func Timestamp

func Timestamp(timestamp uint64, operator primitives.ComparisonOperator) Expression

func TxHash

func TxHash(txHash string) Expression

func (Expression) IsPrimitive

func (expr Expression) IsPrimitive() bool

type KeyFilter

type KeyFilter struct {
	// Key points to the underlying chain contract address and some data that belongs to that contract.
	// Depending on the underlying Contract Reader blockchain implementation key can map to different onchain concepts, but should be able to map differing onchain data to same offchain data if they belong to the same key.
	Key string
	// The base Expressions slice indicates AND logical operation over expressions, which can be primitives or nested boolean expressions.
	// For eg. []Expression{primitive, primitive, BoolExpression{AND, primitive, BoolExpression{OR, primitive, primitive}} is primitive AND primitive AND (primitive AND (primitive OR primitive)).
	Expressions []Expression
}

KeyFilter is used to filter down chain specific data related to a key.

func IndexedSequencesByBlockRangeKeyFilter added in v0.4.0

func IndexedSequencesByBlockRangeKeyFilter(
	readName string,
	start, end string,
	comparatorName string,
	values []string,
) KeyFilter

IndexedSequencesByBlockRangeKeyFilter creates a KeyFilter that filters sequences for the provided property values at the specified property name. Value filters are 'OR'ed together and results are limited by provided cursor range. A read name is the value that identifies the sequence type. The signature property name is the sequence property to apply the filter to and the sequence values are the individual values to search for in the provided property.

func IndexedSequencesByTxHashKeyFilter added in v0.4.0

func IndexedSequencesByTxHashKeyFilter(
	readName, txHash string,
) KeyFilter

IndexedSequencesByTxHashKeyFilter creates a KeyFilter that filters logs for the provided transaction hash. A sequence read name is the value that identifies the sequence type.

func IndexedSequencesCreatedAfterKeyFilter added in v0.4.0

func IndexedSequencesCreatedAfterKeyFilter(
	readName string,
	comparatorName string,
	values []string,
	timestamp time.Time,
	confidence primitives.ConfidenceLevel,
) KeyFilter

IndexedSequencesCreatedAfterKeyFilter creates a KeyFilter that filters sequences for the provided property and values created after the provided time value. Sequence property values filters are 'OR'ed. A sequence read name is the value that identifies the sequence type.

func IndexedSequencesKeyFilter added in v0.4.0

func IndexedSequencesKeyFilter(
	readName string,
	comparatorName string,
	values []string,
	confidence primitives.ConfidenceLevel,
) KeyFilter

IndexedSequencesKeyFilter creates a KeyFilter that filters logs for the provided sequence property values at the specified property name. Sequence value filters are 'OR'ed together. A sequence read name is the value that identifies the sequence type. The signature value name is the sequence property to apply the filter to and the sequence values are the individual values to search for in the provided property.

func IndexedSequencesValueGreaterThanKeyFilter added in v0.4.0

func IndexedSequencesValueGreaterThanKeyFilter(
	readName string,
	comparatorName, value string,
	confidence primitives.ConfidenceLevel,
) KeyFilter

IndexedSequencesValueGreaterThanKeyFilter creates a KeyFilter that filters sequences for the provided property value and name at or above the specified confidence level. A sequence read name is the value that identifies the sequence type. The property name is the sequence property to apply the filter to and the value is the individual value to search for in the provided property.

func IndexedSequencesValueRangeKeyFilter added in v0.4.0

func IndexedSequencesValueRangeKeyFilter(
	readName string,
	comparatorName string,
	min, max string,
	confidence primitives.ConfidenceLevel,
) KeyFilter

IndexedSequencesValueRangeKeyFilter creates a KeyFilter that filters logs on the provided sequence property between the provided min and max, endpoints inclusive. A sequence read name is the value that identifies the sequence type.

func SequencesByBlockRangeKeyFilter added in v0.4.0

func SequencesByBlockRangeKeyFilter(
	readName string,
	start, end string,
) KeyFilter

SequencesByBlockRangeKeyFilter creates a KeyFilter that filters sequences for the provided block range, endpoints inclusive.

func SequencesCreatedAfterKeyFilter added in v0.4.0

func SequencesCreatedAfterKeyFilter(
	readName string,
	timestamp time.Time,
	confidence primitives.ConfidenceLevel,
) KeyFilter

SequencesCreatedAfterKeyFilter creates a KeyFilter that filters sequences for after but not equal to the provided time value.

func Where

func Where(key string, expressions ...Expression) (KeyFilter, error)

Where is a helper function for building KeyFilter, eg. usage:

queryFilter, err := Where(
		"key",
		TxHash("0xHash"),
		Block(startBlock, Gte),
		Block(endBlock, Lte),
		Or(
			And(
				Timestamp(someTs1, Gte),
				Timestamp(otherTs1, Lte)),
			And(
				Timestamp(someTs2, Gte),
				Timestamp(otherTs2, Lte)),
		),
	)
Equals:`txHash = '0xHash' AND
		block > startBlock AND
		block < endBlock   AND
		((timestamp > someTs1 And timestamp < otherTs1)
			OR
		(timestamp > someTs2 And timestamp < otherTs2))`

type Limit

type Limit struct {
	Cursor          string
	CursorDirection CursorDirection
	Count           uint64
}

func CountLimit

func CountLimit(count uint64) Limit

func CursorLimit

func CursorLimit(cursor string, cursorDirection CursorDirection, count uint64) Limit

type LimitAndSort

type LimitAndSort struct {
	SortBy []SortBy
	Limit  Limit
}

func NewLimitAndSort

func NewLimitAndSort(limit Limit, sortBy ...SortBy) LimitAndSort

func (LimitAndSort) HasCursorLimit

func (p LimitAndSort) HasCursorLimit() bool

func (LimitAndSort) HasSequenceSort

func (p LimitAndSort) HasSequenceSort() bool

type SortBy

type SortBy interface {
	GetDirection() SortDirection
}

type SortByBlock

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

func NewSortByBlock

func NewSortByBlock(sortDir SortDirection) SortByBlock

func (SortByBlock) GetDirection

func (o SortByBlock) GetDirection() SortDirection

type SortBySequence

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

func NewSortBySequence

func NewSortBySequence(sortDir SortDirection) SortBySequence

func (SortBySequence) GetDirection

func (o SortBySequence) GetDirection() SortDirection

type SortByTimestamp

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

func NewSortByTimestamp

func NewSortByTimestamp(sortDir SortDirection) SortByTimestamp

func (SortByTimestamp) GetDirection

func (o SortByTimestamp) GetDirection() SortDirection

type SortDirection

type SortDirection int
const (
	Asc SortDirection = iota
	Desc
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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