fix: types

This commit is contained in:
Danish Arora 2025-08-29 15:29:20 +05:30
parent 9a70c59bc7
commit fe17cbc57b
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
4 changed files with 8 additions and 4 deletions

View File

@ -19,3 +19,7 @@ export function hexToBytes(hex: string): Uint8Array {
} }
return bytes; return bytes;
} }
export function generateStringId(): string {
return crypto.randomUUID();
}

View File

@ -62,7 +62,7 @@ export function encodeMessage(message: OpchanMessage): Uint8Array {
/** /**
* Decode a message from a Uint8Array based on its type * Decode a message from a Uint8Array based on its type
*/ */
export function decodeMessage(payload: Uint8Array): CellMessage | PostMessage | CommentMessage | VoteMessage { export function decodeMessage(payload: Uint8Array): OpchanMessage {
const messageJson = new TextDecoder().decode(payload); const messageJson = new TextDecoder().decode(payload);
const message = JSON.parse(messageJson) as OpchanMessage; const message = JSON.parse(messageJson) as OpchanMessage;

View File

@ -1,6 +1,6 @@
import { IDecodedMessage, LightNode } from "@waku/sdk"; import { IDecodedMessage, LightNode } from "@waku/sdk";
import { decodeMessage, decoders} from "./codec"; import { decodeMessage, decoders} from "./codec";
import { CellMessage, PostMessage, CommentMessage, VoteMessage } from "./types"; import { OpchanMessage } from "@/types/forum";
class StoreManager { class StoreManager {
private node: LightNode; private node: LightNode;
@ -10,7 +10,7 @@ class StoreManager {
} }
public async queryStore() { public async queryStore() {
const result: (CellMessage | PostMessage | CommentMessage | VoteMessage)[] = []; const result: OpchanMessage[] = [];
try { try {
// Add query options to prevent database overload // Add query options to prevent database overload

View File

@ -14,7 +14,7 @@ export enum MessageType {
*/ */
export interface BaseMessage { export interface BaseMessage {
type: MessageType; type: MessageType;
timestamp: number; timestamp: number | Date;
author: string; author: string;
signature?: string; // Message signature for verification signature?: string; // Message signature for verification
browserPubKey?: string; // Public key that signed the message browserPubKey?: string; // Public key that signed the message