fix: desktop wallet navigation and build issues
- Add escape options on unlock page (import/reset wallet) - Add confirmation modal for wallet reset with warning - Fix Rust build errors by adding once_cell and md5 dependencies - Remove duplicate Arc import in commands.rs - Browser mock mode improvements for 24-word mnemonic
This commit is contained in:
parent
b6522c21ef
commit
681f40cb5e
4 changed files with 83 additions and 6 deletions
|
|
@ -55,6 +55,8 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
|||
|
||||
# Utils
|
||||
uuid = { version = "1", features = ["v4"] }
|
||||
once_cell = "1"
|
||||
md5 = "0.7"
|
||||
|
||||
# Local crates from the monorepo (required for wallet functionality)
|
||||
synor-crypto = { path = "../../../crates/synor-crypto" }
|
||||
|
|
|
|||
|
|
@ -1978,7 +1978,6 @@ pub async fn get_network_status(state: State<'_, WalletState>) -> Result<Network
|
|||
use crate::node::{ConnectionMode, NodeManager, NodeStatus, PeerInfo, SyncProgress};
|
||||
use crate::rpc_client::RpcClient;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Application state containing node manager and RPC client
|
||||
pub struct AppState {
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ export const isTauri = (): boolean => {
|
|||
|
||||
// Mock data generators
|
||||
const mockGenerators = {
|
||||
// Wallet commands
|
||||
// Wallet commands - 24-word BIP39 mnemonic
|
||||
create_wallet: async (_args?: { password: string }) => ({
|
||||
mnemonic: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
|
||||
mnemonic: 'abandon ability able about above absent absorb abstract absurd abuse access accident account accuse achieve acid acoustic acquire across act action actor actress actual',
|
||||
address: 'tsynor1qz8v5zp2q0ew9d2k8n7j3x4c5v6b7n8m9k0l1p2q3r4s5t6u7v8w9x0y',
|
||||
}),
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { AlertTriangle, Lock } from 'lucide-react';
|
||||
import { useNavigate, Link } from 'react-router-dom';
|
||||
import { AlertTriangle, Lock, KeyRound, Download, Trash2 } from 'lucide-react';
|
||||
import { useWalletStore } from '../store/wallet';
|
||||
|
||||
export default function Unlock() {
|
||||
const navigate = useNavigate();
|
||||
const { unlockWallet } = useWalletStore();
|
||||
const { unlockWallet, setInitialized } = useWalletStore();
|
||||
|
||||
const [password, setPassword] = useState('');
|
||||
const [error, setError] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [showResetConfirm, setShowResetConfirm] = useState(false);
|
||||
|
||||
const handleUnlock = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
|
@ -31,6 +32,16 @@ export default function Unlock() {
|
|||
}
|
||||
};
|
||||
|
||||
const handleResetWallet = () => {
|
||||
// Clear wallet state and localStorage
|
||||
setInitialized(false);
|
||||
localStorage.removeItem('synor-wallet-storage');
|
||||
localStorage.removeItem('synor-node-storage');
|
||||
localStorage.removeItem('synor-mining-storage');
|
||||
// Navigate to welcome page
|
||||
navigate('/');
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="h-full flex flex-col items-center justify-center p-8">
|
||||
<div className="w-full max-w-sm">
|
||||
|
|
@ -76,7 +87,72 @@ export default function Unlock() {
|
|||
{loading ? 'Unlocking...' : 'Unlock'}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
{/* Divider */}
|
||||
<div className="my-6 border-t border-gray-800" />
|
||||
|
||||
{/* Alternative options */}
|
||||
<div className="space-y-3">
|
||||
<Link
|
||||
to="/import"
|
||||
className="w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg border border-gray-700 text-gray-300 hover:bg-gray-800 hover:text-white transition-colors text-sm"
|
||||
>
|
||||
<Download size={16} />
|
||||
Import Different Wallet
|
||||
</Link>
|
||||
|
||||
<button
|
||||
onClick={() => setShowResetConfirm(true)}
|
||||
className="w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg border border-gray-700 text-gray-400 hover:border-red-500/50 hover:text-red-400 transition-colors text-sm"
|
||||
>
|
||||
<KeyRound size={16} />
|
||||
Forgot Password?
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Reset Confirmation Modal */}
|
||||
{showResetConfirm && (
|
||||
<div className="fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4">
|
||||
<div className="bg-gray-900 rounded-xl p-6 max-w-md w-full border border-gray-800">
|
||||
<div className="flex items-center gap-3 mb-4">
|
||||
<div className="w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center">
|
||||
<Trash2 className="text-red-400" size={20} />
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold text-white">Reset Wallet?</h3>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3 mb-6">
|
||||
<p className="text-gray-300 text-sm">
|
||||
This will permanently delete your wallet data from this device.
|
||||
</p>
|
||||
<div className="bg-red-500/10 border border-red-500/30 rounded-lg p-3">
|
||||
<p className="text-red-300 text-sm font-medium">
|
||||
Warning: If you don't have your 24-word recovery phrase, you will lose access to your funds forever.
|
||||
</p>
|
||||
</div>
|
||||
<p className="text-gray-400 text-sm">
|
||||
After reset, you can create a new wallet or import an existing one using your recovery phrase.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-3">
|
||||
<button
|
||||
onClick={() => setShowResetConfirm(false)}
|
||||
className="flex-1 px-4 py-2.5 rounded-lg border border-gray-700 text-gray-300 hover:bg-gray-800 transition-colors"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
onClick={handleResetWallet}
|
||||
className="flex-1 px-4 py-2.5 rounded-lg bg-red-600 hover:bg-red-700 text-white transition-colors"
|
||||
>
|
||||
Reset Wallet
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue