@solana/subscriptions 0.4.0 → 0.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -17
- package/dist/index.cjs +832 -551
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +197 -17
- package/dist/index.d.ts +197 -17
- package/dist/index.js +811 -522
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -48,19 +48,23 @@ await client.subscriptions.instructions
|
|
|
48
48
|
|
|
49
49
|
For custom wallet flows, use the exported `get*OverlayInstruction*` functions. They return a single Kit `Instruction` or `Promise<Instruction>` that you can add to your own transaction builder.
|
|
50
50
|
|
|
51
|
+
### Sponsored (gasless) flows
|
|
52
|
+
|
|
53
|
+
Installing a distinct `payer()` alongside `identity()` makes that signer sponsor **rent**, not just fees, on every creation instruction (init-authority, create-delegation, subscribe, create-plan). Some sponsored rent is not unilaterally recoverable by the sponsor: an open `SubscriptionAuthority` closes only by the user, non-expiring delegations and perpetual subscriptions stay open indefinitely, and sponsored plan rent refunds to the merchant on delete. Prefer finite `expiryTs`/`endTs` when sponsoring, and enforce per-user and aggregate rent quotas relayer-side. To cover fees without sponsoring rent, set the instruction's `payer` to the user so rent is self-funded while `client.payer` still pays the fee.
|
|
54
|
+
|
|
51
55
|
## Capabilities
|
|
52
56
|
|
|
53
57
|
### Delegation Management
|
|
54
58
|
|
|
55
|
-
| Plugin instruction / builder | Description
|
|
56
|
-
| --------------------------------------------------------------------------------------- |
|
|
57
|
-
| `initSubscriptionAuthority` / `getInitSubscriptionAuthorityOverlayInstructionAsync` | Set up the per-mint SubscriptionAuthority PDA and token approval
|
|
58
|
-
| `closeSubscriptionAuthority` / `getCloseSubscriptionAuthorityOverlayInstructionAsync` |
|
|
59
|
-
| `createFixedDelegation` / `getCreateFixedDelegationOverlayInstructionAsync` | One-time token allowance with optional expiry
|
|
60
|
-
| `createRecurringDelegation` / `getCreateRecurringDelegationOverlayInstructionAsync` | Periodic allowance (amount per time period)
|
|
61
|
-
| `revokeDelegation` / `getRevokeDelegationOverlayInstruction` | Permanently close a fixed or recurring delegation and reclaim rent
|
|
62
|
-
| `revokeSubscription` / `getRevokeSubscriptionOverlayInstruction` | Close a subscription delegation PDA (requires `planPda`) and reclaim rent
|
|
63
|
-
| `revokeSubscriptionAuthority` / `getRevokeSubscriptionAuthorityOverlayInstructionAsync` | Revoke the per-mint SPL delegate and close the SubscriptionAuthority PDA, reclaiming rent (pass `receiver` when a sponsor funded it)
|
|
59
|
+
| Plugin instruction / builder | Description |
|
|
60
|
+
| --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
61
|
+
| `initSubscriptionAuthority` / `getInitSubscriptionAuthorityOverlayInstructionAsync` | Set up the per-mint SubscriptionAuthority PDA and token approval |
|
|
62
|
+
| `closeSubscriptionAuthority` / `getCloseSubscriptionAuthorityOverlayInstructionAsync` | Close the SubscriptionAuthority PDA and reclaim rent. Does not revoke the ATA's SPL delegate — use `revokeSubscriptionAuthority` to stop spending. A same-slot re-init reuses `init_id` and keeps existing delegations live, so this is not a kill switch. |
|
|
63
|
+
| `createFixedDelegation` / `getCreateFixedDelegationOverlayInstructionAsync` | One-time token allowance with optional expiry |
|
|
64
|
+
| `createRecurringDelegation` / `getCreateRecurringDelegationOverlayInstructionAsync` | Periodic allowance (amount per time period) |
|
|
65
|
+
| `revokeDelegation` / `getRevokeDelegationOverlayInstruction` | Permanently close a fixed or recurring delegation and reclaim rent |
|
|
66
|
+
| `revokeSubscription` / `getRevokeSubscriptionOverlayInstruction` | Close a subscription delegation PDA (requires `planPda`) and reclaim rent |
|
|
67
|
+
| `revokeSubscriptionAuthority` / `getRevokeSubscriptionAuthorityOverlayInstructionAsync` | Revoke the per-mint SPL delegate and close the SubscriptionAuthority PDA, reclaiming rent (pass `receiver` when a sponsor funded it) |
|
|
64
68
|
|
|
65
69
|
Abandoned delegation and subscription PDAs (Subscription Authority closed or re-initialized) can be closed by the recorded payer via the generated `getRevokeAbandonedDelegationInstruction` / `getRevokeAbandonedSubscriptionInstruction` builders (no overlay wrapper).
|
|
66
70
|
|
|
@@ -76,14 +80,15 @@ For Token-2022 mints with a configured transfer hook, the plugin resolves and ap
|
|
|
76
80
|
|
|
77
81
|
### Subscription Plans
|
|
78
82
|
|
|
79
|
-
| Plugin instruction / builder
|
|
80
|
-
|
|
|
81
|
-
| `createPlan` / `getCreatePlanOverlayInstructionAsync`
|
|
82
|
-
| `updatePlan` / `getUpdatePlanOverlayInstruction`
|
|
83
|
-
| `deletePlan` / `getDeletePlanOverlayInstruction`
|
|
84
|
-
| `subscribe` / `getSubscribeOverlayInstructionAsync`
|
|
85
|
-
| `cancelSubscription` / `getCancelSubscriptionOverlayInstructionAsync`
|
|
86
|
-
| `
|
|
83
|
+
| Plugin instruction / builder | Description |
|
|
84
|
+
| --------------------------------------------------------------------------- | ---------------------------------------------------------------- |
|
|
85
|
+
| `createPlan` / `getCreatePlanOverlayInstructionAsync` | Publish a subscription plan with billing terms |
|
|
86
|
+
| `updatePlan` / `getUpdatePlanOverlayInstruction` | Update plan status, end date, pullers, or metadata |
|
|
87
|
+
| `deletePlan` / `getDeletePlanOverlayInstruction` | Delete an expired plan and reclaim rent |
|
|
88
|
+
| `subscribe` / `getSubscribeOverlayInstructionAsync` | Subscribe to a plan |
|
|
89
|
+
| `cancelSubscription` / `getCancelSubscriptionOverlayInstructionAsync` | Cancel a subscription (grace period until end of billing period) |
|
|
90
|
+
| `cancelSubscriptionNow` / `getCancelSubscriptionNowOverlayInstructionAsync` | Cancel immediately with subscriber and plan-owner approval |
|
|
91
|
+
| `resumeSubscription` / `getResumeSubscriptionOverlayInstructionAsync` | Resume a cancelled subscription before revocation |
|
|
87
92
|
|
|
88
93
|
### Account Queries
|
|
89
94
|
|