-
-
Notifications
You must be signed in to change notification settings - Fork 126
fix: throw correct error on empty or invalid address #238
Conversation
|
No top level dependency changes detected. Learn more about Socket for GitHub ↗︎ |
|
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
|
Could be worth waiting for MetaMask/utils#112 to be merged and released as |
|
Added minor bump of |
Shouldn't it be still covered by the test case |
6fbeccc to
de2bdd1
Compare
My bad, overlooked it. LGTM then! |
Description
Since
@metamask/utilshas been updated to the latest version,normalizemethod does not returnundefinedfor empty strings anymore.getKeyringForAccountchecks if the provided address is an empty string (or undefined) and returns an error in case. But as all the other methods of the controller normalize the address before callinggetKeyringForAccountwhat we check in there is0x, which is not seen as invalid/empty by the function.To fix the problem and provide a correct error message, this PR uses
isValidHexAddressfrom@metamask/utilsto check if the string passed togetKeyringForAccountis a valid address.Changes
getKeyringForAccountprovides a correct error message when an address is invalidReferences
Checklist