From 68d6f236eb56de4d0fd59a30cd0f05a60def45ac Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Fri, 1 Sep 2017 04:46:23 +0100 Subject: [PATCH 01/21] First draft --- src/app/execution/txLogger.js | 127 ++++++++++++++++++++++++++++++++-- 1 file changed, 121 insertions(+), 6 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index bc5b0d0468..ddb28cef9c 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -1,12 +1,59 @@ 'use strict' var yo = require('yo-yo') + +// -------------- styling ---------------------- +var csjs = require('csjs-inject') var remix = require('ethereum-remix') +var styleGuide = remix.ui.styleGuide +var styles = styleGuide() + var EventManager = remix.lib.EventManager var helper = require('../../lib/helper') var ethJSUtil = require('ethereumjs-util') var BN = ethJSUtil.BN var executionContext = require('../../execution-context') +var css = csjs` + .log { + display: flex; + align-items: baseline; + } + .txTable, .tr, .td { + border: 1px solid black; + border-collapse: collapse; + font-size: 10px; + color: grey; + } + .txTable { + width: 35%; + } + #txTable { + width: 200px; + margin-left: 20px; + align-self: center; + } + .tr, .td { + padding: 3px; + } + .buttons { + display: flex; + } + .debug, .details { + ${styles.button} + min-height: 18px; + max-height: 18px; + width: 45px; + min-width: 45px; + font-size: 10px; + margin-left: 5px; + } + .debug { + background-color: ${styles.colors.lightOrange}; + } + .details { + background-color: ${styles.colors.lightGrey}; + } +` /** * This just export a function that register to `newTransaction` and forward them to the logger. * Emit debugRequested @@ -64,10 +111,44 @@ function renderKnownTransaction (self, data) { function debug () { self.event.trigger('debugRequested', [data.tx.hash]) } - function detail () { - // @TODO here should open a modal containing some info (e.g input params, logs, ...) + var tx = yo` + + ${context(self, data.tx)}, ${data.resolvedData.contractName}.${data.resolvedData.fn}, ${data.logs.length} logs +
+ + +
+
+ ` + function detail (e, container) { + var el = container + var table = yo` + + + + + + + + + + + + + + + + + + + + + +
from${helper.shortenAddress(data.tx.from)}
to:${to}
value:${value(data.tx.value)} wei
data:${helper.shortenHexData(data.tx.input)}
hash:${helper.shortenHexData((data.tx.hash))}
+ ` + el.appendChild(table) } - return yo`${context(self, data.tx)}: from:${helper.shortenAddress(data.tx.from)}, to:${to}, ${data.resolvedData.contractName}.${data.resolvedData.fn}, value:${value(data.tx.value)} wei, data:${helper.shortenHexData(data.tx.input)}, ${data.logs.length} logs, hash:${helper.shortenHexData((data.tx.hash))}, ` + return tx } function renderUnknownTransaction (self, data) { @@ -76,10 +157,44 @@ function renderUnknownTransaction (self, data) { function debug () { self.event.trigger('debugRequested', [data.tx.hash]) } - function detail () { - // @TODO here should open a modal containing some info (e.g input params, logs, ...) + var tx = yo` + + ${context(self, data.tx)} +
+ + +
+
+ ` + function detail (e, container) { + var el = container + var table = yo` + + + + + + + + + + + + + + + + + + + + + +
from${helper.shortenAddress(data.tx.from)}
to:${to}
value:${value(data.tx.value)} wei
data:${helper.shortenHexData(data.tx.input)}
hash:${helper.shortenHexData((data.tx.hash))}
+ ` + el.appendChild(table) } - return yo`${context(self, data.tx)}: from:${helper.shortenAddress(data.tx.from)}, to:${to}, value:${value(data.tx.value)} wei, data:${helper.shortenHexData((data.tx.input))}, hash:${helper.shortenHexData((data.tx.hash))}, ` + return tx } function renderEmptyBlock (self, data) { From c0081f6634fe0c4a33297eee98687faac4271e6d Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Sat, 2 Sep 2017 23:38:25 +0100 Subject: [PATCH 02/21] Fix TO field in details for constructor and call transactions --- src/app/execution/txLogger.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index ddb28cef9c..fedaee9de2 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -106,8 +106,19 @@ function log (self, tx, api) { } function renderKnownTransaction (self, data) { - var to = data.tx.to - if (to) to = helper.shortenAddress(data.tx.to) + if (data.tx.blockHash) { + var to = data.tx.to + to = helper.shortenAddress(data.tx.to) + } else if (data.tx.hash) { + var name = data.resolvedData.contractName + var fn = data.resolvedData.fn + if (fn === '(constructor)') { // create instance + to = name + '.' + fn + ',' + ' 0 logs' + } else { // function call + var toHash = helper.shortenAddress(data.resolvedData.to) + to = name + '.' + fn + toHash + ',' + ' 0 logs' + } + } function debug () { self.event.trigger('debugRequested', [data.tx.hash]) } From 7ede5d1d34929432094ed13b765e1cf54584e39e Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Sun, 3 Sep 2017 00:22:35 +0100 Subject: [PATCH 03/21] Add FROM field to details --- src/app/execution/txLogger.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index fedaee9de2..76ff3ecc81 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -106,17 +106,20 @@ function log (self, tx, api) { } function renderKnownTransaction (self, data) { + var from = helper.shortenAddress(data.tx.from) + var to = '' if (data.tx.blockHash) { - var to = data.tx.to to = helper.shortenAddress(data.tx.to) - } else if (data.tx.hash) { - var name = data.resolvedData.contractName - var fn = data.resolvedData.fn - if (fn === '(constructor)') { // create instance - to = name + '.' + fn + ',' + ' 0 logs' - } else { // function call + } else if (data.tx.hash) { // call (constructor of function call) + var name = data.resolvedData.contractName + '.' + data.resolvedData.fn + var logs = ',' + ' 0 logs' + if (data.resolvedData.fn === '(constructor)') { + to = name + logs + from = from + ' ' + name + logs + } else { var toHash = helper.shortenAddress(data.resolvedData.to) - to = name + '.' + fn + toHash + ',' + ' 0 logs' + to = name + ' ' + toHash + logs + from = from + ' ' + name + logs } } function debug () { @@ -137,7 +140,7 @@ function renderKnownTransaction (self, data) { - + @@ -163,6 +166,7 @@ function renderKnownTransaction (self, data) { } function renderUnknownTransaction (self, data) { + var from = helper.shortenAddress(data.tx.from) var to = data.tx.to if (to) to = helper.shortenAddress(data.tx.to) function debug () { @@ -183,7 +187,7 @@ function renderUnknownTransaction (self, data) {
from${helper.shortenAddress(data.tx.from)}${from}
to:
- + From c32e1b203314fad282b73c0caca014b811a15347 Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Sun, 3 Sep 2017 01:22:43 +0100 Subject: [PATCH 04/21] Fix table position and colors --- src/app/execution/txLogger.js | 50 ++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 76ff3ecc81..ef05471079 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -19,21 +19,19 @@ var css = csjs` align-items: baseline; } .txTable, .tr, .td { - border: 1px solid black; + border: 1px solid ${styles.colors.orange}; + background-color: ${styles.colors.veryLightGrey}; border-collapse: collapse; font-size: 10px; - color: grey; - } - .txTable { - width: 35%; + color: ${styles.colors.grey}; } #txTable { - width: 200px; - margin-left: 20px; + width: 450px; + margin-top: 10px; align-self: center; } .tr, .td { - padding: 3px; + padding: 4px; } .buttons { display: flex; @@ -108,6 +106,7 @@ function log (self, tx, api) { function renderKnownTransaction (self, data) { var from = helper.shortenAddress(data.tx.from) var to = '' + if (data.tx.blockHash) { to = helper.shortenAddress(data.tx.to) } else if (data.tx.hash) { // call (constructor of function call) @@ -122,20 +121,22 @@ function renderKnownTransaction (self, data) { from = from + ' ' + name + logs } } + function debug () { self.event.trigger('debugRequested', [data.tx.hash]) } var tx = yo` - - ${context(self, data.tx)}, ${data.resolvedData.contractName}.${data.resolvedData.fn}, ${data.logs.length} logs -
- - + +
+ ${context(self, data.tx)}, ${data.resolvedData.contractName}.${data.resolvedData.fn}, ${data.logs.length} logs +
+ + +
` - function detail (e, container) { - var el = container + function detail () { var table = yo`
from${helper.shortenAddress(data.tx.from)}${from}
to:
@@ -160,7 +161,7 @@ function renderKnownTransaction (self, data) {
` - el.appendChild(table) + tx.appendChild(table) } return tx } @@ -173,16 +174,17 @@ function renderUnknownTransaction (self, data) { self.event.trigger('debugRequested', [data.tx.hash]) } var tx = yo` - - ${context(self, data.tx)} -
- - + +
+ ${context(self, data.tx)} +
+ + +
` - function detail (e, container) { - var el = container + function detail () { var table = yo` @@ -207,7 +209,7 @@ function renderUnknownTransaction (self, data) {
` - el.appendChild(table) + tx.appendChild(table) } return tx } From 9a9e993244c7f42e5cf195053263ae226a2a4067 Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Sun, 3 Sep 2017 02:42:32 +0100 Subject: [PATCH 05/21] Fix show/hide --- src/app/execution/txLogger.js | 115 +++++++++++++++++----------------- 1 file changed, 59 insertions(+), 56 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index ef05471079..deb1b2fa0c 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -20,7 +20,6 @@ var css = csjs` } .txTable, .tr, .td { border: 1px solid ${styles.colors.orange}; - background-color: ${styles.colors.veryLightGrey}; border-collapse: collapse; font-size: 10px; color: ${styles.colors.grey}; @@ -130,39 +129,25 @@ function renderKnownTransaction (self, data) {
${context(self, data.tx)}, ${data.resolvedData.contractName}.${data.resolvedData.fn}, ${data.logs.length} logs
- - + +
` - function detail () { - var table = yo` - - - - - - - - - - - - - - - - - - - - - -
from${from}
to:${to}
value:${value(data.tx.value)} wei
data:${helper.shortenHexData(data.tx.input)}
hash:${helper.shortenHexData((data.tx.hash))}
- ` - tx.appendChild(table) + + var table + function txDetails () { + if (table && table.parentNode) { + tx.removeChild(table) + } else { + table = createTable({ + from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash + }) + tx.appendChild(table) + } } + return tx } @@ -178,38 +163,22 @@ function renderUnknownTransaction (self, data) {
${context(self, data.tx)}
- +
` - function detail () { - var table = yo` - - - - - - - - - - - - - - - - - - - - - -
from${from}
to:${to}
value:${value(data.tx.value)} wei
data:${helper.shortenHexData(data.tx.input)}
hash:${helper.shortenHexData((data.tx.hash))}
- ` - tx.appendChild(table) + var table + function txDetails () { + if (table && table.parentNode) { + tx.removeChild(table) + } else { + table = createTable({ + from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash + }) + tx.appendChild(table) + } } return tx } @@ -240,3 +209,37 @@ function value (v) { } module.exports = TxLogger + +// helpers + +function createTable (opts) { + var from = opts.from + var to = opts.to + var val = opts.val + var input = opts.input + var hash = opts.hash + return yo` + + + + + + + + + + + + + + + + + + + + + +
from${from}
to:${to}
value:${value(val)} wei
data:${helper.shortenHexData(input)}
hash:${helper.shortenHexData((hash))}
+ ` +} From b8d0975d73016a5dab4cb346c0a5236cd49c1a4a Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Mon, 4 Sep 2017 19:14:15 +0100 Subject: [PATCH 06/21] Show from/to/value and hash --- src/app/execution/txLogger.js | 37 +++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index deb1b2fa0c..15037dff34 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -19,7 +19,7 @@ var css = csjs` align-items: baseline; } .txTable, .tr, .td { - border: 1px solid ${styles.colors.orange}; + border: 1px solid ${styles.colors.lightOrange}; border-collapse: collapse; font-size: 10px; color: ${styles.colors.grey}; @@ -103,21 +103,18 @@ function log (self, tx, api) { } function renderKnownTransaction (self, data) { - var from = helper.shortenAddress(data.tx.from) + var from = data.tx.from var to = '' if (data.tx.blockHash) { - to = helper.shortenAddress(data.tx.to) + to = data.tx.to } else if (data.tx.hash) { // call (constructor of function call) var name = data.resolvedData.contractName + '.' + data.resolvedData.fn - var logs = ',' + ' 0 logs' + var logs = ',' + data.logs.length + ' logs' if (data.resolvedData.fn === '(constructor)') { to = name + logs - from = from + ' ' + name + logs } else { - var toHash = helper.shortenAddress(data.resolvedData.to) - to = name + ' ' + toHash + logs - from = from + ' ' + name + logs + to = data.resolvedData.to } } @@ -127,7 +124,7 @@ function renderKnownTransaction (self, data) { var tx = yo`
- ${context(self, data.tx)}, ${data.resolvedData.contractName}.${data.resolvedData.fn}, ${data.logs.length} logs + ${context(self, data)}
@@ -152,16 +149,15 @@ function renderKnownTransaction (self, data) { } function renderUnknownTransaction (self, data) { - var from = helper.shortenAddress(data.tx.from) + var from = data.tx.from var to = data.tx.to - if (to) to = helper.shortenAddress(data.tx.to) function debug () { self.event.trigger('debugRequested', [data.tx.hash]) } var tx = yo`
- ${context(self, data.tx)} + ${context(self, data)}
@@ -187,11 +183,22 @@ function renderEmptyBlock (self, data) { return yo`block ${data.block.number} - O transactions` } -function context (self, tx) { +function context (self, data) { + var from = helper.shortenHexData(data.tx.from) + var to = '' if (executionContext.getProvider() === 'vm') { - return yo`(vm)` + if (data.resolvedData.to) { + to = `${data.resolvedData.contractName}.${data.resolvedData.fn}, ${data.resolvedData.to}, ${data.logs.length} logs` + } else { + to = `${data.resolvedData.contractName}.${data.resolvedData.fn}, ${data.logs.length} logs` + } + return yo`[vm] from: ${from}, to:${to}, value:${data.tx.value} wei` } else { - return yo`block:${tx.blockNumber}, txIndex:${tx.transactionIndex}` + var hash = helper.shortenHexData(data.tx.blockHash) + var block = data.tx.blockNumber + var i = data.tx.transactionIndex + var val = data.tx.value + return yo`[block:${block} txIndex:${i}] from:${from}, to:${hash}, value:${value(val)} wei` } } From ec564a5de7b8933d0b37ca7e34e0a6335ac6bb34 Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Mon, 4 Sep 2017 20:01:23 +0100 Subject: [PATCH 07/21] Add gas to the table --- src/app/execution/txLogger.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 15037dff34..d9a2bdead1 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -139,7 +139,7 @@ function renderKnownTransaction (self, data) { tx.removeChild(table) } else { table = createTable({ - from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash + from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash, gas: data.tx.gas }) tx.appendChild(table) } @@ -171,7 +171,7 @@ function renderUnknownTransaction (self, data) { tx.removeChild(table) } else { table = createTable({ - from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash + from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash, gas: data.tx.gas }) tx.appendChild(table) } @@ -225,6 +225,7 @@ function createTable (opts) { var val = opts.val var input = opts.input var hash = opts.hash + var gas = opts.gas return yo` @@ -241,11 +242,15 @@ function createTable (opts) { - + - + + + + +
data:${helper.shortenHexData(input)}${input}
hash:${helper.shortenHexData((hash))}${hash}
gas:${gas}
` From 84a30d55ab6e906db54273b8ca951ee675cafb88 Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Mon, 4 Sep 2017 21:43:08 +0100 Subject: [PATCH 08/21] Add logs to known TX --- src/app/execution/txLogger.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index d9a2bdead1..358b208004 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -110,7 +110,7 @@ function renderKnownTransaction (self, data) { to = data.tx.to } else if (data.tx.hash) { // call (constructor of function call) var name = data.resolvedData.contractName + '.' + data.resolvedData.fn - var logs = ',' + data.logs.length + ' logs' + var logs = ', ' + data.logs.length + ' logs' if (data.resolvedData.fn === '(constructor)') { to = name + logs } else { @@ -139,7 +139,7 @@ function renderKnownTransaction (self, data) { tx.removeChild(table) } else { table = createTable({ - from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash, gas: data.tx.gas + from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash, gas: data.tx.gas, logs: data.logs }) tx.appendChild(table) } @@ -226,7 +226,7 @@ function createTable (opts) { var input = opts.input var hash = opts.hash var gas = opts.gas - return yo` + var table = yo` @@ -241,8 +241,8 @@ function createTable (opts) { - - + + @@ -254,4 +254,15 @@ function createTable (opts) {
from${value(val)} wei
data:${input}input:${helper.shortenHexData(input)}
hash:
` + if (opts.logs) { + var logs = opts.logs + var logs = yo` + + logs: + ${logs} + + ` + table.appendChild(logs) + } + return table } From 1ac03a7ce6b23f3085a9e5a44d3628626eab13d9 Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Mon, 4 Sep 2017 23:15:59 +0100 Subject: [PATCH 09/21] Improve styling for terminal logs and details table --- assets/css/universal-dapp.css | 2 +- src/app/execution/txLogger.js | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/assets/css/universal-dapp.css b/assets/css/universal-dapp.css index 1c68020991..693c730be8 100644 --- a/assets/css/universal-dapp.css +++ b/assets/css/universal-dapp.css @@ -215,7 +215,7 @@ padding: 0 0.4em; box-sizing: border-box; float: left; - word-wrap: break-word; + min-width: 100%; } #runTabView .contractProperty.hasArgs input { diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 358b208004..da2387b136 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -17,12 +17,17 @@ var css = csjs` .log { display: flex; align-items: baseline; + justify-content: space-between; + } + .txBlock, .txVM { + color: ${styles.colors.violet}; + width: 45%; } .txTable, .tr, .td { - border: 1px solid ${styles.colors.lightOrange}; border-collapse: collapse; font-size: 10px; color: ${styles.colors.grey}; + border: 1px dashed ${styles.colors.black}; } #txTable { width: 450px; @@ -32,6 +37,9 @@ var css = csjs` .tr, .td { padding: 4px; } + .tableTitle { + width: 25%; + } .buttons { display: flex; } @@ -229,36 +237,36 @@ function createTable (opts) { var table = yo` - + - + - + - + - + - +
from from ${from}
to: to ${to}
value: value ${value(val)} wei
input: input ${helper.shortenHexData(input)}
hash: hash ${hash}
gas: gas ${gas}
` if (opts.logs) { var logs = opts.logs - var logs = yo` + logs = yo` - logs: + logs ${logs} ` From eebbc352d613c08dc34504b913ed5674eee7f1f3 Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Tue, 5 Sep 2017 19:16:12 +0100 Subject: [PATCH 10/21] Add rows to the table --- src/app/execution/txLogger.js | 97 +++++++++++++++++++++++------------ src/app/tabs/run-tab.js | 2 +- src/universal-dapp.js | 2 +- 3 files changed, 65 insertions(+), 36 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index da2387b136..5d10eba2d5 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -117,10 +117,8 @@ function renderKnownTransaction (self, data) { if (data.tx.blockHash) { to = data.tx.to } else if (data.tx.hash) { // call (constructor of function call) - var name = data.resolvedData.contractName + '.' + data.resolvedData.fn - var logs = ', ' + data.logs.length + ' logs' if (data.resolvedData.fn === '(constructor)') { - to = name + logs + to = data.resolvedData.contractName + '.' + data.resolvedData.fn } else { to = data.resolvedData.to } @@ -147,7 +145,15 @@ function renderKnownTransaction (self, data) { tx.removeChild(table) } else { table = createTable({ - from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash, gas: data.tx.gas, logs: data.logs + contractAddress: data.tx.contractAddress, + data: data.tx.data, + from, + to, + gas: data.tx.gas, + hash: data.tx.has, + input: data.tx.input, + logs: JSON.stringify(data.tx.logs) || '0', + val: data.tx.value }) tx.appendChild(table) } @@ -179,7 +185,7 @@ function renderUnknownTransaction (self, data) { tx.removeChild(table) } else { table = createTable({ - from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash, gas: data.tx.gas + from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash, gas: data.tx.gas, logs: JSON.stringify(data.tx.logs) || '0' }) tx.appendChild(table) } @@ -196,9 +202,9 @@ function context (self, data) { var to = '' if (executionContext.getProvider() === 'vm') { if (data.resolvedData.to) { - to = `${data.resolvedData.contractName}.${data.resolvedData.fn}, ${data.resolvedData.to}, ${data.logs.length} logs` + to = `${data.resolvedData.contractName}.${data.resolvedData.fn}, ${helper.shortenHexData(data.resolvedData.to)}` } else { - to = `${data.resolvedData.contractName}.${data.resolvedData.fn}, ${data.logs.length} logs` + to = `${data.resolvedData.contractName}.${data.resolvedData.fn}` } return yo`[vm] from: ${from}, to:${to}, value:${data.tx.value} wei` } else { @@ -228,49 +234,72 @@ module.exports = TxLogger // helpers function createTable (opts) { - var from = opts.from - var to = opts.to - var val = opts.val - var input = opts.input - var hash = opts.hash - var gas = opts.gas - var table = yo` - + var table = yo`
` + var contractAddress = yo` + + contractAddress + ${opts.contractAddress} + + ` + if (opts.contractAddress) table.appendChild(contractAddress) + var data = helper.shortenHexData(opts.input) + data = yo` + + data + ${data} + + ` + if (opts.data) table.appendChild(data) + var from = yo` from - ${from} + ${opts.from} + ` + if (opts.from) table.appendChild(from) + var to = yo` to - ${to} + ${opts.to} + ` + if (opts.to) table.appendChild(to) + var gas = yo` - value - ${value(val)} wei + gas + ${opts.gas} + ` + if (opts.gas) table.appendChild(gas) + var hash = yo` - input - ${helper.shortenHexData(input)} + hash + ${opts.hash} + ` + if (opts.hash) table.appendChild(hash) + var input = helper.shortenHexData(opts.input) + input = yo` - hash - ${hash} + input + ${input} + ` + if (opts.input) table.appendChild(input) + var logs = yo` - gas - ${gas} + logs + ${opts.logs || '0'} - ` - if (opts.logs) { - var logs = opts.logs - logs = yo` + if (opts.logs) table.appendChild(logs) + var val = value(opts.val) + val = yo` - logs - ${logs} + value + ${val} wei - ` - table.appendChild(logs) - } + ` + if (opts.val) table.appendChild(val) return table } diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index 0cf97bb140..9e09bb03c5 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -300,7 +300,7 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { var args = createButtonInput.value txFormat.buildData(contract, contracts, true, constructor, args, appAPI.udapp(), (error, data) => { if (!error) { - appAPI.logMessage('transaction added ...') + appAPI.logMessage('[WEB3] transaction added ...') txExecution.createContract(data, appAPI.udapp(), (error, txResult) => { if (!error) { var isVM = executionContext.isVM() diff --git a/src/universal-dapp.js b/src/universal-dapp.js index 06feb38cb1..51618438aa 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -309,7 +309,7 @@ UniversalDApp.prototype.getCallButton = function (args) { if (!error) { txExecution.callFunction(args.address, data, args.funABI, self, (error, txResult) => { if (!error) { - self._api.logMessage('UDApp transaction added ...') + self._api.logMessage('[WEB3] UDApp transaction added ...') var isVM = executionContext.isVM() if (isVM) { var vmError = txExecution.checkVMError(txResult) From 9fbb016e5a519d878e11dfea5d266a53d6bff2de Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Tue, 5 Sep 2017 21:29:40 +0100 Subject: [PATCH 11/21] Replace data.tx.logs with data.logs + some other mini fixes --- src/app/execution/txLogger.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 5d10eba2d5..96749d3db9 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -152,7 +152,7 @@ function renderKnownTransaction (self, data) { gas: data.tx.gas, hash: data.tx.has, input: data.tx.input, - logs: JSON.stringify(data.tx.logs) || '0', + logs: JSON.stringify(data.logs) || '0', val: data.tx.value }) tx.appendChild(table) @@ -185,7 +185,7 @@ function renderUnknownTransaction (self, data) { tx.removeChild(table) } else { table = createTable({ - from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash, gas: data.tx.gas, logs: JSON.stringify(data.tx.logs) || '0' + from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash, gas: data.tx.gas, logs: JSON.stringify(data.logs) || '0' }) tx.appendChild(table) } @@ -202,7 +202,7 @@ function context (self, data) { var to = '' if (executionContext.getProvider() === 'vm') { if (data.resolvedData.to) { - to = `${data.resolvedData.contractName}.${data.resolvedData.fn}, ${helper.shortenHexData(data.resolvedData.to)}` + to = `${data.resolvedData.contractName}.${data.resolvedData.fn} ${helper.shortenHexData(data.resolvedData.to)}` } else { to = `${data.resolvedData.contractName}.${data.resolvedData.fn}` } From bf064ac0aaeb7eb06e35f06d134efdddfac3f3cc Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Wed, 6 Sep 2017 17:27:57 +0100 Subject: [PATCH 12/21] Logs and table details: round 1456999 --- src/app/execution/txLogger.js | 75 +++++++++++++++++------------------ src/app/tabs/run-tab.js | 2 +- src/universal-dapp.js | 2 +- 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 96749d3db9..c048a7f238 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -19,7 +19,7 @@ var css = csjs` align-items: baseline; justify-content: space-between; } - .txBlock, .txVM { + .tx { color: ${styles.colors.violet}; width: 45%; } @@ -112,16 +112,10 @@ function log (self, tx, api) { function renderKnownTransaction (self, data) { var from = data.tx.from - var to = '' - - if (data.tx.blockHash) { - to = data.tx.to - } else if (data.tx.hash) { // call (constructor of function call) - if (data.resolvedData.fn === '(constructor)') { - to = data.resolvedData.contractName + '.' + data.resolvedData.fn - } else { - to = data.resolvedData.to - } + var to = data.resolvedData.contractName + '.' + data.resolvedData.fn + if (data.resolvedData.to) { + to = to + data.resolvedData.to + var shortTo = to + helper.shortenHexData(data.resolvedData.to) } function debug () { @@ -130,7 +124,7 @@ function renderKnownTransaction (self, data) { var tx = yo`
- ${context(self, data)} + ${context(self, {from, to: shortTo, data})}
@@ -150,7 +144,7 @@ function renderKnownTransaction (self, data) { from, to, gas: data.tx.gas, - hash: data.tx.has, + hash: data.tx.hash, input: data.tx.input, logs: JSON.stringify(data.logs) || '0', val: data.tx.value @@ -171,7 +165,7 @@ function renderUnknownTransaction (self, data) { var tx = yo`
- ${context(self, data)} + ${context(self, {from, to, data})}
@@ -197,22 +191,25 @@ function renderEmptyBlock (self, data) { return yo`block ${data.block.number} - O transactions` } -function context (self, data) { - var from = helper.shortenHexData(data.tx.from) - var to = '' +function context (self, opts) { + var data = opts.data || '' + var from = opts.from ? helper.shortenHexData(opts.from) : '' + var to = opts.to || '' + var val = data.tx.value + var type = opts.type || '' + var hash = data.tx.hash ? helper.shortenHexData(data.tx.hash) : '' + var input = data.tx.input ? helper.shortenHexData(data.tx.input) : '' + var logs = data.logs ? data.logs.length : 0 if (executionContext.getProvider() === 'vm') { - if (data.resolvedData.to) { - to = `${data.resolvedData.contractName}.${data.resolvedData.fn} ${helper.shortenHexData(data.resolvedData.to)}` - } else { - to = `${data.resolvedData.contractName}.${data.resolvedData.fn}` - } - return yo`[vm] from: ${from}, to:${to}, value:${data.tx.value} wei` + return yo`[vm] from:${from}, to:${to}, value:${value(val)} wei, data:${input}, ${logs} logs, hash:${hash}` + } else if (executionContext.getProvider() !== 'web3' && data.resolvedData) { + return yo`[web3] from:${from}, to:${to}, value:${value(val)} wei, data:${input}, ${logs} logs, hash:${hash}` } else { - var hash = helper.shortenHexData(data.tx.blockHash) - var block = data.tx.blockNumber - var i = data.tx.transactionIndex - var val = data.tx.value - return yo`[block:${block} txIndex:${i}] from:${from}, to:${hash}, value:${value(val)} wei` + to = helper.shortenHexData(to) + hash = helper.shortenHexData(data.tx.blockHash) + var block = data.tx.blockNumber + var i = data.tx.transactionIndex + return yo`[block:${block} txIndex:${i}] from:${from}, to:${hash}, value:${value(val)} wei` } } @@ -235,6 +232,7 @@ module.exports = TxLogger function createTable (opts) { var table = yo`
` + var contractAddress = yo` contractAddress @@ -242,14 +240,7 @@ function createTable (opts) { ` if (opts.contractAddress) table.appendChild(contractAddress) - var data = helper.shortenHexData(opts.input) - data = yo` - - data - ${data} - - ` - if (opts.data) table.appendChild(data) + var from = yo` from @@ -257,6 +248,7 @@ function createTable (opts) { ` if (opts.from) table.appendChild(from) + var to = yo` to @@ -264,6 +256,7 @@ function createTable (opts) { ` if (opts.to) table.appendChild(to) + var gas = yo` gas @@ -271,6 +264,7 @@ function createTable (opts) { ` if (opts.gas) table.appendChild(gas) + var hash = yo` hash @@ -278,14 +272,15 @@ function createTable (opts) { ` if (opts.hash) table.appendChild(hash) - var input = helper.shortenHexData(opts.input) - input = yo` + + var input = yo` input - ${input} + ${opts.input} ` if (opts.input) table.appendChild(input) + var logs = yo` logs @@ -293,6 +288,7 @@ function createTable (opts) { ` if (opts.logs) table.appendChild(logs) + var val = value(opts.val) val = yo` @@ -301,5 +297,6 @@ function createTable (opts) { ` if (opts.val) table.appendChild(val) + return table } diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index 9e09bb03c5..1e8e82944b 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -300,7 +300,7 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { var args = createButtonInput.value txFormat.buildData(contract, contracts, true, constructor, args, appAPI.udapp(), (error, data) => { if (!error) { - appAPI.logMessage('[WEB3] transaction added ...') + appAPI.logMessage('Transaction added ...') txExecution.createContract(data, appAPI.udapp(), (error, txResult) => { if (!error) { var isVM = executionContext.isVM() diff --git a/src/universal-dapp.js b/src/universal-dapp.js index 51618438aa..06feb38cb1 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -309,7 +309,7 @@ UniversalDApp.prototype.getCallButton = function (args) { if (!error) { txExecution.callFunction(args.address, data, args.funABI, self, (error, txResult) => { if (!error) { - self._api.logMessage('[WEB3] UDApp transaction added ...') + self._api.logMessage('UDApp transaction added ...') var isVM = executionContext.isVM() if (isVM) { var vmError = txExecution.checkVMError(txResult) From 9d57d5a66466c0844a2211780f3ffc36e64e5af3 Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Wed, 6 Sep 2017 22:11:23 +0100 Subject: [PATCH 13/21] Fix a bug in the logs --- src/app/execution/txLogger.js | 36 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index c048a7f238..88bcef447b 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -113,18 +113,13 @@ function log (self, tx, api) { function renderKnownTransaction (self, data) { var from = data.tx.from var to = data.resolvedData.contractName + '.' + data.resolvedData.fn - if (data.resolvedData.to) { - to = to + data.resolvedData.to - var shortTo = to + helper.shortenHexData(data.resolvedData.to) - } - function debug () { self.event.trigger('debugRequested', [data.tx.hash]) } var tx = yo`
- ${context(self, {from, to: shortTo, data})} + ${context(self, {from, to, data})}
@@ -194,22 +189,33 @@ function renderEmptyBlock (self, data) { function context (self, opts) { var data = opts.data || '' var from = opts.from ? helper.shortenHexData(opts.from) : '' - var to = opts.to || '' + var to = opts.to || 'empty' var val = data.tx.value - var type = opts.type || '' var hash = data.tx.hash ? helper.shortenHexData(data.tx.hash) : '' var input = data.tx.input ? helper.shortenHexData(data.tx.input) : '' var logs = data.logs ? data.logs.length : 0 + var block = data.tx.blockNumber || '' + var i = data.tx.transactionIndex if (executionContext.getProvider() === 'vm') { + console.log('-----') + console.log('data') + console.log(data) + console.log('-----') + console.log('to') + console.log(to) return yo`[vm] from:${from}, to:${to}, value:${value(val)} wei, data:${input}, ${logs} logs, hash:${hash}` - } else if (executionContext.getProvider() !== 'web3' && data.resolvedData) { - return yo`[web3] from:${from}, to:${to}, value:${value(val)} wei, data:${input}, ${logs} logs, hash:${hash}` + } else if (executionContext.getProvider() !== 'vm' && data.resolvedData) { + console.log('-----') + console.log('data') + console.log(data) + console.log('-----') + console.log('to') + console.log(to) + return yo`[block:${block} txIndex:${i}] from:${from}, to:${to}, value:${value(val)} wei` } else { - to = helper.shortenHexData(to) - hash = helper.shortenHexData(data.tx.blockHash) - var block = data.tx.blockNumber - var i = data.tx.transactionIndex - return yo`[block:${block} txIndex:${i}] from:${from}, to:${hash}, value:${value(val)} wei` + to = helper.shortenHexData(to) + hash = helper.shortenHexData(data.tx.blockHash) + return yo`[block:${block} txIndex:${i}] from:${from}, to:${to}, value:${value(val)} wei` } } From 31b884a2455c9d6874336c46684b3290e411a18c Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Thu, 7 Sep 2017 22:21:54 +0100 Subject: [PATCH 14/21] Add hex address --- src/app/execution/txLogger.js | 37 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 88bcef447b..c688d20e31 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -135,7 +135,7 @@ function renderKnownTransaction (self, data) { } else { table = createTable({ contractAddress: data.tx.contractAddress, - data: data.tx.data, + data: data.tx, from, to, gas: data.tx.gas, @@ -174,7 +174,14 @@ function renderUnknownTransaction (self, data) { tx.removeChild(table) } else { table = createTable({ - from, to, val: data.tx.value, input: data.tx.input, hash: data.tx.hash, gas: data.tx.gas, logs: JSON.stringify(data.logs) || '0' + data: data.tx, + from, + to, + val: data.tx.value, + input: data.tx.input, + hash: data.tx.hash, + gas: data.tx.gas, + logs: JSON.stringify(data.logs) || '0' }) tx.appendChild(table) } @@ -189,7 +196,8 @@ function renderEmptyBlock (self, data) { function context (self, opts) { var data = opts.data || '' var from = opts.from ? helper.shortenHexData(opts.from) : '' - var to = opts.to || 'empty' + var to = opts.to + if (data.tx.to) to = to + ' ' + helper.shortenHexData(data.tx.to) var val = data.tx.value var hash = data.tx.hash ? helper.shortenHexData(data.tx.hash) : '' var input = data.tx.input ? helper.shortenHexData(data.tx.input) : '' @@ -197,20 +205,8 @@ function context (self, opts) { var block = data.tx.blockNumber || '' var i = data.tx.transactionIndex if (executionContext.getProvider() === 'vm') { - console.log('-----') - console.log('data') - console.log(data) - console.log('-----') - console.log('to') - console.log(to) return yo`[vm] from:${from}, to:${to}, value:${value(val)} wei, data:${input}, ${logs} logs, hash:${hash}` } else if (executionContext.getProvider() !== 'vm' && data.resolvedData) { - console.log('-----') - console.log('data') - console.log(data) - console.log('-----') - console.log('to') - console.log(to) return yo`[block:${block} txIndex:${i}] from:${from}, to:${to}, value:${value(val)} wei` } else { to = helper.shortenHexData(to) @@ -255,10 +251,17 @@ function createTable (opts) { ` if (opts.from) table.appendChild(from) + var toHash + var data = opts.data // opts.data = data.tx + if (data.to) { + toHash = opts.to + ' ' + data.to + } else { + toHash = opts.to + } var to = yo` - to - ${opts.to} + to + ${toHash} ` if (opts.to) table.appendChild(to) From bfe3c9339c40f42697fae02ac453e1e4353d342d Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Thu, 7 Sep 2017 23:43:46 +0100 Subject: [PATCH 15/21] Restyle table --- src/app/execution/txLogger.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index c688d20e31..6eacce3e36 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -30,8 +30,8 @@ var css = csjs` border: 1px dashed ${styles.colors.black}; } #txTable { - width: 450px; - margin-top: 10px; + margin-top: 1%; + margin-bottom: 5%; align-self: center; } .tr, .td { From eae840236d4918427ace1e335a144b703ed1d3dd Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 8 Sep 2017 10:53:36 +0200 Subject: [PATCH 16/21] better decode input param (add type and name) --- src/app/execution/txListener.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/execution/txListener.js b/src/app/execution/txListener.js index 104300ac2d..49ad15f861 100644 --- a/src/app/execution/txListener.js +++ b/src/app/execution/txListener.js @@ -249,7 +249,12 @@ class TxListener { for (var i = 0; i < abi.inputs.length; i++) { inputTypes.push(abi.inputs[i].type) } - return ethJSABI.rawDecode(inputTypes, data) + var decoded = ethJSABI.rawDecode(inputTypes, data) + var ret = {} + for (var k in abi.inputs) { + ret[abi.inputs[k].type + ' ' + abi.inputs[k].name] = decoded[k] + } + return ret } } From 021d8fc182329b05d4bb2bdcc4faa44177d9924f Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 8 Sep 2017 10:54:03 +0200 Subject: [PATCH 17/21] standard fix --- src/app/execution/txLogger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 6eacce3e36..58f55e2da4 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -197,7 +197,7 @@ function context (self, opts) { var data = opts.data || '' var from = opts.from ? helper.shortenHexData(opts.from) : '' var to = opts.to - if (data.tx.to) to = to + ' ' + helper.shortenHexData(data.tx.to) + if (data.tx.to) to = to + ' ' + helper.shortenHexData(data.tx.to) var val = data.tx.value var hash = data.tx.hash ? helper.shortenHexData(data.tx.hash) : '' var input = data.tx.input ? helper.shortenHexData(data.tx.input) : '' From 9ed3b0f412b3693b9637b0962e63fd2a780b0bcf Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 8 Sep 2017 12:46:33 +0200 Subject: [PATCH 18/21] format json stringify --- src/app/execution/txLogger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 58f55e2da4..03bcdb9b47 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -141,7 +141,7 @@ function renderKnownTransaction (self, data) { gas: data.tx.gas, hash: data.tx.hash, input: data.tx.input, - logs: JSON.stringify(data.logs) || '0', + logs: JSON.stringify(data.logs, null, '\t') || '0', val: data.tx.value }) tx.appendChild(table) From a7746442c83cf8e83703fa0fd3f63d4d1e5c2096 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 8 Sep 2017 12:46:45 +0200 Subject: [PATCH 19/21] display decoded input --- src/app/execution/txLogger.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 03bcdb9b47..e847b10d7d 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -141,6 +141,7 @@ function renderKnownTransaction (self, data) { gas: data.tx.gas, hash: data.tx.hash, input: data.tx.input, + 'decoded input': data.resolvedData && data.resolvedData.params ? JSON.stringify(value(data.resolvedData.params), null, '\t') : ' - ', logs: JSON.stringify(data.logs, null, '\t') || '0', val: data.tx.value }) @@ -217,10 +218,24 @@ function context (self, opts) { function value (v) { try { - if (v.indexOf && v.indexOf('0x') === 0) { + if (v instanceof Array) { + var ret = [] + for (var k in v) { + ret.push(value(v[k])) + } + return ret + } else if (BN.isBN(v)) { + return v.toString(10) + } else if (v.indexOf && v.indexOf('0x') === 0) { return (new BN(v.replace('0x', ''), 16)).toString(10) + } else if (typeof v === 'object') { + var retObject = {} + for (var i in v) { + retObject[i] = value(v[i]) + } + return retObject } else { - return v.toString(10) + return v } } catch (e) { console.log(e) @@ -290,6 +305,15 @@ function createTable (opts) { ` if (opts.input) table.appendChild(input) + if (opts['decoded input']) { + var inputDecoded = yo` + + decoded input + ${opts['decoded input']} + ` + table.appendChild(inputDecoded) + } + var logs = yo` logs From ce85603822d94f3544c3ff750f4fd89cfe3ad59b Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 8 Sep 2017 13:12:49 +0200 Subject: [PATCH 20/21] fix test --- test-browser/tests/compiling.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-browser/tests/compiling.js b/test-browser/tests/compiling.js index 81a7654209..696f12cd45 100644 --- a/test-browser/tests/compiling.js +++ b/test-browser/tests/compiling.js @@ -33,7 +33,7 @@ function runTests (browser) { .waitForElementPresent('.instance button[title="f - transact (not payable)"]') .click('.instance button[title="f - transact (not payable)"]') .waitForElementPresent('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]') - .assert.containsText('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]', '(vm): from:0xca3...a733c, to:0x692...77b3a, browser/Untitled.sol:TestContract.f(), value:0 wei, data:0x261...21ff0, 0 logs, hash:0xa17...523bc,DetailsDebug') + .assert.containsText('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]', '[vm] from:0xca3...a733c, to:browser/Untitled.sol:TestContract.f() 0x692...77b3a, value:0 wei, data:0x261...21ff0, 0 logs, hash:0xa17...523bc') .end() /* @TODO: need to check now the return value of the function From 3b45f0954e87d070b16e4bd3d4404ba11fb86fd9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 8 Sep 2017 13:14:19 +0200 Subject: [PATCH 21/21] fix shortenHexData --- src/lib/helper.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/helper.js b/src/lib/helper.js index 917a547b3a..5676c06040 100644 --- a/src/lib/helper.js +++ b/src/lib/helper.js @@ -4,6 +4,7 @@ module.exports = { return address.slice(0, 5) + '...' + address.slice(len - 5, len) + (etherBalance ? ' (' + etherBalance.toString() + ' ether)' : '') }, shortenHexData: function (data) { + if (!data) return '' if (data.length < 5) return data var len = data.length return data.slice(0, 5) + '...' + data.slice(len - 5, len)