|
|
|
@ -447,23 +447,7 @@ UniversalDApp.prototype.getCallButton = function (args) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
self.runTx(data, args, function (err, result) { |
|
|
|
|
if (err) { |
|
|
|
|
replaceOutput($result, $('<span/>').text(err).addClass('error')); |
|
|
|
|
// VM only
|
|
|
|
|
} else if (self.options.vm && result.vm.exception && result.vm.exceptionError) { |
|
|
|
|
replaceOutput($result, $('<span/>').text('VM Exception: ' + result.vm.exceptionError).addClass('error')); |
|
|
|
|
// VM only
|
|
|
|
|
} else if (self.options.vm && result.vm.return === undefined) { |
|
|
|
|
replaceOutput($result, $('<span/>').text('Exception during execution.').addClass('error')); |
|
|
|
|
} else if (isConstructor) { |
|
|
|
|
replaceOutput($result, getGasUsedOutput(result, result.vm)); |
|
|
|
|
args.appendFunctions(self.options.vm ? result.createdAddress : result.contractAddress); |
|
|
|
|
} else if (self.options.vm) { |
|
|
|
|
var outputObj = '0x' + result.vm.return.toString('hex'); |
|
|
|
|
clearOutput($result); |
|
|
|
|
$result.append(getReturnOutput(outputObj)).append(getGasUsedOutput(result, result.vm)); |
|
|
|
|
|
|
|
|
|
var decodeResponse = function (response) { |
|
|
|
|
// Only decode if there supposed to be fields
|
|
|
|
|
if (args.abi.outputs.length > 0) { |
|
|
|
|
try { |
|
|
|
@ -475,7 +459,7 @@ UniversalDApp.prototype.getCallButton = function (args) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// decode data
|
|
|
|
|
var decodedObj = ethJSABI.rawDecode(outputTypes, result.vm.return); |
|
|
|
|
var decodedObj = ethJSABI.rawDecode(outputTypes, response); |
|
|
|
|
|
|
|
|
|
// format decoded data
|
|
|
|
|
decodedObj = ethJSABI.stringify(outputTypes, decodedObj); |
|
|
|
@ -488,13 +472,43 @@ UniversalDApp.prototype.getCallButton = function (args) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$result.append(getDecodedOutput(decodedObj)); |
|
|
|
|
return getDecodedOutput(decodedObj); |
|
|
|
|
} catch (e) { |
|
|
|
|
$result.append(getDecodedOutput('Failed to decode output: ' + e)); |
|
|
|
|
return getDecodedOutput('Failed to decode output: ' + e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var decoded; |
|
|
|
|
self.runTx(data, args, function (err, result) { |
|
|
|
|
if (err) { |
|
|
|
|
replaceOutput($result, $('<span/>').text(err).addClass('error')); |
|
|
|
|
// VM only
|
|
|
|
|
} else if (self.options.vm && result.vm.exception && result.vm.exceptionError) { |
|
|
|
|
replaceOutput($result, $('<span/>').text('VM Exception: ' + result.vm.exceptionError).addClass('error')); |
|
|
|
|
// VM only
|
|
|
|
|
} else if (self.options.vm && result.vm.return === undefined) { |
|
|
|
|
replaceOutput($result, $('<span/>').text('Exception during execution.').addClass('error')); |
|
|
|
|
} else if (isConstructor) { |
|
|
|
|
replaceOutput($result, getGasUsedOutput(result, result.vm)); |
|
|
|
|
args.appendFunctions(self.options.vm ? result.createdAddress : result.contractAddress); |
|
|
|
|
} else if (self.options.vm) { |
|
|
|
|
var outputObj = '0x' + result.vm.return.toString('hex'); |
|
|
|
|
clearOutput($result); |
|
|
|
|
$result.append(getReturnOutput(outputObj)).append(getGasUsedOutput(result, result.vm)); |
|
|
|
|
|
|
|
|
|
decoded = decodeResponse(result.vm.return); |
|
|
|
|
if (decoded) { |
|
|
|
|
$result.append(decoded); |
|
|
|
|
} |
|
|
|
|
} else if (args.abi.constant && !isConstructor) { |
|
|
|
|
replaceOutput($result, getReturnOutput(result)); |
|
|
|
|
clearOutput($result); |
|
|
|
|
$result.append(getReturnOutput(result)).append(getGasUsedOutput({})); |
|
|
|
|
|
|
|
|
|
decoded = decodeResponse(ethJSUtil.toBuffer(result)); |
|
|
|
|
if (decoded) { |
|
|
|
|
$result.append(decoded); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
clearOutput($result); |
|
|
|
|
$result.append(getReturnOutput(result)).append(getGasUsedOutput(result)); |
|
|
|
|