Skip to content

Commit

Permalink
fix: use uint256 type for weights
Browse files Browse the repository at this point in the history
Signed-off-by: 0xRaccoon <[email protected]>
  • Loading branch information
0xRaccoon committed Dec 19, 2023
1 parent d7d9aa0 commit a041f0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions solidity/contracts/governance/utils/WonderVotes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ abstract contract WonderVotes is Context, EIP712, Nonces, IERC6372, IWonderVotes
/**
* @dev See {IWonderVotes-totalWeight}.
*/
function totalWeight() external view virtual returns (uint8) {
function totalWeight() external view virtual returns (uint256) {
return _totalWeight();
}

Expand Down Expand Up @@ -244,7 +244,7 @@ abstract contract WonderVotes is Context, EIP712, Nonces, IERC6372, IWonderVotes
function _delegate(address account, uint8 proposalType, Delegate[] memory delegatees) internal virtual {
if (delegatees.length > _maxDelegates()) revert DelegatesMaxNumberExceeded(delegatees.length);

uint8 _weightSum;
uint256 _weightSum;
for (uint256 i = 0; i < delegatees.length; i++) {
if (delegatees[i].weight == 0) revert ZeroWeight();
_weightSum += delegatees[i].weight;
Expand Down Expand Up @@ -287,8 +287,8 @@ abstract contract WonderVotes is Context, EIP712, Nonces, IERC6372, IWonderVotes
* @dev Moves delegated votes from one delegate to another.
*/
function _moveDelegateVotes(uint8 proposalType, Delegate[] memory from, Delegate[] memory to, uint256 amount) private {
uint8 _weightSum = _totalWeight();
uint8 _weight;
uint256 _weightSum = _totalWeight();
uint256 _weight;

for (uint256 i = 0; i < from.length; i++) {
if (from[i].account != address(0)) {
Expand Down Expand Up @@ -353,7 +353,7 @@ abstract contract WonderVotes is Context, EIP712, Nonces, IERC6372, IWonderVotes
/**
* @dev Returns the total weight that each delegation should sum.
*/
function _totalWeight() internal view virtual returns (uint8);
function _totalWeight() internal view virtual returns (uint256);

/**
* @dev Returns the types of proposals that are supported by the implementation.
Expand Down
6 changes: 3 additions & 3 deletions solidity/interfaces/governance/utils/IWonderVotes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pragma solidity ^0.8.20;
interface IWonderVotes {
struct Delegate {
address account;
uint8 weight;
uint256 weight;
}

/**
Expand All @@ -19,7 +19,7 @@ interface IWonderVotes {
/**
* @dev The weight delegation sum is different from totalWeight.
*/
error InvalidWeightSum(uint8 weightSum);
error InvalidWeightSum(uint256 weightSum);

/**
* @dev The weight set for a delegate is zero.
Expand Down Expand Up @@ -124,7 +124,7 @@ interface IWonderVotes {
* used to calculate the amount of votes when partial delegating to more than 1 delegate.
* Example: 100% = 10000 - beware of precision loss from division and overflows from multiplications
*/
function totalWeight() external view returns (uint8);
function totalWeight() external view returns (uint256);

/**
* @dev Returns the maximum amount of delegates that a `proposalType` can be delegated to.
Expand Down

0 comments on commit a041f0c

Please sign in to comment.