Skip to content

Commit

Permalink
Fixes package.json dependencies, various metadata, and linting issues (
Browse files Browse the repository at this point in the history
…storyprotocol#82)

* Fixes package.json dependencies, various metadata, and linting issues

* Cleans up dependency management
  • Loading branch information
leeren authored Feb 7, 2024
1 parent 2dc30e6 commit 300b0c5
Show file tree
Hide file tree
Showing 87 changed files with 150 additions and 11,795 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/IPAccountImpl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol
import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import { IERC1155Receiver } from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import { IERC6551Account } from "@reference/src/interfaces/IERC6551Account.sol";
import { SignatureChecker } from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import { IERC6551Account } from "@erc6551/interfaces/IERC6551Account.sol";

import { IAccessController } from "./interfaces/IAccessController.sol";
import { IIPAccount } from "./interfaces/IIPAccount.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IIPAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.23;

import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import { IERC1155Receiver } from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import { IERC6551Account } from "@reference/src/interfaces/IERC6551Account.sol";
import { IERC6551Account } from "@erc6551/interfaces/IERC6551Account.sol";

/// @title IIPAccount
/// @dev IPAccount is a token-bound account that adopts the EIP-6551 standard.
Expand Down
4 changes: 3 additions & 1 deletion contracts/interfaces/modules/IRegistrationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ interface IRegistrationModule {
uint256 policyId,
address tokenContract,
uint256 tokenId,
bytes calldata metadata
string memory ipName,
bytes32 hash,
string calldata externalURL
) external returns (address);

function registerDerivativeIp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
// See https://github.com/storyprotocol/protocol-contracts/blob/main/StoryProtocol-AlphaTestingAgreement-17942166.3.pdf
pragma solidity ^0.8.23;

import { IP } from "../../../lib/IP.sol";
import { IMetadataProvider } from "./IMetadataProvider.sol";

/// @title Metadata Provider v1 Interface
interface IMetadataProviderV1 is IMetadataProvider {

/// @notice Fetches the metadata linked to an IP asset.
/// @param ipId The address identifier of the IP asset.
function metadata(address ipId) external view returns (IP.MetadataV1 memory);

/// @notice Gets the name associated with the IP asset.
/// @param ipId The address identifier of the IP asset.
function name(address ipId) external view returns (string memory);
Expand Down
2 changes: 1 addition & 1 deletion contracts/lib/registries/IPAccountChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.21;

import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import { IERC6551Account } from "@reference/src/interfaces/IERC6551Account.sol";
import { IERC6551Account } from "@erc6551/interfaces/IERC6551Account.sol";

import { IIPAccountRegistry } from "../../interfaces/registries/IIPAccountRegistry.sol";
import { IIPAccount } from "../..//interfaces/IIPAccount.sol";
Expand Down
17 changes: 16 additions & 1 deletion contracts/modules/RegistrationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ contract RegistrationModule is BaseModule, IRegistrationModule {
/// @param policyId The policy that identifies the licensing terms of the IP.
/// @param tokenContract The address of the NFT bound to the root-level IP.
/// @param tokenId The token id of the NFT bound to the root-level IP.
/// @param ipName The name assigned to the new IP.
/// @param contentHash The content hash of the IP being registered.
/// @param externalURL An external URI to link to the IP.
function registerRootIp(
uint256 policyId,
address tokenContract,
uint256 tokenId,
bytes calldata metadata
string memory ipName,
bytes32 contentHash,
string calldata externalURL
) external returns (address) {
// Perform registrant authorization.
// Check that the caller is authorized to perform the registration.
Expand All @@ -62,6 +67,16 @@ contract RegistrationModule is BaseModule, IRegistrationModule {
revert Errors.RegistrationModule__InvalidOwner();
}

bytes memory metadata = abi.encode(
IP.MetadataV1({
name: ipName,
hash: contentHash,
registrationDate: uint64(block.timestamp),
registrant: msg.sender,
uri: externalURL
})
);

// Perform core IP registration and IP account creation.
address ipId = IP_ASSET_REGISTRY.register(
block.chainid,
Expand Down
2 changes: 1 addition & 1 deletion contracts/registries/IPAccountRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// See https://github.com/storyprotocol/protocol-contracts/blob/main/StoryProtocol-AlphaTestingAgreement-17942166.3.pdf
pragma solidity ^0.8.23;

import { IERC6551Registry } from "@reference/src/interfaces/IERC6551Registry.sol";
import { IERC6551Registry } from "@erc6551/interfaces/IERC6551Registry.sol";

import { IIPAccountRegistry } from "../interfaces/registries/IIPAccountRegistry.sol";
import { Errors } from "../lib/Errors.sol";
Expand Down
18 changes: 6 additions & 12 deletions contracts/registries/metadata/MetadataProviderV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ contract MetadataProviderV1 is MetadataProviderBase {
/// @param ipAssetRegistry The protocol-wide IP asset registry.
constructor(address ipAssetRegistry) MetadataProviderBase(ipAssetRegistry) {}

/// @notice Fetches the metadata linked to an IP asset.
/// @param ipId The address identifier of the IP asset.
function metadata(address ipId) external view returns (IP.MetadataV1 memory) {
return _metadataV1(ipId);
}

/// @notice Gets the name associated with the IP asset.
/// @param ipId The address identifier of the IP asset.
function name(address ipId) external view returns (string memory) {
Expand Down Expand Up @@ -48,21 +54,9 @@ contract MetadataProviderV1 is MetadataProviderBase {
/// @param data The canonical metadata in bytes to verify.
function _verifyMetadata(bytes memory data) internal virtual override {
IP.MetadataV1 memory decodedMetadata = abi.decode(data, (IP.MetadataV1));
if (bytes(decodedMetadata.name).length == 0) {
revert Errors.MetadataProvider__NameInvalid();
}
if (decodedMetadata.hash == "") {
revert Errors.MetadataProvider__HashInvalid();
}
if (decodedMetadata.registrationDate != uint64(block.timestamp)) {
revert Errors.MetadataProvider__RegistrationDateInvalid();
}
if (decodedMetadata.registrant == address(0)) {
revert Errors.MetadataProvider__RegistrantInvalid();
}
if (bytes(decodedMetadata.uri).length == 0) {
revert Errors.MetadataProvider__URIInvalid();
}
}

/// @dev Checks whether two sets of metadata are compatible with one another.
Expand Down
4 changes: 0 additions & 4 deletions lib/forge-std/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions lib/forge-std/.gitmodules

This file was deleted.

203 changes: 0 additions & 203 deletions lib/forge-std/LICENSE-APACHE

This file was deleted.

25 changes: 0 additions & 25 deletions lib/forge-std/LICENSE-MIT

This file was deleted.

Loading

0 comments on commit 300b0c5

Please sign in to comment.