60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
export interface Game {
|
|
ended_time: string; // "2025-06-04 13:24:52"
|
|
address: string; // "12oDoNd73dCcHqq2fB5QxpzE8TTQQyMVj4mGavm2pGX8"
|
|
game: string; // "tetris"
|
|
master_score: string; // "0"
|
|
client_score: string; // "0"
|
|
winner: string; // "master"
|
|
wager: string; // "1000000"
|
|
master_id: string; // "did:privy:cm9a3f19v00iri90mag51e0zk"
|
|
client_id: string; // "na"
|
|
reward_tx: string; // "xYJnbWNTyMU36J7HL188Rq6tMHYf8X6ausPXP6izedNAiuzdPmwYkeCNFeRejT2mU8uXpjPjVPAaK5GD42dMbGM"
|
|
rematch_address: string | null; // null
|
|
owner_referree: string | null; // "9esrj2X33pr5og6fdkDMjaW6fdnnb9hT1cWshamxTdL4"
|
|
joiner_referree: string | null; // "9esrj2X33pr5og6fdkDMjaW6fdnnb9hT1cWshamxTdL4"
|
|
}
|
|
|
|
export interface User {
|
|
ref_id: string; // "146"
|
|
id: string; // ""
|
|
username: string; // ""
|
|
bio: string; // ""
|
|
x_profile_url: string; // ""
|
|
referred_id: string; // "-1"
|
|
active_wallet: string; // ""
|
|
}
|
|
|
|
// Helper function to truncate wallet address
|
|
export function truncateAddress(address: string): string {
|
|
if (!address || address === 'na' || address.startsWith('did:privy:')) return address;
|
|
return `${address.slice(0, 4)}...${address.slice(-4)}`;
|
|
}
|
|
|
|
export async function fetchGames(): Promise<Game[]> {
|
|
try {
|
|
const response = await fetch('https://api.duelfi.io/v1/admin/get_all_games.php');
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
}
|
|
const data = await response.json();
|
|
|
|
return data;
|
|
} catch (error) {
|
|
console.error('Error fetching games:', error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
export async function fetchUsers(): Promise<User[]> {
|
|
try {
|
|
const response = await fetch('https://api.duelfi.io/v1/admin/get_all_users.php');
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
}
|
|
const data = await response.json();
|
|
return data;
|
|
} catch (error) {
|
|
console.error('Error fetching users:', error);
|
|
throw error;
|
|
}
|
|
}
|