diff --git a/app/_locales/am/messages.json b/app/_locales/am/messages.json index 1ba47fede..a62e23ddc 100644 --- a/app/_locales/am/messages.json +++ b/app/_locales/am/messages.json @@ -731,7 +731,7 @@ "optionalBlockExplorerUrl": { "message": "ኤክስፕሎረር URL አግድ (አማራጭ)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "ምልክት (አማራጭ)" }, "orderOneHere": { diff --git a/app/_locales/ar/messages.json b/app/_locales/ar/messages.json index 5c579e93d..b868e8dd5 100644 --- a/app/_locales/ar/messages.json +++ b/app/_locales/ar/messages.json @@ -727,7 +727,7 @@ "optionalBlockExplorerUrl": { "message": "العنوان الإلكتروني لمستكشف البلوكات (اختياري)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "الرمز (اختياري)" }, "orderOneHere": { diff --git a/app/_locales/bg/messages.json b/app/_locales/bg/messages.json index 7b47d5ff8..cc42761e2 100644 --- a/app/_locales/bg/messages.json +++ b/app/_locales/bg/messages.json @@ -730,7 +730,7 @@ "optionalBlockExplorerUrl": { "message": "Блокиране на Explorer URL (по избор)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Символ (по избор)" }, "orderOneHere": { diff --git a/app/_locales/bn/messages.json b/app/_locales/bn/messages.json index ded364151..cfc2d49bd 100644 --- a/app/_locales/bn/messages.json +++ b/app/_locales/bn/messages.json @@ -734,7 +734,7 @@ "optionalBlockExplorerUrl": { "message": "এক্সপ্লোরার URL ব্লক করুন (ঐচ্ছিক)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "প্রতীক (ঐচ্ছিক)" }, "orderOneHere": { diff --git a/app/_locales/ca/messages.json b/app/_locales/ca/messages.json index 19102f8b3..d1060d8bd 100644 --- a/app/_locales/ca/messages.json +++ b/app/_locales/ca/messages.json @@ -718,7 +718,7 @@ "optionalBlockExplorerUrl": { "message": "Bloqueja l'URL d'Explorer (opcional)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Símbol (opcional)" }, "orderOneHere": { diff --git a/app/_locales/da/messages.json b/app/_locales/da/messages.json index 0c3ffed48..5e19e8d01 100644 --- a/app/_locales/da/messages.json +++ b/app/_locales/da/messages.json @@ -718,7 +718,7 @@ "optionalBlockExplorerUrl": { "message": "Blok-stifinder-URL (valgfrit)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Symbol (valgfrit)" }, "orderOneHere": { diff --git a/app/_locales/el/messages.json b/app/_locales/el/messages.json index b16b43cbb..00d493f80 100644 --- a/app/_locales/el/messages.json +++ b/app/_locales/el/messages.json @@ -731,7 +731,7 @@ "optionalBlockExplorerUrl": { "message": "Διεύθυνση URL Εξερευνητή Μπλοκ (προαιρετικό)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Σύμβολο (προαιρετικό)" }, "orderOneHere": { diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index b6842da63..b8d57bb21 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -869,7 +869,7 @@ "message": "Invalid IPFS Gateway: The value must be a valid URL" }, "invalidNumber": { - "message": "Invalid number. Enter a decimal or hexadecimal number." + "message": "Invalid number. Enter a decimal or '0x'-prefixed hexadecimal number." }, "invalidNumberLeadingZeros": { "message": "Invalid number. Remove any leading zeros." @@ -1031,7 +1031,7 @@ "message": "Network Name" }, "networkSettingsChainIdDescription": { - "message": "The chain ID is used for signing transactions. It must match the chain ID returned by the network. Enter a decimal or hexadecimal number starting with '0x'." + "message": "The chain ID is used for signing transactions. It must match the chain ID returned by the network. You can enter a decimal or '0x'-prefixed hexadecimal number, but we will display the number in decimal." }, "networkSettingsDescription": { "message": "Add and edit custom RPC networks" @@ -1150,8 +1150,8 @@ "optionalBlockExplorerUrl": { "message": "Block Explorer URL (optional)" }, - "optionalSymbol": { - "message": "Symbol (optional)" + "optionalCurrencySymbol": { + "message": "Currency Symbol (optional)" }, "orderOneHere": { "message": "Order a Trezor or Ledger and keep your funds in cold storage" diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index e71326d10..8dd8cdd6f 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -574,7 +574,7 @@ "ofTextNofM": { "message": "de" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Símbolo (opcional)" }, "orderOneHere": { diff --git a/app/_locales/es_419/messages.json b/app/_locales/es_419/messages.json index a7faf3eba..f5cfccba2 100644 --- a/app/_locales/es_419/messages.json +++ b/app/_locales/es_419/messages.json @@ -719,7 +719,7 @@ "optionalBlockExplorerUrl": { "message": "Bloquear la URL de Explorer (opcional)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Símbolo (opcional)" }, "orderOneHere": { diff --git a/app/_locales/et/messages.json b/app/_locales/et/messages.json index 600b57354..8a1c3ee52 100644 --- a/app/_locales/et/messages.json +++ b/app/_locales/et/messages.json @@ -724,7 +724,7 @@ "optionalBlockExplorerUrl": { "message": "Blokeeri Exploreri URL (valikuline)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Sümbol (valikuline)" }, "orderOneHere": { diff --git a/app/_locales/fa/messages.json b/app/_locales/fa/messages.json index bb0dc4bca..f13059643 100644 --- a/app/_locales/fa/messages.json +++ b/app/_locales/fa/messages.json @@ -734,7 +734,7 @@ "optionalBlockExplorerUrl": { "message": "بلاک کردن مرورگر URL (انتخابی)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "سمبول (انتخابی)" }, "orderOneHere": { diff --git a/app/_locales/fi/messages.json b/app/_locales/fi/messages.json index f0dcd6c01..53dd7496f 100644 --- a/app/_locales/fi/messages.json +++ b/app/_locales/fi/messages.json @@ -731,7 +731,7 @@ "optionalBlockExplorerUrl": { "message": "Estä Explorerin URL-osoite (valinnainen)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Symboli (valinnainen)" }, "orderOneHere": { diff --git a/app/_locales/fil/messages.json b/app/_locales/fil/messages.json index 537fe32be..6285949c6 100644 --- a/app/_locales/fil/messages.json +++ b/app/_locales/fil/messages.json @@ -665,7 +665,7 @@ "optionalBlockExplorerUrl": { "message": "Block Explorer URL (opsyonal)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Simbolo (opsyonal)" }, "orderOneHere": { diff --git a/app/_locales/fr/messages.json b/app/_locales/fr/messages.json index 853494ba5..750591cfc 100644 --- a/app/_locales/fr/messages.json +++ b/app/_locales/fr/messages.json @@ -716,7 +716,7 @@ "optionalBlockExplorerUrl": { "message": "Bloquer l'URL de l'explorateur (facultatif)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Symbole (facultatif)" }, "orderOneHere": { diff --git a/app/_locales/he/messages.json b/app/_locales/he/messages.json index 9c2480559..6a0bc2cbd 100644 --- a/app/_locales/he/messages.json +++ b/app/_locales/he/messages.json @@ -731,7 +731,7 @@ "optionalBlockExplorerUrl": { "message": "חסום כתובת URL של אקספלורר (אופציונלי)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "סמל (אופציונלי)" }, "orderOneHere": { diff --git a/app/_locales/hi/messages.json b/app/_locales/hi/messages.json index 2665eec15..da83a04b7 100644 --- a/app/_locales/hi/messages.json +++ b/app/_locales/hi/messages.json @@ -731,7 +731,7 @@ "optionalBlockExplorerUrl": { "message": "एक्सप्लोरर यूआरएल ब्लॉक (वैकल्पिक)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "सिम्बल (वैकल्पिक)" }, "orderOneHere": { diff --git a/app/_locales/hr/messages.json b/app/_locales/hr/messages.json index e7d8f9f5b..1564bd012 100644 --- a/app/_locales/hr/messages.json +++ b/app/_locales/hr/messages.json @@ -727,7 +727,7 @@ "optionalBlockExplorerUrl": { "message": "Blokiraj Explorerov URL (neobavezno)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Simbol (neobavezno)" }, "orderOneHere": { diff --git a/app/_locales/hu/messages.json b/app/_locales/hu/messages.json index b43fda718..9188af756 100644 --- a/app/_locales/hu/messages.json +++ b/app/_locales/hu/messages.json @@ -727,7 +727,7 @@ "optionalBlockExplorerUrl": { "message": "Explorer URL letiltása (nem kötelező)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Szimbólum (opcionális)" }, "orderOneHere": { diff --git a/app/_locales/id/messages.json b/app/_locales/id/messages.json index bcc90707b..9eff50642 100644 --- a/app/_locales/id/messages.json +++ b/app/_locales/id/messages.json @@ -718,7 +718,7 @@ "optionalBlockExplorerUrl": { "message": "Blokir URL Penjelajah (opsional)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Simbol (opsional)" }, "orderOneHere": { diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json index 8342e11ee..98bd7c936 100644 --- a/app/_locales/it/messages.json +++ b/app/_locales/it/messages.json @@ -1050,7 +1050,7 @@ "optionalBlockExplorerUrl": { "message": "URL del Block Explorer (opzionale)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Simbolo (opzionale)" }, "orderOneHere": { diff --git a/app/_locales/kn/messages.json b/app/_locales/kn/messages.json index 350bbeae7..d482f073e 100644 --- a/app/_locales/kn/messages.json +++ b/app/_locales/kn/messages.json @@ -734,7 +734,7 @@ "optionalBlockExplorerUrl": { "message": "ಅನ್ವೇಷಕ URL ಅನ್ನು ನಿರ್ಬಂಧಿಸಿ (ಐಚ್ಛಿಕ)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "ಚಿಹ್ನೆ (ಐಚ್ಛಿಕ)" }, "orderOneHere": { diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json index 1030f275a..ec4b28b2f 100644 --- a/app/_locales/ko/messages.json +++ b/app/_locales/ko/messages.json @@ -728,7 +728,7 @@ "optionalBlockExplorerUrl": { "message": "익스플로러 URL 차단 (선택 사항)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Symbol (선택)" }, "orderOneHere": { diff --git a/app/_locales/lt/messages.json b/app/_locales/lt/messages.json index 4706d4e22..b8596bc82 100644 --- a/app/_locales/lt/messages.json +++ b/app/_locales/lt/messages.json @@ -734,7 +734,7 @@ "optionalBlockExplorerUrl": { "message": "Blokuoti naršyklės URL (pasirinktinai)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Simbolis (nebūtinas)" }, "orderOneHere": { diff --git a/app/_locales/lv/messages.json b/app/_locales/lv/messages.json index 64a48dac8..f3362994c 100644 --- a/app/_locales/lv/messages.json +++ b/app/_locales/lv/messages.json @@ -730,7 +730,7 @@ "optionalBlockExplorerUrl": { "message": "Bloķēt Explorer URL (pēc izvēles)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Simbols (neobligāti)" }, "orderOneHere": { diff --git a/app/_locales/ms/messages.json b/app/_locales/ms/messages.json index 010392658..04eeb3342 100644 --- a/app/_locales/ms/messages.json +++ b/app/_locales/ms/messages.json @@ -711,7 +711,7 @@ "optionalBlockExplorerUrl": { "message": "Sekat URL Explorer (pilihan)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Simbol (pilihan)" }, "orderOneHere": { diff --git a/app/_locales/no/messages.json b/app/_locales/no/messages.json index ffc04048b..18ef48537 100644 --- a/app/_locales/no/messages.json +++ b/app/_locales/no/messages.json @@ -721,7 +721,7 @@ "optionalBlockExplorerUrl": { "message": "Blokker Explorer URL (valgfritt)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Symbol (valgfritt)" }, "orderOneHere": { diff --git a/app/_locales/pl/messages.json b/app/_locales/pl/messages.json index 2d1e6484a..4ad06b5df 100644 --- a/app/_locales/pl/messages.json +++ b/app/_locales/pl/messages.json @@ -728,7 +728,7 @@ "optionalBlockExplorerUrl": { "message": "Adres URL przeglądarki łańcucha bloków (opcjonalnie)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Symbol (opcjonalnie)" }, "orderOneHere": { diff --git a/app/_locales/pt_BR/messages.json b/app/_locales/pt_BR/messages.json index 1a98307b0..04debdecf 100644 --- a/app/_locales/pt_BR/messages.json +++ b/app/_locales/pt_BR/messages.json @@ -722,7 +722,7 @@ "optionalBlockExplorerUrl": { "message": "URL exploradora de blocos (opcional)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Símbolo (opcional)" }, "orderOneHere": { diff --git a/app/_locales/ro/messages.json b/app/_locales/ro/messages.json index a2469af1d..8f0997e65 100644 --- a/app/_locales/ro/messages.json +++ b/app/_locales/ro/messages.json @@ -721,7 +721,7 @@ "optionalBlockExplorerUrl": { "message": "URL explorator bloc (opțional)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Simbol (opțional)" }, "orderOneHere": { diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json index 307e638eb..e2927be2a 100644 --- a/app/_locales/ru/messages.json +++ b/app/_locales/ru/messages.json @@ -763,7 +763,7 @@ "optionalBlockExplorerUrl": { "message": "URL блок-эксплорера (необязательно)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Символ (необязательно)" }, "orderOneHere": { diff --git a/app/_locales/sk/messages.json b/app/_locales/sk/messages.json index fa7860ca4..718e32616 100644 --- a/app/_locales/sk/messages.json +++ b/app/_locales/sk/messages.json @@ -703,7 +703,7 @@ "optionalBlockExplorerUrl": { "message": "Blokovať URL Explorera (voliteľné)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Symbol (voliteľné)" }, "orderOneHere": { diff --git a/app/_locales/sl/messages.json b/app/_locales/sl/messages.json index 10ef7ee0a..cf1b3ad00 100644 --- a/app/_locales/sl/messages.json +++ b/app/_locales/sl/messages.json @@ -719,7 +719,7 @@ "optionalBlockExplorerUrl": { "message": "Blokiraj URL Explorerja (poljubno)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Simbol (nezahtevano)" }, "orderOneHere": { diff --git a/app/_locales/sr/messages.json b/app/_locales/sr/messages.json index d07bacfa1..730f4b5e4 100644 --- a/app/_locales/sr/messages.json +++ b/app/_locales/sr/messages.json @@ -725,7 +725,7 @@ "optionalBlockExplorerUrl": { "message": "Blokirajte URL Explorer-a (opciono)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Simbol (opciono)" }, "orderOneHere": { diff --git a/app/_locales/sv/messages.json b/app/_locales/sv/messages.json index 4fb6bfe1e..bb5e8e5a5 100644 --- a/app/_locales/sv/messages.json +++ b/app/_locales/sv/messages.json @@ -718,7 +718,7 @@ "optionalBlockExplorerUrl": { "message": "Block Explorer URL (valfritt)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Symbol (frivillig)" }, "orderOneHere": { diff --git a/app/_locales/sw/messages.json b/app/_locales/sw/messages.json index 61203f047..4244565b8 100644 --- a/app/_locales/sw/messages.json +++ b/app/_locales/sw/messages.json @@ -712,7 +712,7 @@ "optionalBlockExplorerUrl": { "message": "URL ya Block Explorer URL (hiari)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Ishara (hiari)" }, "orderOneHere": { diff --git a/app/_locales/uk/messages.json b/app/_locales/uk/messages.json index 70a9b0c36..958376615 100644 --- a/app/_locales/uk/messages.json +++ b/app/_locales/uk/messages.json @@ -734,7 +734,7 @@ "optionalBlockExplorerUrl": { "message": "Блокувати Explorer URL (не обов'язково)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Символ (не обов'язково)" }, "orderOneHere": { diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json index 5dfed18d1..493c98310 100644 --- a/app/_locales/zh_CN/messages.json +++ b/app/_locales/zh_CN/messages.json @@ -716,7 +716,7 @@ "optionalBlockExplorerUrl": { "message": "屏蔽管理器 URL(选填)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "符号(选填)" }, "orderOneHere": { diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json index c34a0411f..c2cad7c58 100644 --- a/app/_locales/zh_TW/messages.json +++ b/app/_locales/zh_TW/messages.json @@ -725,7 +725,7 @@ "optionalBlockExplorerUrl": { "message": "區塊鏈瀏覽器 URL(非必要)" }, - "optionalSymbol": { + "optionalCurrencySymbol": { "message": "Symbol (可選)" }, "orderOneHere": { diff --git a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js index 47b9b09cf..83d506420 100644 --- a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js +++ b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js @@ -35,7 +35,7 @@ export default class NetworkForm extends PureComponent { state = { rpcUrl: this.props.rpcUrl, - chainId: this.props.chainId, + chainId: this.getDisplayChainIdFromProps(), ticker: this.props.ticker, networkName: this.props.networkName, blockExplorerUrl: this.props.blockExplorerUrl, @@ -49,7 +49,6 @@ export default class NetworkForm extends PureComponent { } = prevProps const { rpcUrl, - chainId, ticker, networkName, networksTabIsInAddMode, @@ -68,7 +67,7 @@ export default class NetworkForm extends PureComponent { } else if (prevRpcUrl !== rpcUrl) { this.setState({ rpcUrl, - chainId, + chainId: this.getDisplayChainIdFromProps(), ticker, networkName, blockExplorerUrl, @@ -94,17 +93,11 @@ export default class NetworkForm extends PureComponent { } resetForm() { - const { - rpcUrl, - chainId, - ticker, - networkName, - blockExplorerUrl, - } = this.props + const { rpcUrl, ticker, networkName, blockExplorerUrl } = this.props this.setState({ rpcUrl, - chainId, + chainId: this.getDisplayChainIdFromProps(), ticker, networkName, blockExplorerUrl, @@ -112,6 +105,28 @@ export default class NetworkForm extends PureComponent { }) } + /** + * Ensures that the chainId is always displayed in decimal, even though + * it's stored in hexadecimal. + * + * Should be called to get the chainId whenever props are used to set the + * component's state. + * + * @returns {string} The props chainId in decimal. + */ + getDisplayChainIdFromProps() { + const { chainId: propsChainId } = this.props + + if ( + !propsChainId || + typeof propsChainId !== 'string' || + !propsChainId.startsWith('0x') + ) { + return propsChainId + } + return new BigNumber(propsChainId, 16).toString(10) + } + onSubmit = async () => { const { setRpcTarget, @@ -129,13 +144,14 @@ export default class NetworkForm extends PureComponent { blockExplorerUrl, } = this.state + const formChainId = stateChainId.trim().toLowerCase() // Ensure chainId is a 0x-prefixed, lowercase hex string - let chainId = stateChainId.trim().toLowerCase() + let chainId = formChainId if (!chainId.startsWith('0x')) { chainId = `0x${new BigNumber(chainId, 10).toString(16)}` } - if (!(await this.validateChainIdOnSubmit(chainId, rpcUrl))) { + if (!(await this.validateChainIdOnSubmit(formChainId, chainId, rpcUrl))) { return } @@ -153,6 +169,10 @@ export default class NetworkForm extends PureComponent { if (networksTabIsInAddMode) { onClear() + } else { + this.setState({ + chainId: this.getDisplayChainIdFromProps(), + }) } } @@ -178,13 +198,7 @@ export default class NetworkForm extends PureComponent { } stateIsUnchanged() { - const { - rpcUrl, - chainId, - ticker, - networkName, - blockExplorerUrl, - } = this.props + const { rpcUrl, ticker, networkName, blockExplorerUrl } = this.props const { rpcUrl: stateRpcUrl, @@ -196,7 +210,7 @@ export default class NetworkForm extends PureComponent { return ( stateRpcUrl === rpcUrl && - stateChainId === chainId && + stateChainId === this.getDisplayChainIdFromProps() && stateTicker === ticker && stateNetworkName === networkName && stateBlockExplorerUrl === blockExplorerUrl @@ -260,7 +274,7 @@ export default class NetworkForm extends PureComponent { }) } - validateChainId = (chainIdArg = '') => { + validateChainIdOnChange = (chainIdArg = '') => { const chainId = chainIdArg.trim() let errorMessage = '' @@ -279,7 +293,17 @@ export default class NetworkForm extends PureComponent { this.setErrorTo('chainId', errorMessage) } - validateChainIdOnSubmit = async (chainId, rpcUrl) => { + /** + * Validates the chain ID by checking it against the `eth_chainId` return + * value from the given RPC URL. + * Assumes that all strings are non-empty and correctly formatted. + * + * @param {string} formChainId - Non-empty, hex or decimal number string from + * the form. + * @param {string} parsedChainId - The parsed, hex string chain ID. + * @param {string} rpcUrl - The RPC URL from the form. + */ + validateChainIdOnSubmit = async (formChainId, parsedChainId, rpcUrl) => { const { t } = this.context let errorMessage let endpointChainId @@ -294,7 +318,22 @@ export default class NetworkForm extends PureComponent { if (providerError || typeof endpointChainId !== 'string') { errorMessage = t('failedToFetchChainId') - } else if (chainId !== endpointChainId) { + } else if (parsedChainId !== endpointChainId) { + // Here, we are in an error state. The endpoint should always return a + // hexadecimal string. If the user entered a decimal string, we attempt + // to convert the endpoint's return value to decimal before rendering it + // in an error message in the form. + if (!formChainId.startsWith('0x')) { + try { + endpointChainId = new BigNumber(endpointChainId, 16).toString(10) + } catch (err) { + log.warn( + 'Failed to convert endpoint chain ID to decimal', + endpointChainId, + ) + } + } + errorMessage = t('endpointReturnedDifferentChainId', [ endpointChainId.length <= 12 ? endpointChainId @@ -394,17 +433,17 @@ export default class NetworkForm extends PureComponent { {this.renderFormTextField( 'chainId', 'chainId', - this.setStateWithValue('chainId', this.validateChainId), + this.setStateWithValue('chainId', this.validateChainIdOnChange), chainId, null, - t('networkSettingsChainIdDescription'), + viewOnly ? null : t('networkSettingsChainIdDescription'), )} {this.renderFormTextField( 'symbol', 'network-ticker', this.setStateWithValue('ticker'), ticker, - 'optionalSymbol', + 'optionalCurrencySymbol', )} {this.renderFormTextField( 'blockExplorerUrl',