diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/jsonrpc.js | 8 | ||||
-rw-r--r-- | lib/providermanager.js | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/jsonrpc.js b/lib/jsonrpc.js index 0036d0abf..63afa3229 100644 --- a/lib/jsonrpc.js +++ b/lib/jsonrpc.js @@ -39,9 +39,13 @@ var toPayload = function (method, params) { }; /// Should be called to check if jsonrpc response is valid -/// @returns true if response doesn't have error field +/// @returns true if response is valid, otherwise false var isValidResponse = function (response) { - return response && !response.error; + return !!response && + !response.error && + response.jsonrpc === '2.0' && + typeof response.id === 'number' && + (!!response.result || typeof response.result === 'boolean'); }; /// Should be called to create batch payload object diff --git a/lib/providermanager.js b/lib/providermanager.js index ce208917d..55f166bcd 100644 --- a/lib/providermanager.js +++ b/lib/providermanager.js @@ -54,6 +54,7 @@ var ProviderManager = function() { var result = results[index]; if (!jsonrpc.isValidResponse(result)) { + console.log(result); return; } @@ -86,7 +87,7 @@ ProviderManager.prototype.send = function(data) { var result = this.provider.send(payload); if (!jsonrpc.isValidResponse(result)) { - console.log(result.error); + console.log(result); return null; } |