update to latest @waku/core

This commit is contained in:
danisharora099 2023-02-01 12:38:24 +05:30
parent 362e307594
commit 35ff489247
No known key found for this signature in database
GPG Key ID: FBD2BF500037F135
5 changed files with 1222 additions and 887 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
"@livechat/ui-kit": "^0.5.0-24",
"@multiformats/multiaddr": "11.0.7",
"@waku/byte-utils": "^0.0.2",
"@waku/core": "^0.0.6",
"@waku/core": "^0.0.10",
"@waku/create": "^0.0.4",
"@waku/dns-discovery": "0.0.5",
"@waku/interfaces": "^0.0.5",

View File

@ -8,10 +8,10 @@ import { generate } from "server-name-generator";
import { Message } from "./Message";
import { wakuDnsDiscovery } from "@waku/dns-discovery";
import { wakuPeerExchangeDiscovery } from "@waku/peer-exchange";
import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer";
import { waitForRemotePeer } from "@waku/core";
import { Protocols, WakuLight } from "@waku/interfaces";
import { createLightNode } from "@waku/create";
import { DecoderV0, MessageV0 } from "@waku/core/lib/waku_message/version_0";
import { DecodedMessage, Decoder } from "@waku/core/lib/message/version_0";
import { PageDirection } from "@waku/interfaces";
const themes = {
@ -44,7 +44,7 @@ const themes = {
};
export const ChatContentTopic = "/toy-chat/2/huilong/proto";
const ChatDecoder = new DecoderV0(ChatContentTopic);
const ChatDecoder = new Decoder(ChatContentTopic);
async function retrieveStoreMessages(
waku: WakuLight,
@ -111,7 +111,7 @@ export default function App() {
// Let's retrieve previous messages before listening to new messages
if (!historicalMessagesRetrieved) return;
const handleIncomingMessage = (wakuMsg: MessageV0) => {
const handleIncomingMessage = (wakuMsg: DecodedMessage) => {
console.log("Message received: ", wakuMsg);
const msg = Message.fromWakuMessage(wakuMsg);
if (msg) {
@ -223,6 +223,8 @@ function reduceMessages(state: Message[], newMessages: Message[]) {
return state.concat(newMessages);
}
const isMessageDefined = (msg: MessageV0 | undefined): msg is MessageV0 => {
const isMessageDefined = (
msg: DecodedMessage | undefined
): msg is DecodedMessage => {
return !!msg;
};

View File

@ -1,4 +1,4 @@
import { MessageV0 } from "@waku/core/lib/waku_message/version_0";
import { DecodedMessage } from "@waku/core/lib/message/version_0";
import { ChatMessage } from "./chat_message";
export class Message {
@ -11,7 +11,7 @@ export class Message {
this.sentTimestamp = sentTimestamp;
}
static fromWakuMessage(wakuMsg: MessageV0): Message | undefined {
static fromWakuMessage(wakuMsg: DecodedMessage): Message | undefined {
if (wakuMsg.payload) {
try {
const chatMsg = ChatMessage.decode(wakuMsg.payload);

View File

@ -7,7 +7,7 @@ import { TitleBar } from "@livechat/ui-kit";
import { Message } from "./Message";
import { ChatMessage } from "./chat_message";
import { useEffect, useState } from "react";
import { EncoderV0 } from "@waku/core/lib/waku_message/version_0";
import { Encoder } from "@waku/core/lib/message/version_0";
interface Props {
messages: Message[];
@ -25,7 +25,7 @@ export default function Room(props: Props) {
const [bootstrapPeers, setBootstrapPeers] = useState(new Set<string>());
const [peerExchangePeers, setPeerExchangePeers] = useState(new Set<string>());
const ChatEncoder = new EncoderV0(ChatContentTopic);
const ChatEncoder = new Encoder(ChatContentTopic);
useEffect(() => {
if (!waku) return;