Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
RequestManager.prototype.send = function (data, callback) {
callback = callback || function(){};
if (!this.provider) {
return callback(errors.InvalidProvider());
}
var payload = Jsonrpc.toPayload(data.method, data.params);
this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](payload, function (err, result) {
if(result && result.id && payload.id !== result.id) return callback(new Error('Wrong response id "'+ result.id +'" (expected: "'+ payload.id +'") in '+ JSON.stringify(payload)));
if (err) {
return callback(err);
}
if (result && result.error) {
return callback(errors.ErrorResponse(result));
}
if (!Jsonrpc.isValidResponse(result)) {
return callback(errors.InvalidResponse(result));
RequestManager.prototype.sendBatch = function (data, callback) {
if (!this.provider) {
return callback(errors.InvalidProvider());
}
var payload = Jsonrpc.toBatchPayload(data);
this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](payload, function (err, results) {
if (err) {
return callback(err);
}
if (!_.isArray(results)) {
return callback(errors.InvalidResponse(results));
}
callback(null, results);
});
};
RequestManager.prototype.sendBatch = function (data, callback) {
if (!this.provider) {
return callback(errors.InvalidProvider());
}
var payload = Jsonrpc.toBatchPayload(data);
this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](payload, function (err, results) {
if (err) {
return callback(err);
}
if (!_.isArray(results)) {
return callback(errors.InvalidResponse(results));
}
callback(null, results);
});
};
RequestManager.prototype.send = function (data, callback) {
callback = callback || function(){};
if (!this.provider) {
return callback(errors.InvalidProvider());
}
var payload = Jsonrpc.toPayload(data.method, data.params);
this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](payload, function (err, result) {
if(result && result.id && payload.id !== result.id) return callback(new Error('Wrong response id "'+ result.id +'" (expected: "'+ payload.id +'") in '+ JSON.stringify(payload)));
if (err) {
return callback(err);
}
if (result && result.error) {
return callback(errors.ErrorResponse(result));
}
if (!Jsonrpc.isValidResponse(result)) {
return callback(errors.InvalidResponse(result));
RequestManager.prototype.send = function (data, callback) {
callback = callback || function(){};
if (!this.provider) {
return callback(errors.InvalidProvider());
}
var payload = Jsonrpc.toPayload(data.method, data.params);
this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](payload, function (err, result) {
if(result && result.id && payload.id !== result.id) return callback(new Error('Wrong response id "'+ result.id +'" (expected: "'+ payload.id +'") in '+ JSON.stringify(payload)));
if (err) {
return callback(err);
}
if (result && result.error) {
return callback(errors.ErrorResponse(result));
}
if (!Jsonrpc.isValidResponse(result)) {
return callback(errors.InvalidResponse(result));
RequestManager.prototype.sendBatch = function (data, callback) {
if (!this.provider) {
return callback(errors.InvalidProvider());
}
var payload = Jsonrpc.toBatchPayload(data);
this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](payload, function (err, results) {
if (err) {
return callback(err);
}
if (!_.isArray(results)) {
return callback(errors.InvalidResponse(results));
}
callback(null, results);
});
};