parent
a9e1b5b6ac
commit
3e7477d0a8
@ -1,75 +1,74 @@ |
|||||||
'use strict' |
'use strict' |
||||||
import Web3 from 'web3' |
import Web3 from 'web3' |
||||||
|
|
||||||
export = { |
export function loadWeb3 (url) { |
||||||
loadWeb3: function (url) { |
if (!url) url = 'http://localhost:8545' |
||||||
if (!url) url = 'http://localhost:8545' |
const web3 = new Web3() |
||||||
const web3 = new Web3() |
web3.setProvider(new Web3.providers.HttpProvider(url)) |
||||||
web3.setProvider(new Web3.providers.HttpProvider(url)) |
extend(web3) |
||||||
this.extend(web3) |
return web3 |
||||||
return web3 |
} |
||||||
}, |
|
||||||
|
|
||||||
extendWeb3: function (web3) { |
export function extendWeb3 (web3) { |
||||||
this.extend(web3) |
extend(web3) |
||||||
}, |
} |
||||||
|
|
||||||
setProvider: function (web3, url) { |
export function setProvider (web3, url) { |
||||||
web3.setProvider(new web3.providers.HttpProvider(url)) |
web3.setProvider(new web3.providers.HttpProvider(url)) |
||||||
}, |
} |
||||||
|
|
||||||
web3DebugNode: function (network) { |
export function web3DebugNode (network) { |
||||||
const web3DebugNodes = { |
const web3DebugNodes = { |
||||||
'Main': 'https://rpc.archivenode.io/e50zmkroshle2e2e50zm0044i7ao04ym', |
'Main': 'https://rpc.archivenode.io/e50zmkroshle2e2e50zm0044i7ao04ym', |
||||||
'Rinkeby': 'https://remix-rinkeby.ethdevops.io', |
'Rinkeby': 'https://remix-rinkeby.ethdevops.io', |
||||||
'Ropsten': 'https://remix-ropsten.ethdevops.io', |
'Ropsten': 'https://remix-ropsten.ethdevops.io', |
||||||
'Goerli': 'https://remix-goerli.ethdevops.io', |
'Goerli': 'https://remix-goerli.ethdevops.io', |
||||||
'Kovan': 'https://remix-kovan.ethdevops.io' |
'Kovan': 'https://remix-kovan.ethdevops.io' |
||||||
} |
} |
||||||
if (web3DebugNodes[network]) { |
if (web3DebugNodes[network]) { |
||||||
return this.loadWeb3(web3DebugNodes[network]) |
return loadWeb3(web3DebugNodes[network]) |
||||||
} |
} |
||||||
return null |
return null |
||||||
}, |
} |
||||||
|
|
||||||
extend: function (web3) { |
export function extend (web3) { |
||||||
if (!web3.extend) { |
if (!web3.extend) { |
||||||
return |
return |
||||||
} |
} |
||||||
// DEBUG
|
// DEBUG
|
||||||
const methods = [] |
const methods = [] |
||||||
if (!(web3.debug && web3.debug.preimage)) { |
if (!(web3.debug && web3.debug.preimage)) { |
||||||
methods.push(new web3.extend.Method({ |
methods.push(new web3.extend.Method({ |
||||||
name: 'preimage', |
name: 'preimage', |
||||||
call: 'debug_preimage', |
call: 'debug_preimage', |
||||||
inputFormatter: [null], |
inputFormatter: [null], |
||||||
params: 1 |
params: 1 |
||||||
})) |
})) |
||||||
} |
} |
||||||
|
|
||||||
if (!(web3.debug && web3.debug.traceTransaction)) { |
if (!(web3.debug && web3.debug.traceTransaction)) { |
||||||
methods.push(new web3.extend.Method({ |
methods.push(new web3.extend.Method({ |
||||||
name: 'traceTransaction', |
name: 'traceTransaction', |
||||||
call: 'debug_traceTransaction', |
call: 'debug_traceTransaction', |
||||||
inputFormatter: [null, null], |
inputFormatter: [null, null], |
||||||
params: 2 |
params: 2 |
||||||
})) |
})) |
||||||
} |
} |
||||||
|
|
||||||
if (!(web3.debug && web3.debug.storageRangeAt)) { |
if (!(web3.debug && web3.debug.storageRangeAt)) { |
||||||
methods.push(new web3.extend.Method({ |
methods.push(new web3.extend.Method({ |
||||||
name: 'storageRangeAt', |
name: 'storageRangeAt', |
||||||
call: 'debug_storageRangeAt', |
call: 'debug_storageRangeAt', |
||||||
inputFormatter: [null, null, null, null, null], |
inputFormatter: [null, null, null, null, null], |
||||||
params: 5 |
params: 5 |
||||||
})) |
})) |
||||||
} |
} |
||||||
if (methods.length > 0) { |
if (methods.length > 0) { |
||||||
web3.extend({ |
web3.extend({ |
||||||
property: 'debug', |
property: 'debug', |
||||||
methods: methods, |
methods: methods, |
||||||
properties: [] |
properties: [] |
||||||
}) |
}) |
||||||
} |
|
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
|
Loading…
Reference in new issue