From f73b1ce21197eeada696927a566d200431cd107e Mon Sep 17 00:00:00 2001
From: Shreerang Kale
Date: Wed, 23 Jul 2025 20:36:09 +0530
Subject: [PATCH] Show warning if gorbagana chain not selected in wallet
---
src/app/page.tsx | 41 +++++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 1bff5db..26ea6da 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -1,23 +1,26 @@
'use client';
-import { useCallback, useState } from 'react';
+import { useCallback, useEffect, useState } from 'react';
import dynamic from 'next/dynamic';
import { WalletMultiButton } from '@solana/wallet-adapter-react-ui';
import { useWallet } from '@solana/wallet-adapter-react';
+import { BackpackWalletName } from '@solana/wallet-adapter-backpack';
import URLForm from '@/components/URLForm';
import StatusDisplay from '@/components/StatusDisplay';
import { createApplicationDeploymentRequest } from '@/services/registry';
import { PaymentMethod, PAYMENT_METHOD_LABELS } from '@/constants/payments';
-
import { usePaymentMethod } from '@/contexts/PaymentMethodContext';
// Dynamically import components to avoid SSR issues with browser APIs
const PaymentModal = dynamic(() => import('@/components/PaymentModal'), { ssr: false });
+const GORBAGANA_GENESIS_HASH = '533uBE9RRquhTBqEX58oV52FdTTsReMdAvaUvP6hNjsn';
+
export default function Home() {
- const { wallet, connected, publicKey } = useWallet();
+ const { wallet, connected, publicKey, disconnect } = useWallet();
+
const { selectedPaymentMethod, setSelectedPaymentMethod } = usePaymentMethod();
const [url, setUrl] = useState(null);
const [showPaymentModal, setShowPaymentModal] = useState(false);
@@ -30,6 +33,31 @@ export default function Home() {
const [appName, setAppName] = useState(null);
const [repoUrl, setRepoUrl] = useState(null);
const [error, setError] = useState(null);
+ const [incorrectChainWarining, setIncorrectChainWarining] = useState(null);
+
+ useEffect(() => {
+ if (!wallet || wallet.adapter.name !== BackpackWalletName) {
+ return;
+ }
+
+ const warnOnIncorrectChain = async () => {
+ // @ts-expect-error: backpack exists on window object
+ const genesisHash = await window.backpack.solana.connection.getGenesisHash();
+ if (genesisHash !== GORBAGANA_GENESIS_HASH) {
+ setIncorrectChainWarining("WARNING: Unsupported chain selected in wallet. Please switch to Gorbagana chain")
+ }
+ }
+
+ warnOnIncorrectChain();
+ }, [wallet]);
+
+ useEffect(() => {
+ if (selectedPaymentMethod === null) {
+ return;
+ }
+
+ disconnect();
+ }, [selectedPaymentMethod, disconnect]);
const handleUrlSubmit = (submittedUrl: string) => {
setUrl(submittedUrl);
@@ -183,11 +211,16 @@ export default function Home() {
{!isWalletCompatible() && (
-
+
This wallet is not compatible with {PAYMENT_METHOD_LABELS[selectedPaymentMethod]} payments.
Please select a different wallet or payment method.
)}
+ {incorrectChainWarining && (
+
+ {incorrectChainWarining}
+
+ )}