mirror of
https://github.com/logos-messaging/OpChan.git
synced 2026-01-02 12:53:10 +00:00
fix: types
This commit is contained in:
parent
9a70c59bc7
commit
fe17cbc57b
@ -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();
|
||||
}
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user