From 1cc79983bd8a717d33a2937e030818bfdd93987f Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 19 Apr 2018 15:19:39 -0400 Subject: [PATCH 01/28] move provider code from remix-tests to remix-simulator --- remix-simulator/README.md | 2 + remix-simulator/package.json | 73 ++++++++++++++++++++++++ remix-simulator/src/provider.js | 76 +++++++++++++++++++++++++ remix-simulator/src/txProcess.js | 98 ++++++++++++++++++++++++++++++++ 4 files changed, 249 insertions(+) create mode 100644 remix-simulator/README.md create mode 100644 remix-simulator/package.json create mode 100644 remix-simulator/src/provider.js create mode 100644 remix-simulator/src/txProcess.js diff --git a/remix-simulator/README.md b/remix-simulator/README.md new file mode 100644 index 0000000000..ea0ecbddb0 --- /dev/null +++ b/remix-simulator/README.md @@ -0,0 +1,2 @@ +# `remix-simulator` + diff --git a/remix-simulator/package.json b/remix-simulator/package.json new file mode 100644 index 0000000000..29c65a855f --- /dev/null +++ b/remix-simulator/package.json @@ -0,0 +1,73 @@ +{ + "name": "remix-simulator", + "version": "0.0.1", + "description": "Ethereum IDE and tools for the web", + "contributors": [ + { + "name": "Iuri Matias", + "email": "iuri@ethereum.org" + }, + { + "name": "Yann Levreau", + "email": "yann@ethdev.com" + } + ], + "main": "./index.js", + "dependencies": { + "remix-lib": "latest", + "standard": "^10.0.3", + "web3": "1.0.0-beta.27" + }, + "scripts": { + "test": "standard" + }, + "standard": { + "ignore": [ + "node_modules/*", + ], + "parser": "babel-eslint" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ethereum/remix.git" + }, + "author": "remix team", + "license": "MIT", + "bugs": { + "url": "https://github.com/ethereum/remix/issues" + }, + "homepage": "https://github.com/ethereum/remix#readme", + "browserify": { + "transform": [ + [ + "babelify", + { + "plugins": [ + [ + "fast-async", + { + "runtimePatten": null, + "compiler": { + "promises": true, + "es7": true, + "noRuntime": true, + "wrapAwait": true + } + } + ], + "transform-object-assign" + ] + } + ], + [ + "babelify", + { + "presets": [ + "es2017" + ] + } + ] + ] + } +} + diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js new file mode 100644 index 0000000000..9a0b61e3be --- /dev/null +++ b/remix-simulator/src/provider.js @@ -0,0 +1,76 @@ +var Web3 = require('web3') +var RemixLib = require('remix-lib') +var executionContext = RemixLib.execution.executionContext + +var processTx = require('./txProcess.js') + +function jsonRPCResponse (id, result) { + return {'id': id, 'jsonrpc': '2.0', 'result': result} +} + +var Provider = function () { + this.web3 = new Web3() + // TODO: make it random + this.accounts = [this.web3.eth.accounts.create(['abcd'])] + + this.accounts[this.accounts[0].address.toLowerCase()] = this.accounts[0] + this.accounts[this.accounts[0].address.toLowerCase()].privateKey = Buffer.from(this.accounts[this.accounts[0].address.toLowerCase()].privateKey.slice(2), 'hex') + + // TODO: fix me; this is a temporary and very hackish thing just to get the getCode working for now + this.deployedContracts = {} +} + +Provider.prototype.sendAsync = function (payload, callback) { + const self = this + + if (payload.method === 'eth_accounts') { + return callback(null, jsonRPCResponse(payload.id, this.accounts.map((x) => x.address))) + } + if (payload.method === 'eth_estimateGas') { + callback(null, jsonRPCResponse(payload.id, 3000000)) + } + if (payload.method === 'eth_gasPrice') { + callback(null, jsonRPCResponse(payload.id, 1)) + } + if (payload.method === 'eth_sendTransaction') { + processTx(this.accounts, payload, false, callback) + } + if (payload.method === 'eth_getTransactionReceipt') { + executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => { + if (error) { + return callback(error) + } + self.deployedContracts[receipt.contractAddress] = receipt.data + + var r = { + 'transactionHash': receipt.hash, + 'transactionIndex': '0x00', + 'blockHash': '0x766d18646a06cf74faeabf38597314f84a82c3851859d9da9d94fc8d037269e5', + 'blockNumber': '0x06', + 'gasUsed': '0x06345f', + 'cumulativeGasUsed': '0x06345f', + 'contractAddress': receipt.contractAddress, + 'logs': [], + 'status': 1 + } + + callback(null, jsonRPCResponse(payload.id, r)) + }) + } + if (payload.method === 'eth_getCode') { + let address = payload.params[0] + // let block = payload.params[1] + + callback(null, jsonRPCResponse(payload.id, self.deployedContracts[address])) + } + if (payload.method === 'eth_call') { + processTx(this.accounts, payload, true, callback) + } +} + +Provider.prototype.isConnected = function () { + return true +} + +module.exports = Provider + diff --git a/remix-simulator/src/txProcess.js b/remix-simulator/src/txProcess.js new file mode 100644 index 0000000000..702fb9d713 --- /dev/null +++ b/remix-simulator/src/txProcess.js @@ -0,0 +1,98 @@ +var RemixLib = require('remix-lib') +var TxExecution = RemixLib.execution.txExecution +var TxRunner = RemixLib.execution.txRunner +var executionContext = RemixLib.execution.executionContext + +function jsonRPCResponse (id, result) { + return {'id': id, 'jsonrpc': '2.0', 'result': result} +} + +function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, isCall, callback) { + let finalCallback = function (err, result) { + if (err) { + return callback(err) + } + let toReturn + if (isCall) { + toReturn = '0x' + result.result.vm.return.toString('hex') + if (toReturn === '0x') { + toReturn = '0x0' + } + } else { + toReturn = result.transactionHash + } + + callback(null, jsonRPCResponse(payload.id, toReturn)) + } + + TxExecution.callFunction(from, to, data, value, gasLimit, null, txRunner, callbacks, finalCallback, isCall) +} + +function createContract (payload, from, data, value, gasLimit, txRunner, callbacks, callback) { + let finalCallback = function (err, result) { + if (err) { + return callback(err) + } + // let contractAddress = ('0x' + result.result.createdAddress.toString('hex')) + callback(null, jsonRPCResponse(payload.id, result.transactionHash)) + } + + TxExecution.createContract(from, data, value, gasLimit, txRunner, callbacks, finalCallback) +} + +function processTx (accounts, payload, isCall, callback) { + let api = { + logMessage: (msg) => { + }, + logHtmlMessage: (msg) => { + }, + // config: self._api.config, + config: { + getUnpersistedProperty: (key) => { + // if (key === 'settings/always-use-vm') { + // return true + // } + return true + }, + get: () => { + return true + } + }, + detectNetwork: (cb) => { + cb() + }, + personalMode: () => { + // return self._api.config.get('settings/personal-mode') + return false + } + } + + executionContext.init(api.config) + + let txRunner = new TxRunner(accounts, api) + let { from, to, data, value, gas } = payload.params[0] + gas = gas || 3000000 + + let callbacks = { + confirmationCb: (network, tx, gasEstimation, continueTxExecution, cancelCb) => { + continueTxExecution(null) + }, + gasEstimationForceSend: (error, continueTxExecution, cancelCb) => { + if (error) { + continueTxExecution(error) + } + continueTxExecution() + }, + promptCb: (okCb, cancelCb) => { + okCb() + } + } + + if (to) { + runTx(payload, from, to, data, value, gas, txRunner, callbacks, isCall, callback) + } else { + createContract(payload, from, data, value, gas, txRunner, callbacks, callback) + } +} + +module.exports = processTx From 74c1135807fb4a94ef0e1ed477158db119c5d744 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 19 Apr 2018 15:44:25 -0400 Subject: [PATCH 02/28] add index --- remix-simulator/index.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 remix-simulator/index.js diff --git a/remix-simulator/index.js b/remix-simulator/index.js new file mode 100644 index 0000000000..0d944a0f57 --- /dev/null +++ b/remix-simulator/index.js @@ -0,0 +1,6 @@ +var Provider = require('./src/provider') + +module.exports = { + Provider: Provider +} + From 62da19da9092604bdacd3eaa0e16c03a8430eceb Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 19 Apr 2018 15:45:03 -0400 Subject: [PATCH 03/28] fix trailing comma --- remix-simulator/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remix-simulator/package.json b/remix-simulator/package.json index 29c65a855f..6f4e497247 100644 --- a/remix-simulator/package.json +++ b/remix-simulator/package.json @@ -23,7 +23,7 @@ }, "standard": { "ignore": [ - "node_modules/*", + "node_modules/*" ], "parser": "babel-eslint" }, From 9bcf90434353be20dd712d56f67e80ef4216a55e Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 19 Apr 2018 15:57:37 -0400 Subject: [PATCH 04/28] address linting issues --- remix-simulator/index.js | 1 - remix-simulator/src/provider.js | 1 - 2 files changed, 2 deletions(-) diff --git a/remix-simulator/index.js b/remix-simulator/index.js index 0d944a0f57..4b17d07532 100644 --- a/remix-simulator/index.js +++ b/remix-simulator/index.js @@ -3,4 +3,3 @@ var Provider = require('./src/provider') module.exports = { Provider: Provider } - diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index 9a0b61e3be..31f3f99fee 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -73,4 +73,3 @@ Provider.prototype.isConnected = function () { } module.exports = Provider - From 43fc700a6b8a842fc912e44d99c004057a162ae1 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 19 Apr 2018 20:09:25 -0400 Subject: [PATCH 05/28] server mvp --- remix-simulator/bin/ethsim | 1 + remix-simulator/package.json | 3 ++- remix-simulator/src/provider.js | 36 ++++++++++++++++++++++++++++++++- remix-simulator/src/server.js | 26 ++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 remix-simulator/bin/ethsim create mode 100644 remix-simulator/src/server.js diff --git a/remix-simulator/bin/ethsim b/remix-simulator/bin/ethsim new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/remix-simulator/bin/ethsim @@ -0,0 +1 @@ + diff --git a/remix-simulator/package.json b/remix-simulator/package.json index 6f4e497247..719f0f1d27 100644 --- a/remix-simulator/package.json +++ b/remix-simulator/package.json @@ -14,6 +14,8 @@ ], "main": "./index.js", "dependencies": { + "body-parser": "^1.18.2", + "express": "^4.16.3", "remix-lib": "latest", "standard": "^10.0.3", "web3": "1.0.0-beta.27" @@ -70,4 +72,3 @@ ] } } - diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index 31f3f99fee..f9939d2b2e 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -22,8 +22,11 @@ var Provider = function () { Provider.prototype.sendAsync = function (payload, callback) { const self = this + console.dir("payload method is ") + console.dir(payload.method) if (payload.method === 'eth_accounts') { + console.dir('eth_accounts'); return callback(null, jsonRPCResponse(payload.id, this.accounts.map((x) => x.address))) } if (payload.method === 'eth_estimateGas') { @@ -61,11 +64,42 @@ Provider.prototype.sendAsync = function (payload, callback) { let address = payload.params[0] // let block = payload.params[1] - callback(null, jsonRPCResponse(payload.id, self.deployedContracts[address])) + callback(null, jsonRPCResponse(payload.id, self.deployedContracts[address] || "0x")) } if (payload.method === 'eth_call') { processTx(this.accounts, payload, true, callback) } + if (payload.method === 'web3_clientVersion') { + callback(null, jsonRPCResponse(payload.id, "Remix Simulator/0.0.1")) + } + if (payload.method === 'shh_version') { + callback(null, jsonRPCResponse(payload.id, 5)) + } + if (payload.method === 'eth_getBlockByNumber') { + let b = { + "difficulty": "0x0", + "extraData": "0x", + "gasLimit": "0x7a1200", + "gasUsed": "0x0", + "hash": "0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "miner": "0x3333333333333333333333333333333333333333", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000042", + "number": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "size": "0x1f8", + "stateRoot": "0xb7917653f92e62394d2207d0f39a1320ff1cb93d1cee80d3c492627e00b219ff", + "timestamp": "0x0", + "totalDifficulty": "0x0", + "transactions": [], + "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncles": [] + } + callback(null, jsonRPCResponse(payload.id, b)) + } } Provider.prototype.isConnected = function () { diff --git a/remix-simulator/src/server.js b/remix-simulator/src/server.js new file mode 100644 index 0000000000..f833713307 --- /dev/null +++ b/remix-simulator/src/server.js @@ -0,0 +1,26 @@ +const express = require('express') +const bodyParser = require('body-parser') +const app = express() +const Provider = require('./provider') + +var provider = new Provider() + +app.use(bodyParser.urlencoded({extended: true})) +app.use(bodyParser.json()) + +app.get('/', (req, res) => { + res.send('Welcome to remix-simulator') +}); + +app.use(function(req,res) { + // url, body, params, method + console.log("request ", req.method, req.body) + provider.sendAsync(req.body, (err, jsonResponse) => { + console.dir("response is ") + console.dir(jsonResponse) + res.send(jsonResponse) + }); +}); + +app.listen(8545, () => console.log('Example app listening on port 8545!')) + From 200b0a108c6969730c8eaca4578c0f6406371f30 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 19 Apr 2018 20:12:21 -0400 Subject: [PATCH 06/28] add bin --- remix-simulator/bin/ethsim | 3 +++ remix-simulator/package.json | 4 ++++ 2 files changed, 7 insertions(+) mode change 100644 => 100755 remix-simulator/bin/ethsim diff --git a/remix-simulator/bin/ethsim b/remix-simulator/bin/ethsim old mode 100644 new mode 100755 index 8b13789179..e136cc361f --- a/remix-simulator/bin/ethsim +++ b/remix-simulator/bin/ethsim @@ -1 +1,4 @@ +#!/usr/bin/env node + +require('../src/server'); diff --git a/remix-simulator/package.json b/remix-simulator/package.json index 719f0f1d27..6f5eb91a69 100644 --- a/remix-simulator/package.json +++ b/remix-simulator/package.json @@ -23,6 +23,10 @@ "scripts": { "test": "standard" }, + "bin": { + "ethsim": "./bin/ethsim", + "remix-simulator": "./bin/ethsim" + }, "standard": { "ignore": [ "node_modules/*" From 949e0fbd1cda35dda20a4204b59b462b915451f4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 19 Apr 2018 20:50:58 -0400 Subject: [PATCH 07/28] fix linting issues --- remix-simulator/src/provider.js | 48 ++++++++++++++++----------------- remix-simulator/src/server.js | 16 ++++++----- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index f9939d2b2e..8791883a7c 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -22,11 +22,11 @@ var Provider = function () { Provider.prototype.sendAsync = function (payload, callback) { const self = this - console.dir("payload method is ") + console.dir('payload method is ') console.dir(payload.method) if (payload.method === 'eth_accounts') { - console.dir('eth_accounts'); + console.dir('eth_accounts') return callback(null, jsonRPCResponse(payload.id, this.accounts.map((x) => x.address))) } if (payload.method === 'eth_estimateGas') { @@ -64,39 +64,39 @@ Provider.prototype.sendAsync = function (payload, callback) { let address = payload.params[0] // let block = payload.params[1] - callback(null, jsonRPCResponse(payload.id, self.deployedContracts[address] || "0x")) + callback(null, jsonRPCResponse(payload.id, self.deployedContracts[address] || '0x')) } if (payload.method === 'eth_call') { processTx(this.accounts, payload, true, callback) } if (payload.method === 'web3_clientVersion') { - callback(null, jsonRPCResponse(payload.id, "Remix Simulator/0.0.1")) + callback(null, jsonRPCResponse(payload.id, 'Remix Simulator/0.0.1')) } if (payload.method === 'shh_version') { callback(null, jsonRPCResponse(payload.id, 5)) } if (payload.method === 'eth_getBlockByNumber') { let b = { - "difficulty": "0x0", - "extraData": "0x", - "gasLimit": "0x7a1200", - "gasUsed": "0x0", - "hash": "0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "miner": "0x3333333333333333333333333333333333333333", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x0000000000000042", - "number": "0x0", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "size": "0x1f8", - "stateRoot": "0xb7917653f92e62394d2207d0f39a1320ff1cb93d1cee80d3c492627e00b219ff", - "timestamp": "0x0", - "totalDifficulty": "0x0", - "transactions": [], - "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncles": [] + 'difficulty': '0x0', + 'extraData': '0x', + 'gasLimit': '0x7a1200', + 'gasUsed': '0x0', + 'hash': '0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f', + 'logsBloom': '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + 'miner': '0x3333333333333333333333333333333333333333', + 'mixHash': '0x0000000000000000000000000000000000000000000000000000000000000000', + 'nonce': '0x0000000000000042', + 'number': '0x0', + 'parentHash': '0x0000000000000000000000000000000000000000000000000000000000000000', + 'receiptsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', + 'sha3Uncles': '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', + 'size': '0x1f8', + 'stateRoot': '0xb7917653f92e62394d2207d0f39a1320ff1cb93d1cee80d3c492627e00b219ff', + 'timestamp': '0x0', + 'totalDifficulty': '0x0', + 'transactions': [], + 'transactionsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', + 'uncles': [] } callback(null, jsonRPCResponse(payload.id, b)) } diff --git a/remix-simulator/src/server.js b/remix-simulator/src/server.js index f833713307..dd52b7f6c9 100644 --- a/remix-simulator/src/server.js +++ b/remix-simulator/src/server.js @@ -10,17 +10,19 @@ app.use(bodyParser.json()) app.get('/', (req, res) => { res.send('Welcome to remix-simulator') -}); +}) -app.use(function(req,res) { +app.use(function (req, res) { // url, body, params, method - console.log("request ", req.method, req.body) + console.log('request ', req.method, req.body) provider.sendAsync(req.body, (err, jsonResponse) => { - console.dir("response is ") + if (err) { + res.send({error: err}) + } + console.dir('response is ') console.dir(jsonResponse) res.send(jsonResponse) - }); -}); + }) +}) app.listen(8545, () => console.log('Example app listening on port 8545!')) - From 42283211cc605f1ed64c5de4551818a366ef61cd Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 19 Apr 2018 21:09:28 -0400 Subject: [PATCH 08/28] use logger --- remix-simulator/package.json | 1 + remix-simulator/src/provider.js | 7 ++++--- remix-simulator/src/server.js | 10 ++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/remix-simulator/package.json b/remix-simulator/package.json index 6f5eb91a69..cc878af009 100644 --- a/remix-simulator/package.json +++ b/remix-simulator/package.json @@ -16,6 +16,7 @@ "dependencies": { "body-parser": "^1.18.2", "express": "^4.16.3", + "fancy-log": "^1.3.2", "remix-lib": "latest", "standard": "^10.0.3", "web3": "1.0.0-beta.27" diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index 8791883a7c..76c6e33ba3 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -1,6 +1,7 @@ var Web3 = require('web3') var RemixLib = require('remix-lib') var executionContext = RemixLib.execution.executionContext +const log = require('fancy-log') var processTx = require('./txProcess.js') @@ -22,11 +23,11 @@ var Provider = function () { Provider.prototype.sendAsync = function (payload, callback) { const self = this - console.dir('payload method is ') - console.dir(payload.method) + log.dir('payload method is ') + log.dir(payload.method) if (payload.method === 'eth_accounts') { - console.dir('eth_accounts') + log.dir('eth_accounts') return callback(null, jsonRPCResponse(payload.id, this.accounts.map((x) => x.address))) } if (payload.method === 'eth_estimateGas') { diff --git a/remix-simulator/src/server.js b/remix-simulator/src/server.js index dd52b7f6c9..f287755a53 100644 --- a/remix-simulator/src/server.js +++ b/remix-simulator/src/server.js @@ -2,6 +2,7 @@ const express = require('express') const bodyParser = require('body-parser') const app = express() const Provider = require('./provider') +const log = require('fancy-log') var provider = new Provider() @@ -14,15 +15,16 @@ app.get('/', (req, res) => { app.use(function (req, res) { // url, body, params, method - console.log('request ', req.method, req.body) + log('request ', req.method, req.body) provider.sendAsync(req.body, (err, jsonResponse) => { if (err) { res.send({error: err}) } - console.dir('response is ') - console.dir(jsonResponse) + log.dir('response is ') + log.dir(jsonResponse) res.send(jsonResponse) }) }) -app.listen(8545, () => console.log('Example app listening on port 8545!')) +app.listen(8545, () => log('Remix Simulator listening on port 8545!')) + From 4ced44b008ce910c9f8e1a47839c9d9a5715caff Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 19 Apr 2018 21:12:17 -0400 Subject: [PATCH 09/28] cleanup and minor refactor --- remix-simulator/src/txProcess.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/remix-simulator/src/txProcess.js b/remix-simulator/src/txProcess.js index 702fb9d713..9139b8706b 100644 --- a/remix-simulator/src/txProcess.js +++ b/remix-simulator/src/txProcess.js @@ -12,17 +12,16 @@ function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, i if (err) { return callback(err) } - let toReturn + if (isCall) { - toReturn = '0x' + result.result.vm.return.toString('hex') + let toReturn = '0x' + result.result.vm.return.toString('hex') if (toReturn === '0x') { toReturn = '0x0' } - } else { - toReturn = result.transactionHash + return callback(null, jsonRPCResponse(payload.id, toReturn)) } - callback(null, jsonRPCResponse(payload.id, toReturn)) + callback(null, jsonRPCResponse(payload.id, result.transactionHash)) } TxExecution.callFunction(from, to, data, value, gasLimit, null, txRunner, callbacks, finalCallback, isCall) @@ -33,7 +32,6 @@ function createContract (payload, from, data, value, gasLimit, txRunner, callbac if (err) { return callback(err) } - // let contractAddress = ('0x' + result.result.createdAddress.toString('hex')) callback(null, jsonRPCResponse(payload.id, result.transactionHash)) } @@ -46,12 +44,8 @@ function processTx (accounts, payload, isCall, callback) { }, logHtmlMessage: (msg) => { }, - // config: self._api.config, config: { getUnpersistedProperty: (key) => { - // if (key === 'settings/always-use-vm') { - // return true - // } return true }, get: () => { @@ -62,7 +56,6 @@ function processTx (accounts, payload, isCall, callback) { cb() }, personalMode: () => { - // return self._api.config.get('settings/personal-mode') return false } } From 60f4570460684d724d7def53117e580f891f9ce3 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 19 Apr 2018 21:23:09 -0400 Subject: [PATCH 10/28] move json rpc response out of txProcess --- remix-simulator/src/provider.js | 4 +++- remix-simulator/src/server.js | 1 - remix-simulator/src/txProcess.js | 10 +++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index 76c6e33ba3..c834278251 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -37,7 +37,9 @@ Provider.prototype.sendAsync = function (payload, callback) { callback(null, jsonRPCResponse(payload.id, 1)) } if (payload.method === 'eth_sendTransaction') { - processTx(this.accounts, payload, false, callback) + processTx(this.accounts, payload, false, (_err, result) => { + callback(null, jsonRPCResponse(payload.id, result)) + }) } if (payload.method === 'eth_getTransactionReceipt') { executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => { diff --git a/remix-simulator/src/server.js b/remix-simulator/src/server.js index f287755a53..705d4a5dba 100644 --- a/remix-simulator/src/server.js +++ b/remix-simulator/src/server.js @@ -27,4 +27,3 @@ app.use(function (req, res) { }) app.listen(8545, () => log('Remix Simulator listening on port 8545!')) - diff --git a/remix-simulator/src/txProcess.js b/remix-simulator/src/txProcess.js index 9139b8706b..f79c3550c5 100644 --- a/remix-simulator/src/txProcess.js +++ b/remix-simulator/src/txProcess.js @@ -3,10 +3,6 @@ var TxExecution = RemixLib.execution.txExecution var TxRunner = RemixLib.execution.txRunner var executionContext = RemixLib.execution.executionContext -function jsonRPCResponse (id, result) { - return {'id': id, 'jsonrpc': '2.0', 'result': result} -} - function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, isCall, callback) { let finalCallback = function (err, result) { if (err) { @@ -18,10 +14,10 @@ function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, i if (toReturn === '0x') { toReturn = '0x0' } - return callback(null, jsonRPCResponse(payload.id, toReturn)) + return callback(null, toReturn) } - callback(null, jsonRPCResponse(payload.id, result.transactionHash)) + callback(null, result.transactionHash) } TxExecution.callFunction(from, to, data, value, gasLimit, null, txRunner, callbacks, finalCallback, isCall) @@ -32,7 +28,7 @@ function createContract (payload, from, data, value, gasLimit, txRunner, callbac if (err) { return callback(err) } - callback(null, jsonRPCResponse(payload.id, result.transactionHash)) + callback(null, result.transactionHash) } TxExecution.createContract(from, data, value, gasLimit, txRunner, callbacks, finalCallback) From 3951acdd99946bf286c6ca67c00a6847cbe04978 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 19 Apr 2018 21:34:37 -0400 Subject: [PATCH 11/28] separate call from tx --- remix-simulator/src/txProcess.js | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/remix-simulator/src/txProcess.js b/remix-simulator/src/txProcess.js index f79c3550c5..fad01e5e78 100644 --- a/remix-simulator/src/txProcess.js +++ b/remix-simulator/src/txProcess.js @@ -3,24 +3,31 @@ var TxExecution = RemixLib.execution.txExecution var TxRunner = RemixLib.execution.txRunner var executionContext = RemixLib.execution.executionContext -function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, isCall, callback) { +function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) { let finalCallback = function (err, result) { if (err) { return callback(err) } - if (isCall) { - let toReturn = '0x' + result.result.vm.return.toString('hex') - if (toReturn === '0x') { - toReturn = '0x0' - } - return callback(null, toReturn) + let toReturn = '0x' + result.result.vm.return.toString('hex') + if (toReturn === '0x') { + toReturn = '0x0' } + return callback(null, toReturn) + } + + TxExecution.callFunction(from, to, data, value, gasLimit, null, txRunner, callbacks, finalCallback, true) +} +function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) { + let finalCallback = function (err, result) { + if (err) { + return callback(err) + } callback(null, result.transactionHash) } - TxExecution.callFunction(from, to, data, value, gasLimit, null, txRunner, callbacks, finalCallback, isCall) + TxExecution.callFunction(from, to, data, value, gasLimit, null, txRunner, callbacks, finalCallback, false) } function createContract (payload, from, data, value, gasLimit, txRunner, callbacks, callback) { @@ -77,8 +84,10 @@ function processTx (accounts, payload, isCall, callback) { } } - if (to) { - runTx(payload, from, to, data, value, gas, txRunner, callbacks, isCall, callback) + if (isCall) { + runCall(payload, from, to, data, value, gas, txRunner, callbacks, callback) + } else if (to) { + runTx(payload, from, to, data, value, gas, txRunner, callbacks, callback) } else { createContract(payload, from, data, value, gas, txRunner, callbacks, callback) } From 2cb2fc5220513af52a0db5c381174327e6be444b Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 20 Apr 2018 07:53:55 -0400 Subject: [PATCH 12/28] move transactions methods --- remix-simulator/package.json | 1 + remix-simulator/src/methods/transactions.js | 58 +++++++++++++++++++ .../src/{ => methods}/txProcess.js | 0 remix-simulator/src/provider.js | 58 ++++++------------- 4 files changed, 76 insertions(+), 41 deletions(-) create mode 100644 remix-simulator/src/methods/transactions.js rename remix-simulator/src/{ => methods}/txProcess.js (100%) diff --git a/remix-simulator/package.json b/remix-simulator/package.json index cc878af009..fee69cf275 100644 --- a/remix-simulator/package.json +++ b/remix-simulator/package.json @@ -17,6 +17,7 @@ "body-parser": "^1.18.2", "express": "^4.16.3", "fancy-log": "^1.3.2", + "merge": "^1.2.0", "remix-lib": "latest", "standard": "^10.0.3", "web3": "1.0.0-beta.27" diff --git a/remix-simulator/src/methods/transactions.js b/remix-simulator/src/methods/transactions.js new file mode 100644 index 0000000000..c707540482 --- /dev/null +++ b/remix-simulator/src/methods/transactions.js @@ -0,0 +1,58 @@ +var RemixLib = require('remix-lib') +var executionContext = RemixLib.execution.executionContext +var processTx = require('./txProcess.js') + +var Transactions = function(accounts) { + this.accounts = accounts; + // TODO: fix me; this is a temporary and very hackish thing just to get the getCode working for now + this.deployedContracts = {} +} + +Transactions.prototype.methods = function () { + return { + eth_sendTransaction: this.eth_sendTransaction.bind(this), + eth_getTransactionReceipt: this.eth_getTransactionReceipt.bind(this), + eth_getCode: this.eth_getCode.bind(this), + eth_call: this.eth_call.bind(this) + } +} + +Transactions.prototype.eth_sendTransaction = function(payload, cb) { + processTx(this.accounts, payload, false, cb); +} + +Transactions.prototype.eth_getTransactionReceipt = function(payload, cb) { + const self = this; + executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => { + if (error) { + return cb(error) + } + self.deployedContracts[receipt.contractAddress] = receipt.data + + var r = { + 'transactionHash': receipt.hash, + 'transactionIndex': '0x00', + 'blockHash': '0x766d18646a06cf74faeabf38597314f84a82c3851859d9da9d94fc8d037269e5', + 'blockNumber': '0x06', + 'gasUsed': '0x06345f', + 'cumulativeGasUsed': '0x06345f', + 'contractAddress': receipt.contractAddress, + 'logs': [], + 'status': 1 + } + + cb(null, r) + }) +} + +Transactions.prototype.eth_getCode = function(payload, cb) { + let address = payload.params[0] + + cb(null, this.deployedContracts[address] || '0x') +} + +Transactions.prototype.eth_call = function(payload, cb) { + processTx(this.accounts, payload, true, cb) +} + + module.exports = Transactions; diff --git a/remix-simulator/src/txProcess.js b/remix-simulator/src/methods/txProcess.js similarity index 100% rename from remix-simulator/src/txProcess.js rename to remix-simulator/src/methods/txProcess.js diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index c834278251..040d104462 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -1,9 +1,8 @@ var Web3 = require('web3') var RemixLib = require('remix-lib') -var executionContext = RemixLib.execution.executionContext const log = require('fancy-log') - -var processTx = require('./txProcess.js') +const Transactions = require('./methods/transactions.js') +const merge = require('merge') function jsonRPCResponse (id, result) { return {'id': id, 'jsonrpc': '2.0', 'result': result} @@ -17,8 +16,11 @@ var Provider = function () { this.accounts[this.accounts[0].address.toLowerCase()] = this.accounts[0] this.accounts[this.accounts[0].address.toLowerCase()].privateKey = Buffer.from(this.accounts[this.accounts[0].address.toLowerCase()].privateKey.slice(2), 'hex') - // TODO: fix me; this is a temporary and very hackish thing just to get the getCode working for now - this.deployedContracts = {} + this.Transactions = new Transactions(this.accounts); + + this.methods = {} + this.methods = merge(this.methods, this.Transactions.methods()) + log.dir(this.methods) } Provider.prototype.sendAsync = function (payload, callback) { @@ -36,42 +38,6 @@ Provider.prototype.sendAsync = function (payload, callback) { if (payload.method === 'eth_gasPrice') { callback(null, jsonRPCResponse(payload.id, 1)) } - if (payload.method === 'eth_sendTransaction') { - processTx(this.accounts, payload, false, (_err, result) => { - callback(null, jsonRPCResponse(payload.id, result)) - }) - } - if (payload.method === 'eth_getTransactionReceipt') { - executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => { - if (error) { - return callback(error) - } - self.deployedContracts[receipt.contractAddress] = receipt.data - - var r = { - 'transactionHash': receipt.hash, - 'transactionIndex': '0x00', - 'blockHash': '0x766d18646a06cf74faeabf38597314f84a82c3851859d9da9d94fc8d037269e5', - 'blockNumber': '0x06', - 'gasUsed': '0x06345f', - 'cumulativeGasUsed': '0x06345f', - 'contractAddress': receipt.contractAddress, - 'logs': [], - 'status': 1 - } - - callback(null, jsonRPCResponse(payload.id, r)) - }) - } - if (payload.method === 'eth_getCode') { - let address = payload.params[0] - // let block = payload.params[1] - - callback(null, jsonRPCResponse(payload.id, self.deployedContracts[address] || '0x')) - } - if (payload.method === 'eth_call') { - processTx(this.accounts, payload, true, callback) - } if (payload.method === 'web3_clientVersion') { callback(null, jsonRPCResponse(payload.id, 'Remix Simulator/0.0.1')) } @@ -103,6 +69,16 @@ Provider.prototype.sendAsync = function (payload, callback) { } callback(null, jsonRPCResponse(payload.id, b)) } + let method = this.methods[payload.method] + if (method) { + return method.call(method, payload, (err, result) => { + if (err) { + return callback({error: err}) + } + callback(null, jsonRPCResponse(payload.id, result)) + }); + } + callback("unknown method " + payload.method); } Provider.prototype.isConnected = function () { From d0512430c74c2d4949fdd842c2a26af0cb94ea6e Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 20 Apr 2018 08:04:23 -0400 Subject: [PATCH 13/28] move whisper methods --- remix-simulator/src/methods/whisper.js | 16 ++++++++++++++++ remix-simulator/src/provider.js | 9 ++++----- 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 remix-simulator/src/methods/whisper.js diff --git a/remix-simulator/src/methods/whisper.js b/remix-simulator/src/methods/whisper.js new file mode 100644 index 0000000000..f7ffccf6ae --- /dev/null +++ b/remix-simulator/src/methods/whisper.js @@ -0,0 +1,16 @@ + +var Whisper = function() { +} + +Whisper.prototype.methods = function() { + return { + shh_version: this.shh_version.bind(this) + } +} + +Whisper.prototype.shh_version = function(payload, cb) { + cb(null, 5) +} + +module.exports = Whisper; + diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index 040d104462..e966f7d80e 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -2,6 +2,7 @@ var Web3 = require('web3') var RemixLib = require('remix-lib') const log = require('fancy-log') const Transactions = require('./methods/transactions.js') +const Whisper = require('./methods/whisper.js') const merge = require('merge') function jsonRPCResponse (id, result) { @@ -16,10 +17,11 @@ var Provider = function () { this.accounts[this.accounts[0].address.toLowerCase()] = this.accounts[0] this.accounts[this.accounts[0].address.toLowerCase()].privateKey = Buffer.from(this.accounts[this.accounts[0].address.toLowerCase()].privateKey.slice(2), 'hex') - this.Transactions = new Transactions(this.accounts); + this.Transactions = ; this.methods = {} - this.methods = merge(this.methods, this.Transactions.methods()) + this.methods = merge(this.methods, (new Transactions(this.accounts)).methods()) + this.methods = merge(this.methods, (new Whisper()).methods()) log.dir(this.methods) } @@ -41,9 +43,6 @@ Provider.prototype.sendAsync = function (payload, callback) { if (payload.method === 'web3_clientVersion') { callback(null, jsonRPCResponse(payload.id, 'Remix Simulator/0.0.1')) } - if (payload.method === 'shh_version') { - callback(null, jsonRPCResponse(payload.id, 5)) - } if (payload.method === 'eth_getBlockByNumber') { let b = { 'difficulty': '0x0', From 8888b3d595d6839b547128e0d38e1654d94158a2 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 20 Apr 2018 08:04:53 -0400 Subject: [PATCH 14/28] remove leftover code --- remix-simulator/src/provider.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index e966f7d80e..e5ffd85549 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -17,8 +17,6 @@ var Provider = function () { this.accounts[this.accounts[0].address.toLowerCase()] = this.accounts[0] this.accounts[this.accounts[0].address.toLowerCase()].privateKey = Buffer.from(this.accounts[this.accounts[0].address.toLowerCase()].privateKey.slice(2), 'hex') - this.Transactions = ; - this.methods = {} this.methods = merge(this.methods, (new Transactions(this.accounts)).methods()) this.methods = merge(this.methods, (new Whisper()).methods()) From 431b7fb936ce5028d721bd180f4e69ff71ec0d61 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 20 Apr 2018 08:23:52 -0400 Subject: [PATCH 15/28] move block related methods --- remix-simulator/src/methods/blocks.js | 37 +++++++++++++++++++++++++++ remix-simulator/src/provider.js | 26 +------------------ 2 files changed, 38 insertions(+), 25 deletions(-) create mode 100644 remix-simulator/src/methods/blocks.js diff --git a/remix-simulator/src/methods/blocks.js b/remix-simulator/src/methods/blocks.js new file mode 100644 index 0000000000..cb2fe1118f --- /dev/null +++ b/remix-simulator/src/methods/blocks.js @@ -0,0 +1,37 @@ + +var Blocks = function() { +} + +Blocks.prototype.methods = function () { + return { + eth_getBlockByNumber: this.eth_getBlockByNumber.bind(this) + } +} + +Blocks.prototype.eth_getBlockByNumber = function (payload, cb) { + let b = { + 'difficulty': '0x0', + 'extraData': '0x', + 'gasLimit': '0x7a1200', + 'gasUsed': '0x0', + 'hash': '0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f', + 'logsBloom': '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + 'miner': '0x3333333333333333333333333333333333333333', + 'mixHash': '0x0000000000000000000000000000000000000000000000000000000000000000', + 'nonce': '0x0000000000000042', + 'number': '0x0', + 'parentHash': '0x0000000000000000000000000000000000000000000000000000000000000000', + 'receiptsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', + 'sha3Uncles': '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', + 'size': '0x1f8', + 'stateRoot': '0xb7917653f92e62394d2207d0f39a1320ff1cb93d1cee80d3c492627e00b219ff', + 'timestamp': '0x0', + 'totalDifficulty': '0x0', + 'transactions': [], + 'transactionsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', + 'uncles': [] + } + cb(null, b) +} + +module.exports = Blocks; diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index e5ffd85549..2713c823a8 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -20,6 +20,7 @@ var Provider = function () { this.methods = {} this.methods = merge(this.methods, (new Transactions(this.accounts)).methods()) this.methods = merge(this.methods, (new Whisper()).methods()) + this.methods = merge(this.methods, (new Blocks()).methods()) log.dir(this.methods) } @@ -41,31 +42,6 @@ Provider.prototype.sendAsync = function (payload, callback) { if (payload.method === 'web3_clientVersion') { callback(null, jsonRPCResponse(payload.id, 'Remix Simulator/0.0.1')) } - if (payload.method === 'eth_getBlockByNumber') { - let b = { - 'difficulty': '0x0', - 'extraData': '0x', - 'gasLimit': '0x7a1200', - 'gasUsed': '0x0', - 'hash': '0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f', - 'logsBloom': '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', - 'miner': '0x3333333333333333333333333333333333333333', - 'mixHash': '0x0000000000000000000000000000000000000000000000000000000000000000', - 'nonce': '0x0000000000000042', - 'number': '0x0', - 'parentHash': '0x0000000000000000000000000000000000000000000000000000000000000000', - 'receiptsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', - 'sha3Uncles': '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', - 'size': '0x1f8', - 'stateRoot': '0xb7917653f92e62394d2207d0f39a1320ff1cb93d1cee80d3c492627e00b219ff', - 'timestamp': '0x0', - 'totalDifficulty': '0x0', - 'transactions': [], - 'transactionsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', - 'uncles': [] - } - callback(null, jsonRPCResponse(payload.id, b)) - } let method = this.methods[payload.method] if (method) { return method.call(method, payload, (err, result) => { From 95d9a533ab5c43c6bd3a5f6a0624ac6e118a4745 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 20 Apr 2018 08:53:33 -0400 Subject: [PATCH 16/28] move other methods to their own modules --- remix-simulator/src/methods/accounts.js | 22 +++++++++++++++ remix-simulator/src/methods/blocks.js | 4 +++ remix-simulator/src/methods/misc.js | 16 +++++++++++ remix-simulator/src/methods/transactions.js | 7 ++++- remix-simulator/src/provider.js | 30 ++++++--------------- 5 files changed, 56 insertions(+), 23 deletions(-) create mode 100644 remix-simulator/src/methods/accounts.js create mode 100644 remix-simulator/src/methods/misc.js diff --git a/remix-simulator/src/methods/accounts.js b/remix-simulator/src/methods/accounts.js new file mode 100644 index 0000000000..406069e2e2 --- /dev/null +++ b/remix-simulator/src/methods/accounts.js @@ -0,0 +1,22 @@ +var Web3 = require('web3') + +var Accounts = function(web3) { + this.web3 = new Web3() + // TODO: make it random and/or use remix-libs + this.accounts = [this.web3.eth.accounts.create(['abcd'])] + + this.accounts[this.accounts[0].address.toLowerCase()] = this.accounts[0] + this.accounts[this.accounts[0].address.toLowerCase()].privateKey = Buffer.from(this.accounts[this.accounts[0].address.toLowerCase()].privateKey.slice(2), 'hex') +} + +Accounts.prototype.methods = function () { + return { + eth_accounts: this.eth_accounts.bind(this) + } +} + +Accounts.prototype.eth_accounts = function(payload, cb) { + return cb(null, this.accounts.map((x) => x.address)) +} + +module.exports = Accounts; diff --git a/remix-simulator/src/methods/blocks.js b/remix-simulator/src/methods/blocks.js index cb2fe1118f..a2687bbb1c 100644 --- a/remix-simulator/src/methods/blocks.js +++ b/remix-simulator/src/methods/blocks.js @@ -34,4 +34,8 @@ Blocks.prototype.eth_getBlockByNumber = function (payload, cb) { cb(null, b) } +Blocks.prototype.eth_gasPrice = function (payload, cb) { + cb(null, 1) +} + module.exports = Blocks; diff --git a/remix-simulator/src/methods/misc.js b/remix-simulator/src/methods/misc.js new file mode 100644 index 0000000000..7976253773 --- /dev/null +++ b/remix-simulator/src/methods/misc.js @@ -0,0 +1,16 @@ + +var Misc = function() { +} + +Misc.prototype.methods = function () { + return { + web3_clientVersion: 'web3_clientVersion' + } +} + +Misc.prototype.web3_clientVersion = function (payload, cb) { + cb(null, 'Remix Simulator/0.0.1') +} + + +module.exports = Misc; diff --git a/remix-simulator/src/methods/transactions.js b/remix-simulator/src/methods/transactions.js index c707540482..1095f23a2b 100644 --- a/remix-simulator/src/methods/transactions.js +++ b/remix-simulator/src/methods/transactions.js @@ -13,7 +13,8 @@ Transactions.prototype.methods = function () { eth_sendTransaction: this.eth_sendTransaction.bind(this), eth_getTransactionReceipt: this.eth_getTransactionReceipt.bind(this), eth_getCode: this.eth_getCode.bind(this), - eth_call: this.eth_call.bind(this) + eth_call: this.eth_call.bind(this), + eth_estimateGas: this.eth_estimateGas.bind(this) } } @@ -45,6 +46,10 @@ Transactions.prototype.eth_getTransactionReceipt = function(payload, cb) { }) } +Transactions.prototype.eth_estimateGas = function(payload, cb) { + cb(null, 3000000) +} + Transactions.prototype.eth_getCode = function(payload, cb) { let address = payload.params[0] diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index 2713c823a8..47b3ba70b2 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -1,6 +1,8 @@ -var Web3 = require('web3') var RemixLib = require('remix-lib') const log = require('fancy-log') +const Accounts = require('./methods/accounts.js') +const Blocks = require('./methods/blocks.js') +const Misc = require('./methods/misc.js') const Transactions = require('./methods/transactions.js') const Whisper = require('./methods/whisper.js') const merge = require('merge') @@ -10,17 +12,14 @@ function jsonRPCResponse (id, result) { } var Provider = function () { - this.web3 = new Web3() - // TODO: make it random - this.accounts = [this.web3.eth.accounts.create(['abcd'])] - - this.accounts[this.accounts[0].address.toLowerCase()] = this.accounts[0] - this.accounts[this.accounts[0].address.toLowerCase()].privateKey = Buffer.from(this.accounts[this.accounts[0].address.toLowerCase()].privateKey.slice(2), 'hex') + this.Accounts = new Accounts(); this.methods = {} - this.methods = merge(this.methods, (new Transactions(this.accounts)).methods()) - this.methods = merge(this.methods, (new Whisper()).methods()) + this.methods = merge(this.methods, this.Accounts.methods()) this.methods = merge(this.methods, (new Blocks()).methods()) + this.methods = merge(this.methods, (new Misc()).methods()) + this.methods = merge(this.methods, (new Transactions(this.Accounts.accounts)).methods()) + this.methods = merge(this.methods, (new Whisper()).methods()) log.dir(this.methods) } @@ -29,19 +28,6 @@ Provider.prototype.sendAsync = function (payload, callback) { log.dir('payload method is ') log.dir(payload.method) - if (payload.method === 'eth_accounts') { - log.dir('eth_accounts') - return callback(null, jsonRPCResponse(payload.id, this.accounts.map((x) => x.address))) - } - if (payload.method === 'eth_estimateGas') { - callback(null, jsonRPCResponse(payload.id, 3000000)) - } - if (payload.method === 'eth_gasPrice') { - callback(null, jsonRPCResponse(payload.id, 1)) - } - if (payload.method === 'web3_clientVersion') { - callback(null, jsonRPCResponse(payload.id, 'Remix Simulator/0.0.1')) - } let method = this.methods[payload.method] if (method) { return method.call(method, payload, (err, result) => { From b3d1f076fe31a005ed07b7f386329ef6d68f84d3 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 20 Apr 2018 09:03:46 -0400 Subject: [PATCH 17/28] fix bindings --- remix-simulator/src/methods/blocks.js | 3 ++- remix-simulator/src/methods/misc.js | 2 +- remix-simulator/src/provider.js | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/remix-simulator/src/methods/blocks.js b/remix-simulator/src/methods/blocks.js index a2687bbb1c..ae99b50713 100644 --- a/remix-simulator/src/methods/blocks.js +++ b/remix-simulator/src/methods/blocks.js @@ -4,7 +4,8 @@ var Blocks = function() { Blocks.prototype.methods = function () { return { - eth_getBlockByNumber: this.eth_getBlockByNumber.bind(this) + eth_getBlockByNumber: this.eth_getBlockByNumber.bind(this), + eth_gasPrice: this.eth_gasPrice.bind(this) } } diff --git a/remix-simulator/src/methods/misc.js b/remix-simulator/src/methods/misc.js index 7976253773..33c81e395f 100644 --- a/remix-simulator/src/methods/misc.js +++ b/remix-simulator/src/methods/misc.js @@ -4,7 +4,7 @@ var Misc = function() { Misc.prototype.methods = function () { return { - web3_clientVersion: 'web3_clientVersion' + web3_clientVersion: this.web3_clientVersion.bind(this) } } diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index 47b3ba70b2..ccc48e117b 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -25,8 +25,7 @@ var Provider = function () { Provider.prototype.sendAsync = function (payload, callback) { const self = this - log.dir('payload method is ') - log.dir(payload.method) + log.info('payload method is ', payload.method) let method = this.methods[payload.method] if (method) { From 1bc72a1f80d3c6edb838992e318288b79f9f7991 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 20 Apr 2018 09:07:23 -0400 Subject: [PATCH 18/28] display current version --- remix-simulator/src/methods/misc.js | 3 ++- remix-simulator/src/methods/whisper.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/remix-simulator/src/methods/misc.js b/remix-simulator/src/methods/misc.js index 33c81e395f..ffb386c57e 100644 --- a/remix-simulator/src/methods/misc.js +++ b/remix-simulator/src/methods/misc.js @@ -1,3 +1,4 @@ +var version = require('../../package.json').version var Misc = function() { } @@ -9,7 +10,7 @@ Misc.prototype.methods = function () { } Misc.prototype.web3_clientVersion = function (payload, cb) { - cb(null, 'Remix Simulator/0.0.1') + cb(null, 'Remix Simulator/' + version) } diff --git a/remix-simulator/src/methods/whisper.js b/remix-simulator/src/methods/whisper.js index f7ffccf6ae..b1b3e38ccb 100644 --- a/remix-simulator/src/methods/whisper.js +++ b/remix-simulator/src/methods/whisper.js @@ -12,5 +12,5 @@ Whisper.prototype.shh_version = function(payload, cb) { cb(null, 5) } -module.exports = Whisper; +module.exports = Whisper From 6ba89e9bd1d994bfb9f9b83efe48b7b601761256 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 20 Apr 2018 09:17:02 -0400 Subject: [PATCH 19/28] fix linting issues --- remix-simulator/src/methods/accounts.js | 6 +++--- remix-simulator/src/methods/blocks.js | 4 ++-- remix-simulator/src/methods/misc.js | 5 ++--- remix-simulator/src/methods/transactions.js | 20 ++++++++++---------- remix-simulator/src/methods/whisper.js | 7 +++---- remix-simulator/src/provider.js | 20 ++++++++------------ 6 files changed, 28 insertions(+), 34 deletions(-) diff --git a/remix-simulator/src/methods/accounts.js b/remix-simulator/src/methods/accounts.js index 406069e2e2..c85493aade 100644 --- a/remix-simulator/src/methods/accounts.js +++ b/remix-simulator/src/methods/accounts.js @@ -1,6 +1,6 @@ var Web3 = require('web3') -var Accounts = function(web3) { +var Accounts = function () { this.web3 = new Web3() // TODO: make it random and/or use remix-libs this.accounts = [this.web3.eth.accounts.create(['abcd'])] @@ -15,8 +15,8 @@ Accounts.prototype.methods = function () { } } -Accounts.prototype.eth_accounts = function(payload, cb) { +Accounts.prototype.eth_accounts = function (payload, cb) { return cb(null, this.accounts.map((x) => x.address)) } -module.exports = Accounts; +module.exports = Accounts diff --git a/remix-simulator/src/methods/blocks.js b/remix-simulator/src/methods/blocks.js index ae99b50713..718070f42c 100644 --- a/remix-simulator/src/methods/blocks.js +++ b/remix-simulator/src/methods/blocks.js @@ -1,5 +1,5 @@ -var Blocks = function() { +var Blocks = function () { } Blocks.prototype.methods = function () { @@ -39,4 +39,4 @@ Blocks.prototype.eth_gasPrice = function (payload, cb) { cb(null, 1) } -module.exports = Blocks; +module.exports = Blocks diff --git a/remix-simulator/src/methods/misc.js b/remix-simulator/src/methods/misc.js index ffb386c57e..a2fd6db044 100644 --- a/remix-simulator/src/methods/misc.js +++ b/remix-simulator/src/methods/misc.js @@ -1,6 +1,6 @@ var version = require('../../package.json').version -var Misc = function() { +var Misc = function () { } Misc.prototype.methods = function () { @@ -13,5 +13,4 @@ Misc.prototype.web3_clientVersion = function (payload, cb) { cb(null, 'Remix Simulator/' + version) } - -module.exports = Misc; +module.exports = Misc diff --git a/remix-simulator/src/methods/transactions.js b/remix-simulator/src/methods/transactions.js index 1095f23a2b..987ebdc3f2 100644 --- a/remix-simulator/src/methods/transactions.js +++ b/remix-simulator/src/methods/transactions.js @@ -2,8 +2,8 @@ var RemixLib = require('remix-lib') var executionContext = RemixLib.execution.executionContext var processTx = require('./txProcess.js') -var Transactions = function(accounts) { - this.accounts = accounts; +var Transactions = function (accounts) { + this.accounts = accounts // TODO: fix me; this is a temporary and very hackish thing just to get the getCode working for now this.deployedContracts = {} } @@ -18,12 +18,12 @@ Transactions.prototype.methods = function () { } } -Transactions.prototype.eth_sendTransaction = function(payload, cb) { - processTx(this.accounts, payload, false, cb); +Transactions.prototype.eth_sendTransaction = function (payload, cb) { + processTx(this.accounts, payload, false, cb) } -Transactions.prototype.eth_getTransactionReceipt = function(payload, cb) { - const self = this; +Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) { + const self = this executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => { if (error) { return cb(error) @@ -46,18 +46,18 @@ Transactions.prototype.eth_getTransactionReceipt = function(payload, cb) { }) } -Transactions.prototype.eth_estimateGas = function(payload, cb) { +Transactions.prototype.eth_estimateGas = function (payload, cb) { cb(null, 3000000) } -Transactions.prototype.eth_getCode = function(payload, cb) { +Transactions.prototype.eth_getCode = function (payload, cb) { let address = payload.params[0] cb(null, this.deployedContracts[address] || '0x') } -Transactions.prototype.eth_call = function(payload, cb) { +Transactions.prototype.eth_call = function (payload, cb) { processTx(this.accounts, payload, true, cb) } - module.exports = Transactions; +module.exports = Transactions diff --git a/remix-simulator/src/methods/whisper.js b/remix-simulator/src/methods/whisper.js index b1b3e38ccb..bfd88f43e0 100644 --- a/remix-simulator/src/methods/whisper.js +++ b/remix-simulator/src/methods/whisper.js @@ -1,16 +1,15 @@ -var Whisper = function() { +var Whisper = function () { } -Whisper.prototype.methods = function() { +Whisper.prototype.methods = function () { return { shh_version: this.shh_version.bind(this) } } -Whisper.prototype.shh_version = function(payload, cb) { +Whisper.prototype.shh_version = function (payload, cb) { cb(null, 5) } module.exports = Whisper - diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index ccc48e117b..e8ef2f3e77 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -1,18 +1,14 @@ -var RemixLib = require('remix-lib') const log = require('fancy-log') +const merge = require('merge') + const Accounts = require('./methods/accounts.js') const Blocks = require('./methods/blocks.js') const Misc = require('./methods/misc.js') const Transactions = require('./methods/transactions.js') const Whisper = require('./methods/whisper.js') -const merge = require('merge') - -function jsonRPCResponse (id, result) { - return {'id': id, 'jsonrpc': '2.0', 'result': result} -} var Provider = function () { - this.Accounts = new Accounts(); + this.Accounts = new Accounts() this.methods = {} this.methods = merge(this.methods, this.Accounts.methods()) @@ -24,19 +20,19 @@ var Provider = function () { } Provider.prototype.sendAsync = function (payload, callback) { - const self = this log.info('payload method is ', payload.method) let method = this.methods[payload.method] if (method) { return method.call(method, payload, (err, result) => { if (err) { - return callback({error: err}) + return callback(err) } - callback(null, jsonRPCResponse(payload.id, result)) - }); + let response = {'id': payload.id, 'jsonrpc': '2.0', 'result': result} + callback(null, response) + }) } - callback("unknown method " + payload.method); + callback(new Error('unknown method ' + payload.method)) } Provider.prototype.isConnected = function () { From 2dbf44bec10efcb12bea7ad2b50d5a6900d01c86 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 19 May 2018 08:00:56 -0400 Subject: [PATCH 20/28] remove yoify --- remix-lib/package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/remix-lib/package.json b/remix-lib/package.json index e14204ddd2..e1e475ef6d 100644 --- a/remix-lib/package.json +++ b/remix-lib/package.json @@ -75,9 +75,6 @@ ] } ], - [ - "yo-yoify" - ], [ "babelify", { From 555cf5e48f09cd53e0fe60de00c8a2f3a46dc5b4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 19 May 2018 08:49:45 -0400 Subject: [PATCH 21/28] fix logs so they be compatible with different envs --- remix-simulator/package.json | 7 ++- remix-simulator/src/provider.js | 3 +- remix-simulator/src/server.js | 6 +-- remix-simulator/src/utils/logs.js | 81 +++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 remix-simulator/src/utils/logs.js diff --git a/remix-simulator/package.json b/remix-simulator/package.json index fee69cf275..54ecf12a02 100644 --- a/remix-simulator/package.json +++ b/remix-simulator/package.json @@ -14,12 +14,15 @@ ], "main": "./index.js", "dependencies": { + "ansi-gray": "^0.1.1", + "babel-preset-es2017": "^6.24.1", "body-parser": "^1.18.2", + "color-support": "^1.1.3", "express": "^4.16.3", - "fancy-log": "^1.3.2", "merge": "^1.2.0", - "remix-lib": "latest", + "remix-lib": "^0.2.5", "standard": "^10.0.3", + "time-stamp": "^2.0.0", "web3": "1.0.0-beta.27" }, "scripts": { diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index e8ef2f3e77..6a4327f7b5 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -1,4 +1,4 @@ -const log = require('fancy-log') +const log = require('./utils/logs.js') const merge = require('merge') const Accounts = require('./methods/accounts.js') @@ -16,7 +16,6 @@ var Provider = function () { this.methods = merge(this.methods, (new Misc()).methods()) this.methods = merge(this.methods, (new Transactions(this.Accounts.accounts)).methods()) this.methods = merge(this.methods, (new Whisper()).methods()) - log.dir(this.methods) } Provider.prototype.sendAsync = function (payload, callback) { diff --git a/remix-simulator/src/server.js b/remix-simulator/src/server.js index 705d4a5dba..1171b8826d 100644 --- a/remix-simulator/src/server.js +++ b/remix-simulator/src/server.js @@ -2,7 +2,7 @@ const express = require('express') const bodyParser = require('body-parser') const app = express() const Provider = require('./provider') -const log = require('fancy-log') +const log = require('./utils/logs.js') var provider = new Provider() @@ -14,14 +14,10 @@ app.get('/', (req, res) => { }) app.use(function (req, res) { - // url, body, params, method - log('request ', req.method, req.body) provider.sendAsync(req.body, (err, jsonResponse) => { if (err) { res.send({error: err}) } - log.dir('response is ') - log.dir(jsonResponse) res.send(jsonResponse) }) }) diff --git a/remix-simulator/src/utils/logs.js b/remix-simulator/src/utils/logs.js new file mode 100644 index 0000000000..d117ea9fcb --- /dev/null +++ b/remix-simulator/src/utils/logs.js @@ -0,0 +1,81 @@ +'use strict'; + +var gray = require('ansi-gray'); +var timestamp = require('time-stamp'); +var supportsColor = require('color-support'); + +function hasFlag(flag) { + return ((typeof(process) !== 'undefined') && (process.argv.indexOf('--' + flag) !== -1)); +} + +function addColor(str) { + if (hasFlag('no-color')) { + return str; + } + + if (hasFlag('color')) { + return gray(str); + } + + if (supportsColor()) { + return gray(str); + } + + return str; +} + +let logger = { + stdout: function(arg) { + if (typeof(process) === 'undefined' || !process.stdout) return; + process.stdout.write(arg); + }, + stderr: function(arg) { + if (typeof(process) === 'undefined' || process.stderr) return; + process.stderr.write(arg); + }, +}; + +function getTimestamp(){ + return '['+addColor(timestamp('HH:mm:ss'))+']'; +} + +function log(){ + var time = getTimestamp(); + logger.stdout(time + ' '); + console.log.apply(console, arguments); + return this; +} + +function info(){ + var time = getTimestamp(); + logger.stdout(time + ' '); + console.info.apply(console, arguments); + return this; +} + +function dir(){ + var time = getTimestamp(); + logger.stdout(time + ' '); + console.dir.apply(console, arguments); + return this; +} + +function warn(){ + var time = getTimestamp(); + logger.stderr(time + ' '); + console.warn.apply(console, arguments); + return this; +} + +function error(){ + var time = getTimestamp(); + logger.stderr(time + ' '); + console.error.apply(console, arguments); + return this; +} + +module.exports = log; +module.exports.info = info; +module.exports.dir = dir; +module.exports.warn = warn; +module.exports.error = error; From 9d0ad76d25ae4c469b4954590cb1cd3c2f9ff079 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 19 May 2018 10:38:18 -0400 Subject: [PATCH 22/28] update to 0.0.2 --- remix-simulator/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remix-simulator/package.json b/remix-simulator/package.json index 54ecf12a02..eba4e987b7 100644 --- a/remix-simulator/package.json +++ b/remix-simulator/package.json @@ -1,6 +1,6 @@ { "name": "remix-simulator", - "version": "0.0.1", + "version": "0.0.2", "description": "Ethereum IDE and tools for the web", "contributors": [ { From 84134570b6b0a462b39db847967f48e3d03dcc6c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 25 May 2018 10:12:49 -0400 Subject: [PATCH 23/28] use receipt.logs --- remix-simulator/src/methods/transactions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remix-simulator/src/methods/transactions.js b/remix-simulator/src/methods/transactions.js index 987ebdc3f2..53834ea7dd 100644 --- a/remix-simulator/src/methods/transactions.js +++ b/remix-simulator/src/methods/transactions.js @@ -38,7 +38,7 @@ Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) { 'gasUsed': '0x06345f', 'cumulativeGasUsed': '0x06345f', 'contractAddress': receipt.contractAddress, - 'logs': [], + 'logs': receipt.logs, 'status': 1 } From b728720eed66cfaa4c92deeecd9416c348fc7f7b Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 5 Jun 2018 12:08:48 -0400 Subject: [PATCH 24/28] update to 0.0.3 --- remix-simulator/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remix-simulator/package.json b/remix-simulator/package.json index eba4e987b7..280d8b60db 100644 --- a/remix-simulator/package.json +++ b/remix-simulator/package.json @@ -1,6 +1,6 @@ { "name": "remix-simulator", - "version": "0.0.2", + "version": "0.0.3", "description": "Ethereum IDE and tools for the web", "contributors": [ { From 700a1c8c063953e30ca3f1b38b3acb4afc230378 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 25 Jul 2018 06:31:51 -0400 Subject: [PATCH 25/28] fix missing export --- remix-debug/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/remix-debug/index.js b/remix-debug/index.js index 002a89d5a2..c451bbd147 100644 --- a/remix-debug/index.js +++ b/remix-debug/index.js @@ -4,6 +4,8 @@ var EthDebugger = require('./src/Ethdebugger') var StorageViewer = require('./src/storage/storageViewer') var StorageResolver = require('./src/storage/storageResolver') +var SolidityDecoder = require('./src/solidity-decoder) + var remixLib = require('remix-lib') var BreakpointManager = remixLib.code.BreakpointManager @@ -27,6 +29,7 @@ module.exports = { storage: { StorageViewer: StorageViewer, StorageResolver: StorageResolver - } + }, + SolidityDecoder: SolidityDecoder } From 1e6452c6df0d48d83dad31ed95a77300a3d90c7e Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 25 Jul 2018 07:59:12 -0400 Subject: [PATCH 26/28] update references to solc --- remix-simulator/package.json | 3 +++ remix-solidity/package.json | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/remix-simulator/package.json b/remix-simulator/package.json index 280d8b60db..e3d2116695 100644 --- a/remix-simulator/package.json +++ b/remix-simulator/package.json @@ -15,10 +15,13 @@ "main": "./index.js", "dependencies": { "ansi-gray": "^0.1.1", + "babel-plugin-transform-object-assign": "^6.22.0", "babel-preset-es2017": "^6.24.1", + "babelify": "^7.3.0", "body-parser": "^1.18.2", "color-support": "^1.1.3", "express": "^4.16.3", + "fast-async": "^6.3.7", "merge": "^1.2.0", "remix-lib": "^0.2.5", "standard": "^10.0.3", diff --git a/remix-solidity/package.json b/remix-solidity/package.json index 17c08b3510..18f18992ff 100644 --- a/remix-solidity/package.json +++ b/remix-solidity/package.json @@ -29,7 +29,8 @@ "webworkify": "^1.2.1" }, "scripts": { - "test": "standard && tape ./test/tests.js" + "test": "standard && tape ./test/tests.js", + "prepublish": "mkdirp build" }, "standard": { "ignore": [ From 3aefdd8b2db65de2d5e04442d7e3a40421b1d01f Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 25 Jul 2018 08:01:40 -0400 Subject: [PATCH 27/28] fix typo --- remix-debug/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remix-debug/index.js b/remix-debug/index.js index c451bbd147..5b6c38dc09 100644 --- a/remix-debug/index.js +++ b/remix-debug/index.js @@ -4,7 +4,7 @@ var EthDebugger = require('./src/Ethdebugger') var StorageViewer = require('./src/storage/storageViewer') var StorageResolver = require('./src/storage/storageResolver') -var SolidityDecoder = require('./src/solidity-decoder) +var SolidityDecoder = require('./src/solidity-decoder') var remixLib = require('remix-lib') var BreakpointManager = remixLib.code.BreakpointManager From e11981fdb79c98faa058f51755099fbcef4d4abc Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 25 Jul 2018 08:05:45 -0400 Subject: [PATCH 28/28] remove unneded script --- remix-solidity/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/remix-solidity/package.json b/remix-solidity/package.json index 18f18992ff..17c08b3510 100644 --- a/remix-solidity/package.json +++ b/remix-solidity/package.json @@ -29,8 +29,7 @@ "webworkify": "^1.2.1" }, "scripts": { - "test": "standard && tape ./test/tests.js", - "prepublish": "mkdirp build" + "test": "standard && tape ./test/tests.js" }, "standard": { "ignore": [