Skip to content

Commit

Permalink
Merge branch 'OpenZeppelin:master' into feat/ERC-7540
Browse files Browse the repository at this point in the history
  • Loading branch information
DeeJayElly authored Jan 24, 2025
2 parents 2784e8b + 6dc9242 commit 5dd9d86
Show file tree
Hide file tree
Showing 26 changed files with 80 additions and 84 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-drinks-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openzeppelin-solidity": minor
---

`Pausable`: Stop explicitly setting `paused` to `false` during construction.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ npm-debug.log

# docs artifacts
docs/modules/api
build/site

# only used to package @openzeppelin/contracts
contracts/build/
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

### Breaking Changes

- Replace `GovernorCountingOverridable.VoteReceipt` struct parameter member names `hasOverriden` and `overridenWeight` for `hasOverridden` and `overriddenWeight` respectively.

#### Custom error changes

- Replace `GovernorAlreadyOverridenVote` with `GovernorAlreadyOverriddenVote`.

## 5.2.0 (2025-01-08)

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion contracts/governance/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ abstract contract Governor is Context, ERC165, EIP712, Nonces, IGovernor, IERC72
* performed (for example adding a vault/timelock).
*
* NOTE: Calling this function directly will NOT check the current state of the proposal, set the executed flag to
* true or emit the `ProposalExecuted` event. Executing a proposal should be done using {execute} or {_execute}.
* true or emit the `ProposalExecuted` event. Executing a proposal should be done using {execute}.
*/
function _executeOperations(
uint256 /* proposalId */,
Expand Down
4 changes: 2 additions & 2 deletions contracts/governance/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ NOTE: Functions of the `Governor` contract do not include access control. If you

{{GovernorCountingFractional}}

{{GovernorCountingOverride}}
{{GovernorCountingOverridable}}

{{GovernorVotes}}

Expand Down Expand Up @@ -103,7 +103,7 @@ In a governance system, the {TimelockController} contract is in charge of introd
[[timelock-terminology]]
==== Terminology

* *Operation:* A transaction (or a set of transactions) that is the subject of the timelock. It has to be scheduled by a proposer and executed by an executor. The timelock enforces a minimum delay between the proposition and the execution (see xref:access-control.adoc#operation_lifecycle[operation lifecycle]). If the operation contains multiple transactions (batch mode), they are executed atomically. Operations are identified by the hash of their content.
* *Operation:* A transaction (or a set of transactions) that is the subject of the timelock. It has to be scheduled by a proposer and executed by an executor. The timelock enforces a minimum delay between the proposition and the execution. If the operation contains multiple transactions (batch mode), they are executed atomically. Operations are identified by the hash of their content.
* *Operation status:*
** *Unset:* An operation that is not part of the timelock mechanism.
** *Waiting:* An operation that has been scheduled, before the timer expires.
Expand Down
34 changes: 17 additions & 17 deletions contracts/governance/extensions/GovernorCountingOverridable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ abstract contract GovernorCountingOverridable is GovernorVotes {

struct VoteReceipt {
uint8 casted; // 0 if vote was not casted. Otherwise: support + 1
bool hasOverriden;
uint208 overridenWeight;
bool hasOverridden;
uint208 overriddenWeight;
}

struct ProposalVote {
Expand All @@ -42,7 +42,7 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
/// @dev A delegated vote on `proposalId` was overridden by `weight`
event OverrideVoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason);

error GovernorAlreadyOverridenVote(address account);
error GovernorAlreadyOverriddenVote(address account);

mapping(uint256 proposalId => ProposalVote) private _proposalVotes;

Expand Down Expand Up @@ -70,7 +70,7 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
* @dev Check if an `account` has overridden their delegate for a proposal.
*/
function hasVotedOverride(uint256 proposalId, address account) public view virtual returns (bool) {
return _proposalVotes[proposalId].voteReceipt[account].hasOverriden;
return _proposalVotes[proposalId].voteReceipt[account].hasOverridden;
}

/**
Expand Down Expand Up @@ -122,7 +122,7 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
revert GovernorAlreadyCastVote(account);
}

totalWeight -= proposalVote.voteReceipt[account].overridenWeight;
totalWeight -= proposalVote.voteReceipt[account].overriddenWeight;
proposalVote.votes[support] += totalWeight;
proposalVote.voteReceipt[account].casted = support + 1;

Expand All @@ -141,26 +141,26 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
revert GovernorInvalidVoteType();
}

if (proposalVote.voteReceipt[account].hasOverriden) {
revert GovernorAlreadyOverridenVote(account);
if (proposalVote.voteReceipt[account].hasOverridden) {
revert GovernorAlreadyOverriddenVote(account);
}

uint256 snapshot = proposalSnapshot(proposalId);
uint256 overridenWeight = VotesExtended(address(token())).getPastBalanceOf(account, snapshot);
uint256 overriddenWeight = VotesExtended(address(token())).getPastBalanceOf(account, snapshot);
address delegate = VotesExtended(address(token())).getPastDelegate(account, snapshot);
uint8 delegateCasted = proposalVote.voteReceipt[delegate].casted;

proposalVote.voteReceipt[account].hasOverriden = true;
proposalVote.votes[support] += overridenWeight;
proposalVote.voteReceipt[account].hasOverridden = true;
proposalVote.votes[support] += overriddenWeight;
if (delegateCasted == 0) {
proposalVote.voteReceipt[delegate].overridenWeight += SafeCast.toUint208(overridenWeight);
proposalVote.voteReceipt[delegate].overriddenWeight += SafeCast.toUint208(overriddenWeight);
} else {
uint8 delegateSupport = delegateCasted - 1;
proposalVote.votes[delegateSupport] -= overridenWeight;
emit VoteReduced(delegate, proposalId, delegateSupport, overridenWeight);
proposalVote.votes[delegateSupport] -= overriddenWeight;
emit VoteReduced(delegate, proposalId, delegateSupport, overriddenWeight);
}

return overridenWeight;
return overriddenWeight;
}

/// @dev Variant of {Governor-_castVote} that deals with vote overrides. Returns the overridden weight.
Expand All @@ -172,13 +172,13 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
) internal virtual returns (uint256) {
_validateStateBitmap(proposalId, _encodeStateBitmap(ProposalState.Active));

uint256 overridenWeight = _countOverride(proposalId, account, support);
uint256 overriddenWeight = _countOverride(proposalId, account, support);

emit OverrideVoteCast(account, proposalId, support, overridenWeight, reason);
emit OverrideVoteCast(account, proposalId, support, overriddenWeight, reason);

_tallyUpdated(proposalId);

return overridenWeight;
return overriddenWeight;
}

/// @dev Public function for casting an override vote. Returns the overridden weight.
Expand Down
2 changes: 1 addition & 1 deletion contracts/governance/extensions/GovernorStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract contract GovernorStorage is Governor {
}

/**
* @dev Version of {IGovernorTimelock-queue} with only `proposalId` as an argument.
* @dev Version of {IGovernor-queue} with only `proposalId` as an argument.
*/
function queue(uint256 proposalId) public virtual {
// here, using storage is more efficient than memory
Expand Down
2 changes: 1 addition & 1 deletion contracts/governance/extensions/GovernorTimelockAccess.sol
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ abstract contract GovernorTimelockAccess is Governor {
}

/**
* @dev See {IGovernor-_cancel}
* @dev See {Governor-_cancel}
*/
function _cancel(
address[] memory targets,
Expand Down
1 change: 0 additions & 1 deletion contracts/proxy/utils/UUPSUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ abstract contract UUPSUpgradeable is IERC1822Proxiable {
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
* See {_onlyProxy}.
*/
function _checkProxy() internal view virtual {
if (
Expand Down
4 changes: 2 additions & 2 deletions contracts/token/ERC1155/IERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ interface IERC1155 is IERC165 {
* @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {onERC1155Received} on the receiver.
* to an untrusted contract, when invoking {IERC1155Receiver-onERC1155Received} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
Expand All @@ -101,7 +101,7 @@ interface IERC1155 is IERC165 {
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
* to an untrusted contract, when invoking {IERC1155Receiver-onERC1155BatchReceived} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
Expand Down
4 changes: 2 additions & 2 deletions contracts/token/ERC1155/utils/ERC1155Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {IERC1155Errors} from "../../../interfaces/draft-IERC6093.sol";
*/
library ERC1155Utils {
/**
* @dev Performs an acceptance check for the provided `operator` by calling {IERC1155-onERC1155Received}
* @dev Performs an acceptance check for the provided `operator` by calling {IERC1155Receiver-onERC1155Received}
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
*
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
Expand Down Expand Up @@ -50,7 +50,7 @@ library ERC1155Utils {
}

/**
* @dev Performs a batch acceptance check for the provided `operator` by calling {IERC1155-onERC1155BatchReceived}
* @dev Performs a batch acceptance check for the provided `operator` by calling {IERC1155Receiver-onERC1155BatchReceived}
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
*
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC20/extensions/ERC4626.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {Math} from "../../../utils/math/Math.sol";
* offset (0) makes it non-profitable even if an attacker is able to capture value from multiple user deposits, as a result
* of the value being captured by the virtual shares (out of the attacker's donation) matching the attacker's expected gains.
* With a larger offset, the attack becomes orders of magnitude more expensive than it is profitable. More details about the
* underlying math can be found xref:erc4626.adoc#inflation-attack[here].
* underlying math can be found xref:ROOT:erc4626.adoc#inflation-attack[here].
*
* The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued
* to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC721/extensions/ERC721Consecutive.sol
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 {
}

/**
* @dev Used to offset the first token id in {_nextConsecutiveId}
* @dev Used to offset the first token id in `_nextConsecutiveId`
*/
function _firstConsecutiveId() internal view virtual returns (uint96) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC721/extensions/ERC721URIStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ abstract contract ERC721URIStorage is IERC4906, ERC721 {
/**
* @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
*
* Emits {MetadataUpdate}.
* Emits {IERC4906-MetadataUpdate}.
*/
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
_tokenURIs[tokenId] = _tokenURI;
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC721/utils/ERC721Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {IERC721Errors} from "../../../interfaces/draft-IERC6093.sol";
*/
library ERC721Utils {
/**
* @dev Performs an acceptance check for the provided `operator` by calling {IERC721-onERC721Received}
* @dev Performs an acceptance check for the provided `operator` by calling {IERC721Receiver-onERC721Received}
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
*
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
Expand Down
4 changes: 2 additions & 2 deletions contracts/utils/Multicall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {Context} from "./Context.sol";
* careful about sending transactions invoking {multicall}. For example, a relay address that filters function
* selectors won't filter calls nested within a {multicall} operation.
*
* NOTE: Since 5.0.1 and 4.9.4, this contract identifies non-canonical contexts (i.e. `msg.sender` is not {_msgSender}).
* NOTE: Since 5.0.1 and 4.9.4, this contract identifies non-canonical contexts (i.e. `msg.sender` is not {Context-_msgSender}).
* If a non-canonical context is identified, the following self `delegatecall` appends the last bytes of `msg.data`
* to the subcall. This makes it safe to use with {ERC2771Context}. Contexts that don't affect the resolution of
* {_msgSender} are not propagated to subcalls.
* {Context-_msgSender} are not propagated to subcalls.
*/
abstract contract Multicall is Context {
/**
Expand Down
7 changes: 0 additions & 7 deletions contracts/utils/Pausable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ abstract contract Pausable is Context {
*/
error ExpectedPause();

/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}

/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
Expand Down
4 changes: 2 additions & 2 deletions contracts/utils/ShortStrings.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ library ShortStrings {
}

/**
* @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
* @dev Decode a string that was encoded to `ShortString` or written to storage using {toShortStringWithFallback}.
*/
function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
Expand All @@ -107,7 +107,7 @@ library ShortStrings {

/**
* @dev Return the length of a string that was encoded to `ShortString` or written to storage using
* {setWithFallback}.
* {toShortStringWithFallback}.
*
* WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
* actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
Expand Down
18 changes: 9 additions & 9 deletions contracts/utils/Strings.sol
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ library Strings {
}

/**
* @dev Variant of {parseUint} that parses a substring of `input` located between position `begin` (included) and
* @dev Variant of {parseUint-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
Expand Down Expand Up @@ -177,7 +177,7 @@ library Strings {
}

/**
* @dev Implementation of {tryParseUint} that does not check bounds. Caller should make sure that
* @dev Implementation of {tryParseUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseUintUncheckedBounds(
Expand Down Expand Up @@ -250,7 +250,7 @@ library Strings {
}

/**
* @dev Implementation of {tryParseInt} that does not check bounds. Caller should make sure that
* @dev Implementation of {tryParseInt-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseIntUncheckedBounds(
Expand Down Expand Up @@ -287,7 +287,7 @@ library Strings {
}

/**
* @dev Variant of {parseHexUint} that parses a substring of `input` located between position `begin` (included) and
* @dev Variant of {parseHexUint-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
Expand Down Expand Up @@ -325,7 +325,7 @@ library Strings {
}

/**
* @dev Implementation of {tryParseHexUint} that does not check bounds. Caller should make sure that
* @dev Implementation of {tryParseHexUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseHexUintUncheckedBounds(
Expand All @@ -346,7 +346,7 @@ library Strings {
result *= 16;
unchecked {
// Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).
// This guaratees that adding a value < 16 will not cause an overflow, hence the unchecked.
// This guarantees that adding a value < 16 will not cause an overflow, hence the unchecked.
result += chr;
}
}
Expand All @@ -364,7 +364,7 @@ library Strings {
}

/**
* @dev Variant of {parseAddress} that parses a substring of `input` located between position `begin` (included) and
* @dev Variant of {parseAddress-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
Expand All @@ -378,15 +378,15 @@ library Strings {

/**
* @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly
* formatted address. See {parseAddress} requirements.
* formatted address. See {parseAddress-string} requirements.
*/
function tryParseAddress(string memory input) internal pure returns (bool success, address value) {
return tryParseAddress(input, 0, bytes(input).length);
}

/**
* @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly
* formatted address. See {parseAddress} requirements.
* formatted address. See {parseAddress-string-uint256-uint256} requirements.
*/
function tryParseAddress(
string memory input,
Expand Down
2 changes: 1 addition & 1 deletion contracts/utils/cryptography/EIP712.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ abstract contract EIP712 is IERC5267 {
}

/**
* @dev See {IERC-5267}.
* @inheritdoc IERC5267
*/
function eip712Domain()
public
Expand Down
11 changes: 0 additions & 11 deletions docs/modules/ROOT/pages/crowdsales.adoc

This file was deleted.

Loading

0 comments on commit 5dd9d86

Please sign in to comment.