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

Recipient name passed to confirm-page-container component should be u… #16961

Merged
merged 4 commits into from
Dec 15, 2022

Conversation

danjm
Copy link
Contributor

@danjm danjm commented Dec 14, 2022

…sed if pet name exists for the to address

Fixes #16658

Explanation

In a recent PR, in the ConfirmPageContainer, we stopped defaulting to the addressbook contact name or passed toName prop if no owned account name for the to address existed. That causes the send-to-recipient component to default to showing "New Contract" when sending to an address that is not in our address book or account names: https://github.com/MetaMask/metamask-extension/pull/15888/files#diff-214bde98baa3dbda2a9df24d3d2cbb420d51b54bb1404a1b710418213827236fR162-R166.

This PR fixes the issue by firstly adding the shortened address as a fallback in the sender-to-recipient component in all cases. To then also ensure that the address book contact name is shown if it exists, it is added as a fallback in the ConfirmPageContainer container if an owned account name doesn't exist. Appropriate tests are also restored.

Furthermore, this PR passes the sender-to-recipient component a new boolean property which indicates whether the recipient is an account owned by the user. This boolean is used to decide whether to show the user edit/add nickname popover, which should be shown when the recipient is clicked unless that recipient as an account owned by the user. This was also needed to get e2e tests to pass.

@danjm danjm requested a review from a team as a code owner December 14, 2022 21:31
@danjm danjm requested a review from ryanml December 14, 2022 21:31
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@danjm danjm force-pushed the fix-recipient-name-bug branch from 75a37a5 to 6839799 Compare December 15, 2022 02:29
@danjm danjm force-pushed the fix-recipient-name-bug branch from 30350ef to f489403 Compare December 15, 2022 03:25
const toMetadataName = getMetadataContractName(state, to);

return {
isBuyableChain,
contact,
toName,
toMetadataName,
isOwnedAccount: getAccountsWithLabels(state)
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 isOwnedAccount was unused

@@ -163,6 +164,7 @@ export function RecipientWithAddress({
recipientNickname ||
recipientMetadataName ||
recipientEns ||
shortenAddress(checksummedRecipientAddress) ||
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 line ensures that a recipient address is rendered if it exists but does not have an account, addressbook, token or ens name

@@ -19,17 +18,16 @@ function mapStateToProps(state, ownProps) {
const defaultToken = getSwapsDefaultToken(state);
const accountBalance = defaultToken.string;
const identities = getMetaMaskIdentities(state);
const toName = getAccountName(identities, to);
const ownedAccountName = getAccountName(identities, to);
const toName = ownedAccountName || contact?.name;
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 above line ensures that the addressbook name is used if available

@@ -129,7 +129,7 @@ describe('Send ETH non-contract address with data that matches ERC20 transfer da

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the test changes restore the tests to the state they were in before the previous PR linked in the above description of this PR

Copy link
Contributor

@jpuri jpuri left a comment

Choose a reason for hiding this comment

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

Changes look good 👍

@metamaskbot
Copy link
Collaborator

Builds ready [9e471cb]
Page Load Metrics (2580 ± 355 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1061481270391188
domContentLoaded188645042558742357
load188645042580738355
domInteractive188645042558742357
Bundle size diffs
  • background: 0 bytes
  • ui: 260 bytes
  • common: 0 bytes

highlights:

storybook

Copy link
Contributor

@adonesky1 adonesky1 left a comment

Choose a reason for hiding this comment

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

LGTM!

@danjm danjm merged commit 0792e4e into develop Dec 15, 2022
@danjm danjm deleted the fix-recipient-name-bug branch December 15, 2022 16:34
@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2022
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.

[Bug]: Some addresses are displayed as New Contract on the recipient for a simple Send
4 participants