Преглед на файлове

Remove redundant getVotes call in Governor (#4940)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Co-authored-by: ernestognw <ernestognw@gmail.com>
Aman Kumar Sinha преди 1 година
родител
ревизия
7417c5946f
променени са 1 файла, в които са добавени 5 реда и са изтрити 3 реда
  1. 5 3
      contracts/governance/Governor.sol

+ 5 - 3
contracts/governance/Governor.sol

@@ -286,10 +286,12 @@ abstract contract Governor is Context, ERC165, EIP712, Nonces, IGovernor, IERC72
         }
 
         // check proposal threshold
-        uint256 proposerVotes = getVotes(proposer, clock() - 1);
         uint256 votesThreshold = proposalThreshold();
-        if (proposerVotes < votesThreshold) {
-            revert GovernorInsufficientProposerVotes(proposer, proposerVotes, votesThreshold);
+        if (votesThreshold > 0) {
+            uint256 proposerVotes = getVotes(proposer, clock() - 1);
+            if (proposerVotes < votesThreshold) {
+                revert GovernorInsufficientProposerVotes(proposer, proposerVotes, votesThreshold);
+            }
         }
 
         return _propose(targets, values, calldatas, description, proposer);