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

Fix ENS name displayed on confirm send page #6350

Merged
merged 7 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { shallow } from 'enzyme';
import configureMockStore from 'redux-mock-store';

import renderWithProvider from '../../../util/test/renderWithProvider';
import AccountFromToInfoCard from '.';
import { ENSCache } from '../../../util/ENSUtils';
import { Transaction } from './AccountFromToInfoCard.types';
import AccountFromToInfoCard from '.';

jest.mock('react-redux', () => ({
...jest.requireActual('react-redux'),
Expand Down Expand Up @@ -185,4 +186,28 @@ describe('AccountFromToInfoCard', () => {
);
expect(await findByText('0xF4e8...287B')).toBeDefined();
});

it('should display ens name', async () => {
const txState: Transaction = {
...transactionState,
transaction: { from: '0x0', to: '0x3' },
transactionTo: '0x3',
};
(ENSCache.cache as any) = {
'10x1': {
name: 'test1.eth',
timestamp: new Date().getTime(),
},
'10x3': {
name: 'test3.eth',
timestamp: new Date().getTime(),
},
};
const { queryByText } = renderWithProvider(
<AccountFromToInfoCard transactionState={txState} />,
{ state: initialState },
);
expect(await queryByText('test1.eth')).toBeDefined();
expect(await queryByText('test3.eth')).toBeDefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,28 @@ const AccountFromToInfoCard = (props: AccountFromToInfoCardProps) => {
return;
}
(async () => {
const { name: fromName } = identities[fromAddress];
const fromEns = await doENSReverseLookup(fromAddress);
setFromAccountName(fromEns || fromName);
const fromEns = await doENSReverseLookup(fromAddress, network);
if (fromEns) {
setFromAccountName(fromEns);
} else {
const { name: fromName } = identities[fromAddress];
setFromAccountName(fromName);
}
})();
}, [fromAddress, identities, transactionFromName]);
}, [fromAddress, identities, transactionFromName, network]);
jpuri marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
if (existingToAddress) {
setToAccountName(existingToAddress?.name);
return;
}
(async () => {
if (identities[toAddress]) {
const toEns = await doENSReverseLookup(toAddress);
if (toEns) {
setToAccountName(toEns);
}
const toEns = await doENSReverseLookup(toAddress, network);
if (toEns) {
setToAccountName(toEns);
} else if (identities[toAddress]) {
const { name: toName } = identities[toAddress];
setToAccountName(toName);
}
})();
}, [existingToAddress, identities, network, toAddress, transactionToName]);
Expand Down