diff --git a/contracts/token/ERC20/extensions/ERC20Votes.sol b/contracts/token/ERC20/extensions/ERC20Votes.sol index 3a3d959a1..38d2e208b 100644 --- a/contracts/token/ERC20/extensions/ERC20Votes.sol +++ b/contracts/token/ERC20/extensions/ERC20Votes.sol @@ -59,19 +59,27 @@ abstract contract ERC20Votes is IERC20Votes, ERC20Permit { } /** - * @dev Determine the number of votes for `account` at the begining of `blockNumber`. + * @dev Retrieve the number of votes for `account` at the end of `blockNumber`. + * + * Requirements: + * + * - `blockNumber` must have been already mined */ function getPriorVotes(address account, uint256 blockNumber) external view override returns (uint256) { - require(blockNumber < block.number, "ERC20Votes::getPriorVotes: not yet determined"); + require(blockNumber < block.number, "ERC20Votes: block not yet mined"); return _checkpointsLookup(_checkpoints[account], blockNumber); } /** - * @dev Determine the totalSupply at the begining of `blockNumber`. Note, this value is the sum of all balances. + * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances. * It is but NOT the sum of all the delegated votes! + * + * Requirements: + * + * - `blockNumber` must have been already mined */ - function getPriorTotalSupply(uint256 blockNumber) external view override returns(uint256) { - require(blockNumber < block.number, "ERC20Votes::getPriorTotalSupply: not yet determined"); + function getPriorTotalSupply(uint256 blockNumber) external view override returns (uint256) { + require(blockNumber < block.number, "ERC20Votes: block not yet mined"); return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber); } @@ -117,7 +125,7 @@ abstract contract ERC20Votes is IERC20Votes, ERC20Permit { function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) public virtual override { - require(block.timestamp <= expiry, "ERC20Votes::delegateBySig: signature expired"); + require(block.timestamp <= expiry, "ERC20Votes: signature expired"); address signer = ECDSA.recover( _hashTypedDataV4(keccak256(abi.encode( _DELEGATION_TYPEHASH, @@ -127,7 +135,7 @@ abstract contract ERC20Votes is IERC20Votes, ERC20Permit { ))), v, r, s ); - require(nonce == _useNonce(signer), "ERC20Votes::delegateBySig: invalid nonce"); + require(nonce == _useNonce(signer), "ERC20Votes: invalid nonce"); return _delegate(signer, delegatee); } diff --git a/test/token/ERC20/extensions/ERC20Votes.test.js b/test/token/ERC20/extensions/ERC20Votes.test.js index 588b7f92c..5598d4d89 100644 --- a/test/token/ERC20/extensions/ERC20Votes.test.js +++ b/test/token/ERC20/extensions/ERC20Votes.test.js @@ -192,7 +192,7 @@ contract('ERC20Votes', function (accounts) { await expectRevert( this.token.delegateBySig(delegatorAddress, nonce, MAX_UINT256, v, r, s), - 'ERC20Votes::delegateBySig: invalid nonce', + 'ERC20Votes: invalid nonce', ); }); @@ -224,7 +224,7 @@ contract('ERC20Votes', function (accounts) { )); await expectRevert( this.token.delegateBySig(delegatorAddress, nonce + 1, MAX_UINT256, v, r, s), - 'ERC20Votes::delegateBySig: invalid nonce', + 'ERC20Votes: invalid nonce', ); }); @@ -241,7 +241,7 @@ contract('ERC20Votes', function (accounts) { await expectRevert( this.token.delegateBySig(delegatorAddress, nonce, expiry, v, r, s), - 'ERC20Votes::delegateBySig: signature expired', + 'ERC20Votes: signature expired', ); }); }); @@ -411,7 +411,7 @@ contract('ERC20Votes', function (accounts) { it('reverts if block number >= current block', async function () { await expectRevert( this.token.getPriorVotes(other1, 5e10), - 'ERC20Votes::getPriorVotes: not yet determined', + 'ERC20Votes: block not yet mined', ); }); @@ -473,7 +473,7 @@ contract('ERC20Votes', function (accounts) { it('reverts if block number >= current block', async function () { await expectRevert( this.token.getPriorTotalSupply(5e10), - 'ERC20Votes::getPriorTotalSupply: not yet determined', + 'ERC20Votes: block not yet mined', ); });