remix-project mirror
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.
remix-project/libs/remix-lib/src/init.ts

55 lines
1.1 KiB

9 years ago
'use strict'
import Web3 from 'web3'
7 years ago
export function loadWeb3 (url = 'http://localhost:8545') {
const web3 = new Web3()
web3.setProvider(new Web3.providers.HttpProvider(url))
extend(web3)
return web3
}
7 years ago
export function extendWeb3 (web3) {
extend(web3)
}
7 years ago
export function extend (web3) {
4 years ago
if (!web3.extend) {
return
}
// DEBUG
const methods = []
if (!(web3.debug && web3.debug.preimage)) {
methods.push(new web3.extend.Method({
name: 'preimage',
call: 'debug_preimage',
inputFormatter: [null],
params: 1
}))
}
4 years ago
if (!(web3.debug && web3.debug.traceTransaction)) {
methods.push(new web3.extend.Method({
name: 'traceTransaction',
call: 'debug_traceTransaction',
inputFormatter: [null, null],
params: 2
}))
}
4 years ago
if (!(web3.debug && web3.debug.storageRangeAt)) {
methods.push(new web3.extend.Method({
name: 'storageRangeAt',
call: 'debug_storageRangeAt',
inputFormatter: [null, null, null, null, null],
params: 5
}))
9 years ago
}
4 years ago
if (methods.length > 0) {
web3.extend({
property: 'debug',
methods: methods,
properties: []
})
}
}