Merge branch 'development' into release/v3.4.0

This commit is contained in:
Daniel Sanchez 2021-04-12 13:53:06 +02:00
commit 6eb59f9d0f
10 changed files with 30 additions and 12 deletions

View File

@ -24,6 +24,7 @@ import {
safeTotalFiatBalanceSelector,
safeNameSelector,
safeParamAddressFromStateSelector,
safeLoadedViaUrlSelector,
} from 'src/logic/safe/store/selectors'
import { currentCurrencySelector } from 'src/logic/currencyValues/store/selectors'
import Modal from 'src/components/Modal'
@ -77,8 +78,8 @@ const App: React.FC = ({ children }) => {
const currentCurrency = useSelector(currentCurrencySelector)
const granted = useSelector(grantedSelector)
const sidebarItems = useSidebarItems()
const safeLoaded = useLoadSafe(safeAddress)
const isSafeLoadedViaUrl = useSelector(safeLoadedViaUrlSelector)
const safeLoaded = useLoadSafe(safeAddress, isSafeLoadedViaUrl)
useSafeScheduledUpdates(safeLoaded, safeAddress)
const sendFunds = safeActionsState.sendFunds

View File

@ -39,7 +39,7 @@ type Props = {
export const SafeListSidebar = ({ children }: Props): ReactElement => {
const [isOpen, setIsOpen] = useState(false)
const [filter, setFilter] = useState('')
const safes = useSelector(sortedSafeListSelector)
const safes = useSelector(sortedSafeListSelector).filter((safe) => !safe.loadedViaUrl)
const defaultSafe = useSelector(defaultSafeSelector)
const currentSafe = useSelector(safeParamAddressFromStateSelector)
@ -75,7 +75,6 @@ export const SafeListSidebar = ({ children }: Props): ReactElement => {
}
const filteredSafes = useMemo(() => filterBy(filter, safes), [safes, filter])
useEffect(() => {
setTimeout(() => {
setFilter('')

View File

@ -21,8 +21,13 @@ const addressBookMiddleware = (store) => (next) => async (action) => {
const { dispatch } = store
const addressBook = addressBookSelector(state)
const safes = safesListSelector(state)
if (addressBook.length) {
await saveAddressBook(addressBook)
const filteredSafeAddresses = safes
.filter((safe) => !safe.loadedViaUrl)
.map((safe) => safe.address)
.toJS()
await saveAddressBook(addressBook.filter((entry) => filteredSafeAddresses.includes(entry.address)))
}
switch (action.type) {

View File

@ -10,7 +10,7 @@ import fetchTransactions from 'src/logic/safe/store/actions/transactions/fetchTr
import { Dispatch } from 'src/logic/safe/store/actions/types.d'
import { updateAvailableCurrencies } from 'src/logic/currencyValues/store/actions/updateAvailableCurrencies'
export const useLoadSafe = (safeAddress?: string): boolean => {
export const useLoadSafe = (safeAddress?: string, loadedViaUrl = true): boolean => {
const dispatch = useDispatch<Dispatch>()
const [isSafeLoaded, setIsSafeLoaded] = useState(false)
@ -23,7 +23,9 @@ export const useLoadSafe = (safeAddress?: string): boolean => {
await dispatch(fetchSafeTokens(safeAddress))
await dispatch(updateAvailableCurrencies())
await dispatch(fetchTransactions(safeAddress))
dispatch(addViewedSafe(safeAddress))
if (!loadedViaUrl) {
dispatch(addViewedSafe(safeAddress))
}
}
}
dispatch(loadAddressBookFromStorage())

View File

@ -19,6 +19,7 @@ import { latestMasterContractVersionSelector, safeTotalFiatBalanceSelector } fro
import { getSafeInfo } from 'src/logic/safe/utils/safeInformation'
import { getModules } from 'src/logic/safe/utils/modules'
import { getSpendingLimits } from 'src/logic/safe/utils/spendingLimits'
import { LOADED_SAFE_KEY } from 'src/utils/constants'
const buildOwnersFrom = (safeOwners: string[], localSafe?: SafeRecordProps): List<SafeOwner> => {
const ownersList = safeOwners.map((ownerAddress) => {
@ -159,7 +160,7 @@ export default (safeAdd: string) => async (
): Promise<Action | void> => {
try {
const safeAddress = checksumAddress(safeAdd)
const safeName = (await getSafeName(safeAddress)) || 'LOADED SAFE'
const safeName = (await getSafeName(safeAddress)) || LOADED_SAFE_KEY
const latestMasterContractVersion = latestMasterContractVersionSelector(getState())
const totalFiatBalance = safeTotalFiatBalanceSelector(getState())
const safeProps = await buildSafe(safeAddress, safeName, latestMasterContractVersion, totalFiatBalance)

View File

@ -31,7 +31,7 @@ export const safeStorageMiddleware = (store) => (next) => async (action) => {
const state = store.getState()
const { dispatch } = store
const safes = safesMapSelector(state)
await saveSafes(safes.toJSON())
await saveSafes(safes.filter((safe) => !safe.loadedViaUrl).toJSON())
switch (action.type) {
case ADD_OR_UPDATE_SAFE: {

View File

@ -38,6 +38,7 @@ export type SafeRecordProps = {
nonce: number
latestIncomingTxBlock: number
recurringUser?: boolean
loadedViaUrl?: boolean
currentVersion: string
needsUpdate: boolean
featuresEnabled: Array<FEATURES>
@ -55,6 +56,7 @@ const makeSafe = Record<SafeRecordProps>({
activeTokens: Set(),
balances: Map(),
nonce: 0,
loadedViaUrl: false,
latestIncomingTxBlock: 0,
recurringUser: undefined,
currentVersion: '',

View File

@ -16,6 +16,7 @@ import { checksumAddress } from 'src/utils/checksumAddress'
import { ADD_OR_UPDATE_SAFE, buildOwnersFrom } from 'src/logic/safe/store/actions/addOrUpdateSafe'
import { sameAddress } from 'src/logic/wallets/ethAddresses'
import { shouldSafeStoreBeUpdated } from 'src/logic/safe/utils/shouldSafeStoreBeUpdated'
import { LOADED_SAFE_KEY } from 'src/utils/constants'
export const SAFE_REDUCER_ID = 'safes'
export const DEFAULT_SAFE_INITIAL_STATE = 'NOT_ASKED'
@ -84,11 +85,16 @@ export default handleActions<AppReduxState['safes'], Payloads>(
const safeAddress = safe.address
const shouldUpdate = shouldSafeStoreBeUpdated(safe, state.getIn(['safes', safeAddress]))
let loadedViaUrl = safe.loadedViaUrl
if (!state.hasIn(['safes', safeAddress])) {
loadedViaUrl = !safe?.name || safe?.name === LOADED_SAFE_KEY
}
return shouldUpdate
? state.updateIn(
['safes', safeAddress],
makeSafe({ name: safe?.name || 'LOADED SAFE', address: safeAddress }),
makeSafe({ name: safe?.name || LOADED_SAFE_KEY, address: safeAddress, loadedViaUrl }),
(prevSafe) => updateSafeProps(prevSafe, safe),
)
: state
@ -102,11 +108,10 @@ export default handleActions<AppReduxState['safes'], Payloads>(
}
const shouldUpdate = shouldSafeStoreBeUpdated(safe, state.getIn(['safes', safeAddress]))
return shouldUpdate
? state.updateIn(
['safes', safeAddress],
makeSafe({ name: safe?.name || 'LOADED SAFE', address: safeAddress }),
makeSafe({ name: safe?.name || LOADED_SAFE_KEY, address: safeAddress, loadedViaUrl: !!safe?.name }),
(prevSafe) => updateSafeProps(prevSafe, safe),
)
: state

View File

@ -104,6 +104,8 @@ export const safeFeaturesEnabledSelector = createSelector(safeSelector, safeFiel
export const safeSpendingLimitsSelector = createSelector(safeSelector, safeFieldSelector('spendingLimits'))
export const safeLoadedViaUrlSelector = createSelector(safeSelector, safeFieldSelector('loadedViaUrl'))
export const safeOwnersAddressesListSelector = createSelector(
safeOwnersSelector,
(owners): List<string> => {

View File

@ -17,6 +17,7 @@ export const SQUARELINK_ID = {
*/
export const INFURA_TOKEN = process.env.REACT_APP_INFURA_TOKEN || ''
export const LATEST_SAFE_VERSION = process.env.REACT_APP_LATEST_SAFE_VERSION || '1.1.1'
export const LOADED_SAFE_KEY = 'LOADED SAFE'
export const APP_VERSION = process.env.REACT_APP_APP_VERSION || 'not-defined'
export const OPENSEA_API_KEY = process.env.REACT_APP_OPENSEA_API_KEY || ''
export const COLLECTIBLES_SOURCE = process.env.REACT_APP_COLLECTIBLES_SOURCE || 'Gnosis'