mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-22 06:47:55 +00:00
feat: smart extension detection - only redirect to Chrome Web Store if not installed
This commit is contained in:
@@ -174,31 +174,31 @@ export const PezkuwiWalletButton: React.FC = () => {
|
||||
Connect Wallet
|
||||
</Button>
|
||||
|
||||
{error && error.includes('extension') && (
|
||||
{error && error.includes('not found') && (
|
||||
<Dialog open={!!error} onOpenChange={() => {}}>
|
||||
<DialogContent className="bg-gray-900 border-gray-800">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-white">Install Pezkuwi.js Extension</DialogTitle>
|
||||
<DialogTitle className="text-white">Install Pezkuwi Wallet Extension</DialogTitle>
|
||||
<DialogDescription className="text-gray-400">
|
||||
You need the Pezkuwi.js browser extension to connect your wallet
|
||||
You need the Pezkuwi Wallet browser extension to connect
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="space-y-4">
|
||||
<p className="text-gray-300">
|
||||
The Pezkuwi.js extension allows you to manage your accounts and sign transactions securely.
|
||||
The Pezkuwi Wallet extension allows you to manage your accounts and sign transactions securely.
|
||||
</p>
|
||||
|
||||
<div className="flex gap-3">
|
||||
<a
|
||||
href="https://js.pezkuwichain.io"
|
||||
href="https://chrome.google.com/webstore/detail/pezkuwi-wallet/fbnboicjjeebjhgnapneaeccpgjcdibn"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex-1"
|
||||
>
|
||||
<Button className="w-full bg-green-600 hover:bg-green-700">
|
||||
<ExternalLink className="w-4 h-4 mr-2" />
|
||||
Install Extension
|
||||
Install from Chrome Web Store
|
||||
</Button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -111,25 +111,44 @@ export const WalletModal: React.FC<WalletModalProps> = ({ isOpen, onClose }) =>
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
{/* No Extension Error */}
|
||||
{error && error.includes('extension') && (
|
||||
{/* Authorization Error - Extension installed but not authorized */}
|
||||
{error && error.includes('authorize') && (
|
||||
<div className="space-y-4">
|
||||
<div className="p-4 bg-blue-500/10 border border-blue-500/30 rounded-lg">
|
||||
<p className="text-sm text-blue-300">
|
||||
{error}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
onClick={handleConnect}
|
||||
className="w-full bg-gradient-to-r from-purple-600 to-cyan-400 hover:from-purple-700 hover:to-cyan-500"
|
||||
>
|
||||
<Wallet className="mr-2 h-4 w-4" />
|
||||
Try Again
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* No Extension Error - Extension not installed */}
|
||||
{error && error.includes('not found') && (
|
||||
<div className="space-y-4">
|
||||
<div className="p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg">
|
||||
<p className="text-sm text-yellow-300">
|
||||
Pezkuwi.js extension not detected. Please install it to continue.
|
||||
{error}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-3">
|
||||
<a
|
||||
href="https://js.pezkuwichain.io"
|
||||
href="https://chrome.google.com/webstore/detail/pezkuwi-wallet/fbnboicjjeebjhgnapneaeccpgjcdibn"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex-1"
|
||||
>
|
||||
<Button className="w-full bg-green-600 hover:bg-green-700">
|
||||
<Chrome className="mr-2 h-4 w-4" />
|
||||
Install Pezkuwi.js
|
||||
Install from Chrome Web Store
|
||||
</Button>
|
||||
</a>
|
||||
</div>
|
||||
@@ -310,14 +329,14 @@ export const WalletModal: React.FC<WalletModalProps> = ({ isOpen, onClose }) =>
|
||||
</Button>
|
||||
|
||||
<div className="text-sm text-gray-400 text-center">
|
||||
Don't have Pezkuwi.js?{' '}
|
||||
Don't have Pezkuwi Wallet?{' '}
|
||||
<a
|
||||
href="https://js.pezkuwichain.io"
|
||||
href="https://chrome.google.com/webstore/detail/pezkuwi-wallet/fbnboicjjeebjhgnapneaeccpgjcdibn"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-purple-400 hover:underline"
|
||||
>
|
||||
Download here
|
||||
Get it from Chrome Web Store
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -238,12 +238,21 @@ export const PezkuwiProvider: React.FC<PezkuwiProviderProps> = ({
|
||||
}
|
||||
}
|
||||
|
||||
// Desktop: Enable extension
|
||||
// Desktop: Check if extension is installed first
|
||||
const hasExtension = !!(window as unknown as { injectedWeb3?: Record<string, unknown> }).injectedWeb3;
|
||||
|
||||
// Enable extension
|
||||
const extensions = await web3Enable('PezkuwiChain');
|
||||
|
||||
if (extensions.length === 0) {
|
||||
setError('Please install Pezkuwi.js extension');
|
||||
window.open('https://js.pezkuwichain.io/extension/', '_blank');
|
||||
if (hasExtension) {
|
||||
// Extension is installed but user didn't authorize - don't redirect
|
||||
setError('Please authorize the connection in your Pezkuwi Wallet extension');
|
||||
} else {
|
||||
// Extension not installed - show install link
|
||||
setError('Pezkuwi Wallet extension not found. Please install from Chrome Web Store.');
|
||||
window.open('https://chrome.google.com/webstore/detail/pezkuwi-wallet/fbnboicjjeebjhgnapneaeccpgjcdibn', '_blank');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user