Skip to content

Commit 358b0e5

Browse files
committed
rename extension
1 parent d51a1cf commit 358b0e5

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

contracts/governance/Governor.sol

+3-5
Original file line numberDiff line numberDiff line change
@@ -631,17 +631,15 @@ abstract contract Governor is Context, ERC165, EIP712, Nonces, IGovernor, IERC72
631631
address voter,
632632
uint256 /* proposalId */,
633633
bytes memory signature,
634-
bytes memory rawSignatureDigestData,
634+
bytes memory digestPreimage,
635635
uint256 noncePositionOffset
636636
) internal virtual returns (bool) {
637637
uint256 nonce = nonces(voter);
638638
assembly ("memory-safe") {
639-
mstore(add(rawSignatureDigestData, noncePositionOffset), nonce)
639+
mstore(add(digestPreimage, noncePositionOffset), nonce)
640640
}
641641

642-
if (
643-
SignatureChecker.isValidSignatureNow(voter, _hashTypedDataV4(keccak256(rawSignatureDigestData)), signature)
644-
) {
642+
if (SignatureChecker.isValidSignatureNow(voter, _hashTypedDataV4(keccak256(digestPreimage)), signature)) {
645643
_useNonce(voter);
646644
return true;
647645
}

contracts/governance/extensions/GovernorKeyedNonces.sol contracts/governance/extensions/GovernorNoncesKeyed.sol

+5-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {Nonces} from "../../utils/Nonces.sol";
77
import {NoncesKeyed} from "../../utils/NoncesKeyed.sol";
88
import {SignatureChecker} from "../../utils/cryptography/SignatureChecker.sol";
99

10-
abstract contract GovernorKeyedNonces is Governor, NoncesKeyed {
10+
abstract contract GovernorNoncesKeyed is Governor, NoncesKeyed {
1111
function _useCheckedNonce(address owner, uint256 nonce) internal virtual override(Nonces, NoncesKeyed) {
1212
super._useCheckedNonce(owner, nonce);
1313
}
@@ -16,22 +16,20 @@ abstract contract GovernorKeyedNonces is Governor, NoncesKeyed {
1616
address voter,
1717
uint256 proposalId,
1818
bytes memory signature,
19-
bytes memory rawSignatureDigestData,
19+
bytes memory digestPreimage,
2020
uint256 noncePositionOffset
2121
) internal virtual override returns (bool) {
22-
if (super._validateVoteSignature(voter, proposalId, signature, rawSignatureDigestData, noncePositionOffset)) {
22+
if (super._validateVoteSignature(voter, proposalId, signature, digestPreimage, noncePositionOffset)) {
2323
return true;
2424
}
2525

2626
// uint192 is sufficient entropy for proposalId within nonce keys.
2727
uint256 keyedNonce = nonces(voter, uint192(proposalId));
2828
assembly ("memory-safe") {
29-
mstore(add(rawSignatureDigestData, noncePositionOffset), keyedNonce)
29+
mstore(add(digestPreimage, noncePositionOffset), keyedNonce)
3030
}
3131

32-
if (
33-
SignatureChecker.isValidSignatureNow(voter, _hashTypedDataV4(keccak256(rawSignatureDigestData)), signature)
34-
) {
32+
if (SignatureChecker.isValidSignatureNow(voter, _hashTypedDataV4(keccak256(digestPreimage)), signature)) {
3533
_useNonce(voter, uint192(proposalId));
3634
return true;
3735
}

contracts/mocks/governance/GovernorKeyedNoncesMock.sol contracts/mocks/governance/GovernorNoncesKeyedMock.sol

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import {GovernorSettings} from "../../governance/extensions/GovernorSettings.sol
77
import {GovernorCountingSimple} from "../../governance/extensions/GovernorCountingSimple.sol";
88
import {GovernorVotesQuorumFraction} from "../../governance/extensions/GovernorVotesQuorumFraction.sol";
99
import {GovernorProposalGuardian} from "../../governance/extensions/GovernorProposalGuardian.sol";
10-
import {GovernorKeyedNonces} from "../../governance/extensions/GovernorKeyedNonces.sol";
10+
import {GovernorNoncesKeyed} from "../../governance/extensions/GovernorNoncesKeyed.sol";
1111

12-
abstract contract GovernorKeyedNoncesMock is
12+
abstract contract GovernorNoncesKeyedMock is
1313
GovernorSettings,
1414
GovernorVotesQuorumFraction,
1515
GovernorCountingSimple,
16-
GovernorKeyedNonces
16+
GovernorNoncesKeyed
1717
{
1818
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256) {
1919
return super.proposalThreshold();
@@ -25,11 +25,11 @@ abstract contract GovernorKeyedNoncesMock is
2525
bytes memory signature,
2626
bytes memory rawSignatureDigestData,
2727
uint256 noncePositionOffset
28-
) internal virtual override(Governor, GovernorKeyedNonces) returns (bool) {
28+
) internal virtual override(Governor, GovernorNoncesKeyed) returns (bool) {
2929
return super._validateVoteSignature(voter, proposalId, signature, rawSignatureDigestData, noncePositionOffset);
3030
}
3131

32-
function _useCheckedNonce(address owner, uint256 nonce) internal virtual override(Nonces, GovernorKeyedNonces) {
32+
function _useCheckedNonce(address owner, uint256 nonce) internal virtual override(Nonces, GovernorNoncesKeyed) {
3333
super._useCheckedNonce(owner, nonce);
3434
}
3535
}

test/governance/extensions/GovernorKeyedNonces.test.js test/governance/extensions/GovernorNoncesKeyed.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const signBallot = account => (contract, message) =>
2525
const signExtendedBallot = account => (contract, message) =>
2626
getDomain(contract).then(domain => account.signTypedData(domain, { ExtendedBallot }, message));
2727

28-
describe('GovernorKeyedNonces', function () {
28+
describe('GovernorNoncesKeyed', function () {
2929
for (const { Token, mode } of TOKENS) {
3030
const fixture = async () => {
3131
const [owner, proposer, voter1, voter2, voter3, voter4, userEOA] = await ethers.getSigners();
3232
const receiver = await ethers.deployContract('CallReceiverMock');
3333

3434
const token = await ethers.deployContract(Token, [tokenName, tokenSymbol, tokenName, version]);
35-
const mock = await ethers.deployContract('$GovernorKeyedNoncesMock', [
35+
const mock = await ethers.deployContract('$GovernorNoncesKeyedMock', [
3636
name, // name
3737
votingDelay, // initialVotingDelay
3838
votingPeriod, // initialVotingPeriod

0 commit comments

Comments
 (0)