mirror of https://github.com/status-im/web3.js.git
fixed #147
This commit is contained in:
parent
9fc557543a
commit
e750fd9bb4
|
@ -22,9 +22,10 @@
|
||||||
|
|
||||||
var Jsonrpc = function () {
|
var Jsonrpc = function () {
|
||||||
// singleton pattern
|
// singleton pattern
|
||||||
if (arguments.callee._singletonInstance) {
|
if (Jsonrpc.prototype._singletonInstance) {
|
||||||
return arguments.callee._singletonInstance;
|
return Jsonrpc.prototype._singletonInstance;
|
||||||
}
|
}
|
||||||
|
Jsonrpc.prototype._singletonInstance = this;
|
||||||
this.messageId = 1;
|
this.messageId = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,7 +54,7 @@ Jsonrpc.prototype.toPayload = function (method, params) {
|
||||||
method: method,
|
method: method,
|
||||||
params: params || [],
|
params: params || [],
|
||||||
id: this.messageId++
|
id: this.messageId++
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +62,7 @@ Jsonrpc.prototype.toPayload = function (method, params) {
|
||||||
*
|
*
|
||||||
* @method isValidResponse
|
* @method isValidResponse
|
||||||
* @param {Object}
|
* @param {Object}
|
||||||
* @returns {Boolean} true if response is valid, otherwise false
|
* @returns {Boolean} true if response is valid, otherwise false
|
||||||
*/
|
*/
|
||||||
Jsonrpc.prototype.isValidResponse = function (response) {
|
Jsonrpc.prototype.isValidResponse = function (response) {
|
||||||
return !!response &&
|
return !!response &&
|
||||||
|
@ -82,7 +83,7 @@ Jsonrpc.prototype.toBatchPayload = function (messages) {
|
||||||
var self = this;
|
var self = this;
|
||||||
return messages.map(function (message) {
|
return messages.map(function (message) {
|
||||||
return self.toPayload(message.method, message.params);
|
return self.toPayload(message.method, message.params);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Jsonrpc;
|
module.exports = Jsonrpc;
|
||||||
|
|
Loading…
Reference in New Issue