refactor to make return value conversion in runTx instead of callers

pull/5370/head
Iuri Matias 5 years ago
parent ab8d140223
commit c9a70048ff
  1. 7
      src/blockchain/blockchain.js

@ -251,12 +251,11 @@ class Blockchain {
logCallback(`${logMsg}`) logCallback(`${logMsg}`)
} }
if (funABI.type === 'fallback') data.dataHex = value if (funABI.type === 'fallback') data.dataHex = value
this.callFunction(address, data, funABI, confirmationCb, continueCb, promptCb, (error, txResult) => { this.callFunction(address, data, funABI, confirmationCb, continueCb, promptCb, (error, txResult, _address, returnValue) => {
if (error) { if (error) {
return logCallback(`${logMsg} errored: ${error} `) return logCallback(`${logMsg} errored: ${error} `)
} }
if (lookupOnly) { if (lookupOnly) {
const returnValue = (this.executionContext.isVM() ? txResult.result.execResult.returnValue : ethJSUtil.toBuffer(txResult.result))
outputCb(returnValue) outputCb(returnValue)
} }
}) })
@ -462,11 +461,13 @@ class Blockchain {
} }
let address = null let address = null
let returnValue = null
if (txResult && txResult.result) { if (txResult && txResult.result) {
address = isVM ? txResult.result.createdAddress : txResult.result.contractAddress address = isVM ? txResult.result.createdAddress : txResult.result.contractAddress
returnValue = (txResult.result.execResult && isVM) ? txResult.result.execResult.returnValue : ethJSUtil.toBuffer(txResult.result)
} }
cb(error, txResult, address) cb(error, txResult, address, returnValue)
}) })
} }

Loading…
Cancel
Save