abs

package
v0.0.0-...-5068620 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultWatchLimit = 20

Variables

This section is empty.

Functions

This section is empty.

Types

type Attrs

type Attrs struct {
	ChainId              uint64
	Chain                string
	DeployedBlockNumber  uint64 // contract deployment height
	ProcessedBlockNumber uint64 // has been processed on block number, default is DeployedBlockNumber
	WatchBlockLimit      int64  // Limit the number of blocks scanned each time, default is 20
	ContractToDesc       map[string]ContractDesc
}

type Contract

type Contract struct {
	Attrs

	Addrs  []common.Address
	Topics [][]common.Hash

	IsRunning atomic.Bool
	IsClose   atomic.Bool
	// contains filtered or unexported fields
}

func (*Contract) Close

func (c *Contract) Close() error

func (*Contract) DoneSignal

func (c *Contract) DoneSignal() <-chan struct{}

func (*Contract) GetContractDesc

func (c *Contract) GetContractDesc(addr string) (ContractDesc, error)

func (*Contract) GetProcessedBlockNumber

func (c *Contract) GetProcessedBlockNumber() uint64

GetProcessedBlockNumber ...

func (*Contract) HandleEvent

func (c *Contract) HandleEvent(client *rpcclient.EvmClient, event Event, log types.Log) error

HandleEvent method call Hook

func (*Contract) Init

func (c *Contract) Init(attrs Attrs)

func (*Contract) RegisterEventHook

func (c *Contract) RegisterEventHook(event Event, f func(client *rpcclient.EvmClient, log types.Log) error) error

RegisterEventHook Hook is a function that handles event, HandleEvent method call this Hook

func (*Contract) RegisterWatchEvent

func (c *Contract) RegisterWatchEvent(events ...Event) error

RegisterWatchEvent topics[0] is smart contract event

func (*Contract) RegisterWatchTopics

func (c *Contract) RegisterWatchTopics(topicsIndex int, topics ...common.Hash) error

RegisterWatchTopics topic is smart contract event parameter

topicsIndex: [0-3]
event topics

func (*Contract) Scan

func (c *Contract) Scan(client *rpcclient.EvmClient) error

func (*Contract) UpdateProcessedBlockNumber

func (c *Contract) UpdateProcessedBlockNumber(num uint64) error

UpdateProcessedBlockNumber ...

type ContractDesc

type ContractDesc struct {
	Name     string
	Symbol   string
	Decimals uint8
}

type Event

type Event string

func (Event) String

func (e Event) String() string

type IContract

type IContract interface {
	Init(attrs Attrs)
	Close() error
	DoneSignal() <-chan struct{}
	RegisterWatchEvent(events ...Event) error
	RegisterWatchTopics(topicsIndex int, topics ...common.Hash) error
	RegisterEventHook(event Event, f func(client *rpcclient.EvmClient, log types.Log) error) error
	HandleEvent(client *rpcclient.EvmClient, event Event, log types.Log) error
	UpdateProcessedBlockNumber(num uint64) error
	GetProcessedBlockNumber() uint64
	Scan(client *rpcclient.EvmClient) error
	GetContractDesc(addr string) (ContractDesc, error)
}

Jump to

Keyboard shortcuts

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