utils

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 26 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// LeafTypeAsset represents a bridge asset
	LeafTypeAsset uint32 = 0
	// LeafTypeMessage represents a bridge message
	LeafTypeMessage uint32 = 1
)

Variables

This section is empty.

Functions

func GenerateRandomHash added in v0.1.0

func GenerateRandomHash() [sha256.Size]byte

GenerateRandomHash generates a random hash.

func WaitTxToBeMined

func WaitTxToBeMined(ctx context.Context, client *ethclient.Client, tx *types.Transaction, timeout time.Duration) error

WaitTxToBeMined waits until a tx is mined or forged.

Types

type Client

type Client struct {
	// Client ethclient
	*ethclient.Client
	// contains filtered or unexported fields
}

Client is the utillity client

func NewClient

func NewClient(ctx context.Context, nodeURL string, bridgeSCAddr common.Address) (*Client, error)

NewClient creates client.

func (*Client) ApproveERC20

func (c *Client) ApproveERC20(ctx context.Context, erc20Addr, spender common.Address, amount *big.Int, auth *bind.TransactOpts) error

ApproveERC20 approves erc20 tokens.

func (*Client) BuildSendClaim added in v0.1.0

func (c *Client) BuildSendClaim(ctx context.Context, deposit *etherman.Deposit, smtProof [mtHeight][keyLen]byte, smtRollupProof [mtHeight][keyLen]byte, globalExitRoot *etherman.GlobalExitRoot, nonce, gasPrice int64, gasLimit uint64, rollupID uint, auth *bind.TransactOpts) (*types.Transaction, error)

BuildSendClaim builds a tx data to be sent to the bridge method SendClaim.

func (*Client) CheckTxWasMined added in v0.1.0

func (c *Client) CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error)

CheckTxWasMined check if a tx was already mined

func (*Client) DeployBridgeMessageReceiver

func (c *Client) DeployBridgeMessageReceiver(ctx context.Context, auth *bind.TransactOpts) (common.Address, error)

DeployBridgeMessageReceiver deploys the brdige message receiver smc.

func (*Client) DeployERC20

func (c *Client) DeployERC20(ctx context.Context, name, symbol string, auth *bind.TransactOpts) (common.Address, *ERC20.ERC20, error)

DeployERC20 deploys erc20 smc.

func (*Client) GetSigner

func (c *Client) GetSigner(ctx context.Context, accHexPrivateKey string) (*bind.TransactOpts, error)

GetSigner returns a transaction signer.

func (*Client) GetSignerFromKeystore added in v0.1.0

func (c *Client) GetSignerFromKeystore(ctx context.Context, ks zkevmtypes.KeystoreFileConfig) (*bind.TransactOpts, error)

GetSignerFromKeystore returns a transaction signer from the keystore file.

func (*Client) MintERC20

func (c *Client) MintERC20(ctx context.Context, erc20Addr common.Address, amount *big.Int, auth *bind.TransactOpts) error

MintERC20 mint erc20 tokens.

func (*Client) SendBridgeAsset

func (c *Client) SendBridgeAsset(ctx context.Context, tokenAddr common.Address, amount *big.Int, destNetwork uint32,
	destAddr *common.Address, metadata []byte, auth *bind.TransactOpts,
) error

SendBridgeAsset sends a bridge asset transaction.

func (*Client) SendBridgeMessage

func (c *Client) SendBridgeMessage(ctx context.Context, destNetwork uint32, destAddr common.Address, metadata []byte,
	auth *bind.TransactOpts,
) error

SendBridgeMessage sends a bridge message transaction.

func (*Client) SendClaim

func (c *Client) SendClaim(ctx context.Context, deposit *pb.Deposit, smtProof [mtHeight][keyLen]byte, smtRollupProof [mtHeight][keyLen]byte, globalExitRoot *etherman.GlobalExitRoot, auth *bind.TransactOpts) error

SendClaim sends a claim transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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