deployer

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: Apache-2.0 Imports: 39 Imported by: 2

Documentation

Overview

Copyright 2013 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

With changes for etherman Solidity coverage.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoCoverage           = errors.New("coverage not enabled")
	ErrNoCoverageInContract = errors.New("coverage not compiled into the contract")
)
View Source
var (
	ErrEndpointUnreachable = errors.New("unable to dial EVM RPC endpoint")
	ErrNoChainID           = errors.New("failed to get valid Chain ID")
	ErrNoNonce             = errors.New("failed to get latest from nonce")
)
View Source
var (
	ErrEventNotFound       = errors.New("event not found")
	ErrEventParse          = errors.New("unable to unmarshal log")
	ErrTxNotFound          = errors.New("transaction not found")
	ErrTransactionReverted = errors.New("transaction reverted without logs")
)
View Source
var (
	ErrAwaitTimeout   = errors.New("await timeout")
	ErrNoRevertReason = errors.New("no revert reason")
)
View Source
var ErrClientNotAvailable = errors.New("EVM RPC client is not available due to connection issue")
View Source
var (
	ErrCompilationFailed = errors.New("failed to compile contract code")
)
View Source
var (
	ErrCompilerNotFound = errors.New("unable to locate Solidity compiler")
)
View Source
var ErrNoCache = errors.New("no cached version")

Functions

func NewCoverageMarkerEvent

func NewCoverageMarkerEvent(definitionID uint64) (name string, eventABI abi.ABI)

func OptionBuildCacheDir

func OptionBuildCacheDir(dir string) option

func OptionCallTimeout

func OptionCallTimeout(dur time.Duration) option

func OptionEVMRPCEndpoint

func OptionEVMRPCEndpoint(uri string) option

func OptionEnableCoverage

func OptionEnableCoverage(enabled bool) option

func OptionGasLimit

func OptionGasLimit(gasLimit uint64) option

func OptionGasPrice

func OptionGasPrice(price *big.Int) option

func OptionNoCache

func OptionNoCache(noCache bool) option

func OptionRPCTimeout

func OptionRPCTimeout(dur time.Duration) option

func OptionSignerType

func OptionSignerType(signerType SignerType) option

func OptionSolcAllowedPaths

func OptionSolcAllowedPaths(allowedPaths []string) option

func OptionSolcPath

func OptionSolcPath(dir string) option

func OptionTxTimeout

func OptionTxTimeout(dur time.Duration) option

Types

type AbiMethodInputMapperFunc

type AbiMethodInputMapperFunc func(args abi.Arguments) []interface{}

type BoundContract

type BoundContract struct {
	*bind.BoundContract
	// contains filtered or unexported fields
}

func BindContract

func BindContract(client *ethclient.Client, contract *sol.Contract) (*BoundContract, error)

func (*BoundContract) ABI

func (contract *BoundContract) ABI() abi.ABI

func (*BoundContract) Address

func (contract *BoundContract) Address() common.Address

func (*BoundContract) Client

func (contract *BoundContract) Client() *ethclient.Client

func (*BoundContract) DeployContract

func (c *BoundContract) DeployContract(opts *bind.TransactOpts,
	params ...interface{}) (common.Address, *types.Transaction, error)

DeployContract deploys a contract onto the Ethereum blockchain and binds the deployment address with a Go wrapper.

func (*BoundContract) SetAddress

func (contract *BoundContract) SetAddress(address common.Address)

func (*BoundContract) SetClient

func (contract *BoundContract) SetClient(client *ethclient.Client)

func (*BoundContract) SetTransact

func (contract *BoundContract) SetTransact(fn TransactFunc)

func (*BoundContract) Source

func (contract *BoundContract) Source() *sol.Contract

func (*BoundContract) Transact

func (c *BoundContract) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error)

Transact invokes the (paid) contract method with params as input values.

func (*BoundContract) Transfer

func (c *BoundContract) Transfer(opts *bind.TransactOpts) (*types.Transaction, error)

Transfer initiates a plain transaction to move funds to the contract, calling its default method if one is available.

type BuildCache

type BuildCache interface {
	StoreContract(absSolPath string, contract *sol.Contract) error
	LoadContract(absSolPath, contractName string, coverage bool) (contract *sol.Contract, err error)
	Clear() error
}

func NewBuildCache

func NewBuildCache(prefix string) (BuildCache, error)

type BuildCacheEntry

type BuildCacheEntry struct {
	Timestamp       time.Time       `json:"timestamp"`
	CodeHash        string          `json:"codeHash"`
	AllPaths        []string        `json:"allPaths"`
	ContractName    string          `json:"contractName"`
	CompilerVersion string          `json:"compilerVersion"`
	Coverage        bool            `json:"coverage"`
	Statements      [][]int         `json:"statements"`
	ABI             json.RawMessage `json:"abi"`
	Bin             string          `json:"bin"`
}

type Client

type Client struct {
	*ethclient.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(rc *rpc.Client) *Client

func (*Client) SendTransactionWithRet

func (ec *Client) SendTransactionWithRet(ctx context.Context, tx *types.Transaction) (txHash common.Hash, err error)

type ContractCallOpts

type ContractCallOpts struct {
	From          common.Address
	SolSource     string
	ContractName  string
	Contract      common.Address
	CoverageCall  ContractCoverageCallOpts
	CoverageAgent CoverageDataCollector
	BytecodeOnly  bool
}

type ContractCoverageCallOpts

type ContractCoverageCallOpts struct {
	FromPk   *ecdsa.PrivateKey
	SignerFn bind.SignerFn
}

type ContractDeployOpts

type ContractDeployOpts struct {
	From          common.Address
	FromPk        *ecdsa.PrivateKey
	SignerFn      bind.SignerFn
	SolSource     string
	ContractName  string
	BytecodeOnly  bool
	Await         bool
	CoverageAgent CoverageDataCollector
}

type ContractLogUnpackFunc

type ContractLogUnpackFunc func(unpacker LogUnpacker, event abi.Event, log ctypes.Log) (interface{}, error)

type ContractLogsOpts

type ContractLogsOpts struct {
	// From is required there if calls need to be made
	From common.Address

	SolSource     string
	ContractName  string
	Contract      common.Address
	CoverageAgent CoverageDataCollector
}

type ContractTxOpts

type ContractTxOpts struct {
	From          common.Address
	FromPk        *ecdsa.PrivateKey
	SignerFn      bind.SignerFn
	SolSource     string
	ContractName  string
	Contract      common.Address
	BytecodeOnly  bool
	Await         bool
	CoverageAgent CoverageDataCollector
}

type CoverageDataCollector

type CoverageDataCollector interface {
	LoadContract(contract *sol.Contract) error
	AddStatement(contractName string, start, end, file uint64) error
	CollectCoverageEvent(contractName string, coverageEventABI abi.Event, log *ctypes.Log) error
	CollectCoverageRevert(contractName string, err error) error
	ReportTextSummary(out io.Writer, filterNames ...string) error
	ReportTextCoverfile(out io.Writer, filterNames ...string) error
	ReportHTML(out io.Writer, filterNames ...string) error
}

func NewCoverageDataCollector

func NewCoverageDataCollector(mode CoverageMode) CoverageDataCollector

type CoverageMode

type CoverageMode string
const (
	CoverageModeSet     CoverageMode = "set"
	CoverageModeCount   CoverageMode = "count"
	CoverageModeDefault CoverageMode = CoverageModeCount
)

type Deployer

type Deployer interface {
	Backend() (*Client, error)

	Build(
		ctx context.Context,
		solSource string,
		contractName string,
	) (*sol.Contract, error)

	Deploy(
		ctx context.Context,
		deployOpts ContractDeployOpts,
		constructorInputMapper AbiMethodInputMapperFunc,
	) (txHash common.Hash, contract *sol.Contract, err error)

	Tx(
		ctx context.Context,
		txOpts ContractTxOpts,
		methodName string,
		methodInputMapper AbiMethodInputMapperFunc,
	) (txHash common.Hash, abiPackedArgs []byte, err error)

	Call(
		ctx context.Context,
		callOpts ContractCallOpts,
		methodName string,
		methodInputMapper AbiMethodInputMapperFunc,
	) (output []interface{}, outputAbi abi.Arguments, err error)

	Logs(
		ctx context.Context,
		logsOpts ContractLogsOpts,
		txHash common.Hash,
		eventName string,
		eventUnpacker ContractLogUnpackFunc,
	) (events []interface{}, err error)
}

func New

func New(opts ...option) (Deployer, error)

type LogUnpacker

type LogUnpacker interface {
	UnpackLog(out interface{}, event string, log ctypes.Log) error
}

type SignerType

type SignerType string
const (
	SignerEIP155    SignerType = "eip155"
	SignerHomestead SignerType = "homestead"
)

type TransactFunc

type TransactFunc func(opts *bind.TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error)

Jump to

Keyboard shortcuts

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