Documentation ¶
Index ¶
- Variables
- func Bytes32Enum(in interface{}) interface{}
- func Mine(backend *backends.SimulatedBackend) (stopMining func())
- func MustNewKeyedTransactor(t *testing.T, key *ecdsa.PrivateKey, chainID int64) *bind.TransactOpts
- func MustNewSimulatedBackendKeyedTransactor(t *testing.T, key *ecdsa.PrivateKey) *bind.TransactOpts
- func NewHash() common.Hash
- func NewSimulatedBackendIdentity(t *testing.T) *bind.TransactOpts
- func TestRinkebyPool(t *testing.T)
- func ToHex(b Bytes32) string
- func ToOGRN(orgId Bytes32) string
- func ToString(b Bytes32) string
- func ToString8(b Bytes8) string
- type Bytes16
- type Bytes32
- type Bytes8
- type ContractBackend
- type ContractCaller
- type ContractFilterer
- type ContractTransactor
- type PendingContractCaller
- type SimulatedBackendClient
- func (c *SimulatedBackendClient) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
- func (c *SimulatedBackendClient) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
- func (c *SimulatedBackendClient) BlockByNumber(ctx context.Context, n *big.Int) (*types.Block, error)
- func (c *SimulatedBackendClient) Call(result interface{}, method string, args ...interface{}) error
- func (c *SimulatedBackendClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
- func (c *SimulatedBackendClient) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (c *SimulatedBackendClient) ChainID(context.Context) (*big.Int, error)
- func (c *SimulatedBackendClient) Close()
- func (c *SimulatedBackendClient) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
- func (c *SimulatedBackendClient) Dial(context.Context) error
- func (c *SimulatedBackendClient) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
- func (c *SimulatedBackendClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) (logs []types.Log, err error)
- func (c *SimulatedBackendClient) GetERC20Balance(address common.Address, contractAddress common.Address) (balance *big.Int, err error)
- func (c *SimulatedBackendClient) GetEthBalance(ctx context.Context, account common.Address, blockNumber *big.Int) (*assets.Eth, error)
- func (c *SimulatedBackendClient) GetLINKBalance(linkAddress common.Address, address common.Address) (*assets.Link, error)
- func (c *SimulatedBackendClient) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
- func (c *SimulatedBackendClient) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (c *SimulatedBackendClient) SendRawTx(txBytes []byte) (txHash common.Hash, err error)
- func (c *SimulatedBackendClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (c *SimulatedBackendClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, channel chan<- types.Log) (ethereum.Subscription, error)
- func (c *SimulatedBackendClient) SubscribeNewHead(ctx context.Context, channel chan<- *models.Head) (ethereum.Subscription, error)
- func (c *SimulatedBackendClient) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (c *SimulatedBackendClient) TransactionReceipt(ctx context.Context, receipt common.Hash) (*types.Receipt, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoCode is returned by call and transact operations for which the requested // recipient contract to operate on does not exist in the state db or does not // have any code associated with it (i.e. suicided). ErrNoCode = errors.New("no contract code at given address") // This error is raised when attempting to perform a pending state action // on a backend that doesn't implement PendingContractCaller. ErrNoPendingState = errors.New("backend does not support pending state") // This error is returned by WaitForDeploy if contract creation leaves an // empty contract behind. ErrNoCodeAfterDeploy = errors.New("no contract code after deployment") ErrIsNotDeploy = errors.New("tx is not a contract deployment") ErrZeroAddress = errors.New("zero contract address after deployment") )
var ErrHexTooShort = errors.New("hex string is shorter than bytes32")
var ErrStringTooLong = errors.New("string to long")
Functions ¶
func Bytes32Enum ¶
func Bytes32Enum(in interface{}) interface{}
func Mine ¶
func Mine(backend *backends.SimulatedBackend) (stopMining func())
Mine forces the simulated backend to produce a new block every 2 seconds
func MustNewKeyedTransactor ¶
func MustNewKeyedTransactor(t *testing.T, key *ecdsa.PrivateKey, chainID int64) *bind.TransactOpts
func MustNewSimulatedBackendKeyedTransactor ¶
func MustNewSimulatedBackendKeyedTransactor(t *testing.T, key *ecdsa.PrivateKey) *bind.TransactOpts
func NewSimulatedBackendIdentity ¶
func NewSimulatedBackendIdentity(t *testing.T) *bind.TransactOpts
newIdentity returns a go-ethereum abstraction of an ethereum account for interacting with contract golang wrappers
func TestRinkebyPool ¶
Types ¶
type ContractBackend ¶
type ContractBackend interface { ContractCaller ContractTransactor ContractFilterer }
ContractBackend defines the methods needed to work with contracts on a read-write basis.
type ContractCaller ¶
type ContractCaller 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) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) }
ContractCaller defines the methods needed to allow operating with contract on a read only basis.
type ContractFilterer ¶
type ContractFilterer interface { // 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) }
ContractFilterer defines the methods needed to access log events using one-off queries or continuous event subscriptions.
type ContractTransactor ¶
type ContractTransactor interface { // PendingCodeAt returns the code of the given account in the pending state. PendingCodeAt(ctx context.Context, account common.Address) ([]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) GasLimit(ctx context.Context) (limit uint64, err error) // SendTransaction injects the transaction into the pending pool for execution. SendTransaction(ctx context.Context, tx *types.Transaction) error }
ContractTransactor defines the methods needed to allow operating with contract on a write only basis. Beside the transacting method, the remainder are helpers used when the user does not provide some needed values, but rather leaves it up to the transactor to decide.
type PendingContractCaller ¶
type PendingContractCaller interface { // 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) }
PendingContractCaller defines methods to perform contract calls on the pending state. Call will try to discover this interface when access to the pending state is requested. If the backend does not support the pending state, Call returns ErrNoPendingState.
type SimulatedBackendClient ¶
type SimulatedBackendClient struct {
// contains filtered or unexported fields
}
SimulatedBackendClient is an eth.Client implementation using a simulated blockchain backend. Note that not all RPC methods are implemented here.
func (*SimulatedBackendClient) BatchCallContext ¶
func (*SimulatedBackendClient) BlockByNumber ¶
func (*SimulatedBackendClient) Call ¶
func (c *SimulatedBackendClient) Call(result interface{}, method string, args ...interface{}) error
Call mocks the ethereum client RPC calls used by chainlink, copying the return value into result.
func (*SimulatedBackendClient) CallContext ¶
func (c *SimulatedBackendClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
func (*SimulatedBackendClient) CallContract ¶
func (*SimulatedBackendClient) Close ¶
func (c *SimulatedBackendClient) Close()
Close terminates the underlying blockchain's update loop.
func (*SimulatedBackendClient) EstimateGas ¶
func (c *SimulatedBackendClient) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
func (*SimulatedBackendClient) FilterLogs ¶
func (c *SimulatedBackendClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) (logs []types.Log, err error)
FilterLogs returns all logs that respect the passed filter query.
func (*SimulatedBackendClient) GetERC20Balance ¶
func (c *SimulatedBackendClient) GetERC20Balance(address common.Address, contractAddress common.Address) (balance *big.Int, err error)
GetERC20Balance returns the balance of the given address for the token contract address.
func (*SimulatedBackendClient) GetEthBalance ¶
func (*SimulatedBackendClient) GetLINKBalance ¶
func (*SimulatedBackendClient) PendingCodeAt ¶
func (*SimulatedBackendClient) PendingNonceAt ¶
func (*SimulatedBackendClient) SendRawTx ¶
func (c *SimulatedBackendClient) SendRawTx(txBytes []byte) (txHash common.Hash, err error)
SendRawTx sends a signed transaction to the transaction pool.
func (*SimulatedBackendClient) SendTransaction ¶
func (c *SimulatedBackendClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
func (*SimulatedBackendClient) SubscribeFilterLogs ¶
func (c *SimulatedBackendClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, channel chan<- types.Log) (ethereum.Subscription, error)
SubscribeToLogs registers a subscription for push notifications of logs from a given address.
func (*SimulatedBackendClient) SubscribeNewHead ¶
func (c *SimulatedBackendClient) SubscribeNewHead( ctx context.Context, channel chan<- *models.Head, ) (ethereum.Subscription, error)
SubscribeToNewHeads registers a subscription for push notifications of new blocks.
func (*SimulatedBackendClient) SuggestGasPrice ¶
func (*SimulatedBackendClient) TransactionReceipt ¶
func (c *SimulatedBackendClient) TransactionReceipt(ctx context.Context, receipt common.Hash) (*types.Receipt, error)
TransactionReceipt returns the transaction receipt for the given transaction hash.