Warning not being shown when sending tokens to a known token contract address
In ducks/send/send.js we have code that is meant to show a warning to users when they are sending to a known contract address:
if (
isSendingToken &&
isValidHexAddress(recipient.userInput) &&
(tokenAddressList.find((address) =>
isEqualCaseInsensitive(address, recipient.userInput),
) ||
checkExistingAddresses(recipient.userInput, tokens))
) {
recipient.warning = KNOWN_RECIPIENT_ADDRESS_WARNING;
} else {
recipient.warning = null;
}
This recipient.warning property is read in renderDialogs of ui/pages/send/send-content/add-recipient/add-recipient.component.js
Currently, if I try to send DAI token to the DAI contract, no warning is shown.
Acceptance criteria:
- if a known token contract address is entered in the recipient field in the send flow, a warning should be shown to the user
- this warning can just be the
<Dialog type="warning" className="send__error-dialog">thatadd-recipient.component.jsis currently meant to render - "known token contract addresses" include any of the addresses in this list: https://github.com/MetaMask/contract-metadata/blob/master/contract-map.json
AC:
- Implement the warning message on choosing existing account
- Remove "New address detected ..." when this specific warning is shown
Solving this shouldn't be top priority? I mean it like an honest assessment, it's an easy to fix issue that involves avoiding the lose of tokens.
I agree, I don't know why this was marked sev2. This is a low hanging fix for an easy cause of fund loss.
I didn't realize this had regressed until I saw this prominent example of it in the wild: https://twitter.com/0xfoobar/status/1538000663988228101?s=20&t=w9V_AQgNE5XBHl3nNMS90w