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:
parent
b170211700
commit
136218893b
@ -3,18 +3,17 @@ import { tryReverseResolveAddress } from '../../../store/actions';
|
|||||||
import {
|
import {
|
||||||
getAddressBook,
|
getAddressBook,
|
||||||
getRpcPrefsForCurrentProvider,
|
getRpcPrefsForCurrentProvider,
|
||||||
|
getEnsResolutionByAddress,
|
||||||
} from '../../../selectors';
|
} from '../../../selectors';
|
||||||
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
|
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
|
||||||
import TransactionListItemDetails from './transaction-list-item-details.component';
|
import TransactionListItemDetails from './transaction-list-item-details.component';
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
const { metamask } = state;
|
|
||||||
const { ensResolutionsByAddress } = metamask;
|
|
||||||
const { recipientAddress, senderAddress } = ownProps;
|
const { recipientAddress, senderAddress } = ownProps;
|
||||||
let recipientEns;
|
let recipientEns;
|
||||||
if (recipientAddress) {
|
if (recipientAddress) {
|
||||||
const address = toChecksumHexAddress(recipientAddress);
|
const address = toChecksumHexAddress(recipientAddress);
|
||||||
recipientEns = ensResolutionsByAddress[address] || '';
|
recipientEns = getEnsResolutionByAddress(state, address);
|
||||||
}
|
}
|
||||||
const addressBook = getAddressBook(state);
|
const addressBook = getAddressBook(state);
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ import {
|
|||||||
getTokenList,
|
getTokenList,
|
||||||
getAddressBookEntryOrAccountName,
|
getAddressBookEntryOrAccountName,
|
||||||
getIsMultiLayerFeeNetwork,
|
getIsMultiLayerFeeNetwork,
|
||||||
|
getEnsResolutionByAddress,
|
||||||
} from '../../selectors';
|
} from '../../selectors';
|
||||||
import {
|
import {
|
||||||
disconnectGasFeeEstimatePoller,
|
disconnectGasFeeEstimatePoller,
|
||||||
@ -91,6 +92,7 @@ import { resetEnsResolution } from '../ens';
|
|||||||
import {
|
import {
|
||||||
isBurnAddress,
|
isBurnAddress,
|
||||||
isValidHexAddress,
|
isValidHexAddress,
|
||||||
|
toChecksumHexAddress,
|
||||||
} from '../../../shared/modules/hexstring-utils';
|
} from '../../../shared/modules/hexstring-utils';
|
||||||
import { sumHexes } from '../../helpers/utils/transactions.util';
|
import { sumHexes } from '../../helpers/utils/transactions.util';
|
||||||
import fetchEstimatedL1Fee from '../../helpers/utils/optimism/fetchEstimatedL1Fee';
|
import fetchEstimatedL1Fee from '../../helpers/utils/optimism/fetchEstimatedL1Fee';
|
||||||
@ -2260,6 +2262,17 @@ export function getRecipientUserInput(state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getRecipient(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;
|
return state[name].recipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2585,9 +2585,12 @@ describe('Send Slice', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('has a selector to get recipient state', () => {
|
it('has a selector to get recipient state', () => {
|
||||||
expect(getRecipient({ send: initialState })).toMatchObject(
|
expect(
|
||||||
initialState.recipient,
|
getRecipient({
|
||||||
);
|
send: initialState,
|
||||||
|
metamask: { ensResolutionsByAddress: {} },
|
||||||
|
}),
|
||||||
|
).toMatchObject(initialState.recipient);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ import {
|
|||||||
getIsMultiLayerFeeNetwork,
|
getIsMultiLayerFeeNetwork,
|
||||||
getEIP1559V2Enabled,
|
getEIP1559V2Enabled,
|
||||||
getIsBuyableChain,
|
getIsBuyableChain,
|
||||||
|
getEnsResolutionByAddress,
|
||||||
} from '../../selectors';
|
} from '../../selectors';
|
||||||
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
||||||
import {
|
import {
|
||||||
@ -80,7 +81,6 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
const isBuyableChain = getIsBuyableChain(state);
|
const isBuyableChain = getIsBuyableChain(state);
|
||||||
const { confirmTransaction, metamask } = state;
|
const { confirmTransaction, metamask } = state;
|
||||||
const {
|
const {
|
||||||
ensResolutionsByAddress,
|
|
||||||
conversionRate,
|
conversionRate,
|
||||||
identities,
|
identities,
|
||||||
addressBook,
|
addressBook,
|
||||||
@ -137,7 +137,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
addressBook &&
|
addressBook &&
|
||||||
addressBook[chainId] &&
|
addressBook[chainId] &&
|
||||||
addressBook[chainId][checksummedAddress];
|
addressBook[chainId][checksummedAddress];
|
||||||
const toEns = ensResolutionsByAddress[checksummedAddress] || '';
|
const toEns = getEnsResolutionByAddress(state, checksummedAddress);
|
||||||
const toNickname = addressBookObject ? addressBookObject.name : '';
|
const toNickname = addressBookObject ? addressBookObject.name : '';
|
||||||
const transactionStatus = transaction ? transaction.status : '';
|
const transactionStatus = transaction ? transaction.status : '';
|
||||||
const supportsEIP1559 =
|
const supportsEIP1559 =
|
||||||
|
@ -375,6 +375,10 @@ export function getAddressBook(state) {
|
|||||||
return Object.values(state.metamask.addressBook[chainId]);
|
return Object.values(state.metamask.addressBook[chainId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getEnsResolutionByAddress(state, address) {
|
||||||
|
return state.metamask.ensResolutionsByAddress[address] || '';
|
||||||
|
}
|
||||||
|
|
||||||
export function getAddressBookEntry(state, address) {
|
export function getAddressBookEntry(state, address) {
|
||||||
const addressBook = getAddressBook(state);
|
const addressBook = getAddressBook(state);
|
||||||
const entry = addressBook.find((contact) =>
|
const entry = addressBook.find((contact) =>
|
||||||
|
Loading…
Reference in New Issue
Block a user