From c8307a9e4483f1ed90a97e9c4c8925c11416a2c4 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Fri, 31 Oct 2014 14:12:05 +0100 Subject: license --- httprpc.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'httprpc.js') diff --git a/httprpc.js b/httprpc.js index 085b4693d..f30c5ef67 100644 --- a/httprpc.js +++ b/httprpc.js @@ -1,3 +1,25 @@ +/* + This file is part of ethereum.js. + + ethereum.js is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + ethereum.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with ethereum.js. If not, see . +*/ +/** @file ethereum.js + * @authors: + * Marek Kotewicz + * @date 2014 + */ + (function () { var HttpRpcProvider = function (host) { this.handlers = []; -- cgit v1.2.3 From b0e11826e5f5e73f37304365fbaf504ed53d7886 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Mon, 3 Nov 2014 12:40:57 +0100 Subject: lgpl --- httprpc.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'httprpc.js') diff --git a/httprpc.js b/httprpc.js index f30c5ef67..ef29133e8 100644 --- a/httprpc.js +++ b/httprpc.js @@ -2,19 +2,19 @@ This file is part of ethereum.js. ethereum.js is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by + it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ethereum.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with ethereum.js. If not, see . */ -/** @file ethereum.js +/** @file httprpc.js * @authors: * Marek Kotewicz * @date 2014 -- cgit v1.2.3 From 4be4db5e6cfdde4ba5c1243b2bafeb6bbae3643c Mon Sep 17 00:00:00 2001 From: Marian Oancea Date: Wed, 5 Nov 2014 19:46:01 +0200 Subject: Converted to node module Converted to npm package Added brower Added browserify with minification Updated Readme --- httprpc.js | 92 -------------------------------------------------------------- 1 file changed, 92 deletions(-) delete mode 100644 httprpc.js (limited to 'httprpc.js') diff --git a/httprpc.js b/httprpc.js deleted file mode 100644 index ef29133e8..000000000 --- a/httprpc.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - This file is part of ethereum.js. - - ethereum.js is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - ethereum.js is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with ethereum.js. If not, see . -*/ -/** @file httprpc.js - * @authors: - * Marek Kotewicz - * @date 2014 - */ - -(function () { - var HttpRpcProvider = function (host) { - this.handlers = []; - this.host = host; - }; - - function formatJsonRpcObject(object) { - return { - jsonrpc: '2.0', - method: object.call, - params: object.args, - id: object._id - } - }; - - function formatJsonRpcMessage(message) { - var object = JSON.parse(message); - - return { - _id: object.id, - data: object.result - }; - }; - - HttpRpcProvider.prototype.sendRequest = function (payload, cb) { - var data = formatJsonRpcObject(payload); - - var request = new XMLHttpRequest(); - request.open("POST", this.host, true); - request.send(JSON.stringify(data)); - request.onreadystatechange = function () { - if (request.readyState === 4 && cb) { - cb(request); - } - } - }; - - HttpRpcProvider.prototype.send = function (payload) { - var self = this; - this.sendRequest(payload, function (request) { - self.handlers.forEach(function (handler) { - handler.call(self, formatJsonRpcMessage(request.responseText)); - }); - }); - }; - - HttpRpcProvider.prototype.poll = function (payload, id) { - var self = this; - this.sendRequest(payload, function (request) { - var parsed = JSON.parse(request.responseText); - if (parsed.result instanceof Array ? parsed.result.length === 0 : !parsed.result) { - return; - } - self.handlers.forEach(function (handler) { - handler.call(self, {_event: payload.call, _id: id, data: parsed.result}); - }); - }); - }; - - Object.defineProperty(HttpRpcProvider.prototype, "onmessage", { - set: function (handler) { - this.handlers.push(handler); - } - }); - - if (typeof(web3) !== "undefined" && web3.providers !== undefined) { - web3.providers.HttpRpcProvider = HttpRpcProvider; - } -})(); - -- cgit v1.2.3