evm

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const Chain = "evm"

Chain is the identifier for EVM chains.

Variables

View Source
var ErrReorgDetected = errors.New("reorg detected")

ErrReorgDetected signals that the chain rewound; caller should restart from the updated cursor.

Functions

func FindEvent

func FindEvent(abis map[string]*abi.ABI, eventName string) (*abi.Event, bool)

FindEvent searches loaded ABIs for an event with the given name.

func LoadABIs

func LoadABIs(dirs []string) (map[string]*abi.ABI, error)

LoadABIs loads ABI JSON files from the provided directories.

Types

type BlockClient

type BlockClient interface {
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
	FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
}

BlockClient captures the subset of ethclient used by the scanner.

type NormalizedEvent

type NormalizedEvent struct {
	Chain    string
	SourceID string
	RuleID   string
	Height   uint64
	Hash     string
	TxHash   string
	LogIndex *uint
	Contract string
	Name     string
	Args     map[string]any
}

NormalizedEvent represents a decoded on-chain event in a uniform shape.

type RPCClient

type RPCClient struct {
	*ethclient.Client
}

RPCClient is a thin wrapper over ethclient.Client that satisfies BlockClient.

func NewRPCClient

func NewRPCClient(rpcURL string) (*RPCClient, error)

NewRPCClient builds an RPC client to an EVM node.

type RuleMatcher

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

RuleMatcher filters and decodes logs for a given rule.

func NewRuleMatcher

func NewRuleMatcher(rule config.Rule, abis map[string]*abi.ABI) (*RuleMatcher, error)

NewRuleMatcher builds a matcher for a log rule using available ABIs. Supports only log rules.

func (*RuleMatcher) Match

func (m *RuleMatcher) Match(log types.Log) (*NormalizedEvent, bool, error)

Match checks the log against the matcher; returns a normalized event on success.

type Scanner

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

Scanner processes blocks sequentially with confirmation safety.

func NewScanner

func NewScanner(client BlockClient, store *storage.Store, source config.Source, confirmations uint64, abis map[string]*abi.ABI, rules []config.Rule) (*Scanner, error)

NewScanner builds a scanner for a given source and its log rules.

func (*Scanner) ProcessNext

func (s *Scanner) ProcessNext(ctx context.Context) ([]NormalizedEvent, error)

ProcessNext handles the next eligible block (respecting confirmations) and returns matched events. It advances the cursor on success. If a reorg is detected, ErrReorgDetected is returned after rewinding.

Jump to

Keyboard shortcuts

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