optimized
This commit is contained in:
parent
f0aeadbc0c
commit
145b7946f8
|
|
@ -3,7 +3,6 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import OpenGames from "./OpenGames";
|
import OpenGames from "./OpenGames";
|
||||||
import { Game, games } from "../data/games";
|
|
||||||
import GameModal from "./GameModal";
|
import GameModal from "./GameModal";
|
||||||
import { HowItWorksModal } from "./HowItWorksModal";
|
import { HowItWorksModal } from "./HowItWorksModal";
|
||||||
import YourGames from "./YourGames";
|
import YourGames from "./YourGames";
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import { fetchOpenBets } from "@/shared/solana_helpers";
|
||||||
import {Bet} from "../types/Bet";
|
import {Bet} from "../types/Bet";
|
||||||
export default function YourGames() {
|
export default function YourGames() {
|
||||||
const { wallets, ready } = useSolanaWallets();
|
const { wallets, ready } = useSolanaWallets();
|
||||||
const [openBets, setOpenBets] = useState<Bet[]>([]);
|
|
||||||
const [myBets, setMyBets] = useState<Bet[]>([]);
|
const [myBets, setMyBets] = useState<Bet[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
|
@ -15,7 +14,6 @@ export default function YourGames() {
|
||||||
const updateBets= async ()=>{
|
const updateBets= async ()=>{
|
||||||
const bets:Bet[] = await fetchOpenBets(wallets[0]);
|
const bets:Bet[] = await fetchOpenBets(wallets[0]);
|
||||||
setMyBets(bets.filter((bet) => bet.owner !== wallets[0].address));
|
setMyBets(bets.filter((bet) => bet.owner !== wallets[0].address));
|
||||||
setOpenBets(bets);
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
console.log(`Got ${bets.length} bets`);
|
console.log(`Got ${bets.length} bets`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import { EXPLORER_TX_TEMPLATE } from "@/data/shared";
|
||||||
|
|
||||||
export default function YourGames() {
|
export default function YourGames() {
|
||||||
const { wallets, ready } = useSolanaWallets();
|
const { wallets, ready } = useSolanaWallets();
|
||||||
const [openBets, setOpenBets] = useState<Bet[]>([]);
|
|
||||||
const [myBets, setMyBets] = useState<Bet[]>([]);
|
const [myBets, setMyBets] = useState<Bet[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [selectedBet, setSelectedBet] = useState<Bet | null>(null);
|
const [selectedBet, setSelectedBet] = useState<Bet | null>(null);
|
||||||
|
|
@ -21,7 +20,6 @@ export default function YourGames() {
|
||||||
const updateBets = async () => {
|
const updateBets = async () => {
|
||||||
const bets: Bet[] = await fetchOpenBets(wallets[0]);
|
const bets: Bet[] = await fetchOpenBets(wallets[0]);
|
||||||
setMyBets(bets.filter((bet) => bet.owner === wallets[0].address));
|
setMyBets(bets.filter((bet) => bet.owner === wallets[0].address));
|
||||||
setOpenBets(bets);
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { CLUSTER_URL } from "@/data/shared";
|
||||||
import { Bets } from "@/idl/bets";
|
import { Bets } from "@/idl/bets";
|
||||||
import { AnchorProvider, BN, Program } from "@coral-xyz/anchor";
|
import { AnchorProvider, BN, Program } from "@coral-xyz/anchor";
|
||||||
import { ConnectedSolanaWallet } from "@privy-io/react-auth";
|
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 idl from "../idl/bets_idl.json";
|
||||||
import { Bet } from "@/types/Bet";
|
import { Bet } from "@/types/Bet";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
|
@ -132,10 +132,7 @@ export async function createBet(wallets:ConnectedSolanaWallet,selectedPrice:numb
|
||||||
});
|
});
|
||||||
|
|
||||||
const program = new Program<Bets>(idl, provider);
|
const program = new Program<Bets>(idl, provider);
|
||||||
const [bet_list_pda] = await PublicKey.findProgramAddress(
|
|
||||||
[Buffer.from("bets_list")],
|
|
||||||
program.programId
|
|
||||||
);
|
|
||||||
try {
|
try {
|
||||||
const nonce = 1;
|
const nonce = 1;
|
||||||
const [bet_list_pda] = await PublicKey.findProgramAddress(
|
const [bet_list_pda] = await PublicKey.findProgramAddress(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user