Bladeren bron

Remove unused return value and reuse helper function (#4588)

Co-authored-by: Francisco Giordano <fg@frang.io>
Hadrien Croubois 2 jaren geleden
bovenliggende
commit
bba33516b1
3 gewijzigde bestanden met toevoegingen van 3 en 8 verwijderingen
  1. 1 4
      contracts/governance/Governor.sol
  2. 1 2
      contracts/utils/Nonces.sol
  3. 1 2
      test/utils/Nonces.test.js

+ 1 - 4
contracts/governance/Governor.sol

@@ -635,10 +635,7 @@ abstract contract Governor is Context, ERC165, EIP712, Nonces, IGovernor, IERC72
         string memory reason,
         bytes memory params
     ) internal virtual returns (uint256) {
-        ProposalState currentState = state(proposalId);
-        if (currentState != ProposalState.Active) {
-            revert GovernorUnexpectedProposalState(proposalId, currentState, _encodeStateBitmap(ProposalState.Active));
-        }
+        _validateStateBitmap(proposalId, _encodeStateBitmap(ProposalState.Active));
 
         uint256 weight = _getVotes(account, proposalSnapshot(proposalId), params);
         _countVote(proposalId, account, support, weight, params);

+ 1 - 2
contracts/utils/Nonces.sol

@@ -36,11 +36,10 @@ abstract contract Nonces {
     /**
      * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.
      */
-    function _useCheckedNonce(address owner, uint256 nonce) internal virtual returns (uint256) {
+    function _useCheckedNonce(address owner, uint256 nonce) internal virtual {
         uint256 current = _useNonce(owner);
         if (nonce != current) {
             revert InvalidAccountNonce(owner, current);
         }
-        return current;
     }
 }

+ 1 - 2
test/utils/Nonces.test.js

@@ -42,8 +42,7 @@ contract('Nonces', function (accounts) {
       const currentNonce = await this.nonces.nonces(sender);
       expect(currentNonce).to.be.bignumber.equal('0');
 
-      const { receipt } = await this.nonces.$_useCheckedNonce(sender, currentNonce);
-      expectEvent(receipt, 'return$_useCheckedNonce', [currentNonce]);
+      await this.nonces.$_useCheckedNonce(sender, currentNonce);
 
       expect(await this.nonces.nonces(sender)).to.be.bignumber.equal('1');
     });