From b3306241c5b765ab3f89553e6f75f77f4a21c55d Mon Sep 17 00:00:00 2001 From: James Mealy Date: Fri, 16 Feb 2024 18:05:25 +0100 Subject: [PATCH] show undeployed safes in the owned safes list (#3278) --- .../welcome/MyAccounts/useAllSafes.ts | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/components/welcome/MyAccounts/useAllSafes.ts b/src/components/welcome/MyAccounts/useAllSafes.ts index 2520d1c597..a6f0554234 100644 --- a/src/components/welcome/MyAccounts/useAllSafes.ts +++ b/src/components/welcome/MyAccounts/useAllSafes.ts @@ -7,6 +7,7 @@ import useAllOwnedSafes from './useAllOwnedSafes' import useChains from '@/hooks/useChains' import useChainId from '@/hooks/useChainId' import useWallet from '@/hooks/wallets/useWallet' +import { selectUndeployedSafes } from '@/store/slices' export type SafeItems = Array<{ chainId: string @@ -35,6 +36,7 @@ const useAllSafes = (): SafeItems => { const allAdded = useAddedSafes() const { configs } = useChains() const currentChainId = useChainId() + const undeployedSafes = useAppSelector(selectUndeployedSafes) return useMemo(() => { const chains = uniq([currentChainId].concat(Object.keys(allAdded)).concat(Object.keys(allOwned))) @@ -43,17 +45,22 @@ const useAllSafes = (): SafeItems => { if (!configs.some((item) => item.chainId === chainId)) return [] const addedOnChain = Object.keys(allAdded[chainId] || {}) const ownedOnChain = allOwned[chainId] + const undeployedOnChain = Object.keys(undeployedSafes[chainId] || {}) const uniqueAddresses = uniq(addedOnChain.concat(ownedOnChain)).filter(Boolean) - return uniqueAddresses.map((address) => ({ - address, - chainId, - isWatchlist: !(ownedOnChain || []).includes(address), - threshold: allAdded[chainId]?.[address]?.threshold, - owners: allAdded[chainId]?.[address]?.owners.length, - })) + return uniqueAddresses.map((address) => { + const isUndeployed = undeployedOnChain.includes(address) + const isOwned = (ownedOnChain || []).includes(address) + return { + address, + chainId, + isWatchlist: !isOwned && !isUndeployed, + threshold: allAdded[chainId]?.[address]?.threshold, + owners: allAdded[chainId]?.[address]?.owners.length, + } + }) }) - }, [configs, allAdded, allOwned, currentChainId]) + }, [configs, allAdded, allOwned, currentChainId, undeployedSafes]) } export default useAllSafes