1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00

Return Promise from editRpc thunk (#8441)

`editRpc` returned a thunk that didn't return a Promise, despite doing
async work. It now returns a Promise.

In the one place where this is used, it didn't seem important to update
the callsite to block on this finishing. Only one call followed it in
the event handler, and it didn't seem to depend on this.
This commit is contained in:
Mark Stacey 2020-04-28 13:56:35 -03:00 committed by GitHub
commit 627fc2f93c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1464,25 +1464,30 @@ export function updateAndSetCustomRpc (newRpc, chainId, ticker = 'ETH', nickname
} }
export function editRpc (oldRpc, newRpc, chainId, ticker = 'ETH', nickname, rpcPrefs) { export function editRpc (oldRpc, newRpc, chainId, ticker = 'ETH', nickname, rpcPrefs) {
return (dispatch) => { return async (dispatch) => {
log.debug(`background.delRpcTarget: ${oldRpc}`) log.debug(`background.delRpcTarget: ${oldRpc}`)
background.delCustomRpc(oldRpc, (err) => { try {
if (err) { promisifiedBackground.delCustomRpc(oldRpc)
log.error(err) } catch (error) {
return dispatch(displayWarning('Had a problem removing network!')) log.error(error)
dispatch(displayWarning('Had a problem removing network!'))
return
} }
dispatch(setSelectedToken()) dispatch(setSelectedToken())
background.updateAndSetCustomRpc(newRpc, chainId, ticker, nickname || newRpc, rpcPrefs, (err) => {
if (err) { try {
log.error(err) await promisifiedBackground.updateAndSetCustomRpc(newRpc, chainId, ticker, nickname || newRpc, rpcPrefs)
return dispatch(displayWarning('Had a problem changing networks!')) } catch (error) {
log.error(error)
dispatch(displayWarning('Had a problem changing networks!'))
return
} }
dispatch({ dispatch({
type: actionConstants.SET_RPC_TARGET, type: actionConstants.SET_RPC_TARGET,
value: newRpc, value: newRpc,
}) })
})
})
} }
} }