polished
This commit is contained in:
parent
bb0b9a2142
commit
7a09838a46
|
|
@ -3,7 +3,15 @@ import type { NextConfig } from "next";
|
|||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
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*',
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3031",
|
||||
"dev": "next dev -p 3030",
|
||||
"build": "next build",
|
||||
"start": "next start -p 3031",
|
||||
"start": "next start -p 3030",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { createBet } from "@/shared/solana_helpers";
|
|||
import { Game } from "@/types/Game";
|
||||
import { connection, EXPLORER_TX_TEMPLATE } from "@/data/shared";
|
||||
import { CONFIRMATION_THRESHOLD } from "@/shared/constants";
|
||||
|
||||
import { fetchUserById, showNewGameNotification } from "@/shared/data_fetcher";
|
||||
interface GameModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
|
|
@ -64,6 +64,7 @@ export default function GameModal({ isOpen, onClose }: GameModalProps) {
|
|||
setIsProcessing(true);
|
||||
toast.loading("Creating Game");
|
||||
try {
|
||||
const ownerProfile = await fetchUserById(user?.id ?? "");
|
||||
const tx = await createBet(wallet, user?.id ?? "", selectedPrice, selectedGame.id, false);
|
||||
const url = EXPLORER_TX_TEMPLATE.replace("{address}", tx);
|
||||
if (tx.length > 5) {
|
||||
|
|
@ -77,6 +78,8 @@ export default function GameModal({ isOpen, onClose }: GameModalProps) {
|
|||
},
|
||||
});
|
||||
|
||||
showNewGameNotification(ownerProfile?.username ?? "", selectedGame.name, selectedPrice.toString());
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,8 @@ export default function Header() {
|
|||
<Image
|
||||
src="/duelfiassets/logo.png"
|
||||
alt="Logo"
|
||||
width={100}
|
||||
width={120}
|
||||
height={40}
|
||||
className="w-[100px] h-[40px]"
|
||||
priority
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export default function Leaderboard() {
|
|||
useEffect(() => {
|
||||
const fetchLeaderboard = async () => {
|
||||
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();
|
||||
setLeaderboardData(data);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -584,7 +584,11 @@ export default function PrivyButton() {
|
|||
<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 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") && (
|
||||
<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">
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ export default function YourGames({bets}:GameModalProps) {
|
|||
}
|
||||
});
|
||||
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);
|
||||
connection.confirmTransaction(tx, CONFIRMATION_THRESHOLD).finally(()=>{
|
||||
|
|
|
|||
|
|
@ -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 connection = new Connection(CLUSTER_URL);
|
||||
|
||||
export const API_URL = "https://api.duelfi.io/v1/";
|
||||
export const API_BASE_URL = "https://api.duelfi.io/";
|
||||
export const API_URL = "/api/v1/";
|
||||
export const API_BASE_URL = "/api/";
|
||||
export const VALIDATOR_URL = "https://validator.duelfi.io/";
|
||||
export const VALIDATOR_URL_DEV = "https://validatordev.duelfi.io/";
|
||||
|
||||
|
|
|
|||
|
|
@ -7,3 +7,10 @@ export async function fetchUserById(id: string) {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ export async function closeBet(wallets: ConnectedSolanaWallet, uid:string, betI
|
|||
}
|
||||
|
||||
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 "";
|
||||
}
|
||||
|
||||
|
|
@ -207,6 +207,7 @@ export async function createBet(wallets: ConnectedSolanaWallet, uid: string, sel
|
|||
const txId = await connection.sendRawTransaction(signedTx.serialize());
|
||||
console.log(`Transaction sent: ${txId}`);
|
||||
console.log(`Transaction confirmed: ${txId}`);
|
||||
|
||||
if (get_account_address) {
|
||||
const gameIdBytes = Buffer.from(selectedGame); // selectedGame is a string (game_id)
|
||||
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 "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function joinBet(wallets: ConnectedSolanaWallet, uid: string, gameId: string, address: string): Promise<string> {
|
||||
const wallet = {
|
||||
publicKey: new PublicKey(wallets.address),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user