update lib; remove various console logs

pull/5370/head
Iuri Matias 6 years ago
parent b8c7e30dff
commit cff01523d9
  1. 4
      remix-debug/index.js
  2. 4
      remix-debug/package.json
  3. 66
      remix-debug/rdb.js
  4. 2
      remix-debug/src/cmdline/contextManager.js
  5. 2
      remix-debug/src/cmdline/index.js
  6. 10
      remix-debug/src/debugger/VmDebugger.js
  7. 1
      remix-debug/src/solidity-decoder/internalCallTree.js
  8. 65
      remix-debug/test/sol/ballot.sol
  9. 22
      remix-debug/test/sol/simple_storage.sol
  10. 1
      remix-lib/src/code/codeResolver.js

@ -1,6 +1,7 @@
'use strict'
var EthDebugger = require('./src/Ethdebugger')
var TransactionDebugger = require('./src/debugger/debugger')
var CmdLine = require('./src/cmdline')
var StorageViewer = require('./src/storage/storageViewer')
var StorageResolver = require('./src/storage/storageResolver')
@ -32,6 +33,7 @@ module.exports = {
storage: {
StorageViewer: StorageViewer,
StorageResolver: StorageResolver
}
},
CmdLine: CmdLine
}

@ -10,6 +10,10 @@
{
"name": "Liana Husikyan",
"email": "liana@ethdev.com"
},
{
"name": "Iuri Matias",
"email": "iuri.matias@gmail.com"
}
],
"main": "./index.js",

@ -1,7 +1,46 @@
var CmdLine = require('./src/cmdline/index.js')
var compilation = require('./compilation.json')
var solc = require('solc')
var fs = require('fs')
//var filename = 'test/sol/ballot.sol'
var filename = 'test/sol/simple_storage.sol'
//var filename = 'browser/ballot.sol'
var input_json = {
language: 'Solidity',
sources: {
//"test/sol/ballot.sol": {content: fs.readFileSync('test/sol/ballot.sol').toString()}
},
settings: {
optimizer: {
enabled: true,
runs: 200
},
outputSelection: {
'*': {
'': [ 'legacyAST' ],
'*': [ 'abi', 'metadata', 'devdoc', 'userdoc', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates' ]
}
}
}
}
input_json.sources[filename] = {content: fs.readFileSync(filename).toString()}
console.dir(input_json)
console.log("compiling...")
let compilationData = JSON.parse(solc.compileStandardWrapper(JSON.stringify(input_json)))
console.dir(Object.keys(compilationData))
var compilation = {}
compilation.data = compilationData
compilation.source = { sources: input_json.sources }
console.dir(compilation)
console.dir(compilation.data.errors)
var cmd_line = new CmdLine()
cmd_line.connect("http", "http://localhost:8545")
cmd_line.loadCompilationResult(compilation)
@ -14,13 +53,27 @@ var deployContract = function (cb) {
let txNumber = null
let tx = null
let code = compilation.data.contracts['browser/ballot.sol'].Ballot.evm.bytecode.object
let code = compilation.data.contracts[filename].SimpleStorage.evm.bytecode.object
console.dir("deploying...")
console.dir(code)
_web3.eth.sendTransaction({data: "0x" + code, from: _web3.eth.accounts[0], gas: 800000}, cb)
}
deployContract((err, tx) => {
cmd_line.startDebug(tx, "browser/ballot.sol")
})
let _web3 = cmd_line.debugger.debugger.web3
// var tx = "0x8c44e1b6bcb557512184f851502e43160f415e2e12b2b98ba12b96b699b85859"
// var tx = "0xae365458de8c6669eb146ce2ade4c7767c0edddaee98f5c1878c7c5e5510a0de"
// var tx = "0x04aa74287b3c52e2ecab1cb066d22116317155503681870c516c95cdb148fa28"
// var tx = "0x04aa74287b3c52e2ecab1cb066d22116317155503681870c516c95cdb148fa28"
// var tx = "0x28bd66d99bc45b3f8d959126a26b8c97092892e63fc8ed90eb1598ebedf600ef"
// var tx = "0x3a7355c59f95db494872f33890dbabaceae1ca5330db86db49d24a5c29cd829a"
// _web3.eth.getTransactionReceipt(tx, (err, data) => {
// console.dir(err)
// console.dir(data)
deployContract((err, tx) => {
cmd_line.startDebug(tx, filename)
})
//})
const repl = require('repl')
@ -57,3 +110,6 @@ const r = repl.start({
}
});
module.exports = cmd_line

@ -37,7 +37,7 @@ class ContextManager {
var self = this
this.web3Providers.get(type, function (error, obj) {
if (error) {
console.log('provider ' + type + ' not defined')
// console.log('provider ' + type + ' not defined')
} else {
self.web3 = obj
self.executionContext.detectNetwork((error, network) => {

@ -44,7 +44,7 @@ class CmdLine {
self.debugger.event.register('newSourceLocation', function (lineColumnPos, rawLocation) {
if (!lineColumnPos || !lineColumnPos.start) return;
let content = self.compilation.lastCompilationResult.source.sources['browser/ballot.sol'].content.split("\n")
let content = self.compilation.lastCompilationResult.source.sources[filename].content.split("\n")
let line
line = content[lineColumnPos.start.line - 2]

@ -64,7 +64,7 @@ class VmDebuggerLogic {
self._traceManager.getCallDataAt(index, function (error, calldata) {
if (error) {
console.log(error)
// console.log(error)
self.event.trigger('traceManagerCallDataUpdate', [{}])
} else if (self.stepManager.currentStepIndex === index) {
self.event.trigger('traceManagerCallDataUpdate', [calldata])
@ -73,7 +73,7 @@ class VmDebuggerLogic {
self._traceManager.getMemoryAt(index, function (error, memory) {
if (error) {
console.log(error)
// console.log(error)
self.event.trigger('traceManagerMemoryUpdate', [{}])
} else if (self.stepManager.currentStepIndex === index) {
self.event.trigger('traceManagerMemoryUpdate', [ui.formatMemory(memory, 16)])
@ -82,7 +82,7 @@ class VmDebuggerLogic {
self._traceManager.getCallStackAt(index, function (error, callstack) {
if (error) {
console.log(error)
// console.log(error)
self.event.trigger('traceManagerCallStackUpdate', [{}])
} else if (self.stepManager.currentStepIndex === index) {
self.event.trigger('traceManagerCallStackUpdate', [callstack])
@ -91,7 +91,7 @@ class VmDebuggerLogic {
self._traceManager.getStackAt(index, function (error, callstack) {
if (error) {
console.log(error)
// console.log(error)
self.event.trigger('traceManagerStackUpdate', [{}])
} else if (self.stepManager.currentStepIndex === index) {
self.event.trigger('traceManagerStackUpdate', [callstack])
@ -106,7 +106,7 @@ class VmDebuggerLogic {
storageViewer.storageRange((error, storage) => {
if (error) {
console.log(error)
// console.log(error)
self.event.trigger('traceManagerStorageUpdate', [{}])
} else if (self.stepManager.currentStepIndex === index) {
var header = storageViewer.isComplete(address) ? 'completely loaded' : 'partially loaded...'

@ -38,7 +38,6 @@ class InternalCallTree {
if (result.error) {
this.event.trigger('callTreeBuildFailed', [result.error])
} else {
console.log('ready')
createReducedTrace(this, traceManager.trace.length - 1)
this.event.trigger('callTreeReady', [this.scopes, this.scopeStarts])
}

@ -0,0 +1,65 @@
pragma solidity ^0.4.0;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
}
struct Proposal {
uint voteCount;
}
address chairperson;
mapping(address => Voter) voters;
Proposal[] proposals;
/// Create a new ballot with $(_numProposals) different proposals.
function Ballot(uint8 _numProposals) public {
chairperson = msg.sender;
voters[chairperson].weight = 1;
proposals.length = _numProposals;
}
/// Give $(toVoter) the right to vote on this ballot.
/// May only be called by $(chairperson).
function giveRightToVote(address toVoter) public {
if (msg.sender != chairperson || voters[toVoter].voted) return;
voters[toVoter].weight = 1;
}
/// Delegate your vote to the voter $(to).
function delegate(address to) public {
Voter storage sender = voters[msg.sender]; // assigns reference
if (sender.voted) return;
while (voters[to].delegate != address(0) && voters[to].delegate != msg.sender)
to = voters[to].delegate;
if (to == msg.sender) return;
sender.voted = true;
sender.delegate = to;
Voter storage delegateTo = voters[to];
if (delegateTo.voted)
proposals[delegateTo.vote].voteCount += sender.weight;
else
delegateTo.weight += sender.weight;
}
/// Give a single vote to proposal $(toProposal).
function vote(uint8 toProposal) public {
Voter storage sender = voters[msg.sender];
if (sender.voted || toProposal >= proposals.length) return;
sender.voted = true;
sender.vote = toProposal;
proposals[toProposal].voteCount += sender.weight;
}
function winningProposal() public constant returns (uint8 _winningProposal) {
uint256 winningVoteCount = 0;
for (uint8 prop = 0; prop < proposals.length; prop++)
if (proposals[prop].voteCount > winningVoteCount) {
winningVoteCount = proposals[prop].voteCount;
_winningProposal = prop;
}
}
}

@ -0,0 +1,22 @@
pragma solidity ^0.4.25;
contract SimpleStorage {
uint public storedData;
address owner;
constructor(uint initialValue) public {
storedData = initialValue;
owner = msg.sender;
}
function set(uint x) public {
storedData = x;
require(msg.sender != owner);
storedData = x + 2;
}
function get() public view returns (uint retVal) {
return storedData;
}
}

@ -29,7 +29,6 @@ CodeResolver.prototype.resolveCode = function (address, callBack) {
}
CodeResolver.prototype.loadCode = function (address, callback) {
console.log('loading new code from web3 ' + address)
this.web3.eth.getCode(address, function (error, result) {
if (error) {
console.log(error)

Loading…
Cancel
Save