From 9c9b98cd5bc1d54f9b89431c9eeaa5cff751c1f6 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 23 Jan 2018 22:41:37 +0000 Subject: [PATCH 1/4] Remove obsolete runWast.js --- bin/runWast.js | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100755 bin/runWast.js diff --git a/bin/runWast.js b/bin/runWast.js deleted file mode 100755 index 12a276b9..00000000 --- a/bin/runWast.js +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env node - -/* global WebAssembly */ - -const ethUtil = require('ethereumjs-util') -const cp = require('child_process') -const fs = require('fs') -const path = require('path') - -const loc = path.join(process.cwd(), process.argv[2]) -cp.execSync(`${__dirname}/../tools/sexpr-wasm-prototype/out/sexpr-wasm ${loc} -o ./temp.wasm`) -const tempWasm = fs.readFileSync('./temp.wasm') - -const mod = WebAssembly.Module(tempWasm) -const instance = WebAssembly.Instance(mod) - -const val = instance.exports.main() -console.log(ethUtil.toBuffer(val).toString('hex')) From 9a19d48752e520ff9bd0d30190adbcc7faf04cc3 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 23 Jan 2018 22:26:27 +0000 Subject: [PATCH 2/4] Create proper CLI tool --- bin/compileEVM.js | 5 ----- bin/evm2wasm.js | 17 +++++++++++++++++ package.json | 3 +++ 3 files changed, 20 insertions(+), 5 deletions(-) delete mode 100644 bin/compileEVM.js create mode 100755 bin/evm2wasm.js diff --git a/bin/compileEVM.js b/bin/compileEVM.js deleted file mode 100644 index f1d237b9..00000000 --- a/bin/compileEVM.js +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env node -const transcompiler = require('../index.js') -const ethUtil = require('ethereumjs-util') - -transcompiler.compile(ethUtil.toBuffer(process.argv[2])) diff --git a/bin/evm2wasm.js b/bin/evm2wasm.js new file mode 100755 index 00000000..70678976 --- /dev/null +++ b/bin/evm2wasm.js @@ -0,0 +1,17 @@ +#!/usr/bin/env node + +const evm2wasm = require('../index.js') +const ethUtil = require('ethereumjs-util') + +const input = ethUtil.toBuffer(process.argv[2]) + +evm2wasm.evm2wasm(input, { + stackTrace: process.argv[3] === 'trace', + tempName: 'temp', + inlineOps: true, + wabt: true +}).then(function (output) { + console.log(output.toString('binary')) +}).catch(function (err) { + console.err('Failed: ' + err) +}) diff --git a/package.json b/package.json index db6c8372..4f1e3981 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,9 @@ "build": "node ./wasm/generateInterface.js", "build:docs": "documentation build --github -f md ./index.js > ./docs/index.md" }, + "bin": { + "evm2wasm": "bin/evm2wasm.js" + }, "author": "mjbecze ", "license": "MPL-2.0", "devDependencies": { From c2940566807392cf33f93aee4a6f1acfe5790f93 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 23 Jan 2018 22:54:07 +0000 Subject: [PATCH 3/4] Add the new CLI to the readme --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0492a15c..e06f6f05 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,17 @@ [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) -EVM (Ethereum VM 1.0) to [eWASM](https://github.com/ethereum/evm2.0-design) transcompiler. Here is a online [frontend](https://ewasm.github.io/evm2wasm-frontend/dist/). +EVM (Ethereum VM 1.0) to [eWASM](https://github.com/ewasm/design) transcompiler. Here is a online [frontend](https://ewasm.github.io/evm2wasm-frontend/dist/). # INSTALL `npm install evm2wasm` +# USE +There is a commandline tool to transcompile EVM input: +``` +$ evm2wasm 0x600160020200 trace +``` + # DEVELOP * After any changes to `.wast` file, `npm run build` needs to be run to compile the files into a .json file * To rebuild the documentation run `npm run build:docs` From 1cf1d8ef82617b872ee40d172030d8ca6a148743 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 23 Jan 2018 22:54:40 +0000 Subject: [PATCH 4/4] Run CLI on travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index b07dc83a..2d84ee6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,6 +47,8 @@ before_install: script: - | if [ $LANG = js ]; then + bin/evm2wasm.js 0x600160020200 trace + npm run $TEST_SUITE fi - |