chore(relay-reactjs-chat): bump js-waku to 0.29.0
This commit is contained in:
parent
55d8f7ebc4
commit
b373d41540
|
@ -7,7 +7,7 @@
|
|||
"@testing-library/jest-dom": "^5.16.5",
|
||||
"@testing-library/react": "^13.3.0",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"js-waku": "0.28.1",
|
||||
"js-waku": "0.29.0",
|
||||
"protobufjs": "^7.0.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
|
|
|
@ -6,7 +6,7 @@ specifiers:
|
|||
'@testing-library/react': ^13.3.0
|
||||
'@testing-library/user-event': ^13.5.0
|
||||
eslint: ^8.22.0
|
||||
js-waku: 0.28.1
|
||||
js-waku: 0.29.0
|
||||
protobufjs: ^7.0.0
|
||||
react: ^18.2.0
|
||||
react-dom: ^18.2.0
|
||||
|
@ -17,7 +17,7 @@ dependencies:
|
|||
'@testing-library/jest-dom': 5.16.5
|
||||
'@testing-library/react': 13.3.0_biqbaboplfbrettd7655fr4n2y
|
||||
'@testing-library/user-event': 13.5.0_wl4iynrlixafokvgqnhzlvigei
|
||||
js-waku: 0.28.1_undici@5.10.0
|
||||
js-waku: 0.29.0_undici@5.10.0
|
||||
protobufjs: 7.0.0
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0_react@18.2.0
|
||||
|
@ -7001,8 +7001,8 @@ packages:
|
|||
/js-tokens/4.0.0:
|
||||
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
|
||||
|
||||
/js-waku/0.28.1_undici@5.10.0:
|
||||
resolution: {integrity: sha512-0h9TpV6jywyjdes8hr9tFV/5iJh3LQN3sQFYHcXyi4cK+4htNiMrCRjBSqRBtfhs/j+4tOkrht8gRJRLHdA5RA==}
|
||||
/js-waku/0.29.0_undici@5.10.0:
|
||||
resolution: {integrity: sha512-44GOpNbkFt/1/bDZ3tcaeemehaZaxw404QmTvHw7FUwY6dtvGsDEERLEw1TERUljDESFjvEOcJjYnLcNDY1MHg==}
|
||||
engines: {node: '>=16'}
|
||||
dependencies:
|
||||
'@chainsafe/libp2p-gossipsub': 4.1.1_undici@5.10.0
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import { WakuMessage } from "js-waku";
|
||||
import * as React from "react";
|
||||
import protobuf from "protobufjs";
|
||||
import { createPrivacyNode } from "js-waku/lib/create_waku";
|
||||
import { waitForRemotePeer } from "js-waku/lib/wait_for_remote_peer";
|
||||
import { DecoderV0, EncoderV0 } from "js-waku/lib/waku_message/version_0";
|
||||
|
||||
const ContentTopic = `/js-waku-examples/1/chat/proto`;
|
||||
const Encoder = new EncoderV0(ContentTopic);
|
||||
const Decoder = new DecoderV0(ContentTopic);
|
||||
|
||||
const SimpleChatMessage = new protobuf.Type("SimpleChatMessage")
|
||||
.add(new protobuf.Field("timestamp", 1, "uint32"))
|
||||
|
@ -34,6 +36,7 @@ function App() {
|
|||
}, [waku, wakuStatus]);
|
||||
|
||||
const processIncomingMessage = React.useCallback((wakuMessage) => {
|
||||
console.log("Message received", wakuMessage);
|
||||
if (!wakuMessage.payload) return;
|
||||
|
||||
const { text, timestamp } = SimpleChatMessage.decode(wakuMessage.payload);
|
||||
|
@ -52,9 +55,10 @@ function App() {
|
|||
if (!waku) return;
|
||||
|
||||
// Pass the content topic to only process messages related to your dApp
|
||||
const deleteObserver = waku.relay.addObserver(processIncomingMessage, [
|
||||
ContentTopic,
|
||||
]);
|
||||
const deleteObserver = waku.relay.addObserver(
|
||||
Decoder,
|
||||
processIncomingMessage
|
||||
);
|
||||
|
||||
// Called when the component is unmounted, see ReactJS doc.
|
||||
return deleteObserver;
|
||||
|
@ -105,11 +109,8 @@ function sendMessage(message, waku, timestamp) {
|
|||
});
|
||||
const payload = SimpleChatMessage.encode(protoMsg).finish();
|
||||
|
||||
// Wrap in a Waku Message
|
||||
return WakuMessage.fromBytes(payload, ContentTopic).then((wakuMessage) =>
|
||||
// Send over Waku Relay
|
||||
waku.relay.send(wakuMessage)
|
||||
);
|
||||
// Send over Waku Relay
|
||||
return waku.relay.send(Encoder, { payload });
|
||||
}
|
||||
|
||||
export default App;
|
||||
|
|
Loading…
Reference in New Issue