|
@@ -31,7 +31,6 @@ import {SafeCast} from "../../utils/math/SafeCast.sol";
|
|
* {ERC20Votes} and {ERC721Votes} follow this pattern and are thus safe to use with {VotesExtended}.
|
|
* {ERC20Votes} and {ERC721Votes} follow this pattern and are thus safe to use with {VotesExtended}.
|
|
*/
|
|
*/
|
|
abstract contract VotesExtended is Votes {
|
|
abstract contract VotesExtended is Votes {
|
|
- using SafeCast for uint256;
|
|
|
|
using Checkpoints for Checkpoints.Trace160;
|
|
using Checkpoints for Checkpoints.Trace160;
|
|
using Checkpoints for Checkpoints.Trace208;
|
|
using Checkpoints for Checkpoints.Trace208;
|
|
|
|
|
|
@@ -47,11 +46,7 @@ abstract contract VotesExtended is Votes {
|
|
* - `timepoint` must be in the past. If operating using block numbers, the block must be already mined.
|
|
* - `timepoint` must be in the past. If operating using block numbers, the block must be already mined.
|
|
*/
|
|
*/
|
|
function getPastDelegate(address account, uint256 timepoint) public view virtual returns (address) {
|
|
function getPastDelegate(address account, uint256 timepoint) public view virtual returns (address) {
|
|
- uint48 currentTimepoint = clock();
|
|
|
|
- if (timepoint >= currentTimepoint) {
|
|
|
|
- revert ERC5805FutureLookup(timepoint, currentTimepoint);
|
|
|
|
- }
|
|
|
|
- return address(_delegateCheckpoints[account].upperLookupRecent(timepoint.toUint48()));
|
|
|
|
|
|
+ return address(_delegateCheckpoints[account].upperLookupRecent(_validateTimepoint(timepoint)));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -63,11 +58,7 @@ abstract contract VotesExtended is Votes {
|
|
* - `timepoint` must be in the past. If operating using block numbers, the block must be already mined.
|
|
* - `timepoint` must be in the past. If operating using block numbers, the block must be already mined.
|
|
*/
|
|
*/
|
|
function getPastBalanceOf(address account, uint256 timepoint) public view virtual returns (uint256) {
|
|
function getPastBalanceOf(address account, uint256 timepoint) public view virtual returns (uint256) {
|
|
- uint48 currentTimepoint = clock();
|
|
|
|
- if (timepoint >= currentTimepoint) {
|
|
|
|
- revert ERC5805FutureLookup(timepoint, currentTimepoint);
|
|
|
|
- }
|
|
|
|
- return _balanceOfCheckpoints[account].upperLookupRecent(timepoint.toUint48());
|
|
|
|
|
|
+ return _balanceOfCheckpoints[account].upperLookupRecent(_validateTimepoint(timepoint));
|
|
}
|
|
}
|
|
|
|
|
|
/// @inheritdoc Votes
|
|
/// @inheritdoc Votes
|
|
@@ -82,10 +73,10 @@ abstract contract VotesExtended is Votes {
|
|
super._transferVotingUnits(from, to, amount);
|
|
super._transferVotingUnits(from, to, amount);
|
|
if (from != to) {
|
|
if (from != to) {
|
|
if (from != address(0)) {
|
|
if (from != address(0)) {
|
|
- _balanceOfCheckpoints[from].push(clock(), _getVotingUnits(from).toUint208());
|
|
|
|
|
|
+ _balanceOfCheckpoints[from].push(clock(), SafeCast.toUint208(_getVotingUnits(from)));
|
|
}
|
|
}
|
|
if (to != address(0)) {
|
|
if (to != address(0)) {
|
|
- _balanceOfCheckpoints[to].push(clock(), _getVotingUnits(to).toUint208());
|
|
|
|
|
|
+ _balanceOfCheckpoints[to].push(clock(), SafeCast.toUint208(_getVotingUnits(to)));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|