Created
February 8, 2024 22:04
Revisions
-
Gozala created this gist
Feb 8, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ interface Account { plan: AccountPlan // ... } interface AccountPlan { customer: AccountDID request(): Plan list(): Plan[] // Verifies that plan.customer === this.customer add(terms: Terms): Plan remove(plan: Plan): {} } type Plan = Variant<{ active: ActivePlan pending: PendingPlan }> interface PendingPlan { // URL user can navigate to complete setup url: URL customer: AccountDID } interface ActivePlan extends UCAN<{ with: ServiceDID: can: "plan/*", nb: { customer: AccountDID } }> { terms: Terms // terms of service customer: AccountDID // Account that has a subscription subscription: PlanSubscription // ensures that terms.customer === this.customer update({ terms: Terms }): void } interface Terms extends UCAN<{ with: ProviderDID, nb: { customer: AccountDID } }> { price: Price provider: ProviderDID customer: AccountDID protocol: Record<Ability, Schema> } interface Price extends Record<string, number> {} interface PlanSubscription { list(): Subscription[] add(subscripton: Subscription): {} remove(subscription: Subscription): {} } interface Subscription { consumer: SpaceDID limit: Limit } interface Limit extends Record<PropertyKey, never> { }