-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Conversation
…sed if pet name exists for the to address
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. |
75a37a5
to
6839799
Compare
30350ef
to
f489403
Compare
…book, token and ens names
const toMetadataName = getMetadataContractName(state, to); | ||
|
||
return { | ||
isBuyableChain, | ||
contact, | ||
toName, | ||
toMetadataName, | ||
isOwnedAccount: getAccountsWithLabels(state) |
There was a problem hiding this comment.
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) || |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 | |||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…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 theto
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.