Skip to content
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

Fixing ENS input entry in send flow #10923

Merged
merged 2 commits into from
Apr 26, 2021
Merged

Fixing ENS input entry in send flow #10923

merged 2 commits into from
Apr 26, 2021

Conversation

ryanml
Copy link
Contributor

@ryanml ryanml commented Apr 25, 2021

Fixes #10691

Explanation:
With recent updates to isValidAddress as provided by ethereumjs-util, it is not accepting of invalid hex strings.
This adds an isHex validation check to our shared utility for isValidAddress to address the regression. With regards to #10691, we additionally check domain validity so as to not throw an invalid recipient error.

Manual testing steps:
Steps for #10691 are defined in the issue. A general regression test should be performed with sending to ENS and hex addresses.

With fix:
Screen Shot 2021-04-24 at 8 24 08 PM
Screen Shot 2021-04-24 at 8 22 21 PM
Screen Shot 2021-04-24 at 8 21 47 PM
Screen Shot 2021-04-24 at 8 21 35 PM
Screen Shot 2021-04-24 at 8 21 29 PM

@ryanml ryanml requested a review from a team as a code owner April 25, 2021 03:31
@ryanml ryanml self-assigned this Apr 25, 2021
@metamaskbot
Copy link
Collaborator

Builds ready [25a028f]
Page Load Metrics (600 ± 37 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint467359105
domContentLoaded3727085997837
load3737096007737
domInteractive3717075997837

@@ -314,7 +314,7 @@ export default class EnsInput extends Component {
}

if (ensFailure) {
return <i className="fa fa-warning fa-lg warning'" />;
return <i className="fa fa-warning fa-lg warning" />;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this just seemed to be a typo

@metamaskbot
Copy link
Collaborator

Builds ready [60ae1b9]
Page Load Metrics (556 ± 43 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint427552105
domContentLoaded3306775559143
load3316785569043
domInteractive3306775559143

@metamaskbot
Copy link
Collaborator

Builds ready [d6d1f59]
Page Load Metrics (568 ± 38 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint44695273
domContentLoaded3536575678038
load3546585688038
domInteractive3536575668038

@@ -22,7 +22,7 @@ export function getToErrorObject(to, sendTokenAddress, chainId) {
let toError = null;
if (!to) {
toError = REQUIRED_ERROR;
} else if (!isValidAddress(to)) {
} else if (!isValidAddress(to) && !isValidDomainName(to)) {
Copy link
Contributor Author

@ryanml ryanml Apr 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we use isValidDomainName throughout the codebase to support ENS checks: https://github.com/MetaMask/metamask-extension/blob/develop/ui/app/pages/settings/contact-list-tab/add-contact/add-contact.component.js#L57

In this case, it has no improper fall through as part of add-recipient.js. It allows ENS names to move forward, and in the case of a valid domain name, not an ENS name, (ex: brantly.com) it will just default to the address book lookup, as domain names are fine there.

@brad-decker
Copy link
Contributor

Great work, @ryanml

@ryanml ryanml merged commit f080c10 into develop Apr 26, 2021
@ryanml ryanml deleted the fix-10691 branch April 26, 2021 14:31
@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'Recipient address is invalid' error when resolving ENS name set to a valid Ethereum address
3 participants