Skip to content

Commit

Permalink
03 21 add erc7572 support for opensea (ourzora#271)
Browse files Browse the repository at this point in the history
* Add ERC7572 support for opensea.

* add changesset

* fix tests

* fix lint
  • Loading branch information
iainnash authored Mar 26, 2024
1 parent 13a4785 commit 1cf02a4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-crabs-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zoralabs/zora-1155-contracts": patch
---

Add ERC7572 ContracTURIUpdated() event for indexing
8 changes: 8 additions & 0 deletions packages/1155-contracts/src/interfaces/IERC7572.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

interface IERC7572 {
function contractURI() external view returns (string memory);

event ContractURIUpdated();
}
9 changes: 6 additions & 3 deletions packages/1155-contracts/src/nft/ZoraCreator1155Impl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import {IERC165Upgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/c
import {IProtocolRewards} from "@zoralabs/protocol-rewards/src/interfaces/IProtocolRewards.sol";
import {ERC1155Rewards} from "@zoralabs/protocol-rewards/src/abstract/ERC1155/ERC1155Rewards.sol";
import {ERC1155RewardsStorageV1} from "@zoralabs/protocol-rewards/src/abstract/ERC1155/ERC1155RewardsStorageV1.sol";
import {IZoraCreator1155} from "../interfaces/IZoraCreator1155.sol";
import {IZoraCreator1155Initializer} from "../interfaces/IZoraCreator1155Initializer.sol";
import {ReentrancyGuardUpgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/contracts/security/ReentrancyGuardUpgradeable.sol";
import {UUPSUpgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol";
import {MathUpgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/contracts/utils/math/MathUpgradeable.sol";

import {IZoraCreator1155} from "../interfaces/IZoraCreator1155.sol";
import {IZoraCreator1155Initializer} from "../interfaces/IZoraCreator1155Initializer.sol";
import {IERC7572} from "../interfaces/IERC7572.sol";
import {ContractVersionBase} from "../version/ContractVersionBase.sol";
import {CreatorPermissionControl} from "../permissions/CreatorPermissionControl.sol";
import {CreatorRendererControl} from "../renderer/CreatorRendererControl.sol";
Expand Down Expand Up @@ -55,6 +56,7 @@ contract ZoraCreator1155Impl is
CreatorRoyaltiesControl,
ERC1155Rewards,
ERC1155RewardsStorageV1,
IERC7572,
ERC1155DelegationStorageV1
{
/// @notice This user role allows for any action to be performed
Expand Down Expand Up @@ -315,6 +317,7 @@ contract ZoraCreator1155Impl is
tokens[CONTRACT_BASE_ID].uri = _newURI;
_setName(_newName);
emit ContractMetadataUpdated(msg.sender, _newURI, _newName);
emit ContractURIUpdated();
}

function _setupNewToken(string memory newURI, uint256 maxSupply) internal returns (uint256 tokenId) {
Expand Down Expand Up @@ -671,7 +674,7 @@ contract ZoraCreator1155Impl is
}

/// @notice Returns the URI for the contract
function contractURI() external view returns (string memory) {
function contractURI() external view override(IERC7572, IZoraCreator1155) returns (string memory) {
IRenderer1155 customRenderer = getCustomRenderer(CONTRACT_BASE_ID);
if (address(customRenderer) != address(0)) {
return customRenderer.contractURI();
Expand Down
3 changes: 3 additions & 0 deletions packages/1155-contracts/test/nft/ZoraCreator1155.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ contract ZoraCreator1155Test is Test {
address internal zora;
address[] internal rewardsRecipients;

event ContractURIUpdated();
event Purchased(address indexed sender, address indexed minter, uint256 indexed tokenId, uint256 quantity, uint256 value);
event RewardsDeposit(
address indexed creator,
Expand Down Expand Up @@ -1376,6 +1377,8 @@ contract ZoraCreator1155Test is Test {
assertEq(target.name(), "test");

vm.prank(admin);
vm.expectEmit(true, true, true, true);
emit ContractURIUpdated();
target.updateContractMetadata("newURI", "ASDF");
assertEq(target.name(), "ASDF");
}
Expand Down

0 comments on commit 1cf02a4

Please sign in to comment.