Kill walletconnect session on disconnect

This commit is contained in:
mmv 2019-10-25 15:17:54 +04:00
parent e0ae8c5645
commit beae72c471

View File

@ -2,6 +2,7 @@
import { createAction } from 'redux-actions'
import type { Dispatch as ReduxDispatch } from 'redux'
import { NOTIFICATIONS, showSnackbar } from '~/logic/notifications'
import { getWeb3 } from '~/logic/wallets/getWeb3'
export const REMOVE_PROVIDER = 'REMOVE_PROVIDER'
@ -10,9 +11,11 @@ const removeProvider = createAction<string, *, *>(REMOVE_PROVIDER)
export default (enqueueSnackbar: Function, closeSnackbar: Function) => (dispatch: ReduxDispatch<*>) => {
showSnackbar(NOTIFICATIONS.WALLET_DISCONNECTED_MSG, enqueueSnackbar, closeSnackbar)
// remove info about current wallet connect session on disconnect so it's not used later
// TODO: use a method for killing the session from web3connect when they provide one
localStorage.removeItem('walletconnect')
const web3 = getWeb3()
if (web3.currentProvider && web3.currentProvider.close) {
web3.currentProvider.close()
}
dispatch(removeProvider())
}