cannon
cannon copied to clipboard
feat(registry): Add registry subscription model
Subscription model to the registry with possibility of paying with any ERC20 token implementation.
FAQs
CannonSubscriptionis a separate contract, though that it would be easier for future upgrades.- Subscription Plans are defined by us, and there is going to be always a "default" one for new users.
- Subscription Plans are a combination of Price by Term, and the user when subscribing has to pay
price * amountOfTermsrequired. - We can set the minimum or maximum amount of terms a user can have of a given plan. This means that:
- e.g. using the
minTermsof a plan, we can set that for a plan that has 100 credits per month, the user needs to pay for at least 12 terms, which would mean a 1 year subscription. - e.g. for max duration, the user cannot subscribe more than 2 years in advance (namely 24 terms), this is so we don't commit indefinitely to offering that plan.
- e.g. using the
- A
Membershipis an instance of a givenPlanfor aUser, which saves since when it started and its expiration date. It also has tally ofcreditsby term. - The user can call
cancelMembership, it will delete the existing membership and give back the USDC of the terms that didn't start yet. This means if the terms are 1 month, and the user is on month 3 of a 1 year subscription, we will give back 9 months worth of USDC that they payed. (for this to work the registry has to have sufficient USDC, ofc) - If we create a new default plan, the users that are already subscribed to an older plan they will still have the credits from the old plan.
- We can disable an old plan so the users that are subscribed to them cannot renew them (but they will be able to finish the membership until it ends)
TODO
- [x] Subscription Plan
- [x] Membership Creation/Update
- [x] Membership Payment
- [x] New Publish logic (count publishes, update membership if necessary)
- [x] Update tests
- [ ] Update cannonfiles
- [ ] Builder/CLI subscription logic
- [ ] Prevent re-publish
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
:loudspeaker: Thoughts on this report? Let us know!