chore: disable export keystore if >1 credentials

This commit is contained in:
Danish Arora 2025-04-18 14:29:05 +05:30
parent 6022885144
commit cf04f3579f
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
3 changed files with 6 additions and 4 deletions

View File

@ -63,5 +63,5 @@ If you encounter an "ERC20: insufficient allowance" error, it means the token ap
- [x] fix rate limit fetch
- [ ] fix membership management methods
- [ ] define epoch / quanity epoch
- [ ] alias for individual credentials
- [ ] remove export keystore method (if >1 credentials in keystore)
- [x] alias for individual credentials
- [x] remove export keystore method (if >1 credentials in keystore)

View File

@ -8,7 +8,7 @@ export function KeystoreExporter() {
const [showPasswordInput, setShowPasswordInput] = useState(false);
const [password, setPassword] = useState("");
const [isExporting, setIsExporting] = useState(false);
const { exportEntireKeystore, hasStoredCredentials } = useKeystore();
const { exportEntireKeystore, hasStoredCredentials, credentialsCount } = useKeystore();
const handleExport = async () => {
if (!password) {
@ -36,7 +36,7 @@ export function KeystoreExporter() {
onClick={() => setShowPasswordInput(true)}
variant="terminal"
className="group relative overflow-hidden"
disabled={!hasStoredCredentials}
disabled={!hasStoredCredentials || credentialsCount > 1}
>
<span className="relative z-10 flex items-center">
<ArrowUpToLine className="w-4 h-4 mr-2" />

View File

@ -12,6 +12,7 @@ interface KeystoreContextType {
error: string | null;
hasStoredCredentials: boolean;
storedCredentialsHashes: string[];
credentialsCount: number;
credentialAliases: { [hash: string]: string };
decryptedCredentials: KeystoreEntity | null;
hideCredentials: () => void;
@ -241,6 +242,7 @@ export function KeystoreProvider({ children }: { children: ReactNode }) {
error,
hasStoredCredentials: storedCredentialsHashes.length > 0,
storedCredentialsHashes,
credentialsCount: storedCredentialsHashes.length,
credentialAliases,
saveCredentials,
exportCredential,