Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c596998
feat: introduce PILFlavor class for managing programmable IP license …
bonnie57 Dec 9, 2025
3f48bf7
feat: enhance PILFlavor class with camelCase to snake_case conversion…
bonnie57 Dec 9, 2025
1d5f518
feat: add unit tests for PILFlavor class to validate non-commercial a…
bonnie57 Dec 9, 2025
0712ed8
feat: refactor License class to utilize PILFlavor for license terms m…
bonnie57 Dec 9, 2025
c58fe6c
feat: enhance License class tests by integrating PILFlavorError for i…
bonnie57 Dec 9, 2025
e601dd9
feat: enhance PILFlavor class with new method for converting camelCas…
bonnie57 Dec 10, 2025
d3f7a14
refactor: the pil_flavor class
bonnie57 Dec 10, 2025
f0882e1
feat: update License class to use LicenseTermsInput for license terms…
bonnie57 Dec 10, 2025
f1cae2b
feat: add unit tests for various PILFlavor registration scenarios, in…
bonnie57 Dec 10, 2025
6af77a2
feat: enhance IPAsset and License classes with camelCase conversion f…
bonnie57 Dec 11, 2025
87edb74
refactor: replace Web3 checksum address validation with a dedicated v…
bonnie57 Dec 11, 2025
86e1ba2
feat: integrate ModuleRegistryClient into IPAsset and update licensin…
bonnie57 Dec 11, 2025
f6807e8
fix: update hookData handling in LicensingConfigData to use text conv…
bonnie57 Dec 11, 2025
255d010
refactor: remove LicenseTerms class and integrate LicensingConfigData…
bonnie57 Dec 11, 2025
0b6fa8e
feat: add comprehensive tests for various licensing configurations in…
bonnie57 Dec 11, 2025
4767da7
refactor: improve deprecation messages in License class methods to cl…
bonnie57 Dec 11, 2025
d8f65c2
docs: update parameter descriptions in License and PILFlavor classes …
bonnie57 Dec 11, 2025
e33dbf4
test: add unit tests for snake_to_camel and convert_dict_keys_to_came…
bonnie57 Dec 11, 2025
0a63a78
feat: enhance IPAsset validation by adding checks for whitelisted roy…
bonnie57 Dec 12, 2025
9acc876
refactor: streamline currency whitelisting check in IPAsset validatio…
bonnie57 Dec 12, 2025
862a81a
refactor: enhance License class by utilizing replace for commercial r…
bonnie57 Dec 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/story_protocol_python_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
RegistrationWithRoyaltyVaultAndLicenseTermsResponse,
RegistrationWithRoyaltyVaultResponse,
)
from .types.resource.License import LicenseTermsInput
from .types.resource.Royalty import RoyaltyShareInput
from .types.resource.License import LicenseTermsInput, LicenseTermsOverride
from .types.resource.Royalty import NativeRoyaltyPolicy, RoyaltyShareInput
from .utils.constants import (
DEFAULT_FUNCTION_SELECTOR,
MAX_ROYALTY_TOKEN,
Expand All @@ -44,6 +44,7 @@
from .utils.derivative_data import DerivativeDataInput
from .utils.ip_metadata import IPMetadataInput
from .utils.licensing_config_data import LicensingConfig
from .utils.pil_flavor import PILFlavor, PILFlavorError

__all__ = [
"StoryClient",
Expand Down Expand Up @@ -72,7 +73,9 @@
"LicensingConfig",
"RegisterPILTermsAndAttachResponse",
"RoyaltyShareInput",
"NativeRoyaltyPolicy",
"LicenseTermsInput",
"LicenseTermsOverride",
"MintNFT",
"MintedNFT",
"RegisterIpAssetResponse",
Expand All @@ -86,4 +89,7 @@
"DEFAULT_FUNCTION_SELECTOR",
"MAX_ROYALTY_TOKEN",
"WIP_TOKEN_ADDRESS",
# utils
"PILFlavor",
"PILFlavorError",
]
12 changes: 7 additions & 5 deletions src/story_protocol_python_sdk/resources/Group.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
from story_protocol_python_sdk.abi.LicensingModule.LicensingModule_client import (
LicensingModuleClient,
)
from story_protocol_python_sdk.abi.ModuleRegistry.ModuleRegistry_client import (
ModuleRegistryClient,
)
from story_protocol_python_sdk.abi.PILicenseTemplate.PILicenseTemplate_client import (
PILicenseTemplateClient,
)
Expand All @@ -32,7 +35,7 @@
CollectRoyaltiesResponse,
)
from story_protocol_python_sdk.utils.constants import ZERO_ADDRESS, ZERO_HASH
from story_protocol_python_sdk.utils.license_terms import LicenseTerms
from story_protocol_python_sdk.utils.licensing_config_data import LicensingConfigData
from story_protocol_python_sdk.utils.sign import Sign
from story_protocol_python_sdk.utils.transaction_utils import build_and_send_transaction
from story_protocol_python_sdk.utils.validation import get_revenue_share
Expand All @@ -59,8 +62,7 @@ def __init__(self, web3: Web3, account, chain_id: int):
self.licensing_module_client = LicensingModuleClient(web3)
self.license_registry_client = LicenseRegistryClient(web3)
self.pi_license_template_client = PILicenseTemplateClient(web3)

self.license_terms_util = LicenseTerms(web3)
self.module_registry_client = ModuleRegistryClient(web3)
self.sign_util = Sign(web3, self.chain_id, self.account)

def register_group(self, group_pool: str, tx_options: dict | None = None) -> dict:
Expand Down Expand Up @@ -707,8 +709,8 @@ def _get_license_data(self, license_data: list) -> list:
processed_item = {
"licenseTemplate": license_template,
"licenseTermsId": item["license_terms_id"],
"licensingConfig": self.license_terms_util.validate_licensing_config(
item.get("licensing_config", {})
"licensingConfig": LicensingConfigData.validate_license_config(
self.module_registry_client, item.get("licensing_config", {})
),
}

Expand Down
44 changes: 36 additions & 8 deletions src/story_protocol_python_sdk/resources/IPAsset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Module for handling IP Account operations and transactions."""

from dataclasses import asdict, is_dataclass
from dataclasses import asdict, is_dataclass, replace
from typing import cast

from ens.ens import Address, HexStr
Expand Down Expand Up @@ -37,6 +37,9 @@
from story_protocol_python_sdk.abi.LicensingModule.LicensingModule_client import (
LicensingModuleClient,
)
from story_protocol_python_sdk.abi.ModuleRegistry.ModuleRegistry_client import (
ModuleRegistryClient,
)
from story_protocol_python_sdk.abi.Multicall3.Multicall3_client import Multicall3Client
from story_protocol_python_sdk.abi.PILicenseTemplate.PILicenseTemplate_client import (
PILicenseTemplateClient,
Expand Down Expand Up @@ -68,6 +71,7 @@
RegistrationWithRoyaltyVaultAndLicenseTermsResponse,
RegistrationWithRoyaltyVaultResponse,
)
from story_protocol_python_sdk.types.resource.License import LicenseTermsInput
from story_protocol_python_sdk.types.resource.Royalty import RoyaltyShareInput
from story_protocol_python_sdk.utils.constants import (
DEADLINE,
Expand All @@ -86,11 +90,14 @@
get_ip_metadata_dict,
is_initial_ip_metadata,
)
from story_protocol_python_sdk.utils.license_terms import LicenseTerms
from story_protocol_python_sdk.utils.licensing_config_data import LicensingConfigData
from story_protocol_python_sdk.utils.pil_flavor import PILFlavor
from story_protocol_python_sdk.utils.royalty import get_royalty_shares
from story_protocol_python_sdk.utils.sign import Sign
from story_protocol_python_sdk.utils.transaction_utils import build_and_send_transaction
from story_protocol_python_sdk.utils.util import convert_dict_keys_to_camel_case
from story_protocol_python_sdk.utils.validation import (
get_revenue_share,
validate_address,
validate_max_rts,
)
Expand Down Expand Up @@ -128,8 +135,8 @@ def __init__(self, web3: Web3, account, chain_id: int):
)
self.royalty_module_client = RoyaltyModuleClient(web3)
self.multicall3_client = Multicall3Client(web3)
self.license_terms_util = LicenseTerms(web3)
self.sign_util = Sign(web3, self.chain_id, self.account)
self.module_registry_client = ModuleRegistryClient(web3)

def mint(
self,
Expand Down Expand Up @@ -685,7 +692,6 @@ def register_ip_and_attach_pil_terms(
f"The NFT with id {token_id} is already registered as IP."
)
license_terms = self._validate_license_terms_data(license_terms_data)

calculated_deadline = self.sign_util.get_deadline(deadline=deadline)

# Get permission signature for all required permissions
Expand Down Expand Up @@ -1329,7 +1335,6 @@ def register_ip_and_attach_pil_terms_and_distribute_royalty_tokens(
license_terms = self._validate_license_terms_data(license_terms_data)
calculated_deadline = self.sign_util.get_deadline(deadline=deadline)
royalty_shares_obj = get_royalty_shares(royalty_shares)

signature_response = self.sign_util.get_permission_signature(
ip_id=ip_id,
deadline=calculated_deadline,
Expand Down Expand Up @@ -2181,11 +2186,34 @@ def _validate_license_terms_data(
terms_dict = term["terms"]
licensing_config_dict = term["licensing_config"]

license_terms = PILFlavor.validate_license_terms(
LicenseTermsInput(**terms_dict)
)
license_terms = replace(
license_terms,
commercial_rev_share=get_revenue_share(
license_terms.commercial_rev_share
),
)
if license_terms.royalty_policy != ZERO_ADDRESS:
is_whitelisted = self.royalty_module_client.isWhitelistedRoyaltyPolicy(
license_terms.royalty_policy
)
if not is_whitelisted:
raise ValueError("The royalty_policy is not whitelisted.")

if license_terms.currency != ZERO_ADDRESS:
is_whitelisted = self.royalty_module_client.isWhitelistedRoyaltyToken(
license_terms.currency
)
if not is_whitelisted:
raise ValueError("The currency is not whitelisted.")

validated_license_terms_data.append(
{
"terms": self.license_terms_util.validate_license_terms(terms_dict),
"licensingConfig": self.license_terms_util.validate_licensing_config(
licensing_config_dict
"terms": convert_dict_keys_to_camel_case(asdict(license_terms)),
"licensingConfig": LicensingConfigData.validate_license_config(
self.module_registry_client, licensing_config_dict
),
}
)
Expand Down
Loading
Loading