diff --git a/src/app/(walletConnected)/layout.tsx b/src/app/(walletConnected)/layout.tsx deleted file mode 100644 index ee6302b..0000000 --- a/src/app/(walletConnected)/layout.tsx +++ /dev/null @@ -1,52 +0,0 @@ -'use client' - -import { useWallet } from '@bbachain/wallet-adapter-react' -import { CiWallet } from 'react-icons/ci' - -import ThemeImage from '@/components/common/ThemeImage' -import { Button } from '@/components/ui/button' -import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@/components/ui/card' -import { useWalletListDialog } from '@/stores/walletDialog' - -export default function WalletConnectedLayout({ children }: { children: React.ReactNode }) { - const { publicKey: address } = useWallet() - const { openWalletList } = useWalletListDialog() - - if (!address) - return ( -
- - - Wallet Not Connected - - - -

- Please connect your wallet to use the Quick Token
Generator and access - features. -

-
- - - -
-
- ) - - return
{children}
-} diff --git a/src/app/(walletConnected)/liquidity-pools/create-pool/page.tsx b/src/app/liquidity-pools/create-pool/page.tsx similarity index 93% rename from src/app/(walletConnected)/liquidity-pools/create-pool/page.tsx rename to src/app/liquidity-pools/create-pool/page.tsx index 2327834..30c9eef 100644 --- a/src/app/(walletConnected)/liquidity-pools/create-pool/page.tsx +++ b/src/app/liquidity-pools/create-pool/page.tsx @@ -1,16 +1,17 @@ 'use client' +import { useWallet } from '@bbachain/wallet-adapter-react' import { zodResolver } from '@hookform/resolvers/zod' import { ChevronDown, ArrowLeft, ArrowRight, Info, Loader2, AlertCircle } from 'lucide-react' import Image from 'next/image' import { useEffect, useState, useCallback } from 'react' import { useForm } from 'react-hook-form' import toast from 'react-hot-toast' +import { CiWallet } from 'react-icons/ci' import { FaChartArea } from 'react-icons/fa' import { FaPlus } from 'react-icons/fa6' import { IoSettings } from 'react-icons/io5' -import { NoBalanceAlert } from '@/components/common/Alert' import { Button } from '@/components/ui/button' import { Card, @@ -41,10 +42,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/comp import LPSuccessDialog from '@/features/liquidityPool/components/LPSuccessDialog' import { useCreatePool } from '@/features/liquidityPool/services' import { TCreatePoolPayload, MintInfo } from '@/features/liquidityPool/types' -import { - isBBAPool, - getBBAPositionInPool, -} from '@/features/liquidityPool/utils' +import { isBBAPool, getBBAPositionInPool } from '@/features/liquidityPool/utils' import { createPoolValidation } from '@/features/liquidityPool/validation' import { LoadingDialog } from '@/features/nfts/components/StatusDialog' import SwapItem from '@/features/swap/components/SwapItem' @@ -57,8 +55,8 @@ import { getCoinGeckoId } from '@/lib/token' import { formatTokenBalance } from '@/lib/token' import { cn } from '@/lib/utils' import { useGetTokenBalanceByMint } from '@/services/wallet' -import { useGetBBABalance } from '@/services/wallet' import { useErrorDialog } from '@/stores/errorDialog' +import { useWalletListDialog } from '@/stores/walletDialog' // Enhanced step configuration const createPoolSteps = [ @@ -159,11 +157,9 @@ function TokenSelectionCard({ } export default function CreatePool() { - // Hooks const getTokensQuery = useGetTradeableTokens() const createPoolMutation = useCreatePool() - const getBalanceQuery = useGetBBABalance() - const { openErrorDialog } = useErrorDialog() + const openErrorDialog = useErrorDialog((state) => state.openErrorDialog) // Form setup const form = useForm({ @@ -183,6 +179,10 @@ export default function CreatePool() { } }) + const { publicKey: ownerAddress } = useWallet() + const isWalletConnected = Boolean(ownerAddress) + const openWalletList = useWalletListDialog((state) => state.openWalletList) + // States const [currentStep, setCurrentStep] = useState(0) const [isTokenDialogOpen, setIsTokenDialogOpen] = useState(false) @@ -193,7 +193,6 @@ export default function CreatePool() { const createPoolResponse = createPoolMutation.data?.data const selectedBaseToken = form.watch('baseToken') const selectedQuoteToken = form.watch('quoteToken') - const isNoBalance = getBalanceQuery.isError || !getBalanceQuery.data || getBalanceQuery.data === 0 // BBA Pool Detection const isBBAPoolPair = @@ -404,8 +403,8 @@ export default function CreatePool() { (value: string) => { form.setValue('baseTokenAmount', value, { shouldValidate: true }) - if(value === '') return resetTokenAmounts() - + if (value === '') return resetTokenAmounts() + // Auto-calculate quote amount if both tokens and initial price are set const initialPrice = parseFloat(form.getValues('initialPrice')) if (initialPrice && value && selectedBaseToken && selectedQuoteToken) { @@ -436,20 +435,14 @@ export default function CreatePool() { [form, resetTokenAmounts, selectedBaseToken, selectedQuoteToken] ) - // Show loading state for tokens - return (
- {/* Show balance alert if needed */} - {isNoBalance && } -

Create Liquidity Pool

Create a new liquidity pool for token trading on BBAChain

-
{/* Progress Line */} @@ -1028,45 +1021,59 @@ export default function CreatePool() { )} {/* Navigation Buttons */} - - - + + {isWalletConnected ? ( + <> + + + + ) : ( + + )} diff --git a/src/app/(walletConnected)/liquidity-pools/deposit/[poolId]/page.tsx b/src/app/liquidity-pools/deposit/page.tsx similarity index 87% rename from src/app/(walletConnected)/liquidity-pools/deposit/[poolId]/page.tsx rename to src/app/liquidity-pools/deposit/page.tsx index cd9a4f6..2a47c03 100644 --- a/src/app/(walletConnected)/liquidity-pools/deposit/[poolId]/page.tsx +++ b/src/app/liquidity-pools/deposit/page.tsx @@ -1,10 +1,12 @@ 'use client' +import { useWallet } from '@bbachain/wallet-adapter-react' import { Loader2 } from 'lucide-react' import Image from 'next/image' -import { useRouter } from 'next/navigation' +import { useRouter, useSearchParams } from 'next/navigation' import { useState, useEffect } from 'react' import toast from 'react-hot-toast' +import { CiWallet } from 'react-icons/ci' import { HiOutlineArrowNarrowLeft } from 'react-icons/hi' import { HiOutlineAdjustmentsHorizontal } from 'react-icons/hi2' import { IoCheckmarkCircle } from 'react-icons/io5' @@ -30,6 +32,7 @@ import { useGetTokenPriceByCoinGeckoId } from '@/features/tokens/services' import { formatTokenBalance, getCoinGeckoId } from '@/lib/token' import { cn } from '@/lib/utils' import { useGetTokenBalanceByMint } from '@/services/wallet' +import { useWalletListDialog } from '@/stores/walletDialog' const initialTokeProps: MintInfo = { chainId: 101, @@ -43,8 +46,9 @@ const initialTokeProps: MintInfo = { extensions: {} } -export default function LiquidityPoolDeposit({ params }: { params: { poolId: string } }) { - const poolId = params.poolId +export default function LiquidityPoolDeposit() { + const searchParams = useSearchParams() + const poolId = searchParams.get('poolId') ?? '' const router = useRouter() const getPoolByIdQuery = useGetPoolById({ poolId }) @@ -53,6 +57,10 @@ export default function LiquidityPoolDeposit({ params }: { params: { poolId: str const getUserPoolStats = useGetUserPoolStats({ pool: poolDetailData }) const userStatsData = getUserPoolStats.data?.data + const openWalletList = useWalletListDialog((state) => state.openWalletList) + const { publicKey: ownerAddress } = useWallet() + const isWalletConnected = Boolean(ownerAddress) + const [fromAmount, setFromAmount] = useState('') const [toAmount, setToAmount] = useState('') const [slippage, setSlippage] = useState(1) @@ -320,14 +328,16 @@ export default function LiquidityPoolDeposit({ params }: { params: { poolId: str - - -

- Total value of tokens currently you deposit in this pool, displayed per token. -

-
- - - -
-
- -
- -
- -
- -
+ {isWalletConnected ? ( + <> +
+
+

+ Your Deposits +

+ + + + + +

+ Total value of tokens currently you deposit in this pool, displayed per + token. +

+
+
+
+ +
+
+ +
+ +
+ +
+ +
+ + ) : ( +
+

Please connect your wallet to see your stats

+
+ )} @@ -495,6 +509,11 @@ export default function PoolDetail({ params }: { params: { poolId: string } }) { )} diff --git a/src/app/(walletConnected)/liquidity-pools/page.tsx b/src/app/liquidity-pools/page.tsx similarity index 92% rename from src/app/(walletConnected)/liquidity-pools/page.tsx rename to src/app/liquidity-pools/page.tsx index b0ab5aa..3f28dcd 100644 --- a/src/app/(walletConnected)/liquidity-pools/page.tsx +++ b/src/app/liquidity-pools/page.tsx @@ -61,7 +61,6 @@ function EmptyPoolsState() { export default function LiquidityPools() { const getPoolsQuery = useGetPools() - const getBalanceQuery = useGetBBABalance() const { openErrorDialog } = useErrorDialog() const isMobile = useIsMobile() @@ -69,7 +68,6 @@ export default function LiquidityPools() { if (getPoolsQuery.isSuccess && getPoolsQuery.data) console.log(getPoolsQuery.data?.data) }, [getPoolsQuery.data, getPoolsQuery.isSuccess]) - const isNoBalance = getBalanceQuery.isError || !getBalanceQuery.data || getBalanceQuery.data === 0 const allPoolsData = getPoolsQuery.data ? formatOnchainPoolsForUI(getPoolsQuery.data.data) : [] const statisticData = [ @@ -100,12 +98,6 @@ export default function LiquidityPools() { } }, [getPoolsQuery.isError, getPoolsQuery.error, openErrorDialog]) - // Handle balance errors with toast - useEffect(() => { - if (getBalanceQuery.isError && getBalanceQuery.error) { - toast.error('Failed to load wallet balance') - } - }, [getBalanceQuery.isError, getBalanceQuery.error]) return (
@@ -132,8 +124,6 @@ export default function LiquidityPools() { Create Pool
- {/* Balance Alert */} - {isNoBalance && } {/* Pools Section */}
diff --git a/src/app/(walletConnected)/nfts/[address]/page.tsx b/src/app/nfts/[address]/page.tsx similarity index 100% rename from src/app/(walletConnected)/nfts/[address]/page.tsx rename to src/app/nfts/[address]/page.tsx diff --git a/src/app/(walletConnected)/nfts/collection/create/page.tsx b/src/app/nfts/collection/create/page.tsx similarity index 82% rename from src/app/(walletConnected)/nfts/collection/create/page.tsx rename to src/app/nfts/collection/create/page.tsx index 067e370..9d18fbf 100644 --- a/src/app/(walletConnected)/nfts/collection/create/page.tsx +++ b/src/app/nfts/collection/create/page.tsx @@ -1,12 +1,13 @@ 'use client' +import { useWallet } from '@bbachain/wallet-adapter-react' import { zodResolver } from '@hookform/resolvers/zod' -import { ChevronRight, Loader2 } from 'lucide-react' +import { ChevronRight } from 'lucide-react' import Image from 'next/image' import { useEffect, useState } from 'react' import { useForm } from 'react-hook-form' +import { CiWallet } from 'react-icons/ci' -import { NoBalanceAlert } from '@/components/common/Alert' import { Button } from '@/components/ui/button' import { Card, @@ -33,8 +34,8 @@ import { import { useCreateCollection, useValidateOffChainMetadata } from '@/features/nfts/services' import { TCreateCollectionPayload, TCreateNFTDialogProps } from '@/features/nfts/types' import { CreateCollectionValidation } from '@/features/nfts/validation' -import { useGetBBABalance } from '@/services/wallet' import { useErrorDialog } from '@/stores/errorDialog' +import { useWalletListDialog } from '@/stores/walletDialog' type FieldName = keyof TCreateCollectionPayload @@ -51,8 +52,10 @@ export default function CreateCollection() { const createCollectionMutation = useCreateCollection() const validateMetadataMutation = useValidateOffChainMetadata() - const getBalanceQuery = useGetBBABalance() - const isNoBalance = getBalanceQuery.isError || !getBalanceQuery.data || getBalanceQuery.data === 0 + + const { publicKey: ownerAddress } = useWallet() + const isWalletConnected = Boolean(ownerAddress) + const openWalletList = useWalletListDialog((state) => state.openWalletList) const [step, setStep] = useState(0) const [isSuccessDialogMetadata, setIsSuccessDialogMetadata] = useState(false) @@ -164,11 +167,6 @@ export default function CreateCollection() { mintAddress: createCollectionMutation.data?.data.mintAddress ?? '' }} /> - {isNoBalance && ( -
- -
- )}

Create NFT Collection

@@ -248,15 +246,26 @@ export default function CreateCollection() { )} /> - + {isWalletConnected ? ( + + + + ) : ( - + )} )} @@ -289,16 +298,27 @@ export default function CreateCollection() { )} /> - + {isWalletConnected ? ( + + + + ) : ( - + )} )} diff --git a/src/app/(walletConnected)/nfts/create/page.tsx b/src/app/nfts/create/page.tsx similarity index 85% rename from src/app/(walletConnected)/nfts/create/page.tsx rename to src/app/nfts/create/page.tsx index 48b08a8..38e1384 100644 --- a/src/app/(walletConnected)/nfts/create/page.tsx +++ b/src/app/nfts/create/page.tsx @@ -1,15 +1,16 @@ 'use client' +import { useWallet } from '@bbachain/wallet-adapter-react' import { zodResolver } from '@hookform/resolvers/zod' -import { ChevronRight, Loader2 } from 'lucide-react' -import { useSearchParams, useRouter } from 'next/navigation' +import { ChevronRight } from 'lucide-react' +import { useSearchParams } from 'next/navigation' import { useEffect, useMemo, useState } from 'react' import { useForm } from 'react-hook-form' import toast from 'react-hot-toast' +import { CiWallet } from 'react-icons/ci' import { HiOutlineArrowNarrowLeft } from 'react-icons/hi' import { capitalCase } from 'text-case' -import { NoBalanceAlert } from '@/components/common/Alert' import { Button } from '@/components/ui/button' import { Card, @@ -41,6 +42,7 @@ import { TCreateNFTPayload, TCreateNFTDialogProps } from '@/features/nfts/types' import { CreateNFTValidation } from '@/features/nfts/validation' import { useGetBBABalance } from '@/services/wallet' import { useErrorDialog } from '@/stores/errorDialog' +import { useWalletListDialog } from '@/stores/walletDialog' const initialDialogContent: TCreateNFTDialogProps = { title: '', @@ -63,7 +65,10 @@ export default function CreateNFT() { const getCollectionQuery = useGetCollections() const validateMetadataMutation = useValidateOffChainMetadata() const getBalanceQuery = useGetBBABalance() - const isNoBalance = getBalanceQuery.isError || !getBalanceQuery.data || getBalanceQuery.data === 0 + + const { publicKey: ownerAddress } = useWallet() + const isWalletConnected = Boolean(ownerAddress) + const openWalletList = useWalletListDialog((state) => state.openWalletList) const [step, setStep] = useState<'upload' | 'preview'>('upload') const [isCreateCollection, setIsCreateCollection] = useState(false) @@ -190,11 +195,6 @@ export default function CreateNFT() { description={successDialogProps.description} /> - {isNoBalance && ( -
- -
- )} {step === 'preview' && (
- + {isWalletConnected ? ( + + ) : ( + + )}
@@ -311,15 +322,26 @@ export default function CreateNFT() { )} /> - + {isWalletConnected ? ( + + + + ) : ( - + )} diff --git a/src/app/(walletConnected)/nfts/page.tsx b/src/app/nfts/page.tsx similarity index 79% rename from src/app/(walletConnected)/nfts/page.tsx rename to src/app/nfts/page.tsx index 305db26..ca55e4b 100644 --- a/src/app/(walletConnected)/nfts/page.tsx +++ b/src/app/nfts/page.tsx @@ -1,9 +1,11 @@ 'use client' +import { useWallet } from '@bbachain/wallet-adapter-react' import { ColumnDef } from '@tanstack/react-table' import { useEffect } from 'react' import toast from 'react-hot-toast' +import WalletNotConnectedCard from '@/components/common/WalletNotConnectedCard' import { type NftCardProps } from '@/features/nfts/components/NFTCard' import NFTList from '@/features/nfts/components/NFTList' import { useGetNFTs } from '@/features/nfts/services' @@ -41,6 +43,9 @@ export default function NFTs() { const getNFTQuery = useGetNFTs() const nftMetadata = getNFTQuery.data ? mapToNFTPropsList(getNFTQuery.data.data) : [] + const { publicKey: ownerAddress } = useWallet() + const isWalletConnected = Boolean(ownerAddress) + useEffect(() => { if (getNFTQuery.isError && getNFTQuery.error) toast.error(getNFTQuery.error.message) }, [getNFTQuery.error, getNFTQuery.isError]) @@ -50,7 +55,10 @@ export default function NFTs() {

My NFTs

- + {isWalletConnected && ( + + )} + {!isWalletConnected && } ) } diff --git a/src/app/(walletConnected)/swap/page.tsx b/src/app/swap/page.tsx similarity index 94% rename from src/app/(walletConnected)/swap/page.tsx rename to src/app/swap/page.tsx index b17b779..9f5c97a 100644 --- a/src/app/(walletConnected)/swap/page.tsx +++ b/src/app/swap/page.tsx @@ -1,11 +1,13 @@ 'use client' import { NATIVE_MINT } from '@bbachain/spl-token' +import { useWallet } from '@bbachain/wallet-adapter-react' import { Loader2 } from 'lucide-react' import Image from 'next/image' import { useSearchParams, useRouter } from 'next/navigation' import { useCallback, useEffect, useState } from 'react' import toast from 'react-hot-toast' +import { CiWallet } from 'react-icons/ci' import { IoMdSettings } from 'react-icons/io' import { Button } from '@/components/ui/button' @@ -22,6 +24,7 @@ import { formatTokenBalance, getCoinGeckoId } from '@/lib/token' import { cn } from '@/lib/utils' import { useGetTokenBalanceByMint } from '@/services/wallet' import { USDT_MINT } from '@/staticData/tokens' +import { useWalletListDialog } from '@/stores/walletDialog' const initialTradeableToken: TTradeableTokenProps = { address: '', @@ -33,6 +36,11 @@ const initialTradeableToken: TTradeableTokenProps = { export default function Swap() { const searchParams = useSearchParams() const router = useRouter() + + const { publicKey: ownerAddress } = useWallet() + const isWalletConnected = Boolean(ownerAddress) + const openWalletList = useWalletListDialog((state) => state.openWalletList) + const [amountIn, setAmountIn] = useState('') const [fromTokenProps, setFromTokenProps] = useState(initialTradeableToken) const [toTokenProps, setToTokenProps] = useState(initialTradeableToken) @@ -232,7 +240,8 @@ export default function Swap() { } const buttonDisplay = useCallback(() => { - if (executeSwapMutation.isPending) return 'Swapping...' + if (!isWalletConnected) return 'Connect Wallet' + else if (executeSwapMutation.isPending) return 'Swapping...' else if (isSwapQuoteLoading) return 'Computing...' else if (!isTokenPairValid) return 'Select Different Tokens' else if (!isInputPositive) return 'Enter Valid Amount' @@ -241,6 +250,7 @@ export default function Swap() { else if (isQuoteError) return 'Failed to Get Quote' else return 'Swap' }, [ + isWalletConnected, executeSwapMutation.isPending, isBalanceEnough, isInputPositive, @@ -405,17 +415,17 @@ export default function Swap() { diff --git a/src/app/(walletConnected)/tokens/[address]/page.tsx b/src/app/tokens/[address]/page.tsx similarity index 100% rename from src/app/(walletConnected)/tokens/[address]/page.tsx rename to src/app/tokens/[address]/page.tsx diff --git a/src/app/(walletConnected)/tokens/create/page.tsx b/src/app/tokens/create/page.tsx similarity index 90% rename from src/app/(walletConnected)/tokens/create/page.tsx rename to src/app/tokens/create/page.tsx index 1f37294..e89a407 100644 --- a/src/app/(walletConnected)/tokens/create/page.tsx +++ b/src/app/tokens/create/page.tsx @@ -1,11 +1,12 @@ 'use client' +import { useWallet } from '@bbachain/wallet-adapter-react' import { zodResolver } from '@hookform/resolvers/zod' import { Loader2, ChevronRight, ChevronLeft } from 'lucide-react' import { useEffect, useRef, useState } from 'react' import { useForm } from 'react-hook-form' +import { CiWallet } from 'react-icons/ci' -import { NoBalanceAlert } from '@/components/common/Alert' import { Button } from '@/components/ui/button' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { @@ -29,7 +30,6 @@ import CreateTokenOverview from '@/features/tokens/components/form/TokenOverview import { useCreateToken } from '@/features/tokens/services' import { TCreateTokenDataResponse, TCreateTokenPayload } from '@/features/tokens/types' import { CreateTokenValidation } from '@/features/tokens/validation' -import { useGetBBABalance } from '@/services/wallet' import { useErrorDialog } from '@/stores/errorDialog' type FieldName = keyof TCreateTokenPayload @@ -73,10 +73,11 @@ export default function CreateToken() { } }) + const { publicKey: ownerAddress } = useWallet() + const isWalletConnected = Boolean(ownerAddress) + const watchTokenSupply = form.watch('supply') const createTokenMutation = useCreateToken() - const getBalanceQuery = useGetBBABalance() - const isNoBalance = getBalanceQuery.isError || !getBalanceQuery.data || getBalanceQuery.data === 0 const [currentStep, setCurrentStep] = useState(0) const [isSuccessOpen, setIsSuccessOpen] = useState(false) @@ -86,7 +87,7 @@ export default function CreateToken() { const fileInputRef = useRef(null) - const { openErrorDialog } = useErrorDialog() + const openErrorDialog = useErrorDialog((state) => state.openErrorDialog) const onNext = async () => { const fields = createTokenSteps[currentStep].fields @@ -207,7 +208,6 @@ export default function CreateToken() { onSubmit={form.handleSubmit(onSubmit)} className="xl:px-48 md:px-16 px-4 w-full flex flex-col lg:space-y-14 md:space-y-9 space-y-3" > - {isNoBalance && }

QUICK TOKEN GENERATOR

@@ -436,29 +436,35 @@ export default function CreateToken() { )} - -
- {currentStep > 0 && ( + {isWalletConnected ? ( +
+ {currentStep > 0 && ( + + )} - )} -
+ ) : ( + -
+ )} ) diff --git a/src/app/(walletConnected)/tokens/page.tsx b/src/app/tokens/page.tsx similarity index 54% rename from src/app/(walletConnected)/tokens/page.tsx rename to src/app/tokens/page.tsx index 139f783..49a2616 100644 --- a/src/app/(walletConnected)/tokens/page.tsx +++ b/src/app/tokens/page.tsx @@ -1,9 +1,11 @@ 'use client' +import { useWallet } from '@bbachain/wallet-adapter-react' import { Plus } from 'lucide-react' import Link from 'next/link' import { useState } from 'react' +import WalletNotConnectedCard from '@/components/common/WalletNotConnectedCard' import { buttonVariants } from '@/components/ui/button' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { TokenListColumns, TokenListProps } from '@/features/tokens/components/Columns' @@ -34,6 +36,9 @@ export default function Tokens() { const getTokenDataQuery = useGetTokens() const getLPTokenDataQuery = useGetLPTokens() + const { publicKey: ownerAddress } = useWallet() + const isWalletConnected = Boolean(ownerAddress) + const tokenData = getTokenDataQuery.data ? mapToTokenListPropsList(getTokenDataQuery.data.data) : [] @@ -42,7 +47,9 @@ export default function Tokens() { : [] const isLoading = - getTokenDataQuery.isPending || (activeTab === 'lp-tokens' && getLPTokenDataQuery.isPending) + isWalletConnected && + ((activeTab === 'tokens' && getTokenDataQuery.isPending) || + (activeTab === 'lp-tokens' && getLPTokenDataQuery.isPending)) return (
@@ -64,33 +71,32 @@ export default function Tokens() { Create Token
- - - - Regular Tokens - - - LP Tokens - - - - - getTokenDataQuery.refetch()} - isRefreshing={getTokenDataQuery.isRefetching} - isLoading={isLoading} - columns={TokenListColumns} - data={tokenData} - /> - - - {lpTokenData.length > 0 ? ( + {isWalletConnected && ( + + + + Regular Tokens + + + LP Tokens + + + + getTokenDataQuery.refetch()} + isRefreshing={getTokenDataQuery.isRefetching} + isLoading={isLoading} + columns={TokenListColumns} + data={tokenData} + /> + + getLPTokenDataQuery.refetch()} @@ -99,16 +105,10 @@ export default function Tokens() { columns={TokenListColumns} data={lpTokenData} /> - ) : ( -
-

No LP tokens found

-

- LP tokens are earned when you provide liquidity to pools -

-
- )} -
-
+
+
+ )} + {!isWalletConnected && } ) } diff --git a/src/app/(walletConnected)/wrapping/page.tsx b/src/app/wrapping/page.tsx similarity index 98% rename from src/app/(walletConnected)/wrapping/page.tsx rename to src/app/wrapping/page.tsx index 450905f..dac1c7f 100644 --- a/src/app/(walletConnected)/wrapping/page.tsx +++ b/src/app/wrapping/page.tsx @@ -25,7 +25,7 @@ export default function Wrapping() { const generalInvalid = inputAmount === '' || Number(inputAmount) <= 0 || !isAmountPositive const isWrapInvalid = generalInvalid || Number(inputAmount) > BBABalance const isUnwrapInvalid = generalInvalid || Number(inputAmount) > WBBABalance - const { openErrorDialog } = useErrorDialog() + const openErrorDialog = useErrorDialog((state) => state.openErrorDialog) const onWrapBBA = () => wrapBBAMutation.mutate({ amount: Number(inputAmount) }) const onUnwrapWBBA = () => unwrapWBBAMutation.mutate({ amount: Number(inputAmount) }) diff --git a/src/components/common/WalletNotConnectedCard.tsx b/src/components/common/WalletNotConnectedCard.tsx new file mode 100644 index 0000000..f84eb61 --- /dev/null +++ b/src/components/common/WalletNotConnectedCard.tsx @@ -0,0 +1,41 @@ +import { CiWallet } from 'react-icons/ci' + +import ThemeImage from '@/components/common/ThemeImage' +import { Button } from '@/components/ui/button' +import {Card, CardHeader, CardTitle, CardContent, CardFooter} from '@/components/ui/card' +import { useWalletListDialog } from '@/stores/walletDialog' + +export default function WalletNotConnectedCard() { + const openWalletList = useWalletListDialog((state) => state.openWalletList) + return ( + + + Wallet Not Connected + + + +

+ Please connect your wallet to use the Quick Token
Generator and access features. +

+
+ + + +
+ ) +} diff --git a/src/features/liquidityPool/components/DataTable.tsx b/src/features/liquidityPool/components/DataTable.tsx index 21f4b79..9c59560 100644 --- a/src/features/liquidityPool/components/DataTable.tsx +++ b/src/features/liquidityPool/components/DataTable.tsx @@ -867,7 +867,7 @@ export function DataTable({ 'h-16', index === table.getRowModel().rows.length - 1 && 'border-b-0' )} - onClick={() => router.push(`/liquidity-pools/detail/${id}`)} + onClick={() => router.push(`/liquidity-pools/detail?poolId=${id}`)} > {row.getVisibleCells().map((cell) => ( @@ -887,7 +887,7 @@ export function DataTable({ Swap e.stopPropagation()} className={cn( buttonVariants({ variant: 'default', size: 'lg' }), diff --git a/src/features/liquidityPool/components/TransactionDataTable.tsx b/src/features/liquidityPool/components/TransactionDataTable.tsx index bc7687d..85ac588 100644 --- a/src/features/liquidityPool/components/TransactionDataTable.tsx +++ b/src/features/liquidityPool/components/TransactionDataTable.tsx @@ -8,9 +8,10 @@ import { cn } from '@/lib/utils' interface TransactionDataTableProps { columns: ColumnDef[] data: TData[] + NoDataMessage?: string } -export function TransactionDataTable({ columns, data }: TransactionDataTableProps) { +export function TransactionDataTable({ columns, data, NoDataMessage }: TransactionDataTableProps) { const table = useReactTable({ data, columns, @@ -63,7 +64,7 @@ export function TransactionDataTable({ columns, data }: Transacti ) : ( - No results. + {NoDataMessage ? NoDataMessage : 'No Data'} )} diff --git a/src/features/liquidityPool/services.ts b/src/features/liquidityPool/services.ts index b6a24ef..7c3a91b 100644 --- a/src/features/liquidityPool/services.ts +++ b/src/features/liquidityPool/services.ts @@ -241,7 +241,7 @@ export const useGetUserPoolStats = ({ pool }: { pool: TOnchainPoolData | null | data } }, - enabled: !!pool, + enabled: !!pool && !!ownerAddress, refetchInterval: 300000, staleTime: 60000 }) diff --git a/src/features/swap/components/SwapItem.tsx b/src/features/swap/components/SwapItem.tsx index ddd0928..2215a4a 100644 --- a/src/features/swap/components/SwapItem.tsx +++ b/src/features/swap/components/SwapItem.tsx @@ -1,6 +1,7 @@ /* eslint-disable @next/next/no-img-element */ 'use client' +import { useWallet } from '@bbachain/wallet-adapter-react' import { IoIosArrowDown } from 'react-icons/io' import { capitalCase } from 'text-case' @@ -34,8 +35,10 @@ export default function SwapItem({ setTokenProps, setInputAmount }: SwapItemProps) { - const onMaxClick = () => setInputAmount(balance.toString()) + const { publicKey: ownerAddress } = useWallet() + const isWalletConnected = Boolean(ownerAddress) + const onMaxClick = () => setInputAmount(balance.toString()) return (
{!noTitle &&
{capitalCase(type)}
} @@ -87,18 +90,18 @@ export default function SwapItem({ type="button" className="px-1 text-dark-grey text-xs font-normal" onClick={onMaxClick} - disabled={isTokenLoading} + disabled={!isWalletConnected || isTokenLoading} > Max )}
-
+

Balance:

{isTokenLoading ? ( - + ) : (

{balance.toLocaleString(undefined, { @@ -109,7 +112,7 @@ export default function SwapItem({

)}
-

+

≈${' '} {price.toLocaleString(undefined, { minimumFractionDigits: 2, diff --git a/src/features/tokens/components/DataTable.tsx b/src/features/tokens/components/DataTable.tsx index 2c48297..866c342 100644 --- a/src/features/tokens/components/DataTable.tsx +++ b/src/features/tokens/components/DataTable.tsx @@ -51,6 +51,7 @@ import { cn } from '@/lib/utils' interface DataTableProps { columns: ColumnDef[] data: TData[] + noDataMessage?: string onRefresh?: () => void isLoading?: boolean isRefreshing?: boolean @@ -60,6 +61,7 @@ interface DataTableProps { export function DataTable({ columns, data, + noDataMessage, onRefresh, isLoading, isRefreshing, @@ -286,7 +288,7 @@ export function DataTable({ ) : ( - No results. + {noDataMessage ? noDataMessage : 'No data.'} )} diff --git a/src/features/tokens/services.ts b/src/features/tokens/services.ts index 2cd94a1..0724faf 100644 --- a/src/features/tokens/services.ts +++ b/src/features/tokens/services.ts @@ -95,7 +95,8 @@ export const useGetTokens = () => { message: `Successfully get token with address ${ownerAddress.toBase58()}`, data: filteredTokenData } - } + }, + enabled: !!ownerAddress }) } diff --git a/src/features/wrapping/components/WrapBalanceItem.tsx b/src/features/wrapping/components/WrapBalanceItem.tsx index 14b7284..3947610 100644 --- a/src/features/wrapping/components/WrapBalanceItem.tsx +++ b/src/features/wrapping/components/WrapBalanceItem.tsx @@ -1,3 +1,6 @@ +'use client' + +import { useWallet } from '@bbachain/wallet-adapter-react' import Image from 'next/image' import { Skeleton } from '@/components/ui/skeleton' @@ -12,17 +15,27 @@ interface WrapBalanceItemProps { export default function WrapBalanceItem({ type, balance, isLoading }: WrapBalanceItemProps) { const isWBBA = type === 'WBBA' const isMobile = useIsMobile() + + const { publicKey: ownerAddress } = useWallet() + const isWalletConnected = Boolean(ownerAddress) return (

{`${type} Balance`}

- {isLoading ? ( - - ) : ( -

{`${balance.toLocaleString(undefined, { - minimumFractionDigits: 0, - maximumFractionDigits: 6 - })} ${type}`}

+ {!isWalletConnected && ( +

+ Please connect your wallet to see your balance +

+ )} + {isWalletConnected && isLoading && } + {isWalletConnected && !isLoading && ( +

{`${balance.toLocaleString( + undefined, + { + minimumFractionDigits: 0, + maximumFractionDigits: 6 + } + )} ${type}`}

)}
state.openWalletList) + const isWalletConnected = Boolean(ownerAddress) + return (
{/* Input Section */} @@ -74,16 +81,26 @@ export default function WrapContent({
) diff --git a/src/features/wrapping/components/WrapInputItem.tsx b/src/features/wrapping/components/WrapInputItem.tsx index 15c29c9..9a682d3 100644 --- a/src/features/wrapping/components/WrapInputItem.tsx +++ b/src/features/wrapping/components/WrapInputItem.tsx @@ -1,3 +1,4 @@ +import { useWallet } from '@bbachain/wallet-adapter-react' import Image from 'next/image' import { Dispatch, SetStateAction } from 'react' @@ -25,7 +26,9 @@ export default function WrapInputItem({ }: WrapInputItemProps) { const isWBBA = type === 'WBBA' const isMobile = useIsMobile() - const isBalanceNotEnough = isBase && Number(amount) > balance + const { publicKey: ownerAddress } = useWallet() + const isWalletConnected = Boolean(ownerAddress) + const isBalanceNotEnough = isWalletConnected && isBase && Number(amount) > balance const isAmountPositive = Number(amount) >= 0 const isInValid = isBalanceNotEnough || !isAmountPositive @@ -62,7 +65,7 @@ export default function WrapInputItem({ type="button" size="sm" className="px-1 absolute left-20 -top-1 text-dark-grey text-xs font-normal" - disabled={isBalanceNotEnough} + disabled={!isWalletConnected || isBalanceNotEnough} onClick={ isBalanceNotEnough ? () => { diff --git a/src/services/wallet.tsx b/src/services/wallet.tsx index b03ad3a..4b67723 100644 --- a/src/services/wallet.tsx +++ b/src/services/wallet.tsx @@ -51,7 +51,7 @@ export function useGetTokenBalanceByMint({ mintAddress }: { mintAddress: string const { publicKey: ownerAddress } = useWallet() const { connection } = useConnection() return useQuery({ - queryKey: [SERVICES_KEY.WALLET.GET_TOKEN_BALANCE_BY_MINT, mintAddress], + queryKey: [SERVICES_KEY.WALLET.GET_TOKEN_BALANCE_BY_MINT, mintAddress, ownerAddress?.toBase58()], queryFn: async () => { if (!ownerAddress) throw new Error('No wallet connected')