From e752d056da507eeca82ee0c16877d2344dea656a Mon Sep 17 00:00:00 2001 From: Dan Oved Date: Thu, 14 Sep 2023 11:36:16 -0700 Subject: [PATCH] * Updated script to deploy preminter to now deploy the proxy * Extracted common deployment tasks to reusable helper functions * Added script to upgrade preminter --- addresses/999.json | 12 +-- script/Deploy.s.sol | 30 +------ .../DeployNewPreminterAndFactoryProxy.s.sol | 27 +++++++ script/DeployPreminter.s.sol | 80 ------------------- script/UpgradePreminter.s.sol | 33 ++++++++ script/ZoraDeployerBase.sol | 73 +++++++++++++++-- script/copy-deployed-contracts.mjs | 2 +- 7 files changed, 136 insertions(+), 121 deletions(-) create mode 100644 script/DeployNewPreminterAndFactoryProxy.s.sol delete mode 100644 script/DeployPreminter.s.sol create mode 100644 script/UpgradePreminter.s.sol diff --git a/addresses/999.json b/addresses/999.json index 1bd24c4ab..f2f9d9404 100644 --- a/addresses/999.json +++ b/addresses/999.json @@ -1,12 +1,12 @@ { - "CONTRACT_1155_IMPL": "0xe349c0e2C91DE151F7Fc469BF9c39F8A05EF59D2", + "CONTRACT_1155_IMPL": "0x324bA85dAE97331D8256D96D7e45BdC4688f665C", "CONTRACT_1155_IMPL_VERSION": "1.4.0", - "FACTORY_IMPL": "0x93B2BCa3b7734370BB5bdcaB5Ef83b8E995cb9e0", - "FACTORY_PROXY": "0x368d9Fa8Fe07652a73E91986A7Eee2436D218739", + "FACTORY_IMPL": "0xd360c892c69A70F900352d142e78A9C0a59544c5", + "FACTORY_PROXY": "0x415015A8d73582DF01d83CFa16D11b6c7aD8AF24", "FIXED_PRICE_SALE_STRATEGY": "0xd81351363b7d80b06E4Ec4De7989f0f91e41A846", "MERKLE_MINT_SALE_STRATEGY": "0x2c4457D38A329526063b26a2bB2C31B61553Aa98", - "PREMINTER": "0x9D0162AC5ff579670f9b941db7eb7675667883B5", + "PREMINTER": "0xcb81DbF6DB4526fe2Cdf59Bd8a2Ef627899B9Ef2", "REDEEM_MINTER_FACTORY": "0x27817bAef1341De9Ad04097Bbba4Ea8dA32c8552", - "timestamp": 1692386956, - "commit": "d077c85" + "timestamp": 1694716506, + "commit": "b197446" } \ No newline at end of file diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol index b302012b5..1cbf10167 100644 --- a/script/Deploy.s.sol +++ b/script/Deploy.s.sol @@ -12,9 +12,7 @@ import {Zora1155Factory} from "../src/proxies/Zora1155Factory.sol"; import {ZoraCreator1155Impl} from "../src/nft/ZoraCreator1155Impl.sol"; import {ICreatorRoyaltiesControl} from "../src/interfaces/ICreatorRoyaltiesControl.sol"; import {IZoraCreator1155Factory} from "../src/interfaces/IZoraCreator1155Factory.sol"; -import {IMinter1155} from "../src/interfaces/IMinter1155.sol"; import {IZoraCreator1155} from "../src/interfaces/IZoraCreator1155.sol"; -import {ProxyShim} from "../src/utils/ProxyShim.sol"; import {ZoraCreatorFixedPriceSaleStrategy} from "../src/minters/fixed-price/ZoraCreatorFixedPriceSaleStrategy.sol"; import {ZoraCreatorMerkleMinterStrategy} from "../src/minters/merkle/ZoraCreatorMerkleMinterStrategy.sol"; import {ZoraCreatorRedeemMinterFactory} from "../src/minters/redeem/ZoraCreatorRedeemMinterFactory.sol"; @@ -41,33 +39,9 @@ contract DeployScript is ZoraDeployerBase { deployment.merkleMintSaleStrategy = address(merkleMinter); deployment.redeemMinterFactory = address(redeemMinterFactory); - address factoryShimAddress = address(new ProxyShim(deployer)); - Zora1155Factory factoryProxy = new Zora1155Factory(factoryShimAddress, ""); + deployNew1155AndFactoryProxy(deployment, deployer); - deployment.factoryProxy = address(factoryProxy); - - ZoraCreator1155Impl creatorImpl = - new ZoraCreator1155Impl(chainConfig.mintFeeAmount, chainConfig.mintFeeRecipient, address(factoryProxy), chainConfig.protocolRewards); - - deployment.contract1155Impl = address(creatorImpl); - - ZoraCreator1155FactoryImpl factoryImpl = new ZoraCreator1155FactoryImpl({ - _implementation: creatorImpl, - _merkleMinter: merkleMinter, - _redeemMinterFactory: redeemMinterFactory, - _fixedPriceMinter: fixedPricedMinter - }); - - deployment.factoryImpl = address(factoryImpl); - - // Upgrade to "real" factory address - ZoraCreator1155FactoryImpl(address(factoryProxy)).upgradeTo(address(factoryImpl)); - ZoraCreator1155FactoryImpl(address(factoryProxy)).initialize(chainConfig.factoryOwner); - - console2.log("Factory Proxy", address(factoryProxy)); - console2.log("Implementation Address", address(creatorImpl)); - - deployTestContractForVerification(address(factoryProxy), chainConfig.factoryOwner); + deployTestContractForVerification(deployment.factoryProxy, chainConfig.factoryOwner); return getDeploymentJSON(deployment); } diff --git a/script/DeployNewPreminterAndFactoryProxy.s.sol b/script/DeployNewPreminterAndFactoryProxy.s.sol new file mode 100644 index 000000000..e6fcd46d5 --- /dev/null +++ b/script/DeployNewPreminterAndFactoryProxy.s.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; + +import {ZoraDeployerBase} from "./ZoraDeployerBase.sol"; +import {ChainConfig, Deployment} from "../src/deployment/DeploymentConfig.sol"; + +contract DeployNewPreminterAndFactoryProxy is ZoraDeployerBase { + function run() public returns (string memory) { + Deployment memory deployment = getDeployment(); + + uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); + address deployer = vm.envAddress("DEPLOYER"); + + vm.startBroadcast(deployerPrivateKey); + + deployNew1155AndFactoryProxy(deployment, deployer); + + deployNewPreminterProxy(deployment); + + vm.stopBroadcast(); + + return getDeploymentJSON(deployment); + } +} diff --git a/script/DeployPreminter.s.sol b/script/DeployPreminter.s.sol deleted file mode 100644 index 4126fd9b1..000000000 --- a/script/DeployPreminter.s.sol +++ /dev/null @@ -1,80 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.17; - -import "forge-std/Script.sol"; -import "forge-std/console2.sol"; - -import {ZoraDeployerBase} from "./ZoraDeployerBase.sol"; -import {ChainConfig, Deployment} from "../src/deployment/DeploymentConfig.sol"; - -import {ZoraCreator1155FactoryImpl} from "../src/factory/ZoraCreator1155FactoryImpl.sol"; -import {Zora1155Factory} from "../src/proxies/Zora1155Factory.sol"; -import {ZoraCreator1155Impl} from "../src/nft/ZoraCreator1155Impl.sol"; -import {ICreatorRoyaltiesControl} from "../src/interfaces/ICreatorRoyaltiesControl.sol"; -import {IZoraCreator1155Factory} from "../src/interfaces/IZoraCreator1155Factory.sol"; -import {IMinter1155} from "../src/interfaces/IMinter1155.sol"; -import {IZoraCreator1155} from "../src/interfaces/IZoraCreator1155.sol"; -import {ProxyShim} from "../src/utils/ProxyShim.sol"; -import {ZoraCreatorFixedPriceSaleStrategy} from "../src/minters/fixed-price/ZoraCreatorFixedPriceSaleStrategy.sol"; -import {ZoraCreatorMerkleMinterStrategy} from "../src/minters/merkle/ZoraCreatorMerkleMinterStrategy.sol"; -import {ZoraCreatorRedeemMinterFactory} from "../src/minters/redeem/ZoraCreatorRedeemMinterFactory.sol"; -import {ZoraCreator1155PremintExecutor} from "../src/premint/ZoraCreator1155PremintExecutor.sol"; - -contract DeployPreminter is ZoraDeployerBase { - function run() public returns (string memory) { - Deployment memory deployment = getDeployment(); - - uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); - - // bool deployFactory = vm.envBool("DEPLOY_FACTORY"); - bool deployFactory = vm.envBool("DEPLOY_FACTORY"); - - IZoraCreator1155Factory factoryProxy; - vm.startBroadcast(deployerPrivateKey); - - if (deployFactory) { - address deployer = vm.envAddress("DEPLOYER"); - address factoryShimAddress = address(new ProxyShim(deployer)); - ChainConfig memory chainConfig = getChainConfig(); - - factoryProxy = IZoraCreator1155Factory(address(new Zora1155Factory(factoryShimAddress, ""))); - - deployment.factoryProxy = address(factoryProxy); - - ZoraCreator1155Impl creatorImpl = new ZoraCreator1155Impl( - chainConfig.mintFeeAmount, - chainConfig.mintFeeRecipient, - address(factoryProxy), - chainConfig.protocolRewards - ); - - deployment.contract1155Impl = address(creatorImpl); - - ZoraCreator1155FactoryImpl factoryImpl = new ZoraCreator1155FactoryImpl({ - _implementation: creatorImpl, - _merkleMinter: IMinter1155(deployment.merkleMintSaleStrategy), - _redeemMinterFactory: IMinter1155(deployment.redeemMinterFactory), - _fixedPriceMinter: IMinter1155(deployment.fixedPriceSaleStrategy) - }); - - // Upgrade to "real" factory address - ZoraCreator1155FactoryImpl(address(factoryProxy)).upgradeTo(address(factoryImpl)); - ZoraCreator1155FactoryImpl(address(factoryProxy)).initialize(chainConfig.factoryOwner); - - deployment.factoryImpl = address(factoryImpl); - } else { - factoryProxy = ZoraCreator1155FactoryImpl(deployment.factoryProxy); - } - - console.log("!!!factory proxy!!!"); - // console.log(factoryProxy); - - ZoraCreator1155PremintExecutor preminter = new ZoraCreator1155PremintExecutor(factoryProxy); - - vm.stopBroadcast(); - - deployment.preminter = address(preminter); - - return getDeploymentJSON(deployment); - } -} diff --git a/script/UpgradePreminter.s.sol b/script/UpgradePreminter.s.sol new file mode 100644 index 000000000..60438548a --- /dev/null +++ b/script/UpgradePreminter.s.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; + +import {ZoraDeployerBase} from "./ZoraDeployerBase.sol"; +import {ChainConfig, Deployment} from "../src/deployment/DeploymentConfig.sol"; +import {UUPSUpgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol"; + +contract UpgradePreminter is ZoraDeployerBase { + function run() public returns (string memory, bytes memory upgradeCalldata, address upgradeTarget) { + Deployment memory deployment = getDeployment(); + + uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); + + vm.startBroadcast(deployerPrivateKey); + + address preminterImplementation = deployNewPreminterImplementation(deployment); + + vm.stopBroadcast(); + + upgradeCalldata = abi.encodeWithSelector(UUPSUpgradeable.upgradeTo.selector, preminterImplementation); + + upgradeTarget = deployment.preminter; + + console2.log("Upgrade PremintExecutor target and implementatin:", upgradeTarget, preminterImplementation); + console2.log("To upgrade, use this calldata:"); + console2.logBytes(upgradeCalldata); + + return (getDeploymentJSON(deployment), upgradeCalldata, upgradeTarget); + } +} diff --git a/script/ZoraDeployerBase.sol b/script/ZoraDeployerBase.sol index ecacbb09e..909d65d9c 100644 --- a/script/ZoraDeployerBase.sol +++ b/script/ZoraDeployerBase.sol @@ -6,8 +6,14 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {IZoraCreator1155Factory} from "../src/interfaces/IZoraCreator1155Factory.sol"; import {ZoraCreator1155Impl} from "../src/nft/ZoraCreator1155Impl.sol"; +import {Zora1155Factory} from "../src/proxies/Zora1155Factory.sol"; import {ICreatorRoyaltiesControl} from "../src/interfaces/ICreatorRoyaltiesControl.sol"; -import {ScriptDeploymentConfig, Deployment} from "../src/deployment/DeploymentConfig.sol"; +import {ScriptDeploymentConfig, Deployment, ChainConfig} from "../src/deployment/DeploymentConfig.sol"; +import {ProxyShim} from "../src/utils/ProxyShim.sol"; +import {ZoraCreator1155FactoryImpl} from "../src/factory/ZoraCreator1155FactoryImpl.sol"; +import {Zora1155PremintExecutorProxy} from "../src/proxies/Zora1155PremintExecutorProxy.sol"; +import {ZoraCreator1155PremintExecutor} from "../src/premint/ZoraCreator1155PremintExecutor.sol"; +import {IMinter1155} from "../src/interfaces/IMinter1155.sol"; /// @notice Deployment drops for base where abstract contract ZoraDeployerBase is ScriptDeploymentConfig, Script { @@ -32,6 +38,65 @@ abstract contract ZoraDeployerBase is ScriptDeploymentConfig, Script { console2.log(deploymentJson); } + function deployNew1155AndFactoryImpl(Deployment memory deployment, Zora1155Factory factoryProxy) internal { + ChainConfig memory chainConfig = getChainConfig(); + + ZoraCreator1155Impl creatorImpl = new ZoraCreator1155Impl( + chainConfig.mintFeeAmount, + chainConfig.mintFeeRecipient, + address(factoryProxy), + chainConfig.protocolRewards + ); + + console2.log("Implementation Address", address(creatorImpl)); + + deployment.contract1155Impl = address(creatorImpl); + + ZoraCreator1155FactoryImpl factoryImpl = new ZoraCreator1155FactoryImpl({ + _implementation: creatorImpl, + _merkleMinter: IMinter1155(deployment.merkleMintSaleStrategy), + _redeemMinterFactory: IMinter1155(deployment.redeemMinterFactory), + _fixedPriceMinter: IMinter1155(deployment.fixedPriceSaleStrategy) + }); + + deployment.factoryImpl = address(factoryImpl); + } + + function deployNew1155AndFactoryProxy(Deployment memory deployment, address deployer) internal { + address factoryShimAddress = address(new ProxyShim(deployer)); + Zora1155Factory factoryProxy = new Zora1155Factory(factoryShimAddress, ""); + + deployment.factoryProxy = address(factoryProxy); + + // deploy new 1155 and factory impl, and udpdate deployment config with it + deployNew1155AndFactoryImpl(deployment, factoryProxy); + + ZoraCreator1155FactoryImpl(address(factoryProxy)).upgradeTo(deployment.factoryImpl); + ZoraCreator1155FactoryImpl(address(factoryProxy)).initialize(getChainConfig().factoryOwner); + + console2.log("Factory Proxy", address(factoryProxy)); + } + + function deployNewPreminterImplementation(Deployment memory deployment) internal returns (address) { + // create preminter implementation + ZoraCreator1155PremintExecutor preminterImplementation = new ZoraCreator1155PremintExecutor(ZoraCreator1155FactoryImpl(deployment.factoryProxy)); + + return address(preminterImplementation); + } + + function deployNewPreminterProxy(Deployment memory deployment) internal { + address preminterImplementation = deployNewPreminterImplementation(deployment); + + // build the proxy + Zora1155PremintExecutorProxy proxy = new Zora1155PremintExecutorProxy(preminterImplementation, ""); + + deployment.preminter = address(proxy); + + // access the executor implementation via the proxy, and initialize the admin + ZoraCreator1155PremintExecutor preminterAtProxy = ZoraCreator1155PremintExecutor(address(proxy)); + preminterAtProxy.initialize(getChainConfig().factoryOwner); + } + /// @notice Deploy a test contract for etherscan auto-verification /// @param factoryProxy Factory address to use /// @param admin Admin owner address to use @@ -46,11 +111,7 @@ abstract contract ZoraDeployerBase is ScriptDeploymentConfig, Script { IZoraCreator1155Factory(factoryProxy).createContract( "ipfs://bafybeicgolwqpozsc7iwgytavete56a2nnytzix2nb2rxefdvbtwwtnnoe/metadata", unicode"🪄", - ICreatorRoyaltiesControl.RoyaltyConfiguration({ - royaltyBPS: 0, - royaltyRecipient: address(0), - royaltyMintSchedule: 0 - }), + ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyBPS: 0, royaltyRecipient: address(0), royaltyMintSchedule: 0}), payable(admin), initUpdate ) diff --git a/script/copy-deployed-contracts.mjs b/script/copy-deployed-contracts.mjs index af1baf968..8f6faabc4 100644 --- a/script/copy-deployed-contracts.mjs +++ b/script/copy-deployed-contracts.mjs @@ -44,7 +44,7 @@ if (esMain(import.meta)) { if (command === "upgrade"){ scriptName = 'Upgrade.s.sol'; } else if (command === 'deploy-premint') { - scriptName = 'DeployPreminter.s.sol' + scriptName = 'DeployNewPreminterAndFactoryProxy.s.sol' } await copyEnvironmentRunFiles(scriptName);