add debug node ref

pull/7/head
yann300 7 years ago
parent 6589de2435
commit 7bef3013e3
  1. 2
      remix-core/src/storage/mappingPreimages.js
  2. 2
      remix-core/src/storage/storageResolver.js
  3. 2
      remix-core/src/trace/traceRetriever.js
  4. 10
      remix-debugger/src/ui/Ethdebugger.js
  5. 3
      remix-lib/src/global.js
  6. 16
      remix-lib/src/init.js

@ -44,7 +44,7 @@ async function decodeMappingsKeys (storage, callback) {
*/ */
function getPreimage (key) { function getPreimage (key) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
global.web3.debug.preimage(key.indexOf('0x') === 0 ? key : '0x' + key, function (error, preimage) { global.web3Debug.debug.preimage(key.indexOf('0x') === 0 ? key : '0x' + key, function (error, preimage) {
if (error) { if (error) {
resolve(null) resolve(null)
} else { } else {

@ -146,7 +146,7 @@ function storageRangeWeb3Call (tx, address, start, maxSize, callback) {
if (traceHelper.isContractCreation(address)) { if (traceHelper.isContractCreation(address)) {
callback(null, {}, null) callback(null, {}, null)
} else { } else {
global.web3.debug.storageRangeAt( global.web3Debug.debug.storageRangeAt(
tx.blockHash, tx.transactionIndex === undefined ? tx.hash : tx.transactionIndex, tx.blockHash, tx.transactionIndex === undefined ? tx.hash : tx.transactionIndex,
address, address,
start, start,

@ -12,7 +12,7 @@ TraceRetriever.prototype.getTrace = function (txHash, callback) {
disableStack: false, disableStack: false,
fullStorage: false fullStorage: false
} }
global.web3.debug.traceTransaction(txHash, options, function (error, result) { global.web3Debug.debug.traceTransaction(txHash, options, function (error, result) {
callback(error, result) callback(error, result)
}) })
} }

@ -6,6 +6,8 @@ var TraceManager = remixCore.trace.TraceManager
var VmDebugger = require('./VmDebugger') var VmDebugger = require('./VmDebugger')
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var global = remixLib.global var global = remixLib.global
var init = remixLib.init
var executionContext = remixLib.execution.executionContext
var EventManager = remixLib.EventManager var EventManager = remixLib.EventManager
var yo = require('yo-yo') var yo = require('yo-yo')
var csjs = require('csjs-inject') var csjs = require('csjs-inject')
@ -97,6 +99,14 @@ Ethdebugger.prototype.switchProvider = function (type) {
console.log('provider ' + type + ' not defined') console.log('provider ' + type + ' not defined')
} else { } else {
global.web3 = obj global.web3 = obj
executionContext.detectNetwork((error, network) => {
if (error || !network) {
global.web3Debug = obj
} else {
var webDebugNode = init.web3DebugNode(network.name)
global.web3Debug = !webDebugNode ? obj : webDebugNode
}
})
self.event.trigger('providerChanged', [type]) self.event.trigger('providerChanged', [type])
} }
}) })

@ -1,3 +1,4 @@
module.exports = { module.exports = {
web3: null web3: null,
web3Debug: null // this node should support the debug endpoint
} }

@ -2,9 +2,10 @@
var Web3 = require('web3') var Web3 = require('web3')
module.exports = { module.exports = {
loadWeb3: function () { loadWeb3: function (url) {
if (!url) url = 'http://localhost:8545'
var web3 = new Web3() var web3 = new Web3()
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545')) web3.setProvider(new web3.providers.HttpProvider(url))
this.extend(web3) this.extend(web3)
return web3 return web3
}, },
@ -17,6 +18,13 @@ module.exports = {
web3.setProvider(new web3.providers.HttpProvider(url)) web3.setProvider(new web3.providers.HttpProvider(url))
}, },
web3DebugNode: function (network) {
if (web3DebugNodes[network]) {
return this.loadWeb3(web3DebugNodes[network])
}
return null
},
extend: function (web3) { extend: function (web3) {
if (!web3._extend) { if (!web3._extend) {
return return
@ -58,3 +66,7 @@ module.exports = {
} }
} }
} }
var web3DebugNodes = {
'Main': 'https://mainnet.infura.io/remix'
}

Loading…
Cancel
Save