Skip to content

Commit

Permalink
* Updated script to deploy preminter to now deploy the proxy
Browse files Browse the repository at this point in the history
* Extracted common deployment tasks to reusable helper functions
  • Loading branch information
oveddan committed Sep 18, 2023
1 parent ab48762 commit 9762a7f
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 121 deletions.
12 changes: 6 additions & 6 deletions addresses/999.json
Original file line number Diff line number Diff line change
@@ -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"
}
30 changes: 2 additions & 28 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
}
Expand Down
41 changes: 41 additions & 0 deletions script/DeployNewPreminterAndFactoryProxy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// 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 DeployNewPreminterAndFactoryProxy is ZoraDeployerBase {
function run() public returns (string memory) {
Deployment memory deployment = getDeployment();

uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");

vm.startBroadcast(deployerPrivateKey);

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

deployNew1155AndFactoryProxy(deployment, deployer);

deployNewPreminterProxy(deployment);

vm.stopBroadcast();

return getDeploymentJSON(deployment);
}
}
80 changes: 0 additions & 80 deletions script/DeployPreminter.s.sol

This file was deleted.

67 changes: 61 additions & 6 deletions script/ZoraDeployerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -32,6 +38,59 @@ 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 deployNewPreminterProxy(Deployment memory deployment) internal {
// create preminter implementation
ZoraCreator1155PremintExecutor preminterImplementation = new ZoraCreator1155PremintExecutor(ZoraCreator1155FactoryImpl(deployment.factoryProxy));

// build the proxy
Zora1155PremintExecutorProxy proxy = new Zora1155PremintExecutorProxy(address(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
Expand All @@ -46,11 +105,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
)
Expand Down
2 changes: 1 addition & 1 deletion script/copy-deployed-contracts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9762a7f

Please sign in to comment.