Compiler

Compiler

Compiler class, abstracting solc.

Constructor

new Compiler(options, logSetting)

Source:

Initialize a Compiler object.

Parameters:
Name Type Description
options object

User options

logSetting Logger.state.ENUM

Log setting, as represented by the Logger state enum.

Methods

compile(solcInput) → {object}

Source:
Parameters:
Name Type Description
solcInput object

The JSON input for the solc.js Solidity Compiler. See: https://solidity.readthedocs.io/en/v0.5.7/using-the-compiler.html#input-description

Returns:

output - The returned output generated by solc. See link above!

Type
object

compileDirectory(rootopt) → {object}

Source:

A function which recursively searches through the given directory passed, pasgenerating a solc input, compiling it, and returning the raw compiler output.

If no root filepath is passed, it will assume that the "contracts" folder one level higher than the current dir is the root where all contracts are located.

Parameters:
Name Type Attributes Default Description
root string <optional>
path.resolve(__dirname, '../contracts')

The root directory in which the function will start from, recursively navigated through to parse all contracts found into a solc input.

Returns:

output - The returned output generated by solc. See: https://solidity.readthedocs.io/en/v0.5.7/using-the-compiler.html#output-description

Type
object

compileFile(filepath, rootopt) → {object}

Source:

A function which simply compiles a single file located at the given filepath.

If no root is provided in the second argument, it will assume that the "contracts" folder one level higher than the current dir is the root where all contracts are located.

Parameters:
Name Type Attributes Default Description
filepath string

The filepath at which the file is located.

root string <optional>
path.resolve(__dirname, '../contracts')

The root directory in which all contracts are located; this is for contract naming specification within the solc input.

Returns:

output - The returned output generated by solc. See: https://solidity.readthedocs.io/en/v0.5.7/using-the-compiler.html#output-description

Type
object

compileSource(base, src) → {object}

Source:

A function which compiles a raw "contract solc input name" and source code.

Parameters:
Name Type Description
base string

The "raw contract solc input name" (i.e. 'erc20/ERC20Interface.sol')

src string

The raw Solidity smart contract code as a string.

Returns:

output - The returned output generated by solc. See: https://solidity.readthedocs.io/en/v0.5.7/using-the-compiler.html#output-description

Type
object