Disable deploy button until wallet network is verified
This commit is contained in:
parent
871958adc1
commit
b0b79963a3
@ -23,10 +23,10 @@ NEXT_PUBLIC_REGISTRY_GQL_ENDPOINT=https://laconicd-mainnet-1.laconic.com/graphql
|
|||||||
NEXT_PUBLIC_ALNT_COST_LRN=lrn://laconic/pricing/alnt
|
NEXT_PUBLIC_ALNT_COST_LRN=lrn://laconic/pricing/alnt
|
||||||
NEXT_PUBLIC_DEPLOYMENT_COST_LRN=lrn://laconic/pricing/webapp-deployment
|
NEXT_PUBLIC_DEPLOYMENT_COST_LRN=lrn://laconic/pricing/webapp-deployment
|
||||||
REGISTRY_GAS_PRICE=0.001
|
REGISTRY_GAS_PRICE=0.001
|
||||||
REGISTRY_BOND_ID=5d82586d156fb6671a9170d92f930a72a49a29afb45e30e16fff2100e30776e2
|
|
||||||
REGISTRY_AUTHORITY=laconic-deploy
|
REGISTRY_AUTHORITY=laconic-deploy
|
||||||
|
REGISTRY_BOND_ID=5d82586d156fb6671a9170d92f930a72a49a29afb45e30e16fff2100e30776e2
|
||||||
REGISTRY_USER_KEY=
|
REGISTRY_USER_KEY=
|
||||||
|
|
||||||
# Application Configuration
|
# Application Configuration
|
||||||
DEPLOYER_LRN=
|
DEPLOYER_LRN=lrn://vaasl-provider/deployers/webapp-deployer-api.apps.vaasl.io
|
||||||
NEXT_PUBLIC_DOMAIN_SUFFIX=
|
NEXT_PUBLIC_DOMAIN_SUFFIX=apps.vaasl.io
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useCallback, useEffect, useState, useRef } from 'react';
|
import { useCallback, useEffect, useState, useRef, useMemo } from 'react';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
|
|
||||||
import { WalletMultiButton } from '@solana/wallet-adapter-react-ui';
|
import { WalletMultiButton } from '@solana/wallet-adapter-react-ui';
|
||||||
@ -51,6 +51,7 @@ export default function Home() {
|
|||||||
const [repoUrl, setRepoUrl] = useState<string | null>(null);
|
const [repoUrl, setRepoUrl] = useState<string | null>(null);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [incorrectChainWarning, setIncorrectChainWarning] = useState<string | null>(null);
|
const [incorrectChainWarning, setIncorrectChainWarning] = useState<string | null>(null);
|
||||||
|
const [isFetchingChainGenesisHash, setIsFetchingChainGenesisHash] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!IS_NAT_GOR_TRANSFER_ENABLED) {
|
if (!IS_NAT_GOR_TRANSFER_ENABLED) {
|
||||||
@ -65,6 +66,9 @@ export default function Home() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const warnOnIncorrectChain = async () => {
|
const warnOnIncorrectChain = async () => {
|
||||||
|
setIsFetchingChainGenesisHash(true);
|
||||||
|
|
||||||
|
try {
|
||||||
// @ts-expect-error: backpack exists on window object
|
// @ts-expect-error: backpack exists on window object
|
||||||
const genesisHash = await window.backpack.solana.connection.getGenesisHash();
|
const genesisHash = await window.backpack.solana.connection.getGenesisHash();
|
||||||
|
|
||||||
@ -78,9 +82,12 @@ export default function Home() {
|
|||||||
|
|
||||||
if (genesisHash !== expectedGenesisHash) {
|
if (genesisHash !== expectedGenesisHash) {
|
||||||
setIncorrectChainWarning(
|
setIncorrectChainWarning(
|
||||||
`WARNING: Unsupported chain selected in wallet. Please switch to ${expectedChainName} chain and reconnect the wallet.`
|
`Unsupported network selected in wallet. Please switch to network for ${expectedChainName} chain and reconnect the wallet.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
setIsFetchingChainGenesisHash(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
warnOnIncorrectChain();
|
warnOnIncorrectChain();
|
||||||
@ -110,7 +117,7 @@ export default function Home() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Helper function to check if current wallet is compatible with selected payment method
|
// Helper function to check if current wallet is compatible with selected payment method
|
||||||
const isWalletCompatible = () => {
|
const isWalletCompatible = useMemo(() => {
|
||||||
if (!selectedPaymentMethod || !wallet) return false;
|
if (!selectedPaymentMethod || !wallet) return false;
|
||||||
|
|
||||||
const walletName = wallet.adapter.name.toLowerCase();
|
const walletName = wallet.adapter.name.toLowerCase();
|
||||||
@ -121,7 +128,7 @@ export default function Home() {
|
|||||||
} else {
|
} else {
|
||||||
return true; // Only non-Backpack wallets for SPL tokens
|
return true; // Only non-Backpack wallets for SPL tokens
|
||||||
}
|
}
|
||||||
};
|
}, [selectedPaymentMethod, wallet]);
|
||||||
|
|
||||||
const handlePaymentComplete = useCallback(async (hash: string, paymentMethod: PaymentMethod) => {
|
const handlePaymentComplete = useCallback(async (hash: string, paymentMethod: PaymentMethod) => {
|
||||||
if (!publicKey || !url) {
|
if (!publicKey || !url) {
|
||||||
@ -245,20 +252,25 @@ export default function Home() {
|
|||||||
<div className="flex flex-col items-center space-y-3">
|
<div className="flex flex-col items-center space-y-3">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<span className="w-3 h-3 rounded-full mr-2" style={{
|
<span className="w-3 h-3 rounded-full mr-2" style={{
|
||||||
backgroundColor: isWalletCompatible() ? 'var(--success)' : 'var(--destructive)'
|
backgroundColor: isWalletCompatible ? 'var(--success)' : 'var(--destructive)'
|
||||||
}}></span>
|
}}></span>
|
||||||
<p className="font-medium" style={{
|
<p className="font-medium" style={{
|
||||||
color: isWalletCompatible() ? 'var(--success)' : 'var(--destructive)'
|
color: isWalletCompatible ? 'var(--success)' : 'var(--destructive)'
|
||||||
}}>
|
}}>
|
||||||
{isWalletCompatible() ? 'Compatible' : 'Incompatible'} Wallet ({wallet?.adapter.name})
|
{isWalletCompatible ? 'Compatible' : 'Incompatible'} Wallet ({wallet?.adapter.name})
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{!isWalletCompatible() && (
|
{!isWalletCompatible && (
|
||||||
<p className="text-sm text-amber-400">
|
<p className="text-sm text-amber-400">
|
||||||
This wallet is not compatible with {PAYMENT_METHOD_LABELS[selectedPaymentMethod]} payments.
|
This wallet is not compatible with {PAYMENT_METHOD_LABELS[selectedPaymentMethod]} payments.
|
||||||
Please select a different wallet or payment method.
|
Please select a different wallet or payment method.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
{ isFetchingChainGenesisHash && (
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
Checking wallet network compatibility...
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
{incorrectChainWarning && (
|
{incorrectChainWarning && (
|
||||||
<p className="text-sm text-amber-400">
|
<p className="text-sm text-amber-400">
|
||||||
{incorrectChainWarning}
|
{incorrectChainWarning}
|
||||||
@ -296,18 +308,19 @@ export default function Home() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Step 3: URL Input */}
|
{/* Step 3: URL Input */}
|
||||||
<div className="mb-8 p-6 rounded-lg" style={{
|
<div className="mb-8 p-6 rounded-lg" style={{
|
||||||
background: 'var(--muted-light)',
|
background: 'var(--muted-light)',
|
||||||
borderLeft: '4px solid var(--primary)',
|
borderLeft: '4px solid var(--primary)',
|
||||||
opacity: (connected && isWalletCompatible()) ? '1' : '0.6'
|
opacity: (connected && isWalletCompatible) ? '1' : '0.6'
|
||||||
}}>
|
}}>
|
||||||
<h2 className="text-lg font-semibold mb-4 flex items-center">
|
<h2 className="text-lg font-semibold mb-4 flex items-center">
|
||||||
Enter URL to Deploy
|
Enter URL to Deploy
|
||||||
</h2>
|
</h2>
|
||||||
<URLForm
|
<URLForm
|
||||||
onSubmit={handleUrlSubmit}
|
onSubmit={handleUrlSubmit}
|
||||||
disabled={!connected || !isWalletCompatible() || status === 'creating' || Boolean(incorrectChainWarning)}
|
disabled={!connected || !isWalletCompatible || isFetchingChainGenesisHash || status === 'creating' || Boolean(incorrectChainWarning)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user