get ABI from nim file
This commit is contained in:
parent
783f573256
commit
22308b3816
31
index.js
31
index.js
|
@ -1,4 +1,5 @@
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
const path = require('path');
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
|
|
||||||
function buf2hex(buffer) { // buffer is an ArrayBuffer
|
function buf2hex(buffer) { // buffer is an ArrayBuffer
|
||||||
|
@ -8,6 +9,8 @@ function buf2hex(buffer) { // buffer is an ArrayBuffer
|
||||||
class NimCompiler {
|
class NimCompiler {
|
||||||
constructor(embark, _options) {
|
constructor(embark, _options) {
|
||||||
this.events = embark.events;
|
this.events = embark.events;
|
||||||
|
this.logger = embark.logger;
|
||||||
|
|
||||||
embark.registerCompiler(".nim", this.compile.bind(this));
|
embark.registerCompiler(".nim", this.compile.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,23 +19,23 @@ class NimCompiler {
|
||||||
|
|
||||||
// Get code from wasm file
|
// Get code from wasm file
|
||||||
// const codeHex = "0x" + buf2hex(fs.readFileSync(wasmFile));
|
// const codeHex = "0x" + buf2hex(fs.readFileSync(wasmFile));
|
||||||
// C:/dev/nimplay/examples/king_of_the_hill.nim
|
|
||||||
// C:/dev/embark-nim-compiler/tools/abi_gen
|
|
||||||
// Get ABI from nim file
|
// Get ABI from nim file
|
||||||
exec(`C:/dev/embark-nim-compiler/tools/abi_gen ${contractFiles[0].path}`, (err, stdout, setderr) => {
|
exec(`${path.join(__dirname, './tools/abi_gen')} ${contractFiles[0].path}`, (err, stdout, stderr) => {
|
||||||
console.log('allo');
|
if (err) {
|
||||||
|
this.logger.error('Error while getting ABI');
|
||||||
|
this.logger.error(stderr);
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const abi = JSON.parse(stdout);
|
||||||
|
} catch(e) {
|
||||||
|
return cb(e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// cmdline = ['./tools/abi_gen', fpath.replace('wasm', 'nim')]
|
|
||||||
// completed_process = subprocess.run(
|
|
||||||
// cmdline,
|
|
||||||
// stdout=subprocess.PIPE,
|
|
||||||
// )
|
|
||||||
// if completed_process.returncode != 0:
|
|
||||||
// print(completed_process.stdout)
|
|
||||||
// print(completed_process.stderr)
|
|
||||||
// raise Exception('Could not get ABI')
|
|
||||||
// return json.loads(completed_process.stdout)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = NimCompiler
|
module.exports = NimCompiler
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue