Skip to content

Commit

Permalink
Merge branch 'premint' into add_uups_helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kulkarohan authored Sep 27, 2023
2 parents 7b92825 + ed9e493 commit 70619ba
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 62 deletions.
20 changes: 9 additions & 11 deletions .storage-layout
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@
➡ ZoraCreator1155FactoryImpl
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|------------------|----------------------------------------------|------|--------|-------|-----------------------------------------------------------------------|
| _owner | address | 0 | 0 | 20 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| _pendingOwner | address | 1 | 0 | 20 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| __gap | uint256[50] | 2 | 0 | 1600 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| _initialized | uint8 | 52 | 0 | 1 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| _initializing | bool | 52 | 1 | 1 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| isAllowedUpgrade | mapping(address => mapping(address => bool)) | 53 | 0 | 32 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| __gap | uint256[50] | 54 | 0 | 1600 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| __gap | uint256[50] | 104 | 0 | 1600 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| __gap | uint256[50] | 154 | 0 | 1600 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| Name | Type | Slot | Offset | Bytes | Contract |
|---------------|-------------|------|--------|-------|-----------------------------------------------------------------------|
| _owner | address | 0 | 0 | 20 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| _pendingOwner | address | 1 | 0 | 20 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| __gap | uint256[50] | 2 | 0 | 1600 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| _initialized | uint8 | 52 | 0 | 1 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| _initializing | bool | 52 | 1 | 1 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| __gap | uint256[50] | 53 | 0 | 1600 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
| __gap | uint256[50] | 103 | 0 | 1600 | src/factory/ZoraCreator1155FactoryImpl.sol:ZoraCreator1155FactoryImpl |
2 changes: 1 addition & 1 deletion script/ZoraDeployerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {ZoraCreator1155PremintExecutor} from "../src/delegation/ZoraCreator1155P
import {IMinter1155} from "../src/interfaces/IMinter1155.sol";

/// @notice Deployment drops for base where
abstract contract ZoraDeployerBase is ScriptDeploymentConfig, Script {
abstract contract ZoraDeployerBase is ScriptDeploymentConfig {
using stdJson for string;

/// @notice File used for demo metadata on verification test mint
Expand Down
3 changes: 2 additions & 1 deletion src/deployment/DeploymentConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.17;
import "forge-std/Test.sol";
import {CommonBase} from "forge-std/Base.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {Script} from "forge-std/Script.sol";

/// @notice Chain configuration for constants set manually during deploy. Does not get written to after deploys.
struct ChainConfig {
Expand Down Expand Up @@ -37,7 +38,7 @@ struct Deployment {
address preminter;
}

abstract contract DeploymentConfig is CommonBase {
abstract contract DeploymentConfig is Script {
using stdJson for string;

/// @notice ChainID convenience getter
Expand Down
1 change: 0 additions & 1 deletion src/factory/ZoraCreator1155FactoryImpl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {ICreatorRoyaltiesControl} from "../interfaces/ICreatorRoyaltiesControl.s
import {IMinter1155} from "../interfaces/IMinter1155.sol";
import {IContractMetadata} from "../interfaces/IContractMetadata.sol";
import {Ownable2StepUpgradeable} from "../utils/ownable/Ownable2StepUpgradeable.sol";
import {FactoryManagedUpgradeGate} from "../upgrades/FactoryManagedUpgradeGate.sol";
import {Zora1155} from "../proxies/Zora1155.sol";
import {Create2Upgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol";
import {CREATE3} from "solmate/src/utils/CREATE3.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
pragma solidity 0.8.17;

/// @notice Factory Upgrade Gate Admin Factory Implementation – Allows specific contract upgrades as a safety measure
interface IFactoryManagedUpgradeGate {
interface IUpgradeGate {
/// @notice Event emitted when upgrade gate is emitted
event UpgradeGateSetup();

/// @notice If an implementation is registered by the Builder DAO as an optional upgrade
/// @param baseImpl The base implementation address
/// @param upgradeImpl The upgrade implementation address
Expand Down
10 changes: 5 additions & 5 deletions src/nft/ZoraCreator1155Impl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {ICreatorCommands} from "../interfaces/ICreatorCommands.sol";
import {IMinter1155} from "../interfaces/IMinter1155.sol";
import {IRenderer1155} from "../interfaces/IRenderer1155.sol";
import {ITransferHookReceiver} from "../interfaces/ITransferHookReceiver.sol";
import {IFactoryManagedUpgradeGate} from "../interfaces/IFactoryManagedUpgradeGate.sol";
import {IUpgradeGate} from "../interfaces/IUpgradeGate.sol";
import {IZoraCreator1155} from "../interfaces/IZoraCreator1155.sol";
import {LegacyNamingControl} from "../legacy-naming/LegacyNamingControl.sol";
import {PublicMulticall} from "../utils/PublicMulticall.sol";
Expand Down Expand Up @@ -67,15 +67,15 @@ contract ZoraCreator1155Impl is
/// @notice This user role allows for only withdrawing funds and setting funds withdraw address
uint256 public constant PERMISSION_BIT_FUNDS_MANAGER = 2 ** 5;
/// @notice Factory contract
IFactoryManagedUpgradeGate internal immutable factory;
IUpgradeGate internal immutable upgradeGate;

constructor(
uint256, // TODO remove
address _mintFeeRecipient,
address _factory,
address _upgradeGate,
address _protocolRewards
) ERC1155Rewards(_protocolRewards, _mintFeeRecipient) initializer {
factory = IFactoryManagedUpgradeGate(_factory);
upgradeGate = IUpgradeGate(_upgradeGate);
}

/// @notice Initializes the contract
Expand Down Expand Up @@ -771,7 +771,7 @@ contract ZoraCreator1155Impl is
/// @dev This function is called in `upgradeTo` & `upgradeToAndCall`
/// @param _newImpl The new implementation address
function _authorizeUpgrade(address _newImpl) internal view override onlyAdmin(CONTRACT_BASE_ID) {
if (!factory.isRegisteredUpgradePath(_getImplementation(), _newImpl)) {
if (!upgradeGate.isRegisteredUpgradePath(_getImplementation(), _newImpl)) {
revert();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {IFactoryManagedUpgradeGate} from "../interfaces/IFactoryManagedUpgradeGate.sol";
import {IUpgradeGate} from "../interfaces/IUpgradeGate.sol";
import {Ownable2StepUpgradeable} from "../utils/ownable/Ownable2StepUpgradeable.sol";
import {FactoryManagedUpgradeGateStorageV1} from "./FactoryManagedUpgradeGateStorageV1.sol";
import {UpgradeGateStorageV1} from "./UpgradeGateStorageV1.sol";

/// @title FactoryManagedUpgradeGate
/// @title UpgradeGate
/// @notice Contract for managing upgrades and safe upgrade paths for 1155 contracts
abstract contract FactoryManagedUpgradeGate is IFactoryManagedUpgradeGate, Ownable2StepUpgradeable, FactoryManagedUpgradeGateStorageV1 {
contract UpgradeGate is IUpgradeGate, Ownable2StepUpgradeable, UpgradeGateStorageV1 {
/// @notice Constructor for deployment pathway
constructor(address _defaultOwner) initializer {
__Ownable_init(_defaultOwner);
emit UpgradeGateSetup();
}

/// @notice The URI of the upgrade grate contract
function contractURI() external pure returns (string memory) {
return "https://github.com/ourzora/zora-1155-contracts/";
}

/// @notice The name of the upgrade gate contract
function contractName() external pure returns (string memory) {
return "ZORA 1155 Factory Managed Upgrade Gate";
}

/// ///
/// CREATOR TOKEN UPGRADES ///
/// CREATOR TOKEN UPGRADES ///
/// ///

/// @notice If an implementation is registered by the Builder DAO as an optional upgrade
/// @notice If an implementation is registered as an optional upgrade
/// @param baseImpl The base implementation address
/// @param upgradeImpl The upgrade implementation address
function isRegisteredUpgradePath(address baseImpl, address upgradeImpl) public view returns (bool) {
return isAllowedUpgrade[baseImpl][upgradeImpl];
}

/// @notice Called by the Builder DAO to offer implementation upgrades for created DAOs
/// @notice Registers optional upgrades
/// @param baseImpls The base implementation addresses
/// @param upgradeImpl The upgrade implementation address
function registerUpgradePath(address[] memory baseImpls, address upgradeImpl) public onlyOwner {
Expand All @@ -31,7 +47,7 @@ abstract contract FactoryManagedUpgradeGate is IFactoryManagedUpgradeGate, Ownab
}
}

/// @notice Called by the Builder DAO to remove an upgrade
/// @notice Removes an upgrade
/// @param baseImpl The base implementation address
/// @param upgradeImpl The upgrade implementation address
function removeUpgradePath(address baseImpl, address upgradeImpl) public onlyOwner {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

abstract contract FactoryManagedUpgradeGateStorageV1 {
abstract contract UpgradeGateStorageV1 {
mapping(address => mapping(address => bool)) public isAllowedUpgrade;

uint256[50] private __gap;
Expand Down
8 changes: 6 additions & 2 deletions test/factory/ZoraCreator1155Factory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {IZoraCreator1155Errors} from "../../src/interfaces/IZoraCreator1155Error
import {IMinter1155} from "../../src/interfaces/IMinter1155.sol";
import {ICreatorRoyaltiesControl} from "../../src/interfaces/ICreatorRoyaltiesControl.sol";
import {Zora1155} from "../../src/proxies/Zora1155.sol";
import {UpgradeGate} from "../../src/upgrades/UpgradeGate.sol";
import {MockContractMetadata} from "../mock/MockContractMetadata.sol";
import {ProxyShim} from "../../src/utils/ProxyShim.sol";

Expand All @@ -21,16 +22,19 @@ contract ZoraCreator1155FactoryTest is Test {

ZoraCreator1155FactoryImpl internal factoryImpl;
ZoraCreator1155FactoryImpl internal factory;
UpgradeGate internal upgradeGate;

function setUp() external {
zora = makeAddr("zora");
mintFeeAmount = 0.000777 ether;

upgradeGate = new UpgradeGate(zora);

address factoryShimAddress = address(new ProxyShim(zora));
Zora1155Factory factoryProxy = new Zora1155Factory(factoryShimAddress, "");

ProtocolRewards protocolRewards = new ProtocolRewards();
ZoraCreator1155Impl zoraCreator1155Impl = new ZoraCreator1155Impl(mintFeeAmount, zora, address(factoryProxy), address(protocolRewards));
ZoraCreator1155Impl zoraCreator1155Impl = new ZoraCreator1155Impl(mintFeeAmount, zora, address(upgradeGate), address(protocolRewards));

factoryImpl = new ZoraCreator1155FactoryImpl(zoraCreator1155Impl, IMinter1155(address(1)), IMinter1155(address(2)), IMinter1155(address(3)));
factory = ZoraCreator1155FactoryImpl(address(factoryProxy));
Expand Down Expand Up @@ -253,7 +257,7 @@ contract ZoraCreator1155FactoryTest is Test {
baseImpls[0] = address(factory.implementation());

vm.prank(zora);
factory.registerUpgradePath(baseImpls, address(newZoraCreator));
upgradeGate.registerUpgradePath(baseImpls, address(newZoraCreator));

vm.prank(creatorProxy.owner());
creatorProxy.upgradeTo(address(newZoraCreator));
Expand Down
10 changes: 0 additions & 10 deletions test/mock/MockUpgradeGate.sol

This file was deleted.

10 changes: 0 additions & 10 deletions test/mock/MockUpgradeGateBase.sol

This file was deleted.

12 changes: 6 additions & 6 deletions test/nft/ZoraCreator1155.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {MathUpgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/cont
import {ZoraCreator1155Impl} from "../../src/nft/ZoraCreator1155Impl.sol";
import {Zora1155} from "../../src/proxies/Zora1155.sol";
import {ZoraCreatorFixedPriceSaleStrategy} from "../../src/minters/fixed-price/ZoraCreatorFixedPriceSaleStrategy.sol";
import {UpgradeGate} from "../../src/upgrades/UpgradeGate.sol";

import {IZoraCreator1155Errors} from "../../src/interfaces/IZoraCreator1155Errors.sol";
import {IZoraCreator1155} from "../../src/interfaces/IZoraCreator1155.sol";
Expand All @@ -20,7 +21,6 @@ import {ICreatorRendererControl} from "../../src/interfaces/ICreatorRendererCont

import {SimpleMinter} from "../mock/SimpleMinter.sol";
import {SimpleRenderer} from "../mock/SimpleRenderer.sol";
import {MockUpgradeGate} from "../mock/MockUpgradeGate.sol";

contract ZoraCreator1155Test is Test {
using stdJson for string;
Expand All @@ -31,7 +31,7 @@ contract ZoraCreator1155Test is Test {

SimpleMinter simpleMinter;
ZoraCreatorFixedPriceSaleStrategy internal fixedPriceMinter;
MockUpgradeGate internal upgradeGate;
UpgradeGate internal upgradeGate;

address payable internal admin;
address internal recipient;
Expand All @@ -55,16 +55,16 @@ contract ZoraCreator1155Test is Test {
createReferral = makeAddr("createReferral");
zora = makeAddr("zora");

admin = payable(vm.addr(0x1));
recipient = vm.addr(0x2);

protocolRewards = new ProtocolRewards();
upgradeGate = new MockUpgradeGate();
upgradeGate.initialize(admin);
upgradeGate = new UpgradeGate(admin);
zoraCreator1155Impl = new ZoraCreator1155Impl(0, zora, address(upgradeGate), address(protocolRewards));
target = ZoraCreator1155Impl(address(new Zora1155(address(zoraCreator1155Impl))));
simpleMinter = new SimpleMinter();
fixedPriceMinter = new ZoraCreatorFixedPriceSaleStrategy();

admin = payable(vm.addr(0x1));
recipient = vm.addr(0x2);
adminRole = target.PERMISSION_BIT_ADMIN();
minterRole = target.PERMISSION_BIT_MINTER();
fundsManagerRole = target.PERMISSION_BIT_FUNDS_MANAGER();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
pragma solidity 0.8.17;

import {Test} from "forge-std/Test.sol";
import {MockUpgradeGateBase} from "../mock/MockUpgradeGateBase.sol";
import {UpgradeGate} from "../../src/upgrades/UpgradeGate.sol";

contract FactoryManagedUpgradeGateTest is Test {
MockUpgradeGateBase upgradeGate;
contract UpgradeGateTest is Test {
UpgradeGate upgradeGate;
address constant admin = address(0x123);

function setUp() public {
upgradeGate = new MockUpgradeGateBase();
upgradeGate.setup(admin);
upgradeGate = new UpgradeGate(admin);
}

function test_AdminOnly() public {
Expand Down

0 comments on commit 70619ba

Please sign in to comment.