-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package utils | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum" | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
) | ||
|
||
// Blockchain is a generalized interface for interacting with the ethereum blockchain | ||
type Blockchain interface { | ||
// CodeAt returns the code of the given account. This is needed to differentiate | ||
// between contract internal errors and the local chain being out of sync. | ||
CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error) | ||
// ContractCall executes an Ethereum contract call with the specified data as the | ||
// input. | ||
CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) | ||
// PendingCodeAt returns the code of the given account in the pending state. | ||
PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) | ||
// PendingCallContract executes an Ethereum contract call against the pending state. | ||
PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error) | ||
// PendingNonceAt retrieves the current pending nonce associated with an account. | ||
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) | ||
// SuggestGasPrice retrieves the currently suggested gas price to allow a timely | ||
// execution of a transaction. | ||
SuggestGasPrice(ctx context.Context) (*big.Int, error) | ||
// EstimateGas tries to estimate the gas needed to execute a specific | ||
// transaction based on the current pending state of the backend blockchain. | ||
// There is no guarantee that this is the true gas limit requirement as other | ||
// transactions may be added or removed by miners, but it should provide a basis | ||
// for setting a reasonable default. | ||
EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error) | ||
// SendTransaction injects the transaction into the pending pool for execution. | ||
SendTransaction(ctx context.Context, tx *types.Transaction) error | ||
// FilterLogs executes a log filter operation, blocking during execution and | ||
// returning all the results in one batch. | ||
// | ||
// TODO(karalabe): Deprecate when the subscription one can return past data too. | ||
FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) | ||
// SubscribeFilterLogs creates a background log filtering operation, returning | ||
// a subscription immediately, which can be used to stream the found events. | ||
SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) | ||
TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) | ||
} |