-
-
Notifications
You must be signed in to change notification settings - Fork 134
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/utils
has been updated to the latest version,normalize
method does not returnundefined
for empty strings anymore.getKeyringForAccount
checks 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 callinggetKeyringForAccount
what 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
isValidHexAddress
from@metamask/utils
to check if the string passed togetKeyringForAccount
is a valid address.Changes
getKeyringForAccount
provides a correct error message when an address is invalidReferences
Checklist