Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

update syntax to use const, let and this #1363

Merged
merged 4 commits into from
Dec 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion remix-analyzer/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var CodeAnalysis = require('./src/solidity-analyzer')
const CodeAnalysis = require('./src/solidity-analyzer')

module.exports = {
CodeAnalysis: CodeAnalysis
Expand Down
23 changes: 11 additions & 12 deletions remix-analyzer/src/solidity-analyzer/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
'use strict'
var AstWalker = require('remix-lib').AstWalker
var list = require('./modules/list')
const AstWalker = require('remix-lib').AstWalker
const list = require('./modules/list')

function staticAnalysisRunner () {
}

staticAnalysisRunner.prototype.run = function (compilationResult, toRun, callback) {
var self = this
var modules = toRun.map(function (i) {
var m = self.modules()[i]
const modules = toRun.map((i) => {
const m = this.modules()[i]
return { 'name': m.name, 'mod': new m.Module() }
})

this.runWithModuleList(compilationResult, modules, callback)
}

staticAnalysisRunner.prototype.runWithModuleList = function (compilationResult, modules, callback) {
var reports = []
let reports = []
// Also provide convenience analysis via the AST walker.
var walker = new AstWalker()
for (var k in compilationResult.sources) {
walker.walk(compilationResult.sources[k].legacyAST, {'*': function (node) {
modules.map(function (item, i) {
const walker = new AstWalker()
for (let k in compilationResult.sources) {
walker.walk(compilationResult.sources[k].legacyAST, {'*': (node) => {
modules.map((item, i) => {
if (item.mod.visit !== undefined) {
try {
item.mod.visit(node)
Expand All @@ -38,8 +37,8 @@ staticAnalysisRunner.prototype.runWithModuleList = function (compilationResult,

// Here, modules can just collect the results from the AST walk,
// but also perform new analysis.
reports = reports.concat(modules.map(function (item, i) {
var report = null
reports = reports.concat(modules.map((item, i) => {
let report = null
try {
report = item.mod.report(compilationResult)
} catch (e) {
Expand Down
20 changes: 10 additions & 10 deletions remix-debug/bin/rdb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ program
.option('--node [url]', 'node to connect to')
.parse(process.argv)

var CmdLine = require('../src/cmdline/index.js')
const CmdLine = require('../src/cmdline/index.js')

var solc = require('solc')
var fs = require('fs')
const solc = require('solc')
const fs = require('fs')

var filename = 'test/sol/simple_storage.sol'
var shortFilename = 'simple_storage.sol'
const filename = 'test/sol/simple_storage.sol'
const shortFilename = 'simple_storage.sol'

var inputJson = {
const inputJson = {
language: 'Solidity',
sources: {
},
Expand All @@ -55,17 +55,17 @@ inputJson.sources[shortFilename] = {content: fs.readFileSync(filename).toString(

console.log('compiling...')

let compilationData = JSON.parse(solc.compileStandardWrapper(JSON.stringify(inputJson)))
var compilation = {}
const compilationData = JSON.parse(solc.compileStandardWrapper(JSON.stringify(inputJson)))
const compilation = {}
compilation.data = compilationData
compilation.source = { sources: inputJson.sources }

var cmdLine = new CmdLine()
const cmdLine = new CmdLine()
cmdLine.connect('http', 'http://localhost:8545')
cmdLine.loadCompilationResult(compilation)
cmdLine.initDebugger()

var tx = '0xf510c4f0b1d9ee262d7b9e9e87b4262f275fe029c2c733feef7dfa1e2b1e32aa'
const tx = '0xf510c4f0b1d9ee262d7b9e9e87b4262f275fe029c2c733feef7dfa1e2b1e32aa'

cmdLine.startDebug(tx, shortFilename)

Expand Down
16 changes: 8 additions & 8 deletions remix-debug/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict'
var EthDebugger = require('./src/Ethdebugger')
var TransactionDebugger = require('./src/debugger/debugger')
var CmdLine = require('./src/cmdline')
const EthDebugger = require('./src/Ethdebugger')
const TransactionDebugger = require('./src/debugger/debugger')
const CmdLine = require('./src/cmdline')

var StorageViewer = require('./src/storage/storageViewer')
var StorageResolver = require('./src/storage/storageResolver')
const StorageViewer = require('./src/storage/storageViewer')
const StorageResolver = require('./src/storage/storageResolver')

var SolidityDecoder = require('./src/solidity-decoder')
const SolidityDecoder = require('./src/solidity-decoder')

var remixLib = require('remix-lib')
var BreakpointManager = remixLib.code.BreakpointManager
const remixLib = require('remix-lib')
const BreakpointManager = remixLib.code.BreakpointManager

/*
Use of breakPointManager :
Expand Down
49 changes: 24 additions & 25 deletions remix-debug/src/Ethdebugger.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
'use strict'

var StorageViewer = require('./storage/storageViewer')
var StorageResolver = require('./storage/storageResolver')
const StorageViewer = require('./storage/storageViewer')
const StorageResolver = require('./storage/storageResolver')

var SolidityDecoder = require('./solidity-decoder')
var SolidityProxy = SolidityDecoder.SolidityProxy
var stateDecoder = SolidityDecoder.stateDecoder
var localDecoder = SolidityDecoder.localDecoder
var InternalCallTree = SolidityDecoder.InternalCallTree
const SolidityDecoder = require('./solidity-decoder')
const SolidityProxy = SolidityDecoder.SolidityProxy
const stateDecoder = SolidityDecoder.stateDecoder
const localDecoder = SolidityDecoder.localDecoder
const InternalCallTree = SolidityDecoder.InternalCallTree

var remixLib = require('remix-lib')
var TraceManager = remixLib.trace.TraceManager
var CodeManager = remixLib.code.CodeManager
var traceHelper = remixLib.helpers.trace
var EventManager = remixLib.EventManager
const remixLib = require('remix-lib')
const TraceManager = remixLib.trace.TraceManager
const CodeManager = remixLib.code.CodeManager
const traceHelper = remixLib.helpers.trace
const EventManager = remixLib.EventManager

/**
* Ethdebugger is a wrapper around a few classes that helps debugging a transaction
Expand Down Expand Up @@ -75,7 +75,7 @@ Ethdebugger.prototype.sourceLocationFromVMTraceIndex = function (address, stepIn
}

Ethdebugger.prototype.sourceLocationFromInstructionIndex = function (address, instIndex, callback) {
this.callTree.sourceLocationTracker.getSourceLocationFromInstructionIndex(address, instIndex, this.solidityProxy.contracts, function (error, rawLocation) {
this.callTree.sourceLocationTracker.getSourceLocationFromInstructionIndex(address, instIndex, this.solidityProxy.contracts, (error, rawLocation) => {
callback(error, rawLocation)
})
}
Expand All @@ -98,10 +98,10 @@ Ethdebugger.prototype.decodeLocalsAt = function (step, sourceLocation, callback)
step,
(error, result) => {
if (!error) {
var stack = result[0].value
var memory = result[1].value
const stack = result[0].value
const memory = result[1].value
try {
var storageViewer = new StorageViewer({
const storageViewer = new StorageViewer({
stepIndex: step,
tx: this.tx,
address: result[2].value
Expand All @@ -124,15 +124,15 @@ Ethdebugger.prototype.decodeLocalsAt = function (step, sourceLocation, callback)

/* decode state */
Ethdebugger.prototype.extractStateAt = function (step, callback) {
this.solidityProxy.extractStateVariablesAt(step, function (error, stateVars) {
this.solidityProxy.extractStateVariablesAt(step, (error, stateVars) => {
callback(error, stateVars)
})
}

Ethdebugger.prototype.decodeStateAt = function (step, stateVars, callback) {
this.traceManager.getCurrentCalledAddressAt(step, (error, address) => {
if (error) return callback(error)
var storageViewer = new StorageViewer({
const storageViewer = new StorageViewer({
stepIndex: step,
tx: this.tx,
address: address
Expand Down Expand Up @@ -175,16 +175,15 @@ Ethdebugger.prototype.debug = function (tx) {
}
this.setCompilationResult(this.opts.compilationResult())
this.tx = tx
var self = this
this.traceManager.resolveTrace(tx, function (error, result) {
this.traceManager.resolveTrace(tx, (error, result) => {
if (result) {
self.event.trigger('newTraceLoaded', [self.traceManager.trace])
if (self.breakpointManager && self.breakpointManager.hasBreakpoint()) {
self.breakpointManager.jumpNextBreakpoint(false)
this.event.trigger('newTraceLoaded', [this.traceManager.trace])
if (this.breakpointManager && this.breakpointManager.hasBreakpoint()) {
this.breakpointManager.jumpNextBreakpoint(false)
}
self.storageResolver = new StorageResolver({web3: self.traceManager.web3})
this.storageResolver = new StorageResolver({web3: this.traceManager.web3})
} else {
self.statusMessage = error ? error.message : 'Trace not loaded'
this.statusMessage = error ? error.message : 'Trace not loaded'
}
})
}
Expand Down
25 changes: 12 additions & 13 deletions remix-debug/src/cmdline/contextManager.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var remixLib = require('remix-lib')
const remixLib = require('remix-lib')

var EventManager = remixLib.EventManager
var Web3Providers = remixLib.vm.Web3Providers
var DummyProvider = remixLib.vm.DummyProvider
var init = remixLib.init
const EventManager = remixLib.EventManager
const Web3Providers = remixLib.vm.Web3Providers
const DummyProvider = remixLib.vm.DummyProvider
const init = remixLib.init

class ContextManager {
constructor (executionContext) {
Expand Down Expand Up @@ -33,23 +33,22 @@ class ContextManager {
}

switchProvider (type, cb) {
var self = this
this.web3Providers.get(type, function (error, obj) {
this.web3Providers.get(type, (error, obj) => {
if (error) {
// console.log('provider ' + type + ' not defined')
} else {
self.web3 = obj
self.executionContext.detectNetwork((error, network) => {
this.web3 = obj
this.executionContext.detectNetwork((error, network) => {
if (error || !network) {
self.web3 = obj
this.web3 = obj
} else {
var webDebugNode = init.web3DebugNode(network.name)
self.web3 = (!webDebugNode ? obj : webDebugNode)
this.web3 = (!webDebugNode ? obj : webDebugNode)
}
self.event.trigger('providerChanged', [type, self.web3])
this.event.trigger('providerChanged', [type, this.web3])
if (cb) return cb()
})
self.event.trigger('providerChanged', [type, self.web3])
this.event.trigger('providerChanged', [type, this.web3])
}
})
}
Expand Down
Loading