@@ -31,7 +31,6 @@ import {SafeCast} from "../../utils/math/SafeCast.sol";
31
31
* {ERC20Votes} and {ERC721Votes} follow this pattern and are thus safe to use with {VotesExtended}.
32
32
*/
33
33
abstract contract VotesExtended is Votes {
34
- using SafeCast for uint256 ;
35
34
using Checkpoints for Checkpoints.Trace160;
36
35
using Checkpoints for Checkpoints.Trace208;
37
36
@@ -47,11 +46,7 @@ abstract contract VotesExtended is Votes {
47
46
* - `timepoint` must be in the past. If operating using block numbers, the block must be already mined.
48
47
*/
49
48
function getPastDelegate (address account , uint256 timepoint ) public view virtual returns (address ) {
50
- uint48 currentTimepoint = clock ();
51
- if (timepoint >= currentTimepoint) {
52
- revert ERC5805FutureLookup (timepoint, currentTimepoint);
53
- }
54
- return address (_delegateCheckpoints[account].upperLookupRecent (timepoint.toUint48 ()));
49
+ return address (_delegateCheckpoints[account].upperLookupRecent (_validateTimepoint (timepoint)));
55
50
}
56
51
57
52
/**
@@ -63,11 +58,7 @@ abstract contract VotesExtended is Votes {
63
58
* - `timepoint` must be in the past. If operating using block numbers, the block must be already mined.
64
59
*/
65
60
function getPastBalanceOf (address account , uint256 timepoint ) public view virtual returns (uint256 ) {
66
- uint48 currentTimepoint = clock ();
67
- if (timepoint >= currentTimepoint) {
68
- revert ERC5805FutureLookup (timepoint, currentTimepoint);
69
- }
70
- return _balanceOfCheckpoints[account].upperLookupRecent (timepoint.toUint48 ());
61
+ return _balanceOfCheckpoints[account].upperLookupRecent (_validateTimepoint (timepoint));
71
62
}
72
63
73
64
/// @inheritdoc Votes
@@ -82,10 +73,10 @@ abstract contract VotesExtended is Votes {
82
73
super ._transferVotingUnits (from, to, amount);
83
74
if (from != to) {
84
75
if (from != address (0 )) {
85
- _balanceOfCheckpoints[from].push (clock (), _getVotingUnits (from). toUint208 ( ));
76
+ _balanceOfCheckpoints[from].push (clock (), SafeCast. toUint208 ( _getVotingUnits (from)));
86
77
}
87
78
if (to != address (0 )) {
88
- _balanceOfCheckpoints[to].push (clock (), _getVotingUnits (to). toUint208 ( ));
79
+ _balanceOfCheckpoints[to].push (clock (), SafeCast. toUint208 ( _getVotingUnits (to)));
89
80
}
90
81
}
91
82
}
0 commit comments