address linting issues

pull/7/head
Iuri Matias 7 years ago
parent dd88eedbf6
commit 8948c6ba2a
  1. 4
      run.js
  2. 2
      src/deployer.js
  3. 58
      src/provider.js
  4. 4
      src/testRunner.js
  5. 60
      src/txProcess.js

@ -7,9 +7,9 @@ const Provider = require('./src/provider.js')
commander.action(function (filename) {
let web3 = new Web3()
//web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'))
// web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'))
web3.setProvider(new Provider())
//web3.setProvider(new web3.providers.WebsocketProvider('ws://localhost:8546'))
// web3.setProvider(new web3.providers.WebsocketProvider('ws://localhost:8546'))
let isDirectory = fs.lstatSync(filename).isDirectory()
RemixTests.runTestFiles(filename, isDirectory, web3)

@ -91,7 +91,7 @@ function deployAll (compileResult, web3, callback) {
contracts[contractName] = contractObject
nextEach()
}).on('error', function(err) {
}).on('error', function (err) {
console.dir(err)
nextEach(err)
})

@ -1,28 +1,27 @@
var Web3 = require('web3')
var utils = require('ethereumjs-util')
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};
function jsonRPCResponse (id, result) {
return {'id': id, 'jsonrpc': '2.0', 'result': result}
}
Provider = function() {
this.web3 = new Web3();
var Provider = function () {
this.web3 = new Web3()
// TODO: make it random
this.accounts = [this.web3.eth.accounts.create(["abcd"])]
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[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.deployedContracts = {}
}
Provider.prototype.sendAsync = function(payload, callback) {
const self = this;
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)))
@ -38,36 +37,39 @@ Provider.prototype.sendAsync = function(payload, 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
'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));
});
callback(null, jsonRPCResponse(payload.id, r))
})
}
if (payload.method === 'eth_getCode') {
let address = payload.params[0];
let block = payload.params[1];
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]))
}
if (payload.method === 'eth_call') {
processTx(this.accounts, payload, true, callback)
}
}
Provider.prototype.isConnected = function() {
return true;
Provider.prototype.isConnected = function () {
return true
}
module.exports = Provider;
module.exports = Provider

@ -83,8 +83,8 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
}
}
next()
}).on('error', function(err) {
next(err);
}).on('error', function (err) {
next(err)
})
}
}, function () {

@ -3,15 +3,18 @@ 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 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) {
let toReturn;
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')
toReturn = '0x' + result.result.vm.return.toString('hex')
if (toReturn === '0x') {
toReturn = '0x0'
}
@ -25,30 +28,30 @@ function runTx(payload, from, to, data, value, gasLimit, txRunner, callbacks, is
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) {
function createContract (payload, from, data, value, gasLimit, txRunner, callbacks, callback) {
let finalCallback = function (err, result) {
if (err) {
return callback(err);
return callback(err)
}
let contractAddress = ('0x' + result.result.createdAddress.toString('hex'))
// let contractAddress = ('0x' + result.result.createdAddress.toString('hex'))
callback(null, jsonRPCResponse(payload.id, result.transactionHash))
}
TxExecution.createContract(from, data, value, gasLimit, txRunner, callbacks, finalCallback);
TxExecution.createContract(from, data, value, gasLimit, txRunner, callbacks, finalCallback)
}
function processTx(accounts, payload, isCall, callback) {
function processTx (accounts, payload, isCall, callback) {
let api = {
logMessage: (msg) => {
},
logHtmlMessage: (msg) => {
},
//config: self._api.config,
// config: self._api.config,
config: {
getUnpersistedProperty: (key) => {
//if (key === 'settings/always-use-vm') {
// return true
//}
// if (key === 'settings/always-use-vm') {
// return true
// }
return true
},
get: () => {
@ -59,34 +62,37 @@ function processTx(accounts, payload, isCall, callback) {
cb()
},
personalMode: () => {
//return self._api.config.get('settings/personal-mode')
// return self._api.config.get('settings/personal-mode')
return false
}
}
executionContext.init(api.config);
executionContext.init(api.config)
let txRunner = new TxRunner(accounts, api);
let { from: from, to: to, data: data, value: value, gas: gas } = payload.params[0];
gas = gas || 3000000;
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);
continueTxExecution(null)
},
gasEstimationForceSend: (error, continueTxExecution, cancelCb) => {
continueTxExecution();
if (error) {
continueTxExecution(error)
}
continueTxExecution()
},
promptCb: (okCb, cancelCb) => {
okCb();
okCb()
}
}
if (to) {
runTx(payload, from, to, data, value, gas, txRunner, callbacks, isCall, callback);
runTx(payload, from, to, data, value, gas, txRunner, callbacks, isCall, callback)
} else {
createContract(payload, from, data, value, gas, txRunner, callbacks, callback);
createContract(payload, from, data, value, gas, txRunner, callbacks, callback)
}
}
module.exports = processTx;
module.exports = processTx

Loading…
Cancel
Save