Commit 24f0a13a authored by yann300's avatar yann300

contract creation token in TraceManagerUtil.js

parent bc5c8124
......@@ -2,6 +2,7 @@
var React = require('react')
var style = require('./basicStyles')
var codeResolver = require('./codeResolver')
var traceManagerUtil = require('./traceManagerUtil')
module.exports = React.createClass({
contextTypes: {
......@@ -67,7 +68,7 @@ module.exports = React.createClass({
code: ['loading...']
})
var self = this
if (address.indexOf('(Contract Creation Code)') !== -1) {
if (traceManagerUtil.isContractCreation(address)) {
this.context.traceManager.getContractCreationCode(address, function (error, hexCode) {
if (error) {
console.log(error)
......
......@@ -18,7 +18,7 @@ TraceAnalyser.prototype.analyse = function (trace, tx, callback) {
callStack: callStack.slice(0)
})
if (tx.to === '(Contract Creation Code)') {
if (traceManagerUtil.isContractCreation(tx.to)) {
this.traceCache.pushContractCreation(tx.to, tx.input)
}
......@@ -65,7 +65,7 @@ TraceAnalyser.prototype.buildStorage = function (index, step, context) {
TraceAnalyser.prototype.buildDepth = function (index, step, callStack) {
if (traceManagerUtil.isCallInstruction(step) && !traceManagerUtil.isCallToPrecompiledContract(index, this.trace)) {
if (traceManagerUtil.isCreateInstruction(step)) {
var contractToken = '(Contract Creation Code) ' + index
var contractToken = traceManagerUtil.contractCreationToken(index)
callStack.push(contractToken)
var lastMemoryChange = this.traceCache.memoryChanges[this.traceCache.memoryChanges.length - 1]
this.traceCache.pushContractCreationFromMemory(index, contractToken, this.trace, lastMemoryChange)
......
'use strict'
module.exports = {
// util section
findLowerBound: function (target, changes) {
......@@ -28,7 +29,7 @@ module.exports = {
resolveCalledAddress: function (vmTraceIndex, trace) {
var step = trace[vmTraceIndex]
if (this.isCreateInstruction(step)) {
return '(Contract Creation Code) ' + vmTraceIndex
return this.contractCreationToken(vmTraceIndex)
} else if (this.isCallInstruction(step)) {
var stack = step.stack // callcode, delegatecall, ...
return stack[stack.length - 2]
......@@ -60,5 +61,13 @@ module.exports = {
} else {
return false
}
},
contractCreationToken: function (index) {
return '(Contract Creation - Step' + index + ')'
},
isContractCreation: function (address) {
return address.indexOf('(Contract Creation - Step') !== -1
}
}
'use strict'
var traceManagerUtil = require('./traceManagerUtil')
function TraceRetriever (_web3) {
this.web3 = _web3
this.storages = {} // contains all intial storage (by addresses)
......@@ -17,7 +18,7 @@ TraceRetriever.prototype.getTrace = function (txHash, 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, {})
} else if (this.storages[address]) {
callback(null, this.storages[address])
......
'use strict'
var React = require('react')
var style = require('./basicStyles')
var traceManagerUtil = require('./traceManagerUtil')
module.exports = React.createClass({
contextTypes: {
......@@ -31,7 +32,7 @@ module.exports = React.createClass({
}
if (tx) {
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.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