From 30076566dcad78cd6a1c67fd5950df5137d5ed01 Mon Sep 17 00:00:00 2001 From: Kingter <83567446+kingster-will@users.noreply.github.com> Date: Thu, 27 Jun 2024 06:37:21 -0700 Subject: [PATCH] Refactor `registerIpAccount` to be Internal function (#155) * Make registerIpAccount be internal function * fix lint --- .../registries/IIPAccountRegistry.sol | 17 --------- contracts/registries/IPAccountRegistry.sol | 38 +++++++++---------- contracts/registries/IPAssetRegistry.sol | 2 +- test/foundry/IPAccount.t.sol | 34 ++++++++++++----- test/foundry/IPAccountImpl.btt.t.sol | 2 +- test/foundry/IPAccountMetaTx.t.sol | 26 ++++++------- test/foundry/IPAccountStorage.t.sol | 2 +- test/foundry/IPAccountStorageOps.t.sol | 2 +- test/foundry/access/AccessControlled.t.sol | 4 +- test/foundry/access/AccessController.t.sol | 2 +- .../external/TokenWithdrawalModule.t.sol | 4 +- .../metadata/CoreMetadataViewModule.t.sol | 8 +++- .../modules/metadata/MetadataModule.t.sol | 8 ++-- .../registries/IPAccountRegistry.t.sol | 4 +- test/foundry/registries/IPAssetRegistry.t.sol | 22 +++++++++-- 15 files changed, 96 insertions(+), 79 deletions(-) diff --git a/contracts/interfaces/registries/IIPAccountRegistry.sol b/contracts/interfaces/registries/IIPAccountRegistry.sol index 2357b273..16cc0d25 100644 --- a/contracts/interfaces/registries/IIPAccountRegistry.sol +++ b/contracts/interfaces/registries/IIPAccountRegistry.sol @@ -18,23 +18,6 @@ interface IIPAccountRegistry { uint256 tokenId ); - /// @notice Returns the IPAccount implementation address - function IP_ACCOUNT_IMPL() external view returns (address); - - /// @notice Returns the IPAccount salt - function IP_ACCOUNT_SALT() external view returns (bytes32); - - /// @notice Returns the public ERC6551 registry address - function ERC6551_PUBLIC_REGISTRY() external view returns (address); - - /// @notice Deploys an IPAccount contract with the IPAccount implementation and returns the address of the new IP - /// @dev The IPAccount deployment deltegates to public ERC6551 Registry - /// @param chainId The chain ID where the IP Account will be created - /// @param tokenContract The address of the token contract to be associated with the IP Account - /// @param tokenId The ID of the token to be associated with the IP Account - /// @return ipAccountAddress The address of the newly created IP Account - function registerIpAccount(uint256 chainId, address tokenContract, uint256 tokenId) external returns (address); - /// @notice Returns the IPAccount address for the given NFT token. /// @param chainId The chain ID where the IP Account is located /// @param tokenContract The address of the token contract associated with the IP Account diff --git a/contracts/registries/IPAccountRegistry.sol b/contracts/registries/IPAccountRegistry.sol index deac1ae5..23b0801f 100644 --- a/contracts/registries/IPAccountRegistry.sol +++ b/contracts/registries/IPAccountRegistry.sol @@ -31,17 +31,32 @@ abstract contract IPAccountRegistry is IIPAccountRegistry { ERC6551_PUBLIC_REGISTRY = erc6551Registry; } - /// @notice Deploys an IPAccount contract with the IPAccount implementation and returns the address of the new IP - /// @dev The IPAccount deployment deltegates to public ERC6551 Registry + /// @notice Returns the IPAccount address for the given NFT token. + /// @param chainId The chain ID where the IP Account is located + /// @param tokenContract The address of the token contract associated with the IP Account + /// @param tokenId The ID of the token associated with the IP Account + /// @return ipAccountAddress The address of the IP Account associated with the given NFT token + function ipAccount(uint256 chainId, address tokenContract, uint256 tokenId) public view returns (address) { + return _get6551AccountAddress(chainId, tokenContract, tokenId); + } + + /// @notice Returns the IPAccount implementation address. + /// @return The address of the IPAccount implementation + function getIPAccountImpl() external view override returns (address) { + return IP_ACCOUNT_IMPL; + } + + /// @dev Deploys an IPAccount contract with the IPAccount implementation and returns the address of the new IP + /// The IPAccount deployment delegates to public ERC6551 Registry /// @param chainId The chain ID where the IP Account will be created /// @param tokenContract The address of the token contract to be associated with the IP Account /// @param tokenId The ID of the token to be associated with the IP Account /// @return ipAccountAddress The address of the newly created IP Account - function registerIpAccount( + function _registerIpAccount( uint256 chainId, address tokenContract, uint256 tokenId - ) public returns (address ipAccountAddress) { + ) internal returns (address ipAccountAddress) { ipAccountAddress = IERC6551Registry(ERC6551_PUBLIC_REGISTRY).createAccount( IP_ACCOUNT_IMPL, IP_ACCOUNT_SALT, @@ -52,21 +67,6 @@ abstract contract IPAccountRegistry is IIPAccountRegistry { emit IPAccountRegistered(ipAccountAddress, IP_ACCOUNT_IMPL, chainId, tokenContract, tokenId); } - /// @notice Returns the IPAccount address for the given NFT token. - /// @param chainId The chain ID where the IP Account is located - /// @param tokenContract The address of the token contract associated with the IP Account - /// @param tokenId The ID of the token associated with the IP Account - /// @return ipAccountAddress The address of the IP Account associated with the given NFT token - function ipAccount(uint256 chainId, address tokenContract, uint256 tokenId) public view returns (address) { - return _get6551AccountAddress(chainId, tokenContract, tokenId); - } - - /// @notice Returns the IPAccount implementation address. - /// @return The address of the IPAccount implementation - function getIPAccountImpl() external view override returns (address) { - return IP_ACCOUNT_IMPL; - } - /// @dev Helper function to get the IPAccount address from the ERC6551 registry. function _get6551AccountAddress( uint256 chainId, diff --git a/contracts/registries/IPAssetRegistry.sol b/contracts/registries/IPAssetRegistry.sol index add43c45..b15e52c3 100644 --- a/contracts/registries/IPAssetRegistry.sol +++ b/contracts/registries/IPAssetRegistry.sol @@ -65,7 +65,7 @@ contract IPAssetRegistry is IIPAssetRegistry, IPAccountRegistry, ProtocolPausabl address tokenContract, uint256 tokenId ) external whenNotPaused returns (address id) { - id = registerIpAccount(chainid, tokenContract, tokenId); + id = _registerIpAccount(chainid, tokenContract, tokenId); IIPAccount ipAccount = IIPAccount(payable(id)); if (bytes(ipAccount.getString("NAME")).length != 0) { diff --git a/test/foundry/IPAccount.t.sol b/test/foundry/IPAccount.t.sol index 67e942a4..4f595110 100644 --- a/test/foundry/IPAccount.t.sol +++ b/test/foundry/IPAccount.t.sol @@ -6,17 +6,31 @@ import { ERC6551 } from "@solady/src/accounts/ERC6551.sol"; import { IIPAccount } from "../../contracts/interfaces/IIPAccount.sol"; import { Errors } from "../../contracts/lib/Errors.sol"; +import { IPAccountRegistry } from "../../contracts/registries/IPAccountRegistry.sol"; import { MockModule } from "./mocks/module/MockModule.sol"; import { BaseTest } from "./utils/BaseTest.t.sol"; +contract MockIPAccountRegistry is IPAccountRegistry { + constructor(address erc6551Registry, address ipAccountImpl) IPAccountRegistry(erc6551Registry, ipAccountImpl) {} + + function registerIpAccount(uint256 chainId, address tokenContract, uint256 tokenId) public returns (address) { + return _registerIpAccount(chainId, tokenContract, tokenId); + } +} + contract IPAccountTest is BaseTest { MockModule public module; + MockIPAccountRegistry public mockIpAccountRegistry; function setUp() public override { super.setUp(); module = new MockModule(address(ipAssetRegistry), address(moduleRegistry), "MockModule"); + mockIpAccountRegistry = new MockIPAccountRegistry( + ipAccountRegistry.ERC6551_PUBLIC_REGISTRY(), + ipAccountRegistry.IP_ACCOUNT_IMPL() + ); vm.startPrank(u.admin); // used twice, name() and registerModule() moduleRegistry.registerModule(module.name(), address(module)); @@ -33,14 +47,14 @@ contract IPAccountTest is BaseTest { vm.prank(owner, owner); - address deployedAccount = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address deployedAccount = mockIpAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); assertTrue(deployedAccount != address(0)); assertEq(predictedAccount, deployedAccount); // Create account twice - deployedAccount = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + deployedAccount = mockIpAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); assertEq(predictedAccount, deployedAccount); } @@ -51,7 +65,7 @@ contract IPAccountTest is BaseTest { mockNFT.mintId(owner, tokenId); vm.prank(owner, owner); - address account = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = mockIpAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); @@ -86,7 +100,7 @@ contract IPAccountTest is BaseTest { mockNFT.mintId(owner, tokenId); vm.prank(owner, owner); - address account = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = mockIpAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); uint256 subTokenId = 111; mockNFT.mintId(account, subTokenId); @@ -204,7 +218,7 @@ contract IPAccountTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = mockIpAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); uint256 subTokenId = 111; mockNFT.mintId(account, subTokenId); @@ -231,7 +245,7 @@ contract IPAccountTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = mockIpAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); uint256 subTokenId = 111; mockNFT.mintId(account, subTokenId); @@ -251,7 +265,7 @@ contract IPAccountTest is BaseTest { mockNFT.mintId(owner, tokenId); vm.prank(owner, owner); - address account = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = mockIpAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); address otherOwner = vm.addr(2); uint256 otherTokenId = 200; @@ -269,7 +283,7 @@ contract IPAccountTest is BaseTest { mockNFT.mintId(owner, tokenId); vm.prank(owner, owner); - address account = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = mockIpAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); ERC6551 ipAccount = ERC6551(payable(account)); @@ -304,7 +318,7 @@ contract IPAccountTest is BaseTest { mockNFT.mintId(owner, tokenId); vm.prank(owner, owner); - address account = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = mockIpAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); ERC6551 ipAccount = ERC6551(payable(account)); @@ -325,7 +339,7 @@ contract IPAccountTest is BaseTest { mockNFT.mintId(owner, tokenId); vm.prank(owner, owner); - address account = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = mockIpAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); ERC6551 ipAccount = ERC6551(payable(account)); diff --git a/test/foundry/IPAccountImpl.btt.t.sol b/test/foundry/IPAccountImpl.btt.t.sol index 8eb38e42..005f3cf5 100644 --- a/test/foundry/IPAccountImpl.btt.t.sol +++ b/test/foundry/IPAccountImpl.btt.t.sol @@ -32,7 +32,7 @@ contract IPAccountImplBTT is BaseTest { ipOwner = u.alice; mockNFT.mintId(ipOwner, tokenId); - ipAcct = IIPAccount(payable(ipAssetRegistry.registerIpAccount(chainId, address(mockNFT), tokenId))); + ipAcct = IIPAccount(payable(ipAssetRegistry.register(chainId, address(mockNFT), tokenId))); } function test_IPAccountImpl_supportsInterface() public { diff --git a/test/foundry/IPAccountMetaTx.t.sol b/test/foundry/IPAccountMetaTx.t.sol index 434f0c5d..632019ba 100644 --- a/test/foundry/IPAccountMetaTx.t.sol +++ b/test/foundry/IPAccountMetaTx.t.sol @@ -67,7 +67,7 @@ contract IPAccountMetaTxTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); @@ -117,7 +117,7 @@ contract IPAccountMetaTxTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); @@ -193,7 +193,7 @@ contract IPAccountMetaTxTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); @@ -258,7 +258,7 @@ contract IPAccountMetaTxTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); @@ -305,7 +305,7 @@ contract IPAccountMetaTxTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); @@ -351,7 +351,7 @@ contract IPAccountMetaTxTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); @@ -396,7 +396,7 @@ contract IPAccountMetaTxTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); @@ -442,13 +442,13 @@ contract IPAccountMetaTxTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); uint256 tokenId2 = 101; mockNFT.mintId(owner, tokenId2); - address account2 = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId2); + address account2 = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId2); IIPAccount ipAccount2 = IIPAccount(payable(account2)); uint deadline = block.timestamp + 1000; @@ -482,7 +482,7 @@ contract IPAccountMetaTxTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); @@ -536,7 +536,7 @@ contract IPAccountMetaTxTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); @@ -583,7 +583,7 @@ contract IPAccountMetaTxTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); @@ -628,7 +628,7 @@ contract IPAccountMetaTxTest is BaseTest { mockNFT.mintId(owner, tokenId); - address account = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address account = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); IIPAccount ipAccount = IIPAccount(payable(account)); diff --git a/test/foundry/IPAccountStorage.t.sol b/test/foundry/IPAccountStorage.t.sol index c249cb54..bf789f16 100644 --- a/test/foundry/IPAccountStorage.t.sol +++ b/test/foundry/IPAccountStorage.t.sol @@ -23,7 +23,7 @@ contract IPAccountStorageTest is BaseTest, BaseModule { address owner = vm.addr(1); uint256 tokenId = 100; mockNFT.mintId(owner, tokenId); - ipAccount = IIPAccount(payable(ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId))); + ipAccount = IIPAccount(payable(ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId))); vm.startPrank(admin); moduleRegistry.registerModule("MockModule", address(module)); moduleRegistry.registerModule("IPAccountStorageTest", address(this)); diff --git a/test/foundry/IPAccountStorageOps.t.sol b/test/foundry/IPAccountStorageOps.t.sol index 24afec0b..d3a5cdeb 100644 --- a/test/foundry/IPAccountStorageOps.t.sol +++ b/test/foundry/IPAccountStorageOps.t.sol @@ -25,7 +25,7 @@ contract IPAccountStorageOpsTest is BaseTest, BaseModule { address owner = vm.addr(1); uint256 tokenId = 100; mockNFT.mintId(owner, tokenId); - ipAccount = IIPAccount(payable(ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId))); + ipAccount = IIPAccount(payable(ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId))); vm.startPrank(admin); moduleRegistry.registerModule("MockModule", address(module)); moduleRegistry.registerModule("IPAccountStorageOpsTest", address(this)); diff --git a/test/foundry/access/AccessControlled.t.sol b/test/foundry/access/AccessControlled.t.sol index 144f086d..710ebb30 100644 --- a/test/foundry/access/AccessControlled.t.sol +++ b/test/foundry/access/AccessControlled.t.sol @@ -19,7 +19,7 @@ contract AccessControlledTest is BaseTest { super.setUp(); mockNFT.mintId(owner, tokenId); - address deployedAccount = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address deployedAccount = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); ipAccount = IIPAccount(payable(deployedAccount)); mockModule = new MockAccessControlledModule( @@ -117,7 +117,7 @@ contract AccessControlledTest is BaseTest { function test_AccessControlled_revert_callIpAccountOrPermissionFunction_withOtherIpAccount() public { mockNFT.mintId(owner, 101); - address otherIpAccountAddr = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), 101); + address otherIpAccountAddr = ipAssetRegistry.register(block.chainid, address(mockNFT), 101); IIPAccount otherIpAccount = IIPAccount(payable(otherIpAccountAddr)); vm.expectRevert( abi.encodeWithSelector( diff --git a/test/foundry/access/AccessController.t.sol b/test/foundry/access/AccessController.t.sol index a38145cb..4e729c0a 100644 --- a/test/foundry/access/AccessController.t.sol +++ b/test/foundry/access/AccessController.t.sol @@ -26,7 +26,7 @@ contract AccessControllerTest is BaseTest { super.setUp(); mockNFT.mintId(owner, tokenId); - address deployedAccount = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address deployedAccount = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); ipAccount = IIPAccount(payable(deployedAccount)); mockModule = new MockModule(address(ipAccountRegistry), address(moduleRegistry), "MockModule"); diff --git a/test/foundry/modules/external/TokenWithdrawalModule.t.sol b/test/foundry/modules/external/TokenWithdrawalModule.t.sol index b52a4220..0aa416f0 100644 --- a/test/foundry/modules/external/TokenWithdrawalModule.t.sol +++ b/test/foundry/modules/external/TokenWithdrawalModule.t.sol @@ -36,8 +36,8 @@ contract TokenWithdrawalModuleTest is BaseTest { mockNFT.mintId(alice, 1); mockNFT.mintId(alice, 2); - ipAcct1 = IIPAccount(payable(ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), 1))); - ipAcct2 = IIPAccount(payable(ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), 2))); + ipAcct1 = IIPAccount(payable(ipAssetRegistry.register(block.chainid, address(mockNFT), 1))); + ipAcct2 = IIPAccount(payable(ipAssetRegistry.register(block.chainid, address(mockNFT), 2))); vm.label(address(ipAcct1), "IPAccount1"); vm.label(address(ipAcct2), "IPAccount2"); diff --git a/test/foundry/modules/metadata/CoreMetadataViewModule.t.sol b/test/foundry/modules/metadata/CoreMetadataViewModule.t.sol index 494ac6fd..ccbed6d1 100644 --- a/test/foundry/modules/metadata/CoreMetadataViewModule.t.sol +++ b/test/foundry/modules/metadata/CoreMetadataViewModule.t.sol @@ -84,7 +84,13 @@ contract CoreMetadataViewModuleTest is BaseTest { function test_CoreMetadataViewModule_revert_isSupported() public { mockNFT.mintId(alice, 999); - address nonIpAsset = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), 999); + address nonIpAsset = erc6551Registry.createAccount( + ipAccountRegistry.IP_ACCOUNT_IMPL(), + ipAccountRegistry.IP_ACCOUNT_SALT(), + block.chainid, + address(mockNFT), + 999 + ); assertFalse(coreMetadataViewModule.isSupported(nonIpAsset)); } diff --git a/test/foundry/modules/metadata/MetadataModule.t.sol b/test/foundry/modules/metadata/MetadataModule.t.sol index f79a60d0..d4a85106 100644 --- a/test/foundry/modules/metadata/MetadataModule.t.sol +++ b/test/foundry/modules/metadata/MetadataModule.t.sol @@ -36,7 +36,7 @@ contract MetadataModuleTest is BaseTest { mockNFT.mintId(owner, tokenId); - address ipAccount = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address ipAccount = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); vm.prank(owner); metadataModule.setIpDescription(ipAccount, "This is a mock ERC721 token"); @@ -53,7 +53,7 @@ contract MetadataModuleTest is BaseTest { mockNFT.mintId(owner, tokenId); - address ipAccount = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address ipAccount = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); vm.prank(owner); metadataModule.setIpDescription(ipAccount, "This is a mock ERC721 token"); @@ -75,7 +75,7 @@ contract MetadataModuleTest is BaseTest { mockNFT.mintId(owner, tokenId); - address ipAccount = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address ipAccount = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); vm.prank(owner); metadataModule.setIpDescription(ipAccount, "This is a mock ERC721 token"); @@ -92,7 +92,7 @@ contract MetadataModuleTest is BaseTest { mockNFT.mintId(owner, tokenId); - address ipAccount = ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId); + address ipAccount = ipAssetRegistry.register(block.chainid, address(mockNFT), tokenId); assertFalse(coreMetadataViewModule.isSupported(ipAccount)); assertFalse(allMetadataViewModule.isSupported(ipAccount)); diff --git a/test/foundry/registries/IPAccountRegistry.t.sol b/test/foundry/registries/IPAccountRegistry.t.sol index e1eb385f..da7cba8d 100644 --- a/test/foundry/registries/IPAccountRegistry.t.sol +++ b/test/foundry/registries/IPAccountRegistry.t.sol @@ -24,7 +24,7 @@ contract IPAccountRegistryTest is BaseTest { } function test_IPAccountRegistry_registerIpAccount() public { - address ipAccountAddr = ipAccountRegistry.registerIpAccount(chainId, tokenAddress, tokenId); + address ipAccountAddr = ipAssetRegistry.register(chainId, tokenAddress, tokenId); address registryComputedAddress = ipAccountRegistry.ipAccount(chainId, tokenAddress, tokenId); assertEq(ipAccountAddr, registryComputedAddress); @@ -36,7 +36,7 @@ contract IPAccountRegistryTest is BaseTest { assertEq(tokenAddress_, tokenAddress); assertEq(tokenId_, tokenId); - assertTrue(ipAccountRegistry.isRegistered(chainId, tokenAddress, tokenId)); + assertTrue(ipAssetRegistry.isRegistered(ipAccountAddr)); } function test_IPAccountRegistry_constructor_revert() public { diff --git a/test/foundry/registries/IPAssetRegistry.t.sol b/test/foundry/registries/IPAssetRegistry.t.sol index 6f111cb6..e8625bc1 100644 --- a/test/foundry/registries/IPAssetRegistry.t.sol +++ b/test/foundry/registries/IPAssetRegistry.t.sol @@ -4,7 +4,6 @@ pragma solidity 0.8.23; import { IIPAssetRegistry } from "contracts/interfaces/registries/IIPAssetRegistry.sol"; import { IPAccountChecker } from "contracts/lib/registries/IPAccountChecker.sol"; import { IPAssetRegistry } from "contracts/registries/IPAssetRegistry.sol"; -import { IIPAccountRegistry } from "contracts/interfaces/registries/IIPAccountRegistry.sol"; import { Errors } from "contracts/lib/Errors.sol"; import { IIPAccount } from "contracts/interfaces/IIPAccount.sol"; import { IPAccountStorageOps } from "contracts/lib/IPAccountStorageOps.sol"; @@ -81,8 +80,13 @@ contract IPAssetRegistryTest is BaseTest { /// @notice Tests registration of IP permissionlessly for IPAccount already created. function test_IPAssetRegistry_RegisterPermissionless_IPAccountAlreadyExist() public { uint256 totalSupply = registry.totalSupply(); - - IIPAccountRegistry(registry).registerIpAccount(block.chainid, tokenAddress, tokenId); + erc6551Registry.createAccount( + ipAccountRegistry.IP_ACCOUNT_IMPL(), + ipAccountRegistry.IP_ACCOUNT_SALT(), + block.chainid, + tokenAddress, + tokenId + ); string memory name = string.concat(block.chainid.toString(), ": Ape #99"); vm.expectEmit(true, true, true, true); emit IIPAssetRegistry.IPRegistered( @@ -156,7 +160,17 @@ contract IPAssetRegistryTest is BaseTest { assertTrue(!registry.isRegistered(address(0x12345))); assertTrue(!registry.isRegistered(address(this))); mockNFT.mintId(alice, 1000); - assertTrue(!registry.isRegistered(ipAssetRegistry.registerIpAccount(block.chainid, address(mockNFT), 1000))); + assertTrue( + !registry.isRegistered( + erc6551Registry.createAccount( + ipAccountRegistry.IP_ACCOUNT_IMPL(), + ipAccountRegistry.IP_ACCOUNT_SALT(), + block.chainid, + address(mockNFT), + 1000 + ) + ) + ); } /// @notice Tests registration of IP NFT from other chain.