Last active
May 8, 2021 19:34
-
-
Save percybolmer/e8a01d4331a6adade2aacf46873bf5cd to your computer and use it in GitHub Desktop.
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
/** | |
* @notice | |
* hasStake is used to check if a account has stakes and the total amount along with all the seperate stakes | |
*/ | |
function hasStake(address _staker) public view returns(StakingSummary memory){ | |
// totalStakeAmount is used to count total staked amount of the address | |
uint256 totalStakeAmount; | |
// Keep a summary in memory since we need to calculate this | |
StakingSummary memory summary = StakingSummary(0, stakes[_staker]); | |
// Itterate all stakes and grab amount of stakes | |
for (uint256 s = 0; s < summary.stakes.length; s += 1){ | |
totalStakeAmount = totalStakeAmount+summary.stakes[s].amount; | |
} | |
// Assign calculate amount to summary | |
summary.total_amount = totalStakeAmount; | |
return summary; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment