diff --git a/packages/status-communities/src/chat.ts b/packages/status-communities/src/chat.ts index 184d50dd..95457c87 100644 --- a/packages/status-communities/src/chat.ts +++ b/packages/status-communities/src/chat.ts @@ -1,4 +1,4 @@ -import { chatIdToContentTopic } from "./contentTopic"; +import { idToContentTopic } from "./contentTopic"; import { createSymKeyFromPassword } from "./encryption"; import { ChatMessage, Content } from "./wire/chat_message"; @@ -21,7 +21,7 @@ export class Chat { } public get contentTopic(): string { - return chatIdToContentTopic(this.id); + return idToContentTopic(this.id); } public createMessage(content: Content): ChatMessage { diff --git a/packages/status-communities/src/contentTopic.ts b/packages/status-communities/src/contentTopic.ts index 07bba7b2..0c78777f 100644 --- a/packages/status-communities/src/contentTopic.ts +++ b/packages/status-communities/src/contentTopic.ts @@ -4,8 +4,13 @@ import { keccak256 } from "js-sha3"; const TopicLength = 4; -export function chatIdToContentTopic(chatId: string): string { - const hash = keccak256.arrayBuffer(chatId); +/** + * Get the content topic of for a given Chat or Community + * @param id The Chat id or Community id (hex string prefixed with 0x). + * @returns string The Waku v2 Content Topic. + */ +export function idToContentTopic(id: string): string { + const hash = keccak256.arrayBuffer(id); const topic = Buffer.from(hash).slice(0, TopicLength);