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