Skip to content

Commit

Permalink
Update for Compatibility with protocol-core-v1 and Addition of Regist…
Browse files Browse the repository at this point in the history
…er Method (#119)

* Update abi according to protocol-core-v1 and delete registerRootIp and registerDerivativeIp method

* Update storyTestNet contract address

* Update Abi

* Add register method and tests

* Reset code

* Replace 0x with Hex

* Modify test description

* Remove useless type in ipAsset

* Fix lint error
  • Loading branch information
bonnie57 authored Apr 3, 2024
1 parent 9a67ef5 commit d537b05
Show file tree
Hide file tree
Showing 22 changed files with 423 additions and 1,147 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "packages/core-sdk/protocol-contracts"]
path = packages/core-sdk/protocol-contracts
url = /~https://github.com/storyprotocol/protocol-core
url = /~https://github.com/storyprotocol/protocol-core-v1
branch = main
11 changes: 5 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
compile_contracts:
git submodule add -b main --force /~https://github.com/storyprotocol/protocol-core packages/core-sdk/protocol-contracts
git submodule add -b main --force /~https://github.com/storyprotocol/protocol-core-v1 packages/core-sdk/protocol-contracts
git submodule update --remote --merge
cd packages/core-sdk/protocol-contracts && yarn install
cd packages/core-sdk/protocol-contracts && git checkout tags/v1.0.0-rc.1 && yarn install

solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/IPAccountImpl.sol -o packages/core-sdk/src/abi/json/tmp/IPAccountImpl
solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/AccessController.sol -o packages/core-sdk/src/abi/json/tmp/AccessController
solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/modules/RegistrationModule.sol -o packages/core-sdk/src/abi/json/tmp/RegistrationModule
solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/access/AccessController.sol -o packages/core-sdk/src/abi/json/tmp/AccessController
solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/modules/dispute/DisputeModule.sol -o packages/core-sdk/src/abi/json/tmp/DisputeModule
solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/modules/licensing/LicensingModule.sol -o packages/core-sdk/src/abi/json/tmp/LicensingModule
solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/modules/licensing/PILPolicyFrameworkManager.sol -o packages/core-sdk/src/abi/json/tmp/PILPolicyFrameworkManager
solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/interfaces/registries/IIPAssetRegistry.sol -o packages/core-sdk/src/abi/json/tmp/IIPAssetRegistry
solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/registries/LicenseRegistry.sol -o packages/core-sdk/src/abi/json/tmp/LicenseRegistry
solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/registries/IPAssetRegistry.sol -o packages/core-sdk/src/abi/json/tmp/IPAssetRegistry
solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/lib/Errors.sol -o packages/core-sdk/src/abi/json/tmp/Errors
cp packages/core-sdk/src/abi/json/tmp/Errors/Errors.abi packages/core-sdk/src/abi/json/Errors.json

echo 'export default '"$$(jq '.' packages/core-sdk/src/abi/json/Errors.json)"' as const;' > packages/core-sdk/src/abi/json/Errors.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/IPAccountImpl/IPAccountImpl.abi)"' as const;' > packages/core-sdk/src/abi/json/IPAccountImpl.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/AccessController/AccessController.abi)"' as const;' > packages/core-sdk/src/abi/json/AccessController.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/RegistrationModule/RegistrationModule.abi)"' as const;' > packages/core-sdk/src/abi/json/RegistrationModule.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/DisputeModule/DisputeModule.abi)"' as const;' > packages/core-sdk/src/abi/json/DisputeModule.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/LicensingModule/LicensingModule.abi)"' as const;' > packages/core-sdk/src/abi/json/LicensingModule.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/PILPolicyFrameworkManager/PILPolicyFrameworkManager.abi)"' as const;' > packages/core-sdk/src/abi/json/PILPolicyFrameworkManager.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/IIPAssetRegistry/IIPAssetRegistry.abi)"' as const;' > packages/core-sdk/src/abi/json/IIPAssetRegistry.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/IPAssetRegistry/IIPAssetRegistry.abi)"' as const;' > packages/core-sdk/src/abi/json/IIPAssetRegistry.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/LicenseRegistry/LicenseRegistry.abi)"' as const;' > packages/core-sdk/src/abi/json/LicenseRegistry.abi.ts

rm -rf packages/core-sdk/src/abi/json/tmp
Expand Down
6 changes: 1 addition & 5 deletions packages/core-sdk/src/abi/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import IPAccountImplABI from "./json/IPAccountImpl.abi";
import IPAssetRegistryABI from "./json/IIPAssetRegistry.abi";
import LicensingModuleABI from "./json/LicensingModule.abi";
import PILPolicyFrameworkManagerABI from "./json/PILPolicyFrameworkManager.abi";
import RegistrationModuleABI from "./json/RegistrationModule.abi";
import ErrorsABI from "./json/Errors.abi";
import { contractAddress } from "../utils/env";
import { SupportedChainIds } from "../types/config";
Expand All @@ -34,10 +33,7 @@ export const getLicensingModuleConfig = (chain: SupportedChainIds) => ({
abi: [...LicensingModuleABI, ...ErrorsABI],
address: getAddress(contractAddress[chain].LicensingModule),
});
export const getRegistrationModuleConfig = (chain: SupportedChainIds) => ({
abi: [...RegistrationModuleABI, ...ErrorsABI],
address: getAddress(contractAddress[chain].RegistrationModule),
});

export const getPILPolicyFrameworkManagerConfig = (chain: SupportedChainIds) => ({
abi: [...PILPolicyFrameworkManagerABI, ...ErrorsABI],
address: getAddress(contractAddress[chain].PILPolicyFrameworkManager),
Expand Down
201 changes: 107 additions & 94 deletions packages/core-sdk/src/abi/json/Errors.abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ export default [
name: "AccessControlled__ZeroAddress",
type: "error",
},
{
inputs: [
{
internalType: "address",
name: "signer",
type: "address",
},
{
internalType: "address",
name: "to",
type: "address",
},
],
name: "AccessController__BothCallerAndRecipientAreNotRegisteredModule",
type: "error",
},
{
inputs: [],
name: "AccessController__CallerIsNotIPAccount",
Expand Down Expand Up @@ -78,75 +94,34 @@ export default [
name: "AccessController__PermissionIsNotValid",
type: "error",
},
{
inputs: [
{
internalType: "address",
name: "to",
type: "address",
},
],
name: "AccessController__RecipientIsNotRegisteredModule",
type: "error",
},
{
inputs: [],
name: "AccessController__SignerIsZeroAddress",
type: "error",
},
{
inputs: [],
name: "AncestorsVaultLAP__AlreadyClaimed",
type: "error",
},
{
inputs: [],
name: "AncestorsVaultLAP__ClaimerNotAnAncestor",
type: "error",
},
{
inputs: [],
name: "AncestorsVaultLAP__ERC20BalanceNotZero",
type: "error",
},
{
inputs: [],
name: "AncestorsVaultLAP__ETHBalanceNotZero",
type: "error",
},
{
inputs: [],
name: "AncestorsVaultLAP__InvalidAncestorsHash",
type: "error",
},
{
inputs: [],
name: "AncestorsVaultLAP__InvalidClaimer",
type: "error",
},
{
inputs: [],
name: "AncestorsVaultLAP__TransferFailed",
name: "ArbitrationPolicySP__NotDisputeModule",
type: "error",
},
{
inputs: [],
name: "AncestorsVaultLAP__ZeroRoyaltyPolicyLAP",
name: "ArbitrationPolicySP__ZeroDisputeModule",
type: "error",
},
{
inputs: [],
name: "ArbitrationPolicySP__NotDisputeModule",
name: "ArbitrationPolicySP__ZeroPaymentToken",
type: "error",
},
{
inputs: [],
name: "ArbitrationPolicySP__ZeroDisputeModule",
name: "BasePolicyFrameworkManager__CallerNotLicensingModule",
type: "error",
},
{
inputs: [],
name: "ArbitrationPolicySP__ZeroPaymentToken",
name: "CoreMetadataModule__MetadataAlreadyFrozen",
type: "error",
},
{
Expand Down Expand Up @@ -184,11 +159,6 @@ export default [
name: "DisputeModule__NotWhitelistedDisputeTag",
type: "error",
},
{
inputs: [],
name: "DisputeModule__UnauthorizedAccess",
type: "error",
},
{
inputs: [],
name: "DisputeModule__ZeroArbitrationPolicy",
Expand Down Expand Up @@ -295,6 +265,22 @@ export default [
name: "IPAssetRegistry__InvalidMetadataProvider",
type: "error",
},
{
inputs: [
{
internalType: "address",
name: "contractAddress",
type: "address",
},
{
internalType: "uint256",
name: "tokenId",
type: "uint256",
},
],
name: "IPAssetRegistry__InvalidToken",
type: "error",
},
{
inputs: [],
name: "IPAssetRegistry__NotYetRegistered",
Expand All @@ -315,6 +301,28 @@ export default [
name: "IPAssetRegistry__Unauthorized",
type: "error",
},
{
inputs: [
{
internalType: "address",
name: "contractAddress",
type: "address",
},
],
name: "IPAssetRegistry__UnsupportedIERC721",
type: "error",
},
{
inputs: [
{
internalType: "address",
name: "contractAddress",
type: "address",
},
],
name: "IPAssetRegistry__UnsupportedIERC721Metadata",
type: "error",
},
{
inputs: [],
name: "IPResolver_InvalidIP",
Expand All @@ -325,6 +333,36 @@ export default [
name: "IPResolver_Unauthorized",
type: "error",
},
{
inputs: [],
name: "IpRoyaltyVault__AlreadyClaimed",
type: "error",
},
{
inputs: [],
name: "IpRoyaltyVault__ClaimerNotAnAncestor",
type: "error",
},
{
inputs: [],
name: "IpRoyaltyVault__NotRoyaltyPolicyLAP",
type: "error",
},
{
inputs: [],
name: "IpRoyaltyVault__SnapshotIntervalTooShort",
type: "error",
},
{
inputs: [],
name: "IpRoyaltyVault__ZeroIpId",
type: "error",
},
{
inputs: [],
name: "IpRoyaltyVault__ZeroRoyaltyPolicyLAP",
type: "error",
},
{
inputs: [],
name: "LicenseRegistry__CallerNotLicensingModule",
Expand All @@ -350,11 +388,6 @@ export default [
name: "LicenseRegistry__ZeroLicensingModule",
type: "error",
},
{
inputs: [],
name: "LicensingModuleAware__CallerNotLicensingModule",
type: "error",
},
{
inputs: [],
name: "LicensingModule__CallerNotLicenseRegistry",
Expand Down Expand Up @@ -430,6 +463,11 @@ export default [
name: "LicensingModule__InvalidPolicyFramework",
type: "error",
},
{
inputs: [],
name: "LicensingModule__IpAlreadyLinked",
type: "error",
},
{
inputs: [],
name: "LicensingModule__LicensorDoesntHaveThisPolicy",
Expand All @@ -450,6 +488,11 @@ export default [
name: "LicensingModule__LinkingRevokedLicense",
type: "error",
},
{
inputs: [],
name: "LicensingModule__MintAmountZero",
type: "error",
},
{
inputs: [],
name: "LicensingModule__MintLicenseParamFailed",
Expand Down Expand Up @@ -495,6 +538,11 @@ export default [
name: "LicensingModule__PolicyNotFound",
type: "error",
},
{
inputs: [],
name: "LicensingModule__ReceiverZeroAddress",
type: "error",
},
{
inputs: [],
name: "LicensingModule__RegisterPolicyFrameworkMismatch",
Expand Down Expand Up @@ -656,11 +704,6 @@ export default [
name: "PolicyFrameworkManager__GettingPolicyWrongFramework",
type: "error",
},
{
inputs: [],
name: "RegistrationModule__InvalidOwner",
type: "error",
},
{
inputs: [],
name: "RoyaltyModule__CanOnlyMintSelectedPolicy",
Expand All @@ -686,11 +729,6 @@ export default [
name: "RoyaltyModule__NotAllowedCaller",
type: "error",
},
{
inputs: [],
name: "RoyaltyModule__NotRegisteredIpId",
type: "error",
},
{
inputs: [],
name: "RoyaltyModule__NotWhitelistedRoyaltyPolicy",
Expand Down Expand Up @@ -736,36 +774,11 @@ export default [
name: "RoyaltyPolicyLAP__ImplementationAlreadySet",
type: "error",
},
{
inputs: [],
name: "RoyaltyPolicyLAP__InvalidAncestors",
type: "error",
},
{
inputs: [],
name: "RoyaltyPolicyLAP__InvalidAncestorsHash",
type: "error",
},
{
inputs: [],
name: "RoyaltyPolicyLAP__InvalidAncestorsLength",
type: "error",
},
{
inputs: [],
name: "RoyaltyPolicyLAP__InvalidAncestorsRoyalty",
type: "error",
},
{
inputs: [],
name: "RoyaltyPolicyLAP__InvalidParentRoyaltiesLength",
type: "error",
},
{
inputs: [],
name: "RoyaltyPolicyLAP__InvalidRoyaltyAmountLength",
type: "error",
},
{
inputs: [],
name: "RoyaltyPolicyLAP__LastPositionNotAbleToMintLicense",
Expand All @@ -783,17 +796,17 @@ export default [
},
{
inputs: [],
name: "RoyaltyPolicyLAP__TransferFailed",
name: "RoyaltyPolicyLAP__UnlinkableToParents",
type: "error",
},
{
inputs: [],
name: "RoyaltyPolicyLAP__UnlinkableToParents",
name: "RoyaltyPolicyLAP__ZeroAncestorsVaultImpl",
type: "error",
},
{
inputs: [],
name: "RoyaltyPolicyLAP__ZeroAncestorsVaultImpl",
name: "RoyaltyPolicyLAP__ZeroIpRoyaltyVaultBeacon",
type: "error",
},
{
Expand Down
Loading

0 comments on commit d537b05

Please sign in to comment.