chore(relay-angular-chat): bump js-waku to 0.29.0

This commit is contained in:
fryorcraken.eth 2022-09-21 11:38:32 +10:00
parent 9b3093bee4
commit 55d8f7ebc4
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
3 changed files with 19 additions and 16 deletions

View File

@ -21,7 +21,7 @@
"@angular/platform-browser": "~14.2.0",
"@angular/platform-browser-dynamic": "~14.2.0",
"@angular/router": "~14.2.0",
"js-waku": "0.28.1",
"js-waku": "0.29.0",
"protobufjs": "^7.1.0",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",

View File

@ -16,7 +16,7 @@ specifiers:
'@types/node': ^17.0.21
is-ci-cli: ^2.2.0
jasmine-core: ~4.3.0
js-waku: 0.28.1
js-waku: 0.29.0
karma: ~6.4.0
karma-chrome-launcher: ~3.1.0
karma-coverage: ~2.2.0
@ -37,7 +37,7 @@ dependencies:
'@angular/platform-browser': 14.2.0_afytwol7hs4qio34buyx2grhfa
'@angular/platform-browser-dynamic': 14.2.0_owch6soaoexeadly32xw5vendq
'@angular/router': 14.2.0_6lk4yxyxfaqzosenawf2bqx6vy
js-waku: 0.28.1
js-waku: 0.29.0
protobufjs: 7.1.0
rxjs: 7.5.6
tslib: 2.4.0
@ -5440,8 +5440,8 @@ packages:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
dev: true
/js-waku/0.28.1:
resolution: {integrity: sha512-0h9TpV6jywyjdes8hr9tFV/5iJh3LQN3sQFYHcXyi4cK+4htNiMrCRjBSqRBtfhs/j+4tOkrht8gRJRLHdA5RA==}
/js-waku/0.29.0:
resolution: {integrity: sha512-44GOpNbkFt/1/bDZ3tcaeemehaZaxw404QmTvHw7FUwY6dtvGsDEERLEw1TERUljDESFjvEOcJjYnLcNDY1MHg==}
engines: {node: '>=16'}
dependencies:
'@chainsafe/libp2p-gossipsub': 4.1.1

View File

@ -1,8 +1,9 @@
import { Component, OnInit } from "@angular/core";
import { WakuService } from "../waku.service";
import { WakuMessage } from "js-waku";
import type { WakuPrivacy } from "js-waku/lib/interfaces";
import protobuf from "protobufjs";
import { DecoderV0, EncoderV0 } from "js-waku/lib/waku_message/version_0";
import type { MessageV0 } from "js-waku/lib/waku_message/version_0";
const ProtoChatMessage = new protobuf.Type("ChatMessage")
.add(new protobuf.Field("timestamp", 1, "uint32"))
@ -20,13 +21,18 @@ interface MessageInterface {
})
export class MessagesComponent implements OnInit {
contentTopic: string = `/js-waku-examples/1/chat/proto`;
decoder: DecoderV0;
encoder: EncoderV0;
messages: MessageInterface[] = [];
messageCount: number = 0;
waku!: WakuPrivacy;
wakuStatus!: string;
deleteObserver?: () => void;
constructor(private wakuService: WakuService) {}
constructor(private wakuService: WakuService) {
this.decoder = new DecoderV0(this.contentTopic);
this.encoder = new EncoderV0(this.contentTopic);
}
ngOnInit(): void {
this.wakuService.wakuStatus.subscribe((wakuStatus) => {
@ -36,8 +42,8 @@ export class MessagesComponent implements OnInit {
this.wakuService.waku.subscribe((waku) => {
this.waku = waku;
this.deleteObserver = this.waku.relay.addObserver(
this.processIncomingMessages,
[this.contentTopic]
this.decoder,
this.processIncomingMessages
);
});
@ -57,16 +63,13 @@ export class MessagesComponent implements OnInit {
});
const payload = ProtoChatMessage.encode(protoMsg).finish();
WakuMessage.fromBytes(payload, this.contentTopic).then((wakuMessage) => {
this.waku.relay.send(wakuMessage).then(() => {
console.log(`Message #${this.messageCount} sent`);
this.messageCount += 1;
});
this.waku.relay.send(this.encoder, { payload }).then(() => {
console.log(`Message #${this.messageCount} sent`);
this.messageCount += 1;
});
}
processIncomingMessages = (wakuMessage: WakuMessage) => {
processIncomingMessages = (wakuMessage: MessageV0) => {
if (!wakuMessage.payload) return;
const { text, timestamp } = ProtoChatMessage.decode(