-
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
base: main
Are you sure you want to change the base?
Conversation
| getAvailableTokenBalances(); | ||
| }, [price, productType, paymentChainTokenMap, validTokenBalances]); | ||
| return availableTokens; | ||
| }, [price, paymentChainTokenMap, validTokenBalances]); |
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.
Bug: Stale Data from Missing Dependency in Async Call
Missing productType in the useAsyncResult dependency array. The async function uses productType on line 125 (getSubscriptionCryptoApprovalAmount call), but it's not included in the dependency array on line 160. The old code (using useEffect) had productType in its dependencies. Without it, if productType changes, the async function won't re-execute with the new value, leading to stale data being used for approval amount calculations.
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!]
|
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
Refactors token balance hook to return {availableTokenBalances, pending, error} and updates Shield Plan to await balances and reset selected token on plan change, ensuring approval amounts reflect the selected plan.
useAvailableTokenBalances{ availableTokenBalances, pending, error }instead of just an array.useAsyncResultfor fetching approval amounts.price/token map by returning empty results; logs when token info is absent.pendingfromuseAvailableTokenBalancesand delays token selection until ready.selectedTokenwhenselectedPlanchanges.Written by Cursor Bugbot for commit f31aec5. This will update automatically on new commits. Configure here.