Skip to content

Conversation

@bonnie57
Copy link
Collaborator

@bonnie57 bonnie57 commented Dec 11, 2025

Description

  • Add PILFlavor utility class with pre-configured license term flavors (non-commercial social remixing, commercial use, commercial remix, creative commons attribution) for easier license terms creation
  • Add LicenseTermsOverride dataclass to allow optional field overrides when using PILFlavor methods
  • Deprecate legacy convenience methods in License class:
    • register_non_com_social_remixing_pil() → Use register_pil_terms(**asdict(PILFlavor.non_commercial_social_remixing()))
    • register_commercial_use_pil() → Use register_pil_terms(**asdict(PILFlavor.commercial_use(...)))
    • register_commercial_remix_pil() → Use register_pil_terms(**asdict(PILFlavor.commercial_remix(...)))
  • Refactor license terms validation to use PILFlavor.validate_license_terms() across License.py and IPAsset.py
  • Add snake_to_camel and convert_dict_keys_to_camel_case utility functions for dictionary key transformation
  • Update LicensingConfig.hook_data type from HexStr to str with proper Web3.to_bytes() conversion
  • Export new public APIs: PILFlavor, PILFlavorError, LicenseTermsOverride, NativeRoyaltyPolicy

Code Examples

Using PILFlavor with IPAsset.register_ip_asset()

# Example 1: Commercial Use license
response = story_client.IPAsset.register_ip_asset(
    nft=MintNFT(type="mint", spg_nft_contract=nft_collection),
    license_terms_data=[
        LicenseTermsDataInput(
            terms=PILFlavor.commercial_use(
                default_minting_fee=10,
                currency=WIP_TOKEN_ADDRESS,
            ),
            licensing_config=LicensingConfig(
                is_set=True,
                minting_fee=10000,
                licensing_hook=ZERO_ADDRESS,
                hook_data=ZERO_HASH,
                commercial_rev_share=10,
                disabled=False,
                expect_minimum_group_reward_share=0,
                expect_group_reward_pool=ZERO_ADDRESS,
            ),
        )
    ],
)

# Example 2: Commercial Remix with royalty shares
response = story_client.IPAsset.register_ip_asset(
    nft=MintedNFT(type="minted", nft_contract=nft_collection, token_id=token_id),
    license_terms_data=[
        LicenseTermsDataInput(
            terms=PILFlavor.commercial_remix(
                default_minting_fee=10,
                currency=WIP_TOKEN_ADDRESS,
                commercial_rev_share=10,
            ),
            licensing_config=LicensingConfig(...),
        )
    ],
    royalty_shares=[
        RoyaltyShareInput(recipient=account.address, percentage=40.0),
        RoyaltyShareInput(recipient=account_2.address, percentage=60.0),
    ],
)

# Example 3: Using LicenseTermsOverride to customize a flavor
response = story_client.IPAsset.register_ip_asset(
    nft=MintNFT(type="mint", spg_nft_contract=nft_collection),
    license_terms_data=[
        LicenseTermsDataInput(
            terms=PILFlavor.non_commercial_social_remixing(
                override=LicenseTermsOverride(
                    commercial_use=True,
                    commercial_attribution=True,
                    royalty_policy=NativeRoyaltyPolicy.LRP,
                    currency=WIP_TOKEN_ADDRESS,
                ),
            ),
            licensing_config=LicensingConfig(...),
        )
    ],
)

…e to snake_case license terms and update return types for license terms methods
… management and enhance deprecation messages for clarity
…cluding non-commercial and commercial use cases
…or license terms and improve validation logic
…alidate_address function and update related unit tests
…ersion and adjust related tests for consistency
… into Group and IPAsset for improved licensing configuration management
… IPAsset, including commercial remix and non-commercial terms
…alty policies and currencies, along with corresponding unit tests
…evenue share calculation and streamline address validation in DerivativeData class
@lucas2brh lucas2brh requested a review from jia57b December 12, 2025 08:18
@bonnie57 bonnie57 merged commit 19b60f0 into main Dec 12, 2025
16 of 17 checks passed
@bonnie57 bonnie57 deleted the PYSDK-38 branch December 12, 2025 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants