teleportstarknet

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const LoggerTag = "STARKNET_TELEPORT"
View Source
const TeleportEventType = "teleport_starknet"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.7.1

type Config struct {
	// Sequencer is an instance of Ethereum RPC sequencer.
	Sequencer Sequencer

	// Addresses is a list of contracts from which events will be fetched.
	Addresses []*starknet.Felt

	// Interval specifies how often provider should check for new events.
	Interval time.Duration

	// PrefetchPeriod specifies how far back in time provider should prefetch
	// events. It is used only during the initial start of the provider.
	PrefetchPeriod time.Duration

	// Logger is an instance of a logger. Logger is used mostly to report
	// recoverable errors.
	Logger log.Logger
}

Config contains a configuration options for New.

type EventProvider added in v0.7.1

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

EventProvider listens for TeleportGUID events on Starknet.

https://github.com/makerdao/dss-teleport https://github.com/makerdao/starknet-dai-bridge

It periodically fetches pending block, looks for TeleportGUID events, converts them into messages.Event and sends them to the channel provided by Events method.

During the initial start of the provider it also fetches older blocks until it reaches the block that is older than the prefetch period. This is done to fetch events that were emitted before the provider was started.

Finally, it also listens for newly accepted blocks. This is done to make sure that provider does not miss any events from the pending block. This can happen if the Starknet node becomes unavailable, so it cannot fetch the pending block. If at that time the pending block become accepted, the events that would have been added since the time the node became unavailable would be lost.

In the event of an error in communication with a Starknet node, whether related to network errors or the node itself, the provider will try to repeat requests to the node indefinitely.

func New

func New(cfg Config) (*EventProvider, error)

New creates a new instance of EventProvider.

func (*EventProvider) Events added in v0.7.1

func (ep *EventProvider) Events() chan *messages.Event

Events implements the publisher.EventPublisher interface.

func (*EventProvider) Start added in v0.7.1

func (ep *EventProvider) Start(ctx context.Context) error

Start implements the publisher.EventPublisher interface.

type Sequencer

type Sequencer interface {
	GetPendingBlock(ctx context.Context) (*starknet.Block, error)
	GetLatestBlock(ctx context.Context) (*starknet.Block, error)
	GetBlockByNumber(ctx context.Context, blockNumber uint64) (*starknet.Block, error)
}

Sequencer is a Starknet sequencer.

Jump to

Keyboard shortcuts

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