Uh oh!
There was an error while loading. Please reload this page.
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. |
mikesposito
commented
Jul 10, 2023
Could be worth waiting for MetaMask/utils#112 to be merged and released as |
Added minor bump of |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
mikesposito
commented
Jul 12, 2023
Shouldn't it be still covered by the test case |
6fbeccc to
de2bdd1Comparelegobeat
commented
Jul 12, 2023
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