Fix default currency symbol for `wallet_addEthereumChain` + improve warnings for data that doesn't match our validation expectations (#15201)

* set more appropriate default for ticker symbol when wallet_addEthereumChain is called

* throw error to dapp when site suggests network with same chainId but different ticker symbol from already added network, instead of showing error and disabled notification to user
feature/default_network_editable
Alex Donesky 2 years ago committed by GitHub
parent 6cd036e9a1
commit d92936475a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/_locales/de/messages.json
  2. 8
      app/_locales/el/messages.json
  3. 23
      app/_locales/en/messages.json
  4. 8
      app/_locales/es/messages.json
  5. 8
      app/_locales/es_419/messages.json
  6. 8
      app/_locales/fr/messages.json
  7. 8
      app/_locales/hi/messages.json
  8. 8
      app/_locales/id/messages.json
  9. 8
      app/_locales/ja/messages.json
  10. 8
      app/_locales/ko/messages.json
  11. 8
      app/_locales/ph/messages.json
  12. 8
      app/_locales/pt/messages.json
  13. 8
      app/_locales/pt_BR/messages.json
  14. 8
      app/_locales/ru/messages.json
  15. 8
      app/_locales/tl/messages.json
  16. 8
      app/_locales/tr/messages.json
  17. 8
      app/_locales/vi/messages.json
  18. 8
      app/_locales/zh/messages.json
  19. 8
      app/_locales/zh_CN/messages.json
  20. 5
      app/scripts/controllers/network/network.js
  21. 40
      app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js
  22. 3
      app/scripts/metamask-controller.js
  23. 2
      shared/constants/app.js
  24. 95
      ui/pages/confirmation/templates/add-ethereum-chain.js

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "6M+ Benutzern beitreten um MetaMask zu verbessern"
},
"mismatchedChain": {
"message": "Die Netzwerkdetails für diese Ketten-ID stimmen nicht mit unseren Aufzeichnungen überein. Wir empfehlen Ihnen $1, bevor Sie fortfahren.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "die Netzwerkdetails überprüfen",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "Dieses benutzerdefinierte Netzwerk ist nicht erkannt. Wir empfehlen, dass Sie $1 bevor Sie fortfahren",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "die Netzwerkdetails überprüfen",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "Verwenden von Sammelbaren (ERC-721) Token wird derzeit nicht unterstützt",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "Συμμετάσχετε σε 6εκ+ χρήστες για να βελτιώσετε το MetaMask"
},
"mismatchedChain": {
"message": "Οι λεπτομέρειες δικτύου για αυτό το αναγνωριστικό αλυσίδας δεν ταιριάζουν με τις εγγραφές μας. Σας συνιστούμε να $1 πριν συνεχίσετε.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "επαληθεύστε τα στοιχεία δικτύου",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "Αυτό το προσαρμοσμένο δίκτυο δεν αναγνωρίζεται. Σας συνιστούμε να $1 πριν προχωρήσετε",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "επαληθεύστε τα στοιχεία δικτύου",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "Η αποστολή συλλεκτικών (ERC-721) δεν υποστηρίζεται προς το παρόν",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1909,14 +1909,23 @@
"metametricsTitle": {
"message": "Join 6M+ users to improve MetaMask"
},
"mismatchedChain": {
"message": "The network details for this chain ID do not match our records. We recommend that you $1 before proceeding.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "verify the network details",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
},
"mismatchedChainRecommendation": {
"message": "We recommend that you $1 before proceeding.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key. The link will open to instructions for users to validate custom network details."
},
"mismatchedNetworkName": {
"message": "According to our record the network name may not correctly match this chain ID."
},
"mismatchedNetworkSymbol": {
"message": "The submitted currency symbol does not match what we expect for this chain ID."
},
"mismatchedRpcUrl": {
"message": "According to our records the submitted RPC URL value does not match a known provider for this chain ID."
},
"missingNFT": {
"message": "Don't see your NFT?"
},
@ -3943,13 +3952,9 @@
"message": "The decentralized web awaits"
},
"unrecognizedChain": {
"message": "This custom network is not recognized. We recommend that you $1 before proceeding",
"message": "This custom network is not recognized",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "verify the network details",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "Sending collectible (ERC-721) tokens is not currently supported",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "Únase a más de 6 millones de usuarios para mejorar MetaMask"
},
"mismatchedChain": {
"message": "Los detalles de la red de este identificador de cadena no coinciden con nuestros registros. Antes de continuar, le recomendamos que $1.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "verifique los detalles de la red",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "No se reconoce esta red personalizada. Antes de continuar, le recomendamos que $1",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "verifique los detalles de la red",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "El envío de tokens coleccionables (ERC-721) no se admite actualmente",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1643,10 +1643,6 @@
"metametricsTitle": {
"message": "Únase a más de 6 millones de usuarios para mejorar MetaMask"
},
"mismatchedChain": {
"message": "Los detalles de la red de este ID de cadena no coinciden con nuestros registros. Antes de continuar, le recomendamos que $1.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "verifique los detalles de la red",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3215,10 +3211,6 @@
"message": "No se reconoce esta red personalizada. Antes de continuar, le recomendamos que $1",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "verifique los detalles de la red",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "El envío de tokens coleccionables (ERC-721) no se admite actualmente",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "Rejoignez plus de 6 M d’utilisateurs pour améliorer MetaMask"
},
"mismatchedChain": {
"message": "Les détails du réseau pour cet ID de chaîne ne correspondent pas à nos registres. Nous vous recommandons de $1 avant de poursuivre.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "vérifier les détails du réseau",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "Ce réseau personnalisé n’est pas reconnu. Nous vous recommandons de $1 avant de continuer",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "vérifier les détails du réseau",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "L’envoi de jetons collectibles (ERC-721) n’est pas pris en charge actuellement",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "MetaMask कहतर बनिए 6M+ उपयगकर"
},
"mismatchedChain": {
"message": "इस चन ID किए नटवरक विवरण हमिड सल नह। हम अन करति आप आग बढ पहल $1।",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "नटवरक विवरण सतित कर",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "यह कसटम नटवरक पहच नह गय। हम अन करति आप आग बढ पहल $1",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "नटवरक विवरण सतित कर",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "वरतमन मरहणय (ERC-721) टकन भजन समरित नह",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "Bergabunglah bersama 6 Jt+ pengguna untuk meningkatkan MetaMask"
},
"mismatchedChain": {
"message": "Detail jaringan untuk ID rantai ini tidak cocok dengan catatan kami. Kami menyarankan agar Anda $1 sebelum melanjutkan.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "memverifikasi detail jaringan",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "Jaringan kustom ini tidak dikenali. Kami menyarankan agar Anda $1 sebelum melanjutkan",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "memverifikasi detail jaringan",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "Tidak mendukung pengiriman token koleksi (ERC-721) untuk saat ini",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "6百万人以上のユーザーと共に、MetaMaskの改善にご協力ください"
},
"mismatchedChain": {
"message": "このチェーンIDのネットワーク詳細が、レコードと一致しません。続行する前に$1をお勧めします。",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "ネットワークの詳細の確認",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "このカスタムネットワークは認識されません。続行する前に$1をお勧めします",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "ネットワークの詳細の確認",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "コレクティブル (ERC-721) トークンの送信は現在サポートされていません",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "6백만 명 이상의 사용자와 함께 MetaMask 기능 향상에 동참하세요."
},
"mismatchedChain": {
"message": "이 체인 ID의 네트워크 세부 정보가 기록과 일치하지 않습니다. 진행하기 전에 $1을(를) 권장합니다.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "네트워크 세부 정보 검증",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "이 맞춤형 네트워크는 인식되지 않습니다. 진행하기 전에 $1을(를) 권장합니다.",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "네트워크 세부 정보 검증",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "수집 가능한(ERC-721) 토큰 전송은 현재 지원되지 않습니다.",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1039,10 +1039,6 @@
"metametricsOptInDescription": {
"message": "Gustong kunin ng MetaMask ang data ng paggamit para mas maunawaan kung paano ginagamit ng mga user namin ang extension. Gagamitin ang data na ito para patuloy na mapahusay ang kakayahang magamit at karanasan ng user sa paggamit ng produkto namin at Ethereum ecosystem."
},
"mismatchedChain": {
"message": "Ang mga detalye ng network para sa chain ID na ito ay hindi tumutugma sa aming mga record. Inirerekomenda naming $1 ka bago magpatuloy.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "i-verify ang mga detalye ng network",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -2161,10 +2157,6 @@
"message": "Hindi kinikilala ang custom na network na ito. Inirerekomenda naming $1 ka bago magpatuloy",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "i-verify ang mga detalye ng network",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"updatedWithDate": {
"message": "Na-update noong $1"
},

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "Junte-se a mais de 6 milhões de usuários para melhorar a MetaMask"
},
"mismatchedChain": {
"message": "Os detalhes da rede para esse ID da cadeia não correspondem aos dos nossos registros. Recomendamos que você $1 antes de continuar.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "verifique os detalhes da rede",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "Essa rede personalizada não foi reconhecida. Recomendamos que você $1 antes de continuar",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "verifique os detalhes da rede",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "O envio de tokens colecionáveis (ERC-721) não é suportado no momento",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1627,10 +1627,6 @@
"metametricsTitle": {
"message": "Junte-se a mais de 6 milhões de usuários para melhorar a MetaMask"
},
"mismatchedChain": {
"message": "Os detalhes da rede para esse ID da cadeia não correspondem aos dos nossos registros. Recomendamos que você $1 antes de continuar.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "verifique os detalhes da rede",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3199,10 +3195,6 @@
"message": "Essa rede personalizada não foi reconhecida. Recomendamos que você $1 antes de continuar",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "verifique os detalhes da rede",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "O envio de tokens colecionáveis (ERC-721) não é suportado no momento",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "Присоединяйтесь к более чем 6 млн пользователей, чтобы улучшить MetaMask"
},
"mismatchedChain": {
"message": "Сведения о сети для этого ID цепочки не совпадают с указанными в записях. Мы рекомендуем $1 до того, как продолжить.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "проверить сведения о сети",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "Эта пользовательская сеть не распознана. Мы рекомендуем $1, прежде чем продолжить",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "проверить сведения о сети",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "Отправка коллекционных активов (ERC-721) сейчас не поддерживается",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "Sumali sa 6M+ user upang mapabuti ang MetaMask"
},
"mismatchedChain": {
"message": "Ang mga detalye ng network para sa chain ID na ito ay hindi tumutugma sa aming mga talaan. Inirerekomenda namin na $1 ka bago magpatuloy.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "i-verify ang mga detalye ng network",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "Hindi nakikilala ang custom network na ito. Nirerekomenda namin na ikaw ay $1 bago magpatuloy",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "i-verify ang mga detalye ng network",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "Ang pagpapadala ng collectible (ERC-721) token ay kasalukuyang hindi magagamit",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "MetaMask'i geliştirmek için 6 milyondan fazla kullanıcıya katılın"
},
"mismatchedChain": {
"message": "Bu zincir kimliği için ağ ayrıntıları kayıtlarımızla uyumlu değil. Devam etmeden önce şunu yapmanızı öneriyoruz: $1.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "ağ bilgilerini doğrula",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "Bu özel ağ tanınmadı. Devam etmeden önce $1 öneririz",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "ağ bilgilerini doğrula",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "Toplanabilir (ERC-721) tokenlerin gönderilmesi şu anda desteklenmiyor",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "Tham gia cùng hơn 6 Triệu người dùng để cải thiện MetaMask"
},
"mismatchedChain": {
"message": "Thông tin về mạng cho mã chuỗi này không khớp với hồ sơ của chúng tôi. Bạn nên $1 trước khi tiếp tục.",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "xác minh thông tin về mạng",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "Không nhận ra mạng tùy chỉnh này. Bạn nên $1 trước khi tiếp tục",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "xác minh thông tin về mạng",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "Hiện không hỗ trợ gửi token sưu tập (ERC-721)",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1888,10 +1888,6 @@
"metametricsTitle": {
"message": "和600多万用户一起改进 MetaMask"
},
"mismatchedChain": {
"message": "此链 ID 的网络信息与我们的记录不符。我们建议您在继续操作之前 $1。",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "验证网络信息",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3874,10 +3870,6 @@
"message": "这个自定义网络无法识别。我们建议您在继续操作之前 $1",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "验证网络信息",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "当前不支持发送可收藏的 (ERC-721) 代币",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -1597,10 +1597,6 @@
"metametricsTitle": {
"message": "加入 6M+ 用户来改进MetaMask"
},
"mismatchedChain": {
"message": "此链路的网络详细信息与我们的记录不匹配。我们建议您在继续操作之前$1。",
"description": "$1 is a clickable link with text defined by the 'mismatchedChainLinkText' key"
},
"mismatchedChainLinkText": {
"message": "验证网络详细信息",
"description": "Serves as link text for the 'mismatchedChain' key. This text will be embedded inside the translation for that key."
@ -3157,10 +3153,6 @@
"message": "这个自定义网络无法识别。我们建议您在继续操作之前$1",
"description": "$1 is a clickable link with text defined by the 'unrecognizedChanLinkText' key. The link will open to instructions for users to validate custom network details."
},
"unrecognizedChainLinkText": {
"message": "验证网络详细信息",
"description": "Serves as link text for the 'unrecognizedChain' key. This text will be embedded inside the translation for that key."
},
"unsendableAsset": {
"message": "当前不支持发送可收藏的 (ERC-721) 代币",
"description": "This is an error message we show the user if they attempt to send a collectible asset type, for which currently don't support sending"

@ -272,6 +272,11 @@ export default class NetworkController extends EventEmitter {
return NETWORK_TYPE_TO_ID_MAP[type]?.chainId || configChainId;
}
getCurrentRpcUrl() {
const { rpcUrl } = this.getProviderConfig();
return rpcUrl;
}
setRpcTarget(rpcUrl, chainId, ticker = 'ETH', nickname = '', rpcPrefs) {
assert.ok(
isPrefixedFormattedHexString(chainId),

@ -1,7 +1,10 @@
import { ethErrors, errorCodes } from 'eth-rpc-errors';
import validUrl from 'valid-url';
import { omit } from 'lodash';
import { MESSAGE_TYPE } from '../../../../../shared/constants/app';
import {
MESSAGE_TYPE,
UNKNOWN_TICKER_SYMBOL,
} from '../../../../../shared/constants/app';
import { EVENT } from '../../../../../shared/constants/metametrics';
import {
isPrefixedFormattedHexString,
@ -16,6 +19,7 @@ const addEthereumChain = {
hookNames: {
addCustomRpc: true,
getCurrentChainId: true,
getCurrentRpcUrl: true,
findCustomRpcBy: true,
updateRpcTarget: true,
requestUserApproval: true,
@ -32,6 +36,7 @@ async function addEthereumChainHandler(
{
addCustomRpc,
getCurrentChainId,
getCurrentRpcUrl,
findCustomRpcBy,
updateRpcTarget,
requestUserApproval,
@ -145,15 +150,21 @@ async function addEthereumChainHandler(
const existingNetwork = findCustomRpcBy({ chainId: _chainId });
if (existingNetwork) {
// if the request is to add a network that is already added and configured
// with the same RPC gateway we shouldn't try to add it again.
if (existingNetwork && existingNetwork.rpcUrl === firstValidRPCUrl) {
// If the network already exists, the request is considered successful
res.result = null;
const currentChainId = getCurrentChainId();
if (currentChainId === _chainId) {
const currentRpcUrl = getCurrentRpcUrl();
// If the current chainId and rpcUrl matches that of the incoming request
// We don't need to proceed further.
if (currentChainId === _chainId && currentRpcUrl === firstValidRPCUrl) {
return end();
}
// If this network is already added with but is not the currently selected network
// Ask the user to switch the network
try {
await updateRpcTarget(
@ -236,15 +247,32 @@ async function addEthereumChainHandler(
);
}
}
const ticker = nativeCurrency?.symbol || 'ETH';
if (typeof ticker !== 'string' || ticker.length < 2 || ticker.length > 6) {
const ticker = nativeCurrency?.symbol || UNKNOWN_TICKER_SYMBOL;
if (
ticker !== UNKNOWN_TICKER_SYMBOL &&
(typeof ticker !== 'string' || ticker.length < 2 || ticker.length > 6)
) {
return end(
ethErrors.rpc.invalidParams({
message: `Expected 2-6 character string 'nativeCurrency.symbol'. Received:\n${ticker}`,
}),
);
}
// if the chainId is the same as an existing network but the ticker is different we want to block this action
// as it is potentially malicious and confusing
if (
existingNetwork &&
existingNetwork.chainId === _chainId &&
existingNetwork.ticker !== ticker
) {
return end(
ethErrors.rpc.invalidParams({
message: `nativeCurrency.symbol does not match currency symbol for a network the user already has added with the same chainId. Received:\n${ticker}`,
}),
);
}
try {
await addCustomRpc(

@ -3651,6 +3651,9 @@ export default class MetamaskController extends EventEmitter {
getCurrentChainId: this.networkController.getCurrentChainId.bind(
this.networkController,
),
getCurrentRpcUrl: this.networkController.getCurrentRpcUrl.bind(
this.networkController,
),
setProviderType: this.networkController.setProviderType.bind(
this.networkController,
),

@ -92,3 +92,5 @@ export const FIREFOX_BUILD_IDS = [
METAMASK_PROD_FIREFOX_ID,
METAMASK_FLASK_FIREFOX_ID,
];
export const UNKNOWN_TICKER_SYMBOL = 'UNKNOWN';

@ -20,38 +20,19 @@ const UNRECOGNIZED_CHAIN = {
element: 'MetaMaskTranslation',
props: {
translationKey: 'unrecognizedChain',
variables: [
{
element: 'a',
key: 'unrecognizedChainLink',
props: {
href:
'https://metamask.zendesk.com/hc/en-us/articles/360057142392',
target: '__blank',
tabIndex: 0,
},
children: {
element: 'MetaMaskTranslation',
props: {
translationKey: 'unrecognizedChainLinkText',
},
},
},
],
},
},
},
};
const INVALID_CHAIN = {
id: 'INVALID_CHAIN',
severity: SEVERITIES.DANGER,
const MISMATCHED_CHAIN_RECOMMENDATION = {
id: 'MISMATCHED_CHAIN_RECOMMENDATION',
content: {
element: 'span',
children: {
element: 'MetaMaskTranslation',
props: {
translationKey: 'mismatchedChain',
translationKey: 'mismatchedChainRecommendation',
variables: [
{
element: 'a',
@ -75,6 +56,48 @@ const INVALID_CHAIN = {
},
};
const MISMATCHED_NETWORK_NAME = {
id: 'MISMATCHED_NETWORK_NAME',
severity: SEVERITIES.WARNING,
content: {
element: 'span',
children: {
element: 'MetaMaskTranslation',
props: {
translationKey: 'mismatchedNetworkName',
},
},
},
};
const MISMATCHED_NETWORK_SYMBOL = {
id: 'MISMATCHED_NETWORK_SYMBOL',
severity: SEVERITIES.DANGER,
content: {
element: 'span',
children: {
element: 'MetaMaskTranslation',
props: {
translationKey: 'mismatchedNetworkSymbol',
},
},
},
};
const MISMATCHED_NETWORK_RPC = {
id: 'MISMATCHED_NETWORK_RPC',
severity: SEVERITIES.DANGER,
content: {
element: 'span',
children: {
element: 'MetaMaskTranslation',
props: {
translationKey: 'mismatchedRpcUrl',
},
},
},
};
async function getAlerts(pendingApproval) {
const alerts = [];
const safeChainsList =
@ -83,34 +106,39 @@ async function getAlerts(pendingApproval) {
(chain) =>
chain.chainId === parseInt(pendingApproval.requestData.chainId, 16),
);
let validated = Boolean(matchedChain);
const originIsMetaMask = pendingApproval.origin === 'metamask';
if (originIsMetaMask && validated) {
if (originIsMetaMask && Boolean(matchedChain)) {
return [];
}
if (matchedChain) {
if (
matchedChain.nativeCurrency?.decimals !== 18 ||
matchedChain.name.toLowerCase() !==
pendingApproval.requestData.chainName.toLowerCase() ||
pendingApproval.requestData.chainName.toLowerCase()
) {
alerts.push(MISMATCHED_NETWORK_NAME);
}
if (
matchedChain.nativeCurrency?.symbol !== pendingApproval.requestData.ticker
) {
validated = false;
alerts.push(MISMATCHED_NETWORK_SYMBOL);
}
const { origin } = new URL(pendingApproval.requestData.rpcUrl);
if (!matchedChain.rpc.map((rpc) => new URL(rpc).origin).includes(origin)) {
validated = false;
alerts.push(MISMATCHED_NETWORK_RPC);
}
}
if (!matchedChain) {
alerts.push(UNRECOGNIZED_CHAIN);
} else if (!validated) {
alerts.push(INVALID_CHAIN);
}
if (alerts.length) {
alerts.push(MISMATCHED_CHAIN_RECOMMENDATION);
}
return alerts;
}
@ -281,7 +309,12 @@ function getValues(pendingApproval, t, actions) {
[t('blockExplorerUrl')]: pendingApproval.requestData
.blockExplorerUrl,
},
prefaceKeys: [t('networkName'), t('networkURL'), t('chainId')],
prefaceKeys: [
t('networkName'),
t('networkURL'),
t('chainId'),
t('currencySymbol'),
],
},
},
],

Loading…
Cancel
Save