decoder

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ABI

type ABI []ABIItem

type ABIInput

type ABIInput struct {
	Indexed      bool   `json:"indexed,omitempty"`
	InternalType string `json:"internalType"`
	Name         string `json:"name"`
	Type         string `json:"type"`
}

type ABIItem

type ABIItem struct {
	Anonymous bool       `json:"anonymous"`
	Type      string     `json:"type"`
	Name      string     `json:"name"`
	Inputs    []ABIInput `json:"inputs"`
}

type Decoder

type Decoder interface {
	// Decode is a function to transform log into strcutural event
	Decode(name string, chainId string, log types.Log) (*types.Event, error)
	// Batch decoding
	DecodeBatch(logs []types.Log) (*[]types.Event, error)
}

type DecoderRoute

type DecoderRoute struct {
	// The condition that needs to be fulfill
	Match MatchFunc
	// Name of the abi that registered in decoder
	Name string
	// The decoder after the condition is fulfilled
	Decoder Decoder
}

DecoderRoute pairs a matcher with a decoder

type DecoderRouter

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

func NewDecoderRouter

func NewDecoderRouter() *DecoderRouter

func (*DecoderRouter) Decode

func (r *DecoderRouter) Decode(chainId string, log types.Log) (*types.Event, error)

Decode implements the Decoder interface

func (*DecoderRouter) DecodeBatch

func (r *DecoderRouter) DecodeBatch(logs []types.Log) (*[]types.Event, error)

DecodeBatch implements the Decoder interface

func (*DecoderRouter) Register

func (r *DecoderRouter) Register(match MatchFunc, abiName string, dec Decoder) *DecoderRouter

Register a decoder with a match condition

type MatchFunc

type MatchFunc func(log types.Log) bool

MatchFunc determines if a decoder should be used for a given log

func And

func And(matchers ...MatchFunc) MatchFunc

And combines multiple matchers ( all must be true )

func ByAddress

func ByAddress(address string) MatchFunc

ByAddress matches logs from specific contract address

func ByAddresses

func ByAddresses(addresses []string) MatchFunc

ByAddresses matches logs from any of the addresses

func ByTopic0

func ByTopic0(topic0 string) MatchFunc

ByTopic0 matches logs by event signature (first topic)

func ByTopicCount

func ByTopicCount(count int) MatchFunc

ByTopicCount matches logs with exactly N topics

func Or

func Or(matchers ...MatchFunc) MatchFunc

type StandardDecoder

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

func NewStandardDecoder

func NewStandardDecoder() *StandardDecoder

func (*StandardDecoder) Decode

func (d *StandardDecoder) Decode(name string, chainId string, log types.Log) (*types.Event, error)

func (*StandardDecoder) DecodeBatch

func (d *StandardDecoder) DecodeBatch(logs []types.Log) (*[]types.Event, error)

func (*StandardDecoder) RegisterABI

func (d *StandardDecoder) RegisterABI(name, abiJson string) error

func (*StandardDecoder) RegisterABIFromFile

func (d *StandardDecoder) RegisterABIFromFile(name string, filepath string) error

Jump to

Keyboard shortcuts

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