fix linting issues

pull/3094/head
Iuri Matias 7 years ago
parent 1bc72a1f80
commit 6ba89e9bd1
  1. 4
      remix-simulator/src/methods/accounts.js
  2. 2
      remix-simulator/src/methods/blocks.js
  3. 3
      remix-simulator/src/methods/misc.js
  4. 8
      remix-simulator/src/methods/transactions.js
  5. 1
      remix-simulator/src/methods/whisper.js
  6. 20
      remix-simulator/src/provider.js

@ -1,6 +1,6 @@
var Web3 = require('web3') var Web3 = require('web3')
var Accounts = function(web3) { var Accounts = function () {
this.web3 = new Web3() this.web3 = new Web3()
// TODO: make it random and/or use remix-libs // TODO: make it random and/or use remix-libs
this.accounts = [this.web3.eth.accounts.create(['abcd'])] this.accounts = [this.web3.eth.accounts.create(['abcd'])]
@ -19,4 +19,4 @@ Accounts.prototype.eth_accounts = function(payload, cb) {
return cb(null, this.accounts.map((x) => x.address)) return cb(null, this.accounts.map((x) => x.address))
} }
module.exports = Accounts; module.exports = Accounts

@ -39,4 +39,4 @@ Blocks.prototype.eth_gasPrice = function (payload, cb) {
cb(null, 1) cb(null, 1)
} }
module.exports = Blocks; module.exports = Blocks

@ -13,5 +13,4 @@ Misc.prototype.web3_clientVersion = function (payload, cb) {
cb(null, 'Remix Simulator/' + version) cb(null, 'Remix Simulator/' + version)
} }
module.exports = Misc
module.exports = Misc;

@ -3,7 +3,7 @@ var executionContext = RemixLib.execution.executionContext
var processTx = require('./txProcess.js') var processTx = require('./txProcess.js')
var Transactions = function (accounts) { var Transactions = function (accounts) {
this.accounts = accounts; this.accounts = accounts
// TODO: fix me; this is a temporary and very hackish thing just to get the getCode working for now // TODO: fix me; this is a temporary and very hackish thing just to get the getCode working for now
this.deployedContracts = {} this.deployedContracts = {}
} }
@ -19,11 +19,11 @@ Transactions.prototype.methods = function () {
} }
Transactions.prototype.eth_sendTransaction = function (payload, cb) { Transactions.prototype.eth_sendTransaction = function (payload, cb) {
processTx(this.accounts, payload, false, cb); processTx(this.accounts, payload, false, cb)
} }
Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) { Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) {
const self = this; const self = this
executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => { executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => {
if (error) { if (error) {
return cb(error) return cb(error)
@ -60,4 +60,4 @@ Transactions.prototype.eth_call = function(payload, cb) {
processTx(this.accounts, payload, true, cb) processTx(this.accounts, payload, true, cb)
} }
module.exports = Transactions; module.exports = Transactions

@ -13,4 +13,3 @@ Whisper.prototype.shh_version = function(payload, cb) {
} }
module.exports = Whisper module.exports = Whisper

@ -1,18 +1,14 @@
var RemixLib = require('remix-lib')
const log = require('fancy-log') const log = require('fancy-log')
const merge = require('merge')
const Accounts = require('./methods/accounts.js') const Accounts = require('./methods/accounts.js')
const Blocks = require('./methods/blocks.js') const Blocks = require('./methods/blocks.js')
const Misc = require('./methods/misc.js') const Misc = require('./methods/misc.js')
const Transactions = require('./methods/transactions.js') const Transactions = require('./methods/transactions.js')
const Whisper = require('./methods/whisper.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 () { var Provider = function () {
this.Accounts = new Accounts(); this.Accounts = new Accounts()
this.methods = {} this.methods = {}
this.methods = merge(this.methods, this.Accounts.methods()) this.methods = merge(this.methods, this.Accounts.methods())
@ -24,19 +20,19 @@ var Provider = function () {
} }
Provider.prototype.sendAsync = function (payload, callback) { Provider.prototype.sendAsync = function (payload, callback) {
const self = this
log.info('payload method is ', payload.method) log.info('payload method is ', payload.method)
let method = this.methods[payload.method] let method = this.methods[payload.method]
if (method) { if (method) {
return method.call(method, payload, (err, result) => { return method.call(method, payload, (err, result) => {
if (err) { 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 () { Provider.prototype.isConnected = function () {

Loading…
Cancel
Save