embark/packages/embark-compiler/README.md

61 lines
1.6 KiB
Markdown
Raw Normal View History

## Embark Compiler module
This module abstracts the compiler interface. It exposes a plugin api to register contract extensions and how to handle them. It accepts command requests to compile and returns the aggregated compilation result.
### API
**command: `compiler:contracts`**
arguments:
* `contractFiles` - <array of embark File Objects>
2019-01-14 11:21:40 +00:00
* `options` - <object> config object `{isCoverage: boolean (default: false)}`
response:
* `error`
* `compiledObject` - compilation result
```
{
runtimeBytecode: <deployed bytecode>
realRuntimeByteCode: <deployed bytecode without swarm hash>
code: <bytecode>
abiDefinition: <abi object>
swarmHash: (optional)
gasEstimates: (optional)
functionHashes: (optional)
filename: (optional) <contract relative filename>
originalFilename: (optional) <contract real filename>
}
```
example:
```
2019-01-14 11:21:40 +00:00
import { File } from 'src/lib/core/file.js';
const contractFiles = [(new File({path: "simplestorage.sol", type: "custom", resolver: (cb) => { return cb(".. contract code...") }}))];
embark.events.request("compiler:contracts", contractFiles, {}, (err, compiledObject) => {
})
```
### Plugins
This module enables the `registerCompiler` plugin API. see [documentation](https://embark.status.im/docs/plugin_reference.html#embark-registerCompiler-extension-callback-contractFiles-doneCallback)
***embark.registerCompiler***
arguments:
* `extension` - extension of the contract language (e.g `.sol`)
* response callback
* `contractFiles`: filenames matching the extension
* `callback(error, compiledObject)`
### Dependencies
* async.eachObject