evmclient

package
v1.0.27 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: LGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DomainIdMappingEVMClient = make(map[uint8]*EVMClient)

Functions

func ErrCounterLogic

func ErrCounterLogic(errStr string, domainId uint8)

Types

type CommonTransaction

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

	// RawWithSignature Returns signed transaction by provided private key
	RawWithSignature(key *ecdsa.PrivateKey, domainID *big.Int) ([]byte, error)
}

type DepositLogs

type DepositLogs struct {
	// ID of chain deposit will be bridged to
	DestinationDomainID uint8
	// ResourceID used to find address of handler to be used for deposit
	ResourceID bridgeTypes.ResourceID
	// Nonce of deposit
	DepositNonce uint64
	// Address of sender (msg.sender: user)
	SenderAddress common.Address
	// Additional data to be passed to specified handler
	Data []byte
	// ERC20Handler: responds with empty data
	// ERC721Handler: responds with deposited token metadata acquired by calling a tokenURI method in the token contract
	// GenericHandler: responds with the raw bytes returned from the call to the target contract
	HandlerResponse []byte

	BlockHash   common.Hash
	BlockNumber uint64
}

DepositLogs struct holds event data with all necessary parameters and a handler response https://github.com/ChainSafe/chainbridge-solidity/blob/develop/contracts/Bridge.sol#L47

type EVMClient

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

func NewEVMClient

func NewEVMClient(cfg *chain.EVMConfig) (*EVMClient, error)

NewEVMClient creates a client for EVM chain configured with specified config. Private key is chosen by 'from' param in chain config that matches filename inside keystore path.

func NewEVMClientFromParams

func NewEVMClientFromParams(url string, privateKey *ecdsa.PrivateKey) (*EVMClient, error)

NewEVMClientFromParams creates a client for EVMChain with provided private key.

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) EnsureHasBytecode

func (c *EVMClient) EnsureHasBytecode(addr common.Address) error

EnsureHasBytecode asserts if contract code exists at the specified address

func (*EVMClient) FetchDepositLogs

func (c *EVMClient) FetchDepositLogs(ctx context.Context, contractAddress common.Address, startBlock *big.Int, endBlock *big.Int) ([]*DepositLogs, 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) LatestFinalizedBlock

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

func (*EVMClient) LockNonce

func (c *EVMClient) LockNonce()

func (*EVMClient) PendingCallContract

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

func (*EVMClient) PolygonGasStation

func (c *EVMClient) PolygonGasStation() bool

func (*EVMClient) PrivateKey

func (c *EVMClient) PrivateKey() *ecdsa.PrivateKey

func (*EVMClient) RelayerAddress

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

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) Sign

func (c *EVMClient) Sign(byteData []byte) ([]byte, error)

func (*EVMClient) SignAndSendTransaction

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

func (*EVMClient) SubscribePendingTransactions

func (c *EVMClient) SubscribePendingTransactions(ctx context.Context, ch chan<- common.Hash) (*rpc.ClientSubscription, error)

func (*EVMClient) UnlockNonce

func (c *EVMClient) UnlockNonce()

func (*EVMClient) UnpackDepositEventLog

func (c *EVMClient) UnpackDepositEventLog(abi abi.ABI, data []byte) (*DepositLogs, error)

func (*EVMClient) UnsafeIncreaseNonce

func (c *EVMClient) UnsafeIncreaseNonce() error

func (*EVMClient) UnsafeNonce

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

func (*EVMClient) UpdateEndpoint

func (c *EVMClient) UpdateEndpoint() (string, error)

func (*EVMClient) UpdateNonce

func (c *EVMClient) UpdateNonce()

func (*EVMClient) WaitAndReturnTxReceipt

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

type ProposalEvents

type ProposalEvents struct {
	OriginDomainID uint8
	DepositNonce   uint64
	Status         uint8 // ProposalStatus
	DataHash       [32]byte
}

type SignaturePass

type SignaturePass struct {
	OriginDomainID      uint8
	DestinationDomainID uint8
	DepositNonce        uint64
	ResourceID          [32]byte
	Data                []byte
	Signature           []byte
}

func (SignaturePass) String

func (s SignaturePass) String() string

Jump to

Keyboard shortcuts

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