Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/components/UnlockModal/UnlockModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ export default function UnlockModal() {

{amountValid && (
<Box border="1px solid #303030" borderRadius="2xl" p={3}>
{infoRow(
"Estimated receive",
`${numericAmount.toFixed(4)} ${position.symbol}`,
)}
{infoRow(
"Remaining stake",
`${remainingStake.toFixed(4)} ${position.symbol}`,
Expand Down
38 changes: 38 additions & 0 deletions src/context/StellarWalletContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,44 @@ export function StellarWalletProvider({ children }: { children: ReactNode }) {
setNetworkName(null);
}, []);

// Periodic health check for Freighter extension (#222)
useEffect(() => {
if (!publicKey) return undefined;

const checkFreighterHealth = async () => {
try {
const freighter = await import("@stellar/freighter-api");
const connected = await freighter.isConnected();

// If extension is no longer available, disconnect gracefully
if (!connected.isConnected || connected.error) {
disconnect();
return;
}

// Verify we can still get the address
const addr = await freighter.getAddress();
if (addr.error || !addr.address) {
disconnect();
return;
}

// If address changed, update it
if (addr.address !== publicKey) {
setPublicKey(addr.address);
}
} catch {
// Extension error or removal - disconnect
disconnect();
}
};

// Check every 30 seconds
const interval = setInterval(checkFreighterHealth, 30000);

return () => clearInterval(interval);
}, [publicKey, disconnect]);

// NOTE: this listener does not fire when a user opens the Freighter
// extension popup while this tab stays visible — extension popups are a
// separate top-level browsing context, not an overlay that hides the
Expand Down
Loading