1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Fix contact address pet name (#14613)

* The contact pet name isn't replaced by the recipients address

* Create getEnsResolutionByAddress selector and use it in the codebase

* Modified the getRecipient selector such that it returns an ens resolution as the nickname if a nickname isn't present but a ens resolution is.

* Update ui/ducks/send/send.js

Co-authored-by: Brad Decker <bhdecker84@gmail.com>

* Checked if ens resolution is present in the getRecipient selector

Co-authored-by: Brad Decker <bhdecker84@gmail.com>
This commit is contained in:
VSaric 2022-06-13 18:18:33 +02:00 committed by GitHub
parent b170211700
commit 136218893b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 8 deletions

View File

@ -3,18 +3,17 @@ import { tryReverseResolveAddress } from '../../../store/actions';
import {
getAddressBook,
getRpcPrefsForCurrentProvider,
getEnsResolutionByAddress,
} from '../../../selectors';
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
import TransactionListItemDetails from './transaction-list-item-details.component';
const mapStateToProps = (state, ownProps) => {
const { metamask } = state;
const { ensResolutionsByAddress } = metamask;
const { recipientAddress, senderAddress } = ownProps;
let recipientEns;
if (recipientAddress) {
const address = toChecksumHexAddress(recipientAddress);
recipientEns = ensResolutionsByAddress[address] || '';
recipientEns = getEnsResolutionByAddress(state, address);
}
const addressBook = getAddressBook(state);

View File

@ -44,6 +44,7 @@ import {
getTokenList,
getAddressBookEntryOrAccountName,
getIsMultiLayerFeeNetwork,
getEnsResolutionByAddress,
} from '../../selectors';
import {
disconnectGasFeeEstimatePoller,
@ -91,6 +92,7 @@ import { resetEnsResolution } from '../ens';
import {
isBurnAddress,
isValidHexAddress,
toChecksumHexAddress,
} from '../../../shared/modules/hexstring-utils';
import { sumHexes } from '../../helpers/utils/transactions.util';
import fetchEstimatedL1Fee from '../../helpers/utils/optimism/fetchEstimatedL1Fee';
@ -2260,6 +2262,17 @@ export function getRecipientUserInput(state) {
}
export function getRecipient(state) {
const checksummedAddress = toChecksumHexAddress(
state[name].recipient.address,
);
if (state.metamask.ensResolutionsByAddress) {
return {
...state[name].recipient,
nickname:
state[name].recipient.nickname ||
getEnsResolutionByAddress(state, checksummedAddress),
};
}
return state[name].recipient;
}

View File

@ -2585,9 +2585,12 @@ describe('Send Slice', () => {
});
it('has a selector to get recipient state', () => {
expect(getRecipient({ send: initialState })).toMatchObject(
initialState.recipient,
);
expect(
getRecipient({
send: initialState,
metamask: { ensResolutionsByAddress: {} },
}),
).toMatchObject(initialState.recipient);
});
});

View File

@ -34,6 +34,7 @@ import {
getIsMultiLayerFeeNetwork,
getEIP1559V2Enabled,
getIsBuyableChain,
getEnsResolutionByAddress,
} from '../../selectors';
import { getMostRecentOverviewPage } from '../../ducks/history/history';
import {
@ -80,7 +81,6 @@ const mapStateToProps = (state, ownProps) => {
const isBuyableChain = getIsBuyableChain(state);
const { confirmTransaction, metamask } = state;
const {
ensResolutionsByAddress,
conversionRate,
identities,
addressBook,
@ -137,7 +137,7 @@ const mapStateToProps = (state, ownProps) => {
addressBook &&
addressBook[chainId] &&
addressBook[chainId][checksummedAddress];
const toEns = ensResolutionsByAddress[checksummedAddress] || '';
const toEns = getEnsResolutionByAddress(state, checksummedAddress);
const toNickname = addressBookObject ? addressBookObject.name : '';
const transactionStatus = transaction ? transaction.status : '';
const supportsEIP1559 =

View File

@ -375,6 +375,10 @@ export function getAddressBook(state) {
return Object.values(state.metamask.addressBook[chainId]);
}
export function getEnsResolutionByAddress(state, address) {
return state.metamask.ensResolutionsByAddress[address] || '';
}
export function getAddressBookEntry(state, address) {
const addressBook = getAddressBook(state);
const entry = addressBook.find((contact) =>