Skip to content
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

refactor(StakeManager): make function names more descriptive #93

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

0x-r4bbit
Copy link
Collaborator

Some of the functions on our contracts were confusing. This commit changes them so they describe what they actually do.

Checklist

Ensure you completed all of the steps below before submitting your pull request:

  • Added natspec comments?
  • Ran forge snapshot?
  • Ran pnpm gas-report?
  • Ran pnpm lint?
  • Ran forge test?
  • Ran pnpm verify?

@@ -66,7 +66,7 @@ contract StakeManager is Ownable {
_;
}

modifier onlyInitialized(address account) {
modifier onlyAccountInitialized(address account) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this one as onlyInitialized is commonly used in OZ Initializable contracts

@@ -106,7 +106,7 @@ contract StakeManager is Ownable {
/**
* @notice Process epoch if it has ended
*/
modifier processEpoch() {
modifier finalizeEpoch() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really wat this modifier does is finalizing the epoch if it's duration has passed.
There's an argument to be made that there's cases where it won't finalize, but I still think it's better than "process epoch" which can mean many things.

*/
function increaseMPFromMigration(uint256 _increasedMP) external onlyOldManager {
totalSupplyMP += _increasedMP;
function increaseTotalMP(uint256 _amount) external onlyPreviousManager {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire "increasedMP" notion in this contract felt a bit off to me.
In this case here, really what we're doing is adjusting the total MP of the next manager.

*/
function _getIncreasedMP(uint256 _balance, uint256 _deltaTime) private pure returns (uint256 _increasedMP) {
function _getMPToMint(uint256 _balance, uint256 _deltaTime) private pure returns (uint256) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, this function really just calculates the MP that should be minted

console.log("####### epoch :", epoch);
console.log("===============");
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire function was not used anywhere.

@0x-r4bbit 0x-r4bbit force-pushed the refactor/better-fn-names branch 3 times, most recently from 9f59efb to 97edf24 Compare June 19, 2024 09:57
Some of the functions on our contracts were confusing.
This commit changes them so they describe what they actually do.
Copy link
Collaborator

@3esmit 3esmit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@3esmit 3esmit merged commit d18df07 into develop Jun 20, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants