From 691080dcccc8d7c8b21563e6729cfd71b35a8592 Mon Sep 17 00:00:00 2001 From: Kingster Date: Thu, 21 Mar 2024 11:15:59 -0700 Subject: [PATCH] add chainid into name --- contracts/registries/IPAssetRegistry.sol | 8 +++++++- test/foundry/registries/IPAssetRegistry.t.sol | 14 ++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/contracts/registries/IPAssetRegistry.sol b/contracts/registries/IPAssetRegistry.sol index 00f2278d..9822b9c7 100644 --- a/contracts/registries/IPAssetRegistry.sol +++ b/contracts/registries/IPAssetRegistry.sol @@ -102,7 +102,13 @@ contract IPAssetRegistry is IIPAssetRegistry, IPAccountRegistry, Governable { revert Errors.IPAssetRegistry__AlreadyRegistered(); } - string memory name = string.concat(IERC721Metadata(tokenContract).name(), " #", tokenId.toString()); + string memory name = string.concat( + block.chainid.toString(), + ": ", + IERC721Metadata(tokenContract).name(), + " #", + tokenId.toString() + ); string memory uri = IERC721Metadata(tokenContract).tokenURI(tokenId); uint256 registrationDate = block.timestamp; ipAccount.setString("NAME", name); diff --git a/test/foundry/registries/IPAssetRegistry.t.sol b/test/foundry/registries/IPAssetRegistry.t.sol index d808c17b..8dce47d3 100644 --- a/test/foundry/registries/IPAssetRegistry.t.sol +++ b/test/foundry/registries/IPAssetRegistry.t.sol @@ -10,6 +10,7 @@ import { Errors } from "contracts/lib/Errors.sol"; import { IIPAccount } from "contracts/interfaces/IIPAccount.sol"; import { IPAccountStorageOps } from "contracts/lib/IPAccountStorageOps.sol"; import { ShortStrings } from "@openzeppelin/contracts/utils/ShortStrings.sol"; +import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; import { MockERC721WithoutMetadata } from "test/foundry/mocks/token/MockERC721WithoutMetadata.sol"; import { BaseTest } from "../utils/BaseTest.t.sol"; @@ -19,6 +20,7 @@ import { BaseTest } from "../utils/BaseTest.t.sol"; contract IPAssetRegistryTest is BaseTest { using IPAccountStorageOps for IIPAccount; using ShortStrings for *; + using Strings for *; // Default IP record attributes. string public constant IP_NAME = "IPAsset"; string public constant IP_DESCRIPTION = "IPs all the way down."; @@ -76,14 +78,14 @@ contract IPAssetRegistryTest is BaseTest { assertTrue(!registry.isRegistered(ipId)); assertTrue(!IPAccountChecker.isRegistered(ipAccountRegistry, block.chainid, tokenAddress, tokenId)); - + string memory name = string.concat(block.chainid.toString(), ": Ape #99"); vm.expectEmit(true, true, true, true); emit IIPAssetRegistry.IPRegisteredPermissionless( ipId, block.chainid, tokenAddress, tokenId, - "Ape #99", + name, "https://storyprotocol.xyz/erc721/99", block.timestamp ); @@ -92,7 +94,7 @@ contract IPAssetRegistryTest is BaseTest { assertEq(totalSupply + 1, registry.totalSupply()); assertTrue(IPAccountChecker.isRegistered(ipAccountRegistry, block.chainid, tokenAddress, tokenId)); - assertEq(IIPAccount(payable(ipId)).getString(address(registry), "NAME"), "Ape #99"); + assertEq(IIPAccount(payable(ipId)).getString(address(registry), "NAME"), name); assertEq(IIPAccount(payable(ipId)).getString(address(registry), "URI"), "https://storyprotocol.xyz/erc721/99"); assertEq(IIPAccount(payable(ipId)).getUint256(address(registry), "REGISTRATION_DATE"), block.timestamp); } @@ -102,14 +104,14 @@ contract IPAssetRegistryTest is BaseTest { uint256 totalSupply = registry.totalSupply(); IIPAccountRegistry(registry).registerIpAccount(block.chainid, tokenAddress, tokenId); - + string memory name = string.concat(block.chainid.toString(), ": Ape #99"); vm.expectEmit(true, true, true, true); emit IIPAssetRegistry.IPRegisteredPermissionless( ipId, block.chainid, tokenAddress, tokenId, - "Ape #99", + name, "https://storyprotocol.xyz/erc721/99", block.timestamp ); @@ -118,7 +120,7 @@ contract IPAssetRegistryTest is BaseTest { assertEq(totalSupply + 1, registry.totalSupply()); assertTrue(IPAccountChecker.isRegistered(ipAccountRegistry, block.chainid, tokenAddress, tokenId)); - assertEq(IIPAccount(payable(ipId)).getString(address(registry), "NAME"), "Ape #99"); + assertEq(IIPAccount(payable(ipId)).getString(address(registry), "NAME"), name); assertEq(IIPAccount(payable(ipId)).getString(address(registry), "URI"), "https://storyprotocol.xyz/erc721/99"); assertEq(IIPAccount(payable(ipId)).getUint256(address(registry), "REGISTRATION_DATE"), block.timestamp); }