From e855dca296fafe21f0b688105e4fb135f2c5fcff Mon Sep 17 00:00:00 2001 From: Dan Oved Date: Tue, 21 Nov 2023 15:15:14 -0800 Subject: [PATCH 1/4] fix v2 of domain setting --- .../src/delegation/ZoraCreator1155Attribution.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/1155-contracts/src/delegation/ZoraCreator1155Attribution.sol b/packages/1155-contracts/src/delegation/ZoraCreator1155Attribution.sol index cc3b1b822..79ec4d7bc 100644 --- a/packages/1155-contracts/src/delegation/ZoraCreator1155Attribution.sol +++ b/packages/1155-contracts/src/delegation/ZoraCreator1155Attribution.sol @@ -165,7 +165,7 @@ library ZoraCreator1155Attribution { bytes32 constant ATTRIBUTION_DOMAIN_V2 = keccak256( - "CreatorAttribution(TokenCreationConfig tokenConfig,uint32 uid,uint32 version,bool deleted)TokenCreationConfig(string tokenURI,uint256 maxSupply,uint64 maxTokensPerAddress,uint96 pricePerToken,uint64 mintStart,uint64 mintDuration,uint32 royaltyBPS,address royaltyRecipient,address fixedPriceMinter,address createReferral)" + "CreatorAttribution(TokenCreationConfig tokenConfig,uint32 uid,uint32 version,bool deleted)TokenCreationConfig(string tokenURI,uint256 maxSupply,uint64 maxTokensPerAddress,uint96 pricePerToken,uint64 mintStart,uint64 mintDuration,uint32 royaltyBPS,address payoutRecipient,address fixedPriceMinter,address createReferral)" ); function hashPremint(PremintConfigV2 memory premintConfig) internal pure returns (bytes32) { @@ -208,7 +208,7 @@ library ZoraCreator1155Attribution { return keccak256( abi.encode( - TOKEN_DOMAIN_V1, + TOKEN_DOMAIN_V2, _stringHash(tokenConfig.tokenURI), tokenConfig.maxSupply, tokenConfig.maxTokensPerAddress, From 6a7980d7fd32690a37bb6c02ff66cfe141469822 Mon Sep 17 00:00:00 2001 From: Dan Oved Date: Tue, 21 Nov 2023 15:33:03 -0800 Subject: [PATCH 2/4] fix premint encoding and creator attribution event --- .../delegation/ZoraCreator1155Attribution.sol | 9 ++- .../ZoraCreator1155PremintExecutor.t.sol | 75 ++++++++++++++----- 2 files changed, 61 insertions(+), 23 deletions(-) diff --git a/packages/1155-contracts/src/delegation/ZoraCreator1155Attribution.sol b/packages/1155-contracts/src/delegation/ZoraCreator1155Attribution.sol index 79ec4d7bc..6e9cee97b 100644 --- a/packages/1155-contracts/src/delegation/ZoraCreator1155Attribution.sol +++ b/packages/1155-contracts/src/delegation/ZoraCreator1155Attribution.sol @@ -390,7 +390,7 @@ library DelegatedTokenCreation { if (premintVersion == ZoraCreator1155Attribution.HASHED_VERSION_1) { PremintConfig memory premintConfig = abi.decode(premintConfigEncoded, (PremintConfig)); - creatorAttribution = _recoverCreatorAttribution( + creatorAttribution = recoverCreatorAttribution( ZoraCreator1155Attribution.VERSION_1, ZoraCreator1155Attribution.hashPremint(premintConfig), tokenContract, @@ -401,7 +401,7 @@ library DelegatedTokenCreation { } else { PremintConfigV2 memory premintConfig = abi.decode(premintConfigEncoded, (PremintConfigV2)); - creatorAttribution = _recoverCreatorAttribution( + creatorAttribution = recoverCreatorAttribution( ZoraCreator1155Attribution.VERSION_2, ZoraCreator1155Attribution.hashPremint(premintConfig), tokenContract, @@ -422,12 +422,13 @@ library DelegatedTokenCreation { versions[1] = ZoraCreator1155Attribution.VERSION_2; } - function _recoverCreatorAttribution( + function recoverCreatorAttribution( string memory version, bytes32 structHash, address tokenContract, bytes calldata signature - ) private view returns (DecodedCreatorAttribution memory attribution) { + ) internal view returns (DecodedCreatorAttribution memory attribution) { + attribution.structHash = structHash; attribution.version = version; attribution.creator = ZoraCreator1155Attribution.recoverSignerHashed(structHash, signature, tokenContract, keccak256(bytes(version)), block.chainid); diff --git a/packages/1155-contracts/test/premint/ZoraCreator1155PremintExecutor.t.sol b/packages/1155-contracts/test/premint/ZoraCreator1155PremintExecutor.t.sol index eac1417e1..2a3e72267 100644 --- a/packages/1155-contracts/test/premint/ZoraCreator1155PremintExecutor.t.sol +++ b/packages/1155-contracts/test/premint/ZoraCreator1155PremintExecutor.t.sol @@ -77,7 +77,7 @@ contract ZoraCreator1155PreminterTest is Test { return factory.defaultMinters()[0]; } - function makeDefaultPremintConfig() internal view returns (PremintConfigV2 memory) { + function makeDefaultPremintConfigV2() internal view returns (PremintConfigV2 memory) { return PremintConfigV2({ tokenConfig: Zora1155PremintFixtures.makeDefaultTokenCreationConfigV2(getFixedPriceMinter(), creator), @@ -87,6 +87,10 @@ contract ZoraCreator1155PreminterTest is Test { }); } + function makeDefaultPremintConfigV1() internal view returns (PremintConfig memory) { + return Zora1155PremintFixtures.makeDefaultV1PremintConfig(getFixedPriceMinter(), creator); + } + function makePremintConfigWithCreateReferral(address createReferral) internal view returns (PremintConfigV2 memory) { return PremintConfigV2({ @@ -151,7 +155,7 @@ contract ZoraCreator1155PreminterTest is Test { // configuration of contract to create ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); // how many tokens are minted to the executor uint256 quantityToMint = 4; @@ -208,7 +212,7 @@ contract ZoraCreator1155PreminterTest is Test { // configuration of contract to create ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); // how many tokens are minted to the executor uint256 chainId = block.chainid; @@ -242,10 +246,43 @@ contract ZoraCreator1155PreminterTest is Test { event CreatorAttribution(bytes32 structHash, string domainName, string version, address creator, bytes signature); - function test_premint_emitsCreatorAttribution_fromErc1155Contract() external { + function test_premintV1_emitsCreatorAttribution_fromErc1155Contract() external { + // build a premint + ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); + PremintConfig memory premintConfig = makeDefaultPremintConfigV1(); + + // sign and execute premint + uint256 chainId = block.chainid; + + address deterministicAddress = preminter.getContractAddress(contractConfig); + bytes32 structHash = ZoraCreator1155Attribution.hashPremint(premintConfig); + bytes32 digest = ZoraCreator1155Attribution.premintHashedTypeDataV4( + structHash, + deterministicAddress, + ZoraCreator1155Attribution.HASHED_VERSION_1, + chainId + ); + bytes memory signature = _sign(creatorPrivateKey, digest); + + uint256 quantityToMint = 4; + uint256 mintCost = mintFeeAmount * quantityToMint; + // this account will be used to execute the premint, and should result in a contract being created + vm.deal(collector, mintCost); + + vm.prank(collector); + + // verify CreatorAttribution was emitted from the erc1155 contract + vm.expectEmit(true, true, true, true, deterministicAddress); + emit CreatorAttribution(structHash, ZoraCreator1155Attribution.NAME, ZoraCreator1155Attribution.VERSION_1, creator, signature); + + // create contract and token via premint + preminter.premintV1{value: mintCost}(contractConfig, premintConfig, signature, quantityToMint, defaultMintArguments); + } + + function test_premintV2_emitsCreatorAttribution_fromErc1155Contract() external { // build a premint ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); // sign and execute premint uint256 chainId = block.chainid; @@ -268,7 +305,7 @@ contract ZoraCreator1155PreminterTest is Test { vm.prank(collector); // verify CreatorAttribution was emitted from the erc1155 contract - vm.expectEmit(true, false, false, false, deterministicAddress); + vm.expectEmit(true, true, true, true, deterministicAddress); emit CreatorAttribution(structHash, ZoraCreator1155Attribution.NAME, ZoraCreator1155Attribution.VERSION_2, creator, signature); // create contract and token via premint @@ -280,7 +317,7 @@ contract ZoraCreator1155PreminterTest is Test { // configuration of contract to create ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); // how many tokens are minted to the executor uint256 quantityToMint = 4; @@ -321,7 +358,7 @@ contract ZoraCreator1155PreminterTest is Test { // configuration of contract to create ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); // how many tokens are minted to the executor uint256 quantityToMint = 2; @@ -375,7 +412,7 @@ contract ZoraCreator1155PreminterTest is Test { function testCreateTokenPerUid() public { ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); uint256 quantityToMint = 2; uint256 chainId = block.chainid; @@ -402,7 +439,7 @@ contract ZoraCreator1155PreminterTest is Test { function test_deleted_preventsTokenFromBeingMinted() external { ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); premintConfig.deleted = true; uint chainId = block.chainid; @@ -426,7 +463,7 @@ contract ZoraCreator1155PreminterTest is Test { function test_emitsPremint_whenNewContract() external { ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); address contractAddress = preminter.getContractAddress(contractConfig); // how many tokens are minted to the executor @@ -452,7 +489,7 @@ contract ZoraCreator1155PreminterTest is Test { function test_onlyOwner_hasAdminRights_onCreatedToken() public { ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); // how many tokens are minted to the executor uint256 quantityToMint = 4; @@ -520,7 +557,7 @@ contract ZoraCreator1155PreminterTest is Test { } function test_premintStatus_getsStatus() external { - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); // how many tokens are minted to the executor uint256 quantityToMint = 4; @@ -564,7 +601,7 @@ contract ZoraCreator1155PreminterTest is Test { vm.warp(currentTime); ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); premintConfig.tokenConfig.mintStart = startDate; uint256 quantityToMint = 4; @@ -598,7 +635,7 @@ contract ZoraCreator1155PreminterTest is Test { // build a premint with a token that has the given start date and duration ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); address contractAddress = preminter.getContractAddress(contractConfig); premintConfig.tokenConfig.mintStart = startDate; @@ -637,7 +674,7 @@ contract ZoraCreator1155PreminterTest is Test { function test_premintStatus_getsIfContractHasBeenCreatedAndTokenIdForPremint() external { // build a premint ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); // get premint status (bool contractCreated, uint256 tokenId) = preminter.premintStatus(preminter.getContractAddress(contractConfig), premintConfig.uid); @@ -664,7 +701,7 @@ contract ZoraCreator1155PreminterTest is Test { function test_premint_whenContractCreated_premintCanOnlyBeExecutedByPermissionBitMinter() external { // build a premint ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); address contractAddress = preminter.getContractAddress(contractConfig); @@ -760,7 +797,7 @@ contract ZoraCreator1155PreminterTest is Test { function test_premintVersion_whenCreated_returnsAllVersion() external { // build a premint ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); // sign and execute premint address deterministicAddress = preminter.getContractAddress(contractConfig); @@ -791,7 +828,7 @@ contract ZoraCreator1155PreminterTest is Test { function test_premintWithNoMintRecipient_reverts() public { ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); - PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2(); address contractAddress = preminter.getContractAddress(contractConfig); From e4edaac2004dd0db4a66128ab392bf44e4faa17e Mon Sep 17 00:00:00 2001 From: Dan Oved Date: Tue, 21 Nov 2023 15:34:33 -0800 Subject: [PATCH 3/4] added changeset --- .changeset/light-poems-cry.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/light-poems-cry.md diff --git a/.changeset/light-poems-cry.md b/.changeset/light-poems-cry.md new file mode 100644 index 000000000..96be0a70f --- /dev/null +++ b/.changeset/light-poems-cry.md @@ -0,0 +1,5 @@ +--- +"@zoralabs/zora-1155-contracts": patch +--- + +fixed bug where premint config v2 did not have correct eip-712 domain. fixed bug in CreatorAttribution event where structHash was not included in it From 1d58cd1ab9b8b9bc29e18dbf684299582d5ad6d3 Mon Sep 17 00:00:00 2001 From: Dan Oved Date: Mon, 27 Nov 2023 09:22:15 -0800 Subject: [PATCH 4/4] Deploy 2.5.2 to testnets (#386) * deployed to zora sepolia * deploy zora goerli * added changeset --- .changeset/mighty-peaches-invite.md | 5 +++++ packages/protocol-deployments/addresses/999.json | 12 ++++++------ .../protocol-deployments/addresses/999999999.json | 12 ++++++------ 3 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 .changeset/mighty-peaches-invite.md diff --git a/.changeset/mighty-peaches-invite.md b/.changeset/mighty-peaches-invite.md new file mode 100644 index 000000000..531730709 --- /dev/null +++ b/.changeset/mighty-peaches-invite.md @@ -0,0 +1,5 @@ +--- +"@zoralabs/protocol-deployments": patch +--- + +Deployed 2.5.2 to zora sepolia and zora goerli diff --git a/packages/protocol-deployments/addresses/999.json b/packages/protocol-deployments/addresses/999.json index 669d67b1f..4b25538c9 100644 --- a/packages/protocol-deployments/addresses/999.json +++ b/packages/protocol-deployments/addresses/999.json @@ -1,14 +1,14 @@ { - "CONTRACT_1155_IMPL": "0xa2669e686fa4192166daEa69F269b262636eE198", - "CONTRACT_1155_IMPL_VERSION": "2.5.1", - "FACTORY_IMPL": "0x30ed75ffaDF6215A3190d43ec505750a70B29fAc", + "CONTRACT_1155_IMPL": "0x928279Bf32E3E5318123fD9E936E51c30Be9eE6f", + "CONTRACT_1155_IMPL_VERSION": "2.5.2", + "FACTORY_IMPL": "0x6329e54bcdb44117732a06087f7E485F8943C9AF", "FACTORY_PROXY": "0x777777C338d93e2C7adf08D102d45CA7CC4Ed021", "FIXED_PRICE_SALE_STRATEGY": "0x04E2516A2c207E84a1839755675dfd8eF6302F0a", "MERKLE_MINT_SALE_STRATEGY": "0xf48172CA3B6068B20eE4917Eb27b5472f1f272C7", - "PREMINTER_IMPL": "0x37A7c717c3EDA58e4ec7F424B2A46934Fd8f8468", + "PREMINTER_IMPL": "0x6D3b29A851d595c4d85A3214f1245e74b6Fb8bBb", "PREMINTER_PROXY": "0x7777773606e7e46C8Ba8B98C08f5cD218e31d340", "REDEEM_MINTER_FACTORY": "0x78964965cF77850224513a367f899435C5B69174", "UPGRADE_GATE": "0xbC50029836A59A4E5e1Bb8988272F46ebA0F9900", - "timestamp": 1700533625, - "commit": "8c57238e" + "timestamp": 1700611870, + "commit": "d5eef7cb" } \ No newline at end of file diff --git a/packages/protocol-deployments/addresses/999999999.json b/packages/protocol-deployments/addresses/999999999.json index 49a11f757..05b3de526 100644 --- a/packages/protocol-deployments/addresses/999999999.json +++ b/packages/protocol-deployments/addresses/999999999.json @@ -1,14 +1,14 @@ { - "CONTRACT_1155_IMPL": "0xF3a46845548bE811Ce37e65153563f4a0AaEbe31", - "CONTRACT_1155_IMPL_VERSION": "2.5.1", - "FACTORY_IMPL": "0xF7e49F97E82cc38ACd82E303F37Fe046f5a190B5", + "CONTRACT_1155_IMPL": "0x073ef87C54c192c21ddEf881fE18064b6161fAC9", + "CONTRACT_1155_IMPL_VERSION": "2.5.2", + "FACTORY_IMPL": "0x7316777F0cBe4da5a52cd5e68d1C50af8E466AC1", "FACTORY_PROXY": "0x777777C338d93e2C7adf08D102d45CA7CC4Ed021", "FIXED_PRICE_SALE_STRATEGY": "0x6d28164C3CE04A190D5F9f0f8881fc807EAD975A", "MERKLE_MINT_SALE_STRATEGY": "0x5e5fD4b758076BAD940db0284b711A67E8a3B88c", - "PREMINTER_IMPL": "0x37A7c717c3EDA58e4ec7F424B2A46934Fd8f8468", + "PREMINTER_IMPL": "0x6D3b29A851d595c4d85A3214f1245e74b6Fb8bBb", "PREMINTER_PROXY": "0x7777773606e7e46C8Ba8B98C08f5cD218e31d340", "REDEEM_MINTER_FACTORY": "0x25cFb6dd9cDE8425e781d6718a29Ccbca3F038d6", "UPGRADE_GATE": "0x0000000000000000000000000000000000000000", - "timestamp": 1700531325, - "commit": "fdd3d044" + "timestamp": 1700610104, + "commit": "134b44da" } \ No newline at end of file