move json rpc response out of txProcess

pull/7/head
Iuri Matias 7 years ago
parent 62f818ec89
commit 446608aa12
  1. 4
      remix-simulator/src/provider.js
  2. 1
      remix-simulator/src/server.js
  3. 10
      remix-simulator/src/txProcess.js

@ -37,7 +37,9 @@ Provider.prototype.sendAsync = function (payload, callback) {
callback(null, jsonRPCResponse(payload.id, 1)) callback(null, jsonRPCResponse(payload.id, 1))
} }
if (payload.method === 'eth_sendTransaction') { 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') { if (payload.method === 'eth_getTransactionReceipt') {
executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => { executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => {

@ -27,4 +27,3 @@ app.use(function (req, res) {
}) })
app.listen(8545, () => log('Remix Simulator listening on port 8545!')) app.listen(8545, () => log('Remix Simulator listening on port 8545!'))

@ -3,10 +3,6 @@ var TxExecution = RemixLib.execution.txExecution
var TxRunner = RemixLib.execution.txRunner var TxRunner = RemixLib.execution.txRunner
var executionContext = RemixLib.execution.executionContext 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) { function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, isCall, callback) {
let finalCallback = function (err, result) { let finalCallback = function (err, result) {
if (err) { if (err) {
@ -18,10 +14,10 @@ function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, i
if (toReturn === '0x') { if (toReturn === '0x') {
toReturn = '0x0' 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) 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) { if (err) {
return callback(err) return callback(err)
} }
callback(null, jsonRPCResponse(payload.id, result.transactionHash)) callback(null, result.transactionHash)
} }
TxExecution.createContract(from, data, value, gasLimit, txRunner, callbacks, finalCallback) TxExecution.createContract(from, data, value, gasLimit, txRunner, callbacks, finalCallback)

Loading…
Cancel
Save