-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix: shield plan token approval amount incorrect when plan change #37585
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
Conversation
Builds ready [50a1e6e]
UI Startup Metrics (1205 ± 90 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [f31aec5]
UI Startup Metrics (1206 ± 119 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [4ab428c]
UI Startup Metrics (1249 ± 99 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
|
||
| // reset selected token if selected plan changes | ||
| useEffect(() => { | ||
| setSelectedToken(undefined); |
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.
Should this set to be default instead of undefined?
Like what we do in the above useEffects.
If I'm not mistaken, we don't need new side effects hook for this (we already have the (useEffect) hook which does the similar thing)?
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.
ah no that wouldn't work, since the above effect is only set if there is no selected token set yet to set the default token, if there is already token set, it won't trigger again, so that it won't run everytime token balance change
Description
Previously in shield plan screen, when user change plan, the selected token approval amount didn't get updated hence user will see outdated approval amount in the confirmation screen
This PR reset the selected token when plan change to get correct latest approval amount
Changelog
CHANGELOG entry: fix incorrect token approval amount when change shield plan
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Prevents stale approval amounts by resetting the selected token when the plan changes and refactors
useAvailableTokenBalancesto return{availableTokenBalances, pending, error}viauseAsyncResult.useAvailableTokenBalances:{ availableTokenBalances, pending, error }instead of an array; leveragesuseAsyncResult(removes localuseState/useEffect).priceor chain map; logs when token payment info missing.ui/pages/shield-plan/shield-plan.tsx):pendingto defer token selection until data ready.selectedTokenwhenselectedPlanchanges; only restores last-used token if it matches current plan.Written by Cursor Bugbot for commit 4ab428c. This will update automatically on new commits. Configure here.