connectors

package
v0.0.0-...-43fc98a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_GAP_BATCH_SIZE uint64 = 5

Variables

View Source
var ErrUnsubscribed = errors.New("unsubscribed")

Functions

This section is empty.

Types

type BatchEntry

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

type BatchPollConnector

type BatchPollConnector struct {
	Connector

	Delay time.Duration
	// contains filtered or unexported fields
}

BatchPollConnector uses batch requests to poll for latest, safe and finalized blocks.

func NewBatchPollConnector

func NewBatchPollConnector(ctx context.Context, logger *zap.Logger, baseConnector Connector, safeSupported bool, delay time.Duration) (*BatchPollConnector, error)

func (*BatchPollConnector) SubscribeForBlocks

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

type BatchResult

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

type BlockMarshaller

type BlockMarshaller struct {
	Number *hexutil.Big
	Hash   common.Hash    `json:"hash"`
	Time   hexutil.Uint64 `json:"timestamp"`

	// L1BlockNumber is the L1 block number in which an Arbitrum batch containing this block was submitted.
	// This field is only populated when connecting to Arbitrum.
	L1BlockNumber *hexutil.Big
}

type Blocks

type Blocks []*NewBlock

type CeloConnector

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

CeloConnector implements EVM network query capabilities for the Celo network. It's almost identical to EthereumConnector except it's using the Celo fork and provides shims between their respective types.

func NewCeloConnector

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

func (*CeloConnector) Client

func (c *CeloConnector) Client() *ethClient.Client

func (*CeloConnector) ContractAddress

func (c *CeloConnector) ContractAddress() ethCommon.Address

func (*CeloConnector) GetCurrentGuardianSetIndex

func (c *CeloConnector) GetCurrentGuardianSetIndex(ctx context.Context) (uint32, error)

func (*CeloConnector) GetGuardianSet

func (c *CeloConnector) GetGuardianSet(ctx context.Context, index uint32) (ethAbi.StructsGuardianSet, error)

func (*CeloConnector) NetworkName

func (c *CeloConnector) NetworkName() string

func (*CeloConnector) ParseLogMessagePublished

func (c *CeloConnector) ParseLogMessagePublished(ethLog ethTypes.Log) (*ethAbi.AbiLogMessagePublished, error)

func (*CeloConnector) RawBatchCallContext

func (c *CeloConnector) RawBatchCallContext(ctx context.Context, b []ethRpc.BatchElem) error

func (*CeloConnector) RawCallContext

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

func (*CeloConnector) SubscribeForBlocks

func (c *CeloConnector) SubscribeForBlocks(ctx context.Context, errC chan error, sink chan<- *NewBlock) (ethereum.Subscription, error)

func (*CeloConnector) SubscribeNewHead

func (c *CeloConnector) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)

func (*CeloConnector) TimeOfBlockByHash

func (c *CeloConnector) TimeOfBlockByHash(ctx context.Context, hash ethCommon.Hash) (uint64, error)

func (*CeloConnector) TransactionReceipt

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

func (*CeloConnector) WatchLogMessagePublished

func (c *CeloConnector) WatchLogMessagePublished(ctx context.Context, errC chan error, sink chan<- *ethAbi.AbiLogMessagePublished) (ethEvent.Subscription, error)

type Connector

type Connector interface {
	NetworkName() string
	ContractAddress() common.Address
	GetCurrentGuardianSetIndex(ctx context.Context) (uint32, error)
	GetGuardianSet(ctx context.Context, index uint32) (ethabi.StructsGuardianSet, error)
	WatchLogMessagePublished(ctx context.Context, errC chan error, sink chan<- *ethabi.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) (*ethabi.AbiLogMessagePublished, error)
	SubscribeForBlocks(ctx context.Context, errC chan error, sink chan<- *NewBlock) (ethereum.Subscription, error)
	RawCallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
	RawBatchCallContext(ctx context.Context, b []rpc.BatchElem) error
	Client() *ethClient.Client
	SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
}

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

type EthereumBaseConnector

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

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

func NewEthereumBaseConnector

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

func (*EthereumBaseConnector) Client

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

func (*EthereumBaseConnector) ContractAddress

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

func (*EthereumBaseConnector) GetCurrentGuardianSetIndex

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

func (*EthereumBaseConnector) GetGuardianSet

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

func (*EthereumBaseConnector) NetworkName

func (e *EthereumBaseConnector) NetworkName() string

func (*EthereumBaseConnector) ParseLogMessagePublished

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

func (*EthereumBaseConnector) RawBatchCallContext

func (e *EthereumBaseConnector) RawBatchCallContext(ctx context.Context, b []ethRpc.BatchElem) error

func (*EthereumBaseConnector) RawCallContext

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

func (*EthereumBaseConnector) SubscribeForBlocks

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

func (*EthereumBaseConnector) SubscribeNewHead

func (e *EthereumBaseConnector) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)

func (*EthereumBaseConnector) TimeOfBlockByHash

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

func (*EthereumBaseConnector) TransactionReceipt

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

func (*EthereumBaseConnector) WatchLogMessagePublished

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

type FinalityLevel

type FinalityLevel uint8
const (
	Latest FinalityLevel = iota
	Safe
	Finalized
)

func (FinalityLevel) String

func (f FinalityLevel) String() string

String() formats the finality as a string. Note that these strings are used in the RPC calls, so they cannot be changed.

type FinalizerPollConnector

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

FinalizerPollConnector polls for new blocks. It takes a finalizer which will be used to determine when a block is finalized.

func NewFinalizerPollConnector

func NewFinalizerPollConnector(ctx context.Context, baseConnector Connector, finalizer PollFinalizer, delay time.Duration) (*FinalizerPollConnector, error)

func (*FinalizerPollConnector) SubscribeForBlocks

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

type InstantFinalityConnector

type InstantFinalityConnector struct {
	Connector
	// contains filtered or unexported fields
}

InstantFinalityConnector is used for chains that support instant finality. It uses the standard geth head sink to read blocks and publishes each block as latest, safe and finalized.

func NewInstantFinalityConnector

func NewInstantFinalityConnector(baseConnector Connector, logger *zap.Logger) (*InstantFinalityConnector, error)

func (*InstantFinalityConnector) SubscribeForBlocks

func (c *InstantFinalityConnector) SubscribeForBlocks(ctx context.Context, errC chan error, sink chan<- *NewBlock) (ethereum.Subscription, error)

type LogPollConnector

type LogPollConnector struct {
	Connector
	// contains filtered or unexported fields
}

LogPollConnector pulls logs on each new block event when subscribing using WatchLogMessagePublished instead of using a websocket connection. It can be used in conjunction with a BlockPollConnector and Finalizer to only return finalized message log events.

func NewLogPollConnector

func NewLogPollConnector(ctx context.Context, baseConnector Connector, client *ethClient.Client) (*LogPollConnector, error)

func (*LogPollConnector) WatchLogMessagePublished

func (l *LogPollConnector) WatchLogMessagePublished(ctx context.Context, errC chan error, sink chan<- *ethAbi.AbiLogMessagePublished) (ethEvent.Subscription, error)

type NewBlock

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

func (*NewBlock) Copy

func (b *NewBlock) Copy(f FinalityLevel) *NewBlock

type PollFinalizer

type PollFinalizer interface {
	IsBlockFinalized(ctx context.Context, block *NewBlock) (bool, error)
}

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()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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