Commit 24f0a13a authored by yann300's avatar yann300

contract creation token in TraceManagerUtil.js

parent bc5c8124
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
var React = require('react') var React = require('react')
var style = require('./basicStyles') var style = require('./basicStyles')
var codeResolver = require('./codeResolver') var codeResolver = require('./codeResolver')
var traceManagerUtil = require('./traceManagerUtil')
module.exports = React.createClass({ module.exports = React.createClass({
contextTypes: { contextTypes: {
...@@ -67,7 +68,7 @@ module.exports = React.createClass({ ...@@ -67,7 +68,7 @@ module.exports = React.createClass({
code: ['loading...'] code: ['loading...']
}) })
var self = this var self = this
if (address.indexOf('(Contract Creation Code)') !== -1) { if (traceManagerUtil.isContractCreation(address)) {
this.context.traceManager.getContractCreationCode(address, function (error, hexCode) { this.context.traceManager.getContractCreationCode(address, function (error, hexCode) {
if (error) { if (error) {
console.log(error) console.log(error)
......
...@@ -18,7 +18,7 @@ TraceAnalyser.prototype.analyse = function (trace, tx, callback) { ...@@ -18,7 +18,7 @@ TraceAnalyser.prototype.analyse = function (trace, tx, callback) {
callStack: callStack.slice(0) callStack: callStack.slice(0)
}) })
if (tx.to === '(Contract Creation Code)') { if (traceManagerUtil.isContractCreation(tx.to)) {
this.traceCache.pushContractCreation(tx.to, tx.input) this.traceCache.pushContractCreation(tx.to, tx.input)
} }
...@@ -65,7 +65,7 @@ TraceAnalyser.prototype.buildStorage = function (index, step, context) { ...@@ -65,7 +65,7 @@ TraceAnalyser.prototype.buildStorage = function (index, step, context) {
TraceAnalyser.prototype.buildDepth = function (index, step, callStack) { TraceAnalyser.prototype.buildDepth = function (index, step, callStack) {
if (traceManagerUtil.isCallInstruction(step) && !traceManagerUtil.isCallToPrecompiledContract(index, this.trace)) { if (traceManagerUtil.isCallInstruction(step) && !traceManagerUtil.isCallToPrecompiledContract(index, this.trace)) {
if (traceManagerUtil.isCreateInstruction(step)) { if (traceManagerUtil.isCreateInstruction(step)) {
var contractToken = '(Contract Creation Code) ' + index var contractToken = traceManagerUtil.contractCreationToken(index)
callStack.push(contractToken) callStack.push(contractToken)
var lastMemoryChange = this.traceCache.memoryChanges[this.traceCache.memoryChanges.length - 1] var lastMemoryChange = this.traceCache.memoryChanges[this.traceCache.memoryChanges.length - 1]
this.traceCache.pushContractCreationFromMemory(index, contractToken, this.trace, lastMemoryChange) this.traceCache.pushContractCreationFromMemory(index, contractToken, this.trace, lastMemoryChange)
......
'use strict'
module.exports = { module.exports = {
// util section // util section
findLowerBound: function (target, changes) { findLowerBound: function (target, changes) {
...@@ -28,7 +29,7 @@ module.exports = { ...@@ -28,7 +29,7 @@ module.exports = {
resolveCalledAddress: function (vmTraceIndex, trace) { resolveCalledAddress: function (vmTraceIndex, trace) {
var step = trace[vmTraceIndex] var step = trace[vmTraceIndex]
if (this.isCreateInstruction(step)) { if (this.isCreateInstruction(step)) {
return '(Contract Creation Code) ' + vmTraceIndex return this.contractCreationToken(vmTraceIndex)
} else if (this.isCallInstruction(step)) { } else if (this.isCallInstruction(step)) {
var stack = step.stack // callcode, delegatecall, ... var stack = step.stack // callcode, delegatecall, ...
return stack[stack.length - 2] return stack[stack.length - 2]
...@@ -60,5 +61,13 @@ module.exports = { ...@@ -60,5 +61,13 @@ module.exports = {
} else { } else {
return false return false
} }
},
contractCreationToken: function (index) {
return '(Contract Creation - Step' + index + ')'
},
isContractCreation: function (address) {
return address.indexOf('(Contract Creation - Step') !== -1
} }
} }
'use strict' 'use strict'
var traceManagerUtil = require('./traceManagerUtil')
function TraceRetriever (_web3) { function TraceRetriever (_web3) {
this.web3 = _web3 this.web3 = _web3
this.storages = {} // contains all intial storage (by addresses) this.storages = {} // contains all intial storage (by addresses)
...@@ -17,7 +18,7 @@ TraceRetriever.prototype.getTrace = function (txHash, callback) { ...@@ -17,7 +18,7 @@ TraceRetriever.prototype.getTrace = function (txHash, callback) {
} }
TraceRetriever.prototype.getStorage = function (tx, address, callback) { TraceRetriever.prototype.getStorage = function (tx, address, callback) {
if (tx.to === '(Contract Creation Code)' || address.indexOf('(Contract Creation Code)') !== -1) { if (traceManagerUtil.isContractCreation(address)) {
callback(null, {}) callback(null, {})
} else if (this.storages[address]) { } else if (this.storages[address]) {
callback(null, this.storages[address]) callback(null, this.storages[address])
......
'use strict' 'use strict'
var React = require('react') var React = require('react')
var style = require('./basicStyles') var style = require('./basicStyles')
var traceManagerUtil = require('./traceManagerUtil')
module.exports = React.createClass({ module.exports = React.createClass({
contextTypes: { contextTypes: {
...@@ -31,7 +32,7 @@ module.exports = React.createClass({ ...@@ -31,7 +32,7 @@ module.exports = React.createClass({
} }
if (tx) { if (tx) {
if (!tx.to) { if (!tx.to) {
tx.to = '(Contract Creation Code)' tx.to = traceManagerUtil.contractCreationToken('0')
} }
this.setState({from: tx.from, to: tx.to, hash: tx.hash}) this.setState({from: tx.from, to: tx.to, hash: tx.hash})
this.props.onNewTxRequested(this.state.blockNumber, parseInt(this.state.txNumber), tx) this.props.onNewTxRequested(this.state.blockNumber, parseInt(this.state.txNumber), tx)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment