From bab05f04ee814f169302aa4d8e74b40b33af7fdd Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 29 Oct 2014 17:29:52 +0100 Subject: [PATCH] whisper in alethzero --- alethzero/js/main.js | 12 ++++++++---- libqethereum/QEthereum.cpp | 15 +++++++-------- libweb3jsonrpc/WebThreeStubServer.cpp | 4 ++-- third/js/main.js | 12 ++++++++---- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/alethzero/js/main.js b/alethzero/js/main.js index 32064ce26..cc85b9850 100644 --- a/alethzero/js/main.js +++ b/alethzero/js/main.js @@ -131,11 +131,11 @@ }).then(function (request) { return new Promise(function (resolve, reject) { web3.provider.send(request, function (result) { - if (result) { + if (result || typeof result === "boolean") { resolve(result); - } else { - reject(result); - } + return; + } + reject(result); }); }); }).catch(function( err) { @@ -373,6 +373,10 @@ }); }; + Filter.prototype.arrived = function(callback) { + this.changed(callback); + } + Filter.prototype.changed = function(callback) { var self = this; this.promise.then(function(id) { diff --git a/libqethereum/QEthereum.cpp b/libqethereum/QEthereum.cpp index 25b341146..5218c6ff5 100644 --- a/libqethereum/QEthereum.cpp +++ b/libqethereum/QEthereum.cpp @@ -151,14 +151,13 @@ void QWebThree::onDataProcessed(QString _json, QString _addInfo) { QJsonObject elem = resultsArray[i].toObject(); if (elem.contains("result")) - for (auto e: elem["result"].toArray()) - { - QJsonObject res; - res["_event"] = _addInfo; - res["_id"] = (int)m_shhWatches[i]; - res["data"] = e; - response(QString::fromUtf8(QJsonDocument(res).toJson())); - } + { + QJsonObject res; + res["_event"] = _addInfo; + res["_id"] = (int)m_shhWatches[i]; + res["data"] = elem["result"].toArray(); + response(QString::fromUtf8(QJsonDocument(res).toJson())); + } } } diff --git a/libweb3jsonrpc/WebThreeStubServer.cpp b/libweb3jsonrpc/WebThreeStubServer.cpp index 9b7237745..332276850 100644 --- a/libweb3jsonrpc/WebThreeStubServer.cpp +++ b/libweb3jsonrpc/WebThreeStubServer.cpp @@ -155,7 +155,7 @@ static shh::Message toMessage(Json::Value const& _json) if (!_json["to"].empty()) ret.setTo(jsToPublic(_json["to"].asString())); if (!_json["payload"].empty()) - ret.setPayload(jsToBytes(_json["payload"].asString())); + ret.setPayload(asBytes(_json["payload"].asString())); return ret; } @@ -216,7 +216,7 @@ static Json::Value toJson(h256 const& _h, shh::Envelope const& _e, shh::Message res["workProved"] = (int)_e.workProved(); res["topic"] = toJS(_e.topic()); - res["payload"] = toJS(_m.payload()); + res["payload"] = asString(_m.payload()); res["from"] = toJS(_m.from()); res["to"] = toJS(_m.to()); return res; diff --git a/third/js/main.js b/third/js/main.js index 32064ce26..cc85b9850 100644 --- a/third/js/main.js +++ b/third/js/main.js @@ -131,11 +131,11 @@ }).then(function (request) { return new Promise(function (resolve, reject) { web3.provider.send(request, function (result) { - if (result) { + if (result || typeof result === "boolean") { resolve(result); - } else { - reject(result); - } + return; + } + reject(result); }); }); }).catch(function( err) { @@ -373,6 +373,10 @@ }); }; + Filter.prototype.arrived = function(callback) { + this.changed(callback); + } + Filter.prototype.changed = function(callback) { var self = this; this.promise.then(function(id) {