2019-03-08 19:58:27 +00:00
# `embark-compiler`
2018-12-14 16:48:48 +00:00
2019-03-08 19:58:27 +00:00
> Embark compiler module
2018-12-14 16:48:48 +00:00
2019-09-27 17:58:08 +00:00
Abstracts the compiler interface and 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.
2019-03-08 19:58:27 +00:00
## API
2018-12-14 16:48:48 +00:00
2019-12-05 11:05:31 +00:00
**command: `compiler:contracts:compile` **
2018-12-14 16:48:48 +00:00
arguments:
* `contractFiles` - < array of embark File Objects >
2019-01-14 11:21:40 +00:00
* `options` - < object > config object `{isCoverage: boolean (default: false)}`
2018-12-14 16:48:48 +00:00
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...") }}))];
2018-12-14 16:48:48 +00:00
2019-12-05 11:05:31 +00:00
embark.events.request("compiler:contracts:compile", contractFiles, {}, (err, compiledObject) => {
2018-12-14 16:48:48 +00:00
})
```
2019-03-08 19:58:27 +00:00
## Plugins
2018-12-14 16:48:48 +00:00
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)`
2019-09-27 17:58:08 +00:00
Visit [embark.status.im ](https://embark.status.im/ ) to get started with
2020-01-16 19:37:59 +00:00
[Embark ](https://github.com/embarklabs/embark ).