Changed API Endpoint
This commit is contained in:
parent
bb279ae9e8
commit
f96f18fa0b
|
|
@ -3,7 +3,7 @@ import axios from "axios";
|
|||
import { Game } from "@/types/Game";
|
||||
import { games } from "@/data/games";
|
||||
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 {
|
||||
address: string;
|
||||
|
|
@ -46,7 +46,7 @@ export default function GameHistoryModal({
|
|||
setLoading(true);
|
||||
try {
|
||||
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 || [];
|
||||
setGamesHistory(gameData);
|
||||
|
|
@ -62,7 +62,7 @@ export default function GameHistoryModal({
|
|||
uniqueOpponentIds.map(async (uid) => {
|
||||
try {
|
||||
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;
|
||||
fetchedOpponentInfo[uid] = {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { Bet } from "@/types/Bet";
|
|||
import { fetchOpenBets, createBet, getVaultByAddress } from "@/shared/solana_helpers";
|
||||
import { ConnectedSolanaWallet, usePrivy, useSolanaWallets } from "@privy-io/react-auth";
|
||||
import { RematchModal } from "./RematchModal";
|
||||
import { API_URL } from '../data/shared';
|
||||
|
||||
export default function HeroSection() {
|
||||
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);
|
||||
|
||||
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();
|
||||
|
||||
console.log(`bet history for ${activeBet.address}: ${betHistory}`);
|
||||
|
|
@ -106,7 +107,7 @@ export default function HeroSection() {
|
|||
|
||||
// Step 2: Inform backend of rematch link
|
||||
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());
|
||||
|
||||
|
|
@ -154,7 +155,7 @@ export default function HeroSection() {
|
|||
for (let i = 0; i < maxRetries; i++) {
|
||||
console.log(`Polling rematch address... (${i + 1}/${maxRetries})`);
|
||||
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();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { usePrivy, useSolanaWallets } from "@privy-io/react-auth";
|
|||
import { Connection, PublicKey } from "@solana/web3.js";
|
||||
import { toast } from "sonner";
|
||||
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 axios from "axios";
|
||||
import { Game } from "@/types/Game";
|
||||
|
|
@ -87,7 +87,7 @@ export default function PrivyButton() {
|
|||
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 {
|
||||
const response = await fetch(updateUrl);
|
||||
|
|
@ -106,7 +106,7 @@ export default function PrivyButton() {
|
|||
|
||||
const fetchUserData = async () => {
|
||||
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 {
|
||||
const response = await fetch(apiUrl);
|
||||
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 profilePictureUrl = user?.twitter?.profilePictureUrl ?? customProfileUrl;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -187,7 +187,7 @@ export default function PrivyButton() {
|
|||
formData.append('privy_id', user.id); // Append the privy_id
|
||||
|
||||
// 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',
|
||||
body: formData,
|
||||
});
|
||||
|
|
@ -200,7 +200,7 @@ export default function PrivyButton() {
|
|||
|
||||
// Update the avatar state and database
|
||||
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);
|
||||
|
||||
toast.success('Profile picture uploaded successfully!');
|
||||
|
|
@ -220,7 +220,7 @@ export default function PrivyButton() {
|
|||
|
||||
const handleUsernameClaim = async () => {
|
||||
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 {
|
||||
const response = await fetch(apiUrl);
|
||||
const data = await response.text();
|
||||
|
|
@ -248,7 +248,7 @@ export default function PrivyButton() {
|
|||
setLoading(true);
|
||||
try {
|
||||
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 || [];
|
||||
setGamesHistory(gameData);
|
||||
|
|
@ -264,7 +264,7 @@ export default function PrivyButton() {
|
|||
uniqueOpponentIds.map(async (uid) => {
|
||||
try {
|
||||
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;
|
||||
fetchedOpponentInfo[uid] = {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { API_URL } from '../data/shared';
|
||||
|
||||
interface SupportModalProps {
|
||||
isOpen: boolean;
|
||||
|
|
@ -50,7 +51,7 @@ export default function SupportModal({ isOpen, onClose }: SupportModalProps) {
|
|||
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',
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -3,4 +3,7 @@ import { Connection } from "@solana/web3.js";
|
|||
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_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/";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user