Skip to content

Commit

Permalink
SPG Resource & Test Setup (#162)
Browse files Browse the repository at this point in the history
* config: periphery repo ABI generation

* feat: add all SPG fns & events

* config: add es2015 for promise in tsconfig

* feat: new generated wagmi binding

* feat: SPG resource

* fix(test): basic single SPG test case

* fix: remove test only

* fix: imports and types

* feat: SPG resource unit test

* fix: optional params in create collection

* fix: change fn & type name

* feat: add all pil type tests

* refactor: spg to nft client

* fix: nft client test

* lint: fix
  • Loading branch information
jdubpark authored May 7, 2024
1 parent af83f2e commit b883955
Show file tree
Hide file tree
Showing 14 changed files with 738 additions and 79 deletions.
10 changes: 7 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[submodule "packages/core-sdk/protocol-contracts"]
path = packages/core-sdk/protocol-contracts
[submodule "packages/core-sdk/protocol-periphery-contracts"]
path = packages/core-sdk/protocol-periphery-contracts
url = https://github.com/storyprotocol/protocol-periphery-v1
branch = release-v1.x.x
[submodule "packages/core-sdk/protocol-core-contracts"]
path = packages/core-sdk/protocol-core-contracts
url = https://github.com/storyprotocol/protocol-core-v1
branch = main
branch = release-v1.x.x
49 changes: 24 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
.PHONY: compile_contracts

compile_contracts:
git submodule add -b main --force https://github.com/storyprotocol/protocol-core-v1 packages/core-sdk/protocol-contracts
rm -rf packages/core-sdk/src/abi/json/tmp

git submodule add -b release-v1.x.x --force https://github.com/storyprotocol/protocol-core-v1 packages/core-sdk/protocol-core-contracts
git submodule add -b release-v1.x.x --force https://github.com/storyprotocol/protocol-periphery-v1 packages/core-sdk/protocol-periphery-contracts
git submodule update --remote --merge
cd packages/core-sdk/protocol-contracts && 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/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/royalty/policies/IpRoyaltyVault.sol -o packages/core-sdk/src/abi/json/tmp/Royalty
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/modules/licensing/PILicenseTemplate.sol -o packages/core-sdk/src/abi/json/tmp/PILicenseTemplate
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
cd packages/core-sdk/protocol-core-contracts && yarn install

solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-core-contracts --include-path packages/core-sdk/protocol-core-contracts/node_modules/ --abi packages/core-sdk/protocol-core-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-core-contracts --include-path packages/core-sdk/protocol-core-contracts/node_modules/ --abi packages/core-sdk/protocol-core-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-core-contracts --include-path packages/core-sdk/protocol-core-contracts/node_modules/ --abi packages/core-sdk/protocol-core-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-core-contracts --include-path packages/core-sdk/protocol-core-contracts/node_modules/ --abi packages/core-sdk/protocol-core-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-core-contracts --include-path packages/core-sdk/protocol-core-contracts/node_modules/ --abi packages/core-sdk/protocol-core-contracts/contracts/modules/royalty/policies/IpRoyaltyVault.sol -o packages/core-sdk/src/abi/json/tmp/Royalty
solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-core-contracts --include-path packages/core-sdk/protocol-core-contracts/node_modules/ --abi packages/core-sdk/protocol-core-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-core-contracts --include-path packages/core-sdk/protocol-core-contracts/node_modules/ --abi packages/core-sdk/protocol-core-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-core-contracts --include-path packages/core-sdk/protocol-core-contracts/node_modules/ --abi packages/core-sdk/protocol-core-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-core-contracts --include-path packages/core-sdk/protocol-core-contracts/node_modules/ --abi packages/core-sdk/protocol-core-contracts/contracts/modules/licensing/PILicenseTemplate.sol -o packages/core-sdk/src/abi/json/tmp/PILicenseTemplate
solc @erc6551/=node_modules/erc6551/ --pretty-json --base-path packages/core-sdk/protocol-core-contracts --include-path packages/core-sdk/protocol-core-contracts/node_modules/ --abi packages/core-sdk/protocol-core-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/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/Royalty/IpRoyaltyVault.abi)"' as const;' > packages/core-sdk/src/abi/json/IpRoyaltyVault.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/Royalty/IRoyaltyPolicyLAP.abi)"' as const;' > packages/core-sdk/src/abi/json/IRoyaltyPolicyLAP.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/IRoyaltyModule.abi)"' as const;' > packages/core-sdk/src/abi/json/IRoyaltyModule.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
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/PILicenseTemplate/IPILicenseTemplate.abi)"' as const;' > packages/core-sdk/src/abi/json/IPILicenseTemplate.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/LicensingModule/ILicenseToken.abi)"' as const;' > packages/core-sdk/src/abi/json/ILicenseToken.abi.ts
cd packages/core-sdk/protocol-periphery-contracts && yarn install

solc @storyprotocol/core/=node_modules/@story-protocol/protocol-core/contracts/ --pretty-json --base-path packages/core-sdk/protocol-periphery-contracts --include-path packages/core-sdk/protocol-periphery-contracts/node_modules/ --abi packages/core-sdk/protocol-periphery-contracts/contracts/StoryProtocolGateway.sol -o packages/core-sdk/src/abi/json/tmp/StoryProtocolGateway
solc @storyprotocol/core/=node_modules/@story-protocol/protocol-core/contracts/ --pretty-json --base-path packages/core-sdk/protocol-periphery-contracts --include-path packages/core-sdk/protocol-periphery-contracts/node_modules/ --abi packages/core-sdk/protocol-periphery-contracts/contracts/SPGNFT.sol -o packages/core-sdk/src/abi/json/tmp/SPGNFT

rm -rf packages/core-sdk/src/abi/json/tmp
rm -rf packages/core-sdk/protocol-contracts
rm -rf packages/core-sdk/protocol-core-contracts
rm -rf packages/core-sdk/protocol-periphery-contracts
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ In your testing environment:

- Run `yalc update` to pull the latest changes.

## Steps to pull and compile latest smart contract ABIs (Currently pulls from the protocol-contracts `dev` branch)
## Steps to pull and compile latest Protocol Core & Periphery v1 Smart Contract ABIs (Currently pulls from the protocol-core-v1 and protocol-periphery-v1 `release-v1.x.x` branch)

Must have `solc` installed (https://docs.soliditylang.org/en/v0.8.9/installing-solidity.html)
Must have `solc` installed (https://docs.soliditylang.org/en/v0.8.23/installing-solidity.html)

- run `make compile_contracts`

Expand Down
Loading

0 comments on commit b883955

Please sign in to comment.