reward distribution v1
This commit is contained in:
parent
a78c8db008
commit
c37f8f7457
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
|
|
@ -8,12 +8,13 @@ import { HowItWorksModal } from "./HowItWorksModal";
|
||||||
import YourGames from "./YourGames";
|
import YourGames from "./YourGames";
|
||||||
import { Bet } from "@/types/Bet";
|
import { Bet } from "@/types/Bet";
|
||||||
import { fetchOpenBets } from "@/shared/solana_helpers";
|
import { fetchOpenBets } from "@/shared/solana_helpers";
|
||||||
import { usePrivy, useSolanaWallets } from "@privy-io/react-auth";
|
import { ConnectedSolanaWallet, usePrivy, useSolanaWallets } from "@privy-io/react-auth";
|
||||||
|
|
||||||
export default function HeroSection() {
|
export default function HeroSection() {
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||||
const [isGameModalOpen, setIsGameModalOpen] = useState(false);
|
const [isGameModalOpen, setIsGameModalOpen] = useState(false);
|
||||||
const [bets, setBets] = useState<Bet[]>([]);
|
const [bets, setBets] = useState<Bet[]>([]);
|
||||||
|
const [solWallet, setSolWallet] = useState<ConnectedSolanaWallet>();
|
||||||
const [myActiveBet, setMyActiveBet] = useState<Bet>();
|
const [myActiveBet, setMyActiveBet] = useState<Bet>();
|
||||||
const { wallets, ready } = useSolanaWallets();
|
const { wallets, ready } = useSolanaWallets();
|
||||||
const {user} = usePrivy();
|
const {user} = usePrivy();
|
||||||
|
|
@ -22,8 +23,8 @@ export default function HeroSection() {
|
||||||
if (!ready || wallets.length === 0) return;
|
if (!ready || wallets.length === 0) return;
|
||||||
|
|
||||||
// Find the wallet to use (either Solana wallet or the first available wallet)
|
// Find the wallet to use (either Solana wallet or the first available wallet)
|
||||||
let wallet = wallets.find((_wallet) => _wallet.type === "solana") || wallets[0];
|
const wallet = wallets.find((_wallet) => _wallet.type === "solana") || wallets[0];
|
||||||
|
setSolWallet(wallet);
|
||||||
// Fetch the open bets
|
// Fetch the open bets
|
||||||
const fetchedBets = await fetchOpenBets(wallet);
|
const fetchedBets = await fetchOpenBets(wallet);
|
||||||
|
|
||||||
|
|
@ -62,7 +63,7 @@ export default function HeroSection() {
|
||||||
// Render Unity WebGL game when myActiveBet is found
|
// Render Unity WebGL game when myActiveBet is found
|
||||||
<div className="w-full h-screen flex justify-center items-center bg-black">
|
<div className="w-full h-screen flex justify-center items-center bg-black">
|
||||||
<iframe
|
<iframe
|
||||||
src={`/UnityBuild/${myActiveBet.id}/index.html?betId=${myActiveBet.id}&owner=${myActiveBet.owner_id}&joiner=${myActiveBet.joiner_id}&address=${myActiveBet.address}`} // Change this to the actual path of your Unity WebGL build
|
src={`/UnityBuild/${myActiveBet.id}/index.html?betId=${myActiveBet.id}&owner=${myActiveBet.owner_id}&joiner=${myActiveBet.joiner_id}&address=${myActiveBet.address}&uid=${user?.id}&pubkey=${solWallet?.address}`} // Change this to the actual path of your Unity WebGL build
|
||||||
className="w-full h-full"
|
className="w-full h-full"
|
||||||
allowFullScreen
|
allowFullScreen
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ export default function YourGames({ bets }: GameModalProps) {
|
||||||
|
|
||||||
<div className="flex justify-between text-xs font-mono py-1">
|
<div className="flex justify-between text-xs font-mono py-1">
|
||||||
<p className="text-white">{bet.wager} SOL</p>
|
<p className="text-white">{bet.wager} SOL</p>
|
||||||
<p className="text-white">{(bet.wager * 2).toFixed(2)} SOL</p>
|
<p className="text-white">{(bet.wager * 2 * 0.95).toFixed(2)} SOL</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{bet.ownerProfile && (
|
{bet.ownerProfile && (
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,10 @@ export type Bets = {
|
||||||
"name": "betVault",
|
"name": "betVault",
|
||||||
"writable": true
|
"writable": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "feeWallet",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "winner",
|
"name": "winner",
|
||||||
"writable": true
|
"writable": true
|
||||||
|
|
@ -252,8 +256,8 @@ export type Bets = {
|
||||||
"errors": [
|
"errors": [
|
||||||
{
|
{
|
||||||
"code": 6000,
|
"code": 6000,
|
||||||
"name": "betNotFilled",
|
"name": "customError",
|
||||||
"msg": "Bet is not filled yet!"
|
"msg": "Custom error message"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"types": [
|
"types": [
|
||||||
|
|
@ -305,6 +309,11 @@ export type Bets = {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"constants": [
|
"constants": [
|
||||||
|
{
|
||||||
|
"name": "feeCollector",
|
||||||
|
"type": "string",
|
||||||
|
"value": "\"cocD4r4yNpHxPq7CzUebxEMyLki3X4d2Y3HcTX5ptUc\""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "seed",
|
"name": "seed",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@
|
||||||
"name": "bet_vault",
|
"name": "bet_vault",
|
||||||
"writable": true
|
"writable": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "fee_wallet",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "winner",
|
"name": "winner",
|
||||||
"writable": true
|
"writable": true
|
||||||
|
|
@ -246,8 +250,8 @@
|
||||||
"errors": [
|
"errors": [
|
||||||
{
|
{
|
||||||
"code": 6000,
|
"code": 6000,
|
||||||
"name": "BetNotFilled",
|
"name": "CustomError",
|
||||||
"msg": "Bet is not filled yet!"
|
"msg": "Custom error message"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"types": [
|
"types": [
|
||||||
|
|
@ -299,10 +303,15 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"constants": [
|
"constants": [
|
||||||
|
{
|
||||||
|
"name": "FEE_COLLECTOR",
|
||||||
|
"type": "string",
|
||||||
|
"value": "\"cocD4r4yNpHxPq7CzUebxEMyLki3X4d2Y3HcTX5ptUc\""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SEED",
|
"name": "SEED",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": "\"anchor\""
|
"value": "\"anchor\""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
3
src/shared/constants.ts
Normal file
3
src/shared/constants.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
import { PublicKey } from "@solana/web3.js";
|
||||||
|
|
||||||
|
export const FEE_COLLECTOR_PUBKEY = new PublicKey("cocD4r4yNpHxPq7CzUebxEMyLki3X4d2Y3HcTX5ptUc");
|
||||||
|
|
@ -7,6 +7,7 @@ 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";
|
||||||
import { Game } from "@/types/Game";
|
import { Game } from "@/types/Game";
|
||||||
|
import { FEE_COLLECTOR_PUBKEY } from "./constants";
|
||||||
|
|
||||||
export const fetchOpenBets = async (wallets: ConnectedSolanaWallet): Promise<Bet[]> => {
|
export const fetchOpenBets = async (wallets: ConnectedSolanaWallet): Promise<Bet[]> => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -101,6 +102,7 @@ export const fetchOpenBets = async (wallets: ConnectedSolanaWallet): Promise<Bet
|
||||||
betVault: chosenBet,
|
betVault: chosenBet,
|
||||||
betsList: bet_list_pda,
|
betsList: bet_list_pda,
|
||||||
winner: winner,
|
winner: winner,
|
||||||
|
feeWallet: FEE_COLLECTOR_PUBKEY
|
||||||
})
|
})
|
||||||
.transaction();
|
.transaction();
|
||||||
tx.feePayer = new PublicKey(wallets.address);
|
tx.feePayer = new PublicKey(wallets.address);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user