Skip to content

Commit e0ca256

Browse files
committed
Merge branch 'master' into feat/access-manager-enumerable
2 parents 0b981fd + ea89d42 commit e0ca256

37 files changed

+178
-77
lines changed

.changeset/full-emus-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': minor
3+
---
4+
5+
`Account`: Update default version of the ERC-4337 entrypoint to v0.9.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Breaking changes
44

5+
- `ERC1967Proxy` and `TransparentUpgradeableProxy`: Mandate initialization during construction. Deployment now reverts with `ERC1967ProxyUninitialized` if an initialize call is not provided. Developers that rely on the previous behavior and want to disable this check can do so by overriding the internal `_unsafeAllowUninitialized` function to return true.
6+
- `ERC721` and `ERC1155`: Prevent setting an operator for `address(0)`. In the case of `ERC721` this type of operator allowance could lead to obfuscated mint permission.
57
- `RLP`: The `encode(bytes32)` function now encodes `bytes32` as a fixed size item and not as a scalar in `encode(uint256)`. Users must replace calls to `encode(bytes32)` with `encode(uint256(bytes32))` to preserve the same behavior.
68

79
## 5.5.0 (2025-10-31)

contracts/account/Account.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ abstract contract Account is AbstractSigner, IAccount {
5050
* @dev Canonical entry point for the account that forwards and validates user operations.
5151
*/
5252
function entryPoint() public view virtual returns (IEntryPoint) {
53-
return ERC4337Utils.ENTRYPOINT_V08;
53+
return ERC4337Utils.ENTRYPOINT_V09;
5454
}
5555

5656
/**

contracts/account/utils/draft-ERC4337Utils.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ library ERC4337Utils {
2727
/// @dev Address of the entrypoint v0.8.0
2828
IEntryPoint internal constant ENTRYPOINT_V08 = IEntryPoint(0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108);
2929

30+
/// @dev Address of the entrypoint v0.9.0
31+
IEntryPoint internal constant ENTRYPOINT_V09 = IEntryPoint(0x433709009B8330FDa32311DF1C2AFA402eD8D009);
32+
3033
/// @dev For simulation purposes, validateUserOp (and validatePaymasterUserOp) return this value on success.
3134
uint256 internal constant SIG_VALIDATION_SUCCESS = 0;
3235

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8.22;
4+
5+
import {ERC1967Proxy} from "../../proxy/ERC1967/ERC1967Proxy.sol";
6+
7+
contract ERC1967ProxyUnsafe is ERC1967Proxy {
8+
constructor(address implementation, bytes memory _data) payable ERC1967Proxy(implementation, _data) {}
9+
10+
function _unsafeAllowUninitialized() internal pure override returns (bool) {
11+
return true;
12+
}
13+
}

contracts/proxy/ERC1967/ERC1967Proxy.sol

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,28 @@ import {ERC1967Utils} from "./ERC1967Utils.sol";
1313
* implementation behind the proxy.
1414
*/
1515
contract ERC1967Proxy is Proxy {
16+
/**
17+
* @dev The proxy is left uninitialized.
18+
*/
19+
error ERC1967ProxyUninitialized();
20+
1621
/**
1722
* @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`.
1823
*
19-
* If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
20-
* encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
24+
* Provided `_data` is passed in a delegate call to `implementation`. This will typically be an encoded function
25+
* call, and allows initializing the storage of the proxy like a Solidity constructor. By default construction
26+
* will fail if `_data` is empty. This behavior can be overridden using a custom {_unsafeAllowUninitialized} that
27+
* returns true. In that case, empty `_data` is ignored and no delegate call to the implementation is performed
28+
* during construction.
2129
*
2230
* Requirements:
2331
*
2432
* - If `data` is empty, `msg.value` must be zero.
2533
*/
2634
constructor(address implementation, bytes memory _data) payable {
35+
if (!_unsafeAllowUninitialized() && _data.length == 0) {
36+
revert ERC1967ProxyUninitialized();
37+
}
2738
ERC1967Utils.upgradeToAndCall(implementation, _data);
2839
}
2940

@@ -37,4 +48,15 @@ contract ERC1967Proxy is Proxy {
3748
function _implementation() internal view virtual override returns (address) {
3849
return ERC1967Utils.getImplementation();
3950
}
51+
52+
/**
53+
* @dev Returns whether the proxy can be left uninitialized.
54+
*
55+
* NOTE: Override this function to allow the proxy to be left uninitialized.
56+
* Consider uninitialized proxies might be susceptible to man-in-the-middle threats
57+
* where the proxy is replaced with a malicious one.
58+
*/
59+
function _unsafeAllowUninitialized() internal pure virtual returns (bool) {
60+
return false;
61+
}
4062
}

contracts/token/ERC1155/ERC1155.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IER
356356
* - `operator` cannot be the zero address.
357357
*/
358358
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
359+
if (owner == address(0)) {
360+
revert ERC1155InvalidApprover(address(0));
361+
}
359362
if (operator == address(0)) {
360363
revert ERC1155InvalidOperator(address(0));
361364
}

contracts/token/ERC721/ERC721.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Er
407407
* Emits an {ApprovalForAll} event.
408408
*/
409409
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
410+
if (owner == address(0)) {
411+
revert ERC721InvalidApprover(address(0));
412+
}
410413
if (operator == address(0)) {
411414
revert ERC721InvalidOperator(operator);
412415
}

contracts/utils/Base64.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ library Base64 {
208208
// slither-disable-next-line incorrect-shift
209209
if iszero(and(shl(d, 1), 0xffffffd0ffffffc47ff5)) {
210210
mstore(0, errorSelector)
211-
mstore(4, add(d, 43))
211+
mstore(4, shl(248, add(d, 43)))
212212
revert(0, 0x24)
213213
}
214214

package-lock.json

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)