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
64 changes: 62 additions & 2 deletions src/components/common/WalletConnectCalloutBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useState } from 'react';
import { Wallet } from 'lucide-react';
import { useAccount, useConnect, useReconnect } from 'wagmi';
import { cn } from '@/lib/utils';
import ConnectWalletButton from '@/components/common/ConnectWalletButton';
import showToast from '@/utils/toast.util';
Comment on lines +1 to +5

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

ConnectWalletButton was removed from this banner, and a repo-wide search shows it’s no longer imported anywhere. To avoid dead/unused UI code drifting out of sync, consider deleting src/components/common/ConnectWalletButton.tsx (or reusing it here) so there’s a single, maintained wallet connect entry point.

Copilot uses AI. Check for mistakes.

interface WalletConnectCalloutBannerProps {
title?: string;
Expand All @@ -13,6 +15,57 @@ const WalletConnectCalloutBanner: React.FC<WalletConnectCalloutBannerProps> = ({
description = 'Connect your wallet to continue with creator key purchases and on-chain actions.',
className,
}) => {
const { isConnected } = useAccount();
const { reconnectAsync, connectors: reconnectConnectors } = useReconnect();
const { connectAsync, connectors: connectConnectors } = useConnect();
const [isReconnecting, setIsReconnecting] = useState(false);

const retryConnector = reconnectConnectors[0] ?? connectConnectors[0];

const handleReconnect = async () => {
if (isReconnecting) {
return;
}

Comment on lines +25 to +29

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

This introduces non-trivial reconnect + fallback-connect behavior (and user feedback via toasts) but there are no component tests covering it. Since the repo already uses Vitest/Testing Library for common components, add tests that mock wagmi hooks to assert: (1) clicking disables the button / shows “Reconnecting…”, (2) successful reconnectAsync triggers the success toast, and (3) failed reconnect falls back to connectAsync (or surfaces an error toast).

Copilot uses AI. Check for mistakes.
if (isConnected) {
showToast.success('Wallet is already connected.');
return;
}

setIsReconnecting(true);
showToast.loading('Reconnecting wallet...');

try {
const reconnectResults = await reconnectAsync();
const didReconnect = reconnectResults.some(
result => result.accounts.length > 0
);

if (didReconnect) {
showToast.success('Wallet reconnected successfully.');
return;
}

if (!retryConnector) {
showToast.error(
'No wallet connector is available. Open your wallet extension and try again.'
);
return;
}

await connectAsync({ connector: retryConnector });
showToast.success('Wallet connected successfully.');
} catch (error) {
const message =
error instanceof Error && error.message
? error.message
: 'Please try again after unlocking your wallet.';
showToast.error(`Reconnect failed. ${message}`);
} finally {
setIsReconnecting(false);
}
};

return (
<div
className={cn(
Expand All @@ -32,7 +85,14 @@ const WalletConnectCalloutBanner: React.FC<WalletConnectCalloutBannerProps> = ({
<p className="mt-1 text-xs text-amber-100/75">{description}</p>
</div>
<div className="shrink-0">
<ConnectWalletButton />
<button
type="button"
onClick={handleReconnect}
disabled={isReconnecting}
className="rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:bg-blue-300"
>
{isReconnecting ? 'Reconnecting...' : 'Reconnect Wallet'}
</button>
</div>
</div>
</div>
Expand Down
Loading