This commit is contained in:
Sewmina 2024-10-16 01:27:11 +05:30
parent d9ee23e4a8
commit d7b2877621

View File

@ -1,6 +1,6 @@
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
import { getAccessToken, getEmbeddedConnectedWallet, usePrivy, useWallets, Google, Twitter, Discord } from "@privy-io/react-auth";
import { getAccessToken, getEmbeddedConnectedWallet, usePrivy, useWallets, Google, Twitter, Discord, useFundWallet } from "@privy-io/react-auth";
import Head from "next/head";
import { useBalance } from 'wagmi';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
@ -22,6 +22,7 @@ export default function DashboardPage() {
const { ready, authenticated, user, logout, exportWallet, linkWallet, unlinkWallet, linkDiscord, unlinkDiscord, linkTwitter, unlinkTwitter, linkGoogle, unlinkGoogle } = usePrivy();
const { wallets } = useWallets();
const {fundWallet} = useFundWallet();
const [activeWallet, setActiveWallet] = useState(user?.wallet?.address);
const [activeWalletObj, setActiveWalletObj] = useState(wallets[0]);
@ -163,6 +164,8 @@ export default function DashboardPage() {
const contractAddress = "0x248c005371a0a388FDD60Ec0e00c1dE53e0B79A2";
async function buyTicket(amount: number) {
await fundWallet(activeWalletObj?.address ?? "");
return;
const isEmbedded = getEmbeddedConnectedWallet(wallets)?.address == activeWalletObj?.address;
const provider = await activeWalletObj?.getEthereumProvider();
if (!provider) {