From bca4594f0af6b36d7d931f384c42d8e8226fb7a0 Mon Sep 17 00:00:00 2001 From: Dan Finlay <542863+danfinlay@users.noreply.github.com> Date: Fri, 14 Feb 2020 12:32:56 -0800 Subject: [PATCH] Add warning to watchAsset API when editing a known token (#8049) * Add warning when editing a known token with watchAsset API * Add warning when watchAsset attempts to reuse token symbol --- app/_locales/en/messages.json | 6 +++ .../confirm-add-suggested-token.component.js | 47 ++++++++++++++++++- .../confirm-add-suggested-token.container.js | 3 +- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index c9e1b02db..73c59555e 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -715,6 +715,12 @@ "knownAddressRecipient": { "message": "Known contract address." }, + "knownTokenWarning": { + "message": "This action will edit tokens that are already listed in your wallet, which can be used to phish you. Only approve if you are certain that you mean to change what these tokens represent." + }, + "reusedTokenNameWarning": { + "message": "A token here reuses a symbol from another token you watch, this can be confusing or deceptive." + }, "invalidAddressRecipientNotEthNetwork": { "message": "Not ETH network, set to lowercase" }, diff --git a/ui/app/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js b/ui/app/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js index 04e9c8dcf..7430933b3 100644 --- a/ui/app/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js +++ b/ui/app/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js @@ -16,6 +16,7 @@ export default class ConfirmAddSuggestedToken extends Component { addToken: PropTypes.func, pendingTokens: PropTypes.object, removeSuggestedTokens: PropTypes.func, + tokens: PropTypes.array, } componentDidMount () { @@ -33,9 +34,11 @@ export default class ConfirmAddSuggestedToken extends Component { } render () { - const { addToken, pendingTokens, removeSuggestedTokens, history } = this.props + const { addToken, pendingTokens, tokens, removeSuggestedTokens, history } = this.props const pendingTokenKey = Object.keys(pendingTokens)[0] const pendingToken = pendingTokens[pendingTokenKey] + const hasTokenDuplicates = this.checkTokenDuplicates(pendingTokens, tokens) + const reusesName = this.checkNameReuse(pendingTokens, tokens) return (