Remove unused return value and reuse helper function (#4588)
Co-authored-by: Francisco Giordano <fg@frang.io>
This commit is contained in:
@ -635,10 +635,7 @@ abstract contract Governor is Context, ERC165, EIP712, Nonces, IGovernor, IERC72
|
|||||||
string memory reason,
|
string memory reason,
|
||||||
bytes memory params
|
bytes memory params
|
||||||
) internal virtual returns (uint256) {
|
) internal virtual returns (uint256) {
|
||||||
ProposalState currentState = state(proposalId);
|
_validateStateBitmap(proposalId, _encodeStateBitmap(ProposalState.Active));
|
||||||
if (currentState != ProposalState.Active) {
|
|
||||||
revert GovernorUnexpectedProposalState(proposalId, currentState, _encodeStateBitmap(ProposalState.Active));
|
|
||||||
}
|
|
||||||
|
|
||||||
uint256 weight = _getVotes(account, proposalSnapshot(proposalId), params);
|
uint256 weight = _getVotes(account, proposalSnapshot(proposalId), params);
|
||||||
_countVote(proposalId, account, support, weight, params);
|
_countVote(proposalId, account, support, weight, params);
|
||||||
|
|||||||
@ -36,11 +36,10 @@ abstract contract Nonces {
|
|||||||
/**
|
/**
|
||||||
* @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.
|
* @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);
|
uint256 current = _useNonce(owner);
|
||||||
if (nonce != current) {
|
if (nonce != current) {
|
||||||
revert InvalidAccountNonce(owner, current);
|
revert InvalidAccountNonce(owner, current);
|
||||||
}
|
}
|
||||||
return current;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,8 +42,7 @@ contract('Nonces', function (accounts) {
|
|||||||
const currentNonce = await this.nonces.nonces(sender);
|
const currentNonce = await this.nonces.nonces(sender);
|
||||||
expect(currentNonce).to.be.bignumber.equal('0');
|
expect(currentNonce).to.be.bignumber.equal('0');
|
||||||
|
|
||||||
const { receipt } = await this.nonces.$_useCheckedNonce(sender, currentNonce);
|
await this.nonces.$_useCheckedNonce(sender, currentNonce);
|
||||||
expectEvent(receipt, 'return$_useCheckedNonce', [currentNonce]);
|
|
||||||
|
|
||||||
expect(await this.nonces.nonces(sender)).to.be.bignumber.equal('1');
|
expect(await this.nonces.nonces(sender)).to.be.bignumber.equal('1');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user