contracts

package
v0.0.0-...-25c9f67 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const RECONNECT_TIMEOUT = 2 * time.Second

Variables

View Source
var (
	ErrNoEventSignature       = errors.New("no event signature")
	ErrEventSignatureMismatch = errors.New("event signature mismatch")
)
View Source
var (
	ErrUnknownEvent = errors.New("unknown event")
)

Functions

func BlockchainEventFactory

func BlockchainEventFactory(name string) interface{}

func CreateEventMapper

func CreateEventMapper(eventFactory EventFactory, abi *abi.ABI) func(log types.Log) (interface{}, error)

func UnpackLog

func UnpackLog(out interface{}, event string, log types.Log, ab *abi.ABI) error

UnpackLog unpacks the log into the provided struct, copied from go-ethereum implementation

func WatchContractEvents

func WatchContractEvents(ctx context.Context, client EthereumClient, contractAddr common.Address, mapper EventMapper, log lib.ILogger) (*lib.Subscription, error)

WatchContractEvents watches for all events from the contract and converts them to the concrete type, using mapper

Types

type CloseListererFunc

type CloseListererFunc = func()

type DataAccess

type DataAccess interface {
	// string used as address cause different blockchains may return different type of addresses
	GetContractsIDs() ([]string, error)
	GetContract(contractID string) (interface{}, error)
	CloseContract(contractID string, meta interface{}) error

	OnNewContract(func(contractID string)) CloseListererFunc
	OnContractUpdated(contractID string, cb func()) CloseListererFunc
	OnContractClosed(contractID string, cb func()) CloseListererFunc
}

type EthereumClient

type EthereumClient interface {
	bind.ContractBackend
	bind.DeployBackend
	ChainID(ctx context.Context) (*big.Int, error)
	BalanceAt(ctx context.Context, addr common.Address, blockNumber *big.Int) (*big.Int, error)
	StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
}

type EventFactory

type EventFactory func(name string) interface{}

type EventMapper

type EventMapper func(types.Log) (interface{}, error)

Jump to

Keyboard shortcuts

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