bclient

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Overview

Package bclient provides a wrapper around go-ethereum's ethclient package

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotEthClient is an error return when attempting to do type conversions against the
	// blockchain interface to an ethclient, when the underlying blockchain interface is not
	// an ethclient type. Usually will be encountered when using a simulated backend
	ErrNotEthClient = errors.New("underlying blockchain provider is not of type ethclient.Client")
	// ErrNotSimulatedBackend is an error returned when attempting to do type conversions against the
	// blockchain interface to a simulated backend, when the underlying blockchain interface is not
	// a simulated backend type. Usually will be encountered when using an ethclient backend
	ErrNotSimulatedBackend = errors.New("underlying blockchain provider is not of type simulated backend")
)
View Source
var (
	// WETHTokenAddress is the address of the WETH token contract
	WETHTokenAddress = common.HexToAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
	// DAITokenAddress is the address of the MCD (Multi Collateral DAI) contract
	DAITokenAddress = common.HexToAddress("0x6b175474e89094c44da98b954eedeac495271d0f")
)

token addresses

Functions

This section is empty.

Types

type BClient

type BClient struct {
	// contains filtered or unexported fields
}

BClient wraps ethclient and provides helper functions for commonly used functionality

func NewClient

func NewClient(ctx context.Context, bc utils.Blockchain) (*BClient, error)

New returns a new bclient implementation without any authentication as well as wrappers around the uniswap and sushiswap clients. All underlying types are exposed in addition to helper functions

func (*BClient) Blockchain added in v0.0.4

func (bc *BClient) Blockchain() utils.Blockchain

Blockchain returns the underlying blockchain interface

func (*BClient) ChainID added in v0.0.4

func (bc *BClient) ChainID() (*big.Int, error)

ChainID performs a best effort at determining the chainid we do this by first attempting to retrieve the id from a simulated backend, and if that fails get the chain id from an ethclient

func (*BClient) Close

func (bc *BClient) Close()

Close terminates the blockchain connection

func (*BClient) Context

func (bc *BClient) Context() context.Context

func (*BClient) CurrentBlock

func (bc *BClient) CurrentBlock() (uint64, error)

CurrentBlock returns the current block known by the ethereum client

func (*BClient) EncodeTx added in v0.0.4

func (bc *BClient) EncodeTx(hash string) (string, error)

EncodeTx is used to marshal a transaction and hex encode it suitable for encoding transctions and storing them into a database

func (*BClient) EthClient

func (bc *BClient) EthClient() (*ethclient.Client, error)

EthClient attempts to conver the Blockchain interface to an ethclient type returning an error if unable to type convert the interface. This likely indicates that a simulated backend is being used

func (*BClient) EthDaiPrice

func (bc *BClient) EthDaiPrice() (*big.Int, error)

EthDaiPrice returns the price of ETH in terms of DAI

func (*BClient) SimulatedBackend added in v0.0.4

func (bc *BClient) SimulatedBackend() (*testenv.Testenv, error)

SimulatedBackend attempts to conver the Blockchain interface to a simulated backend type returning an error if unable to type convert the interface. This likely indicates that an ethclient backend is being used

func (*BClient) Sushiswap

func (bc *BClient) Sushiswap() *sushiswap.Client

Sushiswap returns the underlying sushiswap client

func (*BClient) Uniswap

func (bc *BClient) Uniswap() *uniswap.Client

Uniswap returns the underlying uniswap client

Jump to

Keyboard shortcuts

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