Skip to content

Commit

Permalink
added upgrade preminter script
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Sep 14, 2023
1 parent 18ca52e commit bf55e01
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 17 deletions.
16 changes: 1 addition & 15 deletions script/DeployNewPreminterAndFactoryProxy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,15 @@ 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 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);

address deployer = vm.envAddress("DEPLOYER");

deployNew1155AndFactoryProxy(deployment, deployer);

deployNewPreminterProxy(deployment);
Expand Down
33 changes: 33 additions & 0 deletions script/UpgradePreminter.s.sol
Original file line number Diff line number Diff line change
@@ -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);
}
}
10 changes: 8 additions & 2 deletions script/ZoraDeployerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,18 @@ abstract contract ZoraDeployerBase is ScriptDeploymentConfig, Script {
console2.log("Factory Proxy", address(factoryProxy));
}

function deployNewPreminterProxy(Deployment memory deployment) internal {
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(address(preminterImplementation), "");
Zora1155PremintExecutorProxy proxy = new Zora1155PremintExecutorProxy(preminterImplementation, "");

deployment.preminter = address(proxy);

Expand Down

0 comments on commit bf55e01

Please sign in to comment.