Documentation ¶
Index ¶
- Constants
- Variables
- func Poll(interval, deadline time.Duration, condition ConditionFunc) error
- func RevertReason(ctx context.Context, c ethClienter, tx *types.Transaction, ...) (string, error)
- func WaitSignal(cleanupFuncs ...func())
- func WaitTxReceipt(ctx context.Context, txHash common.Hash, timeout time.Duration, ...) (*types.Receipt, error)
- func WaitTxToBeMined(parentCtx context.Context, client ethClienter, tx *types.Transaction, ...) error
- type Client
- func (etherMan *Client) AddOrReplaceAuth(auth bind.TransactOpts) error
- func (etherMan *Client) CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error)
- func (etherMan *Client) CurrentNonce(ctx context.Context, account common.Address) (uint64, error)
- func (etherMan *Client) EstimateGas(ctx context.Context, from common.Address, to *common.Address, value *big.Int, ...) (uint64, error)
- func (etherMan *Client) EstimateGasBlobTx(ctx context.Context, from common.Address, to *common.Address, ...) (uint64, error)
- func (etherMan *Client) GetHeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (etherMan *Client) GetL1GasPrice(ctx context.Context) *big.Int
- func (etherMan *Client) GetLatestBlockNumber(ctx context.Context) (uint64, error)
- func (etherMan *Client) GetRevertMessage(ctx context.Context, tx *types.Transaction) (string, error)
- func (etherMan *Client) GetSuggestGasTipCap(ctx context.Context) (*big.Int, error)
- func (etherMan *Client) GetTx(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error)
- func (etherMan *Client) GetTxReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- func (etherMan *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, error)
- func (etherMan *Client) PendingNonce(ctx context.Context, account common.Address) (uint64, error)
- func (etherMan *Client) SendTx(ctx context.Context, tx *types.Transaction) error
- func (etherMan *Client) SignTx(ctx context.Context, sender common.Address, tx *types.Transaction) (*types.Transaction, error)
- func (etherMan *Client) SuggestedGasPrice(ctx context.Context) (*big.Int, error)
- func (etherMan *Client) WaitTxToBeMined(ctx context.Context, tx *types.Transaction, timeout time.Duration) (bool, error)
- type ConditionFunc
- type Config
- type Wait
Constants ¶
const ( // DefaultInterval is a time interval DefaultInterval = 2 * time.Millisecond // DefaultDeadline is a time interval DefaultDeadline = 2 * time.Minute // DefaultTxMinedDeadline is a time interval DefaultTxMinedDeadline = 5 * time.Second )
Variables ¶
var ( // ErrNotFound is used when the object is not found ErrNotFound = errors.New("not found") // ErrPrivateKeyNotFound used when the provided sender does not have a private key registered to be used ErrPrivateKeyNotFound = errors.New("can't find sender private key to sign tx") )
var ( // ErrTimeoutReached is thrown when the timeout is reached and // because the condition is not matched ErrTimeoutReached = fmt.Errorf("timeout has been reached") )
Functions ¶
func Poll ¶
func Poll(interval, deadline time.Duration, condition ConditionFunc) error
Poll retries the given condition with the given interval until it succeeds or the given deadline expires.
func RevertReason ¶
func RevertReason(ctx context.Context, c ethClienter, tx *types.Transaction, blockNumber *big.Int) (string, error)
RevertReason returns the revert reason for a tx that has a receipt with failed status
func WaitSignal ¶
func WaitSignal(cleanupFuncs ...func())
WaitSignal blocks until an Interrupt or Kill signal is received, then it executes the given cleanup functions and returns.
func WaitTxReceipt ¶
func WaitTxReceipt( ctx context.Context, txHash common.Hash, timeout time.Duration, client *ethclient.Client, ) (*types.Receipt, error)
WaitTxReceipt waits until a tx receipt is available or the given timeout expires.
func WaitTxToBeMined ¶
func WaitTxToBeMined( parentCtx context.Context, client ethClienter, tx *types.Transaction, timeout time.Duration, ) error
WaitTxToBeMined waits until a tx has been mined or the given timeout expires.
Types ¶
type Client ¶
type Client struct { EthClient ethereumClient GasProviders externalGasProviders // contains filtered or unexported fields }
Client is a simple implementation of EtherMan.
func (*Client) AddOrReplaceAuth ¶
func (etherMan *Client) AddOrReplaceAuth(auth bind.TransactOpts) error
AddOrReplaceAuth adds an authorization or replace an existent one to the same account
func (*Client) CheckTxWasMined ¶
func (etherMan *Client) CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error)
CheckTxWasMined check if a tx was already mined
func (*Client) CurrentNonce ¶
CurrentNonce returns the current nonce for the provided account
func (*Client) EstimateGas ¶
func (etherMan *Client) EstimateGas( ctx context.Context, from common.Address, to *common.Address, value *big.Int, data []byte, ) (uint64, error)
EstimateGas returns the estimated gas for the tx
func (*Client) EstimateGasBlobTx ¶ added in v0.1.0
func (etherMan *Client) EstimateGasBlobTx( ctx context.Context, from common.Address, to *common.Address, gasFeeCap *big.Int, gasTipCap *big.Int, value *big.Int, data []byte, ) (uint64, error)
EstimateGasBlobTx returns the estimated gas for the blob tx
func (*Client) GetHeaderByNumber ¶ added in v0.1.0
func (etherMan *Client) GetHeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
GetHeaderByNumber returns a block header from the current canonical chain. If number is nil the latest header is returned
func (*Client) GetL1GasPrice ¶
GetL1GasPrice gets the l1 gas price
func (*Client) GetLatestBlockNumber ¶
GetLatestBlockNumber gets the latest block number from the ethereum
func (*Client) GetRevertMessage ¶
func (etherMan *Client) GetRevertMessage(ctx context.Context, tx *types.Transaction) (string, error)
GetRevertMessage tries to get a revert message of a transaction
func (*Client) GetSuggestGasTipCap ¶ added in v0.1.0
GetSuggestGasTipCap retrieves the currently suggested gas tip cap after EIP-1559 for timely transaction execution.
func (*Client) GetTx ¶
func (etherMan *Client) GetTx(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error)
GetTx function get ethereum tx
func (*Client) GetTxReceipt ¶
func (etherMan *Client) GetTxReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
GetTxReceipt function gets ethereum tx receipt
func (*Client) HeaderByNumber ¶ added in v0.1.5
HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.
func (*Client) LoadAuthFromKeyStore ¶
func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, error)
LoadAuthFromKeyStore loads an authorization from a key store file
func (*Client) PendingNonce ¶
PendingNonce returns the pending nonce for the provided account
func (*Client) SignTx ¶
func (etherMan *Client) SignTx( ctx context.Context, sender common.Address, tx *types.Transaction, ) (*types.Transaction, error)
SignTx tries to sign a transaction accordingly to the provided sender
func (*Client) SuggestedGasPrice ¶
SuggestedGasPrice returns the suggest nonce for the network at the moment
type ConditionFunc ¶
ConditionFunc is a generic function
type Config ¶
type Config struct { // URL is the URL of the Ethereum node for L1 URL string `mapstructure:"URL"` // allow that L1 gas price calculation use multiples sources MultiGasProvider bool `mapstructure:"MultiGasProvider"` // Configuration for use Etherscan as used as gas provider, basically it needs the API-KEY Etherscan etherscan.Config // L1ChainID is the chain ID of the L1 L1ChainID uint64 `mapstructure:"L1ChainID"` // HTTPHeaders are the headers to be used in the HTTP requests HTTPHeaders map[string]string `mapstructure:"HTTPHeaders"` }
Config represents the configuration of the etherman