New Staking and Governance banners and modals#4470
Conversation
packages/yoroi-extension/app/UI/components/Banners/BannerVisibilityManager.tsx
Outdated
Show resolved
Hide resolved
packages/yoroi-extension/app/UI/components/Banners/BannerVisibilityManager.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Bug: Missing useCallback dependency causes stale closure
The resolveBanner callback uses showRewardBanner at line 11, but showRewardBanner is not included in the useCallback dependencies array. This causes a stale closure issue where changes to showRewardBanner won't trigger a new callback instance, potentially leading to the wrong banner being displayed based on outdated state.
packages/yoroi-extension/app/UI/common/hooks/useBannersQueue.tsx#L27-L28
There was a problem hiding this comment.
Bug: Missing dependency in useCallback causes stale closure
The resolveBanner useCallback uses showRewardBanner in its body (line 11) but doesn't include it in the dependency array. This causes a stale closure where the callback may evaluate the reward banner condition using an outdated value of showRewardBanner, potentially showing or hiding the banner incorrectly when the user's delegation or governance status changes.
packages/yoroi-extension/app/UI/common/hooks/useBannersQueue.tsx#L27-L28
...s/yoroi-extension/app/UI/features/staking/useCases/DelegatedStakePoolInfo/DelegateButton.tsx
Outdated
Show resolved
Hide resolved
packages/yoroi-extension/app/UI/features/staking/common/modals/GovernanceRequiredForRewards.tsx
Show resolved
Hide resolved
...s/yoroi-extension/app/UI/features/staking/useCases/DelegatedStakePoolInfo/DelegateButton.tsx
Show resolved
Hide resolved
packages/yoroi-extension/app/UI/common/hooks/useBannersQueue.tsx
Outdated
Show resolved
Hide resolved
packages/yoroi-extension/chrome/extension/background/pushNotificationHandler.ts
Show resolved
Hide resolved
packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js
Outdated
Show resolved
Hide resolved
packages/yoroi-extension/app/UI/features/staking/common/modals/GovernanceRequiredForRewards.tsx
Outdated
Show resolved
Hide resolved
...s/yoroi-extension/app/UI/features/staking/useCases/DelegatedStakePoolInfo/DelegateButton.tsx
Show resolved
Hide resolved
...s/yoroi-extension/app/UI/features/staking/useCases/DelegatedStakePoolInfo/DelegateButton.tsx
Show resolved
Hide resolved
...s/yoroi-extension/app/UI/features/staking/useCases/DelegatedStakePoolInfo/DelegateButton.tsx
Outdated
Show resolved
Hide resolved
packages/yoroi-extension/app/containers/wallet/staking/SeizaFetcherSection.js
Outdated
Show resolved
Hide resolved
packages/yoroi-extension/app/UI/features/staking/common/hooks/useStrings.ts
Show resolved
Hide resolved
| <OperationsDetails | ||
| avatarGenerated={avatarGenerated} | ||
| poolName={selectedPool?.info?.name} | ||
| website={selectedPool.info?.homepage} |
There was a problem hiding this comment.
Missing null check causes potential TypeError on pool info
In the new onDelegateAndStake function, the expression selectedPool.info?.homepage uses optional chaining on homepage but not on selectedPool. If getLocalPoolInfo returns null or undefined, accessing .info will throw a TypeError before the ?.homepage check is reached. Line 76 correctly uses selectedPool?.info?.name, but line 77 is inconsistent and unsafe.
| label={rewardsButton} | ||
| disabled={false} | ||
| poolID={yoroiPoolID || ''} | ||
| poolName={yoroiPoolName || ''} |
There was a problem hiding this comment.
Empty pool ID passed to delegation on mainnet
RewardsBanner passes poolID={yoroiPoolID || ''} which converts undefined remote config values to empty strings. In DelegateButton, the expression isTestnet ? (poolID ?? fallback) : poolID only uses nullish coalescing (??) for testnet, which doesn't catch empty strings. On mainnet, if the remote config lacks poolId, an empty string is passed to createDelegationTransaction, which will likely fail. The || operator in RewardsBanner and ?? operator in DelegateButton handle edge cases inconsistently.
tasks:
Note
Adds a new Rewards banner and governance-required modals, enables one-step stake+DRep delegation via remote config, integrates Tx Review provider, and updates routing/sidebar for the staking revamp.
Rewardsbanner (UI/components/Banners/RewardsBanner.tsx) and queue logic (useBannersQueue) gated by governance status and remote config.BaseBanner) withnoCloseandcustomButton. Show banner viaBannerVisibilityManager.DelegateButtonsupports delegating to a stake pool and DRep in one step (readspoolId/poolName/drepIdfrom remote config) and opens Tx Review.createPoolOrDrepDelegationTransactioninDelegationStoreto handle pool/DRep or both.SeizaFetcherSection,WalletDelegationBannerto use the new flow and prompt governance if needed.GovernanceRequiredForRewardsandStakeWithdrawUpdatesmodals with illustration; block withdraw/undelegate if not participating (WithdrawButton,UndelegateButton).ReviewTxProvider. IntroduceStakingAndGovernancePagesWrapperto shareGovernanceContextProviderand currency.ROUTES.STAKING_REVAMP.ROOT; make staking revamp sidebar entry visible for selected wallets.newWalletquery on wallet switch.YoroiRemoteConfig) withbanners.earnRewardsWithYoroi.delegateVotinglabel for Tx Review.GovUpdatesIlustration.Written by Cursor Bugbot for commit 0c3a933. This will update automatically on new commits. Configure here.