Skip to content

Commit

Permalink
Switches core protocol dependencies to npm beta rc candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
leeren committed Feb 29, 2024
1 parent ed5c4a7 commit 81277de
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 38 deletions.
15 changes: 10 additions & 5 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -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' }]
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
4 changes: 2 additions & 2 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -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/
19 changes: 13 additions & 6 deletions src/IPARegistrar.sol
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,7 +21,7 @@ contract IPARegistrar {
}

function register(
string memory ipName,
string memory ipName,
uint256 tokenId
) external returns (address) {
bytes memory metadata = abi.encode(
Expand All @@ -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
);
}
}
}
31 changes: 23 additions & 8 deletions test/IPARegistrar.t.sol
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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");
}
}

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");

}
}
24 changes: 9 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]", "@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"
Expand Down

0 comments on commit 81277de

Please sign in to comment.