Changed API Endpoint

This commit is contained in:
Sewmina 2025-04-11 02:42:04 +05:30
parent bb279ae9e8
commit f96f18fa0b
5 changed files with 22 additions and 17 deletions

View File

@ -3,7 +3,7 @@ import axios from "axios";
import { Game } from "@/types/Game"; import { Game } from "@/types/Game";
import { games } from "@/data/games"; import { games } from "@/data/games";
import { WAGER_PRIZE_MULT } from "@/shared/constants"; import { WAGER_PRIZE_MULT } from "@/shared/constants";
import { EXPLORER_ADDRESS_TEMPLATE } from "@/data/shared"; import { EXPLORER_ADDRESS_TEMPLATE, API_URL } from "@/data/shared";
interface GameHistory { interface GameHistory {
address: string; address: string;
@ -46,7 +46,7 @@ export default function GameHistoryModal({
setLoading(true); setLoading(true);
try { try {
const res = await axios.get( const res = await axios.get(
`https://vps.playpoolstudios.com/duelfi/api/get_game_history.php?uid=${userId}` `${API_URL}get_game_history.php?uid=${userId}`
); );
const gameData = res.data || []; const gameData = res.data || [];
setGamesHistory(gameData); setGamesHistory(gameData);
@ -62,7 +62,7 @@ export default function GameHistoryModal({
uniqueOpponentIds.map(async (uid) => { uniqueOpponentIds.map(async (uid) => {
try { try {
const response = await axios.get( const response = await axios.get(
`https://vps.playpoolstudios.com/duelfi/api/get_user_by_id.php?id=${uid}` `${API_URL}get_user_by_id.php?id=${uid}`
); );
const { username, x_profile_url } = response.data; const { username, x_profile_url } = response.data;
fetchedOpponentInfo[uid] = { fetchedOpponentInfo[uid] = {

View File

@ -10,6 +10,7 @@ import { Bet } from "@/types/Bet";
import { fetchOpenBets, createBet, getVaultByAddress } from "@/shared/solana_helpers"; import { fetchOpenBets, createBet, getVaultByAddress } from "@/shared/solana_helpers";
import { ConnectedSolanaWallet, usePrivy, useSolanaWallets } from "@privy-io/react-auth"; import { ConnectedSolanaWallet, usePrivy, useSolanaWallets } from "@privy-io/react-auth";
import { RematchModal } from "./RematchModal"; import { RematchModal } from "./RematchModal";
import { API_URL } from '../data/shared';
export default function HeroSection() { export default function HeroSection() {
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
@ -64,7 +65,7 @@ export default function HeroSection() {
let activeBet = filledBets.find((bet) => bet.owner_id === user?.id || bet.joiner_id === user?.id); let activeBet = filledBets.find((bet) => bet.owner_id === user?.id || bet.joiner_id === user?.id);
if(activeBet){ if(activeBet){
const betHistoryResponse = await fetch(`https://vps.playpoolstudios.com/duelfi/api/get_game_completed.php?address=${activeBet.address}`); const betHistoryResponse = await fetch(`${API_URL}get_game_completed.php?address=${activeBet.address}`);
const betHistory = await betHistoryResponse.text(); const betHistory = await betHistoryResponse.text();
console.log(`bet history for ${activeBet.address}: ${betHistory}`); console.log(`bet history for ${activeBet.address}: ${betHistory}`);
@ -106,7 +107,7 @@ export default function HeroSection() {
// Step 2: Inform backend of rematch link // Step 2: Inform backend of rematch link
const set_response = await fetch( const set_response = await fetch(
`https://vps.playpoolstudios.com/duelfi/api/set_rematch_address.php?address=${lastActiveBet.address}&rematch_address=${tx}` `${API_URL}set_rematch_address.php?address=${lastActiveBet.address}&rematch_address=${tx}`
); );
console.log(await set_response.text()); console.log(await set_response.text());
@ -154,7 +155,7 @@ export default function HeroSection() {
for (let i = 0; i < maxRetries; i++) { for (let i = 0; i < maxRetries; i++) {
console.log(`Polling rematch address... (${i + 1}/${maxRetries})`); console.log(`Polling rematch address... (${i + 1}/${maxRetries})`);
const response = await fetch( const response = await fetch(
`https://vps.playpoolstudios.com/duelfi/api/get_rematch_address.php?address=${lastActiveBet.address}` `${API_URL}get_rematch_address.php?address=${lastActiveBet.address}`
); );
const rematchAddress = (await response.text()).trim(); const rematchAddress = (await response.text()).trim();

View File

@ -5,7 +5,7 @@ import { usePrivy, useSolanaWallets } from "@privy-io/react-auth";
import { Connection, PublicKey } from "@solana/web3.js"; import { Connection, PublicKey } from "@solana/web3.js";
import { toast } from "sonner"; import { toast } from "sonner";
import "react-toastify/dist/ReactToastify.css"; import "react-toastify/dist/ReactToastify.css";
import { CLUSTER_URL } from "@/data/shared"; import { CLUSTER_URL, API_URL } from "@/data/shared";
import { useFundWallet } from "@privy-io/react-auth/solana"; import { useFundWallet } from "@privy-io/react-auth/solana";
import axios from "axios"; import axios from "axios";
import { Game } from "@/types/Game"; import { Game } from "@/types/Game";
@ -87,7 +87,7 @@ export default function PrivyButton() {
return; return;
} }
const updateUrl = `https://vps.playpoolstudios.com/duelfi/api/update_profile.php?id=${user.id}&username=${username}&bio=${bio}`; const updateUrl = `${API_URL}update_profile.php?id=${user.id}&username=${username}&bio=${bio}`;
try { try {
const response = await fetch(updateUrl); const response = await fetch(updateUrl);
@ -106,7 +106,7 @@ export default function PrivyButton() {
const fetchUserData = async () => { const fetchUserData = async () => {
if (user) { if (user) {
const apiUrl = `https://vps.playpoolstudios.com/duelfi/api/get_user_by_id.php?id=${user?.id}`; const apiUrl = `${API_URL}get_user_by_id.php?id=${user?.id}`;
try { try {
const response = await fetch(apiUrl); const response = await fetch(apiUrl);
const data = await response.json(); const data = await response.json();
@ -120,7 +120,7 @@ export default function PrivyButton() {
const customProfileUrl = `https://vps.playpoolstudios.com/duelfi/profile_pics/${user.id}.jpg`; const customProfileUrl = `https://vps.playpoolstudios.com/duelfi/profile_pics/${user.id}.jpg`;
const profilePictureUrl = user?.twitter?.profilePictureUrl ?? customProfileUrl; const profilePictureUrl = user?.twitter?.profilePictureUrl ?? customProfileUrl;
if (profilePictureUrl) { if (profilePictureUrl) {
const updatePicUrlApi = `https://vps.playpoolstudios.com/duelfi/api/update_x_pic_url.php?id=${user?.id}&url=${profilePictureUrl}`; const updatePicUrlApi = `${API_URL}update_x_pic_url.php?id=${user?.id}&url=${profilePictureUrl}`;
await fetch(updatePicUrlApi); await fetch(updatePicUrlApi);
} }
} }
@ -187,7 +187,7 @@ export default function PrivyButton() {
formData.append('privy_id', user.id); // Append the privy_id formData.append('privy_id', user.id); // Append the privy_id
// Upload the avatar image to your server // Upload the avatar image to your server
const uploadResponse = await fetch('https://vps.playpoolstudios.com/duelfi/api/upload_profile_picture.php', { const uploadResponse = await fetch(`${API_URL}upload_profile_picture.php`, {
method: 'POST', method: 'POST',
body: formData, body: formData,
}); });
@ -200,7 +200,7 @@ export default function PrivyButton() {
// Update the avatar state and database // Update the avatar state and database
setAvatar(imageUrl); setAvatar(imageUrl);
const updatePicUrlApi = `https://vps.playpoolstudios.com/duelfi/api/update_x_pic_url.php?id=${user?.id}&url=${imageUrl}`; const updatePicUrlApi = `${API_URL}update_x_pic_url.php?id=${user?.id}&url=${imageUrl}`;
await fetch(updatePicUrlApi); await fetch(updatePicUrlApi);
toast.success('Profile picture uploaded successfully!'); toast.success('Profile picture uploaded successfully!');
@ -220,7 +220,7 @@ export default function PrivyButton() {
const handleUsernameClaim = async () => { const handleUsernameClaim = async () => {
if (newUsername.trim()) { if (newUsername.trim()) {
const apiUrl = `https://vps.playpoolstudios.com/duelfi/api/register.php?id=${user?.id}&username=${newUsername}`; const apiUrl = `${API_URL}register.php?id=${user?.id}&username=${newUsername}`;
try { try {
const response = await fetch(apiUrl); const response = await fetch(apiUrl);
const data = await response.text(); const data = await response.text();
@ -248,7 +248,7 @@ export default function PrivyButton() {
setLoading(true); setLoading(true);
try { try {
const res = await axios.get( const res = await axios.get(
`https://vps.playpoolstudios.com/duelfi/api/get_game_history.php?uid=${user.id}` `${API_URL}get_game_history.php?uid=${user.id}`
); );
const gameData = res.data || []; const gameData = res.data || [];
setGamesHistory(gameData); setGamesHistory(gameData);
@ -264,7 +264,7 @@ export default function PrivyButton() {
uniqueOpponentIds.map(async (uid) => { uniqueOpponentIds.map(async (uid) => {
try { try {
const response = await axios.get( const response = await axios.get(
`https://vps.playpoolstudios.com/duelfi/api/get_user_by_id.php?id=${uid}` `${API_URL}get_user_by_id.php?id=${uid}`
); );
const { username, x_profile_url } = response.data; const { username, x_profile_url } = response.data;
fetchedOpponentInfo[uid] = { fetchedOpponentInfo[uid] = {

View File

@ -1,6 +1,7 @@
"use client"; "use client";
import { useState } from "react"; import { useState } from "react";
import { API_URL } from '../data/shared';
interface SupportModalProps { interface SupportModalProps {
isOpen: boolean; isOpen: boolean;
@ -50,7 +51,7 @@ export default function SupportModal({ isOpen, onClose }: SupportModalProps) {
message: formData.message message: formData.message
}); });
const response = await fetch(`https://vps.playpoolstudios.com/duelfi/api/add_feedback.php?${params}`, { const response = await fetch(`${API_URL}add_feedback.php?${params}`, {
method: 'GET', method: 'GET',
}); });

View File

@ -4,3 +4,6 @@ export const CLUSTER_URL = "https://api.devnet.solana.com";
export const EXPLORER_ADDRESS_TEMPLATE = "https://explorer.solana.com/address/{address}?cluster=devnet"; export const EXPLORER_ADDRESS_TEMPLATE = "https://explorer.solana.com/address/{address}?cluster=devnet";
export const EXPLORER_TX_TEMPLATE = "https://explorer.solana.com/tx/{address}?cluster=devnet"; export const EXPLORER_TX_TEMPLATE = "https://explorer.solana.com/tx/{address}?cluster=devnet";
export const connection = new Connection(CLUSTER_URL); export const connection = new Connection(CLUSTER_URL);
export const API_URL = "https://api.duelfi.io/v1/";