From 466bb0e8356b0d24ebc027361db0cf0f053fa723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nishan=20=28o=5E=E2=96=BD=5Eo=29?= Date: Thu, 16 Nov 2023 00:46:09 +0530 Subject: [PATCH] allow fund wallet (#2529) --- .../creator-token/buy-creator-token.tsx | 49 +++++++++++++++---- packages/app/lib/privy/privy-provider.web.tsx | 3 ++ 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/packages/app/components/creator-token/buy-creator-token.tsx b/packages/app/components/creator-token/buy-creator-token.tsx index 2209a513f..59710e31b 100644 --- a/packages/app/components/creator-token/buy-creator-token.tsx +++ b/packages/app/components/creator-token/buy-creator-token.tsx @@ -1,17 +1,14 @@ import { useState, useEffect } from "react"; import { Linking } from "react-native"; +import { useWallets } from "@privy-io/react-auth"; import { createParam } from "solito"; import { Avatar } from "@showtime-xyz/universal.avatar"; import { BottomSheetModalProvider } from "@showtime-xyz/universal.bottom-sheet"; import { Button } from "@showtime-xyz/universal.button"; import { useIsDarkMode } from "@showtime-xyz/universal.hooks"; -import { - Ethereum, - InformationCircle, - LockBadge, -} from "@showtime-xyz/universal.icon"; +import { InformationCircle, LockBadge } from "@showtime-xyz/universal.icon"; import { Image } from "@showtime-xyz/universal.image"; import { ModalSheet } from "@showtime-xyz/universal.modal-sheet"; import { Pressable } from "@showtime-xyz/universal.pressable"; @@ -79,6 +76,8 @@ export const BuyCreatorToken = () => { const [username] = useParam("username"); const [selectedActionParam] = useParam("selectedAction"); const [tokenAmount, setTokenAmount] = useState(1); + const { wallets } = useWallets(); + const isPrivyWalletConnected = wallets?.[0]?.walletClientType === "privy"; const { data: profileData } = useUserProfile({ address: username }); const sellToken = useCreatorTokenSell(); @@ -158,9 +157,25 @@ export const BuyCreatorToken = () => { ); } else if ( paymentMethod === "USDC" && - usdcBalance.data?.balance === 0n && - !wallet.isMagicWallet + Number(usdcBalance.data?.balance) === 0 ) { + if (isPrivyWalletConnected) { + return ( + + ); + } + return ( + ); + } + return (