Skip to content

Commit

Permalink
Deploy premint v2 to zora goerli and zora sepolia. Simulate and give …
Browse files Browse the repository at this point in the history
…instruactions for premint upgrades (#378)

* updated deployment scripts to not fail if determinstic address not already created

* improvements on deploy

* deployed 2.5.1 to zora sepolia

* clean up test

* added a test contract deployer

* deploy to zora goerli

* making sure to stop prank

* fix upgrade test

* updated changeset

* remove upgrade needed log
  • Loading branch information
oveddan authored and kulkarohan committed Dec 8, 2023
1 parent eac806d commit 7d9d0d7
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 77 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-rats-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zoralabs/protocol-deployments": patch
---

Updated determinstic preminter deployment script to not fail if already deployed
5 changes: 5 additions & 0 deletions .changeset/twelve-swans-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zoralabs/protocol-deployments": patch
---

Deployed 2.5.1 to zora sepolia and zora goerli
12 changes: 6 additions & 6 deletions packages/protocol-deployments/addresses/999.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"CONTRACT_1155_IMPL": "0xcD7230AFfBC8C720aE607e0Bc386fbCAF5C34C2E",
"CONTRACT_1155_IMPL_VERSION": "2.4.0",
"FACTORY_IMPL": "0x869Be2EaE4AB30Cf319a46B5dE50Ac203c8784Aa",
"CONTRACT_1155_IMPL": "0xa2669e686fa4192166daEa69F269b262636eE198",
"CONTRACT_1155_IMPL_VERSION": "2.5.1",
"FACTORY_IMPL": "0x30ed75ffaDF6215A3190d43ec505750a70B29fAc",
"FACTORY_PROXY": "0x777777C338d93e2C7adf08D102d45CA7CC4Ed021",
"FIXED_PRICE_SALE_STRATEGY": "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
"FIXED_PRICE_ALLOWED_MINTERS_STRATEGY": "0x9b4aEDF0989B0AF7c5f7511F55d721E37384ca6E",
"MERKLE_MINT_SALE_STRATEGY": "0xf48172CA3B6068B20eE4917Eb27b5472f1f272C7",
"PREMINTER_IMPL": "0x6E2AbBcd82935bFC68A1d5d2c96372b13b65eD9C",
"PREMINTER_IMPL": "0x37A7c717c3EDA58e4ec7F424B2A46934Fd8f8468",
"PREMINTER_PROXY": "0x7777773606e7e46C8Ba8B98C08f5cD218e31d340",
"REDEEM_MINTER_FACTORY": "0x78964965cF77850224513a367f899435C5B69174",
"UPGRADE_GATE": "0xbC50029836A59A4E5e1Bb8988272F46ebA0F9900",
"timestamp": 1699570171,
"commit": "385e4932"
"timestamp": 1700533625,
"commit": "8c57238e"
}
12 changes: 6 additions & 6 deletions packages/protocol-deployments/addresses/999999999.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"CONTRACT_1155_IMPL": "0xC6899816663891D7493939d74d83cb7f2BBcBB16",
"CONTRACT_1155_IMPL_VERSION": "2.4.0",
"FACTORY_IMPL": "0xA2d5B3C1feb801c0A1CF083Ee17d939A5E5D2464",
"CONTRACT_1155_IMPL": "0xF3a46845548bE811Ce37e65153563f4a0AaEbe31",
"CONTRACT_1155_IMPL_VERSION": "2.5.1",
"FACTORY_IMPL": "0xF7e49F97E82cc38ACd82E303F37Fe046f5a190B5",
"FACTORY_PROXY": "0x777777C338d93e2C7adf08D102d45CA7CC4Ed021",
"FIXED_PRICE_SALE_STRATEGY": "0x6d28164C3CE04A190D5F9f0f8881fc807EAD975A",
"MERKLE_MINT_SALE_STRATEGY": "0x5e5fD4b758076BAD940db0284b711A67E8a3B88c",
"PREMINTER_IMPL": "0x4e10791d56a6E90b4b7E2840Fa96DD4fB273F3F2",
"PREMINTER_IMPL": "0x37A7c717c3EDA58e4ec7F424B2A46934Fd8f8468",
"PREMINTER_PROXY": "0x7777773606e7e46C8Ba8B98C08f5cD218e31d340",
"REDEEM_MINTER_FACTORY": "0x25cFb6dd9cDE8425e781d6718a29Ccbca3F038d6",
"UPGRADE_GATE": "0x0000000000000000000000000000000000000000",
"timestamp": 1700087849,
"commit": "a2700107"
"timestamp": 1700531325,
"commit": "fdd3d044"
}
12 changes: 10 additions & 2 deletions packages/protocol-deployments/script/DeployProxiesToNewChain.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import {ZoraDeployerBase} from "../src/ZoraDeployerBase.sol";
import {Deployment} from "../src/DeploymentConfig.sol";
import {ZoraDeployerUtils} from "../src/ZoraDeployerUtils.sol";
import {DeploymentTestingUtils} from "../src/DeploymentTestingUtils.sol";
import {IZoraCreator1155PremintExecutor} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155PremintExecutor.sol";

contract DeployProxiesToNewChain is ZoraDeployerBase, DeploymentTestingUtils {
contract DeployProxiesToNewChain is ZoraDeployerBase {
function run() public returns (string memory) {
Deployment memory deployment = getDeployment();

Expand All @@ -31,7 +32,14 @@ contract DeployProxiesToNewChain is ZoraDeployerBase, DeploymentTestingUtils {

console2.log("testing premint");

signAndExecutePremint(deployment.preminterProxy, vm.envAddress("TEST_PREMINT_FUNDS_RECIPIENT"));
address fundsRecipient = vm.envAddress("TEST_PREMINT_FUNDS_RECIPIENT");
IZoraCreator1155PremintExecutor.MintArguments memory mintArguments = IZoraCreator1155PremintExecutor.MintArguments({
mintRecipient: fundsRecipient,
mintComment: "",
mintReferral: fundsRecipient
});

signAndExecutePremintV2(deployment.preminterProxy, vm.envAddress("TEST_PREMINT_FUNDS_RECIPIENT"), mintArguments);

vm.stopBroadcast();

Expand Down
35 changes: 35 additions & 0 deletions packages/protocol-deployments/script/DeployTestContracts.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "forge-std/Script.sol";
import "forge-std/console2.sol";

import {ZoraDeployerBase} from "../src/ZoraDeployerBase.sol";
import {Deployment} from "../src/DeploymentConfig.sol";
import {ZoraDeployerUtils} from "../src/ZoraDeployerUtils.sol";
import {IZoraCreator1155PremintExecutor} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155PremintExecutor.sol";

contract DeployTestContracts is ZoraDeployerBase {
function run() public returns (string memory) {
Deployment memory deployment = getDeployment();

vm.startBroadcast();

ZoraDeployerUtils.deployTestContractForVerification(deployment.factoryProxy, makeAddr("admin"));

address fundsRecipient = vm.envAddress("DEPLOYER");
IZoraCreator1155PremintExecutor.MintArguments memory mintArguments = IZoraCreator1155PremintExecutor.MintArguments({
mintRecipient: fundsRecipient,
mintComment: "",
mintReferral: fundsRecipient
});

signAndExecutePremintV2(deployment.preminterProxy, fundsRecipient, mintArguments);

vm.stopBroadcast();

// now test signing and executing premint

return getDeploymentJSON(deployment);
}
}
140 changes: 118 additions & 22 deletions packages/protocol-deployments/src/DeploymentTestingUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,138 @@ import {IMinter1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IMinter1
import {IZoraCreator1155PremintExecutor} from "@zoralabs/zora-1155-contracts/src/interfaces/IZoraCreator1155PremintExecutor.sol";
import {ZoraCreator1155PremintExecutorImpl} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImpl.sol";
import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";
import {ZoraCreator1155Attribution, ContractCreationConfig, PremintConfigV2, TokenCreationConfigV2} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155Attribution.sol";
import {ZoraCreator1155Attribution, ContractCreationConfig, PremintConfigV2, TokenCreationConfigV2, PremintConfig, TokenCreationConfig} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155Attribution.sol";
import {ScriptDeploymentConfig} from "./DeploymentConfig.sol";
import {ZoraCreator1155Impl} from "@zoralabs/zora-1155-contracts/src/nft/ZoraCreator1155Impl.sol";

contract DeploymentTestingUtils is Script {
function signAndExecutePremint(address premintExecutorProxyAddress, address payoutRecipient) internal {
console2.log("preminter proxy", premintExecutorProxyAddress);

function createAndSignPremintV1(
address premintExecutorProxyAddress,
address payoutRecipient
)
internal
returns (
ContractCreationConfig memory contractConfig,
IZoraCreator1155PremintExecutor preminterAtProxy,
PremintConfig memory premintConfig,
bytes memory signature
)
{
(address creator, uint256 creatorPrivateKey) = makeAddrAndKey("creator");
IZoraCreator1155PremintExecutor preminterAtProxy = IZoraCreator1155PremintExecutor(premintExecutorProxyAddress);

IMinter1155 fixedPriceMinter = ZoraCreator1155FactoryImpl(address(preminterAtProxy.zora1155Factory())).fixedPriceMinter();
preminterAtProxy = IZoraCreator1155PremintExecutor(premintExecutorProxyAddress);

PremintConfigV2 memory premintConfig = PremintConfigV2({
tokenConfig: TokenCreationConfigV2({
premintConfig = PremintConfig({
tokenConfig: TokenCreationConfig({
tokenURI: "blah.token",
maxSupply: 10,
maxTokensPerAddress: 5,
pricePerToken: 0,
mintStart: 0,
mintDuration: 0,
royaltyMintSchedule: 0,
royaltyBPS: 100,
payoutRecipient: payoutRecipient,
fixedPriceMinter: address(fixedPriceMinter),
createReferral: address(0)
royaltyRecipient: payoutRecipient,
fixedPriceMinter: address(ZoraCreator1155FactoryImpl(address(preminterAtProxy.zora1155Factory())).fixedPriceMinter())
}),
uid: 100,
uid: 101,
version: 0,
deleted: false
});

// now interface with proxy preminter - sign and execute the premint
ContractCreationConfig memory contractConfig = ContractCreationConfig({contractAdmin: creator, contractName: "blah", contractURI: "blah.contract"});
contractConfig = ContractCreationConfig({contractAdmin: creator, contractName: "blahb", contractURI: "blah.contract"});
address deterministicAddress = preminterAtProxy.getContractAddress(contractConfig);

signature = signPremint(premintConfig, deterministicAddress, creatorPrivateKey);
}

function signAndExecutePremintV1(
address premintExecutorProxyAddress,
address payoutRecipient,
IZoraCreator1155PremintExecutor.MintArguments memory mintArguments
) internal {
(
ContractCreationConfig memory contractConfig,
IZoraCreator1155PremintExecutor preminterAtProxy,
PremintConfig memory premintConfig,
bytes memory signature
) = createAndSignPremintV1(premintExecutorProxyAddress, payoutRecipient);

uint256 quantityToMint = 1;

address mintRecipient = creator;
// execute the premint
IZoraCreator1155PremintExecutor.PremintResult memory premintResult = preminterAtProxy.premintV1{value: mintFee(quantityToMint)}(
contractConfig,
premintConfig,
signature,
quantityToMint,
mintArguments
);

require(ZoraCreator1155Impl(premintResult.contractAddress).delegatedTokenId(premintConfig.uid) == premintResult.tokenId, "token id mismatch");
}

function createAndSignPremintV2(
address premintExecutorProxyAddress,
address payoutRecipient
)
internal
returns (
ContractCreationConfig memory contractConfig,
IZoraCreator1155PremintExecutor preminterAtProxy,
PremintConfigV2 memory premintConfig,
bytes memory signature
)
{
(address creator, uint256 creatorPrivateKey) = makeAddrAndKey("creator");
preminterAtProxy = IZoraCreator1155PremintExecutor(premintExecutorProxyAddress);

IZoraCreator1155PremintExecutor.MintArguments memory mintArguments = IZoraCreator1155PremintExecutor.MintArguments({
mintRecipient: mintRecipient,
mintComment: "",
mintReferral: address(0)
premintConfig = PremintConfigV2({
tokenConfig: TokenCreationConfigV2({
tokenURI: "blah.token",
maxSupply: 100,
maxTokensPerAddress: 50,
pricePerToken: 0,
mintStart: 0,
mintDuration: 0,
royaltyBPS: 100,
payoutRecipient: payoutRecipient,
fixedPriceMinter: address(ZoraCreator1155FactoryImpl(address(preminterAtProxy.zora1155Factory())).fixedPriceMinter()),
createReferral: creator
}),
uid: 100,
version: 0,
deleted: false
});

bytes memory signature = signPremint(premintConfig, deterministicAddress, creatorPrivateKey);
// now interface with proxy preminter - sign and execute the premint
contractConfig = ContractCreationConfig({contractAdmin: creator, contractName: "blahb", contractURI: "blah.contract"});
address deterministicAddress = preminterAtProxy.getContractAddress(contractConfig);

signature = signPremint(premintConfig, deterministicAddress, creatorPrivateKey);
}

function signAndExecutePremintV2(
address premintExecutorProxyAddress,
address payoutRecipient,
IZoraCreator1155PremintExecutor.MintArguments memory mintArguments
) internal {
(
ContractCreationConfig memory contractConfig,
IZoraCreator1155PremintExecutor preminterAtProxy,
PremintConfigV2 memory premintConfig,
bytes memory signature
) = createAndSignPremintV2(premintExecutorProxyAddress, payoutRecipient);

uint256 quantityToMint = 1;
// execute the premint
uint256 tokenId = preminterAtProxy.premintV2{value: 0.000777 ether}(contractConfig, premintConfig, signature, quantityToMint, mintArguments).tokenId;
uint256 tokenId = preminterAtProxy
.premintV2{value: mintFee(quantityToMint)}(contractConfig, premintConfig, signature, quantityToMint, mintArguments).tokenId;

require(ZoraCreator1155Impl(deterministicAddress).delegatedTokenId(premintConfig.uid) == tokenId, "token id not created for uid");
require(
ZoraCreator1155Impl(preminterAtProxy.getContractAddress(contractConfig)).delegatedTokenId(premintConfig.uid) == tokenId,
"token id not created for uid"
);
}

function signPremint(PremintConfigV2 memory premintConfig, address deterministicAddress, uint256 privateKey) private view returns (bytes memory signature) {
Expand All @@ -67,4 +149,18 @@ contract DeploymentTestingUtils is Script {
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);
return abi.encodePacked(r, s, v);
}

function mintFee(uint256 quantityToMint) internal pure returns (uint256) {
return quantityToMint * 0.000777 ether;
}

function signPremint(PremintConfig memory premintConfig, address deterministicAddress, uint256 privateKey) private view returns (bytes memory signature) {
bytes32 signatureVersion = ZoraCreator1155Attribution.HASHED_VERSION_1;
bytes32 structHash = ZoraCreator1155Attribution.hashPremint(premintConfig);
// sign the premint
bytes32 digest = ZoraCreator1155Attribution.premintHashedTypeDataV4(structHash, deterministicAddress, signatureVersion, block.chainid);

(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);
return abi.encodePacked(r, s, v);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,9 @@ contract DeterministicDeployerScript is Script {
bytes32 proxyDeployerSalt = params.proxyDeployerSalt;
bytes memory proxyDeployerCreationCode = params.proxyDeployerCreationCode;

if (ZoraDeployerUtils.IMMUTABLE_CREATE2_FACTORY.hasBeenDeployed(proxyDeployerAddress)) {
factoryDeployer = DeterministicProxyDeployer(proxyDeployerAddress);
} else {
factoryDeployer = DeterministicProxyDeployer(ZoraDeployerUtils.IMMUTABLE_CREATE2_FACTORY.safeCreate2(proxyDeployerSalt, proxyDeployerCreationCode));
}
ZoraDeployerUtils.getOrImmutable2Create(proxyDeployerAddress, proxyDeployerSalt, proxyDeployerCreationCode);

if (address(factoryDeployer) != params.proxyDeployerAddress) revert MismatchedAddress(params.proxyDeployerAddress, address(factoryDeployer));
factoryDeployer = DeterministicProxyDeployer(proxyDeployerAddress);
}

function deployDeterministicProxy(string memory proxyName, address implementation, address owner, uint256 chain) internal returns (address) {
Expand Down
3 changes: 2 additions & 1 deletion packages/protocol-deployments/src/ZoraDeployerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import {ZoraDeployerUtils} from "./ZoraDeployerUtils.sol";
import {IMinter1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IMinter1155.sol";
import {DeterministicDeployerScript} from "./DeterministicDeployerScript.sol";
import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";
import {DeploymentTestingUtils} from "./DeploymentTestingUtils.sol";

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

/// @notice File used for demo metadata on verification test mint
Expand Down
Loading

0 comments on commit 7d9d0d7

Please sign in to comment.