Skip to content

Commit

Permalink
Fixing Tech debt in ReleaseGold and Election (#3940)
Browse files Browse the repository at this point in the history
* info.remainingValue is required to be zero

* Contract should be an account before doing any computation

* Change doc

* Update packages/protocol/contracts/governance/ReleaseGold.sol

Co-authored-by: Victor "Nate" Graf <victor@celo.org>

Co-authored-by: Victor "Nate" Graf <victor@celo.org>
  • Loading branch information
37ng and Victor "Nate" Graf committed Jun 2, 2020
1 parent f5b6d3e commit ea80658
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/contracts/governance/Election.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,6 @@ contract Election is
}
}
require(info.remainingValue == 0, "Failure to decrement all votes.");
return value.sub(info.remainingValue);
return value;
}
}
7 changes: 4 additions & 3 deletions packages/protocol/contracts/governance/ReleaseGold.sol
Original file line number Diff line number Diff line change
Expand Up @@ -426,15 +426,16 @@ contract ReleaseGold is UsingRegistry, ReentrancyGuard, IReleaseGold, Initializa
/**
* @notice Calculates remaining locked gold balance in the release schedule instance.
* The returned amount also includes pending withdrawals to maintain consistent releases.
* Return 0 if address of caller is not an account.
* @return The remaining locked gold of the release schedule instance.
* @dev The returned amount may vary over time due to locked gold rewards.
*/
function getRemainingLockedBalance() public view returns (uint256) {
uint256 pendingWithdrawalSum = 0;
if (getAccounts().isAccount(address(this))) {
pendingWithdrawalSum = getLockedGold().getTotalPendingWithdrawals(address(this));
uint256 pendingWithdrawalSum = getLockedGold().getTotalPendingWithdrawals(address(this));
return getLockedGold().getAccountTotalLockedGold(address(this)).add(pendingWithdrawalSum);
}
return getLockedGold().getAccountTotalLockedGold(address(this)).add(pendingWithdrawalSum);
return 0;
}

/**
Expand Down

0 comments on commit ea80658

Please sign in to comment.