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

45 lines
1.1 KiB

9 years ago
'use strict'
import Web3, { Web3PluginBase } from 'web3'
7 years ago
export function loadWeb3 (url = 'http://localhost:8545') {
const web3 = new Web3()
web3.setProvider(new Web3.providers.HttpProvider(url))
web3.registerPlugin(new Web3DebugPlugin())
return web3
}
7 years ago
export function extendWeb3 (web3) {
web3.registerPlugin(new Web3DebugPlugin())
}
7 years ago
class Web3DebugPlugin extends Web3PluginBase {
public pluginNamespace = 'debug'
public preimage(key, cb) {
this.requestManager.send({
method: 'debug_preimage',
params: [key]
})
.then(result => cb(null, result))
.catch(error => cb(error))
4 years ago
}
public traceTransaction(txHash, options, cb) {
this.requestManager.send({
method: 'debug_traceTransaction',
params: [txHash, options]
})
.then(result => cb(null, result))
.catch(error => cb(error))
9 years ago
}
public storageRangeAt(txBlockHash, txIndex, address, start, maxSize, cb) {
this.requestManager.send({
method: 'debug_storageRangeAt',
params: [txBlockHash, txIndex, address, start, maxSize]
4 years ago
})
.then(result => cb(null, result))
.catch(error => cb(error))
4 years ago
}
}