From d23b504eb29207d0eae92d70cb80272e9552ac50 Mon Sep 17 00:00:00 2001 From: Suncheol Kwon Date: Mon, 3 Apr 2023 22:18:32 +0900 Subject: [PATCH 1/4] Add Select RPC Node Function and Locale --- config/default.json | 54 +++++++++++++++++---- src/app/Main.js | 12 ++++- src/app/components/modules/Settings.jsx | 63 ++++++++++++++++++++++++- src/app/locales/en.json | 4 +- src/app/locales/es.json | 5 +- src/app/locales/fr.json | 5 +- src/app/locales/it.json | 5 +- src/app/locales/ja.json | 5 +- src/app/locales/ko.json | 5 +- src/app/locales/pl.json | 5 +- src/app/locales/ru.json | 5 +- src/app/locales/zh.json | 5 +- src/app/redux/AppReducer.js | 1 + src/server/index.js | 1 + 14 files changed, 154 insertions(+), 21 deletions(-) diff --git a/config/default.json b/config/default.json index 292cd9e5f..7949a6226 100644 --- a/config/default.json +++ b/config/default.json @@ -14,14 +14,15 @@ "imgSrc": "* data:", "objectSrc": "'none'", "pluginTypes": "application/pdf", - "scriptSrc": "'self' www.google-analytics.com staticfiles.steemit.com localhost:8080", + "scriptSrc": + "'self' www.google-analytics.com staticfiles.steemit.com localhost:8080", "styleSrc": "'self' 'unsafe-inline' fonts.googleapis.com", "reportUri": "/api/v1/csp_violation" }, "reportOnly": false, "setAllHeaders": true }, - "img_proxy_prefix": "https://steemitdevimages.com/", + "img_proxy_prefix": "https://steemitimages.com/", "ipfs_prefix": false, "mixpanel": false, "newrelic": false, @@ -72,6 +73,38 @@ "upload_image": false, "steemd_connection_client": "https://api.steemit.com", "steemd_connection_server": "https://api.steemit.com", + "rpc_list": [ + "https://api.steemit.com", + "https://api.steemitdev.com", + // "https://api.upvu.org", + // "https://api.supporter.dev", + "https://api.steem.fans", + "https://steem.61bts.com", + // "https://steemyy.com/node/", + "https://api.steemyy.com", + // "https://api.dlike.io", + "https://cn.steems.top", + // "https://api.steem-fanbase.com", + // "https://fullsteem.3dkrender.com", + "https://api.steems.top", + // "https://api.steemzzang.com", + // "https://api.symbionts.io", + // "https://steemd.steemworld.org", + "https://api.wherein.io", + // "https://api.steememory.com", + // "https://api.cotina.org", + "https://justyy.azurewebsites.net/api/steem", + // "https://steemapi.3dkrender.com", + "https://api.justyy.com", + // "https://api.protoss20.com", + "https://steemapi.boylikegirl.club", + // "https://api.pennsif.net", + // "https://rpc.amarbangla.net", + "https://api.steem.buzz" + // "https://steem.senior.workers.dev", + // "https://api.campingclub.me", + // "https://api.blokfield.io" + ], "steemd_use_appbase": false, "chain_id": "0000000000000000000000000000000000000000000000000000000000000000", @@ -80,21 +113,22 @@ "conveyor_username": false, "social_url": "https://steemit.com", "tron_reward": { - "switch": "on", - "vests_per_trx": 10000, - "unbind_tip_limit": 5 + "switch": "on", + "vests_per_trx": 10000, + "unbind_tip_limit": 5 }, "redis_url": "redis://127.0.0.1:6379", "redis_env": "develop", - "tron_create_key": "ade06c9d42d42c7e24bf93dcbb0a481193a6869400ddee21855d4cf585eaad8a", + "tron_create_key": + "ade06c9d42d42c7e24bf93dcbb0a481193a6869400ddee21855d4cf585eaad8a", "tron_create_node": "https://api.shasta.trongrid.io", - "tron_create_address":"xxxxx", - "white_list":"steemit.com localhost steemit-sdc 127.0.0.1", + "tron_create_address": "xxxxx", + "white_list": "steemit.com localhost steemit-sdc 127.0.0.1", "steem_market_endpoint": "http://34.196.9.171", "steem_market_token": "xxxx", "steem_market_cache": { - "ttl": 7200, - "key": "steem-market" + "ttl": 7200, + "key": "steem-market" }, "internal_api_token": "xxxx", "steem_whale": 10000, diff --git a/src/app/Main.js b/src/app/Main.js index f86a82195..94f330b6f 100644 --- a/src/app/Main.js +++ b/src/app/Main.js @@ -32,8 +32,18 @@ function runApp(initial_state) { console.log('Initial state', initial_state); const config = initial_state.offchain.config; + + const steemSelectedRpc = localStorage.getItem('steemSelectedRpc'); + + if (steemSelectedRpc) { + localStorage.setItem( + 'steemSelectedRpc', + config.steemd_connection_client + ); + } + steem.api.setOptions({ - url: config.steemd_connection_client, + url: steemSelectedRpc || config.steemd_connection_client, retry: true, useAppbaseApi: !!config.steemd_use_appbase, }); diff --git a/src/app/components/modules/Settings.jsx b/src/app/components/modules/Settings.jsx index f4464d365..d2b848a2a 100644 --- a/src/app/components/modules/Settings.jsx +++ b/src/app/components/modules/Settings.jsx @@ -2,9 +2,43 @@ import React from 'react'; import { connect } from 'react-redux'; import tt from 'counterpart'; import * as appActions from 'app/redux/AppReducer'; -import o2j from 'shared/clash/object2json'; +import * as steem from '@steemit/steem-js'; class Settings extends React.Component { + constructor() { + super(); + } + + validateUrlFormat(url) { + if (!url) return false; + if (!/^https?:\/\//.test(url)) return false; + return true; + } + + handleSelectRPCNode = event => { + const selectedUrl = event.target.value; + + if (this.validateUrlFormat(selectedUrl) === false) { + this.setState({ + rpcError: tt('settings_jsx.invalid_url'), + }); + return; + } + + this.props.setUserPreferences({ + ...this.props.user_preferences, + selectedRpc: selectedUrl, + }); + + // Set RPC Node + localStorage.setItem('steemSelectedRpc', selectedUrl); + + // Set at the same time as selection + steem.api.setOptions({ + url: selectedUrl, + }); + }; + handleLanguageChange = event => { const locale = event.target.value; const userPreferences = { ...this.props.user_preferences, locale }; @@ -15,6 +49,33 @@ class Settings extends React.Component { const { user_preferences } = this.props; return (
+
+
+
+
+

{tt('settings_jsx.rpc_title')}

+ + +
+
+
+

{tt('settings_jsx.preferences')}

diff --git a/src/app/locales/en.json b/src/app/locales/en.json index 97c02b8a3..ef266109b 100644 --- a/src/app/locales/en.json +++ b/src/app/locales/en.json @@ -875,7 +875,9 @@ "profile_about": "About", "profile_location": "Location", "profile_website": "Website", - "saved": "Saved!" + "saved": "Saved!", + "rpc_title": "RPC Node List", + "rpc_select": "Select RPC Node" }, "transfer_jsx": { "amount_is_in_form": "Amount is in the form 99999.999", diff --git a/src/app/locales/es.json b/src/app/locales/es.json index 84cca5350..f3328abd3 100644 --- a/src/app/locales/es.json +++ b/src/app/locales/es.json @@ -653,7 +653,10 @@ "profile_name": "Nombre de visualización", "profile_about": "Sobre", "profile_location": "Localización", - "profile_website": "Página Web" + "profile_website": "Página Web", + "saved": "salvado!", + "rpc_title": "RPC Node List", + "rpc_select": "RPC Node seleccionar" }, "transfer_jsx": { "amount_is_in_form": "La cantidad está en el formato 99999.999", diff --git a/src/app/locales/fr.json b/src/app/locales/fr.json index b397ab3fd..f4fdee49b 100644 --- a/src/app/locales/fr.json +++ b/src/app/locales/fr.json @@ -675,7 +675,10 @@ "profile_name": "Nom à afficher", "profile_about": "A propos", "profile_location": "Lieu", - "profile_website": "Site internet" + "profile_website": "Site internet", + "saved": "enregistré!", + "rpc_title": "RPC Node List", + "rpc_select": "RPC Node sélectionner" }, "transfer_jsx": { "amount_is_in_form": "Montant dans le format 99999.999", diff --git a/src/app/locales/it.json b/src/app/locales/it.json index 6a7cf80fd..14b4d70e4 100644 --- a/src/app/locales/it.json +++ b/src/app/locales/it.json @@ -665,7 +665,10 @@ "profile_name": "Mostra nome", "profile_about": "About", "profile_location": "Località", - "profile_website": "Sito" + "profile_website": "Sito", + "saved": "salvato!", + "rpc_title": "RPC Node List", + "rpc_select": "RPC Node Selezionare" }, "transfer_jsx": { "amount_is_in_form": "La quantita deve essere della forma 99999.999", diff --git a/src/app/locales/ja.json b/src/app/locales/ja.json index e2d7998a1..ab2698086 100644 --- a/src/app/locales/ja.json +++ b/src/app/locales/ja.json @@ -654,7 +654,10 @@ "profile_name": "表示名", "profile_about": "概要", "profile_location": "場所", - "profile_website": "ウェブサイト" + "profile_website": "ウェブサイト", + "saved": "保存済み!", + "rpc_title": "RPC Node List", + "rpc_select": "RPC Node 選択" }, "transfer_jsx": { "amount_is_in_form": "金額は99999.999の形式です", diff --git a/src/app/locales/ko.json b/src/app/locales/ko.json index ac6d307f7..e66832ae0 100644 --- a/src/app/locales/ko.json +++ b/src/app/locales/ko.json @@ -655,7 +655,10 @@ "profile_name": "닉네임", "profile_about": "한 줄 소개", "profile_location": "지역", - "profile_website": "웹사이트" + "profile_website": "웹사이트", + "saved": "저장됨!", + "rpc_title": "RPC Node List", + "rpc_select": "RPC Node 선택" }, "transfer_jsx": { "amount_is_in_form": "Amount is in the form 99999.999", diff --git a/src/app/locales/pl.json b/src/app/locales/pl.json index c42b8bb8a..e5cd5995f 100644 --- a/src/app/locales/pl.json +++ b/src/app/locales/pl.json @@ -642,7 +642,10 @@ "profile_name": "Wyświetlana nazwa", "profile_about": "Opis", "profile_location": "Lokalizacja", - "profile_website": "Strona www" + "profile_website": "Strona www", + "saved": "zapisane!", + "rpc_title": "RPC Node List", + "rpc_select": "RPC Node wybierać" }, "transfer_jsx": { "amount_is_in_form": "Podana kwota musi być w formacie 99999.999", diff --git a/src/app/locales/ru.json b/src/app/locales/ru.json index 2d2d9d0da..da4c956ab 100644 --- a/src/app/locales/ru.json +++ b/src/app/locales/ru.json @@ -674,7 +674,10 @@ "profile_name": "Отображаемое имя", "profile_about": "О себе", "profile_location": "Местоположение", - "profile_website": "Веб-сайт" + "profile_website": "Веб-сайт", + "saved": "сохранен!", + "rpc_title": "RPC Node List", + "rpc_select": "RPC Node выбирать" }, "transfer_jsx": { "amount_is_in_form": "Сумма должна быть в формате 99999.999", diff --git a/src/app/locales/zh.json b/src/app/locales/zh.json index ff6296c80..d284f9704 100644 --- a/src/app/locales/zh.json +++ b/src/app/locales/zh.json @@ -736,7 +736,10 @@ "profile_name": "显示名称", "profile_about": "关于", "profile_location": "位置", - "profile_website": "网站" + "profile_website": "网站", + "saved": "已保存", + "rpc_title": "RPC Node List", + "rpc_select": "RPC Node 选择" }, "transfer_jsx": { "amount_is_in_form": "金额以99999.999的形式出现", diff --git a/src/app/redux/AppReducer.js b/src/app/redux/AppReducer.js index a0c30079c..0b439888d 100644 --- a/src/app/redux/AppReducer.js +++ b/src/app/redux/AppReducer.js @@ -26,6 +26,7 @@ export const defaultState = Map({ user_preferences: Map({ locale: null, nightmode: false, + selectedRpc: '', }), featureFlags: Map({}), modalLoading: false, diff --git a/src/server/index.js b/src/server/index.js index 05efcad1f..6811750b5 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -20,6 +20,7 @@ global.$STM_Config = { fb_app: config.get('facebook_app_id'), steemd_connection_client: config.get('steemd_connection_client'), steemd_connection_server: config.get('steemd_connection_server'), + steemd_rpc_list: config.get('rpc_list'), steemd_use_appbase: config.get('steemd_use_appbase'), chain_id: config.get('chain_id'), address_prefix: config.get('address_prefix'), From 9989b61507cd042cad3ee70bc6c16b11da1d9d3d Mon Sep 17 00:00:00 2001 From: Suncheol Kwon Date: Tue, 18 Apr 2023 17:22:12 +0900 Subject: [PATCH 2/4] feat(app): Add Label Selected RPC Node Under Component Translations --- config/default.json | 18 +++++------ src/app/components/modules/Settings.jsx | 41 +++++++++++++++---------- src/app/locales/en.json | 3 +- src/app/locales/es.json | 3 +- src/app/locales/fr.json | 3 +- src/app/locales/it.json | 3 +- src/app/locales/ja.json | 3 +- src/app/locales/ko.json | 3 +- src/app/locales/pl.json | 3 +- src/app/locales/ru.json | 3 +- src/app/locales/zh.json | 3 +- 11 files changed, 50 insertions(+), 36 deletions(-) diff --git a/config/default.json b/config/default.json index 7949a6226..1cd17a1d3 100644 --- a/config/default.json +++ b/config/default.json @@ -6,16 +6,14 @@ "helmet": { "directives": { "childSrc": "'self'", - "connectSrc": - "'self' steemit.com https://api.steemit.com https://testnet.steemitdev.com www.googletagmanager.com www.google-analytics.com pagead2.googlesyndication.com googleads.g.doubleclick.net api.trongrid.io", + "connectSrc": "'self' steemit.com https://api.steemit.com https://testnet.steemitdev.com www.googletagmanager.com www.google-analytics.com pagead2.googlesyndication.com googleads.g.doubleclick.net api.trongrid.io", "defaultSrc": "'self'", "fontSrc": "data: fonts.gstatic.com", "frameAncestors": "'none'", "imgSrc": "* data:", "objectSrc": "'none'", "pluginTypes": "application/pdf", - "scriptSrc": - "'self' www.google-analytics.com staticfiles.steemit.com localhost:8080", + "scriptSrc": "'self' www.google-analytics.com staticfiles.steemit.com localhost:8080", "styleSrc": "'self' 'unsafe-inline' fonts.googleapis.com", "reportUri": "/api/v1/csp_violation" }, @@ -100,14 +98,15 @@ "https://steemapi.boylikegirl.club", // "https://api.pennsif.net", // "https://rpc.amarbangla.net", - "https://api.steem.buzz" + "https://api.steem.buzz", // "https://steem.senior.workers.dev", // "https://api.campingclub.me", - // "https://api.blokfield.io" + // "https://api.blokfield.io", + "https://api.futureshock.world", + "https://api.worldofxpilar.com" ], "steemd_use_appbase": false, - "chain_id": - "0000000000000000000000000000000000000000000000000000000000000000", + "chain_id": "0000000000000000000000000000000000000000000000000000000000000000", "address_prefix": "STM", "conveyor_posting_wif": false, "conveyor_username": false, @@ -119,8 +118,7 @@ }, "redis_url": "redis://127.0.0.1:6379", "redis_env": "develop", - "tron_create_key": - "ade06c9d42d42c7e24bf93dcbb0a481193a6869400ddee21855d4cf585eaad8a", + "tron_create_key": "ade06c9d42d42c7e24bf93dcbb0a481193a6869400ddee21855d4cf585eaad8a", "tron_create_node": "https://api.shasta.trongrid.io", "tron_create_address": "xxxxx", "white_list": "steemit.com localhost steemit-sdc 127.0.0.1", diff --git a/src/app/components/modules/Settings.jsx b/src/app/components/modules/Settings.jsx index d2b848a2a..4922144e8 100644 --- a/src/app/components/modules/Settings.jsx +++ b/src/app/components/modules/Settings.jsx @@ -5,8 +5,12 @@ import * as appActions from 'app/redux/AppReducer'; import * as steem from '@steemit/steem-js'; class Settings extends React.Component { - constructor() { + constructor(props) { super(); + + this.rpcNode = + (props.user_preferences && props.user_preferences.selectedRpc) || + $STM_Config.steemd_connection_client; } validateUrlFormat(url) { @@ -30,7 +34,7 @@ class Settings extends React.Component { selectedRpc: selectedUrl, }); - // Set RPC Node + // Store RPC Node in localStorage localStorage.setItem('steemSelectedRpc', selectedUrl); // Set at the same time as selection @@ -56,21 +60,24 @@ class Settings extends React.Component {

{tt('settings_jsx.rpc_title')}

+ +

diff --git a/src/app/locales/en.json b/src/app/locales/en.json index ef266109b..a2d732bc1 100644 --- a/src/app/locales/en.json +++ b/src/app/locales/en.json @@ -877,7 +877,8 @@ "profile_website": "Website", "saved": "Saved!", "rpc_title": "RPC Node List", - "rpc_select": "Select RPC Node" + "rpc_select": "Select RPC Node", + "selected_rpc": "Selected RPC Node : %(rpc)s" }, "transfer_jsx": { "amount_is_in_form": "Amount is in the form 99999.999", diff --git a/src/app/locales/es.json b/src/app/locales/es.json index f3328abd3..2037cccb4 100644 --- a/src/app/locales/es.json +++ b/src/app/locales/es.json @@ -656,7 +656,8 @@ "profile_website": "Página Web", "saved": "salvado!", "rpc_title": "RPC Node List", - "rpc_select": "RPC Node seleccionar" + "rpc_select": "RPC Node seleccionar", + "selected_rpc": "seleccionar RPC Node : %(rpc)s" }, "transfer_jsx": { "amount_is_in_form": "La cantidad está en el formato 99999.999", diff --git a/src/app/locales/fr.json b/src/app/locales/fr.json index f4fdee49b..e0b6dfe87 100644 --- a/src/app/locales/fr.json +++ b/src/app/locales/fr.json @@ -678,7 +678,8 @@ "profile_website": "Site internet", "saved": "enregistré!", "rpc_title": "RPC Node List", - "rpc_select": "RPC Node sélectionner" + "rpc_select": "RPC Node sélectionner", + "selected_rpc": "sélectionner RPC Node : %(rpc)s" }, "transfer_jsx": { "amount_is_in_form": "Montant dans le format 99999.999", diff --git a/src/app/locales/it.json b/src/app/locales/it.json index 14b4d70e4..a97b1d8b6 100644 --- a/src/app/locales/it.json +++ b/src/app/locales/it.json @@ -668,7 +668,8 @@ "profile_website": "Sito", "saved": "salvato!", "rpc_title": "RPC Node List", - "rpc_select": "RPC Node Selezionare" + "rpc_select": "RPC Node Selezionare", + "selected_rpc": "Selezionare RPC Node : %(rpc)s" }, "transfer_jsx": { "amount_is_in_form": "La quantita deve essere della forma 99999.999", diff --git a/src/app/locales/ja.json b/src/app/locales/ja.json index ab2698086..9062f3a26 100644 --- a/src/app/locales/ja.json +++ b/src/app/locales/ja.json @@ -657,7 +657,8 @@ "profile_website": "ウェブサイト", "saved": "保存済み!", "rpc_title": "RPC Node List", - "rpc_select": "RPC Node 選択" + "rpc_select": "RPC Node 選択", + "selected_rpc": "選択 RPC Node : %(rpc)s" }, "transfer_jsx": { "amount_is_in_form": "金額は99999.999の形式です", diff --git a/src/app/locales/ko.json b/src/app/locales/ko.json index e66832ae0..45bdab385 100644 --- a/src/app/locales/ko.json +++ b/src/app/locales/ko.json @@ -658,7 +658,8 @@ "profile_website": "웹사이트", "saved": "저장됨!", "rpc_title": "RPC Node List", - "rpc_select": "RPC Node 선택" + "rpc_select": "RPC Node 선택", + "selected_rpc": "선택된 RPC Node : %(rpc)s" }, "transfer_jsx": { "amount_is_in_form": "Amount is in the form 99999.999", diff --git a/src/app/locales/pl.json b/src/app/locales/pl.json index e5cd5995f..feba21e4d 100644 --- a/src/app/locales/pl.json +++ b/src/app/locales/pl.json @@ -645,7 +645,8 @@ "profile_website": "Strona www", "saved": "zapisane!", "rpc_title": "RPC Node List", - "rpc_select": "RPC Node wybierać" + "rpc_select": "RPC Node wybierać", + "selected_rpc": "Wybrany RPC Node : %(rpc)s" }, "transfer_jsx": { "amount_is_in_form": "Podana kwota musi być w formacie 99999.999", diff --git a/src/app/locales/ru.json b/src/app/locales/ru.json index da4c956ab..6b2767d76 100644 --- a/src/app/locales/ru.json +++ b/src/app/locales/ru.json @@ -677,7 +677,8 @@ "profile_website": "Веб-сайт", "saved": "сохранен!", "rpc_title": "RPC Node List", - "rpc_select": "RPC Node выбирать" + "rpc_select": "RPC Node выбирать", + "selected_rpc": "выбран RPC Node : %(rpc)s" }, "transfer_jsx": { "amount_is_in_form": "Сумма должна быть в формате 99999.999", diff --git a/src/app/locales/zh.json b/src/app/locales/zh.json index d284f9704..a2124b187 100644 --- a/src/app/locales/zh.json +++ b/src/app/locales/zh.json @@ -739,7 +739,8 @@ "profile_website": "网站", "saved": "已保存", "rpc_title": "RPC Node List", - "rpc_select": "RPC Node 选择" + "rpc_select": "RPC Node 选择", + "selected_rpc": "选择 RPC Node : %(rpc)s" }, "transfer_jsx": { "amount_is_in_form": "金额以99999.999的形式出现", From 38702dda23193d7363b5c05c03c585d4a1763d52 Mon Sep 17 00:00:00 2001 From: Suncheol Kwon Date: Fri, 21 Apr 2023 17:40:46 +0900 Subject: [PATCH 3/4] fix(app): Bug Fix/Update Settings.tsx component - Main.js Bug Fix(steemSelectedRpc => !steemSelectedRpc) - Set state(rpcNode, rpcError) - Show rpcError under component when invalid rpc url format --- config/default.json | 28 +++++++++++----------- src/app/Main.js | 2 +- src/app/components/modules/Settings.jsx | 32 +++++++++++++++---------- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/config/default.json b/config/default.json index 1cd17a1d3..7ef011fc8 100644 --- a/config/default.json +++ b/config/default.json @@ -74,36 +74,36 @@ "rpc_list": [ "https://api.steemit.com", "https://api.steemitdev.com", - // "https://api.upvu.org", - // "https://api.supporter.dev", "https://api.steem.fans", "https://steem.61bts.com", - // "https://steemyy.com/node/", "https://api.steemyy.com", - // "https://api.dlike.io", "https://cn.steems.top", + "https://api.steems.top", + "https://api.wherein.io", + "https://justyy.azurewebsites.net/api/steem", + "https://api.justyy.com", + "https://steemapi.boylikegirl.club", + "https://api.steem.buzz", + "https://api.futureshock.world", + "https://api.worldofxpilar.com" + // "https://api.pennsif.net", + // "https://api.upvu.org", + // "https://api.supporter.dev", + // "https://steemyy.com/node/", + // "https://api.dlike.io", // "https://api.steem-fanbase.com", // "https://fullsteem.3dkrender.com", - "https://api.steems.top", // "https://api.steemzzang.com", // "https://api.symbionts.io", // "https://steemd.steemworld.org", - "https://api.wherein.io", // "https://api.steememory.com", // "https://api.cotina.org", - "https://justyy.azurewebsites.net/api/steem", // "https://steemapi.3dkrender.com", - "https://api.justyy.com", // "https://api.protoss20.com", - "https://steemapi.boylikegirl.club", - // "https://api.pennsif.net", // "https://rpc.amarbangla.net", - "https://api.steem.buzz", // "https://steem.senior.workers.dev", // "https://api.campingclub.me", - // "https://api.blokfield.io", - "https://api.futureshock.world", - "https://api.worldofxpilar.com" + // "https://api.blokfield.io" ], "steemd_use_appbase": false, "chain_id": "0000000000000000000000000000000000000000000000000000000000000000", diff --git a/src/app/Main.js b/src/app/Main.js index 94f330b6f..2256c7013 100644 --- a/src/app/Main.js +++ b/src/app/Main.js @@ -35,7 +35,7 @@ function runApp(initial_state) { const steemSelectedRpc = localStorage.getItem('steemSelectedRpc'); - if (steemSelectedRpc) { + if (!steemSelectedRpc) { localStorage.setItem( 'steemSelectedRpc', config.steemd_connection_client diff --git a/src/app/components/modules/Settings.jsx b/src/app/components/modules/Settings.jsx index 4922144e8..70fe053db 100644 --- a/src/app/components/modules/Settings.jsx +++ b/src/app/components/modules/Settings.jsx @@ -8,9 +8,13 @@ class Settings extends React.Component { constructor(props) { super(); - this.rpcNode = - (props.user_preferences && props.user_preferences.selectedRpc) || - $STM_Config.steemd_connection_client; + this.state = { + rpcNode: + (props.user_preferences && + props.user_preferences.selectedRpc) || + $STM_Config.steemd_connection_client, + rpcError: '', + }; } validateUrlFormat(url) { @@ -27,6 +31,11 @@ class Settings extends React.Component { rpcError: tt('settings_jsx.invalid_url'), }); return; + } else { + this.setState({ + rpcNode: selectedUrl, + rpcError: '', + }); } this.props.setUserPreferences({ @@ -51,6 +60,8 @@ class Settings extends React.Component { render() { const { user_preferences } = this.props; + + const { rpcNode, rpcError } = this.state; return (
@@ -59,11 +70,9 @@ class Settings extends React.Component {

{tt('settings_jsx.rpc_title')}

- +

From 093d86bc6f47b7a15b6d54d6b2566987e6af3df9 Mon Sep 17 00:00:00 2001 From: Suncheol Kwon Date: Mon, 24 Apr 2023 15:19:49 +0900 Subject: [PATCH 4/4] (fix) url validation function --- src/app/components/modules/Settings.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/components/modules/Settings.jsx b/src/app/components/modules/Settings.jsx index 70fe053db..ae22d08c3 100644 --- a/src/app/components/modules/Settings.jsx +++ b/src/app/components/modules/Settings.jsx @@ -19,7 +19,12 @@ class Settings extends React.Component { validateUrlFormat(url) { if (!url) return false; - if (!/^https?:\/\//.test(url)) return false; + if ( + !/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/.test( + url + ) + ) + return false; return true; }