cannon icon indicating copy to clipboard operation
cannon copied to clipboard

feat(registry): Add registry subscription model

Open mjlescano opened this issue 10 months ago • 2 comments

Subscription model to the registry with possibility of paying with any ERC20 token implementation.

FAQs

  • CannonSubscription is 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 * amountOfTerms required.
  • We can set the minimum or maximum amount of terms a user can have of a given plan. This means that:
    1. e.g. using the minTerms of 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.
    2. 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.
  • A Membership is an instance of a given Plan for a User, which saves since when it started and its expiration date. It also has tally of credits by 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

mjlescano avatar Jan 17 '25 00:01 mjlescano

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​radix-ui/​react-label@​2.1.0 ⏵ 2.1.21001006798100
Updated@​radix-ui/​react-separator@​1.1.0 ⏵ 1.1.21001006898100
Updated@​radix-ui/​react-aspect-ratio@​1.1.0 ⏵ 1.1.21001006898100
Updated@​radix-ui/​react-slot@​1.1.1 ⏵ 1.1.21001007098100
Updated@​radix-ui/​react-tooltip@​1.1.3 ⏵ 1.2.49910070 -398100
Updated@​radix-ui/​react-switch@​1.1.2 ⏵ 1.1.3991007198100
Updated@​radix-ui/​react-collapsible@​1.1.1 ⏵ 1.1.3991007198100
Updated@​radix-ui/​react-checkbox@​1.1.2 ⏵ 1.1.4991007198100
Updated@​radix-ui/​react-tabs@​1.1.1 ⏵ 1.1.3991007198100
Updated@​radix-ui/​react-dropdown-menu@​2.1.2 ⏵ 2.1.6991007298100
Updated@​radix-ui/​react-popover@​1.1.2 ⏵ 1.1.6991007298100
Updated@​radix-ui/​react-accordion@​1.2.1 ⏵ 1.2.3991007298 +1100
Updated@​radix-ui/​react-dialog@​1.1.2 ⏵ 1.1.6991007398100
Updated@​radix-ui/​react-scroll-area@​1.2.1 ⏵ 1.2.3991007498100
Updated@​radix-ui/​react-select@​2.1.4 ⏵ 2.1.6981007598100
Added@​ethersproject/​bignumber@​5.8.01001008277100
Updated@​cypress/​webpack-preprocessor@​6.0.2 ⏵ 6.0.499 +110010078 -3100
Updated@​monaco-editor/​react@​4.6.0 ⏵ 4.7.010010010078100
Updated@​next/​third-parties@​14.2.6 ⏵ 14.2.261001008099100
Updated@​rollup/​plugin-node-resolve@​15.2.3 ⏵ 15.3.19910010085100
Updated@​bahmutov/​cypress-esbuild-preprocessor@​2.2.2 ⏵ 2.2.410010010085 +1100
Updated@​rollup/​plugin-commonjs@​26.0.1 ⏵ 26.0.39910010086100
Updated@​safe-global/​api-kit@​2.4.4 ⏵ 2.5.11100 +110086 +189 -5100
Updated@​next/​bundle-analyzer@​14.2.6 ⏵ 14.2.261001008899100
Updated@​sentry/​nextjs@​8.26.0 ⏵ 8.55.096 -1100 +590 +1100 +2100
Updated@​rainbow-me/​rainbowkit@​2.2.1 ⏵ 2.2.49910096 +191 -3100
Updated@​hookform/​resolvers@​3.9.1 ⏵ 3.10.0100 +110010092 +6100
Updated@​cypress/​code-coverage@​3.13.11 ⏵ 3.14.099 +110010095 +2100

View full report

socket-security[bot] avatar Apr 15 '25 13:04 socket-security[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

:loudspeaker: Thoughts on this report? Let us know!

codecov[bot] avatar May 05 '25 10:05 codecov[bot]