compiler

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: GPL-3.0 Imports: 9 Imported by: 460

Documentation

Overview

Package compiler wraps the Solidity and Vyper compiler executables (solc; vyper).

Package compiler wraps the Solidity and Vyper compiler executables (solc; vyper).

Package compiler wraps the Solidity and Vyper compiler executables (solc; vyper).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileSolidity added in v1.5.0

func CompileSolidity(solc string, sourcefiles ...string) (map[string]*Contract, error)

CompileSolidity compiles all given Solidity source files.

func CompileSolidityString added in v1.5.0

func CompileSolidityString(solc, source string) (map[string]*Contract, error)

CompileSolidityString builds and returns all the contracts contained within a source string.

func CompileVyper added in v1.9.0

func CompileVyper(vyper string, sourcefiles ...string) (map[string]*Contract, error)

CompileVyper compiles all given Vyper source files.

func ParseCombinedJSON added in v1.8.11

func ParseCombinedJSON(combinedJSON []byte, source string, languageVersion string, compilerVersion string, compilerOptions string) (map[string]*Contract, error)

ParseCombinedJSON takes the direct output of a solc --combined-output run and parses it into a map of string contract name to Contract structs. The provided source, language and compiler version, and compiler options are all passed through into the Contract structs.

The solc output is expected to contain ABI, source mapping, user docs, and dev docs.

Returns an error if the JSON is malformed or missing data, or if the JSON embedded within the JSON is malformed.

func ParseVyperJSON added in v1.9.0

func ParseVyperJSON(combinedJSON []byte, source string, languageVersion string, compilerVersion string, compilerOptions string) (map[string]*Contract, error)

ParseVyperJSON takes the direct output of a vyper --f combined_json run and parses it into a map of string contract name to Contract structs. The provided source, language and compiler version, and compiler options are all passed through into the Contract structs.

The vyper output is expected to contain ABI and source mapping.

Returns an error if the JSON is malformed or missing data, or if the JSON embedded within the JSON is malformed.

Types

type Contract

type Contract struct {
	Code        string            `json:"code"`
	RuntimeCode string            `json:"runtime-code"`
	Info        ContractInfo      `json:"info"`
	Hashes      map[string]string `json:"hashes"`
}

Contract contains information about a compiled contract, alongside its code and runtime code.

type ContractInfo

type ContractInfo struct {
	Source          string      `json:"source"`
	Language        string      `json:"language"`
	LanguageVersion string      `json:"languageVersion"`
	CompilerVersion string      `json:"compilerVersion"`
	CompilerOptions string      `json:"compilerOptions"`
	SrcMap          interface{} `json:"srcMap"`
	SrcMapRuntime   string      `json:"srcMapRuntime"`
	AbiDefinition   interface{} `json:"abiDefinition"`
	UserDoc         interface{} `json:"userDoc"`
	DeveloperDoc    interface{} `json:"developerDoc"`
	Metadata        string      `json:"metadata"`
}

ContractInfo contains information about a compiled contract, including access to the ABI definition, source mapping, user and developer docs, and metadata.

Depending on the source, language version, compiler version, and compiler options will provide information about how the contract was compiled.

type Solidity

type Solidity struct {
	Path, Version, FullVersion string
	Major, Minor, Patch        int
}

Solidity contains information about the solidity compiler.

func SolidityVersion added in v1.5.0

func SolidityVersion(solc string) (*Solidity, error)

SolidityVersion runs solc and parses its version output.

type Vyper added in v1.9.0

type Vyper struct {
	Path, Version, FullVersion string
	Major, Minor, Patch        int
}

Vyper contains information about the vyper compiler.

func VyperVersion added in v1.9.0

func VyperVersion(vyper string) (*Vyper, error)

VyperVersion runs vyper and parses its version output.

Jump to

Keyboard shortcuts

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