- clean code

- normalize hex
pull/7/head
yann300 9 years ago
parent 837a695b55
commit ad96e2cc6e
  1. 2
      src/ButtonNavigator.js
  2. 4
      src/Ethdebugger.js
  3. 4
      src/StackPanel.js
  4. 6
      src/TxBrowser.js
  5. 3
      src/helpers/traceHelper.js
  6. 8
      src/helpers/ui.js
  7. 4
      src/trace/traceRetriever.js
  8. 2
      test/TestTraceRetriever.js

@ -63,7 +63,7 @@ ButtonNavigator.prototype.stepChanged = function (step) {
} else {
self.intoForwardDisabled = step >= length - 1
self.overForwardDisabled = step >= length - 1
self.NextcallDisabled = step >= length - 1
self.nextCallDisabled = step >= length - 1
}
})
}

@ -10,9 +10,8 @@ var yo = require('yo-yo')
var init = require('./helpers/init')
var ui = require('./helpers/ui')
function Ethdebugger (_context) {
function Ethdebugger () {
util.extend(this, new EventManager())
this.context = _context
this.currentStepIndex = -1
this.tx
@ -35,7 +34,6 @@ function Ethdebugger (_context) {
}
Ethdebugger.prototype.render = function () {
var self = this
return (
yo`<div style=${ui.formatCss(style.font)}>
<h1 style=${ui.formatCss(style.container)}>Eth Debugger</h1>

@ -1,5 +1,6 @@
'use strict'
var BasicPanel = require('./BasicPanel')
var ui = require('./helpers/ui')
var yo = require('yo-yo')
function StackPanel (_parent, _traceManager) {
@ -36,7 +37,8 @@ StackPanel.prototype.init = function () {
StackPanel.prototype.format = function (stack) {
var ret = ''
for (var key in stack) {
ret += stack[key] + '\n'
var hex = ui.normalizeHex(stack[key])
ret += hex + '\n'
}
return ret
}

@ -17,12 +17,8 @@ function TxBrowser (_web3) {
this.view
}
/*
getInitialState: function () {
return {blockNumber: '1000110', txNumber: '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51', from: '', to: '', hash: ''}
},
*/
// 0xcda2b2835add61af54cf83bd076664d98d7908c6cd98d86423b3b48d8b8e51ff
// creation 0xa9619e1d0a35b2c1d686f5b661b3abd87f998d2844e8e9cc905edb57fc9ce349
// invokation 0x71a6d583d16d142c5c3e8903060e8a4ee5a5016348a9448df6c3e63b68076ec4
// test:

@ -1,4 +1,5 @@
'use strict'
var ui = require('../helpers/ui')
module.exports = {
// util section
findLowerBound: function (target, changes) {
@ -32,7 +33,7 @@ module.exports = {
return this.contractCreationToken(vmTraceIndex)
} else if (this.isCallInstruction(step)) {
var stack = step.stack // callcode, delegatecall, ...
return stack[stack.length - 2]
return ui.normalizeHex(stack[stack.length - 2])
}
return undefined
},

@ -41,5 +41,13 @@ module.exports = {
}
}
return ret
},
normalizeHex: function (hex) {
if (hex.indexOf('0x') === 0) {
hex = hex.replace('0x', '')
}
hex = hex.replace(/^0+/, '')
return '0x' + hex
}
}

@ -11,7 +11,7 @@ TraceRetriever.prototype.getTrace = function (txHash, callback) {
disableStorage: this.debugStorageAtAvailable(),
disableMemory: false,
disableStack: false,
fullStorage: !this.debugStorageAtAvailable()
fullStorage: false // !this.debugStorageAtAvailable()
}
this.web3.debug.traceTransaction(txHash, options, function (error, result) {
callback(error, result)
@ -33,7 +33,7 @@ TraceRetriever.prototype.getStorage = function (tx, address, callback) {
}
TraceRetriever.prototype.debugStorageAtAvailable = function () {
return true // storageAt not available if using geth
return this.web3.version.node.toLowerCase().indexOf('geth') === -1 // storageAt not available if using geth
}
module.exports = TraceRetriever

@ -32,7 +32,7 @@ TestTraceRetriever.prototype.getStorage = function (tx, address, callback) {
}
TestTraceRetriever.prototype.debugStorageAtAvailable = function () {
return false // storageAt not available if using geth
return false // test scenario does not require web3.
}
module.exports = TestTraceRetriever

Loading…
Cancel
Save