Skip to content

Commit

Permalink
add chainid into name
Browse files Browse the repository at this point in the history
  • Loading branch information
kingster-will committed Mar 21, 2024
1 parent 028e093 commit fb9a935
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 7 additions & 1 deletion contracts/registries/IPAssetRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 8 additions & 6 deletions test/foundry/registries/IPAssetRegistry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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.";
Expand Down Expand Up @@ -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
);
Expand All @@ -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);
}
Expand All @@ -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
);
Expand All @@ -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);
}
Expand Down

0 comments on commit fb9a935

Please sign in to comment.