fix(staking): expose get_stake_amount and get_all_stakers (#272) - #410
Merged
cypriannwokolo2-creator merged 2 commits intoAug 31, 2026
Merged
Conversation
…#272) - Add StakersList DataKey (persistent storage) to types.rs - Maintain StakersList in stake() (add) and unstake() (remove) - Add get_stake_amount(user) -> i128: returns raw staked token amount, 0 if no active stake (including during unbonding) - Add get_all_stakers() -> Vec<Address>: returns all currently active stakers from persistent storage - Expose both new methods in lib.rs contractimpl block - Add 11 new tests (5 for get_stake_amount, 6 for get_all_stakers): happy path, no stake, after unstake, all periods, full lifecycle, empty list, single/multi-user, partial unstake, restake after cycle Resolves cocor-tech#272
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #274