@solana/subscriptions 0.3.0 → 0.4.0-rc.2
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 +15 -11
- package/dist/index.cjs +1082 -261
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +450 -61
- package/dist/index.d.ts +450 -61
- package/dist/index.js +1084 -245
- package/dist/index.js.map +1 -1
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @solana/subscriptions
|
|
2
2
|
|
|
3
|
-
TypeScript SDK for the [Subscriptions Solana program](https://github.com/solana-
|
|
3
|
+
TypeScript SDK for the [Subscriptions Solana program](https://github.com/solana-foundation/subscriptions): token delegation, recurring payments, and subscriptions. Ships as a [`@solana/kit`](https://github.com/anza-xyz/kit) plugin.
|
|
4
4
|
|
|
5
|
-
**Source & issues:** https://github.com/solana-
|
|
5
|
+
**Source & issues:** https://github.com/solana-foundation/subscriptions
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -52,13 +52,15 @@ For custom wallet flows, use the exported `get*OverlayInstruction*` functions. T
|
|
|
52
52
|
|
|
53
53
|
### Delegation Management
|
|
54
54
|
|
|
55
|
-
| Plugin instruction / builder
|
|
56
|
-
|
|
|
57
|
-
| `initSubscriptionAuthority` / `getInitSubscriptionAuthorityOverlayInstructionAsync`
|
|
58
|
-
| `closeSubscriptionAuthority` / `getCloseSubscriptionAuthorityOverlayInstructionAsync`
|
|
59
|
-
| `createFixedDelegation` / `getCreateFixedDelegationOverlayInstructionAsync`
|
|
60
|
-
| `createRecurringDelegation` / `getCreateRecurringDelegationOverlayInstructionAsync`
|
|
61
|
-
| `revokeDelegation` / `getRevokeDelegationOverlayInstruction`
|
|
55
|
+
| Plugin instruction / builder | Description |
|
|
56
|
+
| --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
57
|
+
| `initSubscriptionAuthority` / `getInitSubscriptionAuthorityOverlayInstructionAsync` | Set up the per-mint SubscriptionAuthority PDA and token approval |
|
|
58
|
+
| `closeSubscriptionAuthority` / `getCloseSubscriptionAuthorityOverlayInstructionAsync` | Tear down SubscriptionAuthority, invalidating all delegations (kill switch) |
|
|
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) |
|
|
62
64
|
|
|
63
65
|
### Transfers
|
|
64
66
|
|
|
@@ -93,12 +95,14 @@ For custom wallet flows, use the exported `get*OverlayInstruction*` functions. T
|
|
|
93
95
|
|
|
94
96
|
Use the generated `find*Pda` helpers directly: `findSubscriptionAuthorityPda`,
|
|
95
97
|
`findFixedDelegationPda`, `findRecurringDelegationPda`, `findSubscriptionDelegationPda`,
|
|
96
|
-
`findPlanPda`, `findEventAuthorityPda`.
|
|
98
|
+
`findPlanPda`, `findEventAuthorityPda`. They return `[address, bump]`. The first five take a
|
|
99
|
+
seeds object; `findEventAuthorityPda` takes only an optional `{ programAddress }` config (its
|
|
100
|
+
seed is the constant `"event_authority"`).
|
|
97
101
|
|
|
98
102
|
### Types
|
|
99
103
|
|
|
100
104
|
- `Delegation` - discriminated union: `{ kind: "fixed" | "recurring" | "subscription"; address; data }`. Narrow with `d.kind === '...'`.
|
|
101
|
-
- `PlanWithAddress`, `DelegationKindId` (string union)
|
|
105
|
+
- `PlanWithAddress`, `DelegationKindId` (string union); transfer input types are `TransferDelegationInput` / `TransferSubscriptionInput`
|
|
102
106
|
- Error handling: client-side `ValidationError`; on-chain errors use the generated `SUBSCRIPTIONS_ERROR__*` constants and `isSubscriptionsError` / `getSubscriptionsErrorMessage`.
|
|
103
107
|
|
|
104
108
|
## API Reference
|