-
Notifications
You must be signed in to change notification settings - Fork 428
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
feat: pending recovery widget #2772
Conversation
Branch preview✅ Deploy successful! https://pending_recovery_widget--walletweb.review-wallet-web.5afe.dev |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success1150 tests passing in 161 suites. Report generated by 🧪jest coverage report action from f941c8b |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
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.
On mobile this widget can look a bit cramped but I also saw that there are no mobile designs yet so possibly something we can fix later.
return null | ||
} | ||
|
||
const nonExpiredTxs = recovery |
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.
Somehow these queue items contain a lot more properties than what the type says e.g. functions like getBlock
etc. but they are also not visible in the Redux store, only in the console.
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.
Redux only shows serializable data, hence it not showing in the DevTools. As we are not persisting the data, nor relying on these "hidden" properties, I think we can ignore these.
src/hooks/useBlockTimestamp.ts
Outdated
|
||
import { useWeb3ReadOnly } from './wallets/web3' | ||
|
||
const INTERVAL = 1_000 |
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.
The Countdown
only has minute precision. Why do we need to update the block timestamp every second which rerenders the RecoveryInProgress
component? Would it not suffice to do it every 60 seconds?
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.
The block timestamp is in seconds and this hook is not necessarily recovery-specific.
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.
I understand but wherever we use this hook it would result in rerenders/side effects and possibly expensive computations every second. For the dashboard widget it is only necessary to be updated every 60s as far as I understand. We could pass in the interval as a prop to solve this instead of hard-coding it here.
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.
I've implemented your suggestion in f941c8b.
src/hooks/useBlockTimestamp.ts
Outdated
useEffect(() => { | ||
if (!block) { | ||
return | ||
} | ||
|
||
setTimestamp(block.timestamp) | ||
|
||
const timeout = setInterval(() => { | ||
setTimestamp((prev) => { | ||
return prev ? prev + 1 : block.timestamp | ||
}) | ||
}, INTERVAL) | ||
|
||
return () => { | ||
clearInterval(timeout) | ||
} | ||
}, [block]) |
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.
I am not sure I understand this logic. Is it that we initially want to fetch the block timestamp once but then increase it by 1 every second? Is it possible to move this logic inside the useAsync
block and get rid of the timestamp
state?
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.
Yes, by increasing the timestamp locally we don't need to fetch the it again. We cannot move it inside useAsync
due to the cleanup.
import { FEATURES } from '@/utils/chains' | ||
|
||
export function RecoveryInProgress(): ReactElement | null { | ||
const blockTimestamp = useBlockTimestamp() |
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.
I noticed that it can take a few seconds for the blockTimestamp
to be there. I even navigated away when I first opened the dashboard because it didn't show up for a while. I would suggest adding a loading state and a Skeleton.
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.
I've added a Skeleton
in 9d5270e.
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.
Can we adjust it so the Skeleton is only displayed if the safe has recovery enabled? I can see it flashing now even in safes where no recovery module is enabled.
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.
Loading recovery takes longer than the timestamp so we do not know whether it is enabled. I would sooner suggest we opt for no loader, but dispatch a notification as well in case the user navigates away. What do you think @TanyaEfremova?
(Due to capacity, I will remove this for now and adjust it in a followup PR as to remove blockers.)
ESLint Summary View Full Report
Report generated by eslint-plus-action |
What it solves
Resolves #2754
How this PR fixes it
A pending recovery widget has been added to the top of the dashboard according to the designs:
Full test coverage has been included for UI elements and associated logic.
How to test it
Open a Safe that has a pending recovery attempt, e.g.
gor:0xAecDFD3A19f777F0c03e6bf99AAfB59937d6467b
and observe the new banner.Screenshots
Checklist