diff options
author | Frankie <frankie.diamond@gmail.com> | 2019-01-30 02:13:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-30 02:13:51 +0800 |
commit | df3169d1c7250d13bb8bc123dc91f7913ad75a81 (patch) | |
tree | 266721dc67ae2079543f9ba78e7c546e24f1d068 /ui/app/actions.js | |
parent | 98d5b4d63217094db9dfc535d0baaed7f8ab0520 (diff) | |
download | tangerine-wallet-browser-df3169d1c7250d13bb8bc123dc91f7913ad75a81.tar tangerine-wallet-browser-df3169d1c7250d13bb8bc123dc91f7913ad75a81.tar.gz tangerine-wallet-browser-df3169d1c7250d13bb8bc123dc91f7913ad75a81.tar.bz2 tangerine-wallet-browser-df3169d1c7250d13bb8bc123dc91f7913ad75a81.tar.lz tangerine-wallet-browser-df3169d1c7250d13bb8bc123dc91f7913ad75a81.tar.xz tangerine-wallet-browser-df3169d1c7250d13bb8bc123dc91f7913ad75a81.tar.zst tangerine-wallet-browser-df3169d1c7250d13bb8bc123dc91f7913ad75a81.zip |
I#5956 fix2 dont overwrite existing rpc settings (#6044)
* mm-controller - dont overwrite existing rpc settings
* ui-networkDropdown - dont pass old network as chainId
* add methods preferencesController.updateRpc and metamaskController.updateAndSetCustomRpc
* use updateAndSetCustomRpc in settings to allow rpcs to be updated
* use new rpc as nickname if no nick name has been supplied
* fix update rpc method
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r-- | ui/app/actions.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index c2622d0a0..2b073e915 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -242,6 +242,7 @@ var actions = { removeSuggestedTokens, addKnownMethodData, UPDATE_TOKENS: 'UPDATE_TOKENS', + updateAndSetCustomRpc: updateAndSetCustomRpc, setRpcTarget: setRpcTarget, delRpcTarget: delRpcTarget, setProviderType: setProviderType, @@ -1971,10 +1972,26 @@ function setPreviousProvider (type) { } } -function setRpcTarget (newRpc, chainId, ticker = 'ETH', nickname = '') { +function updateAndSetCustomRpc (newRpc, chainId, ticker = 'ETH', nickname) { + return (dispatch) => { + log.debug(`background.updateAndSetCustomRpc: ${newRpc} ${chainId} ${ticker} ${nickname}`) + background.updateAndSetCustomRpc(newRpc, chainId, ticker, nickname || newRpc, (err, result) => { + if (err) { + log.error(err) + return dispatch(actions.displayWarning('Had a problem changing networks!')) + } + dispatch({ + type: actions.SET_RPC_TARGET, + value: newRpc, + }) + }) + } +} + +function setRpcTarget (newRpc, chainId, ticker = 'ETH', nickname) { return (dispatch) => { log.debug(`background.setRpcTarget: ${newRpc} ${chainId} ${ticker} ${nickname}`) - background.setCustomRpc(newRpc, chainId, ticker, nickname, (err, result) => { + background.setCustomRpc(newRpc, chainId, ticker, nickname || newRpc, (err, result) => { if (err) { log.error(err) return dispatch(actions.displayWarning('Had a problem changing networks!')) |