This commit is contained in:
Sewmina 2025-04-30 10:20:41 +00:00
parent bb0b9a2142
commit 7a09838a46
10 changed files with 38 additions and 14 deletions

View File

@ -3,7 +3,15 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
/* config options here */ /* config options here */
images: { images: {
domains: ["pbs.twimg.com","vps.playpoolstudios.com", "api.duelfi.io"], // ✅ add Twitter's image domain domains: ["pbs.twimg.com","vps.playpoolstudios.com", "api.duelfi.io", "validator.duelfi.io", "validatordev.duelfi.io"], // ✅ add Twitter's image domain
},
async rewrites() {
return [
{
source: '/api/:path*',
destination: 'https://api.duelfi.io/:path*',
},
];
}, },
}; };

View File

@ -3,9 +3,9 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev -p 3031", "dev": "next dev -p 3030",
"build": "next build", "build": "next build",
"start": "next start -p 3031", "start": "next start -p 3030",
"lint": "next lint" "lint": "next lint"
}, },
"dependencies": { "dependencies": {

View File

@ -10,7 +10,7 @@ import { createBet } from "@/shared/solana_helpers";
import { Game } from "@/types/Game"; import { Game } from "@/types/Game";
import { connection, EXPLORER_TX_TEMPLATE } from "@/data/shared"; import { connection, EXPLORER_TX_TEMPLATE } from "@/data/shared";
import { CONFIRMATION_THRESHOLD } from "@/shared/constants"; import { CONFIRMATION_THRESHOLD } from "@/shared/constants";
import { fetchUserById, showNewGameNotification } from "@/shared/data_fetcher";
interface GameModalProps { interface GameModalProps {
isOpen: boolean; isOpen: boolean;
onClose: () => void; onClose: () => void;
@ -64,6 +64,7 @@ export default function GameModal({ isOpen, onClose }: GameModalProps) {
setIsProcessing(true); setIsProcessing(true);
toast.loading("Creating Game"); toast.loading("Creating Game");
try { try {
const ownerProfile = await fetchUserById(user?.id ?? "");
const tx = await createBet(wallet, user?.id ?? "", selectedPrice, selectedGame.id, false); const tx = await createBet(wallet, user?.id ?? "", selectedPrice, selectedGame.id, false);
const url = EXPLORER_TX_TEMPLATE.replace("{address}", tx); const url = EXPLORER_TX_TEMPLATE.replace("{address}", tx);
if (tx.length > 5) { if (tx.length > 5) {
@ -77,6 +78,8 @@ export default function GameModal({ isOpen, onClose }: GameModalProps) {
}, },
}); });
showNewGameNotification(ownerProfile?.username ?? "", selectedGame.name, selectedPrice.toString());
}) })
} }

View File

@ -25,9 +25,8 @@ export default function Header() {
<Image <Image
src="/duelfiassets/logo.png" src="/duelfiassets/logo.png"
alt="Logo" alt="Logo"
width={100} width={120}
height={40} height={40}
className="w-[100px] h-[40px]"
priority priority
/> />
</div> </div>

View File

@ -22,7 +22,7 @@ export default function Leaderboard() {
useEffect(() => { useEffect(() => {
const fetchLeaderboard = async () => { const fetchLeaderboard = async () => {
try { try {
const response = await fetch("https://api.duelfi.io/v1/get_leaderboard.php"); const response = await fetch("/api/v1/get_leaderboard.php");
const data = await response.json(); const data = await response.json();
setLeaderboardData(data); setLeaderboardData(data);
} catch (error) { } catch (error) {

View File

@ -584,7 +584,11 @@ export default function PrivyButton() {
<p className="text-gray-400 text-xs font-mono mb-1">Connected Wallet</p> <p className="text-gray-400 text-xs font-mono mb-1">Connected Wallet</p>
<div className="flex items-center justify-between bg-gray-800 p-2 rounded-md"> <div className="flex items-center justify-between bg-gray-800 p-2 rounded-md">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<p className="font-mono text-sm truncate">{solWallet}</p>
<p className="font-mono text-sm sm:text-sm text-xs">
<span className="hidden sm:inline">{solWallet}</span>
<span className="sm:hidden">{solWallet.slice(0, 30)}...{solWallet.slice(-4)}</span>
</p>
{wallets.some(wallet => wallet.type === "solana" && wallet.address === solWallet && wallet.connectorType === "embedded") && ( {wallets.some(wallet => wallet.type === "solana" && wallet.address === solWallet && wallet.connectorType === "embedded") && (
<span title="Embedded Wallet" className="text-gray-400 hover:text-white transition"> <span title="Embedded Wallet" className="text-gray-400 hover:text-white transition">
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" viewBox="0 0 20 20" fill="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" viewBox="0 0 20 20" fill="currentColor">

View File

@ -54,7 +54,7 @@ export default function YourGames({bets}:GameModalProps) {
} }
}); });
try { try {
const tx = await closeBet(wallet, selectedBet.id, user?.id ?? "na"); const tx = await closeBet(wallet, user?.id ?? "na", selectedBet.id);
const url = EXPLORER_TX_TEMPLATE.replace("{address}", tx); const url = EXPLORER_TX_TEMPLATE.replace("{address}", tx);
connection.confirmTransaction(tx, CONFIRMATION_THRESHOLD).finally(()=>{ connection.confirmTransaction(tx, CONFIRMATION_THRESHOLD).finally(()=>{

View File

@ -11,8 +11,8 @@ export const EXPLORER_ADDRESS_TEMPLATE = "https://explorer.solana.com/address/{a
export const EXPLORER_TX_TEMPLATE = "https://explorer.solana.com/tx/{address}"; export const EXPLORER_TX_TEMPLATE = "https://explorer.solana.com/tx/{address}";
export const connection = new Connection(CLUSTER_URL); export const connection = new Connection(CLUSTER_URL);
export const API_URL = "https://api.duelfi.io/v1/"; export const API_URL = "/api/v1/";
export const API_BASE_URL = "https://api.duelfi.io/"; export const API_BASE_URL = "/api/";
export const VALIDATOR_URL = "https://validator.duelfi.io/"; export const VALIDATOR_URL = "https://validator.duelfi.io/";
export const VALIDATOR_URL_DEV = "https://validatordev.duelfi.io/"; export const VALIDATOR_URL_DEV = "https://validatordev.duelfi.io/";

View File

@ -7,3 +7,10 @@ export async function fetchUserById(id: string) {
return await res.json(); return await res.json();
} }
export async function showNewGameNotification(username:string, game:string, wager:string){
try{
await fetch(`${API_URL}send_telegram_notification.php?username=${username}&wager=${wager}&game=${game}`)
}catch(error){
console.error("Error showing new game notification:", error);
}
}

View File

@ -134,7 +134,7 @@ export async function closeBet(wallets: ConnectedSolanaWallet, uid:string, betI
} }
if (!chosenBet) { if (!chosenBet) {
console.error("Bet not found or not owned by the user"); console.error(`Bet not found or not owned by the user\n${wallets.address}\n${betId}`);
return ""; return "";
} }
@ -207,6 +207,7 @@ export async function createBet(wallets: ConnectedSolanaWallet, uid: string, sel
const txId = await connection.sendRawTransaction(signedTx.serialize()); const txId = await connection.sendRawTransaction(signedTx.serialize());
console.log(`Transaction sent: ${txId}`); console.log(`Transaction sent: ${txId}`);
console.log(`Transaction confirmed: ${txId}`); console.log(`Transaction confirmed: ${txId}`);
if (get_account_address) { if (get_account_address) {
const gameIdBytes = Buffer.from(selectedGame); // selectedGame is a string (game_id) const gameIdBytes = Buffer.from(selectedGame); // selectedGame is a string (game_id)
const nonceBytes = new BN(nonce).toArrayLike(Buffer, "le", 8); // _nonce.to_le_bytes() const nonceBytes = new BN(nonce).toArrayLike(Buffer, "le", 8); // _nonce.to_le_bytes()
@ -239,6 +240,8 @@ export async function createBet(wallets: ConnectedSolanaWallet, uid: string, sel
return ""; return "";
} }
export async function joinBet(wallets: ConnectedSolanaWallet, uid: string, gameId: string, address: string): Promise<string> { export async function joinBet(wallets: ConnectedSolanaWallet, uid: string, gameId: string, address: string): Promise<string> {
const wallet = { const wallet = {
publicKey: new PublicKey(wallets.address), publicKey: new PublicKey(wallets.address),