Examples: Content Topic moved out of options parameter

This commit is contained in:
Franck Royer 2021-07-28 11:22:29 +10:00
parent 0cfdd34284
commit 9aaac20981
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
4 changed files with 16 additions and 15 deletions

View File

@ -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 {

View File

@ -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);
}

View File

@ -115,8 +115,7 @@ async function encodeEncryptedWakuMessage(
});
const payload = directMsg.encode();
return WakuMessage.fromBytes(payload, {
contentTopic: DirectMessageContentTopic,
return WakuMessage.fromBytes(payload, DirectMessageContentTopic, {
encPublicKey: publicKey,
});
}

View File

@ -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);
}
}