-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Refetch owned safes after deployment #4673
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import { SafeCreationEvent, safeCreationSubscribe } from '@/features/counterfactual/services/safeCreationEvents' | ||
import useWallet from '@/hooks/wallets/useWallet' | ||
import { useGetAllOwnedSafesQuery } from '@/store/api/gateway' | ||
import { getBlockExplorerLink } from '@/utils/chains' | ||
import { skipToken } from '@reduxjs/toolkit/query' | ||
import { useEffect } from 'react' | ||
import { formatError } from '@/utils/formatters' | ||
import { showNotification } from '@/store/notificationsSlice' | ||
|
@@ -26,6 +29,8 @@ const usePendingSafeNotifications = (): void => { | |
const dispatch = useAppDispatch() | ||
const chain = useCurrentChain() | ||
const safeAddress = useSafeAddress() | ||
const { address = '' } = useWallet() || {} | ||
const { refetch } = useGetAllOwnedSafesQuery(address === '' ? skipToken : { walletAddress: address }) | ||
|
||
useEffect(() => { | ||
if (!chain) return | ||
|
@@ -43,6 +48,11 @@ const usePendingSafeNotifications = (): void => { | |
const groupKey = 'groupKey' in detail && detail.groupKey ? detail.groupKey : txHash || '' | ||
const link = chain && txHash ? getBlockExplorerLink(chain, txHash) : undefined | ||
|
||
// Fetch all owned safes after the Safe has been deployed | ||
if (isSuccess) { | ||
refetch() | ||
} | ||
|
||
dispatch( | ||
showNotification({ | ||
title: 'Safe Account activation', | ||
|
@@ -59,7 +69,7 @@ const usePendingSafeNotifications = (): void => { | |
return () => { | ||
unsubFns.forEach((unsub) => unsub()) | ||
} | ||
}, [dispatch, safeAddress, chain]) | ||
}, [dispatch, safeAddress, chain, refetch]) | ||
} | ||
|
||
export default usePendingSafeNotifications | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its probably cleaner to create a new listener middleware for this. Wdyt @katspaugh @compojoom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it does require access to the connected wallet which I am not sure is possible inside a middleware. We would have to move the connected wallet state into Redux as well.