Update dependencies and enhance subscription management with plan types#47
Merged
Pvsaint merged 4 commits intoChain-Library:mainfrom Jun 9, 2025
Merged
Update dependencies and enhance subscription management with plan types#47Pvsaint merged 4 commits intoChain-Library:mainfrom
Pvsaint merged 4 commits intoChain-Library:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description: Subscription Types, Record Structure, and Expiration Tracking
Overview
This PR implements robust data structures and logic for managing multiple subscription types and durations, as well as accurate expiration tracking for subscriptions.
Key Changes
Subscription Types & Durations:
Added support for various subscription types (e.g., monthly, yearly, trial) and their corresponding durations via the PlanType enum and related fields in the Subscription struct.
Detailed Subscription Record Structure:
The Subscription struct in storage now captures all relevant information, including type, duration, subscriber, status, and timestamps.
The subscription_record mapping efficiently stores all subscriptions per user.
Expiration Tracking Mechanism:
Subscriptions now include end_date and is_active fields.
The contract automatically tracks expiration and updates subscription status on renewal or termination.
Testing:
Added and updated tests to verify correct handling of subscription creation, renewal, expiration, and refund logic.
Compatibility:
The new structures and logic are fully compatible with the content access system, ensuring permissions are managed based on active subscriptions.
Notes
The design is modular and can be extended for future subscription policies or features.