From a6ecdb22b4eb859c4566dfa9c2fd01a0169a0829 Mon Sep 17 00:00:00 2001 From: andri lim Date: Thu, 7 Feb 2019 17:23:08 +0700 Subject: [PATCH] premix report page: fix empty traces renderer --- premix/assets/js/index.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/premix/assets/js/index.js b/premix/assets/js/index.js index a0b650acd..5205cea4c 100644 --- a/premix/assets/js/index.js +++ b/premix/assets/js/index.js @@ -53,6 +53,10 @@ var premix = function() { }; }(); +function deepCopy(src) { + return JSON.parse(JSON.stringify(src)); +} + function windowResize() { let bodyHeight = $(window).height(); $('#opCodeSideBar').css('height', parseInt(bodyHeight) - 80); @@ -149,8 +153,8 @@ function opCodeRenderer(txId, nimbus, geth) { function moveStack(ncs, gcs, i) { let idx = parseInt(i); - ncs[idx-1].stack = ncs[idx].stack; - gcs[idx-1].stack = gcs[idx].stack; + ncs[idx-1].stack = deepCopy(ncs[idx].stack); + gcs[idx-1].stack = deepCopy(gcs[idx].stack); } function analyze(nimbus, geth) { @@ -167,8 +171,8 @@ function opCodeRenderer(txId, nimbus, geth) { } txId = parseInt(txId); - var ncs = nimbus.txTraces[txId].structLogs; - var gcs = geth.txTraces[txId].structLogs; + var ncs = deepCopy(nimbus.txTraces[txId].structLogs); + var gcs = deepCopy(geth.txTraces[txId].structLogs); var sideBar = $('#opCodeSideBar').empty(); $('#opCodeTitle').text(`Tx #${(txId+1)}`); @@ -215,6 +219,8 @@ function opCodeRenderer(txId, nimbus, geth) { if(ncs.length > 0) { renderTrace("tx", ncs[0], gcs[0]); + } else { + $('#opCodeContainer').empty(); } windowResize(); @@ -313,10 +319,6 @@ function accountsRenderer(nimbus, geth) { }; } - function deepCopy(src) { - return JSON.parse(JSON.stringify(src)); - } - function precompiledContractsName(address) { switch(address) { case "0x0000000000000000000000000000000000000001": return "ecRecover";