From 2a9fbffb6cfcb0f6000b351c4e126deab3cddec3 Mon Sep 17 00:00:00 2001 From: Alex Donesky Date: Wed, 15 Sep 2021 16:54:51 -0500 Subject: [PATCH] Replace hardcoded sent ether label on confirm screen (#11802) * Replace hardcoded sent ether label on confirm screen * replace transaction type SENT_ETHER with network agnostic SENDING_NATIVE_ASSET * remove sentEther translation base * make backwards compatible with lingering transaction of legacy sentEther type * update localalization files * fixup legacy sentEther transaction type * changing new transaction type away from localization string * revert migration tests * update fixtures and test data * update name of new transaction type * add migration * remove legacy SENT_ETHER from transaction types enum object --- 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 | 3 - app/_locales/el/messages.json | 3 - app/_locales/en/messages.json | 5 +- app/_locales/es/messages.json | 3 - 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 | 3 - app/_locales/he/messages.json | 3 - app/_locales/hi/messages.json | 3 - app/_locales/hr/messages.json | 3 - app/_locales/ht/messages.json | 3 - app/_locales/hu/messages.json | 3 - app/_locales/id/messages.json | 3 - app/_locales/it/messages.json | 3 - app/_locales/ja/messages.json | 3 - app/_locales/kn/messages.json | 3 - app/_locales/ko/messages.json | 3 - 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_BR/messages.json | 3 - app/_locales/ro/messages.json | 3 - app/_locales/ru/messages.json | 3 - 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 | 3 - app/_locales/uk/messages.json | 3 - app/_locales/vi/messages.json | 3 - app/_locales/zh_CN/messages.json | 3 - app/_locales/zh_TW/messages.json | 3 - app/scripts/controllers/network/util.test.js | 9 +- app/scripts/controllers/transactions/index.js | 6 +- .../controllers/transactions/index.test.js | 24 +- .../transactions/tx-state-manager.test.js | 8 +- app/scripts/migrations/053.test.js | 13 +- app/scripts/migrations/059.test.js | 28 +- app/scripts/migrations/064.js | 41 ++ app/scripts/migrations/064.test.js | 469 ++++++++++++++++++ app/scripts/migrations/index.js | 2 + shared/constants/transaction.js | 4 +- test/data/transaction-data.json | 12 +- test/e2e/fixtures/import-ui/state.json | 2 +- test/e2e/fixtures/send-edit/state.json | 4 +- test/stub/tx-meta-stub.js | 4 +- ui/helpers/utils/transactions.util.js | 7 +- ui/hooks/useTransactionDisplayData.js | 2 +- .../confirm-transaction-base.component.js | 4 +- .../confirm-transaction-base.container.js | 3 + .../confirm-transaction-switch.component.js | 2 +- 64 files changed, 589 insertions(+), 192 deletions(-) create mode 100644 app/scripts/migrations/064.js create mode 100644 app/scripts/migrations/064.test.js diff --git a/app/_locales/am/messages.json b/app/_locales/am/messages.json index 711d16d73..50fa63a2e 100644 --- a/app/_locales/am/messages.json +++ b/app/_locales/am/messages.json @@ -886,9 +886,6 @@ "sendTokens": { "message": "ተለዋጭ ስሞችን ላክ" }, - "sentEther": { - "message": "የተላከ ether" - }, "separateEachWord": { "message": "እያንዳንዱን ቃል በነጠላ ክፍት ቦታ ይለያዩ" }, diff --git a/app/_locales/ar/messages.json b/app/_locales/ar/messages.json index d1f48d6a1..5f37cb4e1 100644 --- a/app/_locales/ar/messages.json +++ b/app/_locales/ar/messages.json @@ -882,9 +882,6 @@ "sendTokens": { "message": "إرسال عملات رمزية" }, - "sentEther": { - "message": "أرسل عملة إيثير" - }, "separateEachWord": { "message": "افصل كل كلمة بمسافة واحدة" }, diff --git a/app/_locales/bg/messages.json b/app/_locales/bg/messages.json index 88959a469..57196e3b3 100644 --- a/app/_locales/bg/messages.json +++ b/app/_locales/bg/messages.json @@ -885,9 +885,6 @@ "sendTokens": { "message": "Изпращане на жетони" }, - "sentEther": { - "message": "изпратен етер" - }, "separateEachWord": { "message": "Отделете всяка дума с интервал" }, diff --git a/app/_locales/bn/messages.json b/app/_locales/bn/messages.json index 3fb3a3a63..19c45effd 100644 --- a/app/_locales/bn/messages.json +++ b/app/_locales/bn/messages.json @@ -889,9 +889,6 @@ "sendTokens": { "message": "টোকেনগুলি পাঠান" }, - "sentEther": { - "message": "পাঠানো ইথার " - }, "separateEachWord": { "message": "প্রতিটি শব্দকে একটি স্পেস দিয়ে আলাদা করুন" }, diff --git a/app/_locales/ca/messages.json b/app/_locales/ca/messages.json index e37ffcae7..fe3311ead 100644 --- a/app/_locales/ca/messages.json +++ b/app/_locales/ca/messages.json @@ -867,9 +867,6 @@ "sendTokens": { "message": "Enviar Fitxes" }, - "sentEther": { - "message": "envia ether" - }, "separateEachWord": { "message": "Separa cada paraula amb un sol espai" }, diff --git a/app/_locales/da/messages.json b/app/_locales/da/messages.json index 5bb5b7188..c4c147bda 100644 --- a/app/_locales/da/messages.json +++ b/app/_locales/da/messages.json @@ -867,9 +867,6 @@ "sendTokens": { "message": "Send tokens" }, - "sentEther": { - "message": "sendte ether" - }, "separateEachWord": { "message": "Separer hvert ord med et enkelt mellemrum" }, diff --git a/app/_locales/de/messages.json b/app/_locales/de/messages.json index 666ff3dd7..d6e52d78b 100644 --- a/app/_locales/de/messages.json +++ b/app/_locales/de/messages.json @@ -858,9 +858,6 @@ "sendTokens": { "message": "Token senden" }, - "sentEther": { - "message": "Ether senden" - }, "separateEachWord": { "message": "Trennen Sie die Wörter mit einem einzelnen Leerzeichen voneinander" }, diff --git a/app/_locales/el/messages.json b/app/_locales/el/messages.json index f1c49dfd0..e7239b9ae 100644 --- a/app/_locales/el/messages.json +++ b/app/_locales/el/messages.json @@ -886,9 +886,6 @@ "sendTokens": { "message": "Στείλτε Tokens" }, - "sentEther": { - "message": "απεσταλμένα ether" - }, "separateEachWord": { "message": "Διαχωρίστε κάθε λέξη με ένα μόνο κενό" }, diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 31a10e9f1..df8fd5139 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -1958,8 +1958,9 @@ "sendTokens": { "message": "Send Tokens" }, - "sentEther": { - "message": "sent ether" + "sendingNativeAsset": { + "message": "Sending $1", + "description": "$1 represents the native currency symbol for the current network (e.g. ETH or BNB)" }, "separateEachWord": { "message": "Separate each word with a single space" diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index 2334f927e..b30beb5bc 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -1688,9 +1688,6 @@ "sendTokens": { "message": "Enviar tokens" }, - "sentEther": { - "message": "enviar ether" - }, "separateEachWord": { "message": "Separar cada palabra con un solo espacio" }, diff --git a/app/_locales/es_419/messages.json b/app/_locales/es_419/messages.json index 2334f927e..b30beb5bc 100644 --- a/app/_locales/es_419/messages.json +++ b/app/_locales/es_419/messages.json @@ -1688,9 +1688,6 @@ "sendTokens": { "message": "Enviar tokens" }, - "sentEther": { - "message": "enviar ether" - }, "separateEachWord": { "message": "Separar cada palabra con un solo espacio" }, diff --git a/app/_locales/et/messages.json b/app/_locales/et/messages.json index 0e93a6582..f44cca3d0 100644 --- a/app/_locales/et/messages.json +++ b/app/_locales/et/messages.json @@ -879,9 +879,6 @@ "sendTokens": { "message": "Saada lube" }, - "sentEther": { - "message": "saadetud eeter" - }, "separateEachWord": { "message": "Eraldage iga sõna ühe tühikuga" }, diff --git a/app/_locales/fa/messages.json b/app/_locales/fa/messages.json index d2697ac19..96b9ece48 100644 --- a/app/_locales/fa/messages.json +++ b/app/_locales/fa/messages.json @@ -889,9 +889,6 @@ "sendTokens": { "message": "رمزیاب ها را ارسال کنید" }, - "sentEther": { - "message": "ایتر ارسال شد" - }, "separateEachWord": { "message": "هر کلمه را با یک فاصله واحد جدا سازید" }, diff --git a/app/_locales/fi/messages.json b/app/_locales/fi/messages.json index 4afc1159b..2baae1b63 100644 --- a/app/_locales/fi/messages.json +++ b/app/_locales/fi/messages.json @@ -886,9 +886,6 @@ "sendTokens": { "message": "Lähetä tietueita" }, - "sentEther": { - "message": "lähetä etheriä" - }, "separateEachWord": { "message": "Erottele sanat toisistaan yhdellä välilyönnillä" }, diff --git a/app/_locales/fil/messages.json b/app/_locales/fil/messages.json index 78b37425f..a472c8bd0 100644 --- a/app/_locales/fil/messages.json +++ b/app/_locales/fil/messages.json @@ -801,9 +801,6 @@ "sendTokens": { "message": "Magpadala ng Mga Token" }, - "sentEther": { - "message": "nagpadala ng ether" - }, "separateEachWord": { "message": "Paghiwa-hiwalayin ang bawat salita gamit ang isang space" }, diff --git a/app/_locales/fr/messages.json b/app/_locales/fr/messages.json index 10cb15e3d..84b62b472 100644 --- a/app/_locales/fr/messages.json +++ b/app/_locales/fr/messages.json @@ -871,9 +871,6 @@ "sendTokens": { "message": "Envoyer des jetons" }, - "sentEther": { - "message": "Ether envoyé" - }, "separateEachWord": { "message": "Separez chaque mot avec un espace simple" }, diff --git a/app/_locales/he/messages.json b/app/_locales/he/messages.json index 0c0b7c0a0..3ddc4e4fb 100644 --- a/app/_locales/he/messages.json +++ b/app/_locales/he/messages.json @@ -883,9 +883,6 @@ "sendTokens": { "message": "שלח טוקנים" }, - "sentEther": { - "message": "את'ר שנשלח" - }, "separateEachWord": { "message": "יש להפריד כל מילה עם רווח יחיד" }, diff --git a/app/_locales/hi/messages.json b/app/_locales/hi/messages.json index 322e798cb..2e025fb15 100644 --- a/app/_locales/hi/messages.json +++ b/app/_locales/hi/messages.json @@ -1688,9 +1688,6 @@ "sendTokens": { "message": "टोकन भेजें" }, - "sentEther": { - "message": "Ether भेजा गया" - }, "separateEachWord": { "message": "प्रत्येक शब्द को एक रिक्ति से अलग करें" }, diff --git a/app/_locales/hr/messages.json b/app/_locales/hr/messages.json index d098a05e1..656fd84f9 100644 --- a/app/_locales/hr/messages.json +++ b/app/_locales/hr/messages.json @@ -882,9 +882,6 @@ "sendTokens": { "message": "Pošalji tokene" }, - "sentEther": { - "message": "pošalji ether" - }, "separateEachWord": { "message": "Odvojite pojedinačne riječi jednim razmakom" }, diff --git a/app/_locales/ht/messages.json b/app/_locales/ht/messages.json index b04cb3298..6cab69c61 100644 --- a/app/_locales/ht/messages.json +++ b/app/_locales/ht/messages.json @@ -552,9 +552,6 @@ "sendTokens": { "message": "Voye Tokens" }, - "sentEther": { - "message": "Voye ether" - }, "separateEachWord": { "message": "Separe chak mo ak yon sèl espas" }, diff --git a/app/_locales/hu/messages.json b/app/_locales/hu/messages.json index cc8dd451d..7e8cec14b 100644 --- a/app/_locales/hu/messages.json +++ b/app/_locales/hu/messages.json @@ -882,9 +882,6 @@ "sendTokens": { "message": "Token küldése" }, - "sentEther": { - "message": "elküldött ether" - }, "separateEachWord": { "message": "Minden egyes szavat szóközzel válasszon el" }, diff --git a/app/_locales/id/messages.json b/app/_locales/id/messages.json index dc3ff2a7f..9495ff5c4 100644 --- a/app/_locales/id/messages.json +++ b/app/_locales/id/messages.json @@ -1688,9 +1688,6 @@ "sendTokens": { "message": "Kirim Token" }, - "sentEther": { - "message": "ether terkirim" - }, "separateEachWord": { "message": "Pisahkan setiap kata dengan satu spasi" }, diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json index 88bee983f..c9264ef4b 100644 --- a/app/_locales/it/messages.json +++ b/app/_locales/it/messages.json @@ -1368,9 +1368,6 @@ "sendTokens": { "message": "Invia Tokens" }, - "sentEther": { - "message": "ether inviati" - }, "separateEachWord": { "message": "Separa ogni parola con un solo spazio" }, diff --git a/app/_locales/ja/messages.json b/app/_locales/ja/messages.json index c567f7eff..4845b2fce 100644 --- a/app/_locales/ja/messages.json +++ b/app/_locales/ja/messages.json @@ -1688,9 +1688,6 @@ "sendTokens": { "message": "トークンの送信" }, - "sentEther": { - "message": "Ether の送金" - }, "separateEachWord": { "message": "単語ごとにスペースを 1 つ置いて分離します" }, diff --git a/app/_locales/kn/messages.json b/app/_locales/kn/messages.json index f3e77b362..7aad7aed4 100644 --- a/app/_locales/kn/messages.json +++ b/app/_locales/kn/messages.json @@ -889,9 +889,6 @@ "sendTokens": { "message": "ಟೋಕನ್‌ಗಳನ್ನು ಕಳುಹಿಸಿ" }, - "sentEther": { - "message": "ಕಳುಹಿಸಲಾದ ಎಥರ್" - }, "separateEachWord": { "message": "ಒಂದು ಸ್ಪೇಸ್ ಮೂಲಕ ಪ್ರತಿ ಪದವನ್ನು ಬೇರ್ಪಡಿಸಿ" }, diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json index 10b9cfab7..ef61925e9 100644 --- a/app/_locales/ko/messages.json +++ b/app/_locales/ko/messages.json @@ -1688,9 +1688,6 @@ "sendTokens": { "message": "토큰 보내기" }, - "sentEther": { - "message": "Ether 보냄" - }, "separateEachWord": { "message": "공백 한 칸으로 각 단어를 구분하세요." }, diff --git a/app/_locales/lt/messages.json b/app/_locales/lt/messages.json index 8842ad587..f315161d8 100644 --- a/app/_locales/lt/messages.json +++ b/app/_locales/lt/messages.json @@ -889,9 +889,6 @@ "sendTokens": { "message": "Siųsti žetonus" }, - "sentEther": { - "message": "siųsti eterių" - }, "separateEachWord": { "message": "Kiekvieną žodį atskirkite viengubu tarpu" }, diff --git a/app/_locales/lv/messages.json b/app/_locales/lv/messages.json index 354000cc6..3fdcc90a0 100644 --- a/app/_locales/lv/messages.json +++ b/app/_locales/lv/messages.json @@ -885,9 +885,6 @@ "sendTokens": { "message": "Nosūtīt marķierus" }, - "sentEther": { - "message": "nosūtītie ether" - }, "separateEachWord": { "message": "Atdaliet katru vārdu ar vienu atstarpi" }, diff --git a/app/_locales/ms/messages.json b/app/_locales/ms/messages.json index 8a98ca519..38f440b04 100644 --- a/app/_locales/ms/messages.json +++ b/app/_locales/ms/messages.json @@ -866,9 +866,6 @@ "sendTokens": { "message": "Hantar Token" }, - "sentEther": { - "message": "menghantar ether" - }, "separateEachWord": { "message": "Pisahkan setiap perkataan dengan ruang tunggal" }, diff --git a/app/_locales/no/messages.json b/app/_locales/no/messages.json index 5b1f53c02..c63a23962 100644 --- a/app/_locales/no/messages.json +++ b/app/_locales/no/messages.json @@ -870,9 +870,6 @@ "sendTokens": { "message": "Send tokener" }, - "sentEther": { - "message": "sendt ether" - }, "separateEachWord": { "message": "Del hvert ord med et enkelt mellomrom " }, diff --git a/app/_locales/ph/messages.json b/app/_locales/ph/messages.json index 280e98d5e..6d95c0e6c 100644 --- a/app/_locales/ph/messages.json +++ b/app/_locales/ph/messages.json @@ -1688,9 +1688,6 @@ "sendTokens": { "message": "Magpadala ng Mga Token" }, - "sentEther": { - "message": "nagpadala ng ether" - }, "separateEachWord": { "message": "Paghiwa-hiwalayin ang bawat salita gamit ang isang space" }, diff --git a/app/_locales/pl/messages.json b/app/_locales/pl/messages.json index c906d01f0..4c7b7383d 100644 --- a/app/_locales/pl/messages.json +++ b/app/_locales/pl/messages.json @@ -883,9 +883,6 @@ "sendTokens": { "message": "Wyślij tokeny" }, - "sentEther": { - "message": "wyślij eter" - }, "separateEachWord": { "message": "Oddziel słowa pojedynczą spacją" }, diff --git a/app/_locales/pt_BR/messages.json b/app/_locales/pt_BR/messages.json index 90ae89a9c..b59751391 100644 --- a/app/_locales/pt_BR/messages.json +++ b/app/_locales/pt_BR/messages.json @@ -1688,9 +1688,6 @@ "sendTokens": { "message": "Enviar tokens" }, - "sentEther": { - "message": "ether enviado" - }, "separateEachWord": { "message": "Separe cada palavra com um único espaço" }, diff --git a/app/_locales/ro/messages.json b/app/_locales/ro/messages.json index efe1f2b75..9e934ab69 100644 --- a/app/_locales/ro/messages.json +++ b/app/_locales/ro/messages.json @@ -876,9 +876,6 @@ "sendTokens": { "message": "Trimiteți indicative" }, - "sentEther": { - "message": "trimiteți ether" - }, "separateEachWord": { "message": "Despărțiți fiecare cuvânt cu un spațiu" }, diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json index 2cc556eb6..75d64732f 100644 --- a/app/_locales/ru/messages.json +++ b/app/_locales/ru/messages.json @@ -1688,9 +1688,6 @@ "sendTokens": { "message": "Отправить токены" }, - "sentEther": { - "message": "отправленный Ether" - }, "separateEachWord": { "message": "Отделяйте каждое слово одним пробелом" }, diff --git a/app/_locales/sk/messages.json b/app/_locales/sk/messages.json index f1a199f77..0a5af86c0 100644 --- a/app/_locales/sk/messages.json +++ b/app/_locales/sk/messages.json @@ -852,9 +852,6 @@ "sendTokens": { "message": "Odeslat tokeny" }, - "sentEther": { - "message": "poslaný ether" - }, "separateEachWord": { "message": "Každé slovo oddeľte jednou medzerou" }, diff --git a/app/_locales/sl/messages.json b/app/_locales/sl/messages.json index 07d7e9c58..2aa7c40d3 100644 --- a/app/_locales/sl/messages.json +++ b/app/_locales/sl/messages.json @@ -874,9 +874,6 @@ "sendTokens": { "message": "Pošlji žetone" }, - "sentEther": { - "message": "poslani ether" - }, "separateEachWord": { "message": "Vsako besedo ločite z enim presledkom" }, diff --git a/app/_locales/sr/messages.json b/app/_locales/sr/messages.json index e1a3eb0b3..5a21f3df1 100644 --- a/app/_locales/sr/messages.json +++ b/app/_locales/sr/messages.json @@ -880,9 +880,6 @@ "sendTokens": { "message": "Pošalji tokene" }, - "sentEther": { - "message": "ether je poslat" - }, "separateEachWord": { "message": "Razdvojite svaku reč jednim mestom razmaka" }, diff --git a/app/_locales/sv/messages.json b/app/_locales/sv/messages.json index 658158ed4..790027eda 100644 --- a/app/_locales/sv/messages.json +++ b/app/_locales/sv/messages.json @@ -873,9 +873,6 @@ "sendTokens": { "message": "Skicka tokens" }, - "sentEther": { - "message": "skickat ether" - }, "separateEachWord": { "message": "Lägg in ett mellanslag mellan varje ord" }, diff --git a/app/_locales/sw/messages.json b/app/_locales/sw/messages.json index 720adc847..79c583c7b 100644 --- a/app/_locales/sw/messages.json +++ b/app/_locales/sw/messages.json @@ -867,9 +867,6 @@ "sendTokens": { "message": "Tuma Vianzio" }, - "sentEther": { - "message": "ether iliyotumwa" - }, "separateEachWord": { "message": "Tenganisha kila neno kwa nafasi moja" }, diff --git a/app/_locales/tl/messages.json b/app/_locales/tl/messages.json index 02280e381..9a0cc2a9f 100644 --- a/app/_locales/tl/messages.json +++ b/app/_locales/tl/messages.json @@ -1359,9 +1359,6 @@ "sendTokens": { "message": "Magpadala ng Mga Token" }, - "sentEther": { - "message": "nagpadala ng ether" - }, "separateEachWord": { "message": "Paghiwa-hiwalayin ang bawat salita gamit ang espasyo" }, diff --git a/app/_locales/uk/messages.json b/app/_locales/uk/messages.json index 2a41af51f..a9d372722 100644 --- a/app/_locales/uk/messages.json +++ b/app/_locales/uk/messages.json @@ -889,9 +889,6 @@ "sendTokens": { "message": "Надіслати токени" }, - "sentEther": { - "message": "надісланий ефір" - }, "separateEachWord": { "message": "Відділіть кожне слово одним пробілом" }, diff --git a/app/_locales/vi/messages.json b/app/_locales/vi/messages.json index b28cbf86a..8e6f91aa3 100644 --- a/app/_locales/vi/messages.json +++ b/app/_locales/vi/messages.json @@ -1688,9 +1688,6 @@ "sendTokens": { "message": "Gửi token" }, - "sentEther": { - "message": "đã gửi ether" - }, "separateEachWord": { "message": "Phân tách mỗi từ bằng một dấu cách" }, diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json index 02ec5f565..6f3338e2b 100644 --- a/app/_locales/zh_CN/messages.json +++ b/app/_locales/zh_CN/messages.json @@ -1362,9 +1362,6 @@ "sendTokens": { "message": "发送代币" }, - "sentEther": { - "message": "发送 Ether" - }, "separateEachWord": { "message": "用空格分隔每个单词" }, diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json index 17d9bc73b..045826588 100644 --- a/app/_locales/zh_TW/messages.json +++ b/app/_locales/zh_TW/messages.json @@ -877,9 +877,6 @@ "sendTokens": { "message": "發送代幣" }, - "sentEther": { - "message": "發送以太幣" - }, "separateEachWord": { "message": "單詞之間請以空白間隔" }, diff --git a/app/scripts/controllers/network/util.test.js b/app/scripts/controllers/network/util.test.js index 251812741..f8e03ff0f 100644 --- a/app/scripts/controllers/network/util.test.js +++ b/app/scripts/controllers/network/util.test.js @@ -1,5 +1,8 @@ import { strict as assert } from 'assert'; -import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'; +import { + TRANSACTION_STATUSES, + TRANSACTION_TYPES, +} from '../../../../shared/constants/transaction'; import { formatTxMetaForRpcResult } from './util'; describe('network utils', function () { @@ -16,7 +19,7 @@ describe('network utils', function () { gas: '0x7b0d', nonce: '0x4b', }, - type: 'sentEther', + type: TRANSACTION_TYPES.SIMPLE_SEND, origin: 'other', chainId: '0x3', time: 1624408066355, @@ -63,7 +66,7 @@ describe('network utils', function () { gas: '0x7b0d', nonce: '0x4b', }, - type: 'sentEther', + type: TRANSACTION_TYPES.SIMPLE_SEND, origin: 'other', chainId: '0x3', time: 1624408066355, diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 5fe5cc4e6..0aa43d339 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -584,7 +584,7 @@ export default class TransactionController extends EventEmitter { return {}; } else if ( txMeta.txParams.to && - txMeta.type === TRANSACTION_TYPES.SENT_ETHER && + txMeta.type === TRANSACTION_TYPES.SIMPLE_SEND && chainType !== 'custom' ) { // if there's data in the params, but there's no contract code, it's not a valid transaction @@ -1191,7 +1191,7 @@ export default class TransactionController extends EventEmitter { } /** - * @typedef { 'transfer' | 'approve' | 'transferfrom' | 'contractInteraction'| 'sentEther' } InferrableTransactionTypes + * @typedef { 'transfer' | 'approve' | 'transferfrom' | 'contractInteraction'| 'simpleSend' } InferrableTransactionTypes */ /** @@ -1245,7 +1245,7 @@ export default class TransactionController extends EventEmitter { const codeIsEmpty = !code || code === '0x' || code === '0x0'; result = codeIsEmpty - ? TRANSACTION_TYPES.SENT_ETHER + ? TRANSACTION_TYPES.SIMPLE_SEND : TRANSACTION_TYPES.CONTRACT_INTERACTION; } diff --git a/app/scripts/controllers/transactions/index.test.js b/app/scripts/controllers/transactions/index.test.js index 8d12c4138..56669d267 100644 --- a/app/scripts/controllers/transactions/index.test.js +++ b/app/scripts/controllers/transactions/index.test.js @@ -716,7 +716,7 @@ describe('Transaction Controller', function () { gas: '0x7b0d', nonce: '0x4b', }, - type: 'sentEther', + type: TRANSACTION_TYPES.SIMPLE_SEND, transaction_envelope_type: 'legacy', origin: 'metamask', chainId: currentChainId, @@ -1239,7 +1239,7 @@ describe('Transaction Controller', function () { data: '', }); assert.deepEqual(result, { - type: TRANSACTION_TYPES.SENT_ETHER, + type: TRANSACTION_TYPES.SIMPLE_SEND, getCodeResponse: null, }); }); @@ -1285,7 +1285,7 @@ describe('Transaction Controller', function () { data: '0xabd', }); assert.deepEqual(result, { - type: TRANSACTION_TYPES.SENT_ETHER, + type: TRANSACTION_TYPES.SIMPLE_SEND, getCodeResponse: '0x', }); }); @@ -1296,7 +1296,7 @@ describe('Transaction Controller', function () { data: '0xabd', }); assert.deepEqual(result, { - type: TRANSACTION_TYPES.SENT_ETHER, + type: TRANSACTION_TYPES.SIMPLE_SEND, getCodeResponse: null, }); }); @@ -1499,7 +1499,7 @@ describe('Transaction Controller', function () { gas: '0x7b0d', nonce: '0x4b', }, - type: 'sentEther', + type: TRANSACTION_TYPES.SIMPLE_SEND, origin: 'metamask', chainId: currentChainId, time: 1624408066355, @@ -1513,7 +1513,7 @@ describe('Transaction Controller', function () { network: '42', referrer: 'metamask', source: 'user', - type: 'sentEther', + type: TRANSACTION_TYPES.SIMPLE_SEND, }, sensitiveProperties: { gas_price: '2', @@ -1546,7 +1546,7 @@ describe('Transaction Controller', function () { gas: '0x7b0d', nonce: '0x4b', }, - type: 'sentEther', + type: TRANSACTION_TYPES.SIMPLE_SEND, origin: 'other', chainId: currentChainId, time: 1624408066355, @@ -1560,7 +1560,7 @@ describe('Transaction Controller', function () { network: '42', referrer: 'other', source: 'dapp', - type: 'sentEther', + type: TRANSACTION_TYPES.SIMPLE_SEND, }, sensitiveProperties: { gas_price: '2', @@ -1593,7 +1593,7 @@ describe('Transaction Controller', function () { gas: '0x7b0d', nonce: '0x4b', }, - type: 'sentEther', + type: TRANSACTION_TYPES.SIMPLE_SEND, origin: 'other', chainId: currentChainId, time: 1624408066355, @@ -1606,7 +1606,7 @@ describe('Transaction Controller', function () { network: '42', referrer: 'other', source: 'dapp', - type: 'sentEther', + type: TRANSACTION_TYPES.SIMPLE_SEND, chain_id: '0x2a', }, sensitiveProperties: { @@ -1647,7 +1647,7 @@ describe('Transaction Controller', function () { gas: '0x7b0d', nonce: '0x4b', }, - type: 'sentEther', + type: TRANSACTION_TYPES.SIMPLE_SEND, origin: 'other', chainId: currentChainId, time: 1624408066355, @@ -1661,7 +1661,7 @@ describe('Transaction Controller', function () { network: '42', referrer: 'other', source: 'dapp', - type: 'sentEther', + type: TRANSACTION_TYPES.SIMPLE_SEND, }, sensitiveProperties: { baz: 3.0, diff --git a/app/scripts/controllers/transactions/tx-state-manager.test.js b/app/scripts/controllers/transactions/tx-state-manager.test.js index e8a391faf..3c29efc10 100644 --- a/app/scripts/controllers/transactions/tx-state-manager.test.js +++ b/app/scripts/controllers/transactions/tx-state-manager.test.js @@ -24,7 +24,7 @@ function generateTransactions( to, from, status, - type = TRANSACTION_TYPES.SENT_ETHER, + type = TRANSACTION_TYPES.SIMPLE_SEND, nonce = (i) => `${i}`, }, ) { @@ -653,7 +653,7 @@ describe('TransactionStateManager', function () { ? TRANSACTION_STATUSES.DROPPED : TRANSACTION_STATUSES.CONFIRMED, type: (i) => - i === 1 ? TRANSACTION_TYPES.CANCEL : TRANSACTION_STATUSES.SENT_ETHER, + i === 1 ? TRANSACTION_TYPES.CANCEL : TRANSACTION_TYPES.SIMPLE_SEND, }); txs.forEach((tx) => txStateManager.addTransaction(tx)); const result = txStateManager.getTransactions(); @@ -693,7 +693,7 @@ describe('TransactionStateManager', function () { type: (i) => i === 1 || i === 5 ? TRANSACTION_TYPES.CANCEL - : TRANSACTION_STATUSES.SENT_ETHER, + : TRANSACTION_TYPES.SIMPLE_SEND, }); txs.forEach((tx) => txStateManager.addTransaction(tx)); const result = txStateManager.getTransactions({ @@ -737,7 +737,7 @@ describe('TransactionStateManager', function () { type: (i) => i === 1 || i === 5 ? TRANSACTION_TYPES.CANCEL - : TRANSACTION_STATUSES.SENT_ETHER, + : TRANSACTION_TYPES.SIMPLE_SEND, }); txs.forEach((tx) => txStateManager.addTransaction(tx)); const result = txStateManager.getTransactions({ diff --git a/app/scripts/migrations/053.test.js b/app/scripts/migrations/053.test.js index 788110afa..324fa3741 100644 --- a/app/scripts/migrations/053.test.js +++ b/app/scripts/migrations/053.test.js @@ -2,6 +2,8 @@ import { strict as assert } from 'assert'; import { TRANSACTION_TYPES } from '../../../shared/constants/transaction'; import migration53 from './053'; +const SENT_ETHER = 'sentEther'; // a legacy transaction type replaced now by TRANSACTION_TYPES.SIMPLE_SEND + describe('migration #53', function () { it('should update the version metadata', async function () { const oldStorage = { @@ -25,12 +27,12 @@ describe('migration #53', function () { transactions: [ { type: TRANSACTION_TYPES.CANCEL, - transactionCategory: TRANSACTION_TYPES.SENT_ETHER, + transactionCategory: SENT_ETHER, txParams: { foo: 'bar' }, }, { type: 'standard', - transactionCategory: TRANSACTION_TYPES.SENT_ETHER, + transactionCategory: SENT_ETHER, txParams: { foo: 'bar' }, }, { @@ -40,7 +42,7 @@ describe('migration #53', function () { }, { type: TRANSACTION_TYPES.RETRY, - transactionCategory: TRANSACTION_TYPES.SENT_ETHER, + transactionCategory: SENT_ETHER, txParams: { foo: 'bar' }, }, ], @@ -64,7 +66,10 @@ describe('migration #53', function () { TransactionController: { transactions: [ { type: TRANSACTION_TYPES.CANCEL, txParams: { foo: 'bar' } }, - { type: TRANSACTION_TYPES.SENT_ETHER, txParams: { foo: 'bar' } }, + { + type: SENT_ETHER, + txParams: { foo: 'bar' }, + }, { type: TRANSACTION_TYPES.CONTRACT_INTERACTION, txParams: { foo: 'bar' }, diff --git a/app/scripts/migrations/059.test.js b/app/scripts/migrations/059.test.js index bdf4263c2..a9a06c2fd 100644 --- a/app/scripts/migrations/059.test.js +++ b/app/scripts/migrations/059.test.js @@ -12,6 +12,8 @@ import { } from '../../../shared/constants/transaction'; import migration59 from './059'; +const SENT_ETHER = 'sentEther'; // a legacy transaction type replaced now by TRANSACTION_TYPES.SIMPLE_SEND + const ERRONEOUS_TRANSACTION_STATE = { 0: { type: TRANSACTION_TYPES.CANCEL, @@ -22,7 +24,7 @@ const ERRONEOUS_TRANSACTION_STATE = { }, }, 1: { - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, id: 1, chainId: MAINNET_CHAIN_ID, txParams: { @@ -30,7 +32,7 @@ const ERRONEOUS_TRANSACTION_STATE = { }, }, 2: { - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, id: 2, chainId: KOVAN_CHAIN_ID, txParams: { @@ -38,7 +40,7 @@ const ERRONEOUS_TRANSACTION_STATE = { }, }, 3: { - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, id: 3, chainId: RINKEBY_CHAIN_ID, txParams: { @@ -46,7 +48,7 @@ const ERRONEOUS_TRANSACTION_STATE = { }, }, 4: { - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, id: 4, chainId: RINKEBY_CHAIN_ID, txParams: { @@ -54,7 +56,7 @@ const ERRONEOUS_TRANSACTION_STATE = { }, }, 5: { - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, id: 5, chainId: MAINNET_CHAIN_ID, txParams: { @@ -62,7 +64,7 @@ const ERRONEOUS_TRANSACTION_STATE = { }, }, 6: { - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, id: 6, chainId: KOVAN_CHAIN_ID, txParams: { @@ -70,7 +72,7 @@ const ERRONEOUS_TRANSACTION_STATE = { }, }, 7: { - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, id: 7, chainId: RINKEBY_CHAIN_ID, txParams: { @@ -78,7 +80,7 @@ const ERRONEOUS_TRANSACTION_STATE = { }, }, 8: { - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, id: 8, chainId: RINKEBY_CHAIN_ID, txParams: { @@ -86,7 +88,7 @@ const ERRONEOUS_TRANSACTION_STATE = { }, }, 9: { - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, id: 9, chainId: RINKEBY_CHAIN_ID, status: TRANSACTION_STATUSES.UNAPPROVED, @@ -169,7 +171,7 @@ describe('migration #59', function () { ...ERRONEOUS_TRANSACTION_STATE['0'], id: 11, chainId: GOERLI_CHAIN_ID, - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, }, }, }, @@ -200,7 +202,7 @@ describe('migration #59', function () { 11: { ...ERRONEOUS_TRANSACTION_STATE['0'], id: 11, - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, }, }, }, @@ -250,7 +252,7 @@ describe('migration #59', function () { ...ERRONEOUS_TRANSACTION_STATE_RETRY['0'], id: 11, chainId: GOERLI_CHAIN_ID, - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, }, }, }, @@ -281,7 +283,7 @@ describe('migration #59', function () { 11: { ...ERRONEOUS_TRANSACTION_STATE_RETRY['0'], id: 11, - type: TRANSACTION_TYPES.SENT_ETHER, + type: SENT_ETHER, }, }, }, diff --git a/app/scripts/migrations/064.js b/app/scripts/migrations/064.js new file mode 100644 index 000000000..01c384234 --- /dev/null +++ b/app/scripts/migrations/064.js @@ -0,0 +1,41 @@ +import { cloneDeep, isPlainObject } from 'lodash'; +import { TRANSACTION_TYPES } from '../../../shared/constants/transaction'; + +const version = 64; + +const SENT_ETHER = 'sentEther'; // the legacy transaction type being replaced in this migration with TRANSACTION_TYPES.SIMPLE_SEND + +/** + * Removes metaMetricsSendCount from MetaMetrics controller + */ +export default { + version, + async migrate(originalVersionedData) { + const versionedData = cloneDeep(originalVersionedData); + versionedData.meta.version = version; + const state = versionedData.data; + const newState = transformState(state); + versionedData.data = newState; + return versionedData; + }, +}; + +function transformState(state) { + const transactions = state?.TransactionController?.transactions; + if (isPlainObject(transactions)) { + for (const tx of Object.values(transactions)) { + if (tx.type === SENT_ETHER) { + tx.type = TRANSACTION_TYPES.SIMPLE_SEND; + } + if (tx.history) { + tx.history.map((txEvent) => { + if (txEvent.type && txEvent.type === SENT_ETHER) { + txEvent.type = TRANSACTION_TYPES.SIMPLE_SEND; + } + return txEvent; + }); + } + } + } + return state; +} diff --git a/app/scripts/migrations/064.test.js b/app/scripts/migrations/064.test.js new file mode 100644 index 000000000..25d268bdb --- /dev/null +++ b/app/scripts/migrations/064.test.js @@ -0,0 +1,469 @@ +import { strict as assert } from 'assert'; +import { TRANSACTION_TYPES } from '../../../shared/constants/transaction'; +import { MAINNET_CHAIN_ID } from '../../../shared/constants/network'; +import migration64 from './064'; + +const SENT_ETHER = 'sentEther'; // the legacy transaction type being replaced in this migration with TRANSACTION_TYPES.SIMPLE_SEND + +describe('migration #64', function () { + it('should update the version metadata', async function () { + const oldStorage = { + meta: { + version: 63, + }, + data: {}, + }; + + const newStorage = await migration64.migrate(oldStorage); + assert.deepEqual(newStorage.meta, { + version: 64, + }); + }); + + it('should do nothing if transactions state does not exist', async function () { + const oldStorage = { + meta: {}, + data: { + TransactionController: { + bar: 'baz', + }, + IncomingTransactionsController: { + foo: 'baz', + }, + foo: 'bar', + }, + }; + + const newStorage = await migration64.migrate(oldStorage); + assert.deepEqual(oldStorage.data, newStorage.data); + }); + + it('should do nothing if transactions state is empty', async function () { + const oldStorage = { + meta: {}, + data: { + TransactionController: { + transactions: {}, + bar: 'baz', + }, + foo: 'bar', + }, + }; + + const newStorage = await migration64.migrate(oldStorage); + assert.deepEqual(oldStorage.data, newStorage.data); + }); + + it('should do nothing if transactions state is not an object', async function () { + const oldStorage = { + meta: {}, + data: { + TransactionController: { + transactions: [], + bar: 'baz', + }, + foo: 'bar', + }, + }; + + const newStorage = await migration64.migrate(oldStorage); + assert.deepEqual(oldStorage.data, newStorage.data); + }); + + it('should do nothing if state is empty', async function () { + const oldStorage = { + meta: {}, + data: {}, + }; + + const newStorage = await migration64.migrate(oldStorage); + assert.deepEqual(oldStorage.data, newStorage.data); + }); + + it('should change action type of "sentEther" to "simpleSend" for any transactions and transaction history events in transactionsController.transactions', async function () { + const OLD_TRANSACTION_STATE = { + 1462177651588364: { + type: TRANSACTION_TYPES.CANCEL, + id: 0, + chainId: MAINNET_CHAIN_ID, + txParams: { + nonce: '0x0', + }, + origin: 'https://metamask.github.io', + r: '0x29f00dda09306f0f09895e80db110b9348eeb57d3e0b386409bfb674041ba45a', + rawTx: + '0x02f902fc04278459682f008459682f10830314138080b902a3608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029c001a029f00dda09306f0f09895e80db110b9348eeb57d3e0b386409bfb674041ba45aa049f74084dd8c517b305a2e60b39ae9002176a5244cb06de8f9ea3757811f5ec6', + s: '0x49f74084dd8c517b305a2e60b39ae9002176a5244cb06de8f9ea3757811f5ec6', + status: 'confirmed', + estimatedBaseFee: 'b', + hash: + '0x4d8543f12afd3795b94d723dcd0e20bfc3740e1af668e5e90a0c5ec49f36ba12', + }, + 1: { + type: SENT_ETHER, + id: 1, + chainId: MAINNET_CHAIN_ID, + txParams: { + nonce: '0x1', + }, + history: [ + { + chainId: '0x4', + dappSuggestedGasFees: { + gas: '0x31413', + }, + id: 1462177651588364, + loadingDefaults: true, + metamaskNetworkId: '4', + origin: 'https://metamask.github.io', + status: 'unapproved', + time: 1631118004776, + txParams: { + data: + '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', + from: '0x0f002c95c041f003be01c3e4f52cae1f6ab3ba6e', + gas: '0x31413', + value: '0x0', + }, + type: SENT_ETHER, + }, + [ + { + note: 'Added new unapproved transaction.', + op: 'add', + path: '/txParams/maxFeePerGas', + timestamp: 1631118004862, + value: '0x59682f10', + }, + { + op: 'add', + path: '/txParams/maxPriorityFeePerGas', + value: '0x59682f00', + }, + { + op: 'replace', + path: '/loadingDefaults', + value: false, + }, + { + op: 'add', + path: '/userFeeLevel', + value: 'medium', + }, + ], + ], + }, + 3274396743040791: { + baseFeePerGas: '0xb', + chainId: '0x4', + dappSuggestedGasFees: { + gas: '0xa9fe', + }, + estimatedBaseFee: 'b', + hash: + '0x19ffab8a9467df9afbef82d8907f9e39f0696c7a774ed5473ecf7337adcc674b', + origin: 'https://metamask.github.io', + r: '0xc2b2901f3593536d21e9b136c469b9b8f91a944f18a29a3cdf3a2eaadf660e71', + rawTx: + '0x02f87604288459682f008459682f1082a9fe949ef57335bc7d5b6cbc06dca6064a604b75e09ace883782dace9d90000084d0e30db0c001a0c2b2901f3593536d21e9b136c469b9b8f91a944f18a29a3cdf3a2eaadf660e71a057876a0292d548dd67c6faed8e835b94252b55a043ce01a1206361ccab417ad4', + s: '0x57876a0292d548dd67c6faed8e835b94252b55a043ce01a1206361ccab417ad4', + status: 'confirmed', + submittedTime: 1631118228493, + time: 1631118217596, + txParams: { + data: '0xd0e30db0', + from: '0x0f002c95c041f003be01c3e4f52cae1f6ab3ba6e', + gas: '0xa9fe', + maxFeePerGas: '0x59682f10', + maxPriorityFeePerGas: '0x59682f00', + nonce: '0x28', + to: '0x9ef57335bc7d5b6cbc06dca6064a604b75e09ace', + value: '0x3782dace9d900000', + }, + txReceipt: { + blockHash: + '0xafa4e1fd95e429d9c6e6c7c1d282b2bd0bbeb50d0a68743e9392b9c95a06e2eb', + blockNumber: { + length: 1, + negative: 0, + red: null, + words: [9257603, null], + }, + contractAddress: null, + cumulativeGasUsed: { + length: 1, + negative: 0, + red: null, + words: [4954851, null], + }, + effectiveGasPrice: '0x59682f0b', + from: '0x0f002c95c041f003be01c3e4f52cae1f6ab3ba6e', + gasUsed: 'a9fe', + logs: [], + logsBloom: + '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + status: '0x1', + to: '0x9ef57335bc7d5b6cbc06dca6064a604b75e09ace', + transactionHash: + '0x19ffab8a9467df9afbef82d8907f9e39f0696c7a774ed5473ecf7337adcc674b', + transactionIndex: { + length: 1, + negative: 0, + red: null, + words: [9, null], + }, + type: '0x2', + }, + type: SENT_ETHER, + history: [ + { + chainId: '0x4', + dappSuggestedGasFees: { + gas: '0xa9fe', + }, + id: 3274396743040791, + loadingDefaults: true, + metamaskNetworkId: '4', + origin: 'https://metamask.github.io', + status: 'unapproved', + time: 1631118217596, + txParams: { + data: '0xd0e30db0', + from: '0x0f002c95c041f003be01c3e4f52cae1f6ab3ba6e', + gas: '0xa9fe', + to: '0x9ef57335bc7d5b6cbc06dca6064a604b75e09ace', + value: '0x3782dace9d900000', + }, + }, + [ + { + note: 'Added new unapproved transaction.', + op: 'add', + path: '/txParams/maxFeePerGas', + timestamp: 1631118217762, + value: '0x59682f10', + }, + { + op: 'add', + path: '/txParams/maxPriorityFeePerGas', + value: '0x59682f00', + }, + { + op: 'replace', + path: '/loadingDefaults', + value: false, + }, + { + op: 'add', + path: '/userFeeLevel', + value: 'medium', + }, + ], + ], + }, + }; + + const EXPECTED_TRANSACTION_STATE = { + 1462177651588364: { + type: TRANSACTION_TYPES.CANCEL, + id: 0, + chainId: MAINNET_CHAIN_ID, + txParams: { + nonce: '0x0', + }, + origin: 'https://metamask.github.io', + r: '0x29f00dda09306f0f09895e80db110b9348eeb57d3e0b386409bfb674041ba45a', + rawTx: + '0x02f902fc04278459682f008459682f10830314138080b902a3608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029c001a029f00dda09306f0f09895e80db110b9348eeb57d3e0b386409bfb674041ba45aa049f74084dd8c517b305a2e60b39ae9002176a5244cb06de8f9ea3757811f5ec6', + s: '0x49f74084dd8c517b305a2e60b39ae9002176a5244cb06de8f9ea3757811f5ec6', + status: 'confirmed', + estimatedBaseFee: 'b', + hash: + '0x4d8543f12afd3795b94d723dcd0e20bfc3740e1af668e5e90a0c5ec49f36ba12', + }, + 1: { + type: TRANSACTION_TYPES.SIMPLE_SEND, + id: 1, + chainId: MAINNET_CHAIN_ID, + txParams: { + nonce: '0x1', + }, + history: [ + { + chainId: '0x4', + dappSuggestedGasFees: { + gas: '0x31413', + }, + id: 1462177651588364, + loadingDefaults: true, + metamaskNetworkId: '4', + origin: 'https://metamask.github.io', + status: 'unapproved', + time: 1631118004776, + txParams: { + data: + '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', + from: '0x0f002c95c041f003be01c3e4f52cae1f6ab3ba6e', + gas: '0x31413', + value: '0x0', + }, + type: TRANSACTION_TYPES.SIMPLE_SEND, + }, + [ + { + note: 'Added new unapproved transaction.', + op: 'add', + path: '/txParams/maxFeePerGas', + timestamp: 1631118004862, + value: '0x59682f10', + }, + { + op: 'add', + path: '/txParams/maxPriorityFeePerGas', + value: '0x59682f00', + }, + { + op: 'replace', + path: '/loadingDefaults', + value: false, + }, + { + op: 'add', + path: '/userFeeLevel', + value: 'medium', + }, + ], + ], + }, + 3274396743040791: { + baseFeePerGas: '0xb', + chainId: '0x4', + dappSuggestedGasFees: { + gas: '0xa9fe', + }, + estimatedBaseFee: 'b', + hash: + '0x19ffab8a9467df9afbef82d8907f9e39f0696c7a774ed5473ecf7337adcc674b', + origin: 'https://metamask.github.io', + r: '0xc2b2901f3593536d21e9b136c469b9b8f91a944f18a29a3cdf3a2eaadf660e71', + rawTx: + '0x02f87604288459682f008459682f1082a9fe949ef57335bc7d5b6cbc06dca6064a604b75e09ace883782dace9d90000084d0e30db0c001a0c2b2901f3593536d21e9b136c469b9b8f91a944f18a29a3cdf3a2eaadf660e71a057876a0292d548dd67c6faed8e835b94252b55a043ce01a1206361ccab417ad4', + s: '0x57876a0292d548dd67c6faed8e835b94252b55a043ce01a1206361ccab417ad4', + status: 'confirmed', + submittedTime: 1631118228493, + time: 1631118217596, + txParams: { + data: '0xd0e30db0', + from: '0x0f002c95c041f003be01c3e4f52cae1f6ab3ba6e', + gas: '0xa9fe', + maxFeePerGas: '0x59682f10', + maxPriorityFeePerGas: '0x59682f00', + nonce: '0x28', + to: '0x9ef57335bc7d5b6cbc06dca6064a604b75e09ace', + value: '0x3782dace9d900000', + }, + txReceipt: { + blockHash: + '0xafa4e1fd95e429d9c6e6c7c1d282b2bd0bbeb50d0a68743e9392b9c95a06e2eb', + blockNumber: { + length: 1, + negative: 0, + red: null, + words: [9257603, null], + }, + contractAddress: null, + cumulativeGasUsed: { + length: 1, + negative: 0, + red: null, + words: [4954851, null], + }, + effectiveGasPrice: '0x59682f0b', + from: '0x0f002c95c041f003be01c3e4f52cae1f6ab3ba6e', + gasUsed: 'a9fe', + logs: [], + logsBloom: + '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + status: '0x1', + to: '0x9ef57335bc7d5b6cbc06dca6064a604b75e09ace', + transactionHash: + '0x19ffab8a9467df9afbef82d8907f9e39f0696c7a774ed5473ecf7337adcc674b', + transactionIndex: { + length: 1, + negative: 0, + red: null, + words: [9, null], + }, + type: '0x2', + }, + type: TRANSACTION_TYPES.SIMPLE_SEND, + history: [ + { + chainId: '0x4', + dappSuggestedGasFees: { + gas: '0xa9fe', + }, + id: 3274396743040791, + loadingDefaults: true, + metamaskNetworkId: '4', + origin: 'https://metamask.github.io', + status: 'unapproved', + time: 1631118217596, + txParams: { + data: '0xd0e30db0', + from: '0x0f002c95c041f003be01c3e4f52cae1f6ab3ba6e', + gas: '0xa9fe', + to: '0x9ef57335bc7d5b6cbc06dca6064a604b75e09ace', + value: '0x3782dace9d900000', + }, + }, + [ + { + note: 'Added new unapproved transaction.', + op: 'add', + path: '/txParams/maxFeePerGas', + timestamp: 1631118217762, + value: '0x59682f10', + }, + { + op: 'add', + path: '/txParams/maxPriorityFeePerGas', + value: '0x59682f00', + }, + { + op: 'replace', + path: '/loadingDefaults', + value: false, + }, + { + op: 'add', + path: '/userFeeLevel', + value: 'medium', + }, + ], + ], + }, + }; + const oldStorage = { + meta: {}, + data: { + TransactionController: { + transactions: OLD_TRANSACTION_STATE, + }, + }, + }; + + const expectedStorage = { + meta: {}, + data: { + TransactionController: { + transactions: EXPECTED_TRANSACTION_STATE, + }, + }, + }; + + const newStorage = await migration64.migrate(oldStorage); + + assert.deepEqual(expectedStorage.data, newStorage.data); + }); +}); diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js index 4744bc531..8798a0529 100644 --- a/app/scripts/migrations/index.js +++ b/app/scripts/migrations/index.js @@ -67,6 +67,7 @@ import m060 from './060'; import m061 from './061'; import m062 from './062'; import m063 from './063'; +import m064 from './064'; const migrations = [ m002, @@ -131,6 +132,7 @@ const migrations = [ m061, m062, m063, + m064, ]; export default migrations; diff --git a/shared/constants/transaction.js b/shared/constants/transaction.js index 09d780677..d886c030c 100644 --- a/shared/constants/transaction.js +++ b/shared/constants/transaction.js @@ -11,7 +11,7 @@ import { MESSAGE_TYPE } from './app'; * @property {'approve'} TOKEN_METHOD_APPROVE - A token transaction requesting an * allowance of the token to spend on behalf of the user * @property {'incoming'} INCOMING - An incoming (deposit) transaction - * @property {'sentEther'} SENT_ETHER - A transaction sending ether to a recipient + * @property {'simpleSend'} SIMPLE_SEND - A transaction sending a network's native asset to a recipient * @property {'contractInteraction'} CONTRACT_INTERACTION - A transaction that is * interacting with a smart contract's methods that we have not treated as a special * case, such as approve, transfer, and transferfrom @@ -48,7 +48,7 @@ export const TRANSACTION_TYPES = { TOKEN_METHOD_TRANSFER_FROM: 'transferfrom', TOKEN_METHOD_APPROVE: 'approve', INCOMING: 'incoming', - SENT_ETHER: 'sentEther', + SIMPLE_SEND: 'simpleSend', CONTRACT_INTERACTION: 'contractInteraction', DEPLOY_CONTRACT: 'contractDeployment', SWAP: 'swap', diff --git a/test/data/transaction-data.json b/test/data/transaction-data.json index 740e522d1..dbc1ec138 100644 --- a/test/data/transaction-data.json +++ b/test/data/transaction-data.json @@ -16,7 +16,7 @@ "gasPrice": "0x2540be400" }, "origin": "metamask", - "type": "sentEther", + "type": "simpleSend", "nonceDetails": { "params": { "highestLocallyConfirmed": 12, @@ -138,7 +138,7 @@ "gasPrice": "0x2540be400" }, "origin": "metamask", - "type": "sentEther", + "type": "simpleSend", "nonceDetails": { "params": { "highestLocallyConfirmed": 12, @@ -203,7 +203,7 @@ "gasPrice": "0x2540be400" }, "origin": "metamask", - "type": "sentEther", + "type": "simpleSend", "nonceDetails": { "params": { "highestLocallyConfirmed": 0, @@ -325,7 +325,7 @@ "gasPrice": "0x2540be400" }, "origin": "metamask", - "type": "sentEther", + "type": "simpleSend", "nonceDetails": { "params": { "highestLocallyConfirmed": 0, @@ -390,7 +390,7 @@ "gasPrice": "0x306dc4200" }, "origin": "metamask", - "type": "sentEther", + "type": "simpleSend", "nonceDetails": { "params": { "highestLocallyConfirmed": 0, @@ -514,7 +514,7 @@ "gasPrice": "0x306dc4200" }, "origin": "metamask", - "type": "sentEther", + "type": "simpleSend", "nonceDetails": { "params": { "highestLocallyConfirmed": 0, diff --git a/test/e2e/fixtures/import-ui/state.json b/test/e2e/fixtures/import-ui/state.json index 758a85d66..9f5cb4459 100644 --- a/test/e2e/fixtures/import-ui/state.json +++ b/test/e2e/fixtures/import-ui/state.json @@ -150,7 +150,7 @@ "gasPrice": "0x363fe1da00" }, "origin": "metamask", - "type": "sentEther", + "type": "simpleSend", "history": [], "nonceDetails": { "params": { diff --git a/test/e2e/fixtures/send-edit/state.json b/test/e2e/fixtures/send-edit/state.json index 3070c06a6..79efbaed2 100644 --- a/test/e2e/fixtures/send-edit/state.json +++ b/test/e2e/fixtures/send-edit/state.json @@ -163,7 +163,7 @@ "to": "0x2f318C334780961FB129D2a6c30D0763d9a5C970", "value": "0xde0b6b3a7640000" }, - "type": "sentEther" + "type": "simpleSend" }, [ { @@ -188,7 +188,7 @@ "to": "0x2f318C334780961FB129D2a6c30D0763d9a5C970", "value": "0xde0b6b3a7640000" }, - "type": "sentEther" + "type": "simpleSend" } } }, diff --git a/test/stub/tx-meta-stub.js b/test/stub/tx-meta-stub.js index bb1fc4f99..c33ab758c 100644 --- a/test/stub/tx-meta-stub.js +++ b/test/stub/tx-meta-stub.js @@ -14,7 +14,7 @@ export const txMetaStub = { metamaskNetworkId: '4', status: TRANSACTION_STATUSES.UNAPPROVED, time: 1572395156620, - type: TRANSACTION_TYPES.SENT_ETHER, + type: TRANSACTION_TYPES.SIMPLE_SEND, txParams: { from: '0xf231d46dd78806e1dd93442cf33c7671f8538748', gas: GAS_LIMITS.SIMPLE, @@ -195,7 +195,7 @@ export const txMetaStub = { status: TRANSACTION_STATUSES.SUBMITTED, submittedTime: 1572395158570, time: 1572395156620, - type: TRANSACTION_TYPES.SENT_ETHER, + type: TRANSACTION_TYPES.SIMPLE_SEND, txParams: { from: '0xf231d46dd78806e1dd93442cf33c7671f8538748', gas: GAS_LIMITS.SIMPLE, diff --git a/ui/helpers/utils/transactions.util.js b/ui/helpers/utils/transactions.util.js index 307e3dffc..b91e79ee9 100644 --- a/ui/helpers/utils/transactions.util.js +++ b/ui/helpers/utils/transactions.util.js @@ -196,9 +196,10 @@ export function getStatusKey(transaction) { * This will throw an error if the transaction category is unrecognized and no default is provided. * @param {function} t - The translation function * @param {TRANSACTION_TYPES[keyof TRANSACTION_TYPES]} type - The transaction type constant + * @param {string} nativeCurrency - The native currency of the currently selected network * @returns {string} The transaction category title */ -export function getTransactionTypeTitle(t, type) { +export function getTransactionTypeTitle(t, type, nativeCurrency = 'ETH') { switch (type) { case TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER: { return t('transfer'); @@ -209,8 +210,8 @@ export function getTransactionTypeTitle(t, type) { case TRANSACTION_TYPES.TOKEN_METHOD_APPROVE: { return t('approve'); } - case TRANSACTION_TYPES.SENT_ETHER: { - return t('sentEther'); + case TRANSACTION_TYPES.SIMPLE_SEND: { + return t('sendingNativeAsset', [nativeCurrency]); } case TRANSACTION_TYPES.CONTRACT_INTERACTION: { return t('contractInteraction'); diff --git a/ui/hooks/useTransactionDisplayData.js b/ui/hooks/useTransactionDisplayData.js index 122511a35..d63c6278a 100644 --- a/ui/hooks/useTransactionDisplayData.js +++ b/ui/hooks/useTransactionDisplayData.js @@ -222,7 +222,7 @@ export function useTransactionDisplayData(transactionGroup) { title = t('sendSpecifiedTokens', [token?.symbol || t('token')]); recipientAddress = getTokenAddressParam(tokenData); subtitle = t('toAddress', [shortenAddress(recipientAddress)]); - } else if (type === TRANSACTION_TYPES.SENT_ETHER) { + } else if (type === TRANSACTION_TYPES.SIMPLE_SEND) { category = TRANSACTION_GROUP_CATEGORIES.SEND; title = t('send'); subtitle = t('toAddress', [shortenAddress(recipientAddress)]); diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js index 3c857189e..d40c8a24f 100644 --- a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -127,6 +127,7 @@ export default class ConfirmTransactionBase extends Component { gasFeeIsCustom: PropTypes.bool, isLedgerAccount: PropTypes.bool.isRequired, isFirefox: PropTypes.bool.isRequired, + nativeCurrency: PropTypes.string, }; state = { @@ -914,6 +915,7 @@ export default class ConfirmTransactionBase extends Component { txData, gasIsLoading, gasFeeIsCustom, + nativeCurrency, } = this.props; const { submitting, @@ -940,7 +942,7 @@ export default class ConfirmTransactionBase extends Component { let functionType = getMethodName(name); if (!functionType) { if (type) { - functionType = getTransactionTypeTitle(t, type); + functionType = getTransactionTypeTitle(t, type, nativeCurrency); } else { functionType = t('contractInteraction'); } diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js index d1f03e54a..54b8ee39f 100644 --- a/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js +++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js @@ -44,6 +44,7 @@ import { toChecksumHexAddress } from '../../../shared/modules/hexstring-utils'; import { updateTransactionGasFees, getIsGasEstimatesLoading, + getNativeCurrency, } from '../../ducks/metamask/metamask'; import { getGasLoadingAnimationIsShowing } from '../../ducks/app/app'; import ConfirmTransactionBase from './confirm-transaction-base.component'; @@ -169,6 +170,7 @@ const mapStateToProps = (state, ownProps) => { txParamsAreDappSuggested(fullTxData); const isLedgerAccount = getAccountType(state) === KEYRING_TYPES.LEDGER; const isFirefox = getPlatform() === PLATFORM_FIREFOX; + const nativeCurrency = getNativeCurrency(state); return { balance, @@ -217,6 +219,7 @@ const mapStateToProps = (state, ownProps) => { gasFeeIsCustom, isLedgerAccount, isFirefox, + nativeCurrency, }; }; diff --git a/ui/pages/confirm-transaction-switch/confirm-transaction-switch.component.js b/ui/pages/confirm-transaction-switch/confirm-transaction-switch.component.js index 6a708e54d..7e9882d65 100644 --- a/ui/pages/confirm-transaction-switch/confirm-transaction-switch.component.js +++ b/ui/pages/confirm-transaction-switch/confirm-transaction-switch.component.js @@ -31,7 +31,7 @@ export default class ConfirmTransactionSwitch extends Component { return ; } - if (type === TRANSACTION_TYPES.SENT_ETHER) { + if (type === TRANSACTION_TYPES.SIMPLE_SEND) { const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_SEND_ETHER_PATH}`; return ; }