mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-23 12:38:18 +00:00
fix unneeded ascii conversion for topics
This commit is contained in:
parent
8f434df926
commit
6389884851
@ -293,21 +293,21 @@ var EmbarkJS =
|
|||||||
|
|
||||||
// do fromAscii to each topics unless it's already a string
|
// do fromAscii to each topics unless it's already a string
|
||||||
if (typeof topics === 'string') {
|
if (typeof topics === 'string') {
|
||||||
topics = topics;
|
_topics = [web3.fromAscii(topics)];
|
||||||
} else {
|
} else {
|
||||||
// TODO: replace with es6 + babel;
|
// TODO: replace with es6 + babel;
|
||||||
var _topics = [];
|
var _topics = [];
|
||||||
for (var i = 0; i < topics.length; i++) {
|
for (var i = 0; i < topics.length; i++) {
|
||||||
_topics.push(web3.fromAscii(topics[i]));
|
_topics.push(web3.fromAscii(topics[i]));
|
||||||
}
|
}
|
||||||
topics = _topics;
|
|
||||||
}
|
}
|
||||||
|
topics = _topics;
|
||||||
|
|
||||||
var payload = JSON.stringify(data);
|
var payload = JSON.stringify(data);
|
||||||
|
|
||||||
var message = {
|
var message = {
|
||||||
from: identity,
|
from: identity,
|
||||||
topics: [web3.fromAscii(topics)],
|
topics: topics,
|
||||||
payload: web3.fromAscii(payload),
|
payload: web3.fromAscii(payload),
|
||||||
ttl: ttl,
|
ttl: ttl,
|
||||||
priority: priority
|
priority: priority
|
||||||
@ -320,15 +320,15 @@ var EmbarkJS =
|
|||||||
var topics = options.topic || options.topics;
|
var topics = options.topic || options.topics;
|
||||||
|
|
||||||
if (typeof topics === 'string') {
|
if (typeof topics === 'string') {
|
||||||
topics = [web3.fromAscii(topics)];
|
_topics = [topics];
|
||||||
} else {
|
} else {
|
||||||
// TODO: replace with es6 + babel;
|
// TODO: replace with es6 + babel;
|
||||||
var _topics = [];
|
var _topics = [];
|
||||||
for (var i = 0; i < topics.length; i++) {
|
for (var i = 0; i < topics.length; i++) {
|
||||||
_topics.push(web3.fromAscii(topics[i]));
|
_topics.push(topics[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
topics = _topics;
|
topics = _topics;
|
||||||
}
|
|
||||||
|
|
||||||
var filterOptions = {
|
var filterOptions = {
|
||||||
topics: topics
|
topics: topics
|
||||||
@ -355,7 +355,7 @@ var EmbarkJS =
|
|||||||
promise.error(err);
|
promise.error(err);
|
||||||
} else {
|
} else {
|
||||||
data = {
|
data = {
|
||||||
topic: topics.map((t) => web3.toAscii(t)),
|
topic: topics,
|
||||||
data: payload,
|
data: payload,
|
||||||
from: result.from,
|
from: result.from,
|
||||||
time: (new Date(result.sent * 1000))
|
time: (new Date(result.sent * 1000))
|
||||||
|
14
js/embark.js
14
js/embark.js
@ -246,21 +246,21 @@ EmbarkJS.Messages.Whisper.sendMessage = function(options) {
|
|||||||
|
|
||||||
// do fromAscii to each topics unless it's already a string
|
// do fromAscii to each topics unless it's already a string
|
||||||
if (typeof topics === 'string') {
|
if (typeof topics === 'string') {
|
||||||
topics = topics;
|
_topics = [web3.fromAscii(topics)];
|
||||||
} else {
|
} else {
|
||||||
// TODO: replace with es6 + babel;
|
// TODO: replace with es6 + babel;
|
||||||
var _topics = [];
|
var _topics = [];
|
||||||
for (var i = 0; i < topics.length; i++) {
|
for (var i = 0; i < topics.length; i++) {
|
||||||
_topics.push(web3.fromAscii(topics[i]));
|
_topics.push(web3.fromAscii(topics[i]));
|
||||||
}
|
}
|
||||||
topics = _topics;
|
|
||||||
}
|
}
|
||||||
|
topics = _topics;
|
||||||
|
|
||||||
var payload = JSON.stringify(data);
|
var payload = JSON.stringify(data);
|
||||||
|
|
||||||
var message = {
|
var message = {
|
||||||
from: identity,
|
from: identity,
|
||||||
topics: [web3.fromAscii(topics)],
|
topics: topics,
|
||||||
payload: web3.fromAscii(payload),
|
payload: web3.fromAscii(payload),
|
||||||
ttl: ttl,
|
ttl: ttl,
|
||||||
priority: priority
|
priority: priority
|
||||||
@ -273,15 +273,15 @@ EmbarkJS.Messages.Whisper.listenTo = function(options) {
|
|||||||
var topics = options.topic || options.topics;
|
var topics = options.topic || options.topics;
|
||||||
|
|
||||||
if (typeof topics === 'string') {
|
if (typeof topics === 'string') {
|
||||||
topics = [web3.fromAscii(topics)];
|
_topics = [topics];
|
||||||
} else {
|
} else {
|
||||||
// TODO: replace with es6 + babel;
|
// TODO: replace with es6 + babel;
|
||||||
var _topics = [];
|
var _topics = [];
|
||||||
for (var i = 0; i < topics.length; i++) {
|
for (var i = 0; i < topics.length; i++) {
|
||||||
_topics.push(web3.fromAscii(topics[i]));
|
_topics.push(topics[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
topics = _topics;
|
topics = _topics;
|
||||||
}
|
|
||||||
|
|
||||||
var filterOptions = {
|
var filterOptions = {
|
||||||
topics: topics
|
topics: topics
|
||||||
@ -308,7 +308,7 @@ EmbarkJS.Messages.Whisper.listenTo = function(options) {
|
|||||||
promise.error(err);
|
promise.error(err);
|
||||||
} else {
|
} else {
|
||||||
data = {
|
data = {
|
||||||
topic: topics.map((t) => web3.toAscii(t)),
|
topic: topics,
|
||||||
data: payload,
|
data: payload,
|
||||||
from: result.from,
|
from: result.from,
|
||||||
time: (new Date(result.sent * 1000))
|
time: (new Date(result.sent * 1000))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user