Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Adds metadata module and resolvers #30

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/interfaces/modules/IRegistrationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface IRegistrationModule {
address tokenContract,
uint256 tokenId,
string memory ipName,
string memory ipDescription,
bytes32 hash
bytes32 hash,
string calldata externalURL
) external;
}
22 changes: 20 additions & 2 deletions contracts/interfaces/registries/IIPRecordRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ interface IIPRecordRegistry {
/// @param tokenContract The address of the IP.
/// @param tokenId The token identifier of the IP.
/// @param resolver The address of the resolver linked to the IP.
/// @param provider The address of the metadata provider linked to the IP.
event IPRegistered(
address ipId,
uint256 indexed chainId,
address indexed tokenContract,
uint256 indexed tokenId,
address resolver
address resolver,
address provider
);

/// @notice Emits when an IP account is created for an IP.
Expand All @@ -39,6 +41,14 @@ interface IIPRecordRegistry {
address resolver
);

/// @notice Emits when a metadata provider is set for an IP.
/// @param ipId The canonical identifier of the specified IP.
/// @param metadataProvider Address of the metadata provider associated with the IP.
event MetadataProviderSet(
address ipId,
address metadataProvider
);

/// @notice Gets the canonical IP identifier associated with an IP (NFT).
/// @dev This is the same as the address of the IP account bound to the IP.
/// @param chainId The chain identifier of where the IP resides.
Expand Down Expand Up @@ -87,18 +97,26 @@ interface IIPRecordRegistry {
uint256 tokenId
) external view returns (address);

/// @notice Gets the metadata provider linked to an IP based on its ID.
/// @param id The canonical identifier for the IP.
/// @return The metadata that was bound to this IP at creation time.
function metadataProvider(address id) external view returns (address);

/// @notice Registers an NFT as IP, creating a corresponding IP record.
/// @dev This is only callable by an authorized registration module.
/// @param chainId The chain identifier of where the IP resides.
/// @param tokenContract The address of the IP.
/// @param tokenId The token identifier of the IP.
/// @param resolverAddr The address of the resolver to associate with the IP.
/// @param createAccount Whether to create an IP account in the process.
/// @param metadataProvider The metadata provider to associate with the IP.
function register(
uint256 chainId,
address tokenContract,
uint256 tokenId,
address resolverAddr,
bool createAccount
bool createAccount,
address metadataProvider
) external returns (address);

/// @notice Creates the IP account for the specified IP.
Expand Down
11 changes: 11 additions & 0 deletions contracts/interfaces/registries/metadata/IMetadataProvider.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: UNLICENSED
// See https://github.com/storyprotocol/protocol-contracts/blob/main/StoryProtocol-AlphaTestingAgreement-17942166.3.pdf
pragma solidity ^0.8.23;

/// @title Metadata Provider Interface
interface IMetadataProvider {

/// @notice Gets the metadata associated with an IP asset.
/// @param ipId The address identifier of the IP asset.
function getMetadata(address ipId) external view returns (bytes memory);
}
76 changes: 0 additions & 76 deletions contracts/interfaces/resolvers/IIPMetadataResolver.sol

This file was deleted.

20 changes: 20 additions & 0 deletions contracts/interfaces/resolvers/IKeyValueResolver.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: UNLICENSED
// See https://github.com/storyprotocol/protocol-contracts/blob/main/StoryProtocol-AlphaTestingAgreement-17942166.3.pdf
pragma solidity ^0.8.23;

/// @title Key Value Resolver Interface
interface IKeyValueResolver {

/// @notice Emits when a new key-value pair is set for the resolver.
event KeyValueSet(
address indexed ipId,
string indexed key,
string value
);

/// @notice Retrieves the string value associated with a key for an IP asset.
function value(
address ipId,
string calldata key
) external view returns (string memory);
}
8 changes: 7 additions & 1 deletion contracts/lib/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ library Errors {
/// @notice Caller not authorized to perform the IP resolver function call.
error IPResolver_Unauthorized();

////////////////////////////////////////////////////////////////////////////
// Metadata Provider ///
////////////////////////////////////////////////////////////////////////////

/// @notice Caller does not access to set metadata storage for the provider.
error MetadataProvider_Unauthorized();

////////////////////////////////////////////////////////////////////////////
// LicenseRegistry //
////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -132,5 +139,4 @@ library Errors {
error TaggingModule__SrcIpIdDoesNotHaveSrcTag();
error TaggingModule__DstIpIdDoesNotHaveDstTag();
error TaggingModule__RelationTypeDoesNotExist();

}
32 changes: 3 additions & 29 deletions contracts/lib/IP.sol
Original file line number Diff line number Diff line change
@@ -1,47 +1,21 @@
// SPDX-License-Identifier: UNLICENSED
// See https://github.com/storyprotocol/protocol-contracts/blob/main/StoryProtocol-AlphaTestingAgreement-17942166.3.pdf
pragma solidity ^0.8.21;
pragma solidity ^0.8.23;

/// @title IP Library
/// @notice Library for constants, structs, and helper functions used for IP.
library IP {
/// @notice Core metadata associated with an IP.
/// @dev This is what is fetched when `metadata()` is called from an IP
/// resolver, and includes aggregated attributes fetched from various
/// modules in addition to that which is stored on the resolver itself.
/// @notice Core metadata to associate with each IP.
struct Metadata {
// The current owner of the IP.
address owner;
// The name associated with the IP.
string name;
// A description associated with the IP.
string description;
// A keccak-256 hash of the IP content.
bytes32 hash;
// The date which the IP was registered.
uint64 registrationDate;
// The address of the initial IP registrant.
address registrant;
// The token URI associated with the IP.
string uri;
}

/// @notice Core metadata exclusively saved by the IP resolver.
/// @dev This only encompasses metadata which is stored on the IP metadata
/// resolver itself, and does not include those attributes which may
/// be fetched from different modules (e.g. the licensing modules).
struct MetadataRecord {
// The name associated with the IP.
string name;
// A description associated with the IP.
string description;
// A keccak-256 hash of the IP content.
bytes32 hash;
// The date which the IP was registered.
uint64 registrationDate;
// The address of the initial IP registrant.
address registrant;
// The token URI associated with the IP.
// An external URI associated with the IP.
string uri;
}
}
4 changes: 2 additions & 2 deletions contracts/lib/modules/Module.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
// See https://github.com/storyprotocol/protocol-contracts/blob/main/StoryProtocol-AlphaTestingAgreement-17942166.3.pdf
pragma solidity ^0.8.21;
pragma solidity ^0.8.23;

// String values for core protocol modules.
string constant METADATA_RESOLVER_MODULE_KEY = "METADATA_RESOLVER_MODULE";
string constant IP_RESOLVER_MODULE_KEY = "IP_RESOLVER_MODULE";

// String values for core protocol modules.
string constant REGISTRATION_MODULE_KEY = "REGISTRATION_MODULE";
2 changes: 1 addition & 1 deletion contracts/mocks/MockERC721.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract MockERC721 is ERC721 {
leeren marked this conversation as resolved.
Show resolved Hide resolved
uint256 private _counter;
Expand Down
Loading
Loading