You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.3 KiB
61 lines
1.3 KiB
9 years ago
|
'use strict'
|
||
7 years ago
|
var Web3 = require('web3')
|
||
|
|
||
9 years ago
|
module.exports = {
|
||
7 years ago
|
loadWeb3: function () {
|
||
|
var web3 = new Web3()
|
||
|
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'))
|
||
|
this.extend(web3)
|
||
|
return web3
|
||
|
},
|
||
|
|
||
|
extendWeb3: function (web3) {
|
||
|
this.extend(web3)
|
||
|
},
|
||
|
|
||
|
setProvider: function (web3, url) {
|
||
|
web3.setProvider(new web3.providers.HttpProvider(url))
|
||
|
},
|
||
|
|
||
9 years ago
|
extend: function (web3) {
|
||
8 years ago
|
if (!web3._extend) {
|
||
|
return
|
||
|
}
|
||
9 years ago
|
// DEBUG
|
||
9 years ago
|
var methods = []
|
||
8 years ago
|
if (!(web3.debug && web3.debug.preimage)) {
|
||
|
methods.push(new web3._extend.Method({
|
||
|
name: 'preimage',
|
||
|
call: 'debug_preimage',
|
||
|
inputFormatter: [null],
|
||
|
params: 1
|
||
|
}))
|
||
|
}
|
||
|
|
||
9 years ago
|
if (!(web3.debug && web3.debug.traceTransaction)) {
|
||
|
methods.push(new web3._extend.Method({
|
||
|
name: 'traceTransaction',
|
||
|
call: 'debug_traceTransaction',
|
||
|
inputFormatter: [null, null],
|
||
|
params: 2
|
||
|
}))
|
||
|
}
|
||
9 years ago
|
|
||
8 years ago
|
if (!(web3.debug && web3.debug.storageRangeAt)) {
|
||
9 years ago
|
methods.push(new web3._extend.Method({
|
||
8 years ago
|
name: 'storageRangeAt',
|
||
|
call: 'debug_storageRangeAt',
|
||
8 years ago
|
inputFormatter: [null, null, null, null, null],
|
||
|
params: 5
|
||
9 years ago
|
}))
|
||
|
}
|
||
|
if (methods.length > 0) {
|
||
|
web3._extend({
|
||
|
property: 'debug',
|
||
|
methods: methods,
|
||
|
properties: []
|
||
|
})
|
||
|
}
|
||
9 years ago
|
}
|
||
|
}
|