From 145b7946f8a2ce29a123e675d3a5b01b93c38a91 Mon Sep 17 00:00:00 2001 From: Sewmina Date: Thu, 3 Apr 2025 13:46:19 +0530 Subject: [PATCH] optimized --- src/components/HeroSection.tsx | 1 - src/components/OpenGames.tsx | 2 -- src/components/YourGames.tsx | 2 -- src/shared/solana_helpers.ts | 7 ++----- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/components/HeroSection.tsx b/src/components/HeroSection.tsx index eb51208..40a2e88 100644 --- a/src/components/HeroSection.tsx +++ b/src/components/HeroSection.tsx @@ -3,7 +3,6 @@ import { useState } from "react"; import Image from "next/image"; import OpenGames from "./OpenGames"; -import { Game, games } from "../data/games"; import GameModal from "./GameModal"; import { HowItWorksModal } from "./HowItWorksModal"; import YourGames from "./YourGames"; diff --git a/src/components/OpenGames.tsx b/src/components/OpenGames.tsx index 6729468..e72ad00 100644 --- a/src/components/OpenGames.tsx +++ b/src/components/OpenGames.tsx @@ -7,7 +7,6 @@ import { fetchOpenBets } from "@/shared/solana_helpers"; import {Bet} from "../types/Bet"; export default function YourGames() { const { wallets, ready } = useSolanaWallets(); - const [openBets, setOpenBets] = useState([]); const [myBets, setMyBets] = useState([]); const [loading, setLoading] = useState(true); @@ -15,7 +14,6 @@ export default function YourGames() { const updateBets= async ()=>{ const bets:Bet[] = await fetchOpenBets(wallets[0]); setMyBets(bets.filter((bet) => bet.owner !== wallets[0].address)); - setOpenBets(bets); setLoading(false); console.log(`Got ${bets.length} bets`); } diff --git a/src/components/YourGames.tsx b/src/components/YourGames.tsx index 92451bf..a5dc637 100644 --- a/src/components/YourGames.tsx +++ b/src/components/YourGames.tsx @@ -11,7 +11,6 @@ import { EXPLORER_TX_TEMPLATE } from "@/data/shared"; export default function YourGames() { const { wallets, ready } = useSolanaWallets(); - const [openBets, setOpenBets] = useState([]); const [myBets, setMyBets] = useState([]); const [loading, setLoading] = useState(true); const [selectedBet, setSelectedBet] = useState(null); @@ -21,7 +20,6 @@ export default function YourGames() { const updateBets = async () => { const bets: Bet[] = await fetchOpenBets(wallets[0]); setMyBets(bets.filter((bet) => bet.owner === wallets[0].address)); - setOpenBets(bets); setLoading(false); }; diff --git a/src/shared/solana_helpers.ts b/src/shared/solana_helpers.ts index 6c38817..6df21a0 100644 --- a/src/shared/solana_helpers.ts +++ b/src/shared/solana_helpers.ts @@ -2,7 +2,7 @@ import { CLUSTER_URL } from "@/data/shared"; import { Bets } from "@/idl/bets"; import { AnchorProvider, BN, Program } from "@coral-xyz/anchor"; import { ConnectedSolanaWallet } from "@privy-io/react-auth"; -import { Connection, Keypair, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js"; +import { Connection, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js"; import idl from "../idl/bets_idl.json"; import { Bet } from "@/types/Bet"; import { toast } from "sonner"; @@ -132,10 +132,7 @@ export async function createBet(wallets:ConnectedSolanaWallet,selectedPrice:numb }); const program = new Program(idl, provider); - const [bet_list_pda] = await PublicKey.findProgramAddress( - [Buffer.from("bets_list")], - program.programId - ); + try { const nonce = 1; const [bet_list_pda] = await PublicKey.findProgramAddress(