parser

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 35 Imported by: 0

Documentation

Overview

Package parser provides the logic to parse and store events.

Index

Constants

View Source
const ErrUnknownTopic = "unknown topic"

ErrUnknownTopic is returned when the topic is unknown.

Variables

This section is empty.

Functions

func BoolToUint8

func BoolToUint8(input *bool) *uint8

BoolToUint8 is a helper function to handle bool to uint8 conversion for clickhouse.

func GetAdjustedAmount added in v0.0.81

func GetAdjustedAmount(amount *big.Int, decimals uint8) *float64

GetAdjustedAmount computes the adjusted token amount.

func GetAmountUSD

func GetAmountUSD(amount *big.Int, decimals uint8, price *float64) *float64

GetAmountUSD computes the USD value of a token amount.

func ParseYaml added in v0.0.31

func ParseYaml(yamlFile []byte) (res map[string]string, err error)

ParseYaml opens yaml file with coin gecko ID mapping and returns it.

func ToNullBool added in v0.4.4

func ToNullBool(b *bool) sql.NullBool

ToNullBool is a helper function to convert values to null bool.

func ToNullInt32 added in v0.0.138

func ToNullInt32[T int32 | uint32](val *T) sql.NullInt32

ToNullInt32 is a helper function to convert values to null string.

func ToNullInt64 added in v0.0.138

func ToNullInt64[T int64 | uint64](val *T) sql.NullInt64

ToNullInt64 is a helper function to convert values to null string.

func ToNullString

func ToNullString(str *string) sql.NullString

ToNullString is a helper function to convert values to null string.

Types

type BridgeParser

type BridgeParser struct {

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

BridgeParser parses events from the bridge contract.

func NewBridgeParser

func NewBridgeParser(consumerDB db.ConsumerDB, bridgeAddress common.Address, tokenDataService tokendata.Service, consumerFetcher fetcher.ScribeFetcher, tokenPriceService tokenprice.Service, fromAPI bool) (*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) MatureLogs added in v0.0.176

func (p *BridgeParser) MatureLogs(ctx context.Context, bridgeEvent *model.BridgeEvent, iFace bridgeTypes.EventLog, chainID uint32) (interface{}, error)

MatureLogs takes a bridge event and matures it by fetching the sender and timestamp from the API and more.

nolint:gocognit,cyclop

func (*BridgeParser) Parse added in v0.0.31

func (p *BridgeParser) Parse(ctx context.Context, log ethTypes.Log, chainID uint32) (interface{}, error)

Parse parses the bridge logs and returns a model that can be stored.

func (*BridgeParser) ParseLog added in v0.0.176

func (p *BridgeParser) ParseLog(log ethTypes.Log, chainID uint32) (*model.BridgeEvent, bridgeTypes.EventLog, error)

ParseLog parses the bridge logs and returns a model that can be stored.

nolint:gocognit,cyclop

func (*BridgeParser) ParserType added in v0.0.156

func (p *BridgeParser) ParserType() string

ParserType returns the type of parser.

type CCTPParser added in v0.0.138

type CCTPParser struct {

	// Filterer is the message Filterer we use to parse events
	Filterer *cctp.SynapseCCTPFilterer
	// contains filtered or unexported fields
}

CCTPParser parses cctp logs.

func NewCCTPParser added in v0.0.138

func NewCCTPParser(consumerDB db.ConsumerDB, cctpAddress common.Address, consumerFetcher fetcher.ScribeFetcher, cctpService fetcher.CCTPService, tokenDataService tokendata.Service, tokenPriceService tokenprice.Service, fromAPI bool) (*CCTPParser, error)

NewCCTPParser creates a new parser for a cctp event.

func (*CCTPParser) MatureLogs added in v0.0.176

func (c *CCTPParser) MatureLogs(ctx context.Context, cctpEvent *model.CCTPEvent, iFace cctpTypes.EventLog, chainID uint32) (interface{}, error)

MatureLogs takes a cctp event and adds data to them.

func (*CCTPParser) Parse added in v0.0.138

func (c *CCTPParser) Parse(ctx context.Context, log ethTypes.Log, chainID uint32) (interface{}, error)

Parse parses the cctp logs.

nolint:gocognit,cyclop,dupl

func (*CCTPParser) ParseLog added in v0.0.176

func (c *CCTPParser) ParseLog(log ethTypes.Log, chainID uint32) (*model.CCTPEvent, cctpTypes.EventLog, error)

ParseLog log converts an eth log to a cctp event type.

func (*CCTPParser) ParserType added in v0.0.156

func (c *CCTPParser) ParserType() string

ParserType returns the type of parser.

type MessageBusParser added in v0.0.19

type MessageBusParser struct {

	// Filterer is the message Filterer we use to parse events
	Filterer *messagebus.MessageBusUpgradeableFilterer
	// contains filtered or unexported fields
}

MessageBusParser parses messagebus logs.

func NewMessageBusParser added in v0.0.19

func NewMessageBusParser(consumerDB db.ConsumerDB, messageBusAddress common.Address, consumerFetcher fetcher.ScribeFetcher, tokenPriceService tokenprice.Service) (*MessageBusParser, error)

NewMessageBusParser creates a new parser for a given message.

func (*MessageBusParser) EventType added in v0.0.19

func (m *MessageBusParser) EventType(log ethTypes.Log) (_ messageBusTypes.EventType, ok bool)

EventType returns the event type of a message log.

func (*MessageBusParser) Parse added in v0.0.31

func (m *MessageBusParser) Parse(ctx context.Context, log ethTypes.Log, chainID uint32) (interface{}, error)

Parse parses the message logs.

nolint:gocognit,cyclop,dupl

func (*MessageBusParser) ParserType added in v0.0.156

func (m *MessageBusParser) ParserType() string

ParserType returns the type of parser.

type Parser

type Parser interface {
	// Parse parses the logs and returns the parsed data.
	Parse(ctx context.Context, log ethTypes.Log, chainID uint32) (interface{}, error)
	// ParserType returns the type of the parser.
	ParserType() string
}

Parser parses events and stores them.

type RFQParser added in v0.4.4

type RFQParser struct {

	// Filterer is the message Filterer we use to parse events
	Filterer *fastbridge.FastBridgeFilterer
	// contains filtered or unexported fields
}

RFQParser parsers rfq logs.

func NewRFQParser added in v0.4.4

func NewRFQParser(consumerDB db.ConsumerDB, rfqAddress common.Address, consumerFetcher fetcher.ScribeFetcher, rfqService fetcher.RFQService, tokenDataService tokendata.Service, tokenPriceService tokenprice.Service, fromAPI bool) (*RFQParser, error)

NewRFQParser creates a new RFQParser.

func (*RFQParser) MatureLogs added in v0.4.4

func (p *RFQParser) MatureLogs(ctx context.Context, rfqEvent *model.RFQEvent, iFace rfqTypes.EventLog, chainID uint32) (interface{}, error)

MatureLogs takes a rfq event and adds data to them.

func (*RFQParser) Parse added in v0.4.4

func (p *RFQParser) Parse(ctx context.Context, log ethTypes.Log, chainID uint32) (interface{}, error)

Parse parses the rfq logs.

nolint:gocognit,cyclop,dupl

func (*RFQParser) ParseLog added in v0.4.4

func (p *RFQParser) ParseLog(log ethTypes.Log, chainID uint32) (*model.RFQEvent, rfqTypes.EventLog, error)

ParseLog log converts an eth log to a rfq event type.

func (*RFQParser) ParserType added in v0.4.4

func (p *RFQParser) ParserType() string

ParserType returns the type of parser.

type SwapParser

type SwapParser struct {

	// Filterer is the swap Filterer we use to parse events.
	Filterer *swap.SwapFlashLoanFilterer

	// FiltererMetaSwap is the meta swap Filterer we use to parse events.
	FiltererMetaSwap *metaswap.MetaSwapFilterer
	// contains filtered or unexported fields
}

SwapParser parses events from the swap contract.

func NewSwapParser

func NewSwapParser(consumerDB db.ConsumerDB, swapAddress common.Address, metaSwap bool, consumerFetcher fetcher.ScribeFetcher, swapService fetcher.SwapService, tokenDataService tokendata.Service, tokenPriceService tokenprice.Service) (*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) GetCorrectSwapFee added in v0.0.81

func (p *SwapParser) GetCorrectSwapFee(ctx context.Context, swapEvent model.SwapEvent) (uint64, uint64, error)

GetCorrectSwapFee returns the correct swap fee for the given pool contract.

func (*SwapParser) Parse added in v0.0.31

func (p *SwapParser) Parse(ctx context.Context, log ethTypes.Log, chainID uint32) (interface{}, error)

Parse parses the swap logs.

func (*SwapParser) ParserType added in v0.0.156

func (p *SwapParser) ParserType() string

ParserType returns the type of parser.

Directories

Path Synopsis
Package tokendata contains the token data service
Package tokendata contains the token data service
Package tokenpool contains the token pool data service
Package tokenpool contains the token pool data service

Jump to

Keyboard shortcuts

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