hardhat

package
v0.10.14 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCannotFindDeployment = errors.New("cannot find deployment")
	ErrCannotFindArtifact   = errors.New("cannot find artifact")
)

Functions

func GetFullyQualifiedName

func GetFullyQualifiedName(sourceName, contractName string) string

func IsFullyQualifiedName

func IsFullyQualifiedName(name string) bool

Types

type Artifact

type Artifact struct {
	Format                 string         `json:"_format"`
	ContractName           string         `json:"contractName"`
	SourceName             string         `json:"sourceName"`
	Abi                    abi.ABI        `json:"abi"`
	Bytecode               hexutil.Bytes  `json:"bytecode"`
	DeployedBytecode       hexutil.Bytes  `json:"deployedBytecode"`
	LinkReferences         LinkReferences `json:"linkReferences"`
	DeployedLinkReferences LinkReferences `json:"deployedLinkReferences"`
}

Artifact represents a hardhat compilation artifact The Bytecode and DeployedBytecode are not guaranteed to be hexutil.Bytes when there are link references. In the future, custom json marshalling can be used to place the link reference values in the correct location.

type BuildInfo

type BuildInfo struct {
	Format          string              `json:"_format"`
	Id              string              `json:"id"`
	SolcVersion     string              `json:"solcVersion"`
	SolcLongVersion string              `json:"solcLongVersion"`
	Input           solc.CompilerInput  `json:"input"`
	Output          solc.CompilerOutput `json:"output"`
}

BuildInfo represents a hardhat build info artifact that is created after compilation

type DebugFile

type DebugFile struct {
	Format    string `json:"_format"`
	BuildInfo string `json:"buildInfo"`
}

DebugFile represents the debug file that contains the path to the build info file

type Deployment

type Deployment struct {
	Name             string
	Abi              abi.ABI            `json:"abi"`
	Address          common.Address     `json:"address"`
	Args             []any              `json:"args"`
	Bytecode         hexutil.Bytes      `json:"bytecode"`
	DeployedBytecode hexutil.Bytes      `json:"deployedBytecode"`
	Devdoc           json.RawMessage    `json:"devdoc"`
	Metadata         string             `json:"metadata"`
	Receipt          Receipt            `json:"receipt"`
	SolcInputHash    string             `json:"solcInputHash"`
	StorageLayout    solc.StorageLayout `json:"storageLayout"`
	TransactionHash  common.Hash        `json:"transactionHash"`
	Userdoc          json.RawMessage    `json:"userdoc"`
}

Deployment represents a hardhat-deploy artifact file

type Hardhat

type Hardhat struct {
	ArtifactPaths   []string
	DeploymentPaths []string
	// contains filtered or unexported fields
}

`Hardhat` encapsulates all of the functionality required to interact with hardhat style artifacts.

func New

func New(network string, artifacts, deployments []string) (*Hardhat, error)

New creates a new `Hardhat` struct and reads all of the files from disk so that they are cached for the end user. A network is passed that corresponds to the network that they deployments are associated with. A slice of artifact paths and deployment paths are passed so that a single `Hardhat` instance can operate on multiple sets of artifacts and deployments. The deployments paths should be the root of the deployments directory that contains additional directories for each particular network.

func (*Hardhat) GetArtifact

func (h *Hardhat) GetArtifact(name string) (*Artifact, error)

GetArtifact returns the artifact that corresponds to the contract. This method supports just the contract name and the fully qualified contract name.

func (*Hardhat) GetBuildInfo

func (h *Hardhat) GetBuildInfo(name string) (*BuildInfo, error)

GetBuildInfo returns the build info that corresponds to the contract. It does not support fully qualified contract names.

func (*Hardhat) GetDeployment

func (h *Hardhat) GetDeployment(name string) (*Deployment, error)

GetDeployment returns the deployment that corresponds to the contract. It does not support fully qualified contract names.

func (*Hardhat) GetStorageLayout

func (h *Hardhat) GetStorageLayout(name string) (*solc.StorageLayout, error)

TODO(tynes): handle fully qualified names properly

type LinkReference

type LinkReference map[string][]LinkReferenceOffset

LinkReference represents a single linked contract

type LinkReferenceOffset

type LinkReferenceOffset struct {
	Length uint `json:"length"`
	Start  uint `json:"start"`
}

LinkReferenceOffset represents the offsets in a link reference

type LinkReferences

type LinkReferences map[string]LinkReference

LinkReferences represents the linked contracts

type Log

type Log struct {
	TransactionIndex uint           `json:"transactionIndex"`
	BlockNumber      uint           `json:"blockNumber"`
	TransactionHash  common.Hash    `json:"transactionHash"`
	Address          common.Address `json:"address"`
	Topics           []common.Hash  `json:"topics"`
	Data             hexutil.Bytes  `json:"data"`
	LogIndex         uint           `json:"logIndex"`
	Blockhash        common.Hash    `json:"blockHash"`
}

Log represents the logs in the hardhat deploy artifact receipt

type QualifiedName

type QualifiedName struct {
	SourceName   string
	ContractName string
}

func ParseFullyQualifiedName

func ParseFullyQualifiedName(name string) QualifiedName

type Receipt

type Receipt struct {
	To                *common.Address `json:"to"`
	From              common.Address  `json:"from"`
	ContractAddress   *common.Address `json:"contractAddress"`
	TransactionIndex  uint            `json:"transactionIndex"`
	GasUsed           uint            `json:"gasUsed,string"`
	LogsBloom         hexutil.Bytes   `json:"logsBloom"`
	BlockHash         common.Hash     `json:"blockHash"`
	TransactionHash   common.Hash     `json:"transactionHash"`
	Logs              []Log           `json:"logs"`
	BlockNumber       uint            `json:"blockNumber"`
	CumulativeGasUsed uint            `json:"cumulativeGasUsed,string"`
	Status            uint            `json:"status"`
	Byzantium         bool            `json:"byzantium"`
}

Receipt represents the receipt held in a hardhat-deploy artifact file

Jump to

Keyboard shortcuts

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