diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/filter.js | 2 | ||||
-rw-r--r-- | lib/httpsync.js | 29 | ||||
-rw-r--r-- | lib/providermanager.js | 16 | ||||
-rw-r--r-- | lib/web3.js | 10 |
4 files changed, 15 insertions, 42 deletions
diff --git a/lib/filter.js b/lib/filter.js index 8f7729379..6ab2b7edc 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -56,7 +56,7 @@ var Filter = function(options, impl) { this.callbacks = []; this.id = impl.newFilter(options); - web3.provider.startPolling({call: impl.changed, args: [this.id]}, this.id, this.trigger.bind(this)); + web3.provider.startPolling({method: impl.changed, params: [this.id]}, this.id, this.trigger.bind(this)); }; /// alias for changed* diff --git a/lib/httpsync.js b/lib/httpsync.js index a638cfe94..478779c4b 100644 --- a/lib/httpsync.js +++ b/lib/httpsync.js @@ -30,37 +30,12 @@ var HttpSyncProvider = function (host) { this.host = host || 'http://localhost:8080'; }; -/// Transforms inner message to proper jsonrpc object -/// @param inner message object -/// @returns jsonrpc object -function formatJsonRpcObject(object) { - return { - jsonrpc: '2.0', - method: object.call, - params: object.args, - id: object._id - }; -} - -/// Transforms jsonrpc object to inner message -/// @param incoming jsonrpc message -/// @returns inner message object -function formatJsonRpcMessage(message) { - var object = JSON.parse(message); - - return { - _id: object.id, - data: object.result, - error: object.error - }; -} - HttpSyncProvider.prototype.send = function (payload) { - var data = formatJsonRpcObject(payload); + //var data = formatJsonRpcObject(payload); var request = new XMLHttpRequest(); request.open('POST', this.host, false); - request.send(JSON.stringify(data)); + request.send(JSON.stringify(payload)); // check request.status return request.responseText; diff --git a/lib/providermanager.js b/lib/providermanager.js index 25cd14288..38c0f6c46 100644 --- a/lib/providermanager.js +++ b/lib/providermanager.js @@ -43,18 +43,14 @@ var ProviderManager = function() { var poll = function () { if (self.provider) { self.polls.forEach(function (data) { - data.data._id = self.id; - self.id++; - var result = self.provider.send(data.data); + var result = self.send(data.data); - result = JSON.parse(result); - // dont call the callback if result is not an array, or empty one - if (result.error || !(result.result instanceof Array) || result.result.length === 0) { + if (!(result instanceof Array) || result.length === 0) { return; } - data.callback(result.result); + data.callback(result); }); } setTimeout(poll, 1000); @@ -63,10 +59,12 @@ var ProviderManager = function() { }; /// sends outgoing requests +/// @params data - an object with at least 'method' property ProviderManager.prototype.send = function(data) { - data.args = data.args || []; - data._id = this.id++; + data.jsonrpc = '2.0'; + data.params = data.params || []; + data.id = this.id++; if (this.provider === undefined) { console.error('provider is not set'); diff --git a/lib/web3.js b/lib/web3.js index e868e9412..41df75051 100644 --- a/lib/web3.js +++ b/lib/web3.js @@ -136,8 +136,8 @@ var setupMethods = function (obj, methods) { var args = Array.prototype.slice.call(arguments); var call = typeof method.call === 'function' ? method.call(args) : method.call; return web3.provider.send({ - call: call, - args: args + method: call, + params: args }); }; }); @@ -150,15 +150,15 @@ var setupProperties = function (obj, properties) { var proto = {}; proto.get = function () { return web3.provider.send({ - call: property.getter + method: property.getter }); }; if (property.setter) { proto.set = function (val) { return web3.provider.send({ - call: property.setter, - args: [val] + method: property.setter, + params: [val] }); }; } |