Handle "Error: unreachable" message when importing short private key#720
Open
stanisloe wants to merge 4 commits intonamada-net:mainfrom
Open
Handle "Error: unreachable" message when importing short private key#720stanisloe wants to merge 4 commits intonamada-net:mainfrom
stanisloe wants to merge 4 commits intonamada-net:mainfrom
Conversation
mateuszjasiuk
requested changes
Apr 9, 2024
Collaborator
mateuszjasiuk
left a comment
There was a problem hiding this comment.
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!
|
|
||
| const privateKeyError = (() => { | ||
| const validation = validatePrivateKey(filterPrivateKeyPrefix(privateKey)); | ||
| const validatePkAndFormatErrorMessage = (key: string): string => { |
Collaborator
There was a problem hiding this comment.
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 :)
Author
There was a problem hiding this comment.
sure. updated function name and return type 👍
Author
|
Thank for the feedback ! Pushed new commit with updates. Currently the branch is up to date with main. |
mateuszjasiuk
approved these changes
Apr 11, 2024
Collaborator
mateuszjasiuk
left a comment
There was a problem hiding this comment.
LGTM! I will add another reviewer though :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: unreachableto the user. While it is unlikelly someone will be importing private key of value123it 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.