Skip to content

Commit

Permalink
implement common ITransParentVerifiableProxy interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanrikulu committed Nov 21, 2024
1 parent b7d1d1c commit ea98561
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 10 additions & 0 deletions src/ITransparentVerifiableProxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface ITransParentVerifiableProxy {
function salt() external view returns (uint256);

function owner() external view returns (address);

function creator() external view returns (address);
}
3 changes: 2 additions & 1 deletion src/TransparentVerifiableProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pragma solidity ^0.8.20;
import {Proxy} from "@openzeppelin/contracts/proxy/Proxy.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import {ITransParentVerifiableProxy} from "./ITransparentVerifiableProxy.sol";

// EIP-2535 Diamond Storage pattern
// ref: https://eips.ethereum.org/EIPS/eip-2535#storage
Expand All @@ -24,7 +25,7 @@ library StorageSlot {
}
}

interface ITransparentVerifiableProxy {
interface ITransparentVerifiableProxy is ITransParentVerifiableProxy {
/// @dev See {UUPSUpgradeable-upgradeToAndCall}
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable;
}
Expand Down
13 changes: 4 additions & 9 deletions src/VerifiableFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ pragma solidity ^0.8.20;
import {console} from "forge-std/console.sol";
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
import {ITransparentVerifiableProxy, TransparentVerifiableProxy} from "./TransparentVerifiableProxy.sol";

interface IProxy {
function salt() external view returns (uint256);

function owner() external view returns (address);
}
import {ITransParentVerifiableProxy} from "./ITransParentVerifiableProxy.sol";

contract VerifiableFactory {
event ProxyDeployed(address indexed sender, address indexed proxyAddress, uint256 salt, address implementation);
Expand Down Expand Up @@ -48,7 +43,7 @@ contract VerifiableFactory {

// Function to upgrade the proxy's implementation (only owner of proxy can call this)
function upgradeImplementation(address proxyAddress, address newImplementation, bytes memory data) external {
address owner = IProxy(proxyAddress).owner();
address owner = ITransparentVerifiableProxy(proxyAddress).owner();
require(owner == msg.sender, "Only the owner can upgrade");

// Upgrade the proxy to point to the new implementation
Expand All @@ -69,8 +64,8 @@ contract VerifiableFactory {
if (!isContract(proxy)) {
return false;
}
try IProxy(proxy).salt() returns (uint256 salt) {
try IProxy(proxy).owner() returns (address owner) {
try ITransparentVerifiableProxy(proxy).salt() returns (uint256 salt) {
try ITransparentVerifiableProxy(proxy).owner() returns (address owner) {
return _verifyContract(proxy, owner, salt);
} catch {}
} catch {}
Expand Down

0 comments on commit ea98561

Please sign in to comment.