mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 11:38:12 +00:00
fixed linting
This commit is contained in:
parent
4aa286c537
commit
abb393b88c
@ -629,8 +629,8 @@ Contract.prototype.once = function(event, options, callback) {
|
||||
* @param {Function} callback
|
||||
* @return {Object} the event subscription
|
||||
*/
|
||||
Contract.prototype.on = function(event, options, callback){
|
||||
var subOptions = this._generateEventOptions.apply(this, [event, options, callback]);
|
||||
Contract.prototype.on = function(){
|
||||
var subOptions = this._generateEventOptions.apply(this, arguments);
|
||||
|
||||
|
||||
// prevent the event "newListener" and "removeListener" from being overwritten
|
||||
@ -664,8 +664,8 @@ Contract.prototype.on = function(event, options, callback){
|
||||
* @param {Function} callback
|
||||
* @return {Object} the promievent
|
||||
*/
|
||||
Contract.prototype.getPastEvents = function(event, options, callback){
|
||||
var subOptions = this._generateEventOptions.apply(this, [event, options, callback]);
|
||||
Contract.prototype.getPastEvents = function(){
|
||||
var subOptions = this._generateEventOptions.apply(this, arguments);
|
||||
|
||||
var getPastLogs = new Method({
|
||||
name: 'getPastLogs',
|
||||
@ -712,6 +712,73 @@ Contract.prototype._createTxObject = function _createTxObject(){
|
||||
return txObject;
|
||||
};
|
||||
|
||||
/**
|
||||
* The callback called when executing a method
|
||||
*
|
||||
* @method _methodReturnCallback
|
||||
* @param {Object} err
|
||||
* @param {Mixed} returnValue
|
||||
*/
|
||||
var _methodReturnCallback = function(defer, callback, type, err, returnValue) {
|
||||
var _this = this;
|
||||
|
||||
if(type === 'call') {
|
||||
returnValue = _this._parent._decodeMethodReturn(_this._method.outputs, returnValue);
|
||||
}
|
||||
|
||||
|
||||
if (err) {
|
||||
return utils._fireError(err, defer.promise, defer.reject, callback);
|
||||
} else {
|
||||
|
||||
if(callback) {
|
||||
callback(null, returnValue);
|
||||
}
|
||||
|
||||
// send immediate returnValue
|
||||
defer.promise.emit('data', returnValue);
|
||||
|
||||
if(type === 'send') {
|
||||
|
||||
// fire "receipt" event and resolve after
|
||||
_this._parent._web3.eth.subscribe('newBlocks', {}, function (err, block, sub) {
|
||||
if(!err) {
|
||||
|
||||
_this._parent._web3.eth.getTransactionReceipt(returnValue, function (err, receipt) {
|
||||
if(!err) {
|
||||
if(receipt) {
|
||||
sub.unsubscribe();
|
||||
|
||||
if(!receipt.outOfGas) {
|
||||
defer.promise.emit('receipt', receipt);
|
||||
defer.resolve(receipt);
|
||||
defer.promise.removeAllListeners();
|
||||
|
||||
} else {
|
||||
return utils._fireError(new Error('Transaction ran out of gas.'), defer.promise, defer.reject);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sub.unsubscribe();
|
||||
return utils._fireError(err, defer.promise, defer.reject);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
sub.unsubscribe();
|
||||
return utils._fireError(err, defer.promise, defer.reject);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
// remove all listeners on the end, as no event will ever fire again
|
||||
defer.resolve(returnValue);
|
||||
defer.promise.removeAllListeners();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes a call, transact or estimateGas on a contract function
|
||||
*
|
||||
@ -752,9 +819,8 @@ Contract.prototype._executeMethod = function _executeMethod(type){
|
||||
delete options.gasLimit;
|
||||
|
||||
// add contract address
|
||||
if(!utils.isAddress(this._parent.address)) {
|
||||
if(!utils.isAddress(this._parent.address))
|
||||
throw new Error('This contract object doesn\'t have address set yet, please set an address first.');
|
||||
}
|
||||
|
||||
if(utils.isAddress(options.from))
|
||||
options.from = options.from.toLowerCase();
|
||||
@ -762,9 +828,8 @@ Contract.prototype._executeMethod = function _executeMethod(type){
|
||||
options.to = this._parent.address.toLowerCase();
|
||||
|
||||
// return error, if no "data" is specified
|
||||
if(!options.data) {
|
||||
if(!options.data)
|
||||
return utils._fireError(new Error('Couldn\'t find a matching contract method, or the number of parameters is wrong.'), defer.promise, defer.reject, callback);
|
||||
}
|
||||
|
||||
// simple return request
|
||||
if(makeRequest) {
|
||||
@ -785,66 +850,7 @@ Contract.prototype._executeMethod = function _executeMethod(type){
|
||||
|
||||
} else {
|
||||
|
||||
// create the callback method
|
||||
var methodReturnCallback = function(err, returnValue) {
|
||||
|
||||
if(type === 'call') {
|
||||
returnValue = _this._parent._decodeMethodReturn(_this._method.outputs, returnValue);
|
||||
}
|
||||
|
||||
|
||||
if (err) {
|
||||
return utils._fireError(err, defer.promise, defer.reject, callback);
|
||||
} else {
|
||||
|
||||
if(callback) {
|
||||
callback(null, returnValue);
|
||||
}
|
||||
|
||||
// send immediate returnValue
|
||||
defer.promise.emit('data', returnValue);
|
||||
|
||||
if(type === 'send') {
|
||||
|
||||
// fire "receipt" event and resolve after
|
||||
_this._parent._web3.eth.subscribe('newBlocks', {}, function (err, block, sub) {
|
||||
if(!err) {
|
||||
|
||||
_this._parent._web3.eth.getTransactionReceipt(returnValue, function (err, receipt) {
|
||||
if(!err) {
|
||||
if(receipt) {
|
||||
sub.unsubscribe();
|
||||
|
||||
if(!receipt.outOfGas) {
|
||||
defer.promise.emit('receipt', receipt);
|
||||
defer.resolve(receipt);
|
||||
defer.promise.removeAllListeners();
|
||||
|
||||
} else {
|
||||
return utils._fireError(new Error('Transaction ran out of gas.'), defer.promise, defer.reject);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sub.unsubscribe();
|
||||
return utils._fireError(err, defer.promise, defer.reject);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
sub.unsubscribe();
|
||||
return utils._fireError(err, defer.promise, defer.reject);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
// remove all listeners on the end, as no event will ever fire again
|
||||
defer.resolve(returnValue);
|
||||
defer.promise.removeAllListeners();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var methodReturnCallback = _methodReturnCallback.bind(_this, defer, callback, type);
|
||||
|
||||
switch (type) {
|
||||
case 'estimate':
|
||||
|
@ -115,9 +115,9 @@ FakeHttpProvider.prototype.injectNotification = function (notification) {
|
||||
}, 100);
|
||||
};
|
||||
|
||||
FakeHttpProvider.prototype.injectResponse = function (response) {
|
||||
this.response = response;
|
||||
};
|
||||
// FakeHttpProvider.prototype.injectResponse = function (response) {
|
||||
// this.response = response;
|
||||
// };
|
||||
|
||||
FakeHttpProvider.prototype.injectResult = function (result) {
|
||||
var response = this.getResponseStub();
|
||||
|
Loading…
x
Reference in New Issue
Block a user