mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-02 17:03:36 +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
|
||||
if (typeof topics === 'string') {
|
||||
topics = topics;
|
||||
_topics = [web3.fromAscii(topics)];
|
||||
} else {
|
||||
// TODO: replace with es6 + babel;
|
||||
var _topics = [];
|
||||
for (var i = 0; i < topics.length; i++) {
|
||||
_topics.push(web3.fromAscii(topics[i]));
|
||||
}
|
||||
topics = _topics;
|
||||
}
|
||||
topics = _topics;
|
||||
|
||||
var payload = JSON.stringify(data);
|
||||
|
||||
var message = {
|
||||
from: identity,
|
||||
topics: [web3.fromAscii(topics)],
|
||||
topics: topics,
|
||||
payload: web3.fromAscii(payload),
|
||||
ttl: ttl,
|
||||
priority: priority
|
||||
@ -320,15 +320,15 @@ var EmbarkJS =
|
||||
var topics = options.topic || options.topics;
|
||||
|
||||
if (typeof topics === 'string') {
|
||||
topics = [web3.fromAscii(topics)];
|
||||
_topics = [topics];
|
||||
} else {
|
||||
// TODO: replace with es6 + babel;
|
||||
var _topics = [];
|
||||
for (var i = 0; i < topics.length; i++) {
|
||||
_topics.push(web3.fromAscii(topics[i]));
|
||||
_topics.push(topics[i]);
|
||||
}
|
||||
topics = _topics;
|
||||
}
|
||||
topics = _topics;
|
||||
|
||||
var filterOptions = {
|
||||
topics: topics
|
||||
@ -355,7 +355,7 @@ var EmbarkJS =
|
||||
promise.error(err);
|
||||
} else {
|
||||
data = {
|
||||
topic: topics.map((t) => web3.toAscii(t)),
|
||||
topic: topics,
|
||||
data: payload,
|
||||
from: result.from,
|
||||
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
|
||||
if (typeof topics === 'string') {
|
||||
topics = topics;
|
||||
_topics = [web3.fromAscii(topics)];
|
||||
} else {
|
||||
// TODO: replace with es6 + babel;
|
||||
var _topics = [];
|
||||
for (var i = 0; i < topics.length; i++) {
|
||||
_topics.push(web3.fromAscii(topics[i]));
|
||||
}
|
||||
topics = _topics;
|
||||
}
|
||||
topics = _topics;
|
||||
|
||||
var payload = JSON.stringify(data);
|
||||
|
||||
var message = {
|
||||
from: identity,
|
||||
topics: [web3.fromAscii(topics)],
|
||||
topics: topics,
|
||||
payload: web3.fromAscii(payload),
|
||||
ttl: ttl,
|
||||
priority: priority
|
||||
@ -273,15 +273,15 @@ EmbarkJS.Messages.Whisper.listenTo = function(options) {
|
||||
var topics = options.topic || options.topics;
|
||||
|
||||
if (typeof topics === 'string') {
|
||||
topics = [web3.fromAscii(topics)];
|
||||
_topics = [topics];
|
||||
} else {
|
||||
// TODO: replace with es6 + babel;
|
||||
var _topics = [];
|
||||
for (var i = 0; i < topics.length; i++) {
|
||||
_topics.push(web3.fromAscii(topics[i]));
|
||||
_topics.push(topics[i]);
|
||||
}
|
||||
topics = _topics;
|
||||
}
|
||||
topics = _topics;
|
||||
|
||||
var filterOptions = {
|
||||
topics: topics
|
||||
@ -308,7 +308,7 @@ EmbarkJS.Messages.Whisper.listenTo = function(options) {
|
||||
promise.error(err);
|
||||
} else {
|
||||
data = {
|
||||
topic: topics.map((t) => web3.toAscii(t)),
|
||||
topic: topics,
|
||||
data: payload,
|
||||
from: result.from,
|
||||
time: (new Date(result.sent * 1000))
|
||||
|
Loading…
x
Reference in New Issue
Block a user