Skip to content

Commit

Permalink
update peripherals for new version
Browse files Browse the repository at this point in the history
  • Loading branch information
kadirchan committed Nov 10, 2024
1 parent 7b1c4dd commit 379eda7
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 35 deletions.
5 changes: 4 additions & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export const API_URL = 'https://api_drmmina.kadircan.org/';
export const WEB_URL = 'https://drm-mina.kadircan.org/';
export const WEB_URL =
process.env.NODE_ENV === 'development'
? 'http://localhost:3000/'
: 'https://drm-mina.kadircan.org/';
23 changes: 23 additions & 0 deletions src/renderer/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,26 @@ export async function fetchWishlist(userPubKey: string) {
}
return json;
}

export async function fetchComments(
gameId: number,
page: number = 1,
limit: number = 10,
): Promise<any> {
const headers = { 'Content-Type': 'application/json' };
const res = await fetch(
`${API_URL}comments/${gameId}?page=${page}&limit=${limit}`,
{
headers,
method: 'GET',
},
);
if (!res.ok) {
const errorResponse = await res.json();
console.error(errorResponse.message);
throw new Error(`Failed to fetch comments: ${errorResponse.message}`);
}

const json = await res.json();
return json;
}
52 changes: 18 additions & 34 deletions src/renderer/lib/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,25 @@ interface Game {
discount: number;
tags: string[];
downloadable: boolean;
averageRating: number;
ratingCount: number;
}

interface GamePrices {
data: {
runtime: {
GameToken: {
gamePrice: {
value: string | null;
};
discount: {
value: string | null;
};
};
};
};
}

interface GameNumber {
data: {
runtime: {
GameToken: {
totalGameNumber: {
value: string | null;
};
};
};
};
interface RawIdentifiers {
cpuId: string;
systemSerial: string;
systemUUID: string;
baseboardSerial: string;
macAddress: string[];
diskSerial: string;
}

interface Library {
data: {
runtime: {
GameToken: {
users: boolean | null;
};
};
interface IComment {
_id: string;
user: {
publicKey: string;
_id: string;
};
gameId: number;
content: string;
rating: number;
createdAt: string;
}
18 changes: 18 additions & 0 deletions src/renderer/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export function base58Decode(input: string): number {
const alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
const base = BigInt(58);
let result = BigInt(0);

for (let i = 0; i < input.length; i++) {
const char = input[i];
const index = alphabet.indexOf(char);

if (index === -1) {
throw new Error(`Invalid Base58 character '${char}' at position ${i}`);
}

result = result * base + BigInt(index);
}

return Number(result % BigInt(Number.MAX_SAFE_INTEGER));
}

0 comments on commit 379eda7

Please sign in to comment.