diff --git a/foundry.toml b/foundry.toml index 25b918f..8879fd9 100644 --- a/foundry.toml +++ b/foundry.toml @@ -1,6 +1,11 @@ [profile.default] -src = "src" -out = "out" -libs = ["lib"] - -# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options +src = 'contracts' +out = 'out' +libs = ['node_modules', 'lib'] +cache_path = 'forge-cache' +gas_reports = ["*"] +optimizer = true +optimizer_runs = 20000 +test = 'test' +solc = '0.8.23' +fs_permissions = [{ access = 'read', path = './' }, { access = 'read-write', path = './deploy-out' }] diff --git a/package.json b/package.json index 26ac9b9..ce56243 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "dependencies": { "@openzeppelin/contracts": "5.0.1", "@openzeppelin/contracts-upgradeable": "5.0.1", - "@story-protocol/core": "https://github.com/storyprotocol/protocol-core#main", - "@story-protocol/periphery": "https://github.com/storyprotocol/protocol-periphery#main" + "@story-protocol/protocol-core": "^1.0.0-beta-rc6", + "@story-protocol/protocol-periphery": "^1.0.0-beta-rc1" } } diff --git a/remappings.txt b/remappings.txt index 1835929..42f91ac 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,6 +1,6 @@ @openzeppelin/=node_modules/@openzeppelin/ -@story-protocol/core/=node_modules/@story-protocol/core/contracts/ -@story-protocol/periphery/=node_modules/@story-protocol/periphery/contracts/ +@storyprotocol/core/=node_modules/@story-protocol/protocol-core/contracts/ +@storyprotocol/periphery/=node_modules/@story-protocol/protocol-periphery/contracts/ erc6551/=node_modules/erc6551/ forge-std/=node_modules/forge-std/src/ ds-test/=node_modules/ds-test/src/ diff --git a/src/IPARegistrar.sol b/src/IPARegistrar.sol index 48d7bbb..b3a38bd 100644 --- a/src/IPARegistrar.sol +++ b/src/IPARegistrar.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.23; -import { IP } from "@story-protocol/core/lib/IP.sol"; -import { IPAssetRegistry } from "@story-protocol/core/registries/IPAssetRegistry.sol"; -import { IPResolver } from "@story-protocol/core/resolvers/IPResolver.sol"; +import { IP } from "@storyprotocol/core/lib/IP.sol"; +import { IPAssetRegistry } from "@storyprotocol/core/registries/IPAssetRegistry.sol"; +import { IPResolver } from "@storyprotocol/core/resolvers/IPResolver.sol"; contract IPARegistrar { address public immutable NFT; @@ -21,7 +21,7 @@ contract IPARegistrar { } function register( - string memory ipName, + string memory ipName, uint256 tokenId ) external returns (address) { bytes memory metadata = abi.encode( @@ -33,6 +33,13 @@ contract IPARegistrar { uri: "" }) ); - return IPA_REGISTRY.register(block.chainid, NFT, tokenId, IP_RESOLVER, true, metadata); + return IPA_REGISTRY.register( + block.chainid, + NFT, + tokenId, + IP_RESOLVER, + true, + metadata + ); } -} \ No newline at end of file +} diff --git a/test/IPARegistrar.t.sol b/test/IPARegistrar.t.sol index 8c1a7ad..319b3de 100644 --- a/test/IPARegistrar.t.sol +++ b/test/IPARegistrar.t.sol @@ -1,11 +1,12 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.23; +import { stdJson } from "forge-std/Script.sol"; import { Test } from "forge-std/Test.sol"; import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; -import { IPAssetRegistry } from "@story-protocol/core/registries/IPAssetRegistry.sol"; -import { IPResolver } from "@story-protocol/core/resolvers/IPResolver.sol"; +import { IPAssetRegistry } from "@storyprotocol/core/registries/IPAssetRegistry.sol"; +import { IPResolver } from "@storyprotocol/core/resolvers/IPResolver.sol"; import { IPARegistrar } from "../src/IPARegistrar.sol"; @@ -21,24 +22,38 @@ contract MockERC721 is ERC721 { } contract IPARegistrarTest is Test { - address public constant IPA_REGISTRY_ADDR = address(0x7567ea73697De50591EEc317Fe2b924252c41608); - address public constant IP_RESOLVER_ADDR = address(0xEF808885355B3c88648D39c9DB5A0c08D99C6B71); + + using stdJson for string; + + address internal ipAssetRegistryAddr; + address internal licensingModuleAddr; + address internal ipResolverAddr; MockERC721 public NFT; IPARegistrar public ipaRegistrar; function setUp() public { + _readProtocolAddresses(); NFT = new MockERC721("Story Mock NFT", "STORY"); ipaRegistrar = new IPARegistrar( - IPA_REGISTRY_ADDR, - IP_RESOLVER_ADDR, + ipAssetRegistryAddr, + ipResolverAddr, address(NFT) ); } function test_IPARegistration() public { + vm.startPrank(address(ipaRegistrar)); uint256 tokenId = NFT.mint(); address ipId = ipaRegistrar.register("test", tokenId); - assertTrue(IPAssetRegistry(IPA_REGISTRY_ADDR).isRegistered(ipId), "not registered"); } -} \ No newline at end of file + + function _readProtocolAddresses() internal { + string memory root = vm.projectRoot(); + string memory path = string.concat(root, "/node_modules/@story-protocol/protocol-core/deploy-out/deployment-11155111.json"); + string memory json = vm.readFile(path); + ipAssetRegistryAddr = json.readAddress(".main.IPAssetRegistry"); + ipResolverAddr = json.readAddress(".main.IPResolver"); + + } +} diff --git a/yarn.lock b/yarn.lock index b1e9b42..76a08f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,29 +12,23 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-5.0.1.tgz#93da90fc209a0a4ff09c1deb037fbb35e4020890" integrity sha512-yQJaT5HDp9hYOOp4jTYxMsR02gdFZFXhewX5HW9Jo4fsqSVqqyIO/xTHdWDaKX5a3pv1txmf076Lziz+sO7L1w== -"@story-protocol/core@https://github.com/storyprotocol/protocol-core#main": - version "0.3.0" - resolved "https://github.com/storyprotocol/protocol-core#c84d0a68f9bac17ce7b7b12ccfccd2fc5e49d0c8" +"@story-protocol/protocol-core@1.0.0-beta-rc6", "@story-protocol/protocol-core@^1.0.0-beta-rc6": + version "1.0.0-beta-rc6" + resolved "https://registry.yarnpkg.com/@story-protocol/protocol-core/-/protocol-core-1.0.0-beta-rc6.tgz#be833ae95419340816c6f246c40654d0e8a649c0" + integrity sha512-2diMjDOpFuKcKZ7BQTdR0jb/W3Etob3cPkewteZvXgYwpLd0MpwPDkujPOM7KijYlp781kDx0ay8TqutgqH5QQ== dependencies: "@openzeppelin/contracts" "5.0.1" "@openzeppelin/contracts-upgradeable" "5.0.1" erc6551 "^0.3.1" -"@story-protocol/periphery@https://github.com/storyprotocol/protocol-periphery#main": - version "1.0.0" - resolved "https://github.com/storyprotocol/protocol-periphery#7cba00791aee096e6444b28ebf0549bb9687e8ec" +"@story-protocol/protocol-periphery@^1.0.0-beta-rc1": + version "1.0.0-beta-rc1" + resolved "https://registry.yarnpkg.com/@story-protocol/protocol-periphery/-/protocol-periphery-1.0.0-beta-rc1.tgz#143a4fafd7a14fd286e544cf44deb3637d76a984" + integrity sha512-30fArxLUI5aQ7kb6vQsMTvRLdWIhG2fo1+kOkbfe4+kFcBEAnDG1nV6YKxO7zkpkBas6iXzl4QJPcjOr411ehg== dependencies: "@openzeppelin/contracts" "5.0.1" "@openzeppelin/contracts-upgradeable" "5.0.1" - "@storyprotocol/contracts" "https://github.com/storyprotocol/protocol-core#main" - -"@storyprotocol/contracts@https://github.com/storyprotocol/protocol-core#main": - version "1.0.0" - resolved "https://github.com/storyprotocol/protocol-core#de57c330bd04f18f8d8264d1dce584b3ec4ee386" - dependencies: - "@openzeppelin/contracts" "5.0.1" - "@openzeppelin/contracts-upgradeable" "5.0.1" - erc6551 "^0.3.1" + "@story-protocol/protocol-core" "1.0.0-beta-rc6" "ds-test@https://github.com/dapphub/ds-test": version "1.0.0"