-
-
Notifications
You must be signed in to change notification settings - Fork 279
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
Solana staking view only #17296
base: develop
Are you sure you want to change the base?
Solana staking view only #17296
Conversation
WalkthroughThe pull request extends support for Solana staking across multiple modules. A new function is added to compute the total Solana cryptocurrency balance by combining the account's formatted balance with its staking balance. Localization entries for staking-related text are introduced in the internationalization file. Component changes adjust properties and styling based on the network symbol, enabling dynamic alert messages and titles for pending stakes. The selectors have been expanded to include Solana data, with modifications to handle staking balance, pending state, rewards, APY, and device account filtering for Solana accounts. Additionally, a new file containing dedicated Solana staking selectors is added, and the list of recognized staking coins is updated to include Solana symbols. These changes integrate Solana-specific logic alongside existing Ethereum staking functionalities. ✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
suite-native/module-staking-management/src/components/StakePendingCard.tsx (2)
36-37
: Consider a more descriptive helper name.While
isSolana
works, you might rename it to something likeisSolanaNetwork
for added clarity, especially if more symbols or custom checks are expected in the future.
70-75
: Function naming could be more explicit.
getTitle
is generic. Using something likegetPendingStakeTitle
orgetStakePendingCardTitle
might better convey its purpose.suite-native/staking/src/selectors.ts (1)
162-163
: Hardcoded return for Solana confirmation.Returning
false
for Solana stake confirmations is valid for now but consider a future scenario where Solana confirmation might become relevant or track different stake states.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
suite-common/wallet-utils/src/solanaStakingUtils.ts
(1 hunks)suite-native/intl/src/en.ts
(1 hunks)suite-native/module-staking-management/src/components/StakePendingCard.tsx
(5 hunks)suite-native/module-staking-management/src/components/StakingBalancesOverviewCard.tsx
(2 hunks)suite-native/staking/src/selectors.ts
(11 hunks)suite-native/staking/src/solanaStakingSelectors.ts
(1 hunks)suite-native/staking/src/utils.ts
(1 hunks)
🔇 Additional comments (24)
suite-native/module-staking-management/src/components/StakingBalancesOverviewCard.tsx (2)
70-74
: Good implementation of network-specific rewards titleThis change nicely accommodates Solana's different rewards mechanism by conditionally displaying "Rewards per Epoch" for Solana networks, which is more accurate than the generic "Rewards" label used for other networks.
108-108
: Clean implementation using the conditional titleThe component now correctly uses the dynamically determined rewards title based on the network symbol.
suite-common/wallet-utils/src/solanaStakingUtils.ts (1)
85-89
: Good implementation of total balance calculation for SolanaThis new function properly combines the account's formatted balance with its staking balance, correctly handling the case when staking balance is null by defaulting to 0.
The implementation is straightforward and follows the pattern of other utility functions in this file. The use of BigNumber ensures precise calculations without floating-point issues.
suite-native/intl/src/en.ts (2)
1247-1247
: Appropriate addition of Solana-specific rewards labelAdding "Rewards per Epoch" is appropriate for Solana's epoch-based rewards system.
1254-1255
: Clear labels for Solana stake activation statusThese additions provide clear and descriptive labels for the stake activation process in Solana, which differs from other networks.
suite-native/staking/src/utils.ts (1)
4-4
: Correctly expanded staking coins to include SolanaThe stakingCoins constant has been properly updated to include 'sol' and 'dsol', allowing the application to recognize and support Solana staking functionality.
This is a necessary change to enable the view-only staking functionality for Solana networks mentioned in the PR objectives.
suite-native/module-staking-management/src/components/StakePendingCard.tsx (4)
19-22
: Type definition looks good.The newly added
StakePendingCardProps
type is clear and self-explanatory, properly capturing the required props.
38-46
: Logic appears sound.The
getCardAlertProps
function correctly returns consistentalertTitle
andalertVariant
values for Solana vs. other networks. The structure is clean and straightforward.
55-59
: Solana activation messaging is correctly handled.Switching the alert title for Solana via
isSolana(symbol)
is properly differentiated, aligning with the unique activation flow.
99-100
: Appropriate usage of useMemo.Memoizing the alert props based on symbol and staking statuses helps avoid unnecessary render calculations.
suite-native/staking/src/solanaStakingSelectors.ts (8)
1-18
: Imports and setup look good.Utilizing
createWeakMapSelector
and pulling state interfaces from shared modules lays a solid foundation for the Solana staking selectors.
21-35
: Account filtering logic seems correct.Filtering visible device accounts specifically for the
solana
network and confirming the existence of Solana staking accounts is a clean approach. This ensures only relevant Solana accounts appear downstream.
37-46
: Efficient memoized selector.
selectSolStakingAccountsInfoByAccountKey
is well-structured. UsingcreateWeakMapSelector
ensures consistent performance by caching results per account instance.
48-64
: Clear pending stake detection.
selectSolanaIsStakePendingByAccountKey
accurately checks for any positive pending stake or unstake amounts, returning a boolean. This mirrors typical Solana staking logic.
66-74
: APY selection aligns with existing patterns.The selector fetches pool statistics via
selectPoolStatsApyData
. Just ensure that any protocol or network APY mismatches are handled gracefully.
76-90
: Staked balance calculation is correct.Combining staked, claimable, and pending amounts into a single BigNumber result is standard. This avoids floating-point pitfalls.
92-108
: Expected rewards calculation is well-structured.
calculateSolanaStakingReward
is used appropriately. This design cleanly accommodates changes in future reward logic or new constraints.
110-120
: Total stake pending retrieval is straightforward.
selectSolanaTotalStakePendingByAccountKey
returning'0'
for non-staking or missing data is consistent with typical selector conventions.suite-native/staking/src/selectors.ts (6)
2-11
: Expanded imports for Solana.Bringing in additional selectors and utilities for
sol
anddsol
is a proper step toward unifying staking logic for multiple networks.
23-28
: New Solana staking selector references.Importing from
solanaStakingSelectors
seamlessly integrates the Solana-specific logic while preserving clarity for other networks.
48-50
: Solana accounts now included in device account selection.Allowing
sol
anddsol
withinselectDeviceAccountsWithStaking
ensures consistent user interface support for Solana-based staking.
72-78
: Accurate handling of Solana balance.
getSolanaCryptoBalanceWithStaking
merges staked and main balances accurately, aligning with the established pattern for other staking coins.
110-111
: Excellent Solana integration throughout.In all these updated function switches—
selectAccountHasStaking
,selectIsStakePendingByAccountKey
,selectStakedBalanceByAccountKey
,selectRewardsBalanceByAccountKey
,selectTotalStakePendingByAccountKey
—the approach is consistent with the existing pattern for Ethereum. The uniform logic ensures minimal fragmentation across different networks.Also applies to: 136-137, 198-199, 224-226, 251-252
179-179
: Directly returning APY data.Simplifying
selectAPYByAccountKey
for plan synergy with the pool stats API is elegant. It ensures a single source of truth for yield data.
🚀 Expo preview is ready!
|
Related Issue
Resolve #16370
Screenshots: