Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 7 additions & 4 deletions apps/web/src/app/(overview)/distribution/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useDistributionTransaction } from '@/hooks/use-distribution-transaction
import { downloadCSVTemplate, processCSVFile } from '@/utils/csv-processing';
import { SUPPORTED_TOKENS } from '@/lib/validations';
import ProtectedRoute from '@/components/layouts/ProtectedRoute';
import WalletConnectionGuard from '@/components/modules/wallet/WalletConnectionGuard';
import { CSVErrorDisplay } from '@/components/molecules/CSVErrorDisplay';
import { CSVError, CSVWarning } from '@/types/distribution';
import { useVirtualizer } from '@tanstack/react-virtual';
Expand Down Expand Up @@ -384,10 +385,11 @@ export default function DistributionPage() {

return (
<ProtectedRoute description="Connect your Stellar wallet to create token distributions.">
<div
ref={pageRef}
className="h-screen mt-10 bg-black text-white overflow-y-auto scroll-smooth distribution-scrollbar"
>
<WalletConnectionGuard contextLabel="Connect your Stellar wallet to create token distributions.">
Comment on lines 387 to +388
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check ProtectedRoute implementation for additional functionality

ast-grep --pattern $'export default function ProtectedRoute($$$) {
  $$$
}'

# Also check the full file for any additional logic
fd -t f 'ProtectedRoute.tsx' --exec cat {}

Repository: Fundable-Protocol/stellar_client_os

Length of output: 4286


🏁 Script executed:

fd -type f -name '*WalletConnectionGuard*' --exec cat {}

Repository: Fundable-Protocol/stellar_client_os

Length of output: 249


🏁 Script executed:

fd -t f 'WalletConnectionGuard' --exec cat {}

Repository: Fundable-Protocol/stellar_client_os

Length of output: 1869


Remove redundant wallet connection guard.

Both ProtectedRoute (line 387) and WalletConnectionGuard (line 388) check useWallet().address and render a wallet connection prompt when disconnected. Since ProtectedRoute wraps WalletConnectionGuard, it will always intercept first, making WalletConnectionGuard unreachable when the wallet is disconnected.

Remove one of the wrappers. If migrating to WalletConnectionGuard, remove ProtectedRoute. If keeping ProtectedRoute for its customization options (title, description, actionLabel, container/card classes), remove WalletConnectionGuard from this page.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/src/app/`(overview)/distribution/page.tsx around lines 387 - 388,
The page nests two components that both guard on
useWallet().address—ProtectedRoute and WalletConnectionGuard—making one
redundant; remove the extra wrapper so only one guard remains. Decide which to
keep: if you want the customizable title/description/actionLabel/container/card
classes, keep ProtectedRoute and remove the WalletConnectionGuard wrapper around
the page content; if you prefer WalletConnectionGuard semantics, remove
ProtectedRoute and re-add any needed metadata/props
(title/description/actionLabel/container/card classes) to WalletConnectionGuard
or the page layout. Make the change by editing the JSX that currently wraps the
page (references: ProtectedRoute, WalletConnectionGuard, and
useWallet().address) so only the chosen guard remains.

<div
ref={pageRef}
className="h-screen mt-10 bg-black text-white overflow-y-auto scroll-smooth distribution-scrollbar"
>
<div className="max-w-6xl mx-auto p-6 pb-12">
{/* Header */}
<h1 className="text-xl font-semibold mb-8 text-zinc-100">Create Distribution</h1>
Expand Down Expand Up @@ -581,6 +583,7 @@ export default function DistributionPage() {
</div>
</div>
</div>
</WalletConnectionGuard>
</ProtectedRoute>
);
}
8 changes: 3 additions & 5 deletions apps/web/src/app/(overview)/offramp/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import OfframpQuoteModal from "@/components/offramp/OfframpQuoteModal";
import { BridgeStatusTracker } from "@/components/offramp/BridgeStatusTracker";
import OfframpSuccessModal from "@/components/offramp/OfframpSuccessModal";
import DashboardLayout from "@/components/layouts/DashboardLayout";
import ProtectedRoute from "@/components/layouts/ProtectedRoute";
import WalletConnectionGuard from "@/components/modules/wallet/WalletConnectionGuard";

export default function OfframpPage() {
const {
Expand Down Expand Up @@ -75,9 +75,7 @@ export default function OfframpPage() {
showOnNetwork: "testnet"
}}
>
<ProtectedRoute
description="Connect your Stellar wallet to convert USDC to local currency."
>
<WalletConnectionGuard contextLabel="Connect your Stellar wallet to convert USDC to local currency.">
<div className="space-y-8 pb-10">
{/* Intro text */}
<p className="text-fundable-light-grey max-w-2xl px-2">
Expand Down Expand Up @@ -163,7 +161,7 @@ export default function OfframpPage() {
)}
</div>
</div>
</ProtectedRoute>
</WalletConnectionGuard>

{/* Modals outside scroll area */}
<OfframpQuoteModal
Expand Down
5 changes: 4 additions & 1 deletion apps/web/src/app/(overview)/payment-stream/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { Suspense } from "react";
import DashboardLayout from "@/components/layouts/DashboardLayout";
import ProtectedRoute from "@/components/layouts/ProtectedRoute";
import WalletConnectionGuard from "@/components/modules/wallet/WalletConnectionGuard";
import CreatePaymentStream from "@/components/modules/payment-stream/CreatePaymentStream";
import StreamsHistory from "@/components/modules/payment-stream/StreamsHistory";
import StreamsTableSkeleton from "@/components/modules/payment-stream/StreamsTableSkeleton";
Expand All @@ -23,7 +24,9 @@ const PaymentStreamPage = () => {
<ProtectedRoute
description="Connect your Stellar wallet to create and manage payment streams."
>
<CreatePaymentStream />
<WalletConnectionGuard contextLabel="Connect your Stellar wallet to create and manage payment streams.">
<CreatePaymentStream />
</WalletConnectionGuard>
<Suspense fallback={<StreamsTableSkeleton />}>
<StreamsHistory />
</Suspense>
Expand Down
50 changes: 50 additions & 0 deletions apps/web/src/components/modules/wallet/WalletConnectionGuard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"use client";

import React, { type ReactNode } from "react";
import { Wallet } from "lucide-react";

import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { useWallet } from "@/providers/StellarWalletProvider";

interface WalletConnectionGuardProps {
children: ReactNode;
contextLabel?: string;
}

export function WalletConnectionGuard({
children,
contextLabel,
}: WalletConnectionGuardProps) {
const { address, openModal } = useWallet();

if (!address) {
return (
<div className="flex min-h-[60vh] items-center justify-center px-4 py-10">
<div className="relative w-full max-w-xl overflow-hidden rounded-3xl border border-white/10 bg-fundable-mid-dark p-10 text-center shadow-[0_0_40px_rgba(130,86,255,0.12)]">
<div className="pointer-events-none absolute inset-0 bg-gradient-to-br from-white/5 via-transparent to-fundable-purple-2/10" />
<div className="relative z-10 space-y-6">
<div className="mx-auto flex h-16 w-16 items-center justify-center rounded-full border border-white/10 bg-white/5">
<Wallet className="h-7 w-7 text-fundable-purple-2" />
</div>
<div className="space-y-2">
<h2 className="text-2xl font-semibold text-white">
Connect your wallet to continue
</h2>
<p className="text-fundable-light-grey">
{contextLabel || "You'll need a Stellar wallet connected to use this feature."}
</p>
</div>
<Button variant="gradient" size="lg" onClick={openModal}>
Connect Wallet
</Button>
</div>
</div>
</div>
);
}

return <>{children}</>;
}

export default WalletConnectionGuard;