Commit f349ecdd authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

chore: remove selectedWalletBackfilled (#4283)

* remove selectedWalletBackfilled

* FIX
parent 57fb481d
...@@ -35,6 +35,7 @@ Cypress.Commands.overwrite( ...@@ -35,6 +35,7 @@ Cypress.Commands.overwrite(
onBeforeLoad(win) { onBeforeLoad(win) {
options?.onBeforeLoad?.(win) options?.onBeforeLoad?.(win)
win.localStorage.clear() win.localStorage.clear()
win.localStorage.setItem('redux_localstorage_simple_user', '{"selectedWallet":"INJECTED"}')
win.ethereum = injected win.ethereum = injected
}, },
}) })
......
...@@ -2,7 +2,6 @@ import { Connector } from '@web3-react/types' ...@@ -2,7 +2,6 @@ import { Connector } from '@web3-react/types'
import { gnosisSafeConnection, networkConnection } from 'connection' import { gnosisSafeConnection, networkConnection } from 'connection'
import { getConnection } from 'connection/utils' import { getConnection } from 'connection/utils'
import { useEffect } from 'react' import { useEffect } from 'react'
import { BACKFILLABLE_WALLETS } from 'state/connection/constants'
import { useAppSelector } from 'state/hooks' import { useAppSelector } from 'state/hooks'
async function connect(connector: Connector) { async function connect(connector: Connector) {
...@@ -18,7 +17,6 @@ async function connect(connector: Connector) { ...@@ -18,7 +17,6 @@ async function connect(connector: Connector) {
} }
export default function useEagerlyConnect() { export default function useEagerlyConnect() {
const selectedWalletBackfilled = useAppSelector((state) => state.user.selectedWalletBackfilled)
const selectedWallet = useAppSelector((state) => state.user.selectedWallet) const selectedWallet = useAppSelector((state) => state.user.selectedWallet)
useEffect(() => { useEffect(() => {
...@@ -27,11 +25,6 @@ export default function useEagerlyConnect() { ...@@ -27,11 +25,6 @@ export default function useEagerlyConnect() {
if (selectedWallet) { if (selectedWallet) {
connect(getConnection(selectedWallet).connector) connect(getConnection(selectedWallet).connector)
} else if (!selectedWalletBackfilled) { } // The dependency list is empty so this is only run once on mount
BACKFILLABLE_WALLETS.map(getConnection)
.map((connection) => connection.connector)
.forEach(connect)
}
// The dependency list is empty so this is only run once on mount
}, []) // eslint-disable-line react-hooks/exhaustive-deps }, []) // eslint-disable-line react-hooks/exhaustive-deps
} }
import { ConnectionType } from 'connection' import { ConnectionType } from 'connection'
import { getConnection } from 'connection/utils' import { getConnection } from 'connection/utils'
import { useMemo } from 'react' import { useMemo } from 'react'
import { BACKFILLABLE_WALLETS } from 'state/connection/constants'
import { useAppSelector } from 'state/hooks' import { useAppSelector } from 'state/hooks'
const SELECTABLE_WALLETS = [...BACKFILLABLE_WALLETS, ConnectionType.FORTMATIC] const SELECTABLE_WALLETS = [
ConnectionType.INJECTED,
ConnectionType.COINBASE_WALLET,
ConnectionType.WALLET_CONNECT,
ConnectionType.FORTMATIC,
]
export default function useOrderedConnections() { export default function useOrderedConnections() {
const selectedWallet = useAppSelector((state) => state.user.selectedWallet) const selectedWallet = useAppSelector((state) => state.user.selectedWallet)
......
import { ConnectionType } from 'connection'
export const BACKFILLABLE_WALLETS = [
ConnectionType.INJECTED,
ConnectionType.COINBASE_WALLET,
ConnectionType.WALLET_CONNECT,
]
...@@ -9,11 +9,6 @@ import { SerializedPair, SerializedToken } from './types' ...@@ -9,11 +9,6 @@ import { SerializedPair, SerializedToken } from './types'
const currentTimestamp = () => new Date().getTime() const currentTimestamp = () => new Date().getTime()
export interface UserState { export interface UserState {
// We want the user to be able to define which wallet they want to use, even if there are multiple connected wallets via web3-react.
// If a user had previously connected a wallet but didn't have a wallet override set (because they connected prior to this field being added),
// we want to handle that case by backfilling them manually. Once we backfill, we set the backfilled field to `true`.
// After some period of time, our active users will have this property set so we can likely remove the backfilling logic.
selectedWalletBackfilled: boolean
selectedWallet?: ConnectionType selectedWallet?: ConnectionType
// the timestamp of the last updateVersion action // the timestamp of the last updateVersion action
...@@ -66,7 +61,6 @@ function pairKey(token0Address: string, token1Address: string) { ...@@ -66,7 +61,6 @@ function pairKey(token0Address: string, token1Address: string) {
export const initialState: UserState = { export const initialState: UserState = {
selectedWallet: undefined, selectedWallet: undefined,
selectedWalletBackfilled: false,
matchesDarkMode: false, matchesDarkMode: false,
userDarkMode: null, userDarkMode: null,
userExpertMode: false, userExpertMode: false,
...@@ -90,7 +84,6 @@ const userSlice = createSlice({ ...@@ -90,7 +84,6 @@ const userSlice = createSlice({
reducers: { reducers: {
updateSelectedWallet(state, { payload: { wallet } }) { updateSelectedWallet(state, { payload: { wallet } }) {
state.selectedWallet = wallet state.selectedWallet = wallet
state.selectedWalletBackfilled = true
}, },
updateUserDarkMode(state, action) { updateUserDarkMode(state, action) {
state.userDarkMode = action.payload.userDarkMode state.userDarkMode = action.payload.userDarkMode
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment