From 026a06b39d803a7ee0d07a0d6732db5808e2b85c Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Tue, 3 Nov 2020 16:57:51 -0600 Subject: [PATCH] add shared transaction constants (#9459) Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com> --- app/_locales/am/messages.json | 9 -- app/_locales/ar/messages.json | 9 -- app/_locales/bg/messages.json | 9 -- app/_locales/bn/messages.json | 9 -- app/_locales/ca/messages.json | 9 -- app/_locales/cs/messages.json | 3 - app/_locales/da/messages.json | 9 -- app/_locales/de/messages.json | 9 -- app/_locales/el/messages.json | 9 -- app/_locales/en/messages.json | 9 -- app/_locales/es/messages.json | 9 -- app/_locales/es_419/messages.json | 9 -- app/_locales/et/messages.json | 9 -- app/_locales/fa/messages.json | 9 -- app/_locales/fi/messages.json | 9 -- app/_locales/fil/messages.json | 9 -- app/_locales/fr/messages.json | 9 -- app/_locales/he/messages.json | 9 -- app/_locales/hi/messages.json | 9 -- app/_locales/hn/messages.json | 3 - app/_locales/hr/messages.json | 9 -- app/_locales/ht/messages.json | 9 -- app/_locales/hu/messages.json | 9 -- app/_locales/id/messages.json | 6 - app/_locales/it/messages.json | 9 -- app/_locales/ja/messages.json | 3 - app/_locales/kn/messages.json | 9 -- app/_locales/ko/messages.json | 9 -- app/_locales/lt/messages.json | 9 -- app/_locales/lv/messages.json | 9 -- app/_locales/ms/messages.json | 6 - app/_locales/nl/messages.json | 3 - app/_locales/no/messages.json | 9 -- app/_locales/ph/messages.json | 3 - app/_locales/pl/messages.json | 9 -- app/_locales/pt/messages.json | 3 - app/_locales/pt_BR/messages.json | 9 -- app/_locales/pt_PT/messages.json | 3 - app/_locales/ro/messages.json | 9 -- app/_locales/ru/messages.json | 9 -- app/_locales/sk/messages.json | 9 -- app/_locales/sl/messages.json | 9 -- app/_locales/sr/messages.json | 9 -- app/_locales/sv/messages.json | 9 -- app/_locales/sw/messages.json | 9 -- app/_locales/ta/messages.json | 3 - app/_locales/th/messages.json | 3 - app/_locales/tr/messages.json | 3 - app/_locales/uk/messages.json | 9 -- app/_locales/vi/messages.json | 3 - app/_locales/zh_CN/messages.json | 9 -- app/_locales/zh_TW/messages.json | 9 -- app/scripts/controllers/transactions/enums.js | 14 -- app/scripts/controllers/transactions/index.js | 50 +++--- development/verify-locale-strings.js | 7 +- shared/constants/transaction.js | 147 ++++++++++++++++++ .../transactions/tx-controller-test.js | 33 ++-- .../cancel-transaction.component.js | 4 +- .../transaction-activity-log.util.js | 11 +- .../transaction-breakdown.container.js | 5 +- .../app/transaction-icon/transaction-icon.js | 44 ++---- .../transaction-list-item.component.js | 32 ++-- .../transaction-list.component.js | 8 +- .../transaction-status.component.js | 34 ++-- ui/app/ducks/swaps/swaps.js | 6 +- ui/app/helpers/constants/transactions.js | 57 ++----- ui/app/helpers/utils/transactions.util.js | 22 ++- ui/app/hooks/useSwappedTokenValue.js | 10 +- ui/app/hooks/useTransactionDisplayData.js | 66 ++++---- .../confirm-transaction-base.component.js | 9 +- .../confirm-transaction-switch.component.js | 18 +-- .../swaps/awaiting-swap/awaiting-swap.js | 4 +- ui/app/selectors/transactions.js | 26 ++-- 73 files changed, 328 insertions(+), 675 deletions(-) delete mode 100644 app/scripts/controllers/transactions/enums.js create mode 100644 shared/constants/transaction.js diff --git a/app/_locales/am/messages.json b/app/_locales/am/messages.json index 12af3e796..1ba47fede 100644 --- a/app/_locales/am/messages.json +++ b/app/_locales/am/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "ሰርዝ" }, - "cancelAttempt": { - "message": "ሙከራን ሰርዝ" - }, "cancellationGasFee": { "message": "የስረዛ ነዳጅ ወጪ" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "ይህን አውታረ መረብ ለመሰረዝ እንደሚፈልጉ እርግጠኛ ነዎት?" }, - "deposit": { - "message": "ማጠራቀም" - }, "depositEther": { "message": "Ether አስቀምጥ" }, @@ -985,9 +979,6 @@ "sentEther": { "message": "የተላከ ether" }, - "sentTokens": { - "message": "የተላኩ ተለዋጭ ስሞች" - }, "separateEachWord": { "message": "እያንዳንዱን ቃል በነጠላ ክፍት ቦታ ይለያዩ" }, diff --git a/app/_locales/ar/messages.json b/app/_locales/ar/messages.json index 8d5806599..5c579e93d 100644 --- a/app/_locales/ar/messages.json +++ b/app/_locales/ar/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "إلغاء" }, - "cancelAttempt": { - "message": "إلغاء المحاولة" - }, "cancellationGasFee": { "message": "رسوم الإلغاء بعملة جاس" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "هل أنت متأكد أنك تريد حذف هذه الشبكة؟" }, - "deposit": { - "message": "إيداع" - }, "depositEther": { "message": "إيداع عملة إيثير" }, @@ -981,9 +975,6 @@ "sentEther": { "message": "أرسل عملة إيثير" }, - "sentTokens": { - "message": "العملات الرمزية المرسلة" - }, "separateEachWord": { "message": "افصل كل كلمة بمسافة واحدة" }, diff --git a/app/_locales/bg/messages.json b/app/_locales/bg/messages.json index 70dcf4e41..7b47d5ff8 100644 --- a/app/_locales/bg/messages.json +++ b/app/_locales/bg/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Отказ" }, - "cancelAttempt": { - "message": "Отмяна на опита" - }, "cancellationGasFee": { "message": "Такса в газ за анулиране " }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "Наистина ли искате да изтриете тази мрежа?" }, - "deposit": { - "message": "Депозит" - }, "depositEther": { "message": "Депозирайте етер" }, @@ -984,9 +978,6 @@ "sentEther": { "message": "изпратен етер" }, - "sentTokens": { - "message": "изпратени жетони" - }, "separateEachWord": { "message": "Отделете всяка дума с интервал" }, diff --git a/app/_locales/bn/messages.json b/app/_locales/bn/messages.json index 63ce2ed82..ded364151 100644 --- a/app/_locales/bn/messages.json +++ b/app/_locales/bn/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "বাতিল করুন" }, - "cancelAttempt": { - "message": "প্রচেষ্টা বাতিল করুন" - }, "cancellationGasFee": { "message": "বাতিল করার গ্যাস ফী" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "আপনি কি এই নেটওয়ার্কটি মোছার বিষয়ে নিশ্চিত?" }, - "deposit": { - "message": "জমা " - }, "depositEther": { "message": "ইথার জমা করুন" }, @@ -988,9 +982,6 @@ "sentEther": { "message": "পাঠানো ইথার " }, - "sentTokens": { - "message": "টোকেনগুলি পাঠান" - }, "separateEachWord": { "message": "প্রতিটি শব্দকে একটি স্পেস দিয়ে আলাদা করুন" }, diff --git a/app/_locales/ca/messages.json b/app/_locales/ca/messages.json index 759264ec0..19102f8b3 100644 --- a/app/_locales/ca/messages.json +++ b/app/_locales/ca/messages.json @@ -161,9 +161,6 @@ "cancel": { "message": "Cancel·la" }, - "cancelAttempt": { - "message": "Cancel·la l'intent" - }, "cancellationGasFee": { "message": "Preu de cancel·lació del gas" }, @@ -305,9 +302,6 @@ "deleteNetworkDescription": { "message": "Estàs segur que vols eliminar aquesta xarxa?" }, - "deposit": { - "message": "Depòsit" - }, "depositEther": { "message": "Diposita Ether" }, @@ -966,9 +960,6 @@ "sentEther": { "message": "envia ether" }, - "sentTokens": { - "message": "fitxes enviades" - }, "separateEachWord": { "message": "Separa cada paraula amb un sol espai" }, diff --git a/app/_locales/cs/messages.json b/app/_locales/cs/messages.json index 3239f00ab..41757f932 100644 --- a/app/_locales/cs/messages.json +++ b/app/_locales/cs/messages.json @@ -118,9 +118,6 @@ "defaultNetwork": { "message": "Výchozí síť pro Etherové transakce je Main Net." }, - "deposit": { - "message": "Vklad" - }, "depositEther": { "message": "Vložit Ether" }, diff --git a/app/_locales/da/messages.json b/app/_locales/da/messages.json index 449946a69..0c3ffed48 100644 --- a/app/_locales/da/messages.json +++ b/app/_locales/da/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Afbryd" }, - "cancelAttempt": { - "message": "Annullér forsøg" - }, "cancellationGasFee": { "message": "Gebyr for brændstofannullering" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "Er du sikker på, at du vil slette dette netværk?" }, - "deposit": { - "message": "Indbetal" - }, "depositEther": { "message": "Indbetal Ether" }, @@ -966,9 +960,6 @@ "sentEther": { "message": "sendte ether" }, - "sentTokens": { - "message": "afsendte tokens" - }, "separateEachWord": { "message": "Separer hvert ord med et enkelt mellemrum" }, diff --git a/app/_locales/de/messages.json b/app/_locales/de/messages.json index 7b7da3c43..f42343322 100644 --- a/app/_locales/de/messages.json +++ b/app/_locales/de/messages.json @@ -158,9 +158,6 @@ "cancel": { "message": "Abbrechen" }, - "cancelAttempt": { - "message": "Versuch abbrechen" - }, "cancellationGasFee": { "message": "Stornierungs-Gasgebühr" }, @@ -299,9 +296,6 @@ "deleteNetworkDescription": { "message": "Sind Sie sicher, dass Sie dieses Netzwerk löschen möchten?" }, - "deposit": { - "message": "Einzahlen" - }, "depositEther": { "message": "Ether einzahlen" }, @@ -957,9 +951,6 @@ "sentEther": { "message": "Ether senden" }, - "sentTokens": { - "message": "gesendete Token" - }, "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 4ba30a80e..b16b43cbb 100644 --- a/app/_locales/el/messages.json +++ b/app/_locales/el/messages.json @@ -161,9 +161,6 @@ "cancel": { "message": "Ακύρωση" }, - "cancelAttempt": { - "message": "Ακύρωση Προσπάθειας" - }, "cancellationGasFee": { "message": "Ακύρωση Χρέωσης Αερίου" }, @@ -305,9 +302,6 @@ "deleteNetworkDescription": { "message": "Θέλετε σίγουρα να διαγράψετε αυτό το δίκτυο;" }, - "deposit": { - "message": "Κατάθεση" - }, "depositEther": { "message": "Κατάθεση Ether" }, @@ -985,9 +979,6 @@ "sentEther": { "message": "απεσταλμένα ether" }, - "sentTokens": { - "message": "αποστολή token" - }, "separateEachWord": { "message": "Διαχωρίστε κάθε λέξη με ένα μόνο κενό" }, diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index d57c4e79f..b6842da63 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -239,9 +239,6 @@ "cancel": { "message": "Cancel" }, - "cancelAttempt": { - "message": "Cancel Attempt" - }, "cancellationGasFee": { "message": "Cancellation Gas Fee" }, @@ -477,9 +474,6 @@ "deleteNetworkDescription": { "message": "Are you sure you want to delete this network?" }, - "deposit": { - "message": "Deposit" - }, "depositEther": { "message": "Deposit Ether" }, @@ -1458,9 +1452,6 @@ "sentEther": { "message": "sent ether" }, - "sentTokens": { - "message": "sent tokens" - }, "separateEachWord": { "message": "Separate each word with a single space" }, diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index ea36e9b50..e71326d10 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -136,9 +136,6 @@ "cancel": { "message": "Cancelar" }, - "cancelAttempt": { - "message": "Intentar cancelar" - }, "cancellationGasFee": { "message": "Comisión de Gas por cancelación" }, @@ -271,9 +268,6 @@ "deleteAccount": { "message": "Eliminar Cuenta" }, - "deposit": { - "message": "Depositar" - }, "depositEther": { "message": "Depositar Ether" }, @@ -783,9 +777,6 @@ "sentEther": { "message": "se mandó ether" }, - "sentTokens": { - "message": "se mandaron tokens" - }, "separateEachWord": { "message": "Separar a cada palabra con un sólo espacio" }, diff --git a/app/_locales/es_419/messages.json b/app/_locales/es_419/messages.json index 1efcd3d5c..a7faf3eba 100644 --- a/app/_locales/es_419/messages.json +++ b/app/_locales/es_419/messages.json @@ -161,9 +161,6 @@ "cancel": { "message": "Cancelar" }, - "cancelAttempt": { - "message": "Cancelar intento" - }, "cancellationGasFee": { "message": "Tasa de cancelación de gas" }, @@ -305,9 +302,6 @@ "deleteNetworkDescription": { "message": "¿Estás seguro de que deseas borrar esta red?" }, - "deposit": { - "message": "Depósito" - }, "depositEther": { "message": "Depositar Ethers" }, @@ -973,9 +967,6 @@ "sentEther": { "message": "Ethers enviados" }, - "sentTokens": { - "message": "tokens enviados" - }, "separateEachWord": { "message": "Separa cada palabra con un solo espacio" }, diff --git a/app/_locales/et/messages.json b/app/_locales/et/messages.json index 79b42b84c..600b57354 100644 --- a/app/_locales/et/messages.json +++ b/app/_locales/et/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Tühista" }, - "cancelAttempt": { - "message": "Tühista katse" - }, "cancellationGasFee": { "message": "Tühistamise gaasitasu" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "Olete kindel, et soovite selle võrgu kustutada?" }, - "deposit": { - "message": "Sissemakse" - }, "depositEther": { "message": "Eetri sissemakse" }, @@ -978,9 +972,6 @@ "sentEther": { "message": "saadetud eeter" }, - "sentTokens": { - "message": "saadetud load" - }, "separateEachWord": { "message": "Eraldage iga sõna ühe tühikuga" }, diff --git a/app/_locales/fa/messages.json b/app/_locales/fa/messages.json index b6ca24ad5..bb0dc4bca 100644 --- a/app/_locales/fa/messages.json +++ b/app/_locales/fa/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "لغو" }, - "cancelAttempt": { - "message": "لغو تلاش" - }, "cancellationGasFee": { "message": "لغو فیس گاز" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "آیا مطمئن هستید که این شبکه حذف شود؟" }, - "deposit": { - "message": "سپرده" - }, "depositEther": { "message": "پرداخت ایتر" }, @@ -988,9 +982,6 @@ "sentEther": { "message": "ایتر ارسال شد" }, - "sentTokens": { - "message": "رمزیاب های فرستاده شده" - }, "separateEachWord": { "message": "هر کلمه را با یک فاصله واحد جدا سازید" }, diff --git a/app/_locales/fi/messages.json b/app/_locales/fi/messages.json index 0e17618db..f0dcd6c01 100644 --- a/app/_locales/fi/messages.json +++ b/app/_locales/fi/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Peruuta" }, - "cancelAttempt": { - "message": "Peruuta yritys" - }, "cancellationGasFee": { "message": "Peruutuksen gas-maksu" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "Haluatko varmasti poistaa tämän verkon?" }, - "deposit": { - "message": "Talleta" - }, "depositEther": { "message": "Talleta Etheriä" }, @@ -985,9 +979,6 @@ "sentEther": { "message": "lähetä etheriä" }, - "sentTokens": { - "message": "lähetetyt poletit" - }, "separateEachWord": { "message": "Erottele sanat toisistaan yhdellä välilyönnillä" }, diff --git a/app/_locales/fil/messages.json b/app/_locales/fil/messages.json index 445083185..537fe32be 100644 --- a/app/_locales/fil/messages.json +++ b/app/_locales/fil/messages.json @@ -146,9 +146,6 @@ "cancel": { "message": "Kanselahin" }, - "cancelAttempt": { - "message": "Kanselahin ang Pagtangka" - }, "cancellationGasFee": { "message": "Gas Fee sa Pagkansela" }, @@ -284,9 +281,6 @@ "deleteNetworkDescription": { "message": "Sigurado ka bang gusto mong i-delete ang network na ito?" }, - "deposit": { - "message": "Deposito" - }, "depositEther": { "message": "Magdeposito ng Ether" }, @@ -900,9 +894,6 @@ "sentEther": { "message": "nagpadala ng ether" }, - "sentTokens": { - "message": "mga ipinadalang token" - }, "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 78cdb5e2f..853494ba5 100644 --- a/app/_locales/fr/messages.json +++ b/app/_locales/fr/messages.json @@ -155,9 +155,6 @@ "cancel": { "message": "Annuler" }, - "cancelAttempt": { - "message": "Annuler la tentative." - }, "cancellationGasFee": { "message": "Frais en gas de l'annulation" }, @@ -299,9 +296,6 @@ "deleteNetworkDescription": { "message": "Êtes-vous sûr de vouloir supprimer ce réseau ?" }, - "deposit": { - "message": "Déposer" - }, "depositEther": { "message": "Déposer de l'Ether" }, @@ -970,9 +964,6 @@ "sentEther": { "message": "Ether envoyé" }, - "sentTokens": { - "message": "Jetons envoyés" - }, "separateEachWord": { "message": "Separez chaque mot avec un espace simple" }, diff --git a/app/_locales/he/messages.json b/app/_locales/he/messages.json index 8c10e4dad..9c2480559 100644 --- a/app/_locales/he/messages.json +++ b/app/_locales/he/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "ביטול" }, - "cancelAttempt": { - "message": "בטל ניסיון" - }, "cancellationGasFee": { "message": "עמלת דלק עבור ביטול" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "הנך בטוח/ה שברצונך למחוק רשת זו?" }, - "deposit": { - "message": "הפקדה" - }, "depositEther": { "message": "הפקדת את'ר" }, @@ -982,9 +976,6 @@ "sentEther": { "message": "את'ר שנשלח" }, - "sentTokens": { - "message": "טוקנים שנשלחו" - }, "separateEachWord": { "message": "יש להפריד כל מילה עם רווח יחיד" }, diff --git a/app/_locales/hi/messages.json b/app/_locales/hi/messages.json index d189f6110..2665eec15 100644 --- a/app/_locales/hi/messages.json +++ b/app/_locales/hi/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "रद्द करें" }, - "cancelAttempt": { - "message": "प्रयास रद्द करें" - }, "cancellationGasFee": { "message": "रद्दीकरण गैस शुल्क" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "क्या आप वाकई इस नेटवर्क को हटाना चाहते हैं?" }, - "deposit": { - "message": "जमा " - }, "depositEther": { "message": "Ether जमा करें" }, @@ -985,9 +979,6 @@ "sentEther": { "message": "भेजे गए ether" }, - "sentTokens": { - "message": "भेजे गए टोकन" - }, "separateEachWord": { "message": "प्रत्येक शब्द को एक स्पेस से अलग करें" }, diff --git a/app/_locales/hn/messages.json b/app/_locales/hn/messages.json index b0e199100..4bdac8559 100644 --- a/app/_locales/hn/messages.json +++ b/app/_locales/hn/messages.json @@ -97,9 +97,6 @@ "defaultNetwork": { "message": "ईथर लेनदेन के लिए डिफ़ॉल्ट नेटवर्क मुख्य नेट है।" }, - "deposit": { - "message": "जमा" - }, "depositEther": { "message": "जमा - Ether" }, diff --git a/app/_locales/hr/messages.json b/app/_locales/hr/messages.json index 227c154d7..e7d8f9f5b 100644 --- a/app/_locales/hr/messages.json +++ b/app/_locales/hr/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Odustani" }, - "cancelAttempt": { - "message": "Otkaži pokušaj" - }, "cancellationGasFee": { "message": "Otkazivanje naknade za gorivo" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "Sigurno želite izbrisati ovu mrežu?" }, - "deposit": { - "message": "Polog" - }, "depositEther": { "message": "Položi Ether" }, @@ -981,9 +975,6 @@ "sentEther": { "message": "pošalji ether" }, - "sentTokens": { - "message": "pošalji tokene" - }, "separateEachWord": { "message": "Odvojite pojedinačne riječi jednim razmakom" }, diff --git a/app/_locales/ht/messages.json b/app/_locales/ht/messages.json index eefec6bc7..18901dcc8 100644 --- a/app/_locales/ht/messages.json +++ b/app/_locales/ht/messages.json @@ -85,9 +85,6 @@ "cancel": { "message": "Anile" }, - "cancelAttempt": { - "message": "Teste Anile" - }, "cancellationGasFee": { "message": "Anilasyon Gaz Chaj" }, @@ -169,9 +166,6 @@ "defaultNetwork": { "message": "Dfo rezo a pou tranzaksyon Ether se Mainnet." }, - "deposit": { - "message": "Depo" - }, "depositEther": { "message": "Depo Ether" }, @@ -615,9 +609,6 @@ "sentEther": { "message": "Voye ether" }, - "sentTokens": { - "message": "tokens deja voye" - }, "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 97f63d74e..b43fda718 100644 --- a/app/_locales/hu/messages.json +++ b/app/_locales/hu/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Mégse" }, - "cancelAttempt": { - "message": "Kísérlet megszakítása" - }, "cancellationGasFee": { "message": "A törlés gázára" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "Biztosan törli ezt a hálózatot?" }, - "deposit": { - "message": "Befizetés" - }, "depositEther": { "message": "Ether befizetése" }, @@ -981,9 +975,6 @@ "sentEther": { "message": "elküldött ether" }, - "sentTokens": { - "message": "elküldött érmék" - }, "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 1fcd8f960..bcc90707b 100644 --- a/app/_locales/id/messages.json +++ b/app/_locales/id/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Batal" }, - "cancelAttempt": { - "message": "Batalkan Percobaan" - }, "cancellationGasFee": { "message": "Pembatalan Biaya Gas" }, @@ -969,9 +966,6 @@ "sentEther": { "message": "kirim ether" }, - "sentTokens": { - "message": "token terkirim" - }, "separateEachWord": { "message": "Pisahkan setiap kata dengan spasi tunggal" }, diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json index f9400429c..8342e11ee 100644 --- a/app/_locales/it/messages.json +++ b/app/_locales/it/messages.json @@ -226,9 +226,6 @@ "cancel": { "message": "Annulla" }, - "cancelAttempt": { - "message": "Tentativo di Annullamento" - }, "cancellationGasFee": { "message": "Costo di Annullamento in Gas" }, @@ -464,9 +461,6 @@ "deleteNetworkDescription": { "message": "Sei sicuro di voler eliminare questa rete?" }, - "deposit": { - "message": "Deposita" - }, "depositEther": { "message": "Deposita Ether" }, @@ -1358,9 +1352,6 @@ "sentEther": { "message": "ether inviati" }, - "sentTokens": { - "message": "tokens 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 23e4bd9a6..737845b3b 100644 --- a/app/_locales/ja/messages.json +++ b/app/_locales/ja/messages.json @@ -169,9 +169,6 @@ "defaultNetwork": { "message": "デフォルトのEther送受信ネットワークはメインネットです。" }, - "deposit": { - "message": "振込" - }, "depositEther": { "message": "Etherを振込" }, diff --git a/app/_locales/kn/messages.json b/app/_locales/kn/messages.json index 1d92260b9..350bbeae7 100644 --- a/app/_locales/kn/messages.json +++ b/app/_locales/kn/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "ರದ್ದುಮಾಡಿ" }, - "cancelAttempt": { - "message": "ಪ್ರಯತ್ನವನ್ನು ರದ್ದುಪಡಿಸಿ" - }, "cancellationGasFee": { "message": "ರದ್ದುಗೊಳಿಸುವ ಗ್ಯಾಸ್ ಶುಲ್ಕ" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "ನೀವು ಈ ನೆಟ್‌ವರ್ಕ್ ಅನ್ನು ಖಚಿತವಾಗಿ ಅಳಿಸಲು ಬಯಸುತ್ತೀರಾ?" }, - "deposit": { - "message": "ಠೇವಣಿ" - }, "depositEther": { "message": "ಎಥರ್ ಠೇವಣಿ ಮಾಡಿ" }, @@ -988,9 +982,6 @@ "sentEther": { "message": "ಕಳುಹಿಸಲಾದ ಎಥರ್" }, - "sentTokens": { - "message": "ಕಳುಹಿಸಲಾದ ಟೋಕನ್‌ಗಳು" - }, "separateEachWord": { "message": "ಒಂದು ಸ್ಪೇಸ್ ಮೂಲಕ ಪ್ರತಿ ಪದವನ್ನು ಬೇರ್ಪಡಿಸಿ" }, diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json index decd5fecd..1030f275a 100644 --- a/app/_locales/ko/messages.json +++ b/app/_locales/ko/messages.json @@ -161,9 +161,6 @@ "cancel": { "message": "취소" }, - "cancelAttempt": { - "message": "취소 시도" - }, "cancellationGasFee": { "message": "취소 가스 수수료" }, @@ -305,9 +302,6 @@ "deleteNetworkDescription": { "message": "정말로 이 네트워크를 삭제하시겠습니까?" }, - "deposit": { - "message": "입금" - }, "depositEther": { "message": "이더리움 입금하기" }, @@ -979,9 +973,6 @@ "sentEther": { "message": "전송된 이더" }, - "sentTokens": { - "message": "전송된 토큰" - }, "separateEachWord": { "message": "각 단어는 공백 한칸으로 분리합니다" }, diff --git a/app/_locales/lt/messages.json b/app/_locales/lt/messages.json index b88fc2c67..4706d4e22 100644 --- a/app/_locales/lt/messages.json +++ b/app/_locales/lt/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Atšaukti" }, - "cancelAttempt": { - "message": "Atšaukti mėginimą" - }, "cancellationGasFee": { "message": "Dujų mokesčio atšaukimas" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "Ar tikrai norite panaikinti šį tinklą?" }, - "deposit": { - "message": "Indėlis" - }, "depositEther": { "message": "Įnešti eterių" }, @@ -988,9 +982,6 @@ "sentEther": { "message": "siųsti eterių" }, - "sentTokens": { - "message": "išsiųsti žetonai" - }, "separateEachWord": { "message": "Kiekvieną žodį atskirkite viengubu tarpu" }, diff --git a/app/_locales/lv/messages.json b/app/_locales/lv/messages.json index 40fb55edf..64a48dac8 100644 --- a/app/_locales/lv/messages.json +++ b/app/_locales/lv/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Atcelt" }, - "cancelAttempt": { - "message": "Atcelt mēģinājumu" - }, "cancellationGasFee": { "message": "Atcelšanas maksājums par Gas" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "Vai tiešām vēlaties dzēst šo tīklu?" }, - "deposit": { - "message": "Iemaksa" - }, "depositEther": { "message": "Noguldīt Ether" }, @@ -984,9 +978,6 @@ "sentEther": { "message": "nosūtītie ether" }, - "sentTokens": { - "message": "nosūtītie marķieri" - }, "separateEachWord": { "message": "Atdaliet katru vārdu ar vienu atstarpi" }, diff --git a/app/_locales/ms/messages.json b/app/_locales/ms/messages.json index 425e9eb20..010392658 100644 --- a/app/_locales/ms/messages.json +++ b/app/_locales/ms/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Batal" }, - "cancelAttempt": { - "message": "Batalkan Percubaan" - }, "cancellationGasFee": { "message": "Fi Gas Pembatalan" }, @@ -962,9 +959,6 @@ "sentEther": { "message": "menghantar ether" }, - "sentTokens": { - "message": "token dihantar" - }, "separateEachWord": { "message": "Pisahkan setiap perkataan dengan ruang tunggal" }, diff --git a/app/_locales/nl/messages.json b/app/_locales/nl/messages.json index fa9e168ff..f6ef6b7dc 100644 --- a/app/_locales/nl/messages.json +++ b/app/_locales/nl/messages.json @@ -94,9 +94,6 @@ "defaultNetwork": { "message": "Het standaardnetwerk voor Ether-transacties is Main Net." }, - "deposit": { - "message": "Storting" - }, "depositEther": { "message": "Stort Ether" }, diff --git a/app/_locales/no/messages.json b/app/_locales/no/messages.json index ab94ce321..ffc04048b 100644 --- a/app/_locales/no/messages.json +++ b/app/_locales/no/messages.json @@ -161,9 +161,6 @@ "cancel": { "message": "Avbryt" }, - "cancelAttempt": { - "message": "Avbryt forsøk" - }, "cancellationGasFee": { "message": "Kansellering gassavgift" }, @@ -305,9 +302,6 @@ "deleteNetworkDescription": { "message": "Er du sikker på at du vil slette dette nettverket?" }, - "deposit": { - "message": "Innskudd" - }, "depositEther": { "message": "Sett inn Ether " }, @@ -966,9 +960,6 @@ "sentEther": { "message": "sendt ether" }, - "sentTokens": { - "message": "sendte tokener " - }, "separateEachWord": { "message": "Del hvert ord med et enkelt mellomrom " }, diff --git a/app/_locales/ph/messages.json b/app/_locales/ph/messages.json index b2635da57..6cb59f6a0 100644 --- a/app/_locales/ph/messages.json +++ b/app/_locales/ph/messages.json @@ -73,9 +73,6 @@ "defaultNetwork": { "message": "Ang default network para sa Ether transactions ay ang Main Net." }, - "deposit": { - "message": "Deposito" - }, "depositEther": { "message": "I-deposito ang Ether" }, diff --git a/app/_locales/pl/messages.json b/app/_locales/pl/messages.json index 157bfb7d0..2d1e6484a 100644 --- a/app/_locales/pl/messages.json +++ b/app/_locales/pl/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Anuluj" }, - "cancelAttempt": { - "message": "Anuluj próbę" - }, "cancellationGasFee": { "message": "Opłata za gaz za anulowanie" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "Czy na pewno chcesz usunąć tę sieć?" }, - "deposit": { - "message": "Zdeponuj" - }, "depositEther": { "message": "Zdeponuj Eter" }, @@ -982,9 +976,6 @@ "sentEther": { "message": "wyślij eter" }, - "sentTokens": { - "message": "wysłane tokeny" - }, "separateEachWord": { "message": "Oddziel słowa pojedynczą spacją" }, diff --git a/app/_locales/pt/messages.json b/app/_locales/pt/messages.json index 067fd8d34..da8314cad 100644 --- a/app/_locales/pt/messages.json +++ b/app/_locales/pt/messages.json @@ -97,9 +97,6 @@ "defaultNetwork": { "message": "A rede pré definida para transações em Ether é a Main Net." }, - "deposit": { - "message": "Depósito" - }, "depositEther": { "message": "Depositar Ether" }, diff --git a/app/_locales/pt_BR/messages.json b/app/_locales/pt_BR/messages.json index 68eda6f73..1a98307b0 100644 --- a/app/_locales/pt_BR/messages.json +++ b/app/_locales/pt_BR/messages.json @@ -158,9 +158,6 @@ "cancel": { "message": "Cancelar" }, - "cancelAttempt": { - "message": "Tentativa de cancelamento" - }, "cancellationGasFee": { "message": "Tarifa de Gas de cancelamento" }, @@ -302,9 +299,6 @@ "deleteNetworkDescription": { "message": "Tem certeza de que deseja excluir esta rede?" }, - "deposit": { - "message": "Depósito" - }, "depositEther": { "message": "Depositar Ether" }, @@ -976,9 +970,6 @@ "sentEther": { "message": "ether enviado" }, - "sentTokens": { - "message": "tokens enviados" - }, "separateEachWord": { "message": "Separe cada palavra com um único espaço" }, diff --git a/app/_locales/pt_PT/messages.json b/app/_locales/pt_PT/messages.json index ed3c0a8d5..96ed89f8e 100644 --- a/app/_locales/pt_PT/messages.json +++ b/app/_locales/pt_PT/messages.json @@ -45,9 +45,6 @@ "delete": { "message": "Eliminar" }, - "deposit": { - "message": "Depósito" - }, "details": { "message": "Detalhes" }, diff --git a/app/_locales/ro/messages.json b/app/_locales/ro/messages.json index bdcfc126f..a2469af1d 100644 --- a/app/_locales/ro/messages.json +++ b/app/_locales/ro/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Anulare" }, - "cancelAttempt": { - "message": "Anulare încercare" - }, "cancellationGasFee": { "message": "Taxă de anulare în gaz" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "Sigur vreți să ștergeți această rețea?" }, - "deposit": { - "message": "Depunere" - }, "depositEther": { "message": "Depuneți Ether" }, @@ -975,9 +969,6 @@ "sentEther": { "message": "trimiteți ether" }, - "sentTokens": { - "message": "tokenuri trimise" - }, "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 1ef3ac602..307e638eb 100644 --- a/app/_locales/ru/messages.json +++ b/app/_locales/ru/messages.json @@ -163,9 +163,6 @@ "cancel": { "message": "Отмена" }, - "cancelAttempt": { - "message": "Попытка отмены транзакции" - }, "cancellationGasFee": { "message": "Комиссия за газ на отмену" }, @@ -330,9 +327,6 @@ "deleteNetworkDescription": { "message": "Вы уверены, что хотите удалить эту сеть?" }, - "deposit": { - "message": "Пополнить" - }, "depositEther": { "message": "Пополнить Ether" }, @@ -1024,9 +1018,6 @@ "sentEther": { "message": "Отправить Ether" }, - "sentTokens": { - "message": "Отправленные токены" - }, "separateEachWord": { "message": "Разделяйте каждое слово одним пробелом" }, diff --git a/app/_locales/sk/messages.json b/app/_locales/sk/messages.json index 1b0ba15c9..fa7860ca4 100644 --- a/app/_locales/sk/messages.json +++ b/app/_locales/sk/messages.json @@ -158,9 +158,6 @@ "cancel": { "message": "Zrušit" }, - "cancelAttempt": { - "message": "Zrušiť pokus" - }, "cancellationGasFee": { "message": "Storno poplatok za GAS" }, @@ -302,9 +299,6 @@ "deleteNetworkDescription": { "message": "Naozaj chcete túto sieť odstrániť?" }, - "deposit": { - "message": "Vklad" - }, "depositEther": { "message": "Vložit Ether" }, @@ -951,9 +945,6 @@ "sentEther": { "message": "poslaný ether" }, - "sentTokens": { - "message": "poslané tokeny" - }, "separateEachWord": { "message": "Každé slovo oddeľte jednou medzerou" }, diff --git a/app/_locales/sl/messages.json b/app/_locales/sl/messages.json index b49ab7fec..10ef7ee0a 100644 --- a/app/_locales/sl/messages.json +++ b/app/_locales/sl/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Prekliči" }, - "cancelAttempt": { - "message": "Prekliči poskus" - }, "cancellationGasFee": { "message": "Preklicani znesek gas" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "Ali ste prepričani, da želite izbrisati to omrežje?" }, - "deposit": { - "message": "Vplačaj" - }, "depositEther": { "message": "Vplačilo ethra" }, @@ -970,9 +964,6 @@ "sentEther": { "message": "poslani ether" }, - "sentTokens": { - "message": "poslani žetoni" - }, "separateEachWord": { "message": "Vsako besedo ločite z enim presledkom" }, diff --git a/app/_locales/sr/messages.json b/app/_locales/sr/messages.json index d72f4007e..d07bacfa1 100644 --- a/app/_locales/sr/messages.json +++ b/app/_locales/sr/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Otkaži" }, - "cancelAttempt": { - "message": "Otkaži pokušaj" - }, "cancellationGasFee": { "message": "Otkazivanje gas naknade" }, @@ -305,9 +302,6 @@ "deleteNetworkDescription": { "message": "Da li ste sigurni da želite da izbrišete ovu mrežu?" }, - "deposit": { - "message": "Depozit" - }, "depositEther": { "message": "Dajte depozit Ether-u" }, @@ -979,9 +973,6 @@ "sentEther": { "message": "ether je poslat" }, - "sentTokens": { - "message": "poslati tokeni" - }, "separateEachWord": { "message": "Razdvojite svaku reč jednim mestom razmaka" }, diff --git a/app/_locales/sv/messages.json b/app/_locales/sv/messages.json index 6c6b68622..4fb6bfe1e 100644 --- a/app/_locales/sv/messages.json +++ b/app/_locales/sv/messages.json @@ -161,9 +161,6 @@ "cancel": { "message": "Avbryt" }, - "cancelAttempt": { - "message": "Avbryt försök" - }, "cancellationGasFee": { "message": "Gasavgift för avbrytning" }, @@ -302,9 +299,6 @@ "deleteNetworkDescription": { "message": "Är du säker på att du vill ta bort detta nätverk?" }, - "deposit": { - "message": "Deposition" - }, "depositEther": { "message": "Sätt in Ether" }, @@ -972,9 +966,6 @@ "sentEther": { "message": "skickat ether" }, - "sentTokens": { - "message": "skickade tokens" - }, "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 5662950c6..61203f047 100644 --- a/app/_locales/sw/messages.json +++ b/app/_locales/sw/messages.json @@ -158,9 +158,6 @@ "cancel": { "message": "Ghairi" }, - "cancelAttempt": { - "message": "Jaribio la Kubatilisha" - }, "cancellationGasFee": { "message": "Ada ya Kubatilisha Gesi" }, @@ -302,9 +299,6 @@ "deleteNetworkDescription": { "message": "Una uhakika unataka kufuta mtandao huu?" }, - "deposit": { - "message": "Fedha zilizopo kwenye akaunti" - }, "depositEther": { "message": "Weka Ether" }, @@ -966,9 +960,6 @@ "sentEther": { "message": "ether iliyotumwa" }, - "sentTokens": { - "message": "vianzio vilivyotumwa" - }, "separateEachWord": { "message": "Tenganisha kila neno kwa nafasi moja" }, diff --git a/app/_locales/ta/messages.json b/app/_locales/ta/messages.json index 507893d9a..f0ca60e9c 100644 --- a/app/_locales/ta/messages.json +++ b/app/_locales/ta/messages.json @@ -136,9 +136,6 @@ "delete": { "message": "நீக்கு" }, - "deposit": { - "message": "வைப்புத்தொகை" - }, "depositEther": { "message": "வைப்புத்தொகை எதிர் " }, diff --git a/app/_locales/th/messages.json b/app/_locales/th/messages.json index 28a662868..f54947489 100644 --- a/app/_locales/th/messages.json +++ b/app/_locales/th/messages.json @@ -142,9 +142,6 @@ "deleteNetwork": { "message": "ลบเครือข่าย?" }, - "deposit": { - "message": "ฝาก" - }, "depositEther": { "message": "การฝากอีเธอร์" }, diff --git a/app/_locales/tr/messages.json b/app/_locales/tr/messages.json index 7448ad53f..5868000c8 100644 --- a/app/_locales/tr/messages.json +++ b/app/_locales/tr/messages.json @@ -118,9 +118,6 @@ "defaultNetwork": { "message": "Ether işlemleri için varsayılan ağ Main Net." }, - "deposit": { - "message": "Yatır" - }, "depositEther": { "message": "Ether yatır" }, diff --git a/app/_locales/uk/messages.json b/app/_locales/uk/messages.json index c314c5c31..70a9b0c36 100644 --- a/app/_locales/uk/messages.json +++ b/app/_locales/uk/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "Скасувати" }, - "cancelAttempt": { - "message": "Відмінити спробу" - }, "cancellationGasFee": { "message": "Вартість пального за скасування" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "Ви впевнені, що хочете видалити цю мережу?" }, - "deposit": { - "message": "Депозит" - }, "depositEther": { "message": "Депонувати Ether" }, @@ -988,9 +982,6 @@ "sentEther": { "message": "надісланий ефір" }, - "sentTokens": { - "message": "надіслані токени" - }, "separateEachWord": { "message": "Відділіть кожне слово одним пробілом" }, diff --git a/app/_locales/vi/messages.json b/app/_locales/vi/messages.json index 1e8f4b5d1..cfdcf467e 100644 --- a/app/_locales/vi/messages.json +++ b/app/_locales/vi/messages.json @@ -79,9 +79,6 @@ "defaultNetwork": { "message": "Mạng lưới mặc định dùng cho các giao dịch Ether là Main Net (tiền ETH thật)." }, - "deposit": { - "message": "Ký gửi/nạp tiền" - }, "depositEther": { "message": "Ký gửi Ether" }, diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json index 454e1d7cf..5dfed18d1 100644 --- a/app/_locales/zh_CN/messages.json +++ b/app/_locales/zh_CN/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "取消" }, - "cancelAttempt": { - "message": "取消操作" - }, "cancellationGasFee": { "message": "取消天然气费" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "您是否确认要删除该网络?" }, - "deposit": { - "message": "存入" - }, "depositEther": { "message": "存入 Ether" }, @@ -970,9 +964,6 @@ "sentEther": { "message": "以太币已发送" }, - "sentTokens": { - "message": "代币已发送" - }, "separateEachWord": { "message": "用空格分隔每个单词" }, diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json index dcbd8aab0..c34a0411f 100644 --- a/app/_locales/zh_TW/messages.json +++ b/app/_locales/zh_TW/messages.json @@ -164,9 +164,6 @@ "cancel": { "message": "取消" }, - "cancelAttempt": { - "message": "嘗試取消" - }, "cancellationGasFee": { "message": "需要的手續費" }, @@ -308,9 +305,6 @@ "deleteNetworkDescription": { "message": "你確定要刪除網路嗎?" }, - "deposit": { - "message": "存入" - }, "depositEther": { "message": "存入乙太幣" }, @@ -967,9 +961,6 @@ "sentEther": { "message": "發送乙太幣" }, - "sentTokens": { - "message": "發送代幣" - }, "separateEachWord": { "message": "單詞之間請以空白間隔" }, diff --git a/app/scripts/controllers/transactions/enums.js b/app/scripts/controllers/transactions/enums.js deleted file mode 100644 index dcd383dd5..000000000 --- a/app/scripts/controllers/transactions/enums.js +++ /dev/null @@ -1,14 +0,0 @@ -const TRANSACTION_TYPE_CANCEL = 'cancel' -const TRANSACTION_TYPE_RETRY = 'retry' -const TRANSACTION_TYPE_STANDARD = 'standard' - -const TRANSACTION_STATUS_APPROVED = 'approved' -const TRANSACTION_STATUS_CONFIRMED = 'confirmed' - -export { - TRANSACTION_TYPE_CANCEL, - TRANSACTION_TYPE_RETRY, - TRANSACTION_TYPE_STANDARD, - TRANSACTION_STATUS_APPROVED, - TRANSACTION_STATUS_CONFIRMED, -} diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 3e618743b..9c54bc512 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -9,29 +9,19 @@ import { ethers } from 'ethers' import NonceTracker from 'nonce-tracker' import log from 'loglevel' import BigNumber from 'bignumber.js' -import { - TOKEN_METHOD_APPROVE, - TOKEN_METHOD_TRANSFER, - TOKEN_METHOD_TRANSFER_FROM, - SEND_ETHER_ACTION_KEY, - DEPLOY_CONTRACT_ACTION_KEY, - CONTRACT_INTERACTION_KEY, - SWAP, -} from '../../../../ui/app/helpers/constants/transactions' import cleanErrorStack from '../../lib/cleanErrorStack' import { hexToBn, bnToHex, BnMultiplyByFraction } from '../../lib/util' import { TRANSACTION_NO_CONTRACT_ERROR_KEY } from '../../../../ui/app/helpers/constants/error-keys' import { getSwapsTokensReceivedFromTxMeta } from '../../../../ui/app/pages/swaps/swaps.util' +import { + TRANSACTION_CATEGORIES, + TRANSACTION_STATUSES, + TRANSACTION_TYPES, +} from '../../../../shared/constants/transaction' import TransactionStateManager from './tx-state-manager' import TxGasUtil from './tx-gas-utils' import PendingTransactionTracker from './pending-tx-tracker' import * as txUtils from './lib/util' -import { - TRANSACTION_TYPE_CANCEL, - TRANSACTION_TYPE_RETRY, - TRANSACTION_TYPE_STANDARD, - TRANSACTION_STATUS_APPROVED, -} from './enums' const hstInterface = new ethers.utils.Interface(abi) @@ -240,7 +230,7 @@ export default class TransactionController extends EventEmitter { */ let txMeta = this.txStateManager.generateTxMeta({ txParams: normalizedTxParams, - type: TRANSACTION_TYPE_STANDARD, + type: TRANSACTION_TYPES.STANDARD, }) if (origin === 'metamask') { @@ -348,7 +338,7 @@ export default class TransactionController extends EventEmitter { return {} } else if ( txMeta.txParams.to && - txMeta.transactionCategory === SEND_ETHER_ACTION_KEY + txMeta.transactionCategory === TRANSACTION_CATEGORIES.SENT_ETHER ) { // if there's data in the params, but there's no contract code, it's not a valid transaction if (txMeta.txParams.data) { @@ -408,8 +398,8 @@ export default class TransactionController extends EventEmitter { }, lastGasPrice, loadingDefaults: false, - status: TRANSACTION_STATUS_APPROVED, - type: TRANSACTION_TYPE_CANCEL, + status: TRANSACTION_STATUSES.APPROVED, + type: TRANSACTION_TYPES.CANCEL, }) this.addTx(newTxMeta) @@ -443,8 +433,8 @@ export default class TransactionController extends EventEmitter { }, lastGasPrice, loadingDefaults: false, - status: TRANSACTION_STATUS_APPROVED, - type: TRANSACTION_TYPE_RETRY, + status: TRANSACTION_STATUSES.APPROVED, + type: TRANSACTION_TYPES.RETRY, }) if (customGasLimit) { @@ -582,7 +572,7 @@ export default class TransactionController extends EventEmitter { async publishTransaction(txId, rawTx) { const txMeta = this.txStateManager.getTx(txId) txMeta.rawTx = rawTx - if (txMeta.transactionCategory === SWAP) { + if (txMeta.transactionCategory === TRANSACTION_CATEGORIES.SWAP) { const preTxBalance = await this.query.getBalance(txMeta.txParams.from) txMeta.preTxBalance = preTxBalance.toString(16) } @@ -638,7 +628,7 @@ export default class TransactionController extends EventEmitter { 'transactions#confirmTransaction - add txReceipt', ) - if (txMeta.transactionCategory === SWAP) { + if (txMeta.transactionCategory === TRANSACTION_CATEGORIES.SWAP) { const postTxBalance = await this.query.getBalance(txMeta.txParams.from) const latestTxMeta = this.txStateManager.getTx(txId) @@ -754,7 +744,7 @@ export default class TransactionController extends EventEmitter { this.txStateManager .getFilteredTxList({ - status: TRANSACTION_STATUS_APPROVED, + status: TRANSACTION_STATUSES.APPROVED, }) .forEach((txMeta) => { const txSignError = new Error( @@ -826,16 +816,16 @@ export default class TransactionController extends EventEmitter { } const tokenMethodName = [ - TOKEN_METHOD_APPROVE, - TOKEN_METHOD_TRANSFER, - TOKEN_METHOD_TRANSFER_FROM, + TRANSACTION_CATEGORIES.TOKEN_METHOD_APPROVE, + TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER, + TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER_FROM, ].find((methodName) => methodName === name && name.toLowerCase()) let result if (txParams.data && tokenMethodName) { result = tokenMethodName } else if (txParams.data && !to) { - result = DEPLOY_CONTRACT_ACTION_KEY + result = TRANSACTION_CATEGORIES.DEPLOY_CONTRACT } let code @@ -849,7 +839,9 @@ export default class TransactionController extends EventEmitter { const codeIsEmpty = !code || code === '0x' || code === '0x0' - result = codeIsEmpty ? SEND_ETHER_ACTION_KEY : CONTRACT_INTERACTION_KEY + result = codeIsEmpty + ? TRANSACTION_CATEGORIES.SENT_ETHER + : TRANSACTION_CATEGORIES.CONTRACT_INTERACTION } return { transactionCategory: result, getCodeResponse: code } diff --git a/development/verify-locale-strings.js b/development/verify-locale-strings.js index 9325824f7..46bc7f83e 100644 --- a/development/verify-locale-strings.js +++ b/development/verify-locale-strings.js @@ -175,9 +175,14 @@ async function verifyLocale(code) { async function verifyEnglishLocale() { const englishLocale = await getLocale('en') - const javascriptFiles = await findJavascriptFiles( + const uiJSFiles = await findJavascriptFiles( path.resolve(__dirname, '..', 'ui'), ) + const sharedJSFiles = await findJavascriptFiles( + path.resolve(__dirname, '..', 'shared'), + ) + + const javascriptFiles = sharedJSFiles.concat(uiJSFiles) // match "t(`...`)" because constructing message keys from template strings // prevents this script from finding the messages, and then inappropriately diff --git a/shared/constants/transaction.js b/shared/constants/transaction.js new file mode 100644 index 000000000..534b6c57e --- /dev/null +++ b/shared/constants/transaction.js @@ -0,0 +1,147 @@ +/** + * Transaction Type is a MetaMask construct used internally + * @typedef {Object} TransactionTypes + * @property {'standard'} STANDARD - A standard transaction, usually the first with + * a given nonce + * @property {'cancel'} CANCEL - A transaction submitted with the same nonce as a + * previous transaction, a higher gas price and a zeroed out send amount. Useful + * for users who accidentally send to erroneous addresses or if they send too much. + * @property {'retry'} RETRY - When a transaction is failed it can be retried by + * resubmitting the same transaction with a higher gas fee. This type is also used + * to speed up pending transactions. This is accomplished by creating a new tx with + * the same nonce and higher gas fees. + */ + +/** + * @type {TransactionTypes} + */ +export const TRANSACTION_TYPES = { + STANDARD: 'standard', + CANCEL: 'cancel', + RETRY: 'retry', +} + +/** + * Transaction Status is a mix of Ethereum and MetaMask terminology, used internally + * for transaction processing. + * @typedef {Object} TransactionStatuses + * @property {'unapproved'} UNAPPROVED - A new transaction that the user has not + * approved or rejected + * @property {'approved'} APPROVED - The user has approved the transaction in the + * MetaMask UI + * @property {'rejected'} REJECTED - The user has rejected the transaction in the + * MetaMask UI + * @property {'signed'} SIGNED - The transaction has been signed + * @property {'submitted'} SIGNED - The transaction has been submitted to network + * @property {'failed'} FAILED - The transaction has failed for some reason + * @property {'dropped'} DROPPED - The transaction was dropped due to a tx with same + * nonce being accepted + * @property {'confirmed'} CONFIRMED - The transaction was confirmed by the network + */ + +/** + * @type {TransactionStatuses} + */ +export const TRANSACTION_STATUSES = { + UNAPPROVED: 'unapproved', + APPROVED: 'approved', + REJECTED: 'rejected', + SIGNED: 'signed', + SUBMITTED: 'submitted', + FAILED: 'failed', + DROPPED: 'dropped', + CONFIRMED: 'confirmed', +} + +/** + * @typedef {Object} TransactionCategories + * @property {'transfer'} TOKEN_METHOD_TRANSFER - A token transaction where the user + * is sending tokens that they own to another address + * @property {'transferfrom'} TOKEN_METHOD_TRANSFER_FROM - A token transaction + * transferring tokens from an account that the sender has an allowance of. + * For more information on allowances, see the approve category. + * @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 {'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 + * @property {'contractDeployment'} DEPLOY_CONTRACT - A transaction that deployed + * a smart contract + * @property {'swap'} SWAP - A transaction swapping one token for another through + * MetaMask Swaps + * @property {'swapApproval'} SWAP_APPROVAL - Similar to the approve category, a swap + * approval is a special case of ERC20 approve method that requests an allowance of + * the token to spend on behalf of the user for the MetaMask Swaps contract. The first + * swap for any token will have an accompanying swapApproval transaction. + */ + +/** + * @type {TransactionCategories} + */ +export const TRANSACTION_CATEGORIES = { + TOKEN_METHOD_TRANSFER: 'transfer', + TOKEN_METHOD_TRANSFER_FROM: 'transferfrom', + TOKEN_METHOD_APPROVE: 'approve', + INCOMING: 'incoming', + SENT_ETHER: 'sentEther', + CONTRACT_INTERACTION: 'contractInteraction', + DEPLOY_CONTRACT: 'contractDeployment', + SWAP: 'swap', + SWAP_APPROVAL: 'swapApproval', +} + +/** + * Transaction Group Status is a MetaMask construct to track the status of groups + * of transactions. + * @typedef {Object} TransactionGroupStatuses + * @property {'cancelled'} CANCELLED - A cancel type transaction in the group was + * confirmed + * @property {'pending'} PENDING - The primaryTransaction of the group has a status + * that is one of TRANSACTION_STATUSES.APPROVED, TRANSACTION_STATUSES.UNAPPROVED + * or TRANSACTION_STATUSES.SUBMITTED + */ + +/** + * @type {TransactionGroupStatuses} + */ +export const TRANSACTION_GROUP_STATUSES = { + CANCELLED: 'cancelled', + PENDING: 'pending', +} + +/** + * Transaction Group Category is a MetaMask construct to categorize the intent + * of a group of transactions for purposes of displaying in the UI + * @typedef {Object} TransactionGroupCategories + * @property {'send'} SEND - Transaction group representing ether being sent from + * the user. + * @property {'receive'} RECEIVE - Transaction group representing a deposit/incoming + * transaction. This category maps 1:1 with TRANSACTION_CATEGORIES.INCOMING. + * @property {'interaction'} INTERACTION - Transaction group representing + * an interaction with a smart contract's methods. + * @property {'approval'} APPROVAL - Transaction group representing a request for an + * allowance of a token to spend on the user's behalf. + * @property {'signature-request'} SIGNATURE_REQUEST - Transaction group representing + * a signature request This currently only shows up in the UI when its pending user + * approval in the UI. Once the user approves or rejects it will no longer show in + * activity. + * @property {'swap'} SWAP - Transaction group representing a token swap through + * MetaMask Swaps. This transaction group's primary currency changes depending + * on context. If the user is viewing an asset page for a token received from a swap, + * the primary currency will be the received token. Otherwise the token exchanged + * will be shown. + */ + +/** + * @type {TransactionGroupCategories} + */ +export const TRANSACTION_GROUP_CATEGORIES = { + SEND: 'send', + RECEIVE: 'receive', + INTERACTION: 'interaction', + APPROVAL: 'approval', + SIGNATURE_REQUEST: 'signature-request', + SWAP: 'swap', +} diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js index 4effec147..f70cdbd75 100644 --- a/test/unit/app/controllers/transactions/tx-controller-test.js +++ b/test/unit/app/controllers/transactions/tx-controller-test.js @@ -5,20 +5,15 @@ import EthTx from 'ethereumjs-tx' import ObservableStore from 'obs-store' import sinon from 'sinon' import TransactionController from '../../../../../app/scripts/controllers/transactions' -import { TRANSACTION_TYPE_RETRY } from '../../../../../app/scripts/controllers/transactions/enums' - -import { - TOKEN_METHOD_APPROVE, - TOKEN_METHOD_TRANSFER, - SEND_ETHER_ACTION_KEY, - DEPLOY_CONTRACT_ACTION_KEY, - CONTRACT_INTERACTION_KEY, -} from '../../../../../ui/app/helpers/constants/transactions' import { createTestProviderTools, getTestAccounts, } from '../../../../stub/provider' +import { + TRANSACTION_CATEGORIES, + TRANSACTION_TYPES, +} from '../../../../../shared/constants/transaction' const noop = () => true const currentNetworkId = '42' @@ -628,7 +623,7 @@ describe('Transaction Controller', function () { { lastGasPrice, type }, { lastGasPrice: '0xa', - type: TRANSACTION_TYPE_RETRY, + type: TRANSACTION_TYPES.RETRY, }, ) }) @@ -651,7 +646,7 @@ describe('Transaction Controller', function () { { lastGasPrice, type }, { lastGasPrice: '0xa', - type: TRANSACTION_TYPE_RETRY, + type: TRANSACTION_TYPES.RETRY, }, ) }) @@ -773,7 +768,7 @@ describe('Transaction Controller', function () { data: '', }) assert.deepEqual(result, { - transactionCategory: SEND_ETHER_ACTION_KEY, + transactionCategory: TRANSACTION_CATEGORIES.SENT_ETHER, getCodeResponse: null, }) }) @@ -785,7 +780,7 @@ describe('Transaction Controller', function () { '0xa9059cbb0000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C970000000000000000000000000000000000000000000000000000000000000000a', }) assert.deepEqual(result, { - transactionCategory: TOKEN_METHOD_TRANSFER, + transactionCategory: TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER, getCodeResponse: undefined, }) }) @@ -797,7 +792,7 @@ describe('Transaction Controller', function () { '0x095ea7b30000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C9700000000000000000000000000000000000000000000000000000000000000005', }) assert.deepEqual(result, { - transactionCategory: TOKEN_METHOD_APPROVE, + transactionCategory: TRANSACTION_CATEGORIES.TOKEN_METHOD_APPROVE, getCodeResponse: undefined, }) }) @@ -808,7 +803,7 @@ describe('Transaction Controller', function () { data: '0xabd', }) assert.deepEqual(result, { - transactionCategory: DEPLOY_CONTRACT_ACTION_KEY, + transactionCategory: TRANSACTION_CATEGORIES.DEPLOY_CONTRACT, getCodeResponse: undefined, }) }) @@ -819,7 +814,7 @@ describe('Transaction Controller', function () { data: '0xabd', }) assert.deepEqual(result, { - transactionCategory: SEND_ETHER_ACTION_KEY, + transactionCategory: TRANSACTION_CATEGORIES.SENT_ETHER, getCodeResponse: '0x', }) }) @@ -830,7 +825,7 @@ describe('Transaction Controller', function () { data: '0xabd', }) assert.deepEqual(result, { - transactionCategory: SEND_ETHER_ACTION_KEY, + transactionCategory: TRANSACTION_CATEGORIES.SENT_ETHER, getCodeResponse: null, }) }) @@ -869,7 +864,7 @@ describe('Transaction Controller', function () { data: 'abd', }) assert.deepEqual(result, { - transactionCategory: CONTRACT_INTERACTION_KEY, + transactionCategory: TRANSACTION_CATEGORIES.CONTRACT_INTERACTION, getCodeResponse: '0x0a', }) }) @@ -908,7 +903,7 @@ describe('Transaction Controller', function () { data: '', }) assert.deepEqual(result, { - transactionCategory: CONTRACT_INTERACTION_KEY, + transactionCategory: TRANSACTION_CATEGORIES.CONTRACT_INTERACTION, getCodeResponse: '0x0a', }) }) diff --git a/ui/app/components/app/modals/cancel-transaction/cancel-transaction.component.js b/ui/app/components/app/modals/cancel-transaction/cancel-transaction.component.js index 25b04295b..7bddafc34 100644 --- a/ui/app/components/app/modals/cancel-transaction/cancel-transaction.component.js +++ b/ui/app/components/app/modals/cancel-transaction/cancel-transaction.component.js @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react' import PropTypes from 'prop-types' import Modal from '../../modal' -import { SUBMITTED_STATUS } from '../../../../helpers/constants/transactions' +import { TRANSACTION_STATUSES } from '../../../../../../shared/constants/transaction' import CancelTransactionGasFee from './cancel-transaction-gas-fee' export default class CancelTransaction extends PureComponent { @@ -24,7 +24,7 @@ export default class CancelTransaction extends PureComponent { componentDidUpdate() { const { transactionStatus, showTransactionConfirmedModal } = this.props - if (transactionStatus !== SUBMITTED_STATUS) { + if (transactionStatus !== TRANSACTION_STATUSES.SUBMITTED) { showTransactionConfirmedModal() } } diff --git a/ui/app/components/app/transaction-activity-log/transaction-activity-log.util.js b/ui/app/components/app/transaction-activity-log/transaction-activity-log.util.js index aa17ee348..8b7b7ba24 100644 --- a/ui/app/components/app/transaction-activity-log/transaction-activity-log.util.js +++ b/ui/app/components/app/transaction-activity-log/transaction-activity-log.util.js @@ -1,9 +1,6 @@ +import { TRANSACTION_TYPES } from '../../../../../shared/constants/transaction' import { getHexGasTotal } from '../../../helpers/utils/confirm-tx.util' -import { - TRANSACTION_TYPE_CANCEL, - TRANSACTION_TYPE_RETRY, -} from '../../../../../app/scripts/controllers/transactions/enums' import { // event constants TRANSACTION_CREATED_EVENT, @@ -114,13 +111,13 @@ export function getActivities(transaction, isFirstTransaction = false) { // If the status is 'submitted', we need to determine whether the event is a // transaction retry or a cancellation attempt. if (value === SUBMITTED_STATUS) { - if (type === TRANSACTION_TYPE_RETRY) { + if (type === TRANSACTION_TYPES.RETRY) { eventKey = TRANSACTION_RESUBMITTED_EVENT - } else if (type === TRANSACTION_TYPE_CANCEL) { + } else if (type === TRANSACTION_TYPES.CANCEL) { eventKey = TRANSACTION_CANCEL_ATTEMPTED_EVENT } } else if (value === CONFIRMED_STATUS) { - if (type === TRANSACTION_TYPE_CANCEL) { + if (type === TRANSACTION_TYPES.CANCEL) { eventKey = TRANSACTION_CANCEL_SUCCESS_EVENT } } diff --git a/ui/app/components/app/transaction-breakdown/transaction-breakdown.container.js b/ui/app/components/app/transaction-breakdown/transaction-breakdown.container.js index 76ae90617..d4bf56100 100644 --- a/ui/app/components/app/transaction-breakdown/transaction-breakdown.container.js +++ b/ui/app/components/app/transaction-breakdown/transaction-breakdown.container.js @@ -6,7 +6,7 @@ import { } from '../../../selectors' import { getHexGasTotal } from '../../../helpers/utils/confirm-tx.util' import { sumHexes } from '../../../helpers/utils/transactions.util' -import { TOKEN_METHOD_APPROVE } from '../../../helpers/constants/transactions' +import { TRANSACTION_CATEGORIES } from '../../../../../shared/constants/transaction' import TransactionBreakdown from './transaction-breakdown.component' const mapStateToProps = (state, ownProps) => { @@ -17,7 +17,8 @@ const mapStateToProps = (state, ownProps) => { } = transaction const { showFiatInTestnets } = getPreferences(state) const isMainnet = getIsMainnet(state) - const isTokenApprove = transactionCategory === TOKEN_METHOD_APPROVE + const isTokenApprove = + transactionCategory === TRANSACTION_CATEGORIES.TOKEN_METHOD_APPROVE const gasLimit = typeof gasUsed === 'string' ? gasUsed : gas diff --git a/ui/app/components/app/transaction-icon/transaction-icon.js b/ui/app/components/app/transaction-icon/transaction-icon.js index 4941ea78f..fe6aa0e5a 100644 --- a/ui/app/components/app/transaction-icon/transaction-icon.js +++ b/ui/app/components/app/transaction-icon/transaction-icon.js @@ -7,28 +7,18 @@ import Send from '../../ui/icon/send-icon.component' import Sign from '../../ui/icon/sign-icon.component' import Swap from '../../ui/icon/swap-icon-for-list.component' import { - TRANSACTION_CATEGORY_APPROVAL, - TRANSACTION_CATEGORY_SIGNATURE_REQUEST, - TRANSACTION_CATEGORY_INTERACTION, - TRANSACTION_CATEGORY_SEND, - TRANSACTION_CATEGORY_RECEIVE, - TRANSACTION_CATEGORY_SWAP, - UNAPPROVED_STATUS, - FAILED_STATUS, - REJECTED_STATUS, - CANCELLED_STATUS, - DROPPED_STATUS, - SUBMITTED_STATUS, - APPROVED_STATUS, -} from '../../../helpers/constants/transactions' + TRANSACTION_GROUP_CATEGORIES, + TRANSACTION_GROUP_STATUSES, + TRANSACTION_STATUSES, +} from '../../../../../shared/constants/transaction' const ICON_MAP = { - [TRANSACTION_CATEGORY_APPROVAL]: Approve, - [TRANSACTION_CATEGORY_INTERACTION]: Interaction, - [TRANSACTION_CATEGORY_SEND]: Send, - [TRANSACTION_CATEGORY_SIGNATURE_REQUEST]: Sign, - [TRANSACTION_CATEGORY_RECEIVE]: Receive, - [TRANSACTION_CATEGORY_SWAP]: Swap, + [TRANSACTION_GROUP_CATEGORIES.APPROVAL]: Approve, + [TRANSACTION_GROUP_CATEGORIES.INTERACTION]: Interaction, + [TRANSACTION_GROUP_CATEGORIES.SEND]: Send, + [TRANSACTION_GROUP_CATEGORIES.SIGNATURE_REQUEST]: Sign, + [TRANSACTION_GROUP_CATEGORIES.RECEIVE]: Receive, + [TRANSACTION_GROUP_CATEGORIES.SWAP]: Swap, } const FAIL_COLOR = '#D73A49' @@ -36,13 +26,13 @@ const PENDING_COLOR = '#6A737D' const OK_COLOR = '#2F80ED' const COLOR_MAP = { - [SUBMITTED_STATUS]: PENDING_COLOR, - [UNAPPROVED_STATUS]: PENDING_COLOR, - [APPROVED_STATUS]: PENDING_COLOR, - [FAILED_STATUS]: FAIL_COLOR, - [REJECTED_STATUS]: FAIL_COLOR, - [CANCELLED_STATUS]: FAIL_COLOR, - [DROPPED_STATUS]: FAIL_COLOR, + [TRANSACTION_GROUP_STATUSES.PENDING]: PENDING_COLOR, + [TRANSACTION_STATUSES.UNAPPROVED]: PENDING_COLOR, + [TRANSACTION_STATUSES.APPROVED]: PENDING_COLOR, + [TRANSACTION_STATUSES.FAILED]: FAIL_COLOR, + [TRANSACTION_STATUSES.REJECTED]: FAIL_COLOR, + [TRANSACTION_GROUP_STATUSES.CANCELLED]: FAIL_COLOR, + [TRANSACTION_STATUSES.DROPPED]: FAIL_COLOR, } export default function TransactionIcon({ status, category }) { diff --git a/ui/app/components/app/transaction-list-item/transaction-list-item.component.js b/ui/app/components/app/transaction-list-item/transaction-list-item.component.js index 6b276d9f4..9c472c11f 100644 --- a/ui/app/components/app/transaction-list-item/transaction-list-item.component.js +++ b/ui/app/components/app/transaction-list-item/transaction-list-item.component.js @@ -12,20 +12,15 @@ import Button from '../../ui/button' import Tooltip from '../../ui/tooltip' import TransactionListItemDetails from '../transaction-list-item-details' import { CONFIRM_TRANSACTION_ROUTE } from '../../../helpers/constants/routes' -import { - TRANSACTION_CATEGORY_SIGNATURE_REQUEST, - UNAPPROVED_STATUS, - TRANSACTION_CATEGORY_APPROVAL, - FAILED_STATUS, - DROPPED_STATUS, - REJECTED_STATUS, - TRANSACTION_CATEGORY_SWAP, -} from '../../../helpers/constants/transactions' import { useShouldShowSpeedUp } from '../../../hooks/useShouldShowSpeedUp' import TransactionStatus from '../transaction-status/transaction-status.component' import TransactionIcon from '../transaction-icon' import { useTransactionTimeRemaining } from '../../../hooks/useTransactionTimeRemaining' import IconWithLabel from '../../ui/icon-with-label' +import { + TRANSACTION_GROUP_CATEGORIES, + TRANSACTION_STATUSES, +} from '../../../../../shared/constants/transaction' export default function TransactionListItem({ transactionGroup, @@ -71,17 +66,20 @@ export default function TransactionListItem({ gasPrice, ) - const isSignatureReq = category === TRANSACTION_CATEGORY_SIGNATURE_REQUEST - const isApproval = category === TRANSACTION_CATEGORY_APPROVAL - const isUnapproved = displayedStatusKey === UNAPPROVED_STATUS - const isSwap = category === TRANSACTION_CATEGORY_SWAP + const isSignatureReq = + category === TRANSACTION_GROUP_CATEGORIES.SIGNATURE_REQUEST + const isApproval = category === TRANSACTION_GROUP_CATEGORIES.APPROVAL + const isUnapproved = status === TRANSACTION_STATUSES.UNAPPROVED + const isSwap = category === TRANSACTION_GROUP_CATEGORIES.SWAP const className = classnames('transaction-list-item', { 'transaction-list-item--unconfirmed': isPending || - [FAILED_STATUS, DROPPED_STATUS, REJECTED_STATUS].includes( - displayedStatusKey, - ), + [ + TRANSACTION_STATUSES.FAILED, + TRANSACTION_STATUSES.DROPPED, + TRANSACTION_STATUSES.REJECTED, + ].includes(displayedStatusKey), }) const toggleShowDetails = useCallback(() => { @@ -210,7 +208,7 @@ export default function TransactionListItem({ senderAddress={senderAddress} recipientAddress={recipientAddress} onRetry={retryTransaction} - showRetry={status === FAILED_STATUS && !isSwap} + showRetry={status === TRANSACTION_STATUSES.FAILED && !isSwap} showSpeedUp={shouldShowSpeedUp} isEarliestNonce={isEarliestNonce} onCancel={cancelTransaction} diff --git a/ui/app/components/app/transaction-list/transaction-list.component.js b/ui/app/components/app/transaction-list/transaction-list.component.js index 2f8cf6308..cfb70244f 100644 --- a/ui/app/components/app/transaction-list/transaction-list.component.js +++ b/ui/app/components/app/transaction-list/transaction-list.component.js @@ -10,11 +10,9 @@ import * as actions from '../../../ducks/gas/gas.duck' import { useI18nContext } from '../../../hooks/useI18nContext' import TransactionListItem from '../transaction-list-item' import Button from '../../ui/button' -import { - TOKEN_CATEGORY_HASH, - TRANSACTION_CATEGORY_SWAP, -} from '../../../helpers/constants/transactions' +import { TOKEN_CATEGORY_HASH } from '../../../helpers/constants/transactions' import { SWAPS_CONTRACT_ADDRESS } from '../../../helpers/constants/swaps' +import { TRANSACTION_CATEGORIES } from '../../../../../shared/constants/transaction' const PAGE_INCREMENT = 10 @@ -37,7 +35,7 @@ const tokenTransactionFilter = ({ }) => { if (TOKEN_CATEGORY_HASH[transactionCategory]) { return false - } else if (transactionCategory === TRANSACTION_CATEGORY_SWAP) { + } else if (transactionCategory === TRANSACTION_CATEGORIES.SWAP) { return destinationTokenSymbol === 'ETH' || sourceTokenSymbol === 'ETH' } return true diff --git a/ui/app/components/app/transaction-status/transaction-status.component.js b/ui/app/components/app/transaction-status/transaction-status.component.js index 9cd013118..fe75ed8c9 100644 --- a/ui/app/components/app/transaction-status/transaction-status.component.js +++ b/ui/app/components/app/transaction-status/transaction-status.component.js @@ -3,18 +3,11 @@ import PropTypes from 'prop-types' import classnames from 'classnames' import Tooltip from '../../ui/tooltip' -import { - UNAPPROVED_STATUS, - REJECTED_STATUS, - SUBMITTED_STATUS, - CONFIRMED_STATUS, - FAILED_STATUS, - DROPPED_STATUS, - CANCELLED_STATUS, - APPROVED_STATUS, - SIGNED_STATUS, -} from '../../../helpers/constants/transactions' import { useI18nContext } from '../../../hooks/useI18nContext' +import { + TRANSACTION_GROUP_STATUSES, + TRANSACTION_STATUSES, +} from '../../../../../shared/constants/transaction' const QUEUED_PSEUDO_STATUS = 'queued' const PENDING_PSEUDO_STATUS = 'pending' @@ -30,17 +23,17 @@ const PENDING_PSEUDO_STATUS = 'pending' * status label will be the date the transaction was finalized. */ const pendingStatusHash = { - [SUBMITTED_STATUS]: PENDING_PSEUDO_STATUS, - [APPROVED_STATUS]: PENDING_PSEUDO_STATUS, - [SIGNED_STATUS]: PENDING_PSEUDO_STATUS, + [TRANSACTION_STATUSES.SUBMITTED]: PENDING_PSEUDO_STATUS, + [TRANSACTION_STATUSES.APPROVED]: PENDING_PSEUDO_STATUS, + [TRANSACTION_STATUSES.SIGNED]: PENDING_PSEUDO_STATUS, } const statusToClassNameHash = { - [UNAPPROVED_STATUS]: 'transaction-status--unapproved', - [REJECTED_STATUS]: 'transaction-status--rejected', - [FAILED_STATUS]: 'transaction-status--failed', - [DROPPED_STATUS]: 'transaction-status--dropped', - [CANCELLED_STATUS]: 'transaction-status--cancelled', + [TRANSACTION_STATUSES.UNAPPROVED]: 'transaction-status--unapproved', + [TRANSACTION_STATUSES.REJECTED]: 'transaction-status--rejected', + [TRANSACTION_STATUSES.FAILED]: 'transaction-status--failed', + [TRANSACTION_STATUSES.DROPPED]: 'transaction-status--dropped', + [TRANSACTION_GROUP_STATUSES.CANCELLED]: 'transaction-status--cancelled', [QUEUED_PSEUDO_STATUS]: 'transaction-status--queued', [PENDING_PSEUDO_STATUS]: 'transaction-status--pending', } @@ -59,7 +52,8 @@ export default function TransactionStatus({ statusKey = isEarliestNonce ? PENDING_PSEUDO_STATUS : QUEUED_PSEUDO_STATUS } - const statusText = statusKey === CONFIRMED_STATUS ? date : t(statusKey) + const statusText = + statusKey === TRANSACTION_STATUSES.CONFIRMED ? date : t(statusKey) return ( { updateTransaction( { ...approveTxMeta, - transactionCategory: SWAP_APPROVAL, + transactionCategory: TRANSACTION_CATEGORIES.SWAP_APPROVAL, sourceTokenSymbol: sourceTokenInfo.symbol, }, true, @@ -624,7 +624,7 @@ export const signAndSendTransactions = (history, metaMetricsEvent) => { ...tradeTxMeta, sourceTokenSymbol: sourceTokenInfo.symbol, destinationTokenSymbol: destinationTokenInfo.symbol, - transactionCategory: SWAP, + transactionCategory: TRANSACTION_CATEGORIES.SWAP, destinationTokenDecimals: destinationTokenInfo.decimals, destinationTokenAddress: destinationTokenInfo.address, swapMetaData, diff --git a/ui/app/helpers/constants/transactions.js b/ui/app/helpers/constants/transactions.js index 848938852..e344587ba 100644 --- a/ui/app/helpers/constants/transactions.js +++ b/ui/app/helpers/constants/transactions.js @@ -1,56 +1,21 @@ -export const UNAPPROVED_STATUS = 'unapproved' -export const REJECTED_STATUS = 'rejected' -export const APPROVED_STATUS = 'approved' -export const SIGNED_STATUS = 'signed' -export const SUBMITTED_STATUS = 'submitted' -export const CONFIRMED_STATUS = 'confirmed' -export const FAILED_STATUS = 'failed' -export const DROPPED_STATUS = 'dropped' -export const CANCELLED_STATUS = 'cancelled' +import { + TRANSACTION_CATEGORIES, + TRANSACTION_STATUSES, +} from '../../../../shared/constants/transaction' export const PENDING_STATUS_HASH = { - [UNAPPROVED_STATUS]: true, - [APPROVED_STATUS]: true, - [SUBMITTED_STATUS]: true, + [TRANSACTION_STATUSES.UNAPPROVED]: true, + [TRANSACTION_STATUSES.APPROVED]: true, + [TRANSACTION_STATUSES.SUBMITTED]: true, } export const PRIORITY_STATUS_HASH = { ...PENDING_STATUS_HASH, - [CONFIRMED_STATUS]: true, + [TRANSACTION_STATUSES.CONFIRMED]: true, } -export const TOKEN_METHOD_TRANSFER = 'transfer' -export const TOKEN_METHOD_APPROVE = 'approve' -export const TOKEN_METHOD_TRANSFER_FROM = 'transferfrom' - export const TOKEN_CATEGORY_HASH = { - [TOKEN_METHOD_APPROVE]: true, - [TOKEN_METHOD_TRANSFER]: true, - [TOKEN_METHOD_TRANSFER_FROM]: true, + [TRANSACTION_CATEGORIES.TOKEN_METHOD_APPROVE]: true, + [TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER]: true, + [TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER_FROM]: true, } - -export const SWAP = 'swap' -export const SWAP_APPROVAL = 'swapApproval' - -export const INCOMING_TRANSACTION = 'incoming' - -export const SEND_ETHER_ACTION_KEY = 'sentEther' -export const DEPLOY_CONTRACT_ACTION_KEY = 'contractDeployment' -export const APPROVE_ACTION_KEY = 'approve' -export const SEND_TOKEN_ACTION_KEY = 'sentTokens' -export const TRANSFER_FROM_ACTION_KEY = 'transferFrom' -export const SIGNATURE_REQUEST_KEY = 'signatureRequest' -export const DECRYPT_REQUEST_KEY = 'decryptRequest' -export const ENCRYPTION_PUBLIC_KEY_REQUEST_KEY = 'encryptionPublicKeyRequest' -export const CONTRACT_INTERACTION_KEY = 'contractInteraction' -export const CANCEL_ATTEMPT_ACTION_KEY = 'cancelAttempt' -export const DEPOSIT_TRANSACTION_KEY = 'deposit' - -// Transaction List Item Categories -// Used for UI distinction between transactions in the history list -export const TRANSACTION_CATEGORY_SEND = 'send' -export const TRANSACTION_CATEGORY_RECEIVE = 'receive' -export const TRANSACTION_CATEGORY_INTERACTION = 'interaction' -export const TRANSACTION_CATEGORY_APPROVAL = 'approval' -export const TRANSACTION_CATEGORY_SIGNATURE_REQUEST = 'signature-request' -export const TRANSACTION_CATEGORY_SWAP = 'swap' diff --git a/ui/app/helpers/utils/transactions.util.js b/ui/app/helpers/utils/transactions.util.js index 8cb84396f..78dc49c4e 100644 --- a/ui/app/helpers/utils/transactions.util.js +++ b/ui/app/helpers/utils/transactions.util.js @@ -3,16 +3,12 @@ import MethodRegistry from 'eth-method-registry' import abi from 'human-standard-token-abi' import { ethers } from 'ethers' import log from 'loglevel' -import { - TRANSACTION_TYPE_CANCEL, - TRANSACTION_STATUS_CONFIRMED, -} from '../../../../app/scripts/controllers/transactions/enums' import { getEtherscanNetworkPrefix } from '../../../lib/etherscan-prefix-for-network' import { - TOKEN_METHOD_TRANSFER, - TOKEN_METHOD_APPROVE, - TOKEN_METHOD_TRANSFER_FROM, -} from '../constants/transactions' + TRANSACTION_CATEGORIES, + TRANSACTION_STATUSES, + TRANSACTION_TYPES, +} from '../../../../shared/constants/transaction' import fetchWithCache from './fetch-with-cache' import { addCurrencies } from './conversion-util' @@ -120,9 +116,9 @@ export function getFourBytePrefix(data = '') { */ export function isTokenMethodAction(transactionCategory) { return [ - TOKEN_METHOD_TRANSFER, - TOKEN_METHOD_APPROVE, - TOKEN_METHOD_TRANSFER_FROM, + TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER, + TRANSACTION_CATEGORIES.TOKEN_METHOD_APPROVE, + TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER_FROM, ].includes(transactionCategory) } @@ -184,8 +180,8 @@ export function getStatusKey(transaction) { } if ( - status === TRANSACTION_STATUS_CONFIRMED && - type === TRANSACTION_TYPE_CANCEL + status === TRANSACTION_STATUSES.CONFIRMED && + type === TRANSACTION_TYPES.CANCEL ) { return 'cancelled' } diff --git a/ui/app/hooks/useSwappedTokenValue.js b/ui/app/hooks/useSwappedTokenValue.js index f0fe9fd00..952260c9b 100644 --- a/ui/app/hooks/useSwappedTokenValue.js +++ b/ui/app/hooks/useSwappedTokenValue.js @@ -1,5 +1,5 @@ +import { TRANSACTION_CATEGORIES } from '../../../shared/constants/transaction' import { ETH_SWAPS_TOKEN_ADDRESS } from '../helpers/constants/swaps' -import { SWAP } from '../helpers/constants/transactions' import { getSwapsTokensReceivedFromTxMeta } from '../pages/swaps/swaps.util' import { useTokenFiatAmount } from './useTokenFiatAmount' @@ -12,7 +12,7 @@ import { useTokenFiatAmount } from './useTokenFiatAmount' */ /** - * A SWAP transaction group's primaryTransaction contains details of the swap, + * A Swap transaction group's primaryTransaction contains details of the swap, * including the source (from) and destination (to) token type (ETH, DAI, etc..) * When viewing a non ETH asset page, we need to determine if that asset is the * token that was received (destination) from the swap. In that circumstance we @@ -34,7 +34,8 @@ export function useSwappedTokenValue(transactionGroup, currentAsset) { primaryTransaction.destinationTokenSymbol === 'ETH') const swapTokenValue = - transactionCategory === SWAP && isViewingReceivedTokenFromSwap + transactionCategory === TRANSACTION_CATEGORIES.SWAP && + isViewingReceivedTokenFromSwap ? getSwapsTokensReceivedFromTxMeta( primaryTransaction.destinationTokenSymbol, initialTransaction, @@ -42,7 +43,8 @@ export function useSwappedTokenValue(transactionGroup, currentAsset) { senderAddress, decimals, ) - : transactionCategory === SWAP && primaryTransaction.swapTokenValue + : transactionCategory === TRANSACTION_CATEGORIES.SWAP && + primaryTransaction.swapTokenValue const isNegative = typeof swapTokenValue === 'string' diff --git a/ui/app/hooks/useTransactionDisplayData.js b/ui/app/hooks/useTransactionDisplayData.js index 13f68b40e..c763e8682 100644 --- a/ui/app/hooks/useTransactionDisplayData.js +++ b/ui/app/hooks/useTransactionDisplayData.js @@ -10,26 +10,15 @@ import { stripHttpSchemes, } from '../helpers/utils/util' import { - CONTRACT_INTERACTION_KEY, - DEPLOY_CONTRACT_ACTION_KEY, - INCOMING_TRANSACTION, - TOKEN_METHOD_TRANSFER, - TOKEN_METHOD_TRANSFER_FROM, - SEND_ETHER_ACTION_KEY, - TRANSACTION_CATEGORY_APPROVAL, - TRANSACTION_CATEGORY_INTERACTION, - TRANSACTION_CATEGORY_RECEIVE, - TRANSACTION_CATEGORY_SEND, - TRANSACTION_CATEGORY_SIGNATURE_REQUEST, - TRANSACTION_CATEGORY_SWAP, - TOKEN_METHOD_APPROVE, PENDING_STATUS_HASH, TOKEN_CATEGORY_HASH, - SWAP, - SWAP_APPROVAL, - SUBMITTED_STATUS, } from '../helpers/constants/transactions' import { getTokens } from '../ducks/metamask/metamask' +import { + TRANSACTION_CATEGORIES, + TRANSACTION_GROUP_CATEGORIES, + TRANSACTION_STATUSES, +} from '../../../shared/constants/transaction' import { useI18nContext } from './useI18nContext' import { useTokenFiatAmount } from './useTokenFiatAmount' import { useUserPreferencedCurrency } from './useUserPreferencedCurrency' @@ -82,7 +71,7 @@ export function useTransactionDisplayData(transactionGroup) { const displayedStatusKey = getStatusKey(primaryTransaction) const isPending = displayedStatusKey in PENDING_STATUS_HASH - const isSubmitted = displayedStatusKey === SUBMITTED_STATUS + const isSubmitted = displayedStatusKey === TRANSACTION_STATUSES.SUBMITTED const primaryValue = primaryTransaction.txParams?.value let prefix = '-' @@ -154,12 +143,12 @@ export function useTransactionDisplayData(transactionGroup) { // 7. Swap Approval if (transactionCategory === null || transactionCategory === undefined) { - category = TRANSACTION_CATEGORY_SIGNATURE_REQUEST + category = TRANSACTION_GROUP_CATEGORIES.SIGNATURE_REQUEST title = t('signatureRequest') subtitle = origin subtitleContainsOrigin = true - } else if (transactionCategory === SWAP) { - category = TRANSACTION_CATEGORY_SWAP + } else if (transactionCategory === TRANSACTION_CATEGORIES.SWAP) { + category = TRANSACTION_GROUP_CATEGORIES.SWAP title = t('swapTokenToToken', [ initialTransaction.sourceTokenSymbol, initialTransaction.destinationTokenSymbol, @@ -178,43 +167,45 @@ export function useTransactionDisplayData(transactionGroup) { } else { prefix = '-' } - } else if (transactionCategory === SWAP_APPROVAL) { - category = TRANSACTION_CATEGORY_APPROVAL + } else if (transactionCategory === TRANSACTION_CATEGORIES.SWAP_APPROVAL) { + category = TRANSACTION_GROUP_CATEGORIES.APPROVAL title = t('swapApproval', [primaryTransaction.sourceTokenSymbol]) subtitle = origin subtitleContainsOrigin = true primarySuffix = primaryTransaction.sourceTokenSymbol - } else if (transactionCategory === TOKEN_METHOD_APPROVE) { - category = TRANSACTION_CATEGORY_APPROVAL + } else if ( + transactionCategory === TRANSACTION_CATEGORIES.TOKEN_METHOD_APPROVE + ) { + category = TRANSACTION_GROUP_CATEGORIES.APPROVAL prefix = '' title = t('approveSpendLimit', [token?.symbol || t('token')]) subtitle = origin subtitleContainsOrigin = true } else if ( - transactionCategory === DEPLOY_CONTRACT_ACTION_KEY || - transactionCategory === CONTRACT_INTERACTION_KEY + transactionCategory === TRANSACTION_CATEGORIES.DEPLOY_CONTRACT || + transactionCategory === TRANSACTION_CATEGORIES.CONTRACT_INTERACTION ) { - category = TRANSACTION_CATEGORY_INTERACTION + category = TRANSACTION_GROUP_CATEGORIES.INTERACTION title = (methodData?.name && camelCaseToCapitalize(methodData.name)) || t(transactionCategory) subtitle = origin subtitleContainsOrigin = true - } else if (transactionCategory === INCOMING_TRANSACTION) { - category = TRANSACTION_CATEGORY_RECEIVE + } else if (transactionCategory === TRANSACTION_CATEGORIES.INCOMING) { + category = TRANSACTION_GROUP_CATEGORIES.RECEIVE title = t('receive') prefix = '' subtitle = t('fromAddress', [shortenAddress(senderAddress)]) } else if ( - transactionCategory === TOKEN_METHOD_TRANSFER_FROM || - transactionCategory === TOKEN_METHOD_TRANSFER + transactionCategory === TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER_FROM || + transactionCategory === TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER ) { - category = TRANSACTION_CATEGORY_SEND + category = TRANSACTION_GROUP_CATEGORIES.SEND title = t('sendSpecifiedTokens', [token?.symbol || t('token')]) recipientAddress = getTokenAddressParam(tokenData) subtitle = t('toAddress', [shortenAddress(recipientAddress)]) - } else if (transactionCategory === SEND_ETHER_ACTION_KEY) { - category = TRANSACTION_CATEGORY_SEND + } else if (transactionCategory === TRANSACTION_CATEGORIES.SENT_ETHER) { + category = TRANSACTION_GROUP_CATEGORIES.SEND title = t('sendETH') subtitle = t('toAddress', [shortenAddress(recipientAddress)]) } @@ -243,12 +234,15 @@ export function useTransactionDisplayData(transactionGroup) { subtitle, subtitleContainsOrigin, primaryCurrency: - transactionCategory === SWAP && isPending ? '' : primaryCurrency, + transactionCategory === TRANSACTION_CATEGORIES.SWAP && isPending + ? '' + : primaryCurrency, senderAddress, recipientAddress, secondaryCurrency: (isTokenCategory && !tokenFiatAmount) || - (transactionCategory === SWAP && !swapTokenFiatAmount) + (transactionCategory === TRANSACTION_CATEGORIES.SWAP && + !swapTokenFiatAmount) ? undefined : secondaryCurrency, displayedStatusKey, diff --git a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js index 614b5d254..122ef7842 100644 --- a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -13,15 +13,12 @@ import { TRANSACTION_ERROR_KEY, GAS_LIMIT_TOO_LOW_ERROR_KEY, } from '../../helpers/constants/error-keys' -import { - CONFIRMED_STATUS, - DROPPED_STATUS, -} from '../../helpers/constants/transactions' import UserPreferencedCurrencyDisplay from '../../components/app/user-preferenced-currency-display' import { PRIMARY, SECONDARY } from '../../helpers/constants/common' import { hexToDecimal } from '../../helpers/utils/conversions.util' import AdvancedGasInputs from '../../components/app/gas-customization/advanced-gas-inputs' import TextField from '../../components/ui/text-field' +import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction' export default class ConfirmTransactionBase extends Component { static contextTypes = { @@ -134,8 +131,8 @@ export default class ConfirmTransactionBase extends Component { } = prevProps const statusUpdated = transactionStatus !== prevTxStatus const txDroppedOrConfirmed = - transactionStatus === DROPPED_STATUS || - transactionStatus === CONFIRMED_STATUS + transactionStatus === TRANSACTION_STATUSES.DROPPED || + transactionStatus === TRANSACTION_STATUSES.CONFIRMED if ( nextNonce !== prevNextNonce || diff --git a/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.component.js b/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.component.js index 7c35c463e..88dd10084 100644 --- a/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.component.js +++ b/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.component.js @@ -14,14 +14,8 @@ import { DECRYPT_MESSAGE_REQUEST_PATH, ENCRYPTION_PUBLIC_KEY_REQUEST_PATH, } from '../../helpers/constants/routes' -import { - TOKEN_METHOD_TRANSFER, - TOKEN_METHOD_APPROVE, - TOKEN_METHOD_TRANSFER_FROM, - DEPLOY_CONTRACT_ACTION_KEY, - SEND_ETHER_ACTION_KEY, -} from '../../helpers/constants/transactions' import { MESSAGE_TYPE } from '../../../../app/scripts/lib/enums' +import { TRANSACTION_CATEGORIES } from '../../../../shared/constants/transaction' export default class ConfirmTransactionSwitch extends Component { static propTypes = { @@ -32,27 +26,27 @@ export default class ConfirmTransactionSwitch extends Component { const { txData } = this.props const { id, txParams: { data } = {}, transactionCategory } = txData - if (transactionCategory === DEPLOY_CONTRACT_ACTION_KEY) { + if (transactionCategory === TRANSACTION_CATEGORIES.DEPLOY_CONTRACT) { const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_DEPLOY_CONTRACT_PATH}` return } - if (transactionCategory === SEND_ETHER_ACTION_KEY) { + if (transactionCategory === TRANSACTION_CATEGORIES.SENT_ETHER) { const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_SEND_ETHER_PATH}` return } if (data) { switch (transactionCategory) { - case TOKEN_METHOD_TRANSFER: { + case TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER: { const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_SEND_TOKEN_PATH}` return } - case TOKEN_METHOD_APPROVE: { + case TRANSACTION_CATEGORIES.TOKEN_METHOD_APPROVE: { const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_APPROVE_PATH}` return } - case TOKEN_METHOD_TRANSFER_FROM: { + case TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER_FROM: { const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_TRANSFER_FROM_PATH}` return } diff --git a/ui/app/pages/swaps/awaiting-swap/awaiting-swap.js b/ui/app/pages/swaps/awaiting-swap/awaiting-swap.js index 75af8b56a..dfd00d22b 100644 --- a/ui/app/pages/swaps/awaiting-swap/awaiting-swap.js +++ b/ui/app/pages/swaps/awaiting-swap/awaiting-swap.js @@ -34,11 +34,11 @@ import { QUOTES_NOT_AVAILABLE_ERROR, OFFLINE_FOR_MAINTENANCE, } from '../../../helpers/constants/swaps' -import { SUBMITTED_STATUS } from '../../../helpers/constants/transactions' import { ASSET_ROUTE, DEFAULT_ROUTE } from '../../../helpers/constants/routes' import { getRenderableNetworkFeesForQuote } from '../swaps.util' import SwapsFooter from '../swaps-footer' +import { TRANSACTION_STATUSES } from '../../../../../shared/constants/transaction' import SwapFailureIcon from './swap-failure-icon' import SwapSuccessIcon from './swap-success-icon' import QuotesTimeoutIcon from './quotes-timeout-icon' @@ -115,7 +115,7 @@ export default function AwaitingSwap({ const statusKey = tradeTxData && getStatusKey(tradeTxData) const timeRemaining = useTransactionTimeRemaining( - statusKey === SUBMITTED_STATUS, + statusKey === TRANSACTION_STATUSES.SUBMITTED, true, tradeTxData?.submittedTime, usedGasPrice, diff --git a/ui/app/selectors/transactions.js b/ui/app/selectors/transactions.js index f54076e65..7fe00b3e1 100644 --- a/ui/app/selectors/transactions.js +++ b/ui/app/selectors/transactions.js @@ -1,17 +1,14 @@ import { createSelector } from 'reselect' import { - SUBMITTED_STATUS, - CONFIRMED_STATUS, - FAILED_STATUS, PRIORITY_STATUS_HASH, PENDING_STATUS_HASH, } from '../helpers/constants/transactions' -import { - TRANSACTION_TYPE_CANCEL, - TRANSACTION_TYPE_RETRY, -} from '../../../app/scripts/controllers/transactions/enums' import { hexToDecimal } from '../helpers/utils/conversions.util' import txHelper from '../../lib/tx-helper' +import { + TRANSACTION_STATUSES, + TRANSACTION_TYPES, +} from '../../../shared/constants/transaction' import { getSelectedAddress } from '.' export const incomingTxListSelector = (state) => { @@ -252,13 +249,14 @@ export const nonceSortedTransactionsSelector = createSelector( } = nonceProps const previousPrimaryIsNetworkFailure = - nonceProps.primaryTransaction.status === FAILED_STATUS && + nonceProps.primaryTransaction.status === + TRANSACTION_STATUSES.FAILED && nonceProps.primaryTransaction?.txReceipt?.status !== '0x0' const currentTransactionIsOnChainFailure = transaction?.txReceipt?.status === '0x0' if ( - status === CONFIRMED_STATUS || + status === TRANSACTION_STATUSES.CONFIRMED || currentTransactionIsOnChainFailure || previousPrimaryIsNetworkFailure || (txTime > primaryTxTime && status in PRIORITY_STATUS_HASH) @@ -276,11 +274,11 @@ export const nonceSortedTransactionsSelector = createSelector( nonceProps.initialTransaction = transaction } - if (type === TRANSACTION_TYPE_RETRY) { + if (type === TRANSACTION_TYPES.RETRY) { nonceProps.hasRetried = true } - if (type === TRANSACTION_TYPE_CANCEL) { + if (type === TRANSACTION_TYPES.CANCEL) { nonceProps.hasCancelled = true } } else { @@ -289,8 +287,8 @@ export const nonceSortedTransactionsSelector = createSelector( transactions: [transaction], initialTransaction: transaction, primaryTransaction: transaction, - hasRetried: transaction.type === TRANSACTION_TYPE_RETRY, - hasCancelled: transaction.type === TRANSACTION_TYPE_CANCEL, + hasRetried: transaction.type === TRANSACTION_TYPES.RETRY, + hasCancelled: transaction.type === TRANSACTION_TYPES.CANCEL, } insertOrderedNonce(orderedNonces, nonce) @@ -344,6 +342,6 @@ export const submittedPendingTransactionsSelector = createSelector( transactionsSelector, (transactions = []) => transactions.filter( - (transaction) => transaction.status === SUBMITTED_STATUS, + (transaction) => transaction.status === TRANSACTION_STATUSES.SUBMITTED, ), )