refactored serverI and made genId more friendly

This commit is contained in:
2023-08-15 21:51:53 -04:00
parent eaba6a6c93
commit bc7bf8a83c
3 changed files with 7 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "discreetly-interfaces",
"version": "0.1.32",
"version": "0.1.33",
"description": "Common interfaces and utilities for discreetly",
"author": "AtHeartEngineer",
"homepage": "https://github.com/Discreetly",

View File

@@ -45,11 +45,9 @@ export interface RoomI {
}
export interface ServerI {
id: bigint | string;
name: string;
id?: bigint | string;
name?: string;
version?: string;
serverInfoEndpoint?: string;
messageHandlerSocket?: string; // Default port for websocket connections
rooms?: RoomI[];
selectedRoom?: RoomI['roomId'];
url?: string;
rooms?: string[];
}

View File

@@ -8,9 +8,9 @@ export function str2BigInt(str: string) {
return BigInt(num);
}
export function genId(serverID: bigint, roomName: string | bigint | number) {
export function genId(serverID: string | bigint | number, roomName: string | bigint | number) {
if (typeof roomName === 'string') {
return poseidon2([serverID, str2BigInt(roomName)]);
return poseidon2([BigInt(serverID), str2BigInt(roomName)]);
}
return poseidon2([serverID, BigInt(roomName)]);
}