From e4672a884c72e3c4405ef5e81112236d4862ccd0 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Wed, 16 Oct 2024 12:35:06 +0200 Subject: [PATCH] fix: Correct conditions for triggering name lookup during send (#27880) Take changes from https://github.com/MetaMask/metamask-extension/commit/5e08c068f42220ecb98a5c2d0ae739e6412f4d67 ## **Description** Hotfixes a problem preventing certain name resolution Snaps from being triggered due to faulty `IS_FLASK` conditions in `12.4.1`. These conditions were removed in https://github.com/MetaMask/metamask-extension/pull/26242. This PR picks these changes from the previously mentioned PR, without touching the ENS integration. The problem in question occurs when trying to trigger name resolution for a given input. `lookupDomainName` is never called on stable unless the input looks similar to an ENS name. This prevents resolution of inputs that don't use TLDs for instance. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27880?quickstart=1) ## **Manual testing steps** 1. Use a build of stable 2. Install https://snaps.metamask.io/snap/npm/social-names-snap/ 3. See that you can resolve a Farcaster name using that Snap, e.g. `fc:frederik` 4. Check that you can also type a valid ENS name 5. Check that you can also type a valid address --------- Co-authored-by: Hassan Malik --- app/_locales/am/messages.json | 3 -- app/_locales/ar/messages.json | 3 -- app/_locales/bg/messages.json | 3 -- app/_locales/bn/messages.json | 3 -- app/_locales/ca/messages.json | 3 -- app/_locales/da/messages.json | 3 -- app/_locales/de/messages.json | 6 --- app/_locales/el/messages.json | 6 --- app/_locales/en/messages.json | 5 +-- app/_locales/en_GB/messages.json | 5 +-- app/_locales/es/messages.json | 6 --- app/_locales/es_419/messages.json | 3 -- app/_locales/et/messages.json | 3 -- app/_locales/fa/messages.json | 3 -- app/_locales/fi/messages.json | 3 -- app/_locales/fil/messages.json | 3 -- app/_locales/fr/messages.json | 6 --- app/_locales/he/messages.json | 3 -- app/_locales/hi/messages.json | 6 --- app/_locales/hr/messages.json | 3 -- app/_locales/hu/messages.json | 3 -- app/_locales/id/messages.json | 6 --- app/_locales/it/messages.json | 3 -- app/_locales/ja/messages.json | 6 --- app/_locales/kn/messages.json | 3 -- app/_locales/ko/messages.json | 6 --- app/_locales/lt/messages.json | 3 -- app/_locales/lv/messages.json | 3 -- app/_locales/ms/messages.json | 3 -- app/_locales/no/messages.json | 3 -- app/_locales/ph/messages.json | 3 -- app/_locales/pl/messages.json | 3 -- app/_locales/pt/messages.json | 6 --- app/_locales/pt_BR/messages.json | 3 -- app/_locales/ro/messages.json | 3 -- app/_locales/ru/messages.json | 6 --- app/_locales/sk/messages.json | 3 -- app/_locales/sl/messages.json | 3 -- app/_locales/sr/messages.json | 3 -- app/_locales/sv/messages.json | 3 -- app/_locales/sw/messages.json | 3 -- app/_locales/tl/messages.json | 6 --- app/_locales/tr/messages.json | 6 --- app/_locales/uk/messages.json | 3 -- app/_locales/vi/messages.json | 6 --- app/_locales/zh_CN/messages.json | 6 --- app/_locales/zh_TW/messages.json | 3 -- shared/modules/hexstring-utils.test.js | 45 ++++++++++++++++++- shared/modules/hexstring-utils.ts | 10 +++++ test/e2e/tests/account/import-flow.spec.js | 2 +- .../account/metamask-responsive-ui.spec.js | 2 +- test/e2e/tests/network/network-error.spec.js | 2 +- .../petnames/petnames-transactions.spec.js | 2 +- .../tests/settings/change-language.spec.ts | 6 ++- .../tests/swap-send/swap-send-test-utils.ts | 2 +- .../tokens/custom-token-send-transfer.spec.js | 2 +- test/e2e/tests/tokens/nft/send-nft.spec.js | 6 +-- .../tokens/send-erc20-to-contract.spec.js | 2 +- .../tests/transaction/gas-estimates.spec.js | 12 ++--- test/e2e/tests/transaction/send-eth.spec.js | 8 ++-- .../transaction/send-hex-address.spec.js | 8 ++-- test/e2e/user-actions-benchmark.js | 2 +- .../send/__snapshots__/send.test.js.snap | 2 +- .../multichain/pages/send/send.test.js | 2 +- ui/ducks/send/send.js | 12 +++-- ui/ducks/send/send.test.js | 4 +- .../add-recipient/domain-input.component.js | 18 +++----- 67 files changed, 100 insertions(+), 236 deletions(-) diff --git a/app/_locales/am/messages.json b/app/_locales/am/messages.json index cb193bc11c36..d3e41a97143d 100644 --- a/app/_locales/am/messages.json +++ b/app/_locales/am/messages.json @@ -530,9 +530,6 @@ "readdToken": { "message": "በመለያ አማራጮችዎ ምናሌ ውስጥ ወደ “ተለዋጭ ስም አክል” በመግባት ለወደፊቱ ይህን ተለዋጭ ስም መልሰው ማከል ይችላሉ።" }, - "recipientAddressPlaceholder": { - "message": "ፍለጋ፣ ለሕዝብ ክፍት የሆነ አድራሻ (0x), ወይም ENS" - }, "reject": { "message": "አይቀበሉ" }, diff --git a/app/_locales/ar/messages.json b/app/_locales/ar/messages.json index e262cebf3537..e06284ba9a97 100644 --- a/app/_locales/ar/messages.json +++ b/app/_locales/ar/messages.json @@ -542,9 +542,6 @@ "readdToken": { "message": "يمكنك إضافة هذه العملة الرمزية مرة أخرى في المستقبل من خلال الانتقال إلى \"إضافة عملة رمزية\" في قائمة خيارات الحسابات الخاصة بك." }, - "recipientAddressPlaceholder": { - "message": "البحث، العنوان العام (0x)، أو ENS" - }, "reject": { "message": "رفض" }, diff --git a/app/_locales/bg/messages.json b/app/_locales/bg/messages.json index 2169f13ecf9d..6a55cb677fae 100644 --- a/app/_locales/bg/messages.json +++ b/app/_locales/bg/messages.json @@ -541,9 +541,6 @@ "readdToken": { "message": "Можете да добавите този жетон в бъдеще, като отидете на „Добавяне на жетон“ в менюто с опции на акаунти." }, - "recipientAddressPlaceholder": { - "message": "Търсене, публичен адрес (0x) или ENS" - }, "reject": { "message": "Отхвърляне" }, diff --git a/app/_locales/bn/messages.json b/app/_locales/bn/messages.json index 29e06173be17..5936e87ba918 100644 --- a/app/_locales/bn/messages.json +++ b/app/_locales/bn/messages.json @@ -539,9 +539,6 @@ "readdToken": { "message": "আপনি আপনার অ্যাকাউন্টস বিকল্পের মেনুতে \"টোকেনগুলি যোগ করুন\" এ গিয়ে ভবিষ্যতে আবার এই টোকেনটি যোগ করতে পারবেন। " }, - "recipientAddressPlaceholder": { - "message": "অনুসন্ধান, সার্বজনীন ঠিকানা (0x), বা ENS" - }, "reject": { "message": "প্রত্যাখ্যান" }, diff --git a/app/_locales/ca/messages.json b/app/_locales/ca/messages.json index 4393ea21f108..a129476f1251 100644 --- a/app/_locales/ca/messages.json +++ b/app/_locales/ca/messages.json @@ -526,9 +526,6 @@ "readdToken": { "message": "Pots tornar a afegir aquesta fitxa en el futur anant a \"Afegir fitxa\" al menu d'opcions dels teus comptes." }, - "recipientAddressPlaceholder": { - "message": "Cerca, adreça pública (0x), o ENS" - }, "reject": { "message": "Rebutja" }, diff --git a/app/_locales/da/messages.json b/app/_locales/da/messages.json index f5d7c9c89c3e..b67cfed09236 100644 --- a/app/_locales/da/messages.json +++ b/app/_locales/da/messages.json @@ -526,9 +526,6 @@ "readdToken": { "message": "Du kan tilføje denne token i fremtiden, ved at gå til \"Tilføj token\" under dine valgmenuen for dine konti." }, - "recipientAddressPlaceholder": { - "message": "Søg, offentlig adresse (0x) eller ENS" - }, "reject": { "message": "Afvis" }, diff --git a/app/_locales/de/messages.json b/app/_locales/de/messages.json index 5e1b32229bd1..71e3b3c39483 100644 --- a/app/_locales/de/messages.json +++ b/app/_locales/de/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "Empfangen" }, - "recipientAddressPlaceholder": { - "message": "Öffentliche Adresse (0x) oder ENS-Name eingeben" - }, - "recipientAddressPlaceholderFlask": { - "message": "Öffentliche Adresse (0x) oder Domainname eingeben" - }, "recommendedGasLabel": { "message": "Empfohlen" }, diff --git a/app/_locales/el/messages.json b/app/_locales/el/messages.json index d8f080e7752c..5fe99f91fd2d 100644 --- a/app/_locales/el/messages.json +++ b/app/_locales/el/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "Λήψη" }, - "recipientAddressPlaceholder": { - "message": "Εισάγετε τη δημόσια διεύθυνση (0x) ή το όνομα ENS" - }, - "recipientAddressPlaceholderFlask": { - "message": "Εισαγάγετε τη δημόσια διεύθυνση (0x) ή το όνομα τομέα" - }, "recommendedGasLabel": { "message": "Προτεινόμενο" }, diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 27424ebb89df..f27f8e30e15d 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -4242,10 +4242,7 @@ "receive": { "message": "Receive" }, - "recipientAddressPlaceholder": { - "message": "Enter public address (0x) or ENS name" - }, - "recipientAddressPlaceholderFlask": { + "recipientAddressPlaceholderNew": { "message": "Enter public address (0x) or domain name" }, "recommendedGasLabel": { diff --git a/app/_locales/en_GB/messages.json b/app/_locales/en_GB/messages.json index b7e15bc86b55..4cf930dcc0ac 100644 --- a/app/_locales/en_GB/messages.json +++ b/app/_locales/en_GB/messages.json @@ -4207,10 +4207,7 @@ "receive": { "message": "Receive" }, - "recipientAddressPlaceholder": { - "message": "Enter public address (0x) or ENS name" - }, - "recipientAddressPlaceholderFlask": { + "recipientAddressPlaceholderNew": { "message": "Enter public address (0x) or domain name" }, "recommendedGasLabel": { diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index a20b831091a0..376fa10cee14 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "Recibir" }, - "recipientAddressPlaceholder": { - "message": "Ingrese la dirección pública (0x) o el nombre de ENS" - }, - "recipientAddressPlaceholderFlask": { - "message": "Ingrese la dirección pública (0x) o el nombre de dominio" - }, "recommendedGasLabel": { "message": "Recomendado" }, diff --git a/app/_locales/es_419/messages.json b/app/_locales/es_419/messages.json index c406955c36c9..48a240c887a7 100644 --- a/app/_locales/es_419/messages.json +++ b/app/_locales/es_419/messages.json @@ -1562,9 +1562,6 @@ "receive": { "message": "Recibir" }, - "recipientAddressPlaceholder": { - "message": "Búsqueda, dirección pública (0x) o ENS" - }, "recommendedGasLabel": { "message": "Recomendado" }, diff --git a/app/_locales/et/messages.json b/app/_locales/et/messages.json index dbfe1f88fb55..4e00b3cf5d6a 100644 --- a/app/_locales/et/messages.json +++ b/app/_locales/et/messages.json @@ -535,9 +535,6 @@ "readdToken": { "message": "Saate selle loa tulevikus tagasi lisada, kui lähete oma kontovalikute menüüs vahelehele „Lisa luba“." }, - "recipientAddressPlaceholder": { - "message": "Otsing, avalik aadress (0x) või ENS" - }, "reject": { "message": "Lükka tagasi" }, diff --git a/app/_locales/fa/messages.json b/app/_locales/fa/messages.json index 9f1d89793c1b..76abefbdbdf6 100644 --- a/app/_locales/fa/messages.json +++ b/app/_locales/fa/messages.json @@ -545,9 +545,6 @@ "readdToken": { "message": "شما میتوانید این رمزیاب را دوباره برای آینده با رفتن به گزینه \"Add token\" در مینوی تنظیمات حساب ها، اضافه نمایید." }, - "recipientAddressPlaceholder": { - "message": "جستجو، آدرس عمومی (0x)، یا ENS" - }, "reject": { "message": "عدم پذیرش" }, diff --git a/app/_locales/fi/messages.json b/app/_locales/fi/messages.json index 4f193797912c..bbf6d47c8fdb 100644 --- a/app/_locales/fi/messages.json +++ b/app/_locales/fi/messages.json @@ -542,9 +542,6 @@ "readdToken": { "message": "Voit lisätä tämän tietueen myöhemmin takaisin siirtymällä tilisi vaihtoehtovalikon kohtaan ”Lisää tietue”." }, - "recipientAddressPlaceholder": { - "message": "Haku, julkinen osoite (0x) tai ENS" - }, "reject": { "message": "Hylkää" }, diff --git a/app/_locales/fil/messages.json b/app/_locales/fil/messages.json index ab098442e52e..f30e446877d2 100644 --- a/app/_locales/fil/messages.json +++ b/app/_locales/fil/messages.json @@ -469,9 +469,6 @@ "readdToken": { "message": "Puwede mong idagdag ulit ang token na ito sa hinaharap sa pamamagitan ng pagpunta sa “Magdagdag ng token” sa menu ng mga opsyon ng iyong mga accounts." }, - "recipientAddressPlaceholder": { - "message": "Maghanap, pampublikong address (0x), o ENS" - }, "reject": { "message": "Tanggihan" }, diff --git a/app/_locales/fr/messages.json b/app/_locales/fr/messages.json index 28d08810ae82..0bf19b0dca15 100644 --- a/app/_locales/fr/messages.json +++ b/app/_locales/fr/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "Recevoir" }, - "recipientAddressPlaceholder": { - "message": "Saisissez l’adresse publique (0x) ou le nom de domaine ENS" - }, - "recipientAddressPlaceholderFlask": { - "message": "Saisissez l’adresse publique (0x) ou le nom de domaine" - }, "recommendedGasLabel": { "message": "Recommandé" }, diff --git a/app/_locales/he/messages.json b/app/_locales/he/messages.json index e29f44c9f834..ff2347a4036b 100644 --- a/app/_locales/he/messages.json +++ b/app/_locales/he/messages.json @@ -542,9 +542,6 @@ "readdToken": { "message": "באפשרותך להוסיף טוקן זה בחזרה בעתיד על ידי מעבר אל \"הוסף טוקן\" בתפריט אפשרויות החשבונות שלך." }, - "recipientAddressPlaceholder": { - "message": "חיפוש, כתובת ציבורית (0x), או ENS" - }, "reject": { "message": "דחה" }, diff --git a/app/_locales/hi/messages.json b/app/_locales/hi/messages.json index 2371df612b77..b8cd181f1344 100644 --- a/app/_locales/hi/messages.json +++ b/app/_locales/hi/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "प्राप्त करें" }, - "recipientAddressPlaceholder": { - "message": "सार्वजनिक एड्रेस (0x) या ENS नाम डालें" - }, - "recipientAddressPlaceholderFlask": { - "message": "पब्लिक एड्रेस (0x) या डोमेन नाम एंटर करें" - }, "recommendedGasLabel": { "message": "अनुशंसित" }, diff --git a/app/_locales/hr/messages.json b/app/_locales/hr/messages.json index d7e62da80ba4..1216db40c3de 100644 --- a/app/_locales/hr/messages.json +++ b/app/_locales/hr/messages.json @@ -538,9 +538,6 @@ "readdToken": { "message": "Ovaj token možete dodati kasnije odlaskom pod stavku „Dodaj token” u izborniku mogućnosti računa. " }, - "recipientAddressPlaceholder": { - "message": "Pretraži, javne adrese (0x) ili ENS" - }, "reject": { "message": "Odbaci" }, diff --git a/app/_locales/hu/messages.json b/app/_locales/hu/messages.json index 456b63710dd6..805589352021 100644 --- a/app/_locales/hu/messages.json +++ b/app/_locales/hu/messages.json @@ -538,9 +538,6 @@ "readdToken": { "message": "Ezt a tokent a jövőben is hozzáadhatja, ha a fiókbeállítások menü „Token hozzáadása” elemére lép." }, - "recipientAddressPlaceholder": { - "message": "Keresés, nyilvános cím (0x) vagy ENS" - }, "reject": { "message": "Elutasítás" }, diff --git a/app/_locales/id/messages.json b/app/_locales/id/messages.json index 0f8ceacc9ea7..7895c262eec1 100644 --- a/app/_locales/id/messages.json +++ b/app/_locales/id/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "Terima" }, - "recipientAddressPlaceholder": { - "message": "Masukkan alamat publik (0x) atau nama ENS" - }, - "recipientAddressPlaceholderFlask": { - "message": "Masukkan alamat publik (0x) atau nama domain" - }, "recommendedGasLabel": { "message": "Direkomendasikan" }, diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json index 9f9085f4ed81..e8d06cd4f0e7 100644 --- a/app/_locales/it/messages.json +++ b/app/_locales/it/messages.json @@ -1236,9 +1236,6 @@ "receive": { "message": "Ricevi" }, - "recipientAddressPlaceholder": { - "message": "Ricerca, indirizzo pubblico (0x) o ENS" - }, "reject": { "message": "Annulla" }, diff --git a/app/_locales/ja/messages.json b/app/_locales/ja/messages.json index 44226098f705..e41aa542a902 100644 --- a/app/_locales/ja/messages.json +++ b/app/_locales/ja/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "受取" }, - "recipientAddressPlaceholder": { - "message": "パブリックアドレス (0x) またはENS名を入力してください" - }, - "recipientAddressPlaceholderFlask": { - "message": "パブリックアドレス (0x) またはドメイン名を入力してください" - }, "recommendedGasLabel": { "message": "推奨" }, diff --git a/app/_locales/kn/messages.json b/app/_locales/kn/messages.json index 0b0479e3dddf..b7b5b19512cc 100644 --- a/app/_locales/kn/messages.json +++ b/app/_locales/kn/messages.json @@ -545,9 +545,6 @@ "readdToken": { "message": "ನಿಮ್ಮ ಖಾತೆಗಳ ಆಯ್ಕೆಗಳ ಮೆನುವಿನಲ್ಲಿ \"ಟೋಕನ್ ಸೇರಿಸು\" ಗೆ ಹೋಗುವ ಮೂಲಕ ನೀವು ಈ ಟೋಕನ್ ಅನ್ನು ಭವಿಷ್ಯದಲ್ಲಿ ಮರಳಿ ಸೇರಿಸಬಹುದು." }, - "recipientAddressPlaceholder": { - "message": "ಸಾರ್ವಜನಿಕ ವಿಳಾಸ (0x) ಅಥವಾ ENS ಹುಡುಕಿ" - }, "reject": { "message": "ತಿರಸ್ಕರಿಸಿ" }, diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json index 7286eefb09d7..39a2e3cff82a 100644 --- a/app/_locales/ko/messages.json +++ b/app/_locales/ko/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "받기" }, - "recipientAddressPlaceholder": { - "message": "공개 주소(0x) 또는 ENS 제목 입력" - }, - "recipientAddressPlaceholderFlask": { - "message": "공개 주소(0x) 또는 도메인 이름 입력" - }, "recommendedGasLabel": { "message": "권장됨" }, diff --git a/app/_locales/lt/messages.json b/app/_locales/lt/messages.json index 0600ea96f32b..7ddd53a7e1a2 100644 --- a/app/_locales/lt/messages.json +++ b/app/_locales/lt/messages.json @@ -545,9 +545,6 @@ "readdToken": { "message": "Šį žetoną galite bet kada galite įtraukti ir vėl, tiesiog savo paskyros parinkčių meniu nueikite į „Įtraukti žetoną“." }, - "recipientAddressPlaceholder": { - "message": "Ieška, viešieji adresai (0x) arba ENS" - }, "reject": { "message": "Atmesti" }, diff --git a/app/_locales/lv/messages.json b/app/_locales/lv/messages.json index c0dfc6d573b8..0e0a935b2f69 100644 --- a/app/_locales/lv/messages.json +++ b/app/_locales/lv/messages.json @@ -541,9 +541,6 @@ "readdToken": { "message": "Jūs varat šo marķieri iestatīt atpakaļ nākotnē, konta opciju izvēlnē atverot \"Pievienot marķieri\"." }, - "recipientAddressPlaceholder": { - "message": "Meklēšana, publiskā adrese (0x) vai ENS" - }, "reject": { "message": "Noraidīt" }, diff --git a/app/_locales/ms/messages.json b/app/_locales/ms/messages.json index b8a0cb2ac507..e4c60a72d7b9 100644 --- a/app/_locales/ms/messages.json +++ b/app/_locales/ms/messages.json @@ -525,9 +525,6 @@ "readdToken": { "message": "Anda boleh tambah token ini kembali pada masa depan dengan pergi ke \"Tambah token\" di dalam menu pilihan akaun anda." }, - "recipientAddressPlaceholder": { - "message": "Cari, alamat awam (0x), atau ENS" - }, "reject": { "message": "Tolak" }, diff --git a/app/_locales/no/messages.json b/app/_locales/no/messages.json index 56c05ffd958c..854c191c8539 100644 --- a/app/_locales/no/messages.json +++ b/app/_locales/no/messages.json @@ -529,9 +529,6 @@ "readdToken": { "message": "Du kan legge til dette tokenet igjen i fremtiden ved å gå til \"Legg til token\" i menyen for kontoalternativer." }, - "recipientAddressPlaceholder": { - "message": "Søk, offentlig adresse (0x) eller ENS" - }, "reject": { "message": "Avslå" }, diff --git a/app/_locales/ph/messages.json b/app/_locales/ph/messages.json index debc2d35640a..64ebc5a7d1f2 100644 --- a/app/_locales/ph/messages.json +++ b/app/_locales/ph/messages.json @@ -1013,9 +1013,6 @@ "receive": { "message": "Tumanggap" }, - "recipientAddressPlaceholder": { - "message": "Maghanap, pampublikong address (0x), o ENS" - }, "recoveryPhraseReminderBackupStart": { "message": "Magsimula rito" }, diff --git a/app/_locales/pl/messages.json b/app/_locales/pl/messages.json index dbc986a194e4..e3b8e50acd60 100644 --- a/app/_locales/pl/messages.json +++ b/app/_locales/pl/messages.json @@ -539,9 +539,6 @@ "readdToken": { "message": "Możesz później ponownie dodać ten token poprzez \"Dodaj token\" w opcjach menu swojego konta." }, - "recipientAddressPlaceholder": { - "message": "Szukaj, adres publiczny (0x) lub ENS" - }, "reject": { "message": "Odrzuć" }, diff --git a/app/_locales/pt/messages.json b/app/_locales/pt/messages.json index 3a930315bcbc..15ea173cba64 100644 --- a/app/_locales/pt/messages.json +++ b/app/_locales/pt/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "Receber" }, - "recipientAddressPlaceholder": { - "message": "Insira o endereço público (0x) ou o nome ENS" - }, - "recipientAddressPlaceholderFlask": { - "message": "Insira o endereço público (0x) ou nome do domínio" - }, "recommendedGasLabel": { "message": "Recomendado" }, diff --git a/app/_locales/pt_BR/messages.json b/app/_locales/pt_BR/messages.json index a4b211bb0529..16662a57f07c 100644 --- a/app/_locales/pt_BR/messages.json +++ b/app/_locales/pt_BR/messages.json @@ -1566,9 +1566,6 @@ "receive": { "message": "Receber" }, - "recipientAddressPlaceholder": { - "message": "Busca, endereço público (0x) ou ENS" - }, "recommendedGasLabel": { "message": "Recomendado" }, diff --git a/app/_locales/ro/messages.json b/app/_locales/ro/messages.json index a7f916825e57..906ee4f19184 100644 --- a/app/_locales/ro/messages.json +++ b/app/_locales/ro/messages.json @@ -532,9 +532,6 @@ "readdToken": { "message": "Puteți adăuga din nou acest indicativ în viitor accesând „Adăugați indicativ” din meniul de opțiuni al contului dvs." }, - "recipientAddressPlaceholder": { - "message": "Căutare, adresa publică (0x) sau ENS" - }, "reject": { "message": "Respingeți" }, diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json index f3f948d9a84e..6a2389de53cd 100644 --- a/app/_locales/ru/messages.json +++ b/app/_locales/ru/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "Получить" }, - "recipientAddressPlaceholder": { - "message": "Введите публичный адрес (0x) или имя ENS" - }, - "recipientAddressPlaceholderFlask": { - "message": "Введите публичный адрес (0x) или имя домена" - }, "recommendedGasLabel": { "message": "Рекомендовано" }, diff --git a/app/_locales/sk/messages.json b/app/_locales/sk/messages.json index 79a185cf896c..4d21a69a280f 100644 --- a/app/_locales/sk/messages.json +++ b/app/_locales/sk/messages.json @@ -517,9 +517,6 @@ "readdToken": { "message": "Tento token můžete v budoucnu přidat zpět s „Přidat token“ v nastavení účtu." }, - "recipientAddressPlaceholder": { - "message": "Vyhľadávať verejnú adresu (0x) alebo ENS" - }, "reject": { "message": "Odmítnout" }, diff --git a/app/_locales/sl/messages.json b/app/_locales/sl/messages.json index 64e7c5662c3c..d46a56707fe9 100644 --- a/app/_locales/sl/messages.json +++ b/app/_locales/sl/messages.json @@ -533,9 +533,6 @@ "readdToken": { "message": "Ta žeton lahko dodate tudi kasneje z uporabo gumba “Dodaj žeton” v možnostih vašega računa." }, - "recipientAddressPlaceholder": { - "message": "Iskanje, javni naslov (0x) ali ENS" - }, "reject": { "message": "Zavrni" }, diff --git a/app/_locales/sr/messages.json b/app/_locales/sr/messages.json index 1741b7567833..0f4dfeab00f6 100644 --- a/app/_locales/sr/messages.json +++ b/app/_locales/sr/messages.json @@ -536,9 +536,6 @@ "readdToken": { "message": "U budućnosti možete vratiti ovaj token tako što ćete otvoriti „Dodaj token“ u meniju opcija vašeg naloga." }, - "recipientAddressPlaceholder": { - "message": "Pretraga, javna adresa (0x) ili ENS" - }, "reject": { "message": "Одбиј" }, diff --git a/app/_locales/sv/messages.json b/app/_locales/sv/messages.json index df3766108437..f9b3da4891cf 100644 --- a/app/_locales/sv/messages.json +++ b/app/_locales/sv/messages.json @@ -529,9 +529,6 @@ "readdToken": { "message": "Du kan lägga till denna token i framtiden genom att välja \"Lägg till token\" i kontots alternativmeny." }, - "recipientAddressPlaceholder": { - "message": "Sök, allmän adress (0x) eller ENS" - }, "reject": { "message": "Avvisa" }, diff --git a/app/_locales/sw/messages.json b/app/_locales/sw/messages.json index 7eb535bee573..def606c3a1ca 100644 --- a/app/_locales/sw/messages.json +++ b/app/_locales/sw/messages.json @@ -523,9 +523,6 @@ "readdToken": { "message": "Unaweza kuongeza tena kianzio hiki hapo baadaye kwa kwenda kwenye \"Ongeza kianzio\" kwenye machaguo yako ya menyu ya akaunti." }, - "recipientAddressPlaceholder": { - "message": "Tafuta, anwani za umma (0x), au ENS" - }, "reject": { "message": "Kataa" }, diff --git a/app/_locales/tl/messages.json b/app/_locales/tl/messages.json index 7eecf1acfd13..8c0573c338e8 100644 --- a/app/_locales/tl/messages.json +++ b/app/_locales/tl/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "Tumanggap" }, - "recipientAddressPlaceholder": { - "message": "Ilagay ang pampublikong address (0x) o ENS name" - }, - "recipientAddressPlaceholderFlask": { - "message": "Ilagay ang pampublikong address (0x) o pangalan ng domain" - }, "recommendedGasLabel": { "message": "Nirekomenda" }, diff --git a/app/_locales/tr/messages.json b/app/_locales/tr/messages.json index cc40ce53b487..adccdc2d5752 100644 --- a/app/_locales/tr/messages.json +++ b/app/_locales/tr/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "Al" }, - "recipientAddressPlaceholder": { - "message": "Genel adres (0x) veya ENS adı girin" - }, - "recipientAddressPlaceholderFlask": { - "message": "Genel adres (0x) veya alan adı girin" - }, "recommendedGasLabel": { "message": "Önerilen" }, diff --git a/app/_locales/uk/messages.json b/app/_locales/uk/messages.json index 59bb0b477008..a989977a3561 100644 --- a/app/_locales/uk/messages.json +++ b/app/_locales/uk/messages.json @@ -545,9 +545,6 @@ "readdToken": { "message": "Ви можете знову додати цей токен у меню облікового запису у розділі “Додати токен”. " }, - "recipientAddressPlaceholder": { - "message": "Пошук, публічна адреса (0x), або ENS" - }, "reject": { "message": "Відхилити" }, diff --git a/app/_locales/vi/messages.json b/app/_locales/vi/messages.json index c4795a502a7e..81067ceb67d4 100644 --- a/app/_locales/vi/messages.json +++ b/app/_locales/vi/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "Nhận" }, - "recipientAddressPlaceholder": { - "message": "Nhập địa chỉ công khai (0x) hoặc tên ENS" - }, - "recipientAddressPlaceholderFlask": { - "message": "Nhập địa chỉ công khai (0x) hoặc tên miền" - }, "recommendedGasLabel": { "message": "Được đề xuất" }, diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json index c834c8a18230..883a65447a30 100644 --- a/app/_locales/zh_CN/messages.json +++ b/app/_locales/zh_CN/messages.json @@ -4162,12 +4162,6 @@ "receive": { "message": "收款" }, - "recipientAddressPlaceholder": { - "message": "输入公钥 (0x) 或 ENS 名称" - }, - "recipientAddressPlaceholderFlask": { - "message": "输入公钥 (0x) 或域名" - }, "recommendedGasLabel": { "message": "建议" }, diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json index 83c0fc09e565..5acd2113329c 100644 --- a/app/_locales/zh_TW/messages.json +++ b/app/_locales/zh_TW/messages.json @@ -1005,9 +1005,6 @@ "receive": { "message": "接收" }, - "recipientAddressPlaceholder": { - "message": "搜尋、公開位址 (0x)、或 ENS" - }, "reject": { "message": "拒絕" }, diff --git a/shared/modules/hexstring-utils.test.js b/shared/modules/hexstring-utils.test.js index 74e444437310..9bfeac1978e1 100644 --- a/shared/modules/hexstring-utils.test.js +++ b/shared/modules/hexstring-utils.test.js @@ -1,7 +1,50 @@ import { toChecksumAddress } from 'ethereumjs-util'; -import { isValidHexAddress } from './hexstring-utils'; +import { isValidHexAddress, isPossibleAddress } from './hexstring-utils'; describe('hexstring utils', function () { + describe('isPossibleAddress', function () { + it('should allow 40-char non-prefixed hex', function () { + const address = 'fdea65c8e26263f6d9a1b5de9555d2931a33b825'; + const result = isPossibleAddress(address); + expect(result).toStrictEqual(true); + }); + it('should allow 42-char prefixed hex', function () { + const address = '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825'; + const result = isPossibleAddress(address); + expect(result).toStrictEqual(true); + }); + it('should not allow 42-char prefixed non-hex', function () { + const address = '0xzzzz65c8e26263f6d9a1b5de9555d2931a33b825'; + const result = isPossibleAddress(address); + expect(result).toStrictEqual(false); + }); + it('should not allow 40-char non-prefixed non-hex', function () { + const address = 'zzzz65c8e26263f6d9a1b5de9555d2931a33b825'; + const result = isPossibleAddress(address); + expect(result).toStrictEqual(false); + }); + it('should not allow shorter prefixed hex strings', function () { + const address = '0x1234'; + const result = isPossibleAddress(address); + expect(result).toStrictEqual(false); + }); + it('should not allow shorter non-prefixed hex strings', function () { + const address = '1234'; + const result = isPossibleAddress(address); + expect(result).toStrictEqual(false); + }); + it('should not allow longer prefixed hex strings', function () { + const address = '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825fdea65c8e262'; + const result = isPossibleAddress(address); + expect(result).toStrictEqual(false); + }); + it('should not allow longer non-prefixed hex strings', function () { + const address = 'fdea65c8e26263f6d9a1b5de9555d2931a33b825fdea65c8e262'; + const result = isPossibleAddress(address); + expect(result).toStrictEqual(false); + }); + }); + describe('isValidHexAddress', function () { it('should allow 40-char non-prefixed hex', function () { const address = 'fdea65c8e26263f6d9a1b5de9555d2931a33b825'; diff --git a/shared/modules/hexstring-utils.ts b/shared/modules/hexstring-utils.ts index b81dc1303f9c..84b052716738 100644 --- a/shared/modules/hexstring-utils.ts +++ b/shared/modules/hexstring-utils.ts @@ -66,6 +66,16 @@ export function isValidHexAddress( return isValidAddress(addressToCheck); } +/** + * Determines if a string is a possible ethereum address + * + * @param candidate - the input to check + * @returns true if the input is a 40 char hex string with optional 0x prefix, false otherwise + */ +export function isPossibleAddress(candidate: string) { + return /^(0x)?[0-9a-fA-F]{40}$/iu.test(candidate); +} + export function toChecksumHexAddress(address: string) { if (!address) { // our internal checksumAddress function that this method replaces would diff --git a/test/e2e/tests/account/import-flow.spec.js b/test/e2e/tests/account/import-flow.spec.js index 3c05131090cc..045600cff4f4 100644 --- a/test/e2e/tests/account/import-flow.spec.js +++ b/test/e2e/tests/account/import-flow.spec.js @@ -132,7 +132,7 @@ describe('Import flow @no-mmi', function () { await locateAccountBalanceDOM(driver, ganacheServer); await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0x2f318C334780961FB129D2a6c30D0763d9a5C970', ); await driver.fill('input[placeholder="0"]', '1'); diff --git a/test/e2e/tests/account/metamask-responsive-ui.spec.js b/test/e2e/tests/account/metamask-responsive-ui.spec.js index d9e9aa2f965c..ab36b863d860 100644 --- a/test/e2e/tests/account/metamask-responsive-ui.spec.js +++ b/test/e2e/tests/account/metamask-responsive-ui.spec.js @@ -132,7 +132,7 @@ describe('MetaMask Responsive UI', function () { // starts to send a transaction await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0x2f318C334780961FB129D2a6c30D0763d9a5C970', ); diff --git a/test/e2e/tests/network/network-error.spec.js b/test/e2e/tests/network/network-error.spec.js index 02514f19718c..4d45734edf77 100644 --- a/test/e2e/tests/network/network-error.spec.js +++ b/test/e2e/tests/network/network-error.spec.js @@ -60,7 +60,7 @@ describe('Gas API fallback', function () { await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0x2f318C334780961FB129D2a6c30D0763d9a5C970', ); diff --git a/test/e2e/tests/petnames/petnames-transactions.spec.js b/test/e2e/tests/petnames/petnames-transactions.spec.js index ed8115da4a0c..cc19e44a55eb 100644 --- a/test/e2e/tests/petnames/petnames-transactions.spec.js +++ b/test/e2e/tests/petnames/petnames-transactions.spec.js @@ -22,7 +22,7 @@ async function createDappSendTransaction(driver) { async function createWalletSendTransaction(driver, recipientAddress) { await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', recipientAddress, ); diff --git a/test/e2e/tests/settings/change-language.spec.ts b/test/e2e/tests/settings/change-language.spec.ts index 578c27be84f6..aafb36059c9b 100644 --- a/test/e2e/tests/settings/change-language.spec.ts +++ b/test/e2e/tests/settings/change-language.spec.ts @@ -145,7 +145,11 @@ describe('Settings - general tab @no-mmi', function (this: Suite) { await changeLanguage(driver, languageIndex); await driver.navigate(); await driver.clickElement(selectors.ethOverviewSend); - await driver.fill(selectors.ensInput, 'test'); + await driver.pasteIntoField( + selectors.ensInput, + // use wrong checksum address; other inputs don't show error until snaps name-lookup has happened + '0xAAAA6BF26964aF9D7eEd9e03E53415D37aA96045', + ); // Validate the language change is reflected in the dialog message const isDialogMessageChanged = await driver.isElementPresent( diff --git a/test/e2e/tests/swap-send/swap-send-test-utils.ts b/test/e2e/tests/swap-send/swap-send-test-utils.ts index c5f4d8bb3d9c..e029824f0351 100644 --- a/test/e2e/tests/swap-send/swap-send-test-utils.ts +++ b/test/e2e/tests/swap-send/swap-send-test-utils.ts @@ -21,7 +21,7 @@ export class SwapSendPage { fillRecipientAddressInput = async (address: string) => { await this.driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', address, ); }; diff --git a/test/e2e/tests/tokens/custom-token-send-transfer.spec.js b/test/e2e/tests/tokens/custom-token-send-transfer.spec.js index a5ae0fea449e..0810b9c08e3f 100644 --- a/test/e2e/tests/tokens/custom-token-send-transfer.spec.js +++ b/test/e2e/tests/tokens/custom-token-send-transfer.spec.js @@ -36,7 +36,7 @@ describe('Transfer custom tokens @no-mmi', function () { await driver.delay(500); await driver.clickElement('[data-testid="eth-overview-send"]'); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', recipientAddress, ); await driver.waitForSelector({ diff --git a/test/e2e/tests/tokens/nft/send-nft.spec.js b/test/e2e/tests/tokens/nft/send-nft.spec.js index 37b81eca6794..e7f8681172e9 100644 --- a/test/e2e/tests/tokens/nft/send-nft.spec.js +++ b/test/e2e/tests/tokens/nft/send-nft.spec.js @@ -30,7 +30,7 @@ describe('Send NFT', function () { // TODO: Update Test when Multichain Send Flow is added await driver.clickElement({ text: 'Send', tag: 'button' }); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0xc427D562164062a23a5cFf596A4a3208e72Acd28', ); await driver.clickElement({ @@ -104,7 +104,7 @@ describe('Send NFT', function () { await driver.clickElement({ text: 'Send', tag: 'button' }); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0xc427D562164062a23a5cFf596A4a3208e72Acd28', ); @@ -171,7 +171,7 @@ describe('Send NFT', function () { await driver.clickElement({ text: 'Send', tag: 'button' }); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0xc427D562164062a23a5cFf596A4a3208e72Acd28', ); diff --git a/test/e2e/tests/tokens/send-erc20-to-contract.spec.js b/test/e2e/tests/tokens/send-erc20-to-contract.spec.js index a07bdea9bfdc..6e94b6377e67 100644 --- a/test/e2e/tests/tokens/send-erc20-to-contract.spec.js +++ b/test/e2e/tests/tokens/send-erc20-to-contract.spec.js @@ -36,7 +36,7 @@ describe('Send ERC20 token to contract address', function () { // Type contract address await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', contractAddress, ); diff --git a/test/e2e/tests/transaction/gas-estimates.spec.js b/test/e2e/tests/transaction/gas-estimates.spec.js index c4ce94ee9631..263dfc85d904 100644 --- a/test/e2e/tests/transaction/gas-estimates.spec.js +++ b/test/e2e/tests/transaction/gas-estimates.spec.js @@ -30,7 +30,7 @@ describe('Gas estimates generated by MetaMask', function () { await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0x2f318C334780961FB129D2a6c30D0763d9a5C970', ); @@ -72,7 +72,7 @@ describe('Gas estimates generated by MetaMask', function () { await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0x2f318C334780961FB129D2a6c30D0763d9a5C970', ); @@ -111,7 +111,7 @@ describe('Gas estimates generated by MetaMask', function () { await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0x2f318C334780961FB129D2a6c30D0763d9a5C970', ); @@ -145,7 +145,7 @@ describe('Gas estimates generated by MetaMask', function () { await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0x2f318C334780961FB129D2a6c30D0763d9a5C970', ); @@ -191,7 +191,7 @@ describe('Gas estimates generated by MetaMask', function () { await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0x2f318C334780961FB129D2a6c30D0763d9a5C970', ); @@ -220,7 +220,7 @@ describe('Gas estimates generated by MetaMask', function () { await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0x2f318C334780961FB129D2a6c30D0763d9a5C970', ); diff --git a/test/e2e/tests/transaction/send-eth.spec.js b/test/e2e/tests/transaction/send-eth.spec.js index 5c49bba0cf4e..36872115dcbe 100644 --- a/test/e2e/tests/transaction/send-eth.spec.js +++ b/test/e2e/tests/transaction/send-eth.spec.js @@ -27,7 +27,7 @@ describe('Send ETH', function () { await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0x2f318C334780961FB129D2a6c30D0763d9a5C970', ); @@ -110,7 +110,7 @@ describe('Send ETH', function () { await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0x2f318C334780961FB129D2a6c30D0763d9a5C970', ); @@ -172,7 +172,7 @@ describe('Send ETH', function () { await driver.clickElement('[data-testid="eth-overview-send"]'); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', contractAddress, ); @@ -442,7 +442,7 @@ describe('Send ETH', function () { await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0xc427D562164062a23a5cFf596A4a3208e72Acd28', ); diff --git a/test/e2e/tests/transaction/send-hex-address.spec.js b/test/e2e/tests/transaction/send-hex-address.spec.js index 6adb6b5f9f6c..d93f1a0d5484 100644 --- a/test/e2e/tests/transaction/send-hex-address.spec.js +++ b/test/e2e/tests/transaction/send-hex-address.spec.js @@ -27,7 +27,7 @@ describe('Send ETH to a 40 character hexadecimal address', function () { await openActionMenuAndStartSendFlow(driver); // Paste address without hex prefix await driver.pasteIntoField( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', nonHexPrefixedAddress, ); await driver.findElement({ @@ -72,7 +72,7 @@ describe('Send ETH to a 40 character hexadecimal address', function () { await openActionMenuAndStartSendFlow(driver); // Type address without hex prefix await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', nonHexPrefixedAddress, ); await driver.findElement({ @@ -130,7 +130,7 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () { await driver.clickElement('[data-testid="coin-overview-send"]'); // Paste address without hex prefix await driver.pasteIntoField( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', nonHexPrefixedAddress, ); await driver.findElement({ @@ -192,7 +192,7 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () { // Type address without hex prefix await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', nonHexPrefixedAddress, ); await driver.findElement({ diff --git a/test/e2e/user-actions-benchmark.js b/test/e2e/user-actions-benchmark.js index 515764b6259b..5a851c59d61f 100644 --- a/test/e2e/user-actions-benchmark.js +++ b/test/e2e/user-actions-benchmark.js @@ -73,7 +73,7 @@ async function confirmTx() { await openActionMenuAndStartSendFlow(driver); await driver.fill( - 'input[placeholder="Enter public address (0x) or ENS name"]', + 'input[placeholder="Enter public address (0x) or domain name"]', '0x2f318C334780961FB129D2a6c30D0763d9a5C970', ); diff --git a/ui/components/multichain/pages/send/__snapshots__/send.test.js.snap b/ui/components/multichain/pages/send/__snapshots__/send.test.js.snap index 7d7ed8e0c131..7d05e9d44a0b 100644 --- a/ui/components/multichain/pages/send/__snapshots__/send.test.js.snap +++ b/ui/components/multichain/pages/send/__snapshots__/send.test.js.snap @@ -178,7 +178,7 @@ exports[`SendPage render and initialization should render correctly even when a class="ens-input__wrapper__input" data-testid="ens-input" dir="auto" - placeholder="Enter public address (0x) or ENS name" + placeholder="Enter public address (0x) or domain name" spellcheck="false" type="text" value="" diff --git a/ui/components/multichain/pages/send/send.test.js b/ui/components/multichain/pages/send/send.test.js index 164fe2b8bb3c..cdba904090b2 100644 --- a/ui/components/multichain/pages/send/send.test.js +++ b/ui/components/multichain/pages/send/send.test.js @@ -274,7 +274,7 @@ describe('SendPage', () => { // Ensure that the send flow renders on the add recipient screen when // there is no draft transaction. expect( - getByPlaceholderText('Enter public address (0x) or ENS name'), + getByPlaceholderText('Enter public address (0x) or domain name'), ).toBeTruthy(); expect(container).toMatchSnapshot(); diff --git a/ui/ducks/send/send.js b/ui/ducks/send/send.js index 672ee0ea4395..4627b4fe2f44 100644 --- a/ui/ducks/send/send.js +++ b/ui/ducks/send/send.js @@ -95,11 +95,9 @@ import { getTokenIdParam, } from '../../helpers/utils/token-util'; import { - IS_FLASK, checkExistingAddresses, isDefaultMetaMaskChain, isOriginContractAddress, - isValidDomainName, } from '../../helpers/utils/util'; import { getGasEstimateType, @@ -112,6 +110,7 @@ import { resetDomainResolution } from '../domains'; import { isBurnAddress, isValidHexAddress, + isPossibleAddress, toChecksumHexAddress, } from '../../../shared/modules/hexstring-utils'; import { isSmartContractAddress } from '../../helpers/utils/transactions.util'; @@ -1607,11 +1606,10 @@ const slice = createSlice({ if ( isBurnAddress(state.recipientInput) || - (!isValidHexAddress(state.recipientInput, { - mixedCaseUseChecksum: true, - }) && - !IS_FLASK && - !isValidDomainName(state.recipientInput)) + (isPossibleAddress(state.recipientInput) && + !isValidHexAddress(state.recipientInput, { + mixedCaseUseChecksum: true, + })) ) { draftTransaction.recipient.error = isDefaultMetaMaskChain(chainId) ? INVALID_RECIPIENT_ADDRESS_ERROR diff --git a/ui/ducks/send/send.test.js b/ui/ducks/send/send.test.js index 70ca9cde62c7..0a19623db066 100644 --- a/ui/ducks/send/send.test.js +++ b/ui/ducks/send/send.test.js @@ -768,7 +768,7 @@ describe('Send Slice', () => { it('should error with an invalid address error when user input is not a valid hex string', () => { const tokenAssetTypeState = { ...INITIAL_SEND_STATE_FOR_EXISTING_DRAFT, - recipientInput: '0xValidateError', + recipientInput: '0xAAAA6BF26964aF9D7eEd9e03E53415D37aA96045', }; const action = { type: 'send/validateRecipientUserInput', @@ -793,7 +793,7 @@ describe('Send Slice', () => { it('should error with an invalid network error when user input is not a valid hex string on a non default network', () => { const tokenAssetTypeState = { ...INITIAL_SEND_STATE_FOR_EXISTING_DRAFT, - recipientInput: '0xValidateError', + recipientInput: '0xAAAA6BF26964aF9D7eEd9e03E53415D37aA96045', }; const action = { type: 'send/validateRecipientUserInput', diff --git a/ui/pages/confirmations/send/send-content/add-recipient/domain-input.component.js b/ui/pages/confirmations/send/send-content/add-recipient/domain-input.component.js index 5eef93681a3c..0b2514f12414 100644 --- a/ui/pages/confirmations/send/send-content/add-recipient/domain-input.component.js +++ b/ui/pages/confirmations/send/send-content/add-recipient/domain-input.component.js @@ -4,11 +4,7 @@ import classnames from 'classnames'; import { isHexString } from '@metamask/utils'; import { addHexPrefix } from '../../../../../../app/scripts/lib/util'; -import { - IS_FLASK, - isValidDomainName, - shortenAddress, -} from '../../../../../helpers/utils/util'; +import { shortenAddress } from '../../../../../helpers/utils/util'; import { isBurnAddress, isValidHexAddress, @@ -87,9 +83,7 @@ export default class DomainInput extends Component { return null; } - if ((IS_FLASK && !isHexString(input)) || isValidDomainName(input)) { - lookupDomainName(input); - } else { + if (isHexString(input)) { resetDomainResolution(); if ( onValidAddressTyped && @@ -98,6 +92,8 @@ export default class DomainInput extends Component { ) { onValidAddressTyped(addHexPrefix(input)); } + } else { + lookupDomainName(input); } return null; @@ -167,11 +163,7 @@ export default class DomainInput extends Component { className="ens-input__wrapper__input" type="text" dir="auto" - placeholder={ - IS_FLASK - ? t('recipientAddressPlaceholderFlask') - : t('recipientAddressPlaceholder') - } + placeholder={t('recipientAddressPlaceholderNew')} onChange={this.onChange} onPaste={this.onPaste} spellCheck="false"