Display raw result as well as decoded output separately

pull/1/head
Alex Beregszaszi 9 years ago
parent 312098badf
commit 56c8e62d28
  1. 21
      assets/js/universal-dapp.js

@ -264,6 +264,14 @@ UniversalDApp.prototype.getCallButton = function(args) {
return $gasUsed; return $gasUsed;
} }
var getDecodedOutput = function (result) {
var $decoded = $('<ol>');
for (var i = 0; i < result.length; i++) {
$decoded.append($('<li>').text(result[i]));
}
return $('<div class="decoded">').html('<strong>Decoded:</strong> ').append($decoded);
}
var getOutput = function() { var getOutput = function() {
var $result = $('<div class="result" />'); var $result = $('<div class="result" />');
var $close = $('<div class="udapp-close" />'); var $close = $('<div class="udapp-close" />');
@ -340,20 +348,21 @@ UniversalDApp.prototype.getCallButton = function(args) {
replaceOutput($result, getGasUsedOutput(result)); replaceOutput($result, getGasUsedOutput(result));
args.appendFunctions(result.createdAddress); args.appendFunctions(result.createdAddress);
} else if (self.options.vm){ } else if (self.options.vm){
var outputObj; var outputObj = '0x' + result.vm.return.toString('hex');
clearOutput($result);
$result.append(getReturnOutput(outputObj)).append(getGasUsedOutput(result.vm));
try { try {
var outputTypes = []; var outputTypes = [];
for (var i = 0; i < args.abi.outputs.length; i++) { for (var i = 0; i < args.abi.outputs.length; i++) {
outputTypes.push(args.abi.outputs[i].type); outputTypes.push(args.abi.outputs[i].type);
} }
outputObj = EthJS.ABI.rawDecode(null, null, outputTypes, result.vm.return);
var decodedObj = EthJS.ABI.rawDecode(null, null, outputTypes, result.vm.return);
$result.append(getDecodedOutput(decodedObj));
} catch (e) { } catch (e) {
outputObj = '0x' + result.vm.return.toString('hex');
} }
clearOutput($result);
$result.append(getReturnOutput(outputObj)).append(getGasUsedOutput(result.vm));
} else if (args.abi.constant && !isConstructor) { } else if (args.abi.constant && !isConstructor) {
replaceOutput($result, getReturnOutput(result)); replaceOutput($result, getReturnOutput(result));
} else { } else {

Loading…
Cancel
Save