From 5b8c07817a68e4b27ce6a8364a227f2b96188ea5 Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Mon, 12 Oct 2020 12:05:40 -0700 Subject: [PATCH] Remove localhost provider type (#9551) * Delete localhost provider type * Use ganache-cli default chain ID for tests * Delete unused test firstTimeState variable * Migrate default ganache-cli network to frequentRpcListDetail * Add default test provider state * Add test functionality to createJsonRpcClient * Lint locales * Update test middleware creation * fixup! Update test middleware creation --- 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 | 3 - 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/hu/messages.json | 3 - app/_locales/id/messages.json | 3 - app/_locales/it/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/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/uk/messages.json | 3 - app/_locales/zh_CN/messages.json | 3 - app/_locales/zh_TW/messages.json | 3 - app/scripts/background.js | 3 +- .../network/createJsonRpcClient.js | 31 +++++++- .../network/createLocalhostClient.js | 36 --------- app/scripts/controllers/network/enums.js | 1 - app/scripts/controllers/network/network.js | 34 +++----- app/scripts/controllers/preferences.js | 5 +- app/scripts/first-time-state.js | 11 +++ app/scripts/migrations/048.js | 21 ++++- development/run-ganache | 2 +- test/e2e/ethereum-on.spec.js | 2 +- test/e2e/fixtures/imported-account/state.json | 10 +-- test/e2e/fixtures/localization/state.json | 10 +-- test/e2e/fixtures/personal-sign/state.json | 12 +-- test/e2e/ganache.js | 2 +- .../controllers/metamask-controller-test.js | 6 +- .../preferences-controller-test.js | 23 +++++- test/unit/localhostState.js | 1 + test/unit/migrations/048-test.js | 78 +++++++++++++++++-- .../app/dropdowns/network-dropdown.js | 29 ------- .../dropdowns/tests/network-dropdown.test.js | 11 +-- .../loading-network-screen.component.js | 2 - ui/app/components/app/network.js | 6 +- ui/app/helpers/utils/util.js | 2 +- ui/app/pages/routes/routes.component.js | 4 - .../networks-tab/networks-tab.constants.js | 9 --- 65 files changed, 195 insertions(+), 276 deletions(-) delete mode 100644 app/scripts/controllers/network/createLocalhostClient.js diff --git a/app/_locales/am/messages.json b/app/_locales/am/messages.json index 6e3ce50ea..12af3e796 100644 --- a/app/_locales/am/messages.json +++ b/app/_locales/am/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "ከ Kovan የሙከራ አውታረ መረብ መገናኘት" }, - "connectingToLocalhost": { - "message": "ከ Localhost 8545 ጋር መገናኘት" - }, "connectingToMainnet": { "message": "ከዋናው የ Ethereum አውታረ መረብ ጋር መገናኘት" }, diff --git a/app/_locales/ar/messages.json b/app/_locales/ar/messages.json index 62265d304..8d5806599 100644 --- a/app/_locales/ar/messages.json +++ b/app/_locales/ar/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "الاتصال بشبكة اختبار Kovan" }, - "connectingToLocalhost": { - "message": "جاري الاتصال بالمضيف المحلي 8545" - }, "connectingToMainnet": { "message": "جارِ الاتصال بشبكة إيثيريوم الرئيسية" }, diff --git a/app/_locales/bg/messages.json b/app/_locales/bg/messages.json index 74726c04c..70dcf4e41 100644 --- a/app/_locales/bg/messages.json +++ b/app/_locales/bg/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Свързване с тестовата мрежа на Kovan" }, - "connectingToLocalhost": { - "message": "Свързване с Localhost 8545" - }, "connectingToMainnet": { "message": "Свързване с главната мрежа Ethereum" }, diff --git a/app/_locales/bn/messages.json b/app/_locales/bn/messages.json index 3d707a5cd..63ce2ed82 100644 --- a/app/_locales/bn/messages.json +++ b/app/_locales/bn/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "কোভান টেস্ট নেটওয়ার্কের সাথে সংযোগ করছে" }, - "connectingToLocalhost": { - "message": "লোকালহোস্ট 8545 এর সাথে সংযোগ করছে" - }, "connectingToMainnet": { "message": "মুখ্য Ethereum নেটওয়ার্কের সাথে সংযোগ করছে" }, diff --git a/app/_locales/ca/messages.json b/app/_locales/ca/messages.json index db93525a0..759264ec0 100644 --- a/app/_locales/ca/messages.json +++ b/app/_locales/ca/messages.json @@ -215,9 +215,6 @@ "connectingToKovan": { "message": "Conectant a la xarxa de Kovan Test" }, - "connectingToLocalhost": { - "message": "Connectant al host local 8545" - }, "connectingToMainnet": { "message": "Connectant a Xarxa Principal Ethereum" }, diff --git a/app/_locales/da/messages.json b/app/_locales/da/messages.json index d302792b3..449946a69 100644 --- a/app/_locales/da/messages.json +++ b/app/_locales/da/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Forbinder til Kovan Testnetværk" }, - "connectingToLocalhost": { - "message": "Opretter forbindelse til Localhost 8545" - }, "connectingToMainnet": { "message": "Forbinder til dit Primære Ethereum Netværk" }, diff --git a/app/_locales/de/messages.json b/app/_locales/de/messages.json index 1fae46b7b..7b7da3c43 100644 --- a/app/_locales/de/messages.json +++ b/app/_locales/de/messages.json @@ -209,9 +209,6 @@ "connectingToKovan": { "message": " Verbinde zum Kovan Testnetzwerk" }, - "connectingToLocalhost": { - "message": "Verbindung mit Localhost 8545 herstellen" - }, "connectingToMainnet": { "message": "Verbinde zum Ethereum Main Net" }, diff --git a/app/_locales/el/messages.json b/app/_locales/el/messages.json index 814fc3aa2..4ba30a80e 100644 --- a/app/_locales/el/messages.json +++ b/app/_locales/el/messages.json @@ -215,9 +215,6 @@ "connectingToKovan": { "message": "Σύνδεση στο Δοκιμαστικό Δίκτυο Kovan" }, - "connectingToLocalhost": { - "message": "Σύνδεση στον Τοπικό Υπολογιστή 8545" - }, "connectingToMainnet": { "message": "Σύνδεση στο Κύριο Δίκτυο Ethereum" }, diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index b098e984e..e7439db82 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -340,9 +340,6 @@ "connectingToKovan": { "message": "Connecting to Kovan Test Network" }, - "connectingToLocalhost": { - "message": "Connecting to Localhost 8545" - }, "connectingToMainnet": { "message": "Connecting to Ethereum Mainnet" }, diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index 2fa65546c..ea36e9b50 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -187,9 +187,6 @@ "connectingToKovan": { "message": "Conectando a la red de test Kovan" }, - "connectingToLocalhost": { - "message": "Conectando to Localhost 8545" - }, "connectingToMainnet": { "message": "Conectando a la red principal de Ethereum (Main Net)" }, diff --git a/app/_locales/es_419/messages.json b/app/_locales/es_419/messages.json index 26385e8bb..1efcd3d5c 100644 --- a/app/_locales/es_419/messages.json +++ b/app/_locales/es_419/messages.json @@ -215,9 +215,6 @@ "connectingToKovan": { "message": "Conexión con la red de prueba Kovan" }, - "connectingToLocalhost": { - "message": "Conexión con Localhost 8545" - }, "connectingToMainnet": { "message": "Conexión con la red principal de Ethereum" }, diff --git a/app/_locales/et/messages.json b/app/_locales/et/messages.json index d1ca0bb40..79b42b84c 100644 --- a/app/_locales/et/messages.json +++ b/app/_locales/et/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Ühendamine Kovani testvõrguga" }, - "connectingToLocalhost": { - "message": "Ühenduse loomine Localhost 8545" - }, "connectingToMainnet": { "message": "Ühenduse loomine peamise Etherumi võrguga" }, diff --git a/app/_locales/fa/messages.json b/app/_locales/fa/messages.json index 531c20a69..b6ca24ad5 100644 --- a/app/_locales/fa/messages.json +++ b/app/_locales/fa/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "در حال اتصال به شبکه آزمایشی Kovan" }, - "connectingToLocalhost": { - "message": "در حال اتصال با Localhost 8545" - }, "connectingToMainnet": { "message": "در حال اتصال به شبکه اصلی ایتریم" }, diff --git a/app/_locales/fi/messages.json b/app/_locales/fi/messages.json index 88856e1ce..0e17618db 100644 --- a/app/_locales/fi/messages.json +++ b/app/_locales/fi/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Yhdistetään Kovanin koeverkkoon" }, - "connectingToLocalhost": { - "message": "Yhdistetään kohteeseen Localhost 8545" - }, "connectingToMainnet": { "message": "Yhdistetään Ethereumin pääverkkoon" }, diff --git a/app/_locales/fil/messages.json b/app/_locales/fil/messages.json index 69231c629..445083185 100644 --- a/app/_locales/fil/messages.json +++ b/app/_locales/fil/messages.json @@ -197,9 +197,6 @@ "connectingToKovan": { "message": "Kumokonekta sa Kovan Test Network" }, - "connectingToLocalhost": { - "message": "Kumokonekta sa Localhost 8545" - }, "connectingToMainnet": { "message": "Kumokonekta sa Ethereum Mainnet" }, diff --git a/app/_locales/fr/messages.json b/app/_locales/fr/messages.json index af0b261c7..78cdb5e2f 100644 --- a/app/_locales/fr/messages.json +++ b/app/_locales/fr/messages.json @@ -209,9 +209,6 @@ "connectingToKovan": { "message": "Connexion au réseau de test Kovan" }, - "connectingToLocalhost": { - "message": "Connexion à Localhost 8545" - }, "connectingToMainnet": { "message": "Connexion au réseau principal Ethereum" }, diff --git a/app/_locales/he/messages.json b/app/_locales/he/messages.json index 2053b8e02..8c10e4dad 100644 --- a/app/_locales/he/messages.json +++ b/app/_locales/he/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "מתחבר ל-Kovan Test Network" }, - "connectingToLocalhost": { - "message": "מתחבר אל Localhost 8545" - }, "connectingToMainnet": { "message": "מתחבר לרשת אתריום הראשית" }, diff --git a/app/_locales/hi/messages.json b/app/_locales/hi/messages.json index d06bd221a..d189f6110 100644 --- a/app/_locales/hi/messages.json +++ b/app/_locales/hi/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "कोवन टेस्ट नेटवर्क से जोड़ रहा है\n" }, - "connectingToLocalhost": { - "message": "लोकलहोस्ट 8545 से जुड़ना " - }, "connectingToMainnet": { "message": "मुख्य Ethereum नेटवर्क से कनेक्ट हो रहा है" }, diff --git a/app/_locales/hr/messages.json b/app/_locales/hr/messages.json index 0a1e3ad11..227c154d7 100644 --- a/app/_locales/hr/messages.json +++ b/app/_locales/hr/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Povezivanje na testnu mrežu Kovan" }, - "connectingToLocalhost": { - "message": "Povezivanje na Localhost 8545" - }, "connectingToMainnet": { "message": "Povezivanje na glavnu mrežu Ethereum" }, diff --git a/app/_locales/hu/messages.json b/app/_locales/hu/messages.json index 3fb33ca1a..97f63d74e 100644 --- a/app/_locales/hu/messages.json +++ b/app/_locales/hu/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Csatlakozás a Kovan teszthálózathoz" }, - "connectingToLocalhost": { - "message": "Csatlakozás a Localhost 8645-höz" - }, "connectingToMainnet": { "message": "Csatlakozás a fő Ethereum hálózathoz" }, diff --git a/app/_locales/id/messages.json b/app/_locales/id/messages.json index 01093748b..1fcd8f960 100644 --- a/app/_locales/id/messages.json +++ b/app/_locales/id/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Menyambung ke Jaringan Tes Kovan" }, - "connectingToLocalhost": { - "message": "Menghubungkan ke Localhost 8545" - }, "connectingToMainnet": { "message": "Menghubungkan ke Jaringan Ethereum Utama" }, diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json index e680d8dc6..f9400429c 100644 --- a/app/_locales/it/messages.json +++ b/app/_locales/it/messages.json @@ -333,9 +333,6 @@ "connectingToKovan": { "message": "Connessione alla Rete di test Kovan" }, - "connectingToLocalhost": { - "message": "Connessione a Localhost 8545" - }, "connectingToMainnet": { "message": "Connessione alla Rete Ethereum Principale" }, diff --git a/app/_locales/kn/messages.json b/app/_locales/kn/messages.json index 49528ad64..1d92260b9 100644 --- a/app/_locales/kn/messages.json +++ b/app/_locales/kn/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Kovan ಪರೀಕ್ಷಾ ನೆಟ್‌ವರ್ಕ್‌ಗೆ ಸಂಪರ್ಕಿಸಲಾಗುತ್ತಿದೆ " }, - "connectingToLocalhost": { - "message": "ಲೋಕಲ್‌ಹೋಸ್ಟ್ 8545 ಗೆ ಸಂಪರ್ಕಿಸಲಾಗುತ್ತಿದೆ" - }, "connectingToMainnet": { "message": "ಮುಖ್ಯ ಎಥೆರಿಯಮ್ ನೆಟ್‌ವರ್ಕ್‌ಗೆ ಸಂಪರ್ಕಿಸಲಾಗುತ್ತಿದೆ" }, diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json index d5951a9bc..decd5fecd 100644 --- a/app/_locales/ko/messages.json +++ b/app/_locales/ko/messages.json @@ -215,9 +215,6 @@ "connectingToKovan": { "message": "Kovan 테스트넷 접속 중" }, - "connectingToLocalhost": { - "message": "로컬호스트 8545에 연결 중" - }, "connectingToMainnet": { "message": "이더리움 메인넷 접속 중" }, diff --git a/app/_locales/lt/messages.json b/app/_locales/lt/messages.json index 74a5e63b5..b88fc2c67 100644 --- a/app/_locales/lt/messages.json +++ b/app/_locales/lt/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Jungiamasi prie „Kovan“ bandomojo tinklo" }, - "connectingToLocalhost": { - "message": "Jungiamasi prie vietinio serverio 8545" - }, "connectingToMainnet": { "message": "Jungiamasi prie pagrindinio „Ethereum“ tinklo" }, diff --git a/app/_locales/lv/messages.json b/app/_locales/lv/messages.json index 00203e505..40fb55edf 100644 --- a/app/_locales/lv/messages.json +++ b/app/_locales/lv/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Savienojas ar Kovan testa tīklu" }, - "connectingToLocalhost": { - "message": "Savienojas ar vietējo resursdatoru 8545" - }, "connectingToMainnet": { "message": "Savienojas ar galveno Ethereum tīklu" }, diff --git a/app/_locales/ms/messages.json b/app/_locales/ms/messages.json index 90cae7f84..425e9eb20 100644 --- a/app/_locales/ms/messages.json +++ b/app/_locales/ms/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Menyambungkan kepada Rangkaian Ujian Kovan" }, - "connectingToLocalhost": { - "message": "Menyambung kepada Localhost 8545" - }, "connectingToMainnet": { "message": "Menyambung kepada Rangkaian Ethereum Utama" }, diff --git a/app/_locales/no/messages.json b/app/_locales/no/messages.json index 525400738..ab94ce321 100644 --- a/app/_locales/no/messages.json +++ b/app/_locales/no/messages.json @@ -215,9 +215,6 @@ "connectingToKovan": { "message": "Kobler til Kovan testnettverk" }, - "connectingToLocalhost": { - "message": "Kobler til lokalvert 8545" - }, "connectingToMainnet": { "message": "Forbinder med hoved-Ethereumnettverk " }, diff --git a/app/_locales/pl/messages.json b/app/_locales/pl/messages.json index a818347a4..157bfb7d0 100644 --- a/app/_locales/pl/messages.json +++ b/app/_locales/pl/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Łączenie z siecią testową Kovan" }, - "connectingToLocalhost": { - "message": "Połączono z serwerem lokalnym 8545" - }, "connectingToMainnet": { "message": "Łączenie z główną siecią Ethereum" }, diff --git a/app/_locales/pt_BR/messages.json b/app/_locales/pt_BR/messages.json index e1ca071f0..68eda6f73 100644 --- a/app/_locales/pt_BR/messages.json +++ b/app/_locales/pt_BR/messages.json @@ -212,9 +212,6 @@ "connectingToKovan": { "message": "Conectando-se à Rede de Testes Kovan" }, - "connectingToLocalhost": { - "message": "Conectando ao Localhost 8545" - }, "connectingToMainnet": { "message": "Conectando à rede principal Etherum" }, diff --git a/app/_locales/ro/messages.json b/app/_locales/ro/messages.json index a6bb34162..bdcfc126f 100644 --- a/app/_locales/ro/messages.json +++ b/app/_locales/ro/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Se conectează la rețeaua de test Kovan" }, - "connectingToLocalhost": { - "message": "Se conectează la localhost 8545" - }, "connectingToMainnet": { "message": "Se conectează la rețeaua Ethereum principală" }, diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json index 8c4ef56f7..1ef3ac602 100644 --- a/app/_locales/ru/messages.json +++ b/app/_locales/ru/messages.json @@ -217,9 +217,6 @@ "connectingToKovan": { "message": "Соединение с тестовой сетью Kovan" }, - "connectingToLocalhost": { - "message": "Подключение к Localhost:8545" - }, "connectingToMainnet": { "message": "Соединение с основной сетью Ethereum" }, diff --git a/app/_locales/sk/messages.json b/app/_locales/sk/messages.json index d84d5f585..1b0ba15c9 100644 --- a/app/_locales/sk/messages.json +++ b/app/_locales/sk/messages.json @@ -212,9 +212,6 @@ "connectingToKovan": { "message": "Připojuji se k Kovan Test Network" }, - "connectingToLocalhost": { - "message": "Pripája sa k Localhost 8545" - }, "connectingToMainnet": { "message": "Připojuji se k Ethereum Mainnet" }, diff --git a/app/_locales/sl/messages.json b/app/_locales/sl/messages.json index eecd18a99..b49ab7fec 100644 --- a/app/_locales/sl/messages.json +++ b/app/_locales/sl/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Povezovanje na testno omrežje Kovan" }, - "connectingToLocalhost": { - "message": "Povezovanje na lokalnega gostitelja 8545 " - }, "connectingToMainnet": { "message": "Povezovanje na glavno omrežje" }, diff --git a/app/_locales/sr/messages.json b/app/_locales/sr/messages.json index 61fa3c4c0..d72f4007e 100644 --- a/app/_locales/sr/messages.json +++ b/app/_locales/sr/messages.json @@ -215,9 +215,6 @@ "connectingToKovan": { "message": "Povezuje se na test mrežu Kovan" }, - "connectingToLocalhost": { - "message": "Povezuje se na lokalnog hosta 8545" - }, "connectingToMainnet": { "message": "Povezuje se na glavnu Ethereum mrežu" }, diff --git a/app/_locales/sv/messages.json b/app/_locales/sv/messages.json index 74d4c45b8..6c6b68622 100644 --- a/app/_locales/sv/messages.json +++ b/app/_locales/sv/messages.json @@ -212,9 +212,6 @@ "connectingToKovan": { "message": "Ansluter till Kovans testnätverk" }, - "connectingToLocalhost": { - "message": "Ansluter till Localhost 8545" - }, "connectingToMainnet": { "message": "Koppla till Ethereums huvudnätverk" }, diff --git a/app/_locales/sw/messages.json b/app/_locales/sw/messages.json index bdecd20e2..5662950c6 100644 --- a/app/_locales/sw/messages.json +++ b/app/_locales/sw/messages.json @@ -212,9 +212,6 @@ "connectingToKovan": { "message": "Inaunganisha kwenye Mtandao wa Majaribio wa Kovan" }, - "connectingToLocalhost": { - "message": "Inaunganisha kwenye Localhost 8545" - }, "connectingToMainnet": { "message": "Inaunganisha kwenye Mtandao Mkuu wa Ethereum" }, diff --git a/app/_locales/uk/messages.json b/app/_locales/uk/messages.json index a522ba4aa..c314c5c31 100644 --- a/app/_locales/uk/messages.json +++ b/app/_locales/uk/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "Підключення до тестової мережі Kovan" }, - "connectingToLocalhost": { - "message": "Під'єднуємось до локального хосту 8545" - }, "connectingToMainnet": { "message": "З'єднуємось з Головною мережею Ethereum" }, diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json index 5b0bab744..454e1d7cf 100644 --- a/app/_locales/zh_CN/messages.json +++ b/app/_locales/zh_CN/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "正在连接到Kovan测试网络" }, - "connectingToLocalhost": { - "message": "正在连接 Localhost 8545" - }, "connectingToMainnet": { "message": "正在连接到以太坊主网" }, diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json index 383fbb991..dcbd8aab0 100644 --- a/app/_locales/zh_TW/messages.json +++ b/app/_locales/zh_TW/messages.json @@ -218,9 +218,6 @@ "connectingToKovan": { "message": "連線到 Kovan 測試網路" }, - "connectingToLocalhost": { - "message": "連接至本地主機 8545" - }, "connectingToMainnet": { "message": "連線到主 Ethereum 網路" }, diff --git a/app/scripts/background.js b/app/scripts/background.js index b6fdfaf5d..32aaec4af 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -41,8 +41,7 @@ import { } from './lib/enums' /* eslint-enable import/first */ -// METAMASK_TEST_CONFIG is used in e2e tests to set the default network to localhost -const firstTimeState = { ...rawFirstTimeState, ...global.METAMASK_TEST_CONFIG } +const firstTimeState = { ...rawFirstTimeState } log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn') diff --git a/app/scripts/controllers/network/createJsonRpcClient.js b/app/scripts/controllers/network/createJsonRpcClient.js index c161b0a8c..823a34d49 100644 --- a/app/scripts/controllers/network/createJsonRpcClient.js +++ b/app/scripts/controllers/network/createJsonRpcClient.js @@ -1,3 +1,4 @@ +import createAsyncMiddleware from 'json-rpc-engine/src/createAsyncMiddleware' import mergeMiddleware from 'json-rpc-engine/src/mergeMiddleware' import createFetchMiddleware from 'eth-json-rpc-middleware/fetch' import createBlockRefRewriteMiddleware from 'eth-json-rpc-middleware/block-ref-rewrite' @@ -7,12 +8,26 @@ import createBlockTrackerInspectorMiddleware from 'eth-json-rpc-middleware/block import providerFromMiddleware from 'eth-json-rpc-middleware/providerFromMiddleware' import BlockTracker from 'eth-block-tracker' +const inTest = process.env.IN_TEST === 'true' +const blockTrackerOpts = inTest + ? { pollingInterval: 1000 } + : {} +const getTestMiddlewares = () => { + return inTest + ? [createEstimateGasDelayTestMiddleware()] + : [] +} + export default function createJsonRpcClient ({ rpcUrl, chainId }) { const fetchMiddleware = createFetchMiddleware({ rpcUrl }) const blockProvider = providerFromMiddleware(fetchMiddleware) - const blockTracker = new BlockTracker({ provider: blockProvider }) + const blockTracker = new BlockTracker({ + ...blockTrackerOpts, + provider: blockProvider, + }) const networkMiddleware = mergeMiddleware([ + ...getTestMiddlewares(), createChainIdMiddleware(chainId), createBlockRefRewriteMiddleware({ blockTracker }), createBlockCacheMiddleware({ blockTracker }), @@ -20,6 +35,7 @@ export default function createJsonRpcClient ({ rpcUrl, chainId }) { createBlockTrackerInspectorMiddleware({ blockTracker }), fetchMiddleware, ]) + return { networkMiddleware, blockTracker } } @@ -32,3 +48,16 @@ function createChainIdMiddleware (chainId) { return next() } } + +/** + * For use in tests only. + * Adds a delay to `eth_estimateGas` calls. + */ +function createEstimateGasDelayTestMiddleware () { + return createAsyncMiddleware(async (req, _, next) => { + if (req.method === 'eth_estimateGas') { + await new Promise((resolve) => setTimeout(resolve, 2000)) + } + return next() + }) +} diff --git a/app/scripts/controllers/network/createLocalhostClient.js b/app/scripts/controllers/network/createLocalhostClient.js deleted file mode 100644 index efd19801c..000000000 --- a/app/scripts/controllers/network/createLocalhostClient.js +++ /dev/null @@ -1,36 +0,0 @@ -import mergeMiddleware from 'json-rpc-engine/src/mergeMiddleware' -import createFetchMiddleware from 'eth-json-rpc-middleware/fetch' -import createBlockRefRewriteMiddleware from 'eth-json-rpc-middleware/block-ref-rewrite' -import createBlockTrackerInspectorMiddleware from 'eth-json-rpc-middleware/block-tracker-inspector' -import createAsyncMiddleware from 'json-rpc-engine/src/createAsyncMiddleware' -import providerFromMiddleware from 'eth-json-rpc-middleware/providerFromMiddleware' -import BlockTracker from 'eth-block-tracker' - -const inTest = process.env.IN_TEST === 'true' - -export default function createLocalhostClient () { - const fetchMiddleware = createFetchMiddleware({ rpcUrl: 'http://localhost:8545/' }) - const blockProvider = providerFromMiddleware(fetchMiddleware) - const blockTracker = new BlockTracker({ provider: blockProvider, pollingInterval: 1000 }) - - const networkMiddleware = mergeMiddleware([ - createEstimateGasMiddleware(), - createBlockRefRewriteMiddleware({ blockTracker }), - createBlockTrackerInspectorMiddleware({ blockTracker }), - fetchMiddleware, - ]) - return { networkMiddleware, blockTracker } -} - -function delay (time) { - return new Promise((resolve) => setTimeout(resolve, time)) -} - -function createEstimateGasMiddleware () { - return createAsyncMiddleware(async (req, _, next) => { - if (req.method === 'eth_estimateGas' && inTest) { - await delay(2000) - } - return next() - }) -} diff --git a/app/scripts/controllers/network/enums.js b/app/scripts/controllers/network/enums.js index 03658eab3..85adf3b45 100644 --- a/app/scripts/controllers/network/enums.js +++ b/app/scripts/controllers/network/enums.js @@ -3,7 +3,6 @@ export const RINKEBY = 'rinkeby' export const KOVAN = 'kovan' export const MAINNET = 'mainnet' export const GOERLI = 'goerli' -export const LOCALHOST = 'localhost' export const MAINNET_NETWORK_ID = '1' export const ROPSTEN_NETWORK_ID = '3' diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index aee7ba4c4..45e5da2ec 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -10,36 +10,33 @@ import EthQuery from 'eth-query' import createMetamaskMiddleware from './createMetamaskMiddleware' import createInfuraClient from './createInfuraClient' import createJsonRpcClient from './createJsonRpcClient' -import createLocalhostClient from './createLocalhostClient' import { RINKEBY, MAINNET, - LOCALHOST, INFURA_PROVIDER_TYPES, NETWORK_TYPE_TO_ID_MAP, } from './enums' const env = process.env.METAMASK_ENV -let defaultProviderConfigType -let defaultProviderChainId +let defaultProviderConfigOpts if (process.env.IN_TEST === 'true') { - defaultProviderConfigType = LOCALHOST - // Decimal 5777, an arbitrary chain ID we use for testing - defaultProviderChainId = '0x1691' + defaultProviderConfigOpts = { + type: 'rpc', + rpcUrl: 'http://localhost:8545', + chainId: '0x539', + nickname: 'Localhost 8545', + } } else if (process.env.METAMASK_DEBUG || env === 'test') { - defaultProviderConfigType = RINKEBY + defaultProviderConfigOpts = { type: RINKEBY } } else { - defaultProviderConfigType = MAINNET + defaultProviderConfigOpts = { type: MAINNET } } const defaultProviderConfig = { - type: defaultProviderConfigType, ticker: 'ETH', -} -if (defaultProviderChainId) { - defaultProviderConfig.chainId = defaultProviderChainId + ...defaultProviderConfigOpts, } export default class NetworkController extends EventEmitter { @@ -169,7 +166,7 @@ export default class NetworkController extends EventEmitter { async setProviderType (type, rpcUrl = '', ticker = 'ETH', nickname = '') { assert.notEqual(type, 'rpc', `NetworkController - cannot call "setProviderType" with type 'rpc'. use "setRpcTarget"`) - assert(INFURA_PROVIDER_TYPES.includes(type) || type === LOCALHOST, `NetworkController - Unknown rpc type "${type}"`) + assert(INFURA_PROVIDER_TYPES.includes(type), `NetworkController - Unknown rpc type "${type}"`) const { chainId } = NETWORK_TYPE_TO_ID_MAP[type] this.setProviderConfig({ type, rpcUrl, chainId, ticker, nickname }) } @@ -205,9 +202,6 @@ export default class NetworkController extends EventEmitter { const isInfura = INFURA_PROVIDER_TYPES.includes(type) if (isInfura) { this._configureInfuraProvider(type, this._infuraProjectId) - // other type-based rpc endpoints - } else if (type === LOCALHOST) { - this._configureLocalhostProvider() // url-based rpc endpoints } else if (type === 'rpc') { this._configureStandardProvider(rpcUrl, chainId) @@ -225,12 +219,6 @@ export default class NetworkController extends EventEmitter { this._setNetworkClient(networkClient) } - _configureLocalhostProvider () { - log.info('NetworkController - configureLocalhostProvider') - const networkClient = createLocalhostClient() - this._setNetworkClient(networkClient) - } - _configureStandardProvider (rpcUrl, chainId) { log.info('NetworkController - configureStandardProvider', rpcUrl) const networkClient = createJsonRpcClient({ rpcUrl, chainId }) diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 3c6e8e629..02f4086fd 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -553,11 +553,8 @@ export default class PreferencesController { * */ addToFrequentRpcList (rpcUrl, chainId, ticker = 'ETH', nickname = '', rpcPrefs = {}) { - if (rpcUrl === 'http://localhost:8545') { - return - } - const rpcList = this.getFrequentRpcListDetail() + const index = rpcList.findIndex((element) => { return element.rpcUrl === rpcUrl }) diff --git a/app/scripts/first-time-state.js b/app/scripts/first-time-state.js index 06978f8e0..5577907fd 100644 --- a/app/scripts/first-time-state.js +++ b/app/scripts/first-time-state.js @@ -10,6 +10,17 @@ */ const initialState = { config: {}, + PreferencesController: { + frequentRpcListDetail: [ + { + rpcUrl: 'http://localhost:8545', + chainId: '0x539', + ticker: 'ETH', + nickname: 'Localhost 8545', + rpcPrefs: {}, + }, + ], + }, } export default initialState diff --git a/app/scripts/migrations/048.js b/app/scripts/migrations/048.js index 8a07abf0b..c877f3e16 100644 --- a/app/scripts/migrations/048.js +++ b/app/scripts/migrations/048.js @@ -4,9 +4,10 @@ const version = 48 /** * 1. Delete NetworkController.settings - * 2a. Delete NetworkController.provider if set to type 'rpc'. + * 2a. Delete NetworkController.provider if set to type 'rpc' or 'localhost'. * It will be re-set to Mainnet on background initialization. * 2b. Re-key provider.rpcTarget to provider.rpcUrl + * 3. Add localhost network to frequentRpcListDetail. */ export default { version, @@ -24,7 +25,8 @@ function transformState (state = {}) { delete state.NetworkController?.settings // 2. Delete NetworkController.provider or rename rpcTarget key - if (state.NetworkController?.provider?.type === 'rpc') { + const providerType = state.NetworkController?.provider?.type + if (providerType === 'rpc' || providerType === 'localhost') { delete state.NetworkController.provider } else if (state.NetworkController?.provider) { if ('rpcTarget' in state.NetworkController.provider) { @@ -34,5 +36,20 @@ function transformState (state = {}) { delete state.NetworkController?.provider?.rpcTarget } + // 3. Add localhost network to frequentRpcListDetail. + if (!state.PreferencesController) { + state.PreferencesController = {} + } + if (!state.PreferencesController.frequentRpcListDetail) { + state.PreferencesController.frequentRpcListDetail = [] + } + state.PreferencesController.frequentRpcListDetail.unshift({ + rpcUrl: 'http://localhost:8545', + chainId: '0x539', + ticker: 'ETH', + nickname: 'Localhost 8545', + rpcPrefs: {}, + }) + return state } diff --git a/development/run-ganache b/development/run-ganache index 8831c2112..0afdad98d 100755 --- a/development/run-ganache +++ b/development/run-ganache @@ -23,7 +23,7 @@ trap _term SIGTERM trap _int SIGINT # shellcheck disable=SC2086 -$ganache_cli --noVMErrorsOnRPCResponse --networkId 5777 --mnemonic "$seed_phrase" ${GANACHE_ARGS:-} & +$ganache_cli --noVMErrorsOnRPCResponse --networkId 1337 --mnemonic "$seed_phrase" ${GANACHE_ARGS:-} & child=$! wait "$child" diff --git a/test/e2e/ethereum-on.spec.js b/test/e2e/ethereum-on.spec.js index 5dd15d5fd..784267900 100644 --- a/test/e2e/ethereum-on.spec.js +++ b/test/e2e/ethereum-on.spec.js @@ -136,7 +136,7 @@ describe('MetaMask', function () { it('has the ganache network id within the dapp', async function () { const networkDiv = await driver.findElement(By.css('#network')) await driver.delay(regularDelayMs) - assert.equal(await networkDiv.getText(), '5777') + assert.equal(await networkDiv.getText(), '1337') }) it('changes the network', async function () { diff --git a/test/e2e/fixtures/imported-account/state.json b/test/e2e/fixtures/imported-account/state.json index 337875652..1af251b51 100644 --- a/test/e2e/fixtures/imported-account/state.json +++ b/test/e2e/fixtures/imported-account/state.json @@ -28,13 +28,13 @@ "vault": "{\"data\":\"s6TpYjlUNsn7ifhEFTkuDGBUM1GyOlPrim7JSjtfIxgTt8/6MiXgiR/CtFfR4dWW2xhq85/NGIBYEeWrZThGdKGarBzeIqBfLFhw9n509jprzJ0zc2Rf+9HVFGLw+xxC4xPxgCS0IIWeAJQ+XtGcHmn0UZXriXm8Ja4kdlow6SWinB7sr/WM3R0+frYs4WgllkwggDf2/Tv6VHygvLnhtzp6hIJFyTjh+l/KnyJTyZW1TkZhDaNDzX3SCOHT\",\"iv\":\"FbeHDAW5afeWNORfNJBR0Q==\",\"salt\":\"TxZ+WbCW6891C9LK/hbMAoUsSEW1E8pyGLVBU6x5KR8=\"}" }, "NetworkController": { - "network": "5777", + "network": "1337", "provider": { - "nickname": "", - "rpcUrl": "", - "chainId": "0x1691", + "nickname": "Localhost 8545", + "rpcUrl": "http://localhost:8545", + "chainId": "0x539", "ticker": "ETH", - "type": "localhost" + "type": "rpc" } }, "OnboardingController": { diff --git a/test/e2e/fixtures/localization/state.json b/test/e2e/fixtures/localization/state.json index 3ecc52079..8b60ffc9d 100644 --- a/test/e2e/fixtures/localization/state.json +++ b/test/e2e/fixtures/localization/state.json @@ -28,13 +28,13 @@ "vault": "{\"data\":\"s6TpYjlUNsn7ifhEFTkuDGBUM1GyOlPrim7JSjtfIxgTt8/6MiXgiR/CtFfR4dWW2xhq85/NGIBYEeWrZThGdKGarBzeIqBfLFhw9n509jprzJ0zc2Rf+9HVFGLw+xxC4xPxgCS0IIWeAJQ+XtGcHmn0UZXriXm8Ja4kdlow6SWinB7sr/WM3R0+frYs4WgllkwggDf2/Tv6VHygvLnhtzp6hIJFyTjh+l/KnyJTyZW1TkZhDaNDzX3SCOHT\",\"iv\":\"FbeHDAW5afeWNORfNJBR0Q==\",\"salt\":\"TxZ+WbCW6891C9LK/hbMAoUsSEW1E8pyGLVBU6x5KR8=\"}" }, "NetworkController": { - "network": "5777", + "network": "1337", "provider": { - "nickname": "", - "rpcUrl": "", - "chainId": "0x1691", + "nickname": "Localhost 8545", + "rpcUrl": "http://localhost:8545", + "chainId": "0x539", "ticker": "ETH", - "type": "localhost" + "type": "rpc" } }, "OnboardingController": { diff --git a/test/e2e/fixtures/personal-sign/state.json b/test/e2e/fixtures/personal-sign/state.json index 5ca886017..dcf4624c8 100644 --- a/test/e2e/fixtures/personal-sign/state.json +++ b/test/e2e/fixtures/personal-sign/state.json @@ -7,7 +7,7 @@ "CachedBalancesController": { "cachedBalances": { "4": {}, - "5777": { + "1337": { "0x5cfe73b6021e818b776b421b1c4db2474086a7e1": "0x15af1d78b58c40000" } } @@ -33,13 +33,13 @@ }, "NetworkController": { "provider": { - "nickname": "", - "rpcUrl": "", - "chainId": "0x1691", + "nickname": "Localhost 8545", + "rpcUrl": "http://localhost:8545", + "chainId": "0x539", "ticker": "ETH", - "type": "localhost" + "type": "rpc" }, - "network": "5777" + "network": "1337" }, "OnboardingController": { "onboardingTabs": {}, diff --git a/test/e2e/ganache.js b/test/e2e/ganache.js index edce5b15e..99ea7374c 100644 --- a/test/e2e/ganache.js +++ b/test/e2e/ganache.js @@ -3,7 +3,7 @@ const ganache = require('ganache-core') const defaultOptions = { blockTime: 2, - network_id: 5777, + network_id: 1337, mnemonic: 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent', port: 8545, vmErrorsOnRPCResponse: false, diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js index 0cbd0bea9..988665544 100644 --- a/test/unit/app/controllers/metamask-controller-test.js +++ b/test/unit/app/controllers/metamask-controller-test.js @@ -76,6 +76,7 @@ const TEST_ADDRESS_3 = '0xeb9e64b93097bc15f01f13eae97015c57ab64823' const TEST_SEED_ALT = 'setup olympic issue mobile velvet surge alcohol burger horse view reopen gentle' const TEST_ADDRESS_ALT = '0xc42edfcc21ed14dda456aa0756c153f7985d8813' const CUSTOM_RPC_URL = 'http://localhost:8545' +const CUSTOM_RPC_CHAIN_ID = '0x539' describe('MetaMaskController', function () { let metamaskController @@ -530,7 +531,10 @@ describe('MetaMaskController', function () { let rpcUrl beforeEach(function () { - rpcUrl = metamaskController.setCustomRpc(CUSTOM_RPC_URL) + rpcUrl = metamaskController.setCustomRpc( + CUSTOM_RPC_URL, + CUSTOM_RPC_CHAIN_ID, + ) }) it('returns custom RPC that when called', async function () { diff --git a/test/unit/app/controllers/preferences-controller-test.js b/test/unit/app/controllers/preferences-controller-test.js index bcf2d5dd2..a1ffe5b7b 100644 --- a/test/unit/app/controllers/preferences-controller-test.js +++ b/test/unit/app/controllers/preferences-controller-test.js @@ -522,10 +522,27 @@ describe('preferences controller', function () { describe('adding and removing from frequentRpcListDetail', function () { it('should add custom RPC url to state', function () { preferencesController.addToFrequentRpcList('rpc_url', '0x1') - preferencesController.addToFrequentRpcList('http://localhost:8545', '0x1') - assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: '0x1', ticker: 'ETH', nickname: '', rpcPrefs: {} }]) + assert.deepEqual( + preferencesController.store.getState().frequentRpcListDetail, + [{ + rpcUrl: 'rpc_url', + chainId: '0x1', + ticker: 'ETH', + nickname: '', + rpcPrefs: {}, + }], + ) preferencesController.addToFrequentRpcList('rpc_url', '0x1') - assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: '0x1', ticker: 'ETH', nickname: '', rpcPrefs: {} }]) + assert.deepEqual( + preferencesController.store.getState().frequentRpcListDetail, + [{ + rpcUrl: 'rpc_url', + chainId: '0x1', + ticker: 'ETH', + nickname: '', + rpcPrefs: {}, + }], + ) }) it('should throw if chainId is invalid', function () { diff --git a/test/unit/localhostState.js b/test/unit/localhostState.js index 1ec5e1eb2..13bd7af3c 100644 --- a/test/unit/localhostState.js +++ b/test/unit/localhostState.js @@ -14,6 +14,7 @@ const initialState = { provider: { type: 'rpc', rpcUrl: 'http://localhost:8545', + chainId: '0x539', }, }, } diff --git a/test/unit/migrations/048-test.js b/test/unit/migrations/048-test.js index fc93ea65b..0bebf9be9 100644 --- a/test/unit/migrations/048-test.js +++ b/test/unit/migrations/048-test.js @@ -1,6 +1,21 @@ import { strict as assert } from 'assert' import migration48 from '../../../app/scripts/migrations/048' +const localhostNetwork = { + rpcUrl: 'http://localhost:8545', + chainId: '0x539', + ticker: 'ETH', + nickname: 'Localhost 8545', + rpcPrefs: {}, +} +const expectedPreferencesState = { + PreferencesController: { + frequentRpcListDetail: [{ + ...localhostNetwork, + }], + }, +} + describe('migration #48', function () { it('should update the version metadata', async function () { const oldStorage = { @@ -34,6 +49,7 @@ describe('migration #48', function () { const newStorage = await migration48.migrate(oldStorage) assert.deepEqual(newStorage.data, { + ...expectedPreferencesState, NetworkController: { provider: { type: 'notRpc', @@ -60,6 +76,7 @@ describe('migration #48', function () { const newStorage = await migration48.migrate(oldStorage) assert.deepEqual(newStorage.data, { + ...expectedPreferencesState, NetworkController: { foo: 'bar', }, @@ -67,7 +84,32 @@ describe('migration #48', function () { }) }) - it('should re-key NetworkController.provider.rpcTarget to rpcUrl if the type is not "rpc"', async function () { + it('should delete NetworkController.provider if the type is "localhost"', async function () { + const oldStorage = { + meta: {}, + data: { + NetworkController: { + provider: { + type: 'localhost', + fizz: 'buzz', + }, + foo: 'bar', + }, + foo: 'bar', + }, + } + + const newStorage = await migration48.migrate(oldStorage) + assert.deepEqual(newStorage.data, { + ...expectedPreferencesState, + NetworkController: { + foo: 'bar', + }, + foo: 'bar', + }) + }) + + it('should re-key NetworkController.provider.rpcTarget to rpcUrl if the type is not "rpc" or "localhost"', async function () { const oldStorage = { meta: {}, data: { @@ -85,6 +127,7 @@ describe('migration #48', function () { const newStorage = await migration48.migrate(oldStorage) assert.deepEqual(newStorage.data, { + ...expectedPreferencesState, NetworkController: { foo: 'bar', provider: { @@ -97,7 +140,7 @@ describe('migration #48', function () { }) }) - it('should do nothing if affected state does not exist', async function () { + it('should do nothing to NetworkController if affected state does not exist', async function () { const oldStorage = { meta: {}, data: { @@ -111,16 +154,39 @@ describe('migration #48', function () { } const newStorage = await migration48.migrate(oldStorage) - assert.deepEqual(oldStorage.data, newStorage.data) + assert.deepEqual( + { ...oldStorage.data, ...expectedPreferencesState }, + { ...newStorage.data, ...expectedPreferencesState }, + ) }) - it('should do nothing if state is empty', async function () { + it('should add frequentRpcListDetail item to beginning of list', async function () { + const existingList = [ + { rpcUrl: 'foo', chainId: '0x1' }, + { rpcUrl: 'bar', chainId: '0x2' }, + ] + const oldStorage = { meta: {}, - data: {}, + data: { + PreferencesController: { + frequentRpcListDetail: [ + ...existingList, + ], + }, + foo: 'bar', + }, } const newStorage = await migration48.migrate(oldStorage) - assert.deepEqual(oldStorage.data, newStorage.data) + assert.deepEqual(newStorage.data, { + PreferencesController: { + frequentRpcListDetail: [ + { ...localhostNetwork }, + ...existingList, + ], + }, + foo: 'bar', + }) }) }) diff --git a/ui/app/components/app/dropdowns/network-dropdown.js b/ui/app/components/app/dropdowns/network-dropdown.js index a59173aa9..0f566671f 100644 --- a/ui/app/components/app/dropdowns/network-dropdown.js +++ b/ui/app/components/app/dropdowns/network-dropdown.js @@ -101,10 +101,6 @@ class NetworkDropdown extends Component { provider.type === 'rpc' && rpcUrl === provider.rpcUrl ) - if (rpcUrl === 'http://localhost:8545') { - return null - } - return ( - this.props.hideNetworkDropdown()} - onClick={() => this.handleClick('localhost')} - style={dropdownMenuItemStyle} - > - { - providerType === 'localhost' - ? - :
- } - - - {this.context.t('localhost')} - -
{this.renderCustomRpcList(rpcListDetail, this.props.provider)} this.props.hideNetworkDropdown()} diff --git a/ui/app/components/app/dropdowns/tests/network-dropdown.test.js b/ui/app/components/app/dropdowns/tests/network-dropdown.test.js index 6eca49568..750e74bd4 100644 --- a/ui/app/components/app/dropdowns/tests/network-dropdown.test.js +++ b/ui/app/components/app/dropdowns/tests/network-dropdown.test.js @@ -66,8 +66,8 @@ describe('Network Dropdown', function () { ) }) - it('renders 9 DropDownMenuItems ', function () { - assert.equal(wrapper.find(DropdownMenuItem).length, 9) + it('renders 8 DropDownMenuItems ', function () { + assert.equal(wrapper.find(DropdownMenuItem).length, 8) }) it('checks background color for first NetworkDropdownIcon', function () { @@ -95,12 +95,7 @@ describe('Network Dropdown', function () { }) it('checks dropdown for frequestRPCList from state', function () { - assert.equal(wrapper.find(DropdownMenuItem).at(6).text(), '✓http://localhost:7546') + assert.equal(wrapper.find(DropdownMenuItem).at(6).text(), '✓http://localhost:7545') }) - - it('checks background color for seventh NetworkDropdownIcon', function () { - assert.equal(wrapper.find(NetworkDropdownIcon).at(6).prop('innerBorder'), '1px solid #9b9b9b') - }) - }) }) diff --git a/ui/app/components/app/loading-network-screen/loading-network-screen.component.js b/ui/app/components/app/loading-network-screen/loading-network-screen.component.js index 9b9b96619..f20916346 100644 --- a/ui/app/components/app/loading-network-screen/loading-network-screen.component.js +++ b/ui/app/components/app/loading-network-screen/loading-network-screen.component.js @@ -45,8 +45,6 @@ export default class LoadingNetworkScreen extends PureComponent { name = this.context.t('connectingToKovan') } else if (providerName === 'rinkeby') { name = this.context.t('connectingToRinkeby') - } else if (providerName === 'localhost') { - name = this.context.t('connectingToLocalhost') } else if (providerName === 'goerli') { name = this.context.t('connectingToGoerli') } else { diff --git a/ui/app/components/app/network.js b/ui/app/components/app/network.js index 97f7c44bb..f66a0182a 100644 --- a/ui/app/components/app/network.js +++ b/ui/app/components/app/network.js @@ -153,11 +153,7 @@ export default class Network extends Component { ) }
- { - providerName === 'localhost' - ? t('localhost') - : providerNick || t('privateNetwork') - } + {providerNick || t('privateNetwork')}
) diff --git a/ui/app/helpers/utils/util.js b/ui/app/helpers/utils/util.js index 990cd3f6d..454b73a1f 100644 --- a/ui/app/helpers/utils/util.js +++ b/ui/app/helpers/utils/util.js @@ -34,7 +34,7 @@ Object.keys(valueTable).forEach((currency) => { }) export function isEthNetwork (netId) { - if (!netId || netId === '1' || netId === '3' || netId === '4' || netId === '42' || netId === '5777') { + if (!netId || netId === '1' || netId === '3' || netId === '4' || netId === '42' || netId === '1337') { return true } diff --git a/ui/app/pages/routes/routes.component.js b/ui/app/pages/routes/routes.component.js index 41578651f..37bb13f40 100644 --- a/ui/app/pages/routes/routes.component.js +++ b/ui/app/pages/routes/routes.component.js @@ -315,8 +315,6 @@ export default class Routes extends Component { return this.context.t('connectingToKovan') case 'rinkeby': return this.context.t('connectingToRinkeby') - case 'localhost': - return this.context.t('connectingToLocalhost') case 'goerli': return this.context.t('connectingToGoerli') default: @@ -334,8 +332,6 @@ export default class Routes extends Component { return this.context.t('kovan') case 'rinkeby': return this.context.t('rinkeby') - case 'localhost': - return this.context.t('localhost') case 'goerli': return this.context.t('goerli') default: diff --git a/ui/app/pages/settings/networks-tab/networks-tab.constants.js b/ui/app/pages/settings/networks-tab/networks-tab.constants.js index a90608bf3..c408aa89b 100644 --- a/ui/app/pages/settings/networks-tab/networks-tab.constants.js +++ b/ui/app/pages/settings/networks-tab/networks-tab.constants.js @@ -3,7 +3,6 @@ import { GOERLI_CHAIN_ID, KOVAN, KOVAN_CHAIN_ID, - LOCALHOST, MAINNET, MAINNET_CHAIN_ID, RINKEBY, @@ -58,14 +57,6 @@ const defaultNetworksData = [ ticker: 'ETH', blockExplorerUrl: 'https://etherscan.io', }, - { - labelKey: LOCALHOST, - iconColor: 'white', - border: '1px solid #6A737D', - providerType: LOCALHOST, - rpcUrl: 'http://localhost:8545/', - blockExplorerUrl: 'https://etherscan.io', - }, ] export {