chain

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package chain implements everything related to interaction with smart contracts, rpc provider, etc.

Index

Constants

View Source
const (
	L1                            = NetworkType("L1")
	L2                            = NetworkType("L2")
	L2BedrockMessagePasserAddress = "0x4200000000000000000000000000000000000016"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainAPIClient

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

ChainAPIClient connects and encapsulates all the methods to interact with a chain.

func GetAPIClient

func GetAPIClient(ctx context.Context, url string, log log.Logger) (*ChainAPIClient, error)

GetAPIClient returns ChainAPIClient with client attached.

func (*ChainAPIClient) GetBlockByNumber

func (c *ChainAPIClient) GetBlockByNumber(ctx context.Context, blockNumber *big.Int) (*types.Block, error)

GetBlockByNumber returns block for a given block number from a connected node.

func (*ChainAPIClient) GetBlockHeaderByNumber

func (c *ChainAPIClient) GetBlockHeaderByNumber(ctx context.Context, blockNumber *big.Int) (*types.Header, error)

GetBlockHeaderByNumber returns block header for a given block number from a connected node.

func (*ChainAPIClient) GetChainID

func (c *ChainAPIClient) GetChainID(ctx context.Context) (*big.Int, error)

GetChainID returns chainID of a connected node.

func (*ChainAPIClient) GetLatestBlockHeader

func (c *ChainAPIClient) GetLatestBlockHeader(ctx context.Context) (*types.Header, error)

GetLatestBlockHeader returns latest block header from a connected node.

func (*ChainAPIClient) GetLatestBlockNumber

func (c *ChainAPIClient) GetLatestBlockNumber(ctx context.Context) (uint64, error)

GetLatestBlockNumber returns latest block number from a connected node.

func (*ChainAPIClient) GetProof

func (c *ChainAPIClient) GetProof(ctx context.Context, blockNumber *big.Int, address common.Address) (*ProofResponse, error)

GetProof returns the account and storage values, including the Merkle proof, of the specified account/address.

type ConfigOptions

type ConfigOptions struct {
	L1RPCEndpoint                 string
	ChainID                       uint64
	L2OutputOracleContractAddress string
}

ConfigOptions are the options required to interact with the oracle contract.

type Contracts

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

Contracts has information of the L1 & L2 contracts addresses.

func GetContractAddressesByChainID

func GetContractAddressesByChainID(chainID uint64) (Contracts, bool)

GetContractAddressesByChainID returns contract addresses by network chainID.

type L2ChainIDs

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

L2ChainIDs manages L2 network chainIDs.

type L2Output

type L2Output struct {
	OutputRoot    string
	L1Timestamp   uint64
	L2BlockNumber uint64
	L2OutputIndex uint64
}

L2Output is the output of GetL2Output.

type NetworkType

type NetworkType = string

type OracleAccessor

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

OracleAccessor binds oracle contract to an instance for querying data.

func NewOracleAccessor

func NewOracleAccessor(ctx context.Context, opts *ConfigOptions) (*OracleAccessor, error)

NewOracleAccessor returns OracleAccessor with contract instance.

func (*OracleAccessor) FinalizationPeriodSeconds

func (oc *OracleAccessor) FinalizationPeriodSeconds() (*big.Int, error)

FinalizationPeriodSeconds returns output finalization time in seconds.

func (*OracleAccessor) GetL2Output

func (oc *OracleAccessor) GetL2Output(index *big.Int) (L2Output, error)

GetL2Output returns L2 output at given index.

func (*OracleAccessor) GetNextOutputIndex

func (oc *OracleAccessor) GetNextOutputIndex() (*big.Int, error)

GetNextOutputIndex returns index of next output to be proposed.

type ProofResponse

type ProofResponse struct {
	Address      common.Address  `json:"address"`
	AccountProof []hexutil.Bytes `json:"accountProof"`
	Balance      *hexutil.Big    `json:"balance"`
	CodeHash     common.Hash     `json:"codeHash"`
	Nonce        hexutil.Uint64  `json:"nonce"`
	StorageHash  common.Hash     `json:"storageHash"`
	StorageProof []common.Hash   `json:"storageProof"`
}

Jump to

Keyboard shortcuts

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