Skip to content

Commit

Permalink
added step to test deploying
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Sep 29, 2023
1 parent 3423e8b commit b55030e
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 13 deletions.
12 changes: 10 additions & 2 deletions script/DeployAllToNewChain.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ 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 {IZoraCreator1155} from "../src/interfaces/IZoraCreator1155.sol";
import {DeterministicDeployerScript} from "../src/deployment/DeterministicDeployerScript.sol";
import {IMinter1155} from "../src/interfaces/IMinter1155.sol";
import {DeploymentTestingUtils} from "../src/deployment/DeploymentTestingUtils.sol";

contract DeployAllToNewChain is ZoraDeployerBase, DeterministicDeployerScript {
contract DeployAllToNewChain is ZoraDeployerBase, DeterministicDeployerScript, DeploymentTestingUtils {
function run() public returns (string memory) {
Deployment memory deployment = getDeployment();
ChainConfig memory chainConfig = getChainConfig();
Expand Down Expand Up @@ -56,6 +56,8 @@ contract DeployAllToNewChain is ZoraDeployerBase, DeterministicDeployerScript {

ZoraDeployerUtils.deployTestContractForVerification(factoryProxyAddress, makeAddr("admin"));

console2.log("Deployed new contract for verification purposes");

address preminterImpl = ZoraDeployerUtils.deployNewPreminterImplementationDeterminstic(address(factoryProxyAddress));

address preminterProxyAddress = deployDeterministicProxy({
Expand All @@ -75,6 +77,12 @@ contract DeployAllToNewChain is ZoraDeployerBase, DeterministicDeployerScript {
deployment.preminterImpl = preminterImpl;
deployment.preminterProxy = preminterProxyAddress;

vm.stopBroadcast();

// now test signing and executing premint

signAndExecutePremint(preminterProxyAddress);

return getDeploymentJSON(deployment);
}
}
45 changes: 45 additions & 0 deletions src/deployment/DeploymentTestingUtils.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import "forge-std/Script.sol";
import {IMinter1155} from "..//interfaces/IMinter1155.sol";
import {Zora1155FactoryFixtures} from "../../test/fixtures/Zora1155FactoryFixtures.sol";
import {Zora1155PremintFixtures} from "../../test/fixtures/Zora1155PremintFixtures.sol";
import {ZoraCreator1155PremintExecutorImpl} from "../delegation/ZoraCreator1155PremintExecutorImpl.sol";
import {ZoraCreator1155FactoryImpl} from "../factory/ZoraCreator1155FactoryImpl.sol";
import {ZoraCreator1155Attribution, ContractCreationConfig, PremintConfig} from "../delegation/ZoraCreator1155Attribution.sol";
import {ZoraCreator1155Impl} from "../nft/ZoraCreator1155Impl.sol";

contract DeploymentTestingUtils is Script {
function signAndExecutePremint(address premintExecutorProxyAddress) internal {
(address creator, uint256 creatorPrivateKey) = makeAddrAndKey("creator");
ZoraCreator1155PremintExecutorImpl preminterAtProxy = ZoraCreator1155PremintExecutorImpl(premintExecutorProxyAddress);

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

PremintConfig memory premintConfig = PremintConfig({
tokenConfig: Zora1155PremintFixtures.makeDefaultTokenCreationConfig(fixedPriceMinter, creator),
uid: 100,
version: 0,
deleted: false
});

// now interface with proxy preminter - sign and execute the premint
ContractCreationConfig memory contractConfig = Zora1155PremintFixtures.makeDefaultContractCreationConfig(creator);
address deterministicAddress = preminterAtProxy.getContractAddress(contractConfig);

// sign the premint
bytes32 digest = ZoraCreator1155Attribution.premintHashedTypeDataV4(premintConfig, deterministicAddress, block.chainid);

(uint8 v, bytes32 r, bytes32 s) = vm.sign(creatorPrivateKey, digest);

uint256 quantityToMint = 1;

bytes memory signature = abi.encodePacked(r, s, v);

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

require(ZoraCreator1155Impl(deterministicAddress).delegatedTokenId(premintConfig.uid) == tokenId, "token id not created for uid");
}
}
25 changes: 14 additions & 11 deletions src/deployment/ZoraDeployerUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {ZoraCreatorFixedPriceSaleStrategy} from "../minters/fixed-price/ZoraCrea
import {ZoraCreatorMerkleMinterStrategy} from "../minters/merkle/ZoraCreatorMerkleMinterStrategy.sol";
import {ZoraCreatorRedeemMinterFactory} from "../minters/redeem/ZoraCreatorRedeemMinterFactory.sol";
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
import {ICreatorRoyaltiesControl} from "../interfaces/ICreatorRoyaltiesControl.sol";

library ZoraDeployerUtils {
IImmutableCreate2Factory constant IMMUTABLE_CREATE2_FACTORY = IImmutableCreate2Factory(0x0000000000FFe8B47B3e2130213B802212439497);
Expand Down Expand Up @@ -103,22 +104,24 @@ library ZoraDeployerUtils {
/// @notice Deploy a test contract for etherscan auto-verification
/// @param factoryProxy Factory address to use
/// @param admin Admin owner address to use
function deployTestContractForVerification(address factoryProxy, address admin) internal {
function deployTestContractForVerification(address factoryProxy, address admin) internal returns (address) {
bytes[] memory initUpdate = new bytes[](1);
initUpdate[0] = abi.encodeWithSelector(
ZoraCreator1155Impl.setupNewToken.selector,
"ipfs://bafkreigu544g6wjvqcysurpzy5pcskbt45a5f33m6wgythpgb3rfqi3lzi",
100
);
address newContract = address(
IZoraCreator1155Factory(factoryProxy).createContract(
"ipfs://bafybeicgolwqpozsc7iwgytavete56a2nnytzix2nb2rxefdvbtwwtnnoe/metadata",
unicode"🪄",
ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyBPS: 0, royaltyRecipient: address(0), royaltyMintSchedule: 0}),
payable(admin),
initUpdate
)
);
console2.log("Deployed new contract for verification purposes", newContract);
return
address(
IZoraCreator1155Factory(factoryProxy).createContract(
"ipfs://bafybeicgolwqpozsc7iwgytavete56a2nnytzix2nb2rxefdvbtwwtnnoe/metadata",
unicode"🪄",
ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyBPS: 0, royaltyRecipient: address(0), royaltyMintSchedule: 0}),
payable(admin),
initUpdate
)
);
}

function testPremintSigningAndExecution(address preminterProxyAddress, address creatorAddress, uint256 creatorPrivateKey) internal {}
}

0 comments on commit b55030e

Please sign in to comment.