Commit a52b2c4e authored by Iuri Matias's avatar Iuri Matias

fix linting issues

parent b41f3966
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
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
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
......@@ -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
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
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 () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment