-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle "Error: unreachable" message when importing short private key #720
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Left a comment about function name, also make sure your branch is up to date with main(I did not check that) :) Other than that works nicely!
@@ -47,27 +47,31 @@ export const SeedPhraseImport: React.FC<Props> = ({ onConfirm }) => { | |||
Array.from(mnemonicsRange) | |||
); | |||
|
|||
const privateKeyError = (() => { | |||
const validation = validatePrivateKey(filterPrivateKeyPrefix(privateKey)); | |||
const validatePkAndFormatErrorMessage = (key: string): string => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to call it validatePk
. We can also return {valid: boolean, msg: string}
or something, as it seems a bit more explicit :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. updated function name and return type 👍
Thank for the feedback ! Pushed new commit with updates. Currently the branch is up to date with main. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I will add another reviewer though :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
If user attempts to import private key of length less than 64 symbols namada extension continues with the import process but in the end throws
Failed while "Encrypting and storing private key.". Error: unreachable
to the user. While it is unlikelly someone will be importing private key of value123
it is possible to trim few characters from your private key when you copy it and receive error which is not very informative. ( Which happened to me and thought there is something wrong with extension )Changes:
Validation for private key minimum length and error message in case wrong length was provided.
Validation before submitting private key to extension background.
Tests:
Built and imported extension to my browser and tested that it is not possible to proceed with short key and meaningfull validation error message is presented to the user.
Also checked the normal flow with proper key.