Skip to content

Commit 9829142

Browse files
committed
actually think we can use the same upgrade auth
1 parent e02d844 commit 9829142

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/EIP7702Proxy.sol

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,21 @@ contract EIP7702Proxy is Proxy, CustomUpgradeable {
163163

164164
function upgradeToAndCall(
165165
address newImplementation,
166-
bytes memory data,
167-
bytes calldata signature
168-
) public payable override {
169-
// Create hash of upgrade data
170-
bytes32 hash = keccak256(abi.encode(proxy, newImplementation, data));
166+
bytes memory data
167+
) public payable {
168+
// Check ownership using same logic as _checkOwner
169+
(bool success, bytes memory result) = _implementation().delegatecall(
170+
abi.encodeWithSignature("isOwnerAddress(address)", msg.sender)
171+
);
171172

172-
// Use our existing isValidSignature logic to validate the upgrade
173-
if (this.isValidSignature(hash, signature) != ERC1271_MAGIC_VALUE) {
173+
if (
174+
!success ||
175+
(!abi.decode(result, (bool)) && msg.sender != address(this))
176+
) {
174177
revert Unauthorized();
175178
}
176179

177-
// If signature valid, proceed with upgrade
180+
// If sender is owner or contract itself, proceed with upgrade
178181
_setImplementation(newImplementation);
179182
emit Upgraded(newImplementation);
180183

0 commit comments

Comments
 (0)