add deprecated warning for deprecated events

This commit is contained in:
Iuri Matias 2017-08-03 20:03:17 -04:00
parent 2dc1941e48
commit f41702634f
2 changed files with 24 additions and 3 deletions

View File

@ -1,11 +1,32 @@
var EventEmitter = require('events');
function warnIfLegacy(eventName) {
const legacyEvents = ['abi-vanila', 'abi', 'abi-contracts-vanila', 'abi-vanila-deployment'];
if (legacyEvents.indexOf(eventName) >= 0) {
console.warn("this event is deprecated and will be removed in future versions: " + eventName);
}
}
const _on = EventEmitter.prototype.on;
const _setHandler = EventEmitter.prototype.setHandler;
EventEmitter.prototype.on = function(requestName, cb) {
warnIfLegacy(requestName);
return _on.call(this, requestName, cb);
};
EventEmitter.prototype.setHandler = function(requestName, cb) {
warnIfLegacy(requestName);
return _setHandler.call(this, requestName, cb);
};
EventEmitter.prototype.request = function(requestName, cb) {
this.emit('request:' + requestName, cb);
warnIfLegacy(requestName);
return this.emit('request:' + requestName, cb);
};
EventEmitter.prototype.setCommandHandler = function(requestName, cb) {
this.on('request:' + requestName, function(_cb) {
return this.on('request:' + requestName, function(_cb) {
cb.call(this, _cb);
});
};

View File

@ -1,7 +1,7 @@
{
"default": {
"versions": {
"web3.js": "1.0.0",
"web3.js": "0.20.0",
"solc": "0.4.11"
},
"deployment": {