mirror of https://github.com/status-im/js-waku.git
Examples: Content Topic moved out of options parameter
This commit is contained in:
parent
0cfdd34284
commit
9aaac20981
|
@ -104,10 +104,13 @@ export default async function startChat(): Promise<void> {
|
|||
rl.prompt();
|
||||
const chatMessage = ChatMessage.fromUtf8String(new Date(), nick, line);
|
||||
|
||||
const msg = await WakuMessage.fromBytes(chatMessage.encode(), {
|
||||
contentTopic: ChatContentTopic,
|
||||
timestamp: new Date(),
|
||||
});
|
||||
const msg = await WakuMessage.fromBytes(
|
||||
chatMessage.encode(),
|
||||
ChatContentTopic,
|
||||
{
|
||||
timestamp: new Date(),
|
||||
}
|
||||
);
|
||||
if (opts.lightPush) {
|
||||
await waku.lightPush.push(msg);
|
||||
} else {
|
||||
|
|
|
@ -31,7 +31,7 @@ export default function BroadcastPublicKey({
|
|||
console.error('Failed to send Public Key Message', e);
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
.catch(() => {
|
||||
console.log('Failed to encode Public Key Message in Waku Message');
|
||||
});
|
||||
} else {
|
||||
|
@ -47,7 +47,7 @@ export default function BroadcastPublicKey({
|
|||
console.error('Failed to send Public Key Message', e);
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
.catch(() => {
|
||||
console.log(
|
||||
'Failed to encode Public Key Message in Waku Message'
|
||||
);
|
||||
|
@ -75,7 +75,5 @@ async function encodePublicKeyWakuMessage(
|
|||
publicKeyMessage: PublicKeyMessage
|
||||
): Promise<WakuMessage> {
|
||||
const payload = publicKeyMessage.encode();
|
||||
return await WakuMessage.fromBytes(payload, {
|
||||
contentTopic: PublicKeyContentTopic,
|
||||
});
|
||||
return await WakuMessage.fromBytes(payload, PublicKeyContentTopic);
|
||||
}
|
||||
|
|
|
@ -115,8 +115,7 @@ async function encodeEncryptedWakuMessage(
|
|||
});
|
||||
|
||||
const payload = directMsg.encode();
|
||||
return WakuMessage.fromBytes(payload, {
|
||||
contentTopic: DirectMessageContentTopic,
|
||||
return WakuMessage.fromBytes(payload, DirectMessageContentTopic, {
|
||||
encPublicKey: publicKey,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -65,10 +65,11 @@ async function handleMessage(
|
|||
} else {
|
||||
const timestamp = new Date();
|
||||
const chatMessage = ChatMessage.fromUtf8String(timestamp, nick, message);
|
||||
const wakuMsg = await WakuMessage.fromBytes(chatMessage.encode(), {
|
||||
contentTopic: ChatContentTopic,
|
||||
timestamp,
|
||||
});
|
||||
const wakuMsg = await WakuMessage.fromBytes(
|
||||
chatMessage.encode(),
|
||||
ChatContentTopic,
|
||||
{ timestamp }
|
||||
);
|
||||
return messageSender(wakuMsg);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue