From 3b901945f22e17f6029a2d2e73534ee8e35fde8c Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Mon, 19 Feb 2018 01:26:53 +0000 Subject: [PATCH] Fix problems with the caret and move txDetails function --- src/app/execution/txLogger.js | 146 ++++++++++------------------------ 1 file changed, 44 insertions(+), 102 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 1cbcb84913..044bf9ebb5 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -181,14 +181,15 @@ function log (self, tx, api) { } function renderKnownTransaction (self, data) { - var from = data.tx.from - var to = data.resolvedData.contractName + '.' + data.resolvedData.fn function debug () { self.event.trigger('debugRequested', [data.tx.hash]) } + var from = data.tx.from + var to = data.resolvedData.contractName + '.' + data.resolvedData.fn + var obj = {from, to} var tx = yo` -
+
txDetails(e, tx, data, obj)}> ${context(self, {from, to, data})}
@@ -197,40 +198,6 @@ function renderKnownTransaction (self, data) {
` - - var table - function txDetails () { - var log = document.querySelector("[class^='log']") - var caret = document.querySelector("[class^='caret']") - var caretDown = yo`` - var caretRight = yo`` - if (table && table.parentNode) { - tx.removeChild(table) - log.removeChild(caret) - log.appendChild(caretRight) - } else { - log.removeChild(caret) - log.appendChild(caretDown) - table = createTable({ - contractAddress: data.tx.contractAddress, - data: data.tx, - from, - to, - gas: data.tx.gas, - hash: data.tx.hash, - input: data.tx.input, - 'decoded input': data.resolvedData && data.resolvedData.params ? JSON.stringify(typeConversion.stringify(data.resolvedData.params), null, '\t') : ' - ', - 'decoded output': data.resolvedData && data.resolvedData.decodedReturnValue ? JSON.stringify(typeConversion.stringify(data.resolvedData.decodedReturnValue), null, '\t') : ' - ', - logs: data.logs, - val: data.tx.value, - transactionCost: data.tx.transactionCost, - executionCost: data.tx.executionCost, - status: data.tx.status - }) - tx.appendChild(table) - } - } - return tx } @@ -245,9 +212,10 @@ function renderCall (self, data) { var to = data.resolvedData.contractName + '.' + data.resolvedData.fn var from = data.tx.from ? data.tx.from : ' - ' var input = data.tx.input ? helper.shortenHexData(data.tx.input) : '' + var obj = {from, to} var tx = yo` -
+
txDetails(e, tx, data, obj)}> [call] @@ -263,51 +231,20 @@ function renderCall (self, data) {
${JSON.stringify(typeConversion.stringify(data.resolvedData.decodedReturnValue), null, '\t')}
` - - var table - function txDetails () { - var log = document.querySelector("[class^='log']") - var caret = document.querySelector("[class^='caret']") - var caretDown = yo`` - var caretRight = yo`` - if (table && table.parentNode) { - tx.removeChild(table) - log.removeChild(caret) - log.appendChild(caretRight) - } else { - log.removeChild(caret) - log.appendChild(caretDown) - table = createTable({ - isCall: data.tx.isCall, - contractAddress: data.tx.contractAddress, - data: data.tx, - from, - to, - gas: data.tx.gas, - input: data.tx.input, - 'decoded input': data.resolvedData && data.resolvedData.params ? JSON.stringify(typeConversion.stringify(data.resolvedData.params), null, '\t') : ' - ', - 'decoded output': data.resolvedData && data.resolvedData.decodedReturnValue ? JSON.stringify(typeConversion.stringify(data.resolvedData.decodedReturnValue), null, '\t') : ' - ', - logs: data.logs, - val: data.tx.value, - transactionCost: data.tx.transactionCost, - executionCost: data.tx.executionCost - }) - tx.appendChild(table) - } - } return tx } function renderUnknownTransaction (self, data) { - var from = data.tx.from - var to = data.tx.to function debug () { self.event.trigger('debugRequested', [data.tx.hash]) } + var from = data.tx.from + var to = data.tx.to + var obj = {from, to} var tx = yo` -
+
txDetails(e, tx, data, obj)}> ${context(self, {from, to, data})}
[debug]
@@ -315,35 +252,6 @@ function renderUnknownTransaction (self, data) {
` - var table - function txDetails () { - var log = document.querySelector("[class^='log']") - var caret = document.querySelector("[class^='caret']") - var caretDown = yo`` - var caretRight = yo`` - if (table && table.parentNode) { - tx.removeChild(table) - log.removeChild(caret) - log.appendChild(caretRight) - } else { - log.removeChild(caret) - log.appendChild(caretDown) - table = createTable({ - data: data.tx, - from, - to, - val: data.tx.value, - input: data.tx.input, - hash: data.tx.hash, - gas: data.tx.gas, - logs: data.tx.logs, - transactionCost: data.tx.transactionCost, - executionCost: data.tx.executionCost, - status: data.tx.status - }) - tx.appendChild(table) - } - } return tx } @@ -412,6 +320,40 @@ module.exports = TxLogger // helpers +function txDetails (e, tx, data, obj) { + var table = document.querySelector(`#${tx.id} [class^="txTable"`) + var from = obj.from + var to = obj.to + var log = document.querySelector(`#${tx.id} [class^='log']`) + var caret = document.querySelector(`#${tx.id} [class^='caret']`) + var caretDown = yo`` + var caretRight = yo`` + if (table && table.parentNode) { + tx.removeChild(table) + log.removeChild(caret) + log.appendChild(caretRight) + } else { + log.removeChild(caret) + log.appendChild(caretDown) + table = createTable({ + isCall: data.tx.isCall, + contractAddress: data.tx.contractAddress, + data: data.tx, + from, + to, + gas: data.tx.gas, + input: data.tx.input, + 'decoded input': data.resolvedData && data.resolvedData.params ? JSON.stringify(typeConversion.stringify(data.resolvedData.params), null, '\t') : ' - ', + 'decoded output': data.resolvedData && data.resolvedData.decodedReturnValue ? JSON.stringify(typeConversion.stringify(data.resolvedData.decodedReturnValue), null, '\t') : ' - ', + logs: data.logs, + val: data.tx.value, + transactionCost: data.tx.transactionCost, + executionCost: data.tx.executionCost + }) + tx.appendChild(table) + } +} + function createTable (opts) { var table = yo`
`