client

package
v0.0.0-...-3378ddf Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: LGPL-3.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToCallArg

func ToCallArg(msg ethereum.CallMsg) map[string]interface{}

ToCallArg is the function that converts ethereum.CallMsg into more abstract map This is done for matter of making EVMClient more abstract since some go-ethereum forks uses different messages types

Types

type Client

type Client interface {
	ContractCaller
	TransactionDispatcher
}

type CommonTransaction

type CommonTransaction interface {
	// Hash returns the transaction hash.
	Hash() common.Hash

	// RawWithSignature Returns signed transaction by provided signer
	RawWithSignature(signer Signer, domainID *big.Int) ([]byte, error)
}

type ContractCaller

type ContractCaller interface {
	CallContract(ctx context.Context, callArgs map[string]interface{}, blockNumber *big.Int) ([]byte, error)
	CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
}

type EVMClient

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

func NewEVMClient

func NewEVMClient(url string, signer Signer) (*EVMClient, error)

NewEVMClient creates a client for EVMChain with provided signer

func (*EVMClient) BaseFee

func (c *EVMClient) BaseFee() (*big.Int, error)

func (*EVMClient) CallContext

func (c *EVMClient) CallContext(ctx context.Context, target interface{}, rpcMethod string, args ...interface{}) error

func (*EVMClient) CallContract

func (c *EVMClient) CallContract(ctx context.Context, callArgs map[string]interface{}, blockNumber *big.Int) ([]byte, error)

func (*EVMClient) FetchEventLogs

func (c *EVMClient) FetchEventLogs(ctx context.Context, contractAddress common.Address, event string, startBlock *big.Int, endBlock *big.Int) ([]types.Log, error)

func (*EVMClient) From

func (c *EVMClient) From() common.Address

func (*EVMClient) GetTransactionByHash

func (c *EVMClient) GetTransactionByHash(h common.Hash) (tx *types.Transaction, isPending bool, err error)

func (*EVMClient) LatestBlock

func (c *EVMClient) LatestBlock() (*big.Int, error)

LatestBlock returns the latest block from the current chain

func (*EVMClient) LockNonce

func (c *EVMClient) LockNonce()

func (*EVMClient) SendRawTransaction

func (c *EVMClient) SendRawTransaction(ctx context.Context, tx []byte) error

SendRawTransaction accepts rlp-encode of signed transaction and sends it via RPC call

func (*EVMClient) SignAndSendTransaction

func (c *EVMClient) SignAndSendTransaction(ctx context.Context, tx CommonTransaction) (common.Hash, error)

func (*EVMClient) UnlockNonce

func (c *EVMClient) UnlockNonce()

func (*EVMClient) UnsafeIncreaseNonce

func (c *EVMClient) UnsafeIncreaseNonce() error

func (*EVMClient) UnsafeNonce

func (c *EVMClient) UnsafeNonce() (*big.Int, error)

func (*EVMClient) WaitAndReturnTxReceipt

func (c *EVMClient) WaitAndReturnTxReceipt(h common.Hash) (*types.Receipt, error)

type Signer

type Signer interface {
	CommonAddress() common.Address

	// Sign calculates an ECDSA signature.
	// The produced signature must be in the [R || S || V] format where V is 0 or 1.
	Sign(digestHash []byte) ([]byte, error)
}

type TransactionDispatcher

type TransactionDispatcher interface {
	WaitAndReturnTxReceipt(h common.Hash) (*types.Receipt, error)
	SignAndSendTransaction(ctx context.Context, tx CommonTransaction) (common.Hash, error)
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
	GetTransactionByHash(h common.Hash) (tx *types.Transaction, isPending bool, err error)
	UnsafeNonce() (*big.Int, error)
	LockNonce()
	UnlockNonce()
	UnsafeIncreaseNonce() error
	From() common.Address
}

Jump to

Keyboard shortcuts

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