pull/7/head
Iuri Matias 7 years ago
parent 239870f1d1
commit f6e73f725a
  1. 1
      remix-simulator/package.json
  2. 7
      remix-simulator/src/provider.js
  3. 10
      remix-simulator/src/server.js

@ -16,6 +16,7 @@
"dependencies": { "dependencies": {
"body-parser": "^1.18.2", "body-parser": "^1.18.2",
"express": "^4.16.3", "express": "^4.16.3",
"fancy-log": "^1.3.2",
"remix-lib": "latest", "remix-lib": "latest",
"standard": "^10.0.3", "standard": "^10.0.3",
"web3": "1.0.0-beta.27" "web3": "1.0.0-beta.27"

@ -1,6 +1,7 @@
var Web3 = require('web3') var Web3 = require('web3')
var RemixLib = require('remix-lib') var RemixLib = require('remix-lib')
var executionContext = RemixLib.execution.executionContext var executionContext = RemixLib.execution.executionContext
const log = require('fancy-log')
var processTx = require('./txProcess.js') var processTx = require('./txProcess.js')
@ -22,11 +23,11 @@ var Provider = function () {
Provider.prototype.sendAsync = function (payload, callback) { Provider.prototype.sendAsync = function (payload, callback) {
const self = this const self = this
console.dir('payload method is ') log.dir('payload method is ')
console.dir(payload.method) log.dir(payload.method)
if (payload.method === 'eth_accounts') { 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))) return callback(null, jsonRPCResponse(payload.id, this.accounts.map((x) => x.address)))
} }
if (payload.method === 'eth_estimateGas') { if (payload.method === 'eth_estimateGas') {

@ -2,6 +2,7 @@ const express = require('express')
const bodyParser = require('body-parser') const bodyParser = require('body-parser')
const app = express() const app = express()
const Provider = require('./provider') const Provider = require('./provider')
const log = require('fancy-log')
var provider = new Provider() var provider = new Provider()
@ -14,15 +15,16 @@ app.get('/', (req, res) => {
app.use(function (req, res) { app.use(function (req, res) {
// url, body, params, method // url, body, params, method
console.log('request ', req.method, req.body) log('request ', req.method, req.body)
provider.sendAsync(req.body, (err, jsonResponse) => { provider.sendAsync(req.body, (err, jsonResponse) => {
if (err) { if (err) {
res.send({error: err}) res.send({error: err})
} }
console.dir('response is ') log.dir('response is ')
console.dir(jsonResponse) log.dir(jsonResponse)
res.send(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!'))

Loading…
Cancel
Save