mirror of
https://github.com/embarklabs/embark-nim-compiler.git
synced 2025-01-24 12:39:56 +00:00
add modification of blockchain config
This commit is contained in:
parent
79f769109a
commit
d8ccaf9543
@ -16,11 +16,17 @@ then add embark-nim-compiler to the plugins section in `embark.json`:
|
||||
```Json
|
||||
{
|
||||
"plugins": {
|
||||
"embark-nim-compiler": {}
|
||||
"embark-nim-compiler": {
|
||||
"setupBlockchainOptions": true,
|
||||
"libHeraPath": "path/to/libHera.so"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- `setupBlockchainOptions`: boolean that when set to `true`, will change the blockchain config for you. If you set this to `false`, you need to set the blockchain config yourself so that it supports eWasm
|
||||
- `libHeraPath`: string path to the file `libHera.so` that is used to have Geth use Hera as a VM. Not needed if `setupBlockchainOptions` is `false`
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Embark](https://www.npmjs.com/package/embark) 5.0.0 or higher
|
||||
|
32
ewasm-testnet-geth-config.json
Normal file
32
ewasm-testnet-geth-config.json
Normal file
File diff suppressed because one or more lines are too long
41
index.js
41
index.js
@ -8,11 +8,31 @@ function buf2hex(buffer) { // buffer is an ArrayBuffer
|
||||
}
|
||||
|
||||
class NimCompiler {
|
||||
constructor(embark, _options) {
|
||||
constructor(embark) {
|
||||
this.events = embark.events;
|
||||
this.logger = embark.logger;
|
||||
|
||||
embark.registerCompiler(".nim", this.compile.bind(this));
|
||||
|
||||
const options = embark.pluginConfig;
|
||||
if (options.setupBlockchainOptions) {
|
||||
embark.registerActionForEvent("blockchain:config:modify", (currentConfig, cb) => {
|
||||
const newConfig = Object.assign(currentConfig,
|
||||
{
|
||||
customOptions: [
|
||||
`--vm.ewasm="${options.libHeraPath},metering=true,fallback=true"`,
|
||||
'--vmodule="miner=12,rpc=12"',
|
||||
'--etherbase="031159dF845ADe415202e6DA299223cb640B9DB0"'
|
||||
],
|
||||
isDev: false,
|
||||
networkId: 66,
|
||||
networkType: 'custom',
|
||||
genesisBlock: path.join(__dirname, './ewasm-testnet-geth-config.json'),
|
||||
bootnodes: "enode://53458e6bf0353f3378e115034cf6c6039b9faed52548da9030b37b4672de4a8fd09f869c48d16f9f10937e7398ae0dbe8b9d271408da7a0cf47f42a09e662827@23.101.78.254:30303"
|
||||
});
|
||||
cb(null, newConfig)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async compile(contractFiles, options, cb) {
|
||||
@ -38,15 +58,16 @@ class NimCompiler {
|
||||
if (err) {
|
||||
this.logger.error('Error while getting ABI');
|
||||
this.logger.error(stderr);
|
||||
return eachCb(err);
|
||||
}
|
||||
try {
|
||||
const abi = JSON.parse(stdout);
|
||||
compiledObject[className].abiDefinition = abi;
|
||||
return eachCb();
|
||||
} catch(e) {
|
||||
return eachCb(e);
|
||||
}
|
||||
return eachCb(err);
|
||||
}
|
||||
try {
|
||||
const abi = JSON.parse(stdout);
|
||||
compiledObject[className].abiDefinition = abi;
|
||||
return eachCb();
|
||||
} catch(e) {
|
||||
return eachCb(e);
|
||||
}
|
||||
});
|
||||
}, (err) => {
|
||||
cb(err, compiledObject);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user