linting working fine

pull/5370/head
aniket-engg 4 years ago committed by Aniket
parent bcefc24c3d
commit 8dfe290746
  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": {
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-this-alias": "off"
"@typescript-eslint/no-this-alias": "off",
"camelcase": "off"
},
"env": {
"browser": true,

@ -22,7 +22,6 @@ import { SolidityProxy, stateDecoder, localDecoder, InternalCallTree } from './s
* @param {Map} opts - { function compilationResult } //
*/
export class Ethdebugger {
compilationResult
web3
opts
@ -108,8 +107,8 @@ export class Ethdebugger {
try {
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)
if (locals['error']) {
return callback(locals['error'])
if (locals.error) {
return callback(locals.error)
}
return callback(null, locals)
} catch (e) {

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

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

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

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

@ -35,11 +35,11 @@ export function parseCode (raw) {
const opcode = opcodes(raw[i], true)
if (opcode.name.slice(0, 4) === 'PUSH') {
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
if (i + 1 + length > raw.length) {
for (let j = opcode['pushData'].length; j < length; j++) {
opcode['pushData'].push(0)
for (let j = opcode.pushData.length; j < length; j++) {
opcode.pushData.push(0)
}
}
i += length
@ -62,4 +62,3 @@ export function log (num, base) {
export function roundLog (num, base) {
return Math.ceil(this.log(num, base))
}

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

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

@ -3,7 +3,6 @@ import { solidityLocals } from '../solidity-decoder/localDecoder'
import { StorageViewer } from '../storage/storageViewer'
export class DebuggerSolidityLocals {
event
stepManager
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)
solidityLocals(this.stepManager.currentStepIndex, this.internalTreeCall, stack, memory, storageViewer, sourceLocation, cursor).then((locals) => {
if (!cursor) {
if (!locals['error']) {
if (!locals.error) {
this.event.trigger('solidityLocals', [locals])
}
if (!Object.keys(locals).length) {
this.event.trigger('solidityLocalsMessage', ['no locals'])
}
} else {
if (!locals['error']) {
if (!locals.error) {
this.event.trigger('solidityLocalsLoadMoreCompleted', [locals])
}
}

@ -3,7 +3,6 @@ import { decodeState } from '../solidity-decoder/stateDecoder'
import { StorageViewer } from '../storage/storageViewer'
export class DebuggerSolidityState {
event
storageResolver
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)
decodeState(stateVars, storageViewer).then((result) => {
this.event.trigger('solidityStateMessage', [''])
if (result['error']) {
return this.event.trigger('solidityStateMessage', [result['error']])
if (result.error) {
return this.event.trigger('solidityStateMessage', [result.error])
}
this.event.trigger('solidityState', [result])
})

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

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

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

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

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

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

@ -3,13 +3,13 @@
export async function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory, storageResolver, currentSourceLocation, cursor) {
const scope = internalTreeCall.findScope(vmtraceIndex)
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
}
const locals = {}
memory = formatMemory(memory)
let anonymousIncr = 1
for (let local in scope.locals) {
for (const local in scope.locals) {
var variable = scope.locals[local]
if (variable.stackDepth < stack.length && variable.sourceLocation.start <= currentSourceLocation.start) {
let name = variable.name

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

@ -6,7 +6,6 @@ import { RefType } from './RefType'
const sha3256 = util.sha3_256
export class ArrayType extends RefType {
underlyingType
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 }
}
}

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

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

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

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

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

@ -2,7 +2,6 @@
import { extractHexValue } from './util'
export class ValueType {
storageSlots
storageBytes
typeName
@ -58,7 +57,7 @@ export class ValueType {
* @return {Object} - decoded value
*/
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 }
}
}

@ -78,7 +78,7 @@ export function removeLocation (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] !== '') {
return match[1].trim()
}

@ -2,7 +2,6 @@
import { getLinebreakPositions, convertOffsetToLineColumn } from './sourceMappingDecoder'
export class OffsetToColumnConverter {
lineBreakPositionsByContent
sourceMappingDecoder
@ -17,7 +16,7 @@ export class OffsetToColumnConverter {
offsetToLineColumn (rawLocation, file, sources, asts) {
if (!this.lineBreakPositionsByContent[file]) {
for (let filename in asts) {
for (const filename in asts) {
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
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
*/
export class SourceLocationTracker {
opts
codeManager
event
@ -32,7 +31,7 @@ export class SourceLocationTracker {
*/
async getSourceLocationFromInstructionIndex (address, index, 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) {
const sourceMap = await this.extractSourceMap(this, this.codeManager, address, contracts)
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) {
const isCreation = isContractCreation(address)
let bytes
for (let file in contracts) {
for (let contract in contracts[file]) {
for (const file in contracts) {
for (const contract in contracts[file]) {
const bytecode = contracts[file][contract].evm.bytecode
const deployedBytecode = contracts[file][contract].evm.deployedBytecode
if (!deployedBytecode) continue
@ -110,7 +109,7 @@ export class SourceLocationTracker {
if (!isContractCreation(address)) self.sourceMapByAddress[address] = sourceMap
return resolve(sourceMap)
}
reject('no sourcemap associated with the code ' + address)
reject(new Error('no sourcemap associated with the code ' + address))
}).catch(reject)
})
}

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

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

@ -7,7 +7,6 @@ import { decodeMappingsKeys } from './mappingPreimages'
* (TODO: one instance need to be shared over all the components)
*/
export class StorageResolver {
storageByAddress
preimagesMappingByAddress
maxSize
@ -144,7 +143,7 @@ export class StorageResolver {
} else if (result.storage) {
resolve([result.storage, result.nextKey])
} 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)
*/
export class StorageViewer {
context
storageResolver
web3

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

@ -3,7 +3,6 @@ import { util } from '@remix-project/remix-lib'
const { sha3_256 } = util
export class TraceCache {
returnValues
currentCall
callsTree
@ -20,7 +19,6 @@ export class TraceCache {
this.init()
}
init () {
// ...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
// in the vm/geth/eth. TODO add the error property (with about the error in all clients)
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)) {
this.currentCall.call.return = index - 1
if (!validReturnStep) {
@ -63,7 +61,7 @@ export class TraceCache {
this.currentCall = parent ? { call: parent.call, parent: parent.parent } : null
return
}
let call = {
const call = {
op: step.op,
address: address,
callStack: callStack,
@ -102,10 +100,10 @@ export class TraceCache {
pushStoreChanges (index, address, key, value) {
this.sstore[index] = {
'address': address,
'key': key,
'value': value,
'hashedKey': sha3_256(key)
address: address,
key: key,
value: value,
hashedKey: sha3_256(key)
}
this.storageChanges.push(index)
}

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

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

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

Loading…
Cancel
Save