Merge remote-tracking branch 'origin/dev'

This commit is contained in:
Sewmina 2025-05-18 20:05:21 +00:00
commit ad8fb39db2
6 changed files with 19 additions and 7 deletions

View File

@ -13,7 +13,7 @@ import { games } from "@/data/games";
import { WAGER_PRIZE_MULT } from "@/shared/constants";
import { EXPLORER_ADDRESS_TEMPLATE } from "@/data/shared";
const ENABLE_REFERRAL_SYSTEM = false; // Toggle for referral system visibility
const ENABLE_REFERRAL_SYSTEM = true; // Toggle for referral system visibility
interface GameHistory {
ended_time: string;
@ -206,9 +206,21 @@ export default function PrivyButton() {
wallets.forEach((wallet) => {
if (wallet.type === "solana") {
setSolWallet(wallet.address);
updateActiveWallet(wallet.address);
}
});
}
const updateActiveWallet = async (walletAddress: string) => {
if(walletAddress.length < 10){
return;
}
const updateUrl = `${API_URL}update_active_wallet.php?id=${user?.id}&wallet=${walletAddress}`;
const response = await fetch(updateUrl);
const data = await response.text();
console.log(`Updated active wallet to ${walletAddress}, response: ${data}`);
}
const fetchSolBalance = async () => {
updateSolWallet();
@ -719,10 +731,10 @@ export default function PrivyButton() {
<div className="flex items-center justify-between mb-4">
<div className="flex items-center gap-2">
<p className="text-gray-400 text-sm">Your Referral ID:</p>
<p className="font-mono text-sm">{user?.id?.slice(0, 8)}</p>
<p className="font-mono text-sm">{refId}</p>
<button
onClick={() => {
navigator.clipboard.writeText(user?.id || '');
navigator.clipboard.writeText(refId.toString());
toast.success('Referral ID copied!');
}}
className="text-gray-400 hover:text-white transition p-1"
@ -734,7 +746,7 @@ export default function PrivyButton() {
</div>
<button
onClick={() => {
const referralLink = `${window.location.origin}?ref=${user?.id}`;
const referralLink = `${window.location.origin}?ref=${refId}`;
navigator.clipboard.writeText(referralLink);
toast.success('Referral link copied!');
}}
@ -748,10 +760,10 @@ export default function PrivyButton() {
</div>
<div className="flex items-center justify-between">
<div className="flex items-center gap-4">
<div>
{/* <div>
<p className="text-gray-400 text-xs">Referral Earnings</p>
<p className="text-lg font-semibold">{referralStats.earnings.toFixed(2)} SOL</p>
</div>
</div> */}
<div>
<p className="text-gray-400 text-xs">Total Referrals</p>
<p className="text-lg font-semibold">{referralStats.count}</p>

View File

@ -1,4 +1,4 @@
import { Connection } from "@solana/web3.js";
import { Connection } from "@solana/web3.js";
// Replace this URL with your dedicated RPC endpoint
// You can get one from providers like QuickNode, Alchemy, Helius, or GenesysGo