Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions app/components/FundWalletForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import {
ArrowDown01Icon,
InformationSquareIcon,
} from "hugeicons-react";
import { usePrivy } from "@privy-io/react-auth";
import { usePrivy, useWallets } from "@privy-io/react-auth";
import { useSmartWallets } from "@privy-io/react-auth/smart-wallets";
import { useShouldUseEOA } from "../hooks/useEIP7702Account";
import { Token } from "../types";
import Image from "next/image";

Expand All @@ -36,6 +37,8 @@ export const FundWalletForm: React.FC<{
const { allTokens } = useTokens();
const { handleFundWallet } = useFundWalletHandler("Fund wallet form");
const { user } = usePrivy();
const { wallets } = useWallets();
const shouldUseEOA = useShouldUseEOA();
const useInjectedWallet = shouldUseInjectedWallet(searchParams);
const isDark = useActualTheme();

Expand Down Expand Up @@ -134,7 +137,16 @@ export const FundWalletForm: React.FC<{
const smartWalletAccount = user?.linkedAccounts?.find(
(account) => account.type === "smart_wallet",
);
const walletAddress = smartWalletAccount?.address ?? "";
const embeddedWallet = wallets.find((w) => w.walletClientType === "privy");
const walletAddress = shouldUseEOA
? (embeddedWallet?.address ?? "")
: (smartWalletAccount?.address ?? "");

if (!walletAddress) {
setIsFundConfirming(false);
toast.error("Wallet not ready. Please try again.");
return;
}
setFundingInProgress(true);
await handleFundWallet(
walletAddress,
Expand Down