diff --git a/packages/status-communities/src/community.spec.ts b/packages/status-communities/src/community.spec.ts new file mode 100644 index 00000000..e1ab10eb --- /dev/null +++ b/packages/status-communities/src/community.spec.ts @@ -0,0 +1,29 @@ +import { expect } from "chai"; +import { Waku } from "js-waku"; + +import { Community } from "./community"; +import { CommunityDescription } from "./wire/community_description"; + +describe("Community", () => { + it.skip("Retrieves community description For DappConnect Test from Waku prod fleet", async function () { + this.timeout(20000); + const waku = await Waku.create({ bootstrap: true }); + + await waku.waitForConnectedPeer(); + + const community = await Community.instantiateCommunity( + "0x0262c65c881f5a9f79343a26faaa02aad3af7c533d9445fb1939ed11b8bf4d2abd", + waku + ); + await community.refreshCommunityDescription(); + const desc = community.description as CommunityDescription; + expect(desc).to.not.be.undefined; + + expect(desc.identity?.displayName).to.eq("DappConnect Test"); + const chats = Array.from(desc.chats.values()).map( + (chat) => chat?.identity?.displayName + ); + expect(chats).to.include("foobar"); + expect(chats).to.include("another-channel!"); + }); +}); diff --git a/packages/status-communities/src/wire/community_description.ts b/packages/status-communities/src/wire/community_description.ts index f86d95f8..b4bef503 100644 --- a/packages/status-communities/src/wire/community_description.ts +++ b/packages/status-communities/src/wire/community_description.ts @@ -3,9 +3,11 @@ import { WakuMessage, WakuStore } from "js-waku"; import { Reader } from "protobufjs"; import { idToContentTopic } from "../contentTopic"; +import { createSymKeyFromPassword } from "../encryption"; import * as proto from "../proto/communities/v1/communities"; import { bufToHex } from "../utils"; +import { ApplicationMetadataMessage } from "./application_metadata_message"; import { ChatIdentity } from "./chat_identity"; import { CommunityChat } from "./community_chat"; @@ -45,8 +47,11 @@ export class CommunityDescription { orderedMessages.forEach((message: WakuMessage) => { if (!message.payload) return; try { + const metadata = ApplicationMetadataMessage.decode(message.payload); + if (!metadata.payload) return; + const _communityDescription = CommunityDescription.decode( - message.payload + metadata.payload ); if (!_communityDescription.identity) return; @@ -61,9 +66,12 @@ export class CommunityDescription { }); }; + const symKey = await createSymKeyFromPassword(hexCommunityPublicKey); + await wakuStore .queryHistory([contentTopic], { callback, + decryptionKeys: [symKey], }) .catch((e) => { dbg(