Bug Description
getAccount in src/lib/actions/BaseAction.ts (lines 130-136)
unconditionally reads the keystore file after calling
createKeypairByName, even if it failed and never created the file.
Root Cause
if (!existsSync(keystorePath)) {
await this.confirmPrompt(`Account '${accountName}' not found. Would you like to create it?`);
decryptedPrivateKey = await this.createKeypairByName(accountName, false);
}
keystoreJson = readFileSync(keystorePath, "utf-8"); // line 135: no error check
keystoreData = JSON.parse(keystoreJson); // line 136
Impact
If createKeypairByName fails for any reason other than
password mismatch (e.g., disk full, permissions error during
writeFileSync), the keystore file is never created. The code
then crashes with an unhandled ENOENT error on line 135
instead of a clear error message.
Suggested Fix
decryptedPrivateKey = await this.createKeypairByName(accountName, false);
if (!existsSync(keystorePath)) {
this.failSpinner(`Failed to create keystore file for account '${accountName}'`);
return;
}
File
src/lib/actions/BaseAction.ts lines 130-136
Severity: High
Bug Description
getAccountinsrc/lib/actions/BaseAction.ts(lines 130-136)unconditionally reads the keystore file after calling
createKeypairByName, even if it failed and never created the file.Root Cause
Impact
If
createKeypairByNamefails for any reason other thanpassword mismatch (e.g., disk full, permissions error during
writeFileSync), the keystore file is never created. The codethen crashes with an unhandled
ENOENTerror on line 135instead of a clear error message.
Suggested Fix
File
src/lib/actions/BaseAction.tslines 130-136Severity: High