ocr2

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const ConfigDigestPrefixStarknet types.ConfigDigestPrefix = 4

TODO: use libocr constant

Variables

View Source
var (
	MaxObservers = 31

	// Event selectors
	NewTransmissionEventSelector = "019e22f866f4c5aead2809bf160d2b29e921e335d899979732101c6f3c38ff81"
	ConfigSetEventSelector       = "9a144bf4a6a8fd083c93211e163e59221578efcc86b93f8c97c620e7b9608a"
)

Functions

func NewConfigProvider

func NewConfigProvider(chainID string, contractAddress string, basereader starknet.Reader, cfg Config, lggr logger.Logger) (*configProvider, error)

func NewContractCache

func NewContractCache(cfg Config, reader Reader, lggr logger.Logger) *contractCache

func NewContractTransmitter

func NewContractTransmitter(
	reader *transmissionsCache,
	contractAddress string,
	senderAddress string,
	accountAddress string,
	txm txm.TxManager,
) *contractTransmitter

func NewMedianProvider

func NewMedianProvider(chainID string, contractAddress string, senderAddress string, accountAddress string, basereader starknet.Reader, cfg Config, txm txm.TxManager, lggr logger.Logger) (*medianProvider, error)

func NewOffchainConfigDigester

func NewOffchainConfigDigester(chainID, contract string) offchainConfigDigester

func NewTransmissionsCache

func NewTransmissionsCache(cfg Config, reader Reader, lggr logger.Logger) *transmissionsCache

func ParseConfigSetEvent

func ParseConfigSetEvent(event starknetrpc.EmittedEvent) (types.ContractConfig, error)

ParseConfigSetEvent is decoding binary felt data as the libocr ContractConfig type

func XXXMustBytesToConfigDigest

func XXXMustBytesToConfigDigest(b []byte) types.ConfigDigest

Types

type BillingDetails

type BillingDetails struct {
	ObservationPaymentGJuels  uint64
	TransmissionPaymentGJuels uint64
}

func NewBillingDetails

func NewBillingDetails(observationPaymentGJuels *big.Int, transmissionPaymentGJuels *big.Int) (bd BillingDetails, err error)

type Client

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

func NewClient

func NewClient(reader starknet.Reader, lggr logger.Logger) (*Client, error)

func (*Client) BaseReader

func (c *Client) BaseReader() starknet.Reader

func (*Client) BillingDetails

func (c *Client) BillingDetails(ctx context.Context, address *felt.Felt) (bd BillingDetails, err error)

func (*Client) ConfigFromEventAt

func (c *Client) ConfigFromEventAt(ctx context.Context, address *felt.Felt, blockNum uint64) (cc ContractConfig, err error)

func (*Client) LatestConfigDetails

func (c *Client) LatestConfigDetails(ctx context.Context, address *felt.Felt) (ccd ContractConfigDetails, err error)

func (*Client) LatestRoundData

func (c *Client) LatestRoundData(ctx context.Context, address *felt.Felt) (round RoundData, err error)

func (*Client) LatestTransmissionDetails

func (c *Client) LatestTransmissionDetails(ctx context.Context, address *felt.Felt) (td TransmissionDetails, err error)

func (*Client) LinkAvailableForPayment

func (c *Client) LinkAvailableForPayment(ctx context.Context, address *felt.Felt) (*big.Int, error)

func (*Client) NewTransmissionsFromEventsAt

func (c *Client) NewTransmissionsFromEventsAt(ctx context.Context, address *felt.Felt, blockNum uint64) (events []NewTransmissionEvent, err error)

NewTransmissionsFromEventsAt finds events of type new_transmission emitted by the contract address in a given block number.

type Config

type Config interface {
	OCR2CachePollPeriod() time.Duration
	OCR2CacheTTL() time.Duration
}

type ContractConfig

type ContractConfig struct {
	Config      types.ContractConfig
	ConfigBlock uint64
}

type ContractConfigDetails

type ContractConfigDetails struct {
	Block  uint64
	Digest types.ConfigDigest
}

func NewContractConfigDetails

func NewContractConfigDetails(blockNum *big.Int, digest [32]byte) (ccd ContractConfigDetails, err error)

type NewTransmissionEvent

type NewTransmissionEvent struct {
	RoundId         uint32 //nolint:revive
	LatestAnswer    *big.Int
	Transmitter     *felt.Felt
	LatestTimestamp time.Time
	Observers       []uint8
	ObservationsLen uint32
	Observations    []*big.Int
	JuelsPerFeeCoin *big.Int
	GasPrice        *big.Int
	ConfigDigest    types.ConfigDigest
	Epoch           uint32
	Round           uint8
	Reimbursement   *big.Int
}

NewTransmissionEvent represents the 'NewTransmission' event

func ParseNewTransmissionEvent

func ParseNewTransmissionEvent(event starknetrpc.EmittedEvent) (NewTransmissionEvent, error)

ParseNewTransmissionEvent is decoding binary felt data as the NewTransmissionEvent type

type OCR2Reader

type OCR2Reader interface {
	LatestConfigDetails(context.Context, *felt.Felt) (ContractConfigDetails, error)
	LatestTransmissionDetails(context.Context, *felt.Felt) (TransmissionDetails, error)
	LatestRoundData(context.Context, *felt.Felt) (RoundData, error)
	LinkAvailableForPayment(context.Context, *felt.Felt) (*big.Int, error)
	ConfigFromEventAt(context.Context, *felt.Felt, uint64) (ContractConfig, error)
	NewTransmissionsFromEventsAt(context.Context, *felt.Felt, uint64) ([]NewTransmissionEvent, error)
	BillingDetails(context.Context, *felt.Felt) (BillingDetails, error)

	BaseReader() starknet.Reader
}

type Reader

type Reader interface {
	types.ContractConfigTracker
	median.MedianContract
}

func NewContractReader

func NewContractReader(address string, reader OCR2Reader, lggr logger.Logger) Reader

type RoundData

type RoundData struct {
	RoundID     uint32
	Answer      *big.Int
	BlockNumber uint64
	StartedAt   time.Time
	UpdatedAt   time.Time
}

func NewRoundData

func NewRoundData(felts []*felt.Felt) (data RoundData, err error)

type Tracker

type Tracker interface {
	Start() error
	Close() error
	// contains filtered or unexported methods
}

type TransmissionDetails

type TransmissionDetails struct {
	Digest          types.ConfigDigest
	Epoch           uint32
	Round           uint8
	LatestAnswer    *big.Int
	LatestTimestamp time.Time
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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