consumer

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package consumer provides a consumer for the database. It deals with querying, parsing, and storing logs.

Index

Constants

This section is empty.

Variables

View Source
var ErrTokenDoesNotExist = errors.New("token id does not exist")

ErrTokenDoesNotExist indicates the queried for token does not exist.

Functions

This section is empty.

Types

type BridgeConfigFetcher

type BridgeConfigFetcher struct {
	// contains filtered or unexported fields

} // TODO switch bridge config based on block number

BridgeConfigFetcher is the fetcher for the bridge config contract.

func NewBridgeConfigFetcher

func NewBridgeConfigFetcher(bridgeConfigAddress common.Address, backend bind.ContractBackend) (*BridgeConfigFetcher, error)

NewBridgeConfigFetcher creates a new config fetcher. Backend must be an archive backend.

func (*BridgeConfigFetcher) GetToken

func (b *BridgeConfigFetcher) GetToken(ctx context.Context, chainID, block uint32, tokenID string) (token *bridgeconfig.BridgeConfigV3Token, err error)

GetToken gets the token from the bridge config contract.

func (*BridgeConfigFetcher) GetTokenID

func (b *BridgeConfigFetcher) GetTokenID(ctx context.Context, chainID uint32, tokenAddress common.Address) (tokenID *string, err error)

GetTokenID gets the token id from the bridge config contract.

type BridgeParser

type BridgeParser struct {

	// Filterer is the bridge Filterer we use to parse events
	Filterer *bridge.SynapseBridgeFilterer
	// contains filtered or unexported fields
}

BridgeParser parses events from the bridge contract.

func NewBridgeParser

func NewBridgeParser(consumerDB db.ConsumerDB, bridgeAddress common.Address, bridgeConfigFetcher BridgeConfigFetcher) (*BridgeParser, error)

NewBridgeParser creates a new parser for a given bridge.

func (*BridgeParser) EventType

func (p *BridgeParser) EventType(log ethTypes.Log) (_ bridgeTypes.EventType, ok bool)

EventType returns the event type of a bridge log.

func (*BridgeParser) ParseAndStore

func (p *BridgeParser) ParseAndStore(ctx context.Context, log ethTypes.Log, chainID uint32) error

ParseAndStore parses the bridge logs and stores them in the database.

nolint:gocognit,cyclop,dupl

type Fetcher

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

Fetcher is the fetcher for the events. It uses GQL.

func NewFetcher

func NewFetcher(fetchClient *client.Client) *Fetcher

NewFetcher creates a new fetcher.

func (Fetcher) FetchLogsInRange

func (f Fetcher) FetchLogsInRange(ctx context.Context, chainID uint32, startBlock, endBlock uint64) ([]ethTypes.Log, error)

FetchLogsInRange fetches logs in a range with the GQL client.

type Parser

type Parser interface {
	// ParseAndStore parses the logs and stores them in the database.
	ParseAndStore(ctx context.Context, log ethTypes.Log, chainID uint32) error
}

Parser parses events and stores them.

type SwapParser

type SwapParser struct {

	// Filterer is the swap Filterer we use to parse events
	Filterer *swap.SwapFlashLoanFilterer
	// contains filtered or unexported fields
}

SwapParser parses events from the swap contract.

func NewSwapParser

func NewSwapParser(consumerDB db.ConsumerDB, swapAddress common.Address) (*SwapParser, error)

NewSwapParser creates a new parser for a given bridge.

func (*SwapParser) EventType

func (p *SwapParser) EventType(log ethTypes.Log) (_ swapTypes.EventType, ok bool)

EventType returns the event type of a swap log.

func (*SwapParser) ParseAndStore

func (p *SwapParser) ParseAndStore(ctx context.Context, log ethTypes.Log, chainID uint32) error

ParseAndStore parses and stores the swap logs.

Directories

Path Synopsis
Package backfill provides a command to backfill the consumer database.
Package backfill provides a command to backfill the consumer database.
Package client provides a GraphQL client for consuming logs.
Package client provides a GraphQL client for consuming logs.
contrib
Package main generates a GQL client.
Package main generates a GQL client.

Jump to

Keyboard shortcuts

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