mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Recipient name passed to confirm-page-container component should be u… (#16961)
* Recipient name passed to confirm-page-container component should be used if pet name exists for the to address * Ensure recipient edit/add popup is shown for non-owned accounts * Ensure contract name is rendered if it exists for recipient address * Ensure that shortened address is last fallback after account, addressbook, token and ens names
This commit is contained in:
parent
6af3f9a4fb
commit
bb562ea29c
@ -135,7 +135,7 @@ describe('Send ETH non-contract address with data that matches ERC20 transfer da
|
|||||||
|
|
||||||
await driver.clickElement({ text: 'Next', tag: 'button' });
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
||||||
|
|
||||||
await driver.clickElement({ text: 'New contract' });
|
await driver.clickElement({ text: '0xc42...cd28' });
|
||||||
|
|
||||||
const recipientAddress = await driver.findElements({
|
const recipientAddress = await driver.findElements({
|
||||||
text: '0xc427D562164062a23a5cFf596A4a3208e72Acd28',
|
text: '0xc427D562164062a23a5cFf596A4a3208e72Acd28',
|
||||||
|
@ -92,7 +92,7 @@ describe('Confirm Page Container Container Test', () => {
|
|||||||
expect(senderRecipient).toBeInTheDocument();
|
expect(senderRecipient).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
it('should render recipient as address', () => {
|
it('should render recipient as address', () => {
|
||||||
const recipientName = screen.queryByText('New contract');
|
const recipientName = screen.queryByText(shortenAddress(props.toAddress));
|
||||||
expect(recipientName).toBeInTheDocument();
|
expect(recipientName).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ describe('Confirm Page Container Container Test', () => {
|
|||||||
|
|
||||||
describe('Contact/AddressBook name should appear in recipient header', () => {
|
describe('Contact/AddressBook name should appear in recipient header', () => {
|
||||||
it('should not show add to address dialog if recipient is in contact list and should display contact name', () => {
|
it('should not show add to address dialog if recipient is in contact list and should display contact name', () => {
|
||||||
const addressBookName = 'New contract';
|
const addressBookName = 'test save name';
|
||||||
|
|
||||||
const addressBook = {
|
const addressBook = {
|
||||||
'0x5': {
|
'0x5': {
|
||||||
|
@ -68,6 +68,7 @@ export default class ConfirmPageContainer extends Component {
|
|||||||
toMetadataName: PropTypes.string,
|
toMetadataName: PropTypes.string,
|
||||||
toEns: PropTypes.string,
|
toEns: PropTypes.string,
|
||||||
toNickname: PropTypes.string,
|
toNickname: PropTypes.string,
|
||||||
|
recipientIsOwnedAccount: PropTypes.bool,
|
||||||
// Content
|
// Content
|
||||||
contentComponent: PropTypes.node,
|
contentComponent: PropTypes.node,
|
||||||
errorKey: PropTypes.string,
|
errorKey: PropTypes.string,
|
||||||
@ -123,6 +124,7 @@ export default class ConfirmPageContainer extends Component {
|
|||||||
toMetadataName,
|
toMetadataName,
|
||||||
toEns,
|
toEns,
|
||||||
toNickname,
|
toNickname,
|
||||||
|
recipientIsOwnedAccount,
|
||||||
toAddress,
|
toAddress,
|
||||||
disabled,
|
disabled,
|
||||||
errorKey,
|
errorKey,
|
||||||
@ -239,6 +241,7 @@ export default class ConfirmPageContainer extends Component {
|
|||||||
recipientAddress={toAddress}
|
recipientAddress={toAddress}
|
||||||
recipientEns={toEns}
|
recipientEns={toEns}
|
||||||
recipientNickname={toNickname}
|
recipientNickname={toNickname}
|
||||||
|
recipientIsOwnedAccount={recipientIsOwnedAccount}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</ConfirmPageContainerHeader>
|
</ConfirmPageContainerHeader>
|
||||||
|
@ -19,7 +19,8 @@ function mapStateToProps(state, ownProps) {
|
|||||||
const defaultToken = getSwapsDefaultToken(state);
|
const defaultToken = getSwapsDefaultToken(state);
|
||||||
const accountBalance = defaultToken.string;
|
const accountBalance = defaultToken.string;
|
||||||
const identities = getMetaMaskIdentities(state);
|
const identities = getMetaMaskIdentities(state);
|
||||||
const toName = getAccountName(identities, to);
|
const ownedAccountName = getAccountName(identities, to);
|
||||||
|
const toName = ownedAccountName || contact?.name;
|
||||||
const toMetadataName = getMetadataContractName(state, to);
|
const toMetadataName = getMetadataContractName(state, to);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -27,9 +28,7 @@ function mapStateToProps(state, ownProps) {
|
|||||||
contact,
|
contact,
|
||||||
toName,
|
toName,
|
||||||
toMetadataName,
|
toMetadataName,
|
||||||
isOwnedAccount: getAccountsWithLabels(state)
|
recipientIsOwnedAccount: Boolean(ownedAccountName),
|
||||||
.map((accountWithLabel) => accountWithLabel.address)
|
|
||||||
.includes(to),
|
|
||||||
to,
|
to,
|
||||||
networkIdentifier,
|
networkIdentifier,
|
||||||
accountBalance,
|
accountBalance,
|
||||||
|
@ -104,6 +104,7 @@ export function RecipientWithAddress({
|
|||||||
recipientEns,
|
recipientEns,
|
||||||
recipientName,
|
recipientName,
|
||||||
recipientMetadataName,
|
recipientMetadataName,
|
||||||
|
recipientIsOwnedAccount,
|
||||||
}) {
|
}) {
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
const [showNicknamePopovers, setShowNicknamePopovers] = useState(false);
|
const [showNicknamePopovers, setShowNicknamePopovers] = useState(false);
|
||||||
@ -127,7 +128,7 @@ export function RecipientWithAddress({
|
|||||||
<div
|
<div
|
||||||
className="sender-to-recipient__party sender-to-recipient__party--recipient sender-to-recipient__party--recipient-with-address"
|
className="sender-to-recipient__party sender-to-recipient__party--recipient sender-to-recipient__party--recipient-with-address"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (recipientName) {
|
if (recipientIsOwnedAccount) {
|
||||||
setAddressCopied(true);
|
setAddressCopied(true);
|
||||||
copyToClipboard(checksummedRecipientAddress);
|
copyToClipboard(checksummedRecipientAddress);
|
||||||
} else {
|
} else {
|
||||||
@ -163,6 +164,7 @@ export function RecipientWithAddress({
|
|||||||
recipientNickname ||
|
recipientNickname ||
|
||||||
recipientMetadataName ||
|
recipientMetadataName ||
|
||||||
recipientEns ||
|
recipientEns ||
|
||||||
|
shortenAddress(checksummedRecipientAddress) ||
|
||||||
t('newContract')}
|
t('newContract')}
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@ -185,6 +187,7 @@ RecipientWithAddress.propTypes = {
|
|||||||
recipientNickname: PropTypes.string,
|
recipientNickname: PropTypes.string,
|
||||||
addressOnly: PropTypes.bool,
|
addressOnly: PropTypes.bool,
|
||||||
onRecipientClick: PropTypes.func,
|
onRecipientClick: PropTypes.func,
|
||||||
|
recipientIsOwnedAccount: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
function Arrow({ variant }) {
|
function Arrow({ variant }) {
|
||||||
@ -218,6 +221,7 @@ export default function SenderToRecipient({
|
|||||||
recipientAddress,
|
recipientAddress,
|
||||||
variant,
|
variant,
|
||||||
warnUserOnAccountMismatch,
|
warnUserOnAccountMismatch,
|
||||||
|
recipientIsOwnedAccount,
|
||||||
}) {
|
}) {
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
const checksummedSenderAddress = toChecksumHexAddress(senderAddress);
|
const checksummedSenderAddress = toChecksumHexAddress(senderAddress);
|
||||||
@ -246,6 +250,7 @@ export default function SenderToRecipient({
|
|||||||
recipientEns={recipientEns}
|
recipientEns={recipientEns}
|
||||||
recipientName={recipientName}
|
recipientName={recipientName}
|
||||||
recipientMetadataName={recipientMetadataName}
|
recipientMetadataName={recipientMetadataName}
|
||||||
|
recipientIsOwnedAccount={recipientIsOwnedAccount}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="sender-to-recipient__party sender-to-recipient__party--recipient">
|
<div className="sender-to-recipient__party sender-to-recipient__party--recipient">
|
||||||
@ -275,4 +280,5 @@ SenderToRecipient.propTypes = {
|
|||||||
onRecipientClick: PropTypes.func,
|
onRecipientClick: PropTypes.func,
|
||||||
onSenderClick: PropTypes.func,
|
onSenderClick: PropTypes.func,
|
||||||
warnUserOnAccountMismatch: PropTypes.bool,
|
warnUserOnAccountMismatch: PropTypes.bool,
|
||||||
|
recipientIsOwnedAccount: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user