ethereum

package
v0.0.0-...-e8e2c10 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsubscribed = errors.New("unsubscribed")
View Source
var (
	// SECURITY: Hardcoded ABI identifier for the LogMessagePublished topic. When using the watcher, we don't need this
	// since the node will only hand us pre-filtered events. In this case, we need to manually verify it
	// since ParseLogMessagePublished will only verify whether it parses.
	// keccak256("LogMessagePublished(address,uint16,uint64,uint32,bytes,uint8)")
	LogMessagePublishedTopic = eth_common.HexToHash("0xcd7b525350dfac7e06deb9b3a8f19ceb75cf6cd2914cd0b2d7bf9d9a3d9babff")
)

Functions

func MessageEventsForTransaction

func MessageEventsForTransaction(
	ctx context.Context,
	ethConn Connector,
	contract eth_common.Address,
	chainId vaa.ChainID,
	tx eth_common.Hash) (uint64, []*common.MessagePublication, error)

MessageEventsForTransaction returns the lockup events for a given transaction. Returns the block number and a list of MessagePublication events.

func PadAddress

func PadAddress(address common.Address) vaa.Address

PadAddress creates 32-byte VAA.Address from 20-byte Ethereum addresses by adding 12 0-bytes at the left

Types

type BlockPollConnector

type BlockPollConnector struct {
	Connector
	Delay time.Duration
	// contains filtered or unexported fields
}

BlockPollConnector polls for new blocks instead of subscribing when using SubscribeForBlocks

func NewBlockPollConnector

func NewBlockPollConnector(ctx context.Context, baseConnector Connector, delay time.Duration, useFinalized bool) (*BlockPollConnector, error)

func (*BlockPollConnector) DisablePoller

func (b *BlockPollConnector) DisablePoller()

func (*BlockPollConnector) EnablePoller

func (b *BlockPollConnector) EnablePoller()

func (*BlockPollConnector) SubscribeForBlocks

func (b *BlockPollConnector) SubscribeForBlocks(ctx context.Context, sink chan<- *NewBlock) (ethereum.Subscription, error)

type Connector

type Connector interface {
	NetworkName() string
	ContractAddress() common.Address
	GetCurrentGuardianSetIndex(ctx context.Context) (uint32, error)
	GetGuardianSet(ctx context.Context, index uint32) (abi.StructsGuardianSet, error)
	WatchLogMessagePublished(ctx context.Context, sink chan<- *abi.AbiLogMessagePublished) (event.Subscription, error)
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
	TimeOfBlockByHash(ctx context.Context, hash common.Hash) (uint64, error)
	ParseLogMessagePublished(log types.Log) (*abi.AbiLogMessagePublished, error)
	SubscribeForBlocks(ctx context.Context, sink chan<- *NewBlock) (ethereum.Subscription, error)
	RawCallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
}

Connector exposes Wormhole-specific interactions with an EVM-based network

type EthereumConnector

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

EthereumConnector implements EVM network query capabilities for go-ethereum based networks and networks supporting the standard web3 rpc.

func NewEthereumConnector

func NewEthereumConnector(ctx context.Context, networkName, rawUrl string, address ethCommon.Address, logger *zap.Logger) (*EthereumConnector, error)

func (*EthereumConnector) Client

func (e *EthereumConnector) Client() *ethClient.Client

func (*EthereumConnector) ContractAddress

func (e *EthereumConnector) ContractAddress() ethCommon.Address

func (*EthereumConnector) GetCurrentGuardianSetIndex

func (e *EthereumConnector) GetCurrentGuardianSetIndex(ctx context.Context) (uint32, error)

func (*EthereumConnector) GetGuardianSet

func (e *EthereumConnector) GetGuardianSet(ctx context.Context, index uint32) (ethAbi.StructsGuardianSet, error)

func (*EthereumConnector) NetworkName

func (e *EthereumConnector) NetworkName() string

func (*EthereumConnector) ParseLogMessagePublished

func (e *EthereumConnector) ParseLogMessagePublished(log ethTypes.Log) (*ethAbi.AbiLogMessagePublished, error)

func (*EthereumConnector) RawCallContext

func (e *EthereumConnector) RawCallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error

func (*EthereumConnector) SubscribeForBlocks

func (e *EthereumConnector) SubscribeForBlocks(ctx context.Context, sink chan<- *NewBlock) (ethereum.Subscription, error)

func (*EthereumConnector) TimeOfBlockByHash

func (e *EthereumConnector) TimeOfBlockByHash(ctx context.Context, hash ethCommon.Hash) (uint64, error)

func (*EthereumConnector) TransactionReceipt

func (e *EthereumConnector) TransactionReceipt(ctx context.Context, txHash ethCommon.Hash) (*ethTypes.Receipt, error)

func (*EthereumConnector) WatchLogMessagePublished

func (e *EthereumConnector) WatchLogMessagePublished(ctx context.Context, sink chan<- *ethAbi.AbiLogMessagePublished) (ethEvent.Subscription, error)

type MoonbeamFinalizer

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

func (*MoonbeamFinalizer) DialContext

func (f *MoonbeamFinalizer) DialContext(ctx context.Context, rawurl string) (err error)

func (*MoonbeamFinalizer) IsBlockFinalized

func (f *MoonbeamFinalizer) IsBlockFinalized(ctx context.Context, block *common.NewBlock) (bool, error)

func (*MoonbeamFinalizer) SetLogger

func (f *MoonbeamFinalizer) SetLogger(l *zap.Logger, netName string)

type NewBlock

type NewBlock struct {
	Number        *big.Int
	Hash          common.Hash
	L1BlockNumber *big.Int // This is only populated on some chains (Arbitrum)
	Safe          bool
}

type PollSubscription

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

func NewPollSubscription

func NewPollSubscription() *PollSubscription

func (*PollSubscription) Err

func (sub *PollSubscription) Err() <-chan error

func (*PollSubscription) Unsubscribe

func (sub *PollSubscription) Unsubscribe()

type Watcher

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

func NewEthWatcher

func NewEthWatcher(
	url string,
	contract eth_common.Address,
	networkName string,
	readiness readiness.Component,
	chainID vaa.ChainID,
	messageEvents chan *common.MessagePublication,
	setEvents chan *common.GuardianSet,
	obsvReqC chan *gossipv1.ObservationRequest,
	unsafeDevMode bool,
	pollIntervalMs *uint,
	waitForConfirmations bool,
) *Watcher

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context) error

func (*Watcher) SetWaitForConfirmations

func (w *Watcher) SetWaitForConfirmations(waitForConfirmations bool)

SetWaitForConfirmations is used to override whether we should wait for the number of confirmations specified by the consistencyLevel in the message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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