Commit 7a8b0463 authored by aniket-engg's avatar aniket-engg Committed by Aniket

src updated

parent 80b87ef2
This diff is collapsed.
'use strict' 'use strict'
function eventManager () { export class eventManager {
this.registered = {}
this.anonymous = {}
}
/* registered
* Unregister a listener. anonymous
* Note that if obj is a function. the unregistration will be applied to the dummy obj {}.
* constructor() {
* @param {String} eventName - the event name this.registered = {}
* @param {Object or Func} obj - object that will listen on this event this.anonymous = {}
* @param {Func} func - function of the listeners that will be executed
*/
eventManager.prototype.unregister = function (eventName, obj, func) {
if (!this.registered[eventName]) {
return
}
if (obj instanceof Function) {
func = obj
obj = this.anonymous
} }
for (let reg in this.registered[eventName]) {
if (this.registered[eventName][reg].obj === obj && this.registered[eventName][reg].func === func) { /*
this.registered[eventName].splice(reg, 1) * Unregister a listener.
* Note that if obj is a function. the unregistration will be applied to the dummy obj {}.
*
* @param {String} eventName - the event name
* @param {Object or Func} obj - object that will listen on this event
* @param {Func} func - function of the listeners that will be executed
*/
unregister (eventName, obj, func) {
if (!this.registered[eventName]) {
return
}
if (obj instanceof Function) {
func = obj
obj = this.anonymous
}
for (let reg in this.registered[eventName]) {
if (this.registered[eventName][reg].obj === obj && this.registered[eventName][reg].func === func) {
this.registered[eventName].splice(reg, 1)
}
} }
} }
}
/* /*
* Register a new listener. * Register a new listener.
* Note that if obj is a function, the function registration will be associated with the dummy object {} * Note that if obj is a function, the function registration will be associated with the dummy object {}
* *
* @param {String} eventName - the event name * @param {String} eventName - the event name
* @param {Object or Func} obj - object that will listen on this event * @param {Object or Func} obj - object that will listen on this event
* @param {Func} func - function of the listeners that will be executed * @param {Func} func - function of the listeners that will be executed
*/ */
eventManager.prototype.register = function (eventName, obj, func) { register (eventName, obj, func) {
if (!this.registered[eventName]) { if (!this.registered[eventName]) {
this.registered[eventName] = [] this.registered[eventName] = []
} }
if (obj instanceof Function) { if (obj instanceof Function) {
func = obj func = obj
obj = this.anonymous obj = this.anonymous
}
this.registered[eventName].push({
obj: obj,
func: func
})
} }
this.registered[eventName].push({
obj: obj,
func: func
})
}
/* /*
* trigger event. * trigger event.
* Every listener have their associated function executed * Every listener have their associated function executed
* *
* @param {String} eventName - the event name * @param {String} eventName - the event name
* @param {Array}j - argument that will be passed to the executed function. * @param {Array}j - argument that will be passed to the executed function.
*/ */
eventManager.prototype.trigger = function (eventName, args) { trigger (eventName, args) {
if (!this.registered[eventName]) { if (!this.registered[eventName]) {
return return
} }
for (let listener in this.registered[eventName]) { for (let listener in this.registered[eventName]) {
const l = this.registered[eventName][listener] const l = this.registered[eventName][listener]
l.func.apply(l.obj === this.anonymous ? {} : l.obj, args) l.func.apply(l.obj === this.anonymous ? {} : l.obj, args)
}
} }
} }
module.exports = eventManager
\ No newline at end of file
...@@ -23,23 +23,23 @@ const traceHelper = require('./src/trace/traceHelper') ...@@ -23,23 +23,23 @@ const traceHelper = require('./src/trace/traceHelper')
}) })
this.debugger.setBreakpointManager(breakPointManager) this.debugger.setBreakpointManager(breakPointManager)
*/ */
module.exports = { export = {
init, init,
traceHelper, traceHelper,
SourceMappingDecoder, SourceMappingDecoder,
EthDebugger: EthDebugger, EthDebugger,
TransactionDebugger: TransactionDebugger, TransactionDebugger,
/** /**
* constructor * constructor
* *
* @param {Object} _debugger - type of EthDebugger * @param {Object} _debugger - type of EthDebugger
* @return {Function} _locationToRowConverter - function implemented by editor which return a column/line position for a char source location * @return {Function} _locationToRowConverter - function implemented by editor which return a column/line position for a char source location
*/ */
BreakpointManager: BreakpointManager, BreakpointManager,
SolidityDecoder: SolidityDecoder, SolidityDecoder,
storage: { storage: {
StorageViewer: StorageViewer, StorageViewer: StorageViewer,
StorageResolver: StorageResolver StorageResolver: StorageResolver
}, },
CmdLine: CmdLine CmdLine
} }
'use strict' 'use strict'
const Web3 = require('web3') const Web3 = require('web3')
module.exports = { export = {
loadWeb3: function (url) { loadWeb3: function (url) {
if (!url) url = 'http://localhost:8545' if (!url) url = 'http://localhost:8545'
const web3 = new Web3() const web3 = new Web3()
...@@ -19,6 +19,13 @@ module.exports = { ...@@ -19,6 +19,13 @@ module.exports = {
}, },
web3DebugNode: function (network) { web3DebugNode: function (network) {
const web3DebugNodes = {
'Main': 'https://rpc.archivenode.io/e50zmkroshle2e2e50zm0044i7ao04ym',
'Rinkeby': 'https://remix-rinkeby.ethdevops.io',
'Ropsten': 'https://remix-ropsten.ethdevops.io',
'Goerli': 'https://remix-goerli.ethdevops.io',
'Kovan': 'https://remix-kovan.ethdevops.io'
}
if (web3DebugNodes[network]) { if (web3DebugNodes[network]) {
return this.loadWeb3(web3DebugNodes[network]) return this.loadWeb3(web3DebugNodes[network])
} }
...@@ -66,11 +73,3 @@ module.exports = { ...@@ -66,11 +73,3 @@ module.exports = {
} }
} }
} }
const web3DebugNodes = {
'Main': 'https://rpc.archivenode.io/e50zmkroshle2e2e50zm0044i7ao04ym',
'Rinkeby': 'https://remix-rinkeby.ethdevops.io',
'Ropsten': 'https://remix-ropsten.ethdevops.io',
'Goerli': 'https://remix-goerli.ethdevops.io',
'Kovan': 'https://remix-kovan.ethdevops.io'
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment