Skip to content

Commit

Permalink
fix: do not load safe overview for undeployed Safes
Browse files Browse the repository at this point in the history
  • Loading branch information
schmanu committed Sep 25, 2024
1 parent fd0c79d commit 2496bbd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
5 changes: 0 additions & 5 deletions src/components/common/NetworkSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,6 @@ const NetworkSelector = ({
[availableChainIds, configs],
)

const multiChainSafes = useMemo(
() => availableChainIds.map((chain) => ({ address: safeAddress, chainId: chain })),
[availableChainIds, safeAddress],
)

const onChange = (event: SelectChangeEvent) => {
event.preventDefault() // Prevent the link click

Expand Down
17 changes: 10 additions & 7 deletions src/components/welcome/MyAccounts/AccountItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { useGetHref } from './useGetHref'
import { extractCounterfactualSafeSetup, isPredictedSafeProps } from '@/features/counterfactual/utils'
import { useGetSafeOverviewQuery } from '@/store/safeOverviews'
import useWallet from '@/hooks/wallets/useWallet'
import { skipToken } from '@reduxjs/toolkit/query'

type AccountItemProps = {
safeItem: SafeItem
Expand Down Expand Up @@ -64,13 +65,15 @@ const AccountItem = ({ onLinkClick, safeItem }: AccountItemProps) => {

const isReplayable = !safeItem.isWatchlist && (!undeployedSafe || !isPredictedSafeProps(undeployedSafe.props))

const { data: safeOverview } = useGetSafeOverviewQuery({
chainId: safeItem.chainId,
safeAddress: safeItem.address,
walletAddress,
})

console.log('Resulting overview', safeOverview)
const { data: safeOverview } = useGetSafeOverviewQuery(
undeployedSafe
? skipToken
: {
chainId: safeItem.chainId,
safeAddress: safeItem.address,
walletAddress,
},
)

return (
<ListItemButton
Expand Down
6 changes: 5 additions & 1 deletion src/components/welcome/MyAccounts/MultiAccountItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ const MultiAccountItem = ({ onLinkClick, multiSafeAccountItem }: MultiAccountIte

const currency = useAppSelector(selectCurrency)
const { address: walletAddress } = useWallet() ?? {}
const { data: safeOverviews } = useGetMultipleSafeOverviewsQuery({ currency, walletAddress, safes })
const deployedSafes = useMemo(
() => safes.filter((safe) => undeployedSafes[safe.chainId]?.[safe.address] === undefined),
[safes, undeployedSafes],
)
const { data: safeOverviews } = useGetMultipleSafeOverviewsQuery({ currency, walletAddress, safes: deployedSafes })

const safeSetups = useMemo(
() => getSafeSetups(safes, safeOverviews ?? [], undeployedSafes),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ export const InconsistentSignerSetupWarning = () => {
() => allMultiChainSafes?.find((account) => sameAddress(safeAddress, account.safes[0].address))?.safes ?? [],
[allMultiChainSafes, safeAddress],
)
const { data: safeOverviews } = useGetMultipleSafeOverviewsQuery({ safes: multiChainGroupSafes, currency })
const deployedSafes = useMemo(
() => multiChainGroupSafes.filter((safe) => undeployedSafes[safe.chainId]?.[safe.address] === undefined),
[multiChainGroupSafes, undeployedSafes],
)
const { data: safeOverviews } = useGetMultipleSafeOverviewsQuery({ safes: deployedSafes, currency })

const safeSetups = useMemo(
() => getSafeSetups(multiChainGroupSafes, safeOverviews ?? [], undeployedSafes),
Expand Down
2 changes: 1 addition & 1 deletion src/store/safeOverviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SafeOverviewFetcher {
this.fetchTimeout = null

if (nextBatch.length === 0) {
// If for some reason the queue was already processed we are done
// Nothing to process
return
}

Expand Down

0 comments on commit 2496bbd

Please sign in to comment.