add dummy provider

pull/7/head
yann300 8 years ago
parent c49b9c2e8b
commit 472a98edc8
  1. 2
      package.json
  2. 6
      src/ui/Ethdebugger.js
  3. 286
      src/util/web3Admin.js
  4. 46
      src/web3Provider/dummyProvider.js

@ -1,6 +1,6 @@
{
"name": "ethereum-remix",
"version": "0.0.2-alpha.0.0.5",
"version": "0.0.2-alpha.0.0.6",
"description": "Ethereum IDE and tools for the web",
"contributors": [
{

@ -10,7 +10,7 @@ var EventManager = require('../lib/eventManager')
var yo = require('yo-yo')
var ui = require('../helpers/ui')
var Web3Providers = require('../web3Provider/web3Providers')
var init = require('../helpers/init')
var DummyProvider = require('../web3Provider/dummyProvider')
function Ethdebugger () {
util.extend(this, new EventManager())
@ -21,8 +21,8 @@ function Ethdebugger () {
this.view
this.web3Providers = new Web3Providers()
this.addProvider('INTERNAL', init.loadWeb3())
this.switchProvider('INTERNAL')
this.addProvider('DUMMYWEB3', new DummyProvider())
this.switchProvider('DUMMYWEB3')
this.traceManager = new TraceManager()
var self = this

@ -1,269 +1,31 @@
'use strict'
module.exports = {
extend: function (web3) {
// ADMIN
web3._extend({
property: 'admin',
methods: [
new web3._extend.Method({
name: 'addPeer',
call: 'admin_addPeer',
params: 1,
inputFormatter: [web3._extend.utils.fromDecimal],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({
name: 'exportChain',
call: 'admin_exportChain',
params: 1,
inputFormatter: [null],
outputFormatter: function (obj) { return obj }
}),
new web3._extend.Method({
name: 'importChain',
call: 'admin_importChain',
params: 1,
inputFormatter: [null],
outputFormatter: function (obj) { return obj }
}),
new web3._extend.Method({
name: 'verbosity',
call: 'admin_verbosity',
params: 1,
inputFormatter: [web3._extend.utils.formatInputInt],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({
name: 'setSolc',
call: 'admin_setSolc',
params: 1,
inputFormatter: [null],
outputFormatter: web3._extend.formatters.formatOutputString
}),
new web3._extend.Method({
name: 'startRPC',
call: 'admin_startRPC',
params: 4,
inputFormatter: [null, web3._extend.utils.formatInputInteger, null, null],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({
name: 'stopRPC',
call: 'admin_stopRPC',
params: 0,
inputFormatter: [],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({
name: 'vmTrace',
call: 'admin_eth_vmTrace',
inputFormatter: [null, null, null],
params: 3
})
],
properties: [
new web3._extend.Property({
name: 'nodeInfo',
getter: 'admin_nodeInfo',
outputFormatter: web3._extend.formatters.formatOutputString
}),
new web3._extend.Property({
name: 'peers',
getter: 'admin_peers',
outputFormatter: function (obj) { return obj }
}),
new web3._extend.Property({
name: 'datadir',
getter: 'admin_datadir',
outputFormatter: web3._extend.formatters.formatOutputString
}),
new web3._extend.Property({
name: 'chainSyncStatus',
getter: 'admin_chainSyncStatus',
outputFormatter: function (obj) { return obj }
})
]
})
// DEBUG
web3._extend({
property: 'debug',
methods: [
new web3._extend.Method({
name: 'storageAt',
call: 'debug_storageAt',
inputFormatter: [null, null, null],
params: 3
}),
new web3._extend.Method({
name: 'traceTransaction',
call: 'debug_traceTransaction',
inputFormatter: [null, null],
params: 2
}),
new web3._extend.Method({
name: 'printBlock',
call: 'debug_printBlock',
params: 1,
inputFormatter: [web3._extend.formatters.formatInputInt],
outputFormatter: web3._extend.formatters.formatOutputString
}),
new web3._extend.Method({
name: 'getBlockRlp',
call: 'debug_getBlockRlp',
params: 1,
inputFormatter: [web3._extend.formatters.formatInputInt],
outputFormatter: web3._extend.formatters.formatOutputString
}),
new web3._extend.Method({
name: 'setHead',
call: 'debug_setHead',
params: 1,
inputFormatter: [web3._extend.formatters.formatInputInt],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({
name: 'processBlock',
call: 'debug_processBlock',
params: 1,
inputFormatter: [web3._extend.formatters.formatInputInt],
outputFormatter: function (obj) { return obj }
}),
new web3._extend.Method({
name: 'seedHash',
call: 'debug_seedHash',
params: 1,
inputFormatter: [web3._extend.formatters.formatInputInt],
outputFormatter: web3._extend.formatters.formatOutputString
}),
new web3._extend.Method({
name: 'dumpBlock',
call: 'debug_dumpBlock',
params: 1,
inputFormatter: [web3._extend.formatters.formatInputInt],
outputFormatter: function (obj) { return obj }
})
],
properties: []
})
// MINER
web3._extend({
property: 'miner',
methods: [
new web3._extend.Method({
name: 'start',
call: 'miner_start',
params: 1,
inputFormatter: [web3._extend.formatters.formatInputInt],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({
name: 'stop',
call: 'miner_stop',
params: 1,
inputFormatter: [web3._extend.formatters.formatInputInt],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({
name: 'setExtra',
call: 'miner_setExtra',
params: 1,
inputFormatter: [web3._extend.utils.formatInputString],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({
name: 'setGasPrice',
call: 'miner_setGasPrice',
params: 1,
inputFormatter: [web3._extend.utils.formatInputString],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({
name: 'startAutoDAG',
call: 'miner_startAutoDAG',
params: 0,
inputFormatter: [],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({
name: 'stopAutoDAG',
call: 'miner_stopAutoDAG',
params: 0,
inputFormatter: [],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({
name: 'makeDAG',
call: 'miner_makeDAG',
params: 1,
inputFormatter: [web3._extend.formatters.inputDefaultBlockNumberFormatter],
outputFormatter: web3._extend.formatters.formatOutputBool
})
],
properties: [
new web3._extend.Property({
name: 'hashrate',
getter: 'miner_hashrate',
outputFormatter: web3._extend.utils.toDecimal
})
]
})
// NETWORK
web3._extend({
property: 'network',
methods: [
new web3._extend.Method({
name: 'addPeer',
call: 'net_addPeer',
params: 1,
inputFormatter: [web3._extend.utils.formatInputString],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Method({
name: 'getPeerCount',
call: 'net_peerCount',
params: 0,
inputFormatter: [],
outputFormatter: web3._extend.formatters.formatOutputString
})
],
properties: [
new web3._extend.Property({
name: 'listening',
getter: 'net_listening',
outputFormatter: web3._extend.formatters.formatOutputBool
}),
new web3._extend.Property({
name: 'peerCount',
getter: 'net_peerCount',
outputFormatter: web3._extend.utils.toDecimal
}),
new web3._extend.Property({
name: 'peers',
getter: 'net_peers',
outputFormatter: function (obj) { return obj }
}),
new web3._extend.Property({
name: 'version',
getter: 'net_version',
outputFormatter: web3._extend.formatters.formatOutputString
})
]
})
var methods = []
if (!(web3.debug && web3.debug.traceTransaction)) {
methods.push(new web3._extend.Method({
name: 'traceTransaction',
call: 'debug_traceTransaction',
inputFormatter: [null, null],
params: 2
}))
}
// TX POOL
web3._extend({
property: 'txpool',
methods: [],
properties: [
new web3._extend.Property({
name: 'status',
getter: 'txpool_status',
outputFormatter: function (obj) { return obj }
})
]
})
if (!(web3.debug && web3.debug.storageAt)) {
methods.push(new web3._extend.Method({
name: 'storageAt',
call: 'debug_storageAt',
inputFormatter: [null, null, null],
params: 3
}))
}
if (methods.length > 0) {
web3._extend({
property: 'debug',
methods: methods,
properties: []
})
}
}
}

@ -0,0 +1,46 @@
function dummyProvider () {
var self = this
this.eth = {}
this.debug = {}
this.eth.getCode = function (address, cb) { return self.getCode(address, cb) }
this.eth.getTransaction = function (hash, cb) { return self.getTransaction(hash, cb) }
this.eth.getTransactionFromBlock = function (blockNumber, txIndex, cb) { return self.getTransactionFromBlock(blockNumber, txIndex, cb) }
this.eth.getBlockNumber = function (cb) { return self.getBlockNumber(cb) }
this.debug.traceTransaction = function (hash, options, cb) { return self.traceTransaction(hash, options, cb) }
this.debug.storageAt = function (blockNumber, txIndex, address, cb) { return self.storageAt(blockNumber, txIndex, address, cb) }
this.providers = { 'HttpProvider': function (url) {} }
this.currentProvider = {'host': ''}
}
dummyProvider.prototype.getCode = function (address, cb) {
cb(null, '')
}
dummyProvider.prototype.setProvider = function (provider) {}
dummyProvider.prototype.traceTransaction = function (txHash, options, cb) {
if (cb) {
cb(null, {})
}
return {}
}
dummyProvider.prototype.storageAt = function (blockNumber, txIndex, address, cb) { cb(null, {}) }
dummyProvider.prototype.getBlockNumber = function (cb) { cb(null, '') }
dummyProvider.prototype.getTransaction = function (txHash, cb) {
if (cb) {
cb(null, {})
}
return {}
}
dummyProvider.prototype.getTransactionFromBlock = function (blockNumber, txIndex, cb) {
if (cb) {
cb(null, {})
}
return {}
}
module.exports = dummyProvider
Loading…
Cancel
Save