retriever

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoAddress    = errors.New("event without address")
	ErrNotSupported = errors.New("unsupported event type")
)

Rosetta Sentinel Errors.

Functions

func WithTransactionLimit

func WithTransactionLimit(limit uint) func(*Config)

WithTransactionLimit sets a transaction limit in a Config.

Types

type Config

type Config struct {
	TransactionLimit uint
}

Config is the configuration for the Rosetta retriever component.

type Converter

type Converter interface {
	EventToOperation(event flow.Event) (operation *object.Operation, err error)
}

Converter represents something that can convert Flow events into Rosetta operations.

type Generator

type Generator interface {
	GetBalance(symbol string) ([]byte, error)
	TokensDeposited(symbol string) (string, error)
	TokensWithdrawn(symbol string) (string, error)
}

Generator represents something that can generate scripts for retrieving balances as well as the amounts deposited and withdrawn for a given token.

type Invoker

type Invoker interface {
	Key(height uint64, address flow.Address, index int) (*flow.AccountPublicKey, error)
	Script(height uint64, script []byte, parameters []cadence.Value) (cadence.Value, error)
}

Invoker represents something that can retrieve public keys at any given height, and execute scripts to retrieve values from the Flow Virtual Machine.

type Retriever

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

Retriever is a component that retrieves information from the DPS index and converts it into a format that is appropriate for the Rosetta API.

func New

func New(params dps.Params, index dps.Reader, validate Validator, generator Generator, invoke Invoker, convert Converter, options ...func(*Config)) *Retriever

New instantiates and returns a Retriever using the injected dependencies, as well as the provided options.

func (*Retriever) Balances

func (r *Retriever) Balances(rosBlockID identifier.Block, rosAccountID identifier.Account, rosCurrencies []identifier.Currency) (identifier.Block, []object.Amount, error)

Balances retrieves the balances for the given currencies of the given account ID at the given block.

func (*Retriever) Block

func (r *Retriever) Block(rosBlockID identifier.Block) (*object.Block, []identifier.Transaction, error)

Block retrieves a block and its transactions given its identifier.

func (*Retriever) Current

func (r *Retriever) Current() (identifier.Block, time.Time, error)

Current retrieves the last block identifier as well as its timestamp.

func (*Retriever) Oldest

func (r *Retriever) Oldest() (identifier.Block, time.Time, error)

Oldest retrieves the oldest block identifier as well as its timestamp.

func (*Retriever) Sequence added in v1.2.0

func (r *Retriever) Sequence(rosBlockID identifier.Block, rosAccountID identifier.Account, index int) (uint64, error)

Sequence retrieves the sequence number of an account's public key.

func (*Retriever) Transaction

func (r *Retriever) Transaction(rosBlockID identifier.Block, rosTxID identifier.Transaction) (*object.Transaction, error)

Transaction retrieves a transaction given its identifier and the identifier of the block it is a part of.

type Validator

type Validator interface {
	Account(rosAccountID identifier.Account) (address flow.Address, err error)
	Block(rosBlockID identifier.Block) (height uint64, blockID flow.Identifier, err error)
	Transaction(rosTxID identifier.Transaction) (txID flow.Identifier, err error)
	Currency(rosCurrency identifier.Currency) (symbol string, decimals uint, err error)
}

Validator represents something that can validate account, block and transaction identifiers as well as currencies.

Jump to

Keyboard shortcuts

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