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

@ -18,4 +18,8 @@ export function hexToBytes(hex: string): Uint8Array {
bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);
}
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
*/
export function decodeMessage(payload: Uint8Array): CellMessage | PostMessage | CommentMessage | VoteMessage {
export function decodeMessage(payload: Uint8Array): OpchanMessage {
const messageJson = new TextDecoder().decode(payload);
const message = JSON.parse(messageJson) as OpchanMessage;

View File

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

View File

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