linting working fine

pull/697/head
aniket-engg 4 years ago committed by Aniket
parent 3e7477d0a8
commit 399a57d883
  1. 3
      libs/remix-debug/.eslintrc
  2. 5
      libs/remix-debug/src/Ethdebugger.ts
  3. 5
      libs/remix-debug/src/cmdline/index.ts
  4. 10
      libs/remix-debug/src/code/breakpointManager.ts
  5. 7
      libs/remix-debug/src/code/codeManager.ts
  6. 1
      libs/remix-debug/src/code/codeResolver.ts
  7. 7
      libs/remix-debug/src/code/codeUtils.ts
  8. 2
      libs/remix-debug/src/debugger/VmDebugger.ts
  9. 16
      libs/remix-debug/src/debugger/debugger.ts
  10. 5
      libs/remix-debug/src/debugger/solidityLocals.ts
  11. 5
      libs/remix-debug/src/debugger/solidityState.ts
  12. 12
      libs/remix-debug/src/debugger/stepManager.ts
  13. 5
      libs/remix-debug/src/eventManager.ts
  14. 11
      libs/remix-debug/src/init.ts
  15. 9
      libs/remix-debug/src/solidity-decoder/astHelper.ts
  16. 39
      libs/remix-debug/src/solidity-decoder/decodeInfo.ts
  17. 17
      libs/remix-debug/src/solidity-decoder/internalCallTree.ts
  18. 4
      libs/remix-debug/src/solidity-decoder/localDecoder.ts
  19. 7
      libs/remix-debug/src/solidity-decoder/solidityProxy.ts
  20. 1
      libs/remix-debug/src/solidity-decoder/types/ArrayType.ts
  21. 1
      libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts
  22. 1
      libs/remix-debug/src/solidity-decoder/types/Enum.ts
  23. 7
      libs/remix-debug/src/solidity-decoder/types/Mapping.ts
  24. 1
      libs/remix-debug/src/solidity-decoder/types/RefType.ts
  25. 5
      libs/remix-debug/src/solidity-decoder/types/StringType.ts
  26. 1
      libs/remix-debug/src/solidity-decoder/types/Struct.ts
  27. 3
      libs/remix-debug/src/solidity-decoder/types/ValueType.ts
  28. 2
      libs/remix-debug/src/solidity-decoder/types/util.ts
  29. 3
      libs/remix-debug/src/source/offsetToLineColumnConverter.ts
  30. 11
      libs/remix-debug/src/source/sourceLocationTracker.ts
  31. 23
      libs/remix-debug/src/source/sourceMappingDecoder.ts
  32. 4
      libs/remix-debug/src/storage/mappingPreimages.ts
  33. 3
      libs/remix-debug/src/storage/storageResolver.ts
  34. 1
      libs/remix-debug/src/storage/storageViewer.ts
  35. 4
      libs/remix-debug/src/trace/traceAnalyser.ts
  36. 14
      libs/remix-debug/src/trace/traceCache.ts
  37. 1
      libs/remix-debug/src/trace/traceHelper.ts
  38. 13
      libs/remix-debug/src/trace/traceManager.ts
  39. 1
      libs/remix-debug/src/trace/traceStepManager.ts

@ -3,7 +3,8 @@
"rules": { "rules": {
"@typescript-eslint/no-var-requires": "off", "@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-this-alias": "off" "@typescript-eslint/no-this-alias": "off",
"camelcase": "off"
}, },
"env": { "env": {
"browser": true, "browser": true,

@ -22,7 +22,6 @@ import { SolidityProxy, stateDecoder, localDecoder, InternalCallTree } from './s
* @param {Map} opts - { function compilationResult } // * @param {Map} opts - { function compilationResult } //
*/ */
export class Ethdebugger { export class Ethdebugger {
compilationResult compilationResult
web3 web3
opts opts
@ -108,8 +107,8 @@ export class Ethdebugger {
try { try {
const storageViewer = new StorageViewer({ stepIndex: step, tx: this.tx, address: address }, this.storageResolver, this.traceManager) const storageViewer = new StorageViewer({ stepIndex: step, tx: this.tx, address: address }, this.storageResolver, this.traceManager)
const locals = await localDecoder.solidityLocals(step, this.callTree, stack, memory, storageViewer, sourceLocation, null) const locals = await localDecoder.solidityLocals(step, this.callTree, stack, memory, storageViewer, sourceLocation, null)
if (locals['error']) { if (locals.error) {
return callback(locals['error']) return callback(locals.error)
} }
return callback(null, locals) return callback(null, locals)
} catch (e) { } catch (e) {

@ -3,7 +3,6 @@ import { Debugger } from '../debugger/debugger.js'
import { EventEmitter } from 'events' import { EventEmitter } from 'events'
export class CmdLine { export class CmdLine {
events events
lineColumnPos lineColumnPos
rawLocation rawLocation
@ -28,8 +27,8 @@ export class CmdLine {
loadCompilationData (inputJson, outputJson) { loadCompilationData (inputJson, outputJson) {
const data = {} const data = {}
data['data'] = outputJson data.data = outputJson
data['source'] = { sources: inputJson.sources } data.source = { sources: inputJson.sources }
this.loadCompilationResult(data) this.loadCompilationResult(data)
} }

@ -9,7 +9,6 @@ import { isJumpDestInstruction } from '../trace/traceHelper'
* Trigger events: breakpointHit, breakpointAdded, breakpointRemoved * Trigger events: breakpointHit, breakpointAdded, breakpointRemoved
*/ */
export class BreakpointManager { export class BreakpointManager {
event event
traceManager traceManager
callTree callTree
@ -31,7 +30,6 @@ export class BreakpointManager {
this.solidityProxy = solidityProxy this.solidityProxy = solidityProxy
this.breakpoints = {} this.breakpoints = {}
this.locationToRowConverter = locationToRowConverter this.locationToRowConverter = locationToRowConverter
this.previousLine
} }
setManagers ({ traceManager, callTree, solidityProxy }) { setManagers ({ traceManager, callTree, solidityProxy }) {
@ -101,7 +99,7 @@ export class BreakpointManager {
} catch (e) { } catch (e) {
return console.log('cannot jump to breakpoint ' + e) return console.log('cannot jump to breakpoint ' + e)
} }
let lineColumn = await this.locationToRowConverter(sourceLocation) const lineColumn = await this.locationToRowConverter(sourceLocation)
if (this.previousLine !== lineColumn.start.line) { if (this.previousLine !== lineColumn.start.line) {
if (direction === -1 && lineHadBreakpoint) { // TODO : improve this when we will build the correct structure before hand if (direction === -1 && lineHadBreakpoint) { // TODO : improve this when we will build the correct structure before hand
lineHadBreakpoint = false lineHadBreakpoint = false
@ -143,7 +141,7 @@ export class BreakpointManager {
return false return false
} }
const sources = this.breakpoints[filename] const sources = this.breakpoints[filename]
for (let k in sources) { for (const k in sources) {
const source = sources[k] const source = sources[k]
if (line === source.row) { if (line === source.row) {
return true return true
@ -157,7 +155,7 @@ export class BreakpointManager {
* @return {Bool} true if breapoint registered * @return {Bool} true if breapoint registered
*/ */
hasBreakpoint () { hasBreakpoint () {
for (let k in this.breakpoints) { for (const k in this.breakpoints) {
if (this.breakpoints[k].length) { if (this.breakpoints[k].length) {
return true return true
} }
@ -188,7 +186,7 @@ export class BreakpointManager {
if (!sources) { if (!sources) {
return return
} }
for (let k in sources) { for (const k in sources) {
const source = sources[k] const source = sources[k]
if (sourceLocation.row === source.row) { if (sourceLocation.row === source.row) {
sources.splice(k, 1) sources.splice(k, 1)

@ -13,7 +13,6 @@ import { CodeResolver } from './codeResolver'
*/ */
export class CodeManager { export class CodeManager {
event event
isLoading: boolean isLoading: boolean
traceManager traceManager
@ -23,7 +22,8 @@ export class CodeManager {
this.event = new EventManager() this.event = new EventManager()
this.isLoading = false this.isLoading = false
this.traceManager = _traceManager this.traceManager = _traceManager
this.codeResolver = new CodeResolver({getCode: async (address) => { this.codeResolver = new CodeResolver({
getCode: async (address) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.traceManager.web3.eth.getCode(address, (error, code) => { this.traceManager.web3.eth.getCode(address, (error, code) => {
if (error) { if (error) {
@ -32,7 +32,8 @@ export class CodeManager {
return resolve(code) return resolve(code)
}) })
}) })
}}) }
})
} }
/** /**

@ -2,7 +2,6 @@
import { nameOpCodes } from './codeUtils' import { nameOpCodes } from './codeUtils'
export class CodeResolver { export class CodeResolver {
getCode getCode
bytecodeByAddress bytecodeByAddress
instructionsByAddress instructionsByAddress

@ -35,11 +35,11 @@ export function parseCode (raw) {
const opcode = opcodes(raw[i], true) const opcode = opcodes(raw[i], true)
if (opcode.name.slice(0, 4) === 'PUSH') { if (opcode.name.slice(0, 4) === 'PUSH') {
const length = raw[i] - 0x5f const length = raw[i] - 0x5f
opcode['pushData'] = raw.slice(i + 1, i + length + 1) opcode.pushData = raw.slice(i + 1, i + length + 1)
// in case pushdata extends beyond code // in case pushdata extends beyond code
if (i + 1 + length > raw.length) { if (i + 1 + length > raw.length) {
for (let j = opcode['pushData'].length; j < length; j++) { for (let j = opcode.pushData.length; j < length; j++) {
opcode['pushData'].push(0) opcode.pushData.push(0)
} }
} }
i += length i += length
@ -62,4 +62,3 @@ export function log (num, base) {
export function roundLog (num, base) { export function roundLog (num, base) {
return Math.ceil(this.log(num, base)) return Math.ceil(this.log(num, base))
} }

@ -7,7 +7,6 @@ import { DebuggerSolidityLocals } from './solidityLocals'
const { ui } = helpers const { ui } = helpers
export class VmDebuggerLogic { export class VmDebuggerLogic {
event event
debugger debugger
stepManager stepManager
@ -259,5 +258,4 @@ export class VmDebuggerLogic {
this.event.trigger('traceReturnValueUpdate', [data, header]) this.event.trigger('traceReturnValueUpdate', [data, header])
}) })
} }
} }

@ -7,7 +7,6 @@ import { DebuggerStepManager } from './stepManager'
import { VmDebuggerLogic } from './VmDebugger' import { VmDebuggerLogic } from './VmDebugger'
export class Debugger { export class Debugger {
event event
offsetToLineColumnConverter offsetToLineColumnConverter
compilationResult compilationResult
@ -27,15 +26,20 @@ export class Debugger {
this.debugger = new Ethdebugger({ this.debugger = new Ethdebugger({
web3: options.web3, web3: options.web3,
debugWithGeneratedSources: options.debugWithGeneratedSources, debugWithGeneratedSources: options.debugWithGeneratedSources,
compilationResult: this.compilationResult, compilationResult: this.compilationResult
}) })
const { traceManager, callTree, solidityProxy } = this.debugger const { traceManager, callTree, solidityProxy } = this.debugger
this.breakPointManager = new BreakpointManager({traceManager, callTree, solidityProxy, locationToRowConverter: async (sourceLocation) => { this.breakPointManager = new BreakpointManager({
traceManager,
callTree,
solidityProxy,
locationToRowConverter: async (sourceLocation) => {
const compilationResult = await this.compilationResult() const compilationResult = await this.compilationResult()
if (!compilationResult) return { start: null, end: null } if (!compilationResult) return { start: null, end: null }
return this.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, compilationResult.source.sources, compilationResult.data.sources) return this.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, compilationResult.source.sources, compilationResult.data.sources)
}}) }
})
this.breakPointManager.event.register('managersChanged', () => { this.breakPointManager.event.register('managersChanged', () => {
const { traceManager, callTree, solidityProxy } = this.debugger const { traceManager, callTree, solidityProxy } = this.debugger
@ -115,14 +119,14 @@ export class Debugger {
if (txNumber.indexOf('0x') !== -1) { if (txNumber.indexOf('0x') !== -1) {
return web3.eth.getTransaction(txNumber, (_error, tx) => { return web3.eth.getTransaction(txNumber, (_error, tx) => {
if (_error) return reject(_error) if (_error) return reject(_error)
if (!tx) return reject('cannot find transaction ' + txNumber) if (!tx) return reject(new Error('cannot find transaction ' + txNumber))
this.debugTx(tx, loadingCb) this.debugTx(tx, loadingCb)
return resolve() return resolve()
}) })
} }
web3.eth.getTransactionFromBlock(blockNumber, txNumber, (_error, tx) => { web3.eth.getTransactionFromBlock(blockNumber, txNumber, (_error, tx) => {
if (_error) return reject(_error) if (_error) return reject(_error)
if (!tx) return reject('cannot find transaction ' + blockNumber + ' ' + txNumber) if (!tx) return reject(new Error('cannot find transaction ' + blockNumber + ' ' + txNumber))
this.debugTx(tx, loadingCb) this.debugTx(tx, loadingCb)
return resolve() return resolve()
}) })

@ -3,7 +3,6 @@ import { solidityLocals } from '../solidity-decoder/localDecoder'
import { StorageViewer } from '../storage/storageViewer' import { StorageViewer } from '../storage/storageViewer'
export class DebuggerSolidityLocals { export class DebuggerSolidityLocals {
event event
stepManager stepManager
internalTreeCall internalTreeCall
@ -75,14 +74,14 @@ export class DebuggerSolidityLocals {
var storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: result[2].value }, this.storageResolver, this.traceManager) var storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: result[2].value }, this.storageResolver, this.traceManager)
solidityLocals(this.stepManager.currentStepIndex, this.internalTreeCall, stack, memory, storageViewer, sourceLocation, cursor).then((locals) => { solidityLocals(this.stepManager.currentStepIndex, this.internalTreeCall, stack, memory, storageViewer, sourceLocation, cursor).then((locals) => {
if (!cursor) { if (!cursor) {
if (!locals['error']) { if (!locals.error) {
this.event.trigger('solidityLocals', [locals]) this.event.trigger('solidityLocals', [locals])
} }
if (!Object.keys(locals).length) { if (!Object.keys(locals).length) {
this.event.trigger('solidityLocalsMessage', ['no locals']) this.event.trigger('solidityLocalsMessage', ['no locals'])
} }
} else { } else {
if (!locals['error']) { if (!locals.error) {
this.event.trigger('solidityLocalsLoadMoreCompleted', [locals]) this.event.trigger('solidityLocalsLoadMoreCompleted', [locals])
} }
} }

@ -3,7 +3,6 @@ import { decodeState } from '../solidity-decoder/stateDecoder'
import { StorageViewer } from '../storage/storageViewer' import { StorageViewer } from '../storage/storageViewer'
export class DebuggerSolidityState { export class DebuggerSolidityState {
event event
storageResolver storageResolver
stepManager stepManager
@ -78,8 +77,8 @@ export class DebuggerSolidityState {
const storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: address }, this.storageResolver, this.traceManager) const storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: address }, this.storageResolver, this.traceManager)
decodeState(stateVars, storageViewer).then((result) => { decodeState(stateVars, storageViewer).then((result) => {
this.event.trigger('solidityStateMessage', ['']) this.event.trigger('solidityStateMessage', [''])
if (result['error']) { if (result.error) {
return this.event.trigger('solidityStateMessage', [result['error']]) return this.event.trigger('solidityStateMessage', [result.error])
} }
this.event.trigger('solidityState', [result]) this.event.trigger('solidityState', [result])
}) })

@ -2,7 +2,6 @@ import { util } from '@remix-project/remix-lib'
import { EventManager } from '../eventManager' import { EventManager } from '../eventManager'
export class DebuggerStepManager { export class DebuggerStepManager {
event event
debugger debugger
traceManager traceManager
@ -52,7 +51,7 @@ export class DebuggerStepManager {
this.traceManager.buildCallPath(index).then((callsPath) => { this.traceManager.buildCallPath(index).then((callsPath) => {
this.currentCall = callsPath[callsPath.length - 1] this.currentCall = callsPath[callsPath.length - 1]
if (this.currentCall.reverted) { if (this.currentCall.reverted) {
let revertedReason = this.currentCall.outofgas ? 'outofgas' : '' const revertedReason = this.currentCall.outofgas ? 'outofgas' : ''
this.revertionPoint = this.currentCall.return this.revertionPoint = this.currentCall.return
return this.event.trigger('revertWarning', [revertedReason]) return this.event.trigger('revertWarning', [revertedReason])
} }
@ -82,7 +81,7 @@ export class DebuggerStepManager {
stepState = 'end' stepState = 'end'
} }
let jumpOutDisabled = (step === this.traceManager.findStepOut(step)) const jumpOutDisabled = (step === this.traceManager.findStepOut(step))
this.event.trigger('stepChanged', [step, stepState, jumpOutDisabled]) this.event.trigger('stepChanged', [step, stepState, jumpOutDisabled])
}) })
@ -128,7 +127,7 @@ export class DebuggerStepManager {
if (!this.traceManager.isLoaded()) return if (!this.traceManager.isLoaded()) return
if (this.currentStepIndex >= this.traceLength - 1) return if (this.currentStepIndex >= this.traceLength - 1) return
let step = this.currentStepIndex + 1 let step = this.currentStepIndex + 1
let scope = this.debugger.callTree.findScope(step) const scope = this.debugger.callTree.findScope(step)
if (scope && scope.firstStep === step) { if (scope && scope.firstStep === step) {
step = scope.lastStep + 1 step = scope.lastStep + 1
} }
@ -168,7 +167,7 @@ export class DebuggerStepManager {
} }
calculateFirstStep () { calculateFirstStep () {
let step = this.resolveToReducedTrace(0, 1) const step = this.resolveToReducedTrace(0, 1)
return this.resolveToReducedTrace(step, 1) return this.resolveToReducedTrace(step, 1)
} }
@ -176,7 +175,7 @@ export class DebuggerStepManager {
let step = 0 let step = 0
let steps = [] let steps = []
while (step < this.traceLength) { while (step < this.traceLength) {
let _step = this.resolveToReducedTrace(step, 1) const _step = this.resolveToReducedTrace(step, 1)
if (!_step) break if (!_step) break
steps.push(_step) steps.push(_step)
step += 1 step += 1
@ -211,5 +210,4 @@ export class DebuggerStepManager {
} }
return this.debugger.callTree.reducedTrace[nextSource] return this.debugger.callTree.reducedTrace[nextSource]
} }
} }

@ -1,7 +1,6 @@
'use strict' 'use strict'
export class EventManager { export class EventManager {
registered registered
anonymous anonymous
@ -26,7 +25,7 @@ export class EventManager {
func = obj func = obj
obj = this.anonymous obj = this.anonymous
} }
for (let reg in this.registered[eventName]) { for (const reg in this.registered[eventName]) {
if (this.registered[eventName][reg].obj === obj && this.registered[eventName][reg].func === func) { if (this.registered[eventName][reg].obj === obj && this.registered[eventName][reg].func === func) {
this.registered[eventName].splice(reg, 1) this.registered[eventName].splice(reg, 1)
} }
@ -66,7 +65,7 @@ export class EventManager {
if (!this.registered[eventName]) { if (!this.registered[eventName]) {
return return
} }
for (let listener in this.registered[eventName]) { for (const listener in this.registered[eventName]) {
const l = this.registered[eventName][listener] const l = this.registered[eventName][listener]
l.func.apply(l.obj === this.anonymous ? {} : l.obj, args) l.func.apply(l.obj === this.anonymous ? {} : l.obj, args)
} }

@ -19,11 +19,11 @@ export function setProvider (web3, url) {
export function web3DebugNode (network) { export function web3DebugNode (network) {
const web3DebugNodes = { const web3DebugNodes = {
'Main': 'https://rpc.archivenode.io/e50zmkroshle2e2e50zm0044i7ao04ym', Main: 'https://rpc.archivenode.io/e50zmkroshle2e2e50zm0044i7ao04ym',
'Rinkeby': 'https://remix-rinkeby.ethdevops.io', Rinkeby: 'https://remix-rinkeby.ethdevops.io',
'Ropsten': 'https://remix-ropsten.ethdevops.io', Ropsten: 'https://remix-ropsten.ethdevops.io',
'Goerli': 'https://remix-goerli.ethdevops.io', Goerli: 'https://remix-goerli.ethdevops.io',
'Kovan': 'https://remix-kovan.ethdevops.io' Kovan: 'https://remix-kovan.ethdevops.io'
} }
if (web3DebugNodes[network]) { if (web3DebugNodes[network]) {
return loadWeb3(web3DebugNodes[network]) return loadWeb3(web3DebugNodes[network])
@ -71,4 +71,3 @@ export function extend (web3) {
}) })
} }
} }

@ -14,7 +14,7 @@ export function extractContractDefinitions (sourcesList) {
sourcesByContract: {} sourcesByContract: {}
} }
const walker = new AstWalker() const walker = new AstWalker()
for (let k in sourcesList) { for (const k in sourcesList) {
walker.walkFull(sourcesList[k].ast, (node) => { walker.walkFull(sourcesList[k].ast, (node) => {
if (node.nodeType === 'ContractDefinition') { if (node.nodeType === 'ContractDefinition') {
ret.contractsById[node.id] = node ret.contractsById[node.id] = node
@ -58,9 +58,9 @@ export function extractStateDefinitions (contractName, sourcesList, contracts) {
const stateVar = [] const stateVar = []
const baseContracts = getLinearizedBaseContracts(node.id, contracts.contractsById) const baseContracts = getLinearizedBaseContracts(node.id, contracts.contractsById)
baseContracts.reverse() baseContracts.reverse()
for (let k in baseContracts) { for (const k in baseContracts) {
const ctr = baseContracts[k] const ctr = baseContracts[k]
for (let i in ctr.nodes) { for (const i in ctr.nodes) {
const item = ctr.nodes[i] const item = ctr.nodes[i]
stateItems.push(item) stateItems.push(item)
if (item.nodeType === 'VariableDeclaration') { if (item.nodeType === 'VariableDeclaration') {
@ -83,7 +83,7 @@ export function extractStatesDefinitions (sourcesList, contracts) {
contracts = extractContractDefinitions(sourcesList) contracts = extractContractDefinitions(sourcesList)
} }
const ret = {} const ret = {}
for (let contract in contracts.contractsById) { for (const contract in contracts.contractsById) {
const name = contracts.contractsById[contract].name const name = contracts.contractsById[contract].name
const source = contracts.sourcesByContract[contract] const source = contracts.sourcesByContract[contract]
const fullName = source + ':' + name const fullName = source + ':' + name
@ -93,4 +93,3 @@ export function extractStatesDefinitions (sourcesList, contracts) {
} }
return ret return ret
} }

@ -28,8 +28,8 @@ function mapping (type, stateDefinitions, contractName) {
const valueType = parseType(valueTypeName, stateDefinitions, contractName, 'storage') const valueType = parseType(valueTypeName, stateDefinitions, contractName, 'storage')
var underlyingTypes = { var underlyingTypes = {
'keyType': keyType, keyType: keyType,
'valueType': valueType valueType: valueType
} }
return new MappingType(underlyingTypes, 'location', removeLocation(type)) return new MappingType(underlyingTypes, 'location', removeLocation(type))
} }
@ -41,7 +41,7 @@ function mapping (type, stateDefinitions, contractName) {
* @return {Object} returns decoded info about the current type: { storageBytes, typeName} * @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/ */
function uint (type) { function uint (type) {
type === 'uint' ? 'uint256' : type type = type === 'uint' ? 'uint256' : type
const storageBytes = parseInt(type.replace('uint', '')) / 8 const storageBytes = parseInt(type.replace('uint', '')) / 8
return new UintType(storageBytes) return new UintType(storageBytes)
} }
@ -53,7 +53,7 @@ function uint (type) {
* @return {Object} returns decoded info about the current type: { storageBytes, typeName} * @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/ */
function int (type) { function int (type) {
type === 'int' ? 'int256' : type type = type === 'int' ? 'int256' : type
const storageBytes = parseInt(type.replace('int', '')) / 8 const storageBytes = parseInt(type.replace('int', '')) / 8
return new IntType(storageBytes) return new IntType(storageBytes)
} }
@ -139,7 +139,6 @@ function stringType (type, stateDefinitions, contractName, location) {
* @return {Object} returns decoded info about the current type: { storageBytes, typeName, arraySize, subArray} * @return {Object} returns decoded info about the current type: { storageBytes, typeName, arraySize, subArray}
*/ */
function array (type, stateDefinitions, contractName, location) { function array (type, stateDefinitions, contractName, location) {
let arraySize
const match = type.match(/(.*)\[(.*?)\]( storage ref| storage pointer| memory| calldata)?$/) const match = type.match(/(.*)\[(.*?)\]( storage ref| storage pointer| memory| calldata)?$/)
if (!match) { if (!match) {
console.log('unable to parse type ' + type) console.log('unable to parse type ' + type)
@ -148,7 +147,7 @@ function array (type, stateDefinitions, contractName, location) {
if (!location) { if (!location) {
location = match[3].trim() location = match[3].trim()
} }
arraySize = match[2] === '' ? 'dynamic' : parseInt(match[2]) const arraySize = match[2] === '' ? 'dynamic' : parseInt(match[2])
const underlyingType = parseType(match[1], stateDefinitions, contractName, location) const underlyingType = parseType(match[1], stateDefinitions, contractName, location)
if (underlyingType === null) { if (underlyingType === null) {
console.log('unable to parse type ' + type) console.log('unable to parse type ' + type)
@ -215,7 +214,7 @@ function getEnum (type, stateDefinitions, contractName) {
} }
const state = stateDefinitions[contractName] const state = stateDefinitions[contractName]
if (state) { if (state) {
for (let dec of state.stateDefinitions) { for (const dec of state.stateDefinitions) {
if (dec && dec.name && type === contractName + '.' + dec.name) { if (dec && dec.name && type === contractName + '.' + dec.name) {
return dec return dec
} }
@ -242,7 +241,7 @@ function getStructMembers (type, stateDefinitions, contractName, location) {
} }
const state = stateDefinitions[contractName] const state = stateDefinitions[contractName]
if (state) { if (state) {
for (let dec of state.stateDefinitions) { for (const dec of state.stateDefinitions) {
if (dec.nodeType === 'StructDefinition' && type === contractName + '.' + dec.name) { if (dec.nodeType === 'StructDefinition' && type === contractName + '.' + dec.name) {
const offsets = computeOffsets(dec.members, stateDefinitions, contractName, location) const offsets = computeOffsets(dec.members, stateDefinitions, contractName, location)
if (!offsets) { if (!offsets) {
@ -290,18 +289,18 @@ function typeClass (fullType) {
*/ */
function parseType (type, stateDefinitions, contractName, location) { function parseType (type, stateDefinitions, contractName, location) {
const decodeInfos = { const decodeInfos = {
'contract': address, contract: address,
'address': address, address: address,
'array': array, array: array,
'bool': bool, bool: bool,
'bytes': dynamicByteArray, bytes: dynamicByteArray,
'bytesX': fixedByteArray, bytesX: fixedByteArray,
'enum': enumType, enum: enumType,
'string': stringType, string: stringType,
'struct': struct, struct: struct,
'int': int, int: int,
'uint': uint, uint: uint,
'mapping': mapping mapping: mapping
} }
const currentType = typeClass(type) const currentType = typeClass(type)
if (currentType === null) { if (currentType === null) {

@ -13,7 +13,6 @@ import { extractLocationFromAstVariable } from './types/util.js'
* Triggers `callTreeBuildFailed` event when tree fails to build * Triggers `callTreeBuildFailed` event when tree fails to build
*/ */
export class InternalCallTree { export class InternalCallTree {
includeLocalVariables includeLocalVariables
debugWithGeneratedSources debugWithGeneratedSources
event event
@ -121,21 +120,21 @@ export class InternalCallTree {
} }
retrieveFunctionsStack (vmtraceIndex) { retrieveFunctionsStack (vmtraceIndex) {
let scope = this.findScope(vmtraceIndex) const scope = this.findScope(vmtraceIndex)
if (!scope) return [] if (!scope) return []
let scopeId = this.scopeStarts[scope.firstStep] let scopeId = this.scopeStarts[scope.firstStep]
let functions = [] const functions = []
if (!scopeId) return functions if (!scopeId) return functions
let i = 0 let i = 0
// eslint-disable-next-line no-constant-condition // eslint-disable-next-line no-constant-condition
while (true) { while (true) {
i += 1 i += 1
if (i > 1000) throw new Error('retrieFunctionStack: recursion too deep') if (i > 1000) throw new Error('retrieFunctionStack: recursion too deep')
let functionDefinition = this.functionDefinitionsByScope[scopeId] const functionDefinition = this.functionDefinitionsByScope[scopeId]
if (functionDefinition !== undefined) { if (functionDefinition !== undefined) {
functions.push(functionDefinition) functions.push(functionDefinition)
} }
let parent = this.parentScope(scopeId) const parent = this.parentScope(scopeId)
if (!parent) break if (!parent) break
else scopeId = parent else scopeId = parent
} }
@ -294,8 +293,8 @@ async function includeVariableDeclaration (tree, step, sourceLocation, scopeId,
const stack = tree.traceManager.getStackAt(step) const stack = tree.traceManager.getStackAt(step)
states = tree.solidityProxy.extractStatesDefinitions() states = tree.solidityProxy.extractStatesDefinitions()
if (functionDefinition.parameters) { if (functionDefinition.parameters) {
let inputs = functionDefinition.parameters const inputs = functionDefinition.parameters
let outputs = functionDefinition.returnParameters const outputs = functionDefinition.returnParameters
// for (const element of functionDefinition.parameters) { // for (const element of functionDefinition.parameters) {
// if (element.nodeType === 'ParameterList') { // if (element.nodeType === 'ParameterList') {
// if (!inputs) inputs = element // if (!inputs) inputs = element
@ -369,8 +368,8 @@ function extractFunctionDefinitions (ast, astWalker) {
} }
function addParams (parameterList, tree, scopeId, states, contractName, sourceLocation, stackLength, stackPosition, dir) { function addParams (parameterList, tree, scopeId, states, contractName, sourceLocation, stackLength, stackPosition, dir) {
let params = [] const params = []
for (let inputParam in parameterList.parameters) { for (const inputParam in parameterList.parameters) {
const param = parameterList.parameters[inputParam] const param = parameterList.parameters[inputParam]
const stackDepth = stackLength + (dir * stackPosition) const stackDepth = stackLength + (dir * stackPosition)
if (stackDepth >= 0) { if (stackDepth >= 0) {

@ -3,13 +3,13 @@
export async function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory, storageResolver, currentSourceLocation, cursor) { export async function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory, storageResolver, currentSourceLocation, cursor) {
const scope = internalTreeCall.findScope(vmtraceIndex) const scope = internalTreeCall.findScope(vmtraceIndex)
if (!scope) { if (!scope) {
const error = { 'message': 'Can\'t display locals. reason: compilation result might not have been provided' } const error = { message: 'Can\'t display locals. reason: compilation result might not have been provided' }
throw error throw error
} }
const locals = {} const locals = {}
memory = formatMemory(memory) memory = formatMemory(memory)
let anonymousIncr = 1 let anonymousIncr = 1
for (let local in scope.locals) { for (const local in scope.locals) {
var variable = scope.locals[local] var variable = scope.locals[local]
if (variable.stackDepth < stack.length && variable.sourceLocation.start <= currentSourceLocation.start) { if (variable.stackDepth < stack.length && variable.sourceLocation.start <= currentSourceLocation.start) {
let name = variable.name let name = variable.name

@ -5,7 +5,6 @@ import { extractStateVariables } from './stateDecoder'
import { extractContractDefinitions, extractStatesDefinitions } from './astHelper' import { extractContractDefinitions, extractStatesDefinitions } from './astHelper'
export class SolidityProxy { export class SolidityProxy {
cache cache
getCurrentCalledAddressAt getCurrentCalledAddressAt
getCode getCode
@ -127,8 +126,8 @@ export class SolidityProxy {
function contractObjectFromCode (contracts, code, address) { function contractObjectFromCode (contracts, code, address) {
const isCreation = isContractCreation(address) const isCreation = isContractCreation(address)
for (let file in contracts) { for (const file in contracts) {
for (let contract in contracts[file]) { for (const contract in contracts[file]) {
const bytecode = isCreation ? contracts[file][contract].evm.bytecode.object : contracts[file][contract].evm.deployedBytecode.object const bytecode = isCreation ? contracts[file][contract].evm.bytecode.object : contracts[file][contract].evm.deployedBytecode.object
if (util.compareByteCode(code, '0x' + bytecode)) { if (util.compareByteCode(code, '0x' + bytecode)) {
return { name: contract, contract: contracts[file][contract] } return { name: contract, contract: contracts[file][contract] }
@ -139,7 +138,6 @@ function contractObjectFromCode (contracts, code, address) {
} }
class Cache { class Cache {
contractObjectByAddress contractObjectByAddress
stateVariablesByContractName stateVariablesByContractName
contractDeclarations contractDeclarations
@ -148,6 +146,7 @@ class Cache {
constructor () { constructor () {
this.reset() this.reset()
} }
reset () { reset () {
this.contractObjectByAddress = {} this.contractObjectByAddress = {}
this.stateVariablesByContractName = {} this.stateVariablesByContractName = {}

@ -6,7 +6,6 @@ import { RefType } from './RefType'
const sha3256 = util.sha3_256 const sha3256 = util.sha3_256
export class ArrayType extends RefType { export class ArrayType extends RefType {
underlyingType underlyingType
arraySize arraySize

@ -55,4 +55,3 @@ export class DynamicByteArray extends RefType {
return { length: '0x' + length.toString(16), value: '0x' + memory.substr(offset + 64, length), type: this.typeName } return { length: '0x' + length.toString(16), value: '0x' + memory.substr(offset + 64, length), type: this.typeName }
} }
} }

@ -2,7 +2,6 @@
import { ValueType } from './ValueType' import { ValueType } from './ValueType'
export class Enum extends ValueType { export class Enum extends ValueType {
enumDef enumDef
constructor (enumDef) { constructor (enumDef) {

@ -5,7 +5,6 @@ import { toBuffer, setLengthLeft, keccak, BN, bufferToHex} from 'ethereumjs-util
import { intToBuffer } from 'ethjs-util' import { intToBuffer } from 'ethjs-util'
export class Mapping extends RefType { export class Mapping extends RefType {
keyType keyType
valueType valueType
initialDecodedState initialDecodedState
@ -49,7 +48,7 @@ export class Mapping extends RefType {
return {} return {}
} }
const ret = {} const ret = {}
for (let i in preimages[mapSlot]) { for (const i in preimages[mapSlot]) {
const mapLocation = getMappingLocation(i, location.slot) const mapLocation = getMappingLocation(i, location.slot)
const globalLocation = { const globalLocation = {
offset: location.offset, offset: location.offset,
@ -71,13 +70,13 @@ function getMappingLocation (key, position) {
mappingP = setLengthLeft(mappingP, 32) mappingP = setLengthLeft(mappingP, 32)
const mappingKeyBuf = concatTypedArrays(mappingK, mappingP) const mappingKeyBuf = concatTypedArrays(mappingK, mappingP)
const mappingKeyPreimage: string = '0x' + mappingKeyBuf.toString('hex') const mappingKeyPreimage: string = '0x' + mappingKeyBuf.toString('hex')
let mappingStorageLocation: Buffer = keccak(mappingKeyPreimage) const mappingStorageLocation: Buffer = keccak(mappingKeyPreimage)
const mappingStorageLocationinBn: BN = new BN(mappingStorageLocation, 16) const mappingStorageLocationinBn: BN = new BN(mappingStorageLocation, 16)
return mappingStorageLocationinBn return mappingStorageLocationinBn
} }
function concatTypedArrays (a, b) { // a, b TypedArray of same type function concatTypedArrays (a, b) { // a, b TypedArray of same type
let c = new (a.constructor)(a.length + b.length) const c = new (a.constructor)(a.length + b.length)
c.set(a, 0) c.set(a, 0)
c.set(b, a.length) c.set(b, a.length)
return c return c

@ -2,7 +2,6 @@
import { toBN } from './util' import { toBN } from './util'
export class RefType { export class RefType {
location location
storageSlots storageSlots
storageBytes storageBytes

@ -2,7 +2,6 @@
import { DynamicByteArray } from './DynamicByteArray' import { DynamicByteArray } from './DynamicByteArray'
export class StringType extends DynamicByteArray { export class StringType extends DynamicByteArray {
typeName typeName
constructor (location) { constructor (location) {
@ -44,9 +43,9 @@ function format (decoded) {
value = value.replace('0x', '').replace(/(..)/g, '%$1') value = value.replace('0x', '').replace(/(..)/g, '%$1')
const ret = { length: decoded.length, raw: decoded.value, type: 'string' } const ret = { length: decoded.length, raw: decoded.value, type: 'string' }
try { try {
ret['value'] = decodeURIComponent(value) ret.value = decodeURIComponent(value)
} catch (e) { } catch (e) {
ret['error'] = 'Invalid UTF8 encoding' ret.error = 'Invalid UTF8 encoding'
ret.raw = decoded.value ret.raw = decoded.value
} }
return ret return ret

@ -3,7 +3,6 @@ import { add } from './util'
import { RefType } from './RefType' import { RefType } from './RefType'
export class Struct extends RefType { export class Struct extends RefType {
members members
constructor (memberDetails, location, fullType) { constructor (memberDetails, location, fullType) {

@ -2,7 +2,6 @@
import { extractHexValue } from './util' import { extractHexValue } from './util'
export class ValueType { export class ValueType {
storageSlots storageSlots
storageBytes storageBytes
typeName typeName
@ -58,7 +57,7 @@ export class ValueType {
* @return {Object} - decoded value * @return {Object} - decoded value
*/ */
decodeFromMemory (offset, memory) { decodeFromMemory (offset, memory) {
let value = memory.substr(2 * offset, 64) const value = memory.substr(2 * offset, 64)
return { value: this.decodeValue(value), type: this.typeName } return { value: this.decodeValue(value), type: this.typeName }
} }
} }

@ -78,7 +78,7 @@ export function removeLocation (type) {
} }
export function extractLocation (type) { export function extractLocation (type) {
let match = type.match(/( storage ref| storage pointer| memory| calldata)?$/) const match = type.match(/( storage ref| storage pointer| memory| calldata)?$/)
if (match[1] !== '') { if (match[1] !== '') {
return match[1].trim() return match[1].trim()
} }

@ -2,7 +2,6 @@
import { getLinebreakPositions, convertOffsetToLineColumn } from './sourceMappingDecoder' import { getLinebreakPositions, convertOffsetToLineColumn } from './sourceMappingDecoder'
export class OffsetToColumnConverter { export class OffsetToColumnConverter {
lineBreakPositionsByContent lineBreakPositionsByContent
sourceMappingDecoder sourceMappingDecoder
@ -17,7 +16,7 @@ export class OffsetToColumnConverter {
offsetToLineColumn (rawLocation, file, sources, asts) { offsetToLineColumn (rawLocation, file, sources, asts) {
if (!this.lineBreakPositionsByContent[file]) { if (!this.lineBreakPositionsByContent[file]) {
for (let filename in asts) { for (const filename in asts) {
const source = asts[filename] const source = asts[filename]
// source id was string before. in newer versions it has been changed to an integer so we need to check the type here // source id was string before. in newer versions it has been changed to an integer so we need to check the type here
if (typeof source.id === 'string') source.id = parseInt(source.id, 10) if (typeof source.id === 'string') source.id = parseInt(source.id, 10)

@ -8,7 +8,6 @@ import { util } from '@remix-project/remix-lib'
* Process the source code location for the current executing bytecode * Process the source code location for the current executing bytecode
*/ */
export class SourceLocationTracker { export class SourceLocationTracker {
opts opts
codeManager codeManager
event event
@ -32,7 +31,7 @@ export class SourceLocationTracker {
*/ */
async getSourceLocationFromInstructionIndex (address, index, contracts) { async getSourceLocationFromInstructionIndex (address, index, contracts) {
const sourceMap = await this.extractSourceMap(this, this.codeManager, address, contracts) const sourceMap = await this.extractSourceMap(this, this.codeManager, address, contracts)
return atIndex(index, sourceMap['map']) return atIndex(index, sourceMap.map)
} }
/** /**
@ -45,7 +44,7 @@ export class SourceLocationTracker {
async getSourceLocationFromVMTraceIndex (address, vmtraceStepIndex, contracts) { async getSourceLocationFromVMTraceIndex (address, vmtraceStepIndex, contracts) {
const sourceMap = await this.extractSourceMap(this, this.codeManager, address, contracts) const sourceMap = await this.extractSourceMap(this, this.codeManager, address, contracts)
const index = this.codeManager.getInstructionIndex(address, vmtraceStepIndex) const index = this.codeManager.getInstructionIndex(address, vmtraceStepIndex)
return atIndex(index, sourceMap['map']) return atIndex(index, sourceMap.map)
} }
/** /**
@ -83,8 +82,8 @@ export class SourceLocationTracker {
private getSourceMap (address, code, contracts) { private getSourceMap (address, code, contracts) {
const isCreation = isContractCreation(address) const isCreation = isContractCreation(address)
let bytes let bytes
for (let file in contracts) { for (const file in contracts) {
for (let contract in contracts[file]) { for (const contract in contracts[file]) {
const bytecode = contracts[file][contract].evm.bytecode const bytecode = contracts[file][contract].evm.bytecode
const deployedBytecode = contracts[file][contract].evm.deployedBytecode const deployedBytecode = contracts[file][contract].evm.deployedBytecode
if (!deployedBytecode) continue if (!deployedBytecode) continue
@ -110,7 +109,7 @@ export class SourceLocationTracker {
if (!isContractCreation(address)) self.sourceMapByAddress[address] = sourceMap if (!isContractCreation(address)) self.sourceMapByAddress[address] = sourceMap
return resolve(sourceMap) return resolve(sourceMap)
} }
reject('no sourcemap associated with the code ' + address) reject(new Error('no sourcemap associated with the code ' + address))
}).catch(reject) }).catch(reject)
}) })
} }

@ -33,7 +33,7 @@ export function decode (value) {
export function decompressAll (mapping) { export function decompressAll (mapping) {
const map = mapping.split(';') const map = mapping.split(';')
const ret = [] const ret = []
for (let k in map) { for (const k in map) {
const compressed = map[k].split(':') const compressed = map[k].split(':')
const sourceMap = { const sourceMap = {
start: compressed[0] ? parseInt(compressed[0]) : ret[ret.length - 1].start, start: compressed[0] ? parseInt(compressed[0]) : ret[ret.length - 1].start,
@ -77,7 +77,6 @@ export function convertOffsetToLineColumn (sourceLocation, lineBreakPositions) {
return { start: null, end: null } return { start: null, end: null }
} }
function convertFromCharPosition (pos, lineBreakPositions) { function convertFromCharPosition (pos, lineBreakPositions) {
let line = util.findLowerBound(pos, lineBreakPositions) let line = util.findLowerBound(pos, lineBreakPositions)
if (lineBreakPositions[line] !== pos) { if (lineBreakPositions[line] !== pos) {
@ -173,7 +172,7 @@ export function nodesAtPosition (astNodeType, position, ast) {
* @return Object { start, length, file, jump } * @return Object { start, length, file, jump }
*/ */
export function atIndex (index, mapping) { export function atIndex (index, mapping) {
let ret = {} const ret = {}
const map = mapping.split(';') const map = mapping.split(';')
if (index >= map.length) { if (index >= map.length) {
index = map.length - 1 index = map.length - 1
@ -184,19 +183,19 @@ export function atIndex (index, mapping) {
continue continue
} }
current = current.split(':') current = current.split(':')
if (ret['start'] === undefined && current[0] && current[0] !== '-1' && current[0].length) { if (ret.start === undefined && current[0] && current[0] !== '-1' && current[0].length) {
ret['start'] = parseInt(current[0]) ret.start = parseInt(current[0])
} }
if (ret['length'] === undefined && current[1] && current[1] !== '-1' && current[1].length) { if (ret.length === undefined && current[1] && current[1] !== '-1' && current[1].length) {
ret['length'] = parseInt(current[1]) ret.length = parseInt(current[1])
} }
if (ret['file'] === undefined && current[2] && current[2].length) { if (ret.file === undefined && current[2] && current[2].length) {
ret['file'] = parseInt(current[2]) ret.file = parseInt(current[2])
} }
if (ret['jump'] === undefined && current[3] && current[3].length) { if (ret.jump === undefined && current[3] && current[3].length) {
ret['jump'] = current[3] ret.jump = current[3]
} }
if (ret['start'] !== undefined && ret['length'] !== undefined && ret['file'] !== undefined && ret['jump'] !== undefined) { if (ret.start !== undefined && ret.length !== undefined && ret.file !== undefined && ret.jump !== undefined) {
break break
} }
} }

@ -12,11 +12,11 @@ import { sub } from '../solidity-decoder/types/util'
export async function decodeMappingsKeys (web3, storage, corrections) { export async function decodeMappingsKeys (web3, storage, corrections) {
const ret = {} const ret = {}
if (!corrections.length) corrections.push({ offset: 0, slot: 0 }) if (!corrections.length) corrections.push({ offset: 0, slot: 0 })
for (let hashedLoc in storage) { for (const hashedLoc in storage) {
var preimage var preimage
try { try {
const key = storage[hashedLoc].key const key = storage[hashedLoc].key
for (let k in corrections) { for (const k in corrections) {
const corrected = sub(key, corrections[k].slot).toString(16) const corrected = sub(key, corrections[k].slot).toString(16)
preimage = await getPreimage(web3, '0x' + corrected) preimage = await getPreimage(web3, '0x' + corrected)
if (preimage) break if (preimage) break

@ -7,7 +7,6 @@ import { decodeMappingsKeys } from './mappingPreimages'
* (TODO: one instance need to be shared over all the components) * (TODO: one instance need to be shared over all the components)
*/ */
export class StorageResolver { export class StorageResolver {
storageByAddress storageByAddress
preimagesMappingByAddress preimagesMappingByAddress
maxSize maxSize
@ -144,7 +143,7 @@ export class StorageResolver {
} else if (result.storage) { } else if (result.storage) {
resolve([result.storage, result.nextKey]) resolve([result.storage, result.nextKey])
} else { } else {
reject('the storage has not been provided') reject(new Error('the storage has not been provided'))
} }
}) })
} }

@ -8,7 +8,6 @@ import { decodeMappingsKeys } from './mappingPreimages'
* (TODO: one instance need to be shared over all the components) * (TODO: one instance need to be shared over all the components)
*/ */
export class StorageViewer { export class StorageViewer {
context context
storageResolver storageResolver
web3 web3

@ -2,7 +2,6 @@
import * as traceHelper from './traceHelper' import * as traceHelper from './traceHelper'
export class TraceAnalyser { export class TraceAnalyser {
traceCache traceCache
trace trace
@ -42,7 +41,7 @@ export class TraceAnalyser {
const memory = this.trace[this.traceCache.memoryChanges[this.traceCache.memoryChanges.length - 1]].memory const memory = this.trace[this.traceCache.memoryChanges[this.traceCache.memoryChanges.length - 1]].memory
const noOfReturnParams = size / 64 const noOfReturnParams = size / 64
const memoryInString = memory.join('') const memoryInString = memory.join('')
let returnParamsObj = [] const returnParamsObj = []
for (let i = 0; i < noOfReturnParams; i++) { for (let i = 0; i < noOfReturnParams; i++) {
returnParamsObj.push('0x' + memoryInString.substring(offset, offset + 64)) returnParamsObj.push('0x' + memoryInString.substring(offset, offset + 64))
offset += 64 offset += 64
@ -141,4 +140,3 @@ export class TraceAnalyser {
return context return context
} }
} }

@ -3,7 +3,6 @@ import { util } from '@remix-project/remix-lib'
const { sha3_256 } = util const { sha3_256 } = util
export class TraceCache { export class TraceCache {
returnValues returnValues
currentCall currentCall
callsTree callsTree
@ -20,7 +19,6 @@ export class TraceCache {
this.init() this.init()
} }
init () { init () {
// ...Changes contains index in the vmtrace of the corresponding changes // ...Changes contains index in the vmtrace of the corresponding changes
@ -53,7 +51,7 @@ export class TraceCache {
// outOfGas has been removed because gas left logging is apparently made differently // outOfGas has been removed because gas left logging is apparently made differently
// in the vm/geth/eth. TODO add the error property (with about the error in all clients) // in the vm/geth/eth. TODO add the error property (with about the error in all clients)
pushCall (step, index, address, callStack, reverted) { pushCall (step, index, address, callStack, reverted) {
let validReturnStep = step.op === 'RETURN' || step.op === 'STOP' const validReturnStep = step.op === 'RETURN' || step.op === 'STOP'
if ((validReturnStep || reverted) && (this.currentCall)) { if ((validReturnStep || reverted) && (this.currentCall)) {
this.currentCall.call.return = index - 1 this.currentCall.call.return = index - 1
if (!validReturnStep) { if (!validReturnStep) {
@ -63,7 +61,7 @@ export class TraceCache {
this.currentCall = parent ? { call: parent.call, parent: parent.parent } : null this.currentCall = parent ? { call: parent.call, parent: parent.parent } : null
return return
} }
let call = { const call = {
op: step.op, op: step.op,
address: address, address: address,
callStack: callStack, callStack: callStack,
@ -102,10 +100,10 @@ export class TraceCache {
pushStoreChanges (index, address, key, value) { pushStoreChanges (index, address, key, value) {
this.sstore[index] = { this.sstore[index] = {
'address': address, address: address,
'key': key, key: key,
'value': value, value: value,
'hashedKey': sha3_256(key) hashedKey: sha3_256(key)
} }
this.storageChanges.push(index) this.storageChanges.push(index)
} }

@ -66,4 +66,3 @@ export function contractCreationToken (index) {
export function isContractCreation (address) { export function isContractCreation (address) {
return address.indexOf('(Contract Creation - Step') !== -1 return address.indexOf('(Contract Creation - Step') !== -1
} }

@ -6,7 +6,6 @@ import { isCreateInstruction } from './traceHelper'
import { util } from '@remix-project/remix-lib' import { util } from '@remix-project/remix-lib'
export class TraceManager { export class TraceManager {
web3 web3
isLoading: boolean isLoading: boolean
trace trace
@ -33,10 +32,10 @@ export class TraceManager {
try { try {
const result = await this.getTrace(tx.hash) const result = await this.getTrace(tx.hash)
if (result['structLogs'].length > 0) { if (result.structLogs.length > 0) {
this.trace = result['structLogs'] this.trace = result.structLogs
this.traceAnalyser.analyse(result['structLogs'], tx) this.traceAnalyser.analyse(result.structLogs, tx)
this.isLoading = false this.isLoading = false
return true return true
} }
@ -82,7 +81,7 @@ export class TraceManager {
getLength (callback) { getLength (callback) {
if (!this.trace) { if (!this.trace) {
callback('no trace available', null) callback(new Error('no trace available'), null)
} else { } else {
callback(null, this.trace.length) callback(null, this.trace.length)
} }
@ -136,7 +135,7 @@ export class TraceManager {
getStackAt (stepIndex) { getStackAt (stepIndex) {
this.checkRequestedStep(stepIndex) this.checkRequestedStep(stepIndex)
if (this.trace[stepIndex] && this.trace[stepIndex].stack) { // there's always a stack if (this.trace[stepIndex] && this.trace[stepIndex].stack) { // there's always a stack
let stack = this.trace[stepIndex].stack.slice(0) const stack = this.trace[stepIndex].stack.slice(0)
stack.reverse() stack.reverse()
return stack return stack
} else { } else {
@ -268,7 +267,7 @@ export class TraceManager {
} }
waterfall (calls, stepindex, cb) { waterfall (calls, stepindex, cb) {
let ret = [] const ret = []
let retError = null let retError = null
for (var call in calls) { for (var call in calls) {
calls[call].apply(this, [stepindex, function (error, result) { calls[call].apply(this, [stepindex, function (error, result) {

@ -4,7 +4,6 @@ import { isCallInstruction, isCallToPrecompiledContract, isReturnInstruction } f
import { util } from '@remix-project/remix-lib' import { util } from '@remix-project/remix-lib'
export class TraceStepManager { export class TraceStepManager {
traceAnalyser traceAnalyser
constructor (_traceAnalyser) { constructor (_traceAnalyser) {

Loading…
Cancel
Save