Documentation ¶
Index ¶
- Constants
- func BindContract(address common.Address, abi abi.ABI, client Client) *bind.BoundContract
- func EventEmitted(ctx context.Context, c EthClient, from *big.Int, addresses []common.Address, ...) error
- func IsTxnSuccessful(ctx context.Context, c ethereum.TransactionReader, txnHash common.Hash) (addr common.Address, err error)
- func SetClient(client Client)
- func SubmitTransaction(contractMethod interface{}, opts *bind.TransactOpts, params ...interface{}) (tx *types.Transaction, err error)
- type Bootstrapper
- type Client
- type Config
- type EthClient
Constants ¶
const ( // ErrTransactionUnderpriced transaction is under priced ErrTransactionUnderpriced = errors.Error("replacement transaction underpriced") // ErrNonceTooLow nonce is too low ErrNonceTooLow = errors.Error("nonce too low") // ErrTransactionFailed error when transaction failed ErrTransactionFailed = errors.Error("Transaction failed") // ErrEthTransaction is a generic error type to be used for Ethereum errors ErrEthTransaction = errors.Error("error on ethereum tx layer") // ErrEthURL is used when failed to parse ethereum node URL ErrEthURL = errors.Error("failed to parse ethereum node URL") // ErrEthKeyNotProvided holds specific error when ethereum key is not provided ErrEthKeyNotProvided = errors.Error("Ethereum Key not provided") )
const BootstrappedEthereumClient string = "BootstrappedEthereumClient"
BootstrappedEthereumClient is a key to mapped client in bootstrap context.
Variables ¶
This section is empty.
Functions ¶
func BindContract ¶ added in v1.0.0
BindContract returns a bind contract at the address with corresponding ABI
func EventEmitted ¶ added in v1.3.0
func EventEmitted( ctx context.Context, c EthClient, from *big.Int, addresses []common.Address, eventSignature string, topic common.Hash) error
EventEmitted checks if the given event is emitted with given topic from the provided address since the from block.
func IsTxnSuccessful ¶ added in v1.3.0
func IsTxnSuccessful( ctx context.Context, c ethereum.TransactionReader, txnHash common.Hash) (addr common.Address, err error)
IsTxnSuccessful checks if the transaction is successful returns contract address that was created if the txn created a contract
func SetClient ¶
func SetClient(client Client)
SetClient sets the Client Note that this is a singleton and is the same connection for the whole application.
func SubmitTransaction ¶ added in v1.3.0
func SubmitTransaction( contractMethod interface{}, opts *bind.TransactOpts, params ...interface{}) (tx *types.Transaction, err error)
SubmitTransaction signs the txn and submits to the net. Returns the transaction details
Types ¶
type Bootstrapper ¶
type Bootstrapper struct{}
Bootstrapper implements bootstrap.Bootstrapper.
func (Bootstrapper) Bootstrap ¶
func (Bootstrapper) Bootstrap(ctx map[string]interface{}) error
Bootstrap initialises ethereum client.
type Client ¶
type Client interface { // GetEthClient returns the ethereum client GetEthClient() EthClient // GetBlockByNumber returns the block by number GetBlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) // GetTxOpts returns a cached options if available else creates and returns new options GetTxOpts(ctx context.Context, accountName string) (*bind.TransactOpts, error) // SubmitTransactionWithRetries submits transaction to the ethereum chain // Blocking Function that sends transaction using reflection wrapped in a retrial block. It is based on the ErrTransactionUnderpriced error, // meaning that a transaction is being attempted to run twice, and the logic is to override the existing one. As we have constant // gas prices that means that a concurrent transaction race condition event has happened. // - contractMethod: Contract Method that implements GenericEthereumAsset (usually autogenerated binding from abi) // - params: Arbitrary number of parameters that are passed to the function fname call // Note: contractMethod must always return "*types.Job, error" SubmitTransactionWithRetries(contractMethod interface{}, opts *bind.TransactOpts, params ...interface{}) (tx *types.Transaction, err error) // GetGethCallOpts returns the Call options with default GetGethCallOpts(pending bool) (*bind.CallOpts, context.CancelFunc) // TransactionByHash returns a Ethereum transaction TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error) // TransactionReceipt return receipt of a transaction TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) }
Client can be implemented by any chain client
func NewGethClient ¶
NewGethClient returns an gethClient which implements Client
type Config ¶
type Config interface { GetEthereumMaxGasPrice() *big.Int GetEthereumNodeURL() string GetEthereumAccount(accountName string) (account *config.AccountConfig, err error) GetEthereumIntervalRetry() time.Duration GetEthereumMaxRetries() int GetEthereumContextReadWaitTimeout() time.Duration GetEthereumGasMultiplier() float64 }
Config defines functions to get ethereum details
type EthClient ¶ added in v1.0.0
type EthClient interface { ethereum.ChainReader ethereum.ChainSyncReader ethereum.TransactionReader bind.ContractBackend NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error) ChainID(ctx context.Context) (*big.Int, error) }
EthClient abstracts the implementation of eth client