etherman

package
v0.5.0-RC10 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 26 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNotFound is used when the object is not found
	ErrNotFound = errors.New("Not found")
)

Functions

func DecodeGlobalIndex added in v0.5.0

func DecodeGlobalIndex(globalIndex *big.Int) (bool, uint64, uint64, error)

func GenerateGlobalIndex added in v0.4.0

func GenerateGlobalIndex(mainnetFlag bool, rollupIndex uint, localExitRootIndex uint) *big.Int

Types

type Block

type Block struct {
	ID              uint64
	BlockNumber     uint64
	BlockHash       common.Hash
	ParentHash      common.Hash
	NetworkID       uint
	GlobalExitRoots []GlobalExitRoot
	Deposits        []Deposit
	Claims          []Claim
	Tokens          []TokenWrapped
	VerifiedBatches []VerifiedBatch
	ActivateEtrog   []bool
	ReceivedAt      time.Time
}

Block struct

type Claim

type Claim struct {
	MainnetFlag        bool
	RollupIndex        uint64
	Index              uint
	OriginalNetwork    uint
	OriginalAddress    common.Address
	Amount             *big.Int
	DestinationAddress common.Address
	BlockID            uint64
	BlockNumber        uint64
	NetworkID          uint
	TxHash             common.Hash
}

Claim struct

type Client

type Client struct {
	EtherClient                ethClienter
	PolygonBridge              *polygonzkevmbridge.Polygonzkevmbridge
	OldPolygonBridge           *oldpolygonzkevmbridge.Oldpolygonzkevmbridge
	PolygonZkEVMGlobalExitRoot *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot
	PolygonRollupManager       *polygonrollupmanager.Polygonrollupmanager
	ClaimCompressor            *claimcompressor.Claimcompressor
	RollupID                   uint32
	SCAddresses                []common.Address
}

Client is a simple implementation of EtherMan.

func NewClient

func NewClient(cfg Config, polygonBridgeAddr, polygonZkEVMGlobalExitRootAddress, polygonRollupManagerAddress, polygonZkEvmAddress common.Address) (*Client, error)

NewClient creates a new etherman.

func NewL2Client

func NewL2Client(url string, polygonBridgeAddr, claimCompressorAddress common.Address) (*Client, error)

NewL2Client creates a new etherman for L2.

func NewSimulatedEtherman

NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth must be 1337. The address that holds the auth will have an initial balance of 10 ETH

func (*Client) AddExistingRollupEvent added in v0.4.0

func (etherMan *Client) AddExistingRollupEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error

func (*Client) CompressClaimCall added in v0.5.0

func (etherMan *Client) CompressClaimCall(mainnetExitRoot, rollupExitRoot common.Hash, claimData []claimcompressor.ClaimCompressorCompressClaimCallData) ([]byte, error)

func (*Client) EthBlockByNumber

func (etherMan *Client) EthBlockByNumber(ctx context.Context, blockNumber uint64) (*types.Block, error)

EthBlockByNumber function retrieves the ethereum block information by ethereum block number.

func (*Client) GetNetworkID

func (etherMan *Client) GetNetworkID(ctx context.Context) (uint, error)

GetNetworkID gets the network ID of the dedicated chain.

func (*Client) GetRollupID added in v0.4.0

func (etherMan *Client) GetRollupID() uint

func (*Client) GetRollupInfoByBlockRange

func (etherMan *Client) GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]Block, map[common.Hash][]Order, error)

GetRollupInfoByBlockRange function retrieves the Rollup information that are included in all this ethereum blocks from block x to block y.

func (*Client) HeaderByNumber

func (etherMan *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.

func (*Client) SendCompressedClaims added in v0.5.0

func (etherMan *Client) SendCompressedClaims(auth *bind.TransactOpts, compressedTxData []byte) (*types.Transaction, error)

type Config

type Config struct {
	L1URL  string   `mapstructure:"L1URL"`
	L2URLs []string `mapstructure:"L2URLs"`
}

Config represents the configuration of the etherman

type Deposit

type Deposit struct {
	LeafType           uint8
	OriginalNetwork    uint
	OriginalAddress    common.Address
	Amount             *big.Int
	DestinationNetwork uint
	DestinationAddress common.Address
	DepositCount       uint
	BlockID            uint64
	BlockNumber        uint64
	NetworkID          uint
	TxHash             common.Hash
	Metadata           []byte
	// it is only used for the bridge service
	ReadyForClaim bool
}

Deposit struct

type EventOrder

type EventOrder string

EventOrder is the the type used to identify the events order

const (
	// GlobalExitRootsOrder identifies a GlobalExitRoot event
	GlobalExitRootsOrder EventOrder = "GlobalExitRoot"
	// DepositsOrder identifies a Deposits event
	DepositsOrder EventOrder = "Deposit"
	// ClaimsOrder identifies a Claims event
	ClaimsOrder EventOrder = "Claim"
	// TokensOrder identifies a TokenWrapped event
	TokensOrder EventOrder = "TokenWrapped"
	// VerifyBatchOrder identifies a VerifyBatch event
	VerifyBatchOrder EventOrder = "VerifyBatch"
	// ActivateEtrogOrder identifies the event to activate etrog
	ActivateEtrogOrder EventOrder = "etrog"
)

type GlobalExitRoot

type GlobalExitRoot struct {
	BlockID        uint64
	BlockNumber    uint64
	ExitRoots      []common.Hash
	GlobalExitRoot common.Hash
}

GlobalExitRoot struct

type Order

type Order struct {
	Name EventOrder
	Pos  int
}

Order contains the event order to let the synchronizer store the information following this order.

type RollupExitLeaf added in v0.4.0

type RollupExitLeaf struct {
	ID       uint64
	BlockID  uint64
	Leaf     common.Hash
	RollupId uint
	Root     common.Hash
}

RollupExitLeaf struct

type TokenMetadata

type TokenMetadata struct {
	Name     string
	Symbol   string
	Decimals uint8
}

TokenMetadata is a metadata of ERC20 token.

type TokenWrapped

type TokenWrapped struct {
	TokenMetadata
	OriginalNetwork      uint
	OriginalTokenAddress common.Address
	WrappedTokenAddress  common.Address
	BlockID              uint64
	BlockNumber          uint64
	NetworkID            uint
}

TokenWrapped struct

type VerifiedBatch

type VerifiedBatch struct {
	BlockNumber   uint64
	BatchNumber   uint64
	RollupID      uint
	LocalExitRoot common.Hash
	TxHash        common.Hash
	StateRoot     common.Hash
	Aggregator    common.Address
}

Directories

Path Synopsis
smartcontracts

Jump to

Keyboard shortcuts

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