@solana/subscriptions 0.0.0 → 0.1.0
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/LICENSE +9 -0
- package/README.md +117 -0
- package/dist/index.cjs +3420 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1974 -0
- package/dist/index.d.ts +1974 -0
- package/dist/index.js +3422 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -8
package/dist/index.js
ADDED
|
@@ -0,0 +1,3422 @@
|
|
|
1
|
+
// src/accounts/decode.ts
|
|
2
|
+
import { getBase64Encoder } from "@solana/kit";
|
|
3
|
+
|
|
4
|
+
// src/generated/accounts/eventAuthority.ts
|
|
5
|
+
import {
|
|
6
|
+
assertAccountExists,
|
|
7
|
+
assertAccountsExist,
|
|
8
|
+
combineCodec,
|
|
9
|
+
decodeAccount,
|
|
10
|
+
fetchEncodedAccount,
|
|
11
|
+
fetchEncodedAccounts,
|
|
12
|
+
getStructDecoder,
|
|
13
|
+
getStructEncoder
|
|
14
|
+
} from "@solana/kit";
|
|
15
|
+
|
|
16
|
+
// src/generated/pdas/eventAuthority.ts
|
|
17
|
+
import { getProgramDerivedAddress, getUtf8Encoder } from "@solana/kit";
|
|
18
|
+
async function findEventAuthorityPda(config = {}) {
|
|
19
|
+
const {
|
|
20
|
+
programAddress = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44"
|
|
21
|
+
} = config;
|
|
22
|
+
return await getProgramDerivedAddress({ programAddress, seeds: [getUtf8Encoder().encode("event_authority")] });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/generated/pdas/fixedDelegation.ts
|
|
26
|
+
import {
|
|
27
|
+
getAddressEncoder,
|
|
28
|
+
getProgramDerivedAddress as getProgramDerivedAddress2,
|
|
29
|
+
getU64Encoder,
|
|
30
|
+
getUtf8Encoder as getUtf8Encoder2
|
|
31
|
+
} from "@solana/kit";
|
|
32
|
+
async function findFixedDelegationPda(seeds, config = {}) {
|
|
33
|
+
const {
|
|
34
|
+
programAddress = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44"
|
|
35
|
+
} = config;
|
|
36
|
+
return await getProgramDerivedAddress2({
|
|
37
|
+
programAddress,
|
|
38
|
+
seeds: [
|
|
39
|
+
getUtf8Encoder2().encode("delegation"),
|
|
40
|
+
getAddressEncoder().encode(seeds.subscriptionAuthority),
|
|
41
|
+
getAddressEncoder().encode(seeds.delegator),
|
|
42
|
+
getAddressEncoder().encode(seeds.delegatee),
|
|
43
|
+
getU64Encoder().encode(seeds.nonce)
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/generated/pdas/plan.ts
|
|
49
|
+
import {
|
|
50
|
+
getAddressEncoder as getAddressEncoder2,
|
|
51
|
+
getProgramDerivedAddress as getProgramDerivedAddress3,
|
|
52
|
+
getU64Encoder as getU64Encoder2,
|
|
53
|
+
getUtf8Encoder as getUtf8Encoder3
|
|
54
|
+
} from "@solana/kit";
|
|
55
|
+
async function findPlanPda(seeds, config = {}) {
|
|
56
|
+
const {
|
|
57
|
+
programAddress = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44"
|
|
58
|
+
} = config;
|
|
59
|
+
return await getProgramDerivedAddress3({
|
|
60
|
+
programAddress,
|
|
61
|
+
seeds: [
|
|
62
|
+
getUtf8Encoder3().encode("plan"),
|
|
63
|
+
getAddressEncoder2().encode(seeds.owner),
|
|
64
|
+
getU64Encoder2().encode(seeds.planId)
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/generated/pdas/recurringDelegation.ts
|
|
70
|
+
import {
|
|
71
|
+
getAddressEncoder as getAddressEncoder3,
|
|
72
|
+
getProgramDerivedAddress as getProgramDerivedAddress4,
|
|
73
|
+
getU64Encoder as getU64Encoder3,
|
|
74
|
+
getUtf8Encoder as getUtf8Encoder4
|
|
75
|
+
} from "@solana/kit";
|
|
76
|
+
async function findRecurringDelegationPda(seeds, config = {}) {
|
|
77
|
+
const {
|
|
78
|
+
programAddress = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44"
|
|
79
|
+
} = config;
|
|
80
|
+
return await getProgramDerivedAddress4({
|
|
81
|
+
programAddress,
|
|
82
|
+
seeds: [
|
|
83
|
+
getUtf8Encoder4().encode("delegation"),
|
|
84
|
+
getAddressEncoder3().encode(seeds.subscriptionAuthority),
|
|
85
|
+
getAddressEncoder3().encode(seeds.delegator),
|
|
86
|
+
getAddressEncoder3().encode(seeds.delegatee),
|
|
87
|
+
getU64Encoder3().encode(seeds.nonce)
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/generated/pdas/subscriptionAuthority.ts
|
|
93
|
+
import {
|
|
94
|
+
getAddressEncoder as getAddressEncoder4,
|
|
95
|
+
getProgramDerivedAddress as getProgramDerivedAddress5,
|
|
96
|
+
getUtf8Encoder as getUtf8Encoder5
|
|
97
|
+
} from "@solana/kit";
|
|
98
|
+
async function findSubscriptionAuthorityPda(seeds, config = {}) {
|
|
99
|
+
const {
|
|
100
|
+
programAddress = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44"
|
|
101
|
+
} = config;
|
|
102
|
+
return await getProgramDerivedAddress5({
|
|
103
|
+
programAddress,
|
|
104
|
+
seeds: [
|
|
105
|
+
getUtf8Encoder5().encode("SubscriptionAuthority"),
|
|
106
|
+
getAddressEncoder4().encode(seeds.user),
|
|
107
|
+
getAddressEncoder4().encode(seeds.tokenMint)
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/generated/pdas/subscriptionDelegation.ts
|
|
113
|
+
import {
|
|
114
|
+
getAddressEncoder as getAddressEncoder5,
|
|
115
|
+
getProgramDerivedAddress as getProgramDerivedAddress6,
|
|
116
|
+
getUtf8Encoder as getUtf8Encoder6
|
|
117
|
+
} from "@solana/kit";
|
|
118
|
+
async function findSubscriptionDelegationPda(seeds, config = {}) {
|
|
119
|
+
const {
|
|
120
|
+
programAddress = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44"
|
|
121
|
+
} = config;
|
|
122
|
+
return await getProgramDerivedAddress6({
|
|
123
|
+
programAddress,
|
|
124
|
+
seeds: [
|
|
125
|
+
getUtf8Encoder6().encode("subscription"),
|
|
126
|
+
getAddressEncoder5().encode(seeds.planPda),
|
|
127
|
+
getAddressEncoder5().encode(seeds.subscriber)
|
|
128
|
+
]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/generated/accounts/eventAuthority.ts
|
|
133
|
+
function getEventAuthorityEncoder() {
|
|
134
|
+
return getStructEncoder([]);
|
|
135
|
+
}
|
|
136
|
+
function getEventAuthorityDecoder() {
|
|
137
|
+
return getStructDecoder([]);
|
|
138
|
+
}
|
|
139
|
+
function getEventAuthorityCodec() {
|
|
140
|
+
return combineCodec(getEventAuthorityEncoder(), getEventAuthorityDecoder());
|
|
141
|
+
}
|
|
142
|
+
function decodeEventAuthority(encodedAccount) {
|
|
143
|
+
return decodeAccount(encodedAccount, getEventAuthorityDecoder());
|
|
144
|
+
}
|
|
145
|
+
async function fetchEventAuthority(rpc, address, config) {
|
|
146
|
+
const maybeAccount = await fetchMaybeEventAuthority(rpc, address, config);
|
|
147
|
+
assertAccountExists(maybeAccount);
|
|
148
|
+
return maybeAccount;
|
|
149
|
+
}
|
|
150
|
+
async function fetchMaybeEventAuthority(rpc, address, config) {
|
|
151
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
152
|
+
return decodeEventAuthority(maybeAccount);
|
|
153
|
+
}
|
|
154
|
+
async function fetchAllEventAuthority(rpc, addresses, config) {
|
|
155
|
+
const maybeAccounts = await fetchAllMaybeEventAuthority(rpc, addresses, config);
|
|
156
|
+
assertAccountsExist(maybeAccounts);
|
|
157
|
+
return maybeAccounts;
|
|
158
|
+
}
|
|
159
|
+
async function fetchAllMaybeEventAuthority(rpc, addresses, config) {
|
|
160
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
161
|
+
return maybeAccounts.map((maybeAccount) => decodeEventAuthority(maybeAccount));
|
|
162
|
+
}
|
|
163
|
+
async function fetchEventAuthorityFromSeeds(rpc, config = {}) {
|
|
164
|
+
const maybeAccount = await fetchMaybeEventAuthorityFromSeeds(rpc, config);
|
|
165
|
+
assertAccountExists(maybeAccount);
|
|
166
|
+
return maybeAccount;
|
|
167
|
+
}
|
|
168
|
+
async function fetchMaybeEventAuthorityFromSeeds(rpc, config = {}) {
|
|
169
|
+
const { programAddress, ...fetchConfig } = config;
|
|
170
|
+
const [address] = await findEventAuthorityPda({ programAddress });
|
|
171
|
+
return await fetchMaybeEventAuthority(rpc, address, fetchConfig);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/generated/accounts/fixedDelegation.ts
|
|
175
|
+
import {
|
|
176
|
+
assertAccountExists as assertAccountExists2,
|
|
177
|
+
assertAccountsExist as assertAccountsExist2,
|
|
178
|
+
combineCodec as combineCodec12,
|
|
179
|
+
decodeAccount as decodeAccount2,
|
|
180
|
+
fetchEncodedAccount as fetchEncodedAccount2,
|
|
181
|
+
fetchEncodedAccounts as fetchEncodedAccounts2,
|
|
182
|
+
getAddressDecoder as getAddressDecoder6,
|
|
183
|
+
getAddressEncoder as getAddressEncoder11,
|
|
184
|
+
getI64Decoder as getI64Decoder8,
|
|
185
|
+
getI64Encoder as getI64Encoder8,
|
|
186
|
+
getStructDecoder as getStructDecoder10,
|
|
187
|
+
getStructEncoder as getStructEncoder10,
|
|
188
|
+
getU64Decoder as getU64Decoder7,
|
|
189
|
+
getU64Encoder as getU64Encoder10
|
|
190
|
+
} from "@solana/kit";
|
|
191
|
+
|
|
192
|
+
// src/generated/types/accountDiscriminator.ts
|
|
193
|
+
import {
|
|
194
|
+
combineCodec as combineCodec2,
|
|
195
|
+
getEnumDecoder,
|
|
196
|
+
getEnumEncoder
|
|
197
|
+
} from "@solana/kit";
|
|
198
|
+
var AccountDiscriminator = /* @__PURE__ */ ((AccountDiscriminator2) => {
|
|
199
|
+
AccountDiscriminator2[AccountDiscriminator2["SubscriptionAuthority"] = 0] = "SubscriptionAuthority";
|
|
200
|
+
AccountDiscriminator2[AccountDiscriminator2["Plan"] = 1] = "Plan";
|
|
201
|
+
AccountDiscriminator2[AccountDiscriminator2["FixedDelegation"] = 2] = "FixedDelegation";
|
|
202
|
+
AccountDiscriminator2[AccountDiscriminator2["RecurringDelegation"] = 3] = "RecurringDelegation";
|
|
203
|
+
AccountDiscriminator2[AccountDiscriminator2["SubscriptionDelegation"] = 4] = "SubscriptionDelegation";
|
|
204
|
+
return AccountDiscriminator2;
|
|
205
|
+
})(AccountDiscriminator || {});
|
|
206
|
+
function getAccountDiscriminatorEncoder() {
|
|
207
|
+
return getEnumEncoder(AccountDiscriminator);
|
|
208
|
+
}
|
|
209
|
+
function getAccountDiscriminatorDecoder() {
|
|
210
|
+
return getEnumDecoder(AccountDiscriminator);
|
|
211
|
+
}
|
|
212
|
+
function getAccountDiscriminatorCodec() {
|
|
213
|
+
return combineCodec2(getAccountDiscriminatorEncoder(), getAccountDiscriminatorDecoder());
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// src/generated/types/createFixedDelegationData.ts
|
|
217
|
+
import {
|
|
218
|
+
combineCodec as combineCodec3,
|
|
219
|
+
getI64Decoder,
|
|
220
|
+
getI64Encoder,
|
|
221
|
+
getStructDecoder as getStructDecoder2,
|
|
222
|
+
getStructEncoder as getStructEncoder2,
|
|
223
|
+
getU64Decoder,
|
|
224
|
+
getU64Encoder as getU64Encoder4
|
|
225
|
+
} from "@solana/kit";
|
|
226
|
+
function getCreateFixedDelegationDataEncoder() {
|
|
227
|
+
return getStructEncoder2([
|
|
228
|
+
["nonce", getU64Encoder4()],
|
|
229
|
+
["amount", getU64Encoder4()],
|
|
230
|
+
["expiryTs", getI64Encoder()]
|
|
231
|
+
]);
|
|
232
|
+
}
|
|
233
|
+
function getCreateFixedDelegationDataDecoder() {
|
|
234
|
+
return getStructDecoder2([
|
|
235
|
+
["nonce", getU64Decoder()],
|
|
236
|
+
["amount", getU64Decoder()],
|
|
237
|
+
["expiryTs", getI64Decoder()]
|
|
238
|
+
]);
|
|
239
|
+
}
|
|
240
|
+
function getCreateFixedDelegationDataCodec() {
|
|
241
|
+
return combineCodec3(getCreateFixedDelegationDataEncoder(), getCreateFixedDelegationDataDecoder());
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// src/generated/types/createRecurringDelegationData.ts
|
|
245
|
+
import {
|
|
246
|
+
combineCodec as combineCodec4,
|
|
247
|
+
getI64Decoder as getI64Decoder2,
|
|
248
|
+
getI64Encoder as getI64Encoder2,
|
|
249
|
+
getStructDecoder as getStructDecoder3,
|
|
250
|
+
getStructEncoder as getStructEncoder3,
|
|
251
|
+
getU64Decoder as getU64Decoder2,
|
|
252
|
+
getU64Encoder as getU64Encoder5
|
|
253
|
+
} from "@solana/kit";
|
|
254
|
+
function getCreateRecurringDelegationDataEncoder() {
|
|
255
|
+
return getStructEncoder3([
|
|
256
|
+
["nonce", getU64Encoder5()],
|
|
257
|
+
["amountPerPeriod", getU64Encoder5()],
|
|
258
|
+
["periodLengthS", getU64Encoder5()],
|
|
259
|
+
["startTs", getI64Encoder2()],
|
|
260
|
+
["expiryTs", getI64Encoder2()]
|
|
261
|
+
]);
|
|
262
|
+
}
|
|
263
|
+
function getCreateRecurringDelegationDataDecoder() {
|
|
264
|
+
return getStructDecoder3([
|
|
265
|
+
["nonce", getU64Decoder2()],
|
|
266
|
+
["amountPerPeriod", getU64Decoder2()],
|
|
267
|
+
["periodLengthS", getU64Decoder2()],
|
|
268
|
+
["startTs", getI64Decoder2()],
|
|
269
|
+
["expiryTs", getI64Decoder2()]
|
|
270
|
+
]);
|
|
271
|
+
}
|
|
272
|
+
function getCreateRecurringDelegationDataCodec() {
|
|
273
|
+
return combineCodec4(getCreateRecurringDelegationDataEncoder(), getCreateRecurringDelegationDataDecoder());
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// src/generated/types/header.ts
|
|
277
|
+
import {
|
|
278
|
+
combineCodec as combineCodec5,
|
|
279
|
+
getAddressDecoder,
|
|
280
|
+
getAddressEncoder as getAddressEncoder6,
|
|
281
|
+
getI64Decoder as getI64Decoder3,
|
|
282
|
+
getI64Encoder as getI64Encoder3,
|
|
283
|
+
getStructDecoder as getStructDecoder4,
|
|
284
|
+
getStructEncoder as getStructEncoder4,
|
|
285
|
+
getU8Decoder,
|
|
286
|
+
getU8Encoder
|
|
287
|
+
} from "@solana/kit";
|
|
288
|
+
function getHeaderEncoder() {
|
|
289
|
+
return getStructEncoder4([
|
|
290
|
+
["discriminator", getU8Encoder()],
|
|
291
|
+
["version", getU8Encoder()],
|
|
292
|
+
["bump", getU8Encoder()],
|
|
293
|
+
["delegator", getAddressEncoder6()],
|
|
294
|
+
["delegatee", getAddressEncoder6()],
|
|
295
|
+
["payer", getAddressEncoder6()],
|
|
296
|
+
["initId", getI64Encoder3()]
|
|
297
|
+
]);
|
|
298
|
+
}
|
|
299
|
+
function getHeaderDecoder() {
|
|
300
|
+
return getStructDecoder4([
|
|
301
|
+
["discriminator", getU8Decoder()],
|
|
302
|
+
["version", getU8Decoder()],
|
|
303
|
+
["bump", getU8Decoder()],
|
|
304
|
+
["delegator", getAddressDecoder()],
|
|
305
|
+
["delegatee", getAddressDecoder()],
|
|
306
|
+
["payer", getAddressDecoder()],
|
|
307
|
+
["initId", getI64Decoder3()]
|
|
308
|
+
]);
|
|
309
|
+
}
|
|
310
|
+
function getHeaderCodec() {
|
|
311
|
+
return combineCodec5(getHeaderEncoder(), getHeaderDecoder());
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// src/generated/types/planData.ts
|
|
315
|
+
import {
|
|
316
|
+
combineCodec as combineCodec6,
|
|
317
|
+
fixDecoderSize,
|
|
318
|
+
fixEncoderSize,
|
|
319
|
+
getAddressDecoder as getAddressDecoder2,
|
|
320
|
+
getAddressEncoder as getAddressEncoder7,
|
|
321
|
+
getArrayDecoder,
|
|
322
|
+
getArrayEncoder,
|
|
323
|
+
getI64Decoder as getI64Decoder4,
|
|
324
|
+
getI64Encoder as getI64Encoder4,
|
|
325
|
+
getStructDecoder as getStructDecoder5,
|
|
326
|
+
getStructEncoder as getStructEncoder5,
|
|
327
|
+
getU64Decoder as getU64Decoder3,
|
|
328
|
+
getU64Encoder as getU64Encoder6,
|
|
329
|
+
getUtf8Decoder,
|
|
330
|
+
getUtf8Encoder as getUtf8Encoder7
|
|
331
|
+
} from "@solana/kit";
|
|
332
|
+
function getPlanDataEncoder() {
|
|
333
|
+
return getStructEncoder5([
|
|
334
|
+
["planId", getU64Encoder6()],
|
|
335
|
+
["mint", getAddressEncoder7()],
|
|
336
|
+
["terms", getPlanTermsEncoder()],
|
|
337
|
+
["endTs", getI64Encoder4()],
|
|
338
|
+
["destinations", getArrayEncoder(getAddressEncoder7(), { size: 4 })],
|
|
339
|
+
["pullers", getArrayEncoder(getAddressEncoder7(), { size: 4 })],
|
|
340
|
+
["metadataUri", fixEncoderSize(getUtf8Encoder7(), 128)]
|
|
341
|
+
]);
|
|
342
|
+
}
|
|
343
|
+
function getPlanDataDecoder() {
|
|
344
|
+
return getStructDecoder5([
|
|
345
|
+
["planId", getU64Decoder3()],
|
|
346
|
+
["mint", getAddressDecoder2()],
|
|
347
|
+
["terms", getPlanTermsDecoder()],
|
|
348
|
+
["endTs", getI64Decoder4()],
|
|
349
|
+
["destinations", getArrayDecoder(getAddressDecoder2(), { size: 4 })],
|
|
350
|
+
["pullers", getArrayDecoder(getAddressDecoder2(), { size: 4 })],
|
|
351
|
+
["metadataUri", fixDecoderSize(getUtf8Decoder(), 128)]
|
|
352
|
+
]);
|
|
353
|
+
}
|
|
354
|
+
function getPlanDataCodec() {
|
|
355
|
+
return combineCodec6(getPlanDataEncoder(), getPlanDataDecoder());
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// src/generated/types/planStatus.ts
|
|
359
|
+
import {
|
|
360
|
+
combineCodec as combineCodec7,
|
|
361
|
+
getEnumDecoder as getEnumDecoder2,
|
|
362
|
+
getEnumEncoder as getEnumEncoder2
|
|
363
|
+
} from "@solana/kit";
|
|
364
|
+
var PlanStatus = /* @__PURE__ */ ((PlanStatus2) => {
|
|
365
|
+
PlanStatus2[PlanStatus2["Sunset"] = 0] = "Sunset";
|
|
366
|
+
PlanStatus2[PlanStatus2["Active"] = 1] = "Active";
|
|
367
|
+
return PlanStatus2;
|
|
368
|
+
})(PlanStatus || {});
|
|
369
|
+
function getPlanStatusEncoder() {
|
|
370
|
+
return getEnumEncoder2(PlanStatus);
|
|
371
|
+
}
|
|
372
|
+
function getPlanStatusDecoder() {
|
|
373
|
+
return getEnumDecoder2(PlanStatus);
|
|
374
|
+
}
|
|
375
|
+
function getPlanStatusCodec() {
|
|
376
|
+
return combineCodec7(getPlanStatusEncoder(), getPlanStatusDecoder());
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/generated/types/planTerms.ts
|
|
380
|
+
import {
|
|
381
|
+
combineCodec as combineCodec8,
|
|
382
|
+
getI64Decoder as getI64Decoder5,
|
|
383
|
+
getI64Encoder as getI64Encoder5,
|
|
384
|
+
getStructDecoder as getStructDecoder6,
|
|
385
|
+
getStructEncoder as getStructEncoder6,
|
|
386
|
+
getU64Decoder as getU64Decoder4,
|
|
387
|
+
getU64Encoder as getU64Encoder7
|
|
388
|
+
} from "@solana/kit";
|
|
389
|
+
function getPlanTermsEncoder() {
|
|
390
|
+
return getStructEncoder6([
|
|
391
|
+
["amount", getU64Encoder7()],
|
|
392
|
+
["periodHours", getU64Encoder7()],
|
|
393
|
+
["createdAt", getI64Encoder5()]
|
|
394
|
+
]);
|
|
395
|
+
}
|
|
396
|
+
function getPlanTermsDecoder() {
|
|
397
|
+
return getStructDecoder6([
|
|
398
|
+
["amount", getU64Decoder4()],
|
|
399
|
+
["periodHours", getU64Decoder4()],
|
|
400
|
+
["createdAt", getI64Decoder5()]
|
|
401
|
+
]);
|
|
402
|
+
}
|
|
403
|
+
function getPlanTermsCodec() {
|
|
404
|
+
return combineCodec8(getPlanTermsEncoder(), getPlanTermsDecoder());
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// src/generated/types/subscribeData.ts
|
|
408
|
+
import {
|
|
409
|
+
combineCodec as combineCodec9,
|
|
410
|
+
getAddressDecoder as getAddressDecoder3,
|
|
411
|
+
getAddressEncoder as getAddressEncoder8,
|
|
412
|
+
getI64Decoder as getI64Decoder6,
|
|
413
|
+
getI64Encoder as getI64Encoder6,
|
|
414
|
+
getStructDecoder as getStructDecoder7,
|
|
415
|
+
getStructEncoder as getStructEncoder7,
|
|
416
|
+
getU64Decoder as getU64Decoder5,
|
|
417
|
+
getU64Encoder as getU64Encoder8,
|
|
418
|
+
getU8Decoder as getU8Decoder2,
|
|
419
|
+
getU8Encoder as getU8Encoder2
|
|
420
|
+
} from "@solana/kit";
|
|
421
|
+
function getSubscribeDataEncoder() {
|
|
422
|
+
return getStructEncoder7([
|
|
423
|
+
["planId", getU64Encoder8()],
|
|
424
|
+
["planBump", getU8Encoder2()],
|
|
425
|
+
["expectedMint", getAddressEncoder8()],
|
|
426
|
+
["expectedAmount", getU64Encoder8()],
|
|
427
|
+
["expectedPeriodHours", getU64Encoder8()],
|
|
428
|
+
["expectedCreatedAt", getI64Encoder6()]
|
|
429
|
+
]);
|
|
430
|
+
}
|
|
431
|
+
function getSubscribeDataDecoder() {
|
|
432
|
+
return getStructDecoder7([
|
|
433
|
+
["planId", getU64Decoder5()],
|
|
434
|
+
["planBump", getU8Decoder2()],
|
|
435
|
+
["expectedMint", getAddressDecoder3()],
|
|
436
|
+
["expectedAmount", getU64Decoder5()],
|
|
437
|
+
["expectedPeriodHours", getU64Decoder5()],
|
|
438
|
+
["expectedCreatedAt", getI64Decoder6()]
|
|
439
|
+
]);
|
|
440
|
+
}
|
|
441
|
+
function getSubscribeDataCodec() {
|
|
442
|
+
return combineCodec9(getSubscribeDataEncoder(), getSubscribeDataDecoder());
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// src/generated/types/transferData.ts
|
|
446
|
+
import {
|
|
447
|
+
combineCodec as combineCodec10,
|
|
448
|
+
getAddressDecoder as getAddressDecoder4,
|
|
449
|
+
getAddressEncoder as getAddressEncoder9,
|
|
450
|
+
getStructDecoder as getStructDecoder8,
|
|
451
|
+
getStructEncoder as getStructEncoder8,
|
|
452
|
+
getU64Decoder as getU64Decoder6,
|
|
453
|
+
getU64Encoder as getU64Encoder9
|
|
454
|
+
} from "@solana/kit";
|
|
455
|
+
function getTransferDataEncoder() {
|
|
456
|
+
return getStructEncoder8([
|
|
457
|
+
["amount", getU64Encoder9()],
|
|
458
|
+
["delegator", getAddressEncoder9()],
|
|
459
|
+
["mint", getAddressEncoder9()]
|
|
460
|
+
]);
|
|
461
|
+
}
|
|
462
|
+
function getTransferDataDecoder() {
|
|
463
|
+
return getStructDecoder8([
|
|
464
|
+
["amount", getU64Decoder6()],
|
|
465
|
+
["delegator", getAddressDecoder4()],
|
|
466
|
+
["mint", getAddressDecoder4()]
|
|
467
|
+
]);
|
|
468
|
+
}
|
|
469
|
+
function getTransferDataCodec() {
|
|
470
|
+
return combineCodec10(getTransferDataEncoder(), getTransferDataDecoder());
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// src/generated/types/updatePlanData.ts
|
|
474
|
+
import {
|
|
475
|
+
combineCodec as combineCodec11,
|
|
476
|
+
fixDecoderSize as fixDecoderSize2,
|
|
477
|
+
fixEncoderSize as fixEncoderSize2,
|
|
478
|
+
getAddressDecoder as getAddressDecoder5,
|
|
479
|
+
getAddressEncoder as getAddressEncoder10,
|
|
480
|
+
getArrayDecoder as getArrayDecoder2,
|
|
481
|
+
getArrayEncoder as getArrayEncoder2,
|
|
482
|
+
getI64Decoder as getI64Decoder7,
|
|
483
|
+
getI64Encoder as getI64Encoder7,
|
|
484
|
+
getStructDecoder as getStructDecoder9,
|
|
485
|
+
getStructEncoder as getStructEncoder9,
|
|
486
|
+
getU8Decoder as getU8Decoder3,
|
|
487
|
+
getU8Encoder as getU8Encoder3,
|
|
488
|
+
getUtf8Decoder as getUtf8Decoder2,
|
|
489
|
+
getUtf8Encoder as getUtf8Encoder8
|
|
490
|
+
} from "@solana/kit";
|
|
491
|
+
function getUpdatePlanDataEncoder() {
|
|
492
|
+
return getStructEncoder9([
|
|
493
|
+
["status", getU8Encoder3()],
|
|
494
|
+
["endTs", getI64Encoder7()],
|
|
495
|
+
["pullers", getArrayEncoder2(getAddressEncoder10(), { size: 4 })],
|
|
496
|
+
["metadataUri", fixEncoderSize2(getUtf8Encoder8(), 128)]
|
|
497
|
+
]);
|
|
498
|
+
}
|
|
499
|
+
function getUpdatePlanDataDecoder() {
|
|
500
|
+
return getStructDecoder9([
|
|
501
|
+
["status", getU8Decoder3()],
|
|
502
|
+
["endTs", getI64Decoder7()],
|
|
503
|
+
["pullers", getArrayDecoder2(getAddressDecoder5(), { size: 4 })],
|
|
504
|
+
["metadataUri", fixDecoderSize2(getUtf8Decoder2(), 128)]
|
|
505
|
+
]);
|
|
506
|
+
}
|
|
507
|
+
function getUpdatePlanDataCodec() {
|
|
508
|
+
return combineCodec11(getUpdatePlanDataEncoder(), getUpdatePlanDataDecoder());
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// src/generated/accounts/fixedDelegation.ts
|
|
512
|
+
function getFixedDelegationEncoder() {
|
|
513
|
+
return getStructEncoder10([
|
|
514
|
+
["header", getHeaderEncoder()],
|
|
515
|
+
["subscriptionAuthority", getAddressEncoder11()],
|
|
516
|
+
["mint", getAddressEncoder11()],
|
|
517
|
+
["amount", getU64Encoder10()],
|
|
518
|
+
["expiryTs", getI64Encoder8()]
|
|
519
|
+
]);
|
|
520
|
+
}
|
|
521
|
+
function getFixedDelegationDecoder() {
|
|
522
|
+
return getStructDecoder10([
|
|
523
|
+
["header", getHeaderDecoder()],
|
|
524
|
+
["subscriptionAuthority", getAddressDecoder6()],
|
|
525
|
+
["mint", getAddressDecoder6()],
|
|
526
|
+
["amount", getU64Decoder7()],
|
|
527
|
+
["expiryTs", getI64Decoder8()]
|
|
528
|
+
]);
|
|
529
|
+
}
|
|
530
|
+
function getFixedDelegationCodec() {
|
|
531
|
+
return combineCodec12(getFixedDelegationEncoder(), getFixedDelegationDecoder());
|
|
532
|
+
}
|
|
533
|
+
function decodeFixedDelegation(encodedAccount) {
|
|
534
|
+
return decodeAccount2(encodedAccount, getFixedDelegationDecoder());
|
|
535
|
+
}
|
|
536
|
+
async function fetchFixedDelegation(rpc, address, config) {
|
|
537
|
+
const maybeAccount = await fetchMaybeFixedDelegation(rpc, address, config);
|
|
538
|
+
assertAccountExists2(maybeAccount);
|
|
539
|
+
return maybeAccount;
|
|
540
|
+
}
|
|
541
|
+
async function fetchMaybeFixedDelegation(rpc, address, config) {
|
|
542
|
+
const maybeAccount = await fetchEncodedAccount2(rpc, address, config);
|
|
543
|
+
return decodeFixedDelegation(maybeAccount);
|
|
544
|
+
}
|
|
545
|
+
async function fetchAllFixedDelegation(rpc, addresses, config) {
|
|
546
|
+
const maybeAccounts = await fetchAllMaybeFixedDelegation(rpc, addresses, config);
|
|
547
|
+
assertAccountsExist2(maybeAccounts);
|
|
548
|
+
return maybeAccounts;
|
|
549
|
+
}
|
|
550
|
+
async function fetchAllMaybeFixedDelegation(rpc, addresses, config) {
|
|
551
|
+
const maybeAccounts = await fetchEncodedAccounts2(rpc, addresses, config);
|
|
552
|
+
return maybeAccounts.map((maybeAccount) => decodeFixedDelegation(maybeAccount));
|
|
553
|
+
}
|
|
554
|
+
async function fetchFixedDelegationFromSeeds(rpc, seeds, config = {}) {
|
|
555
|
+
const maybeAccount = await fetchMaybeFixedDelegationFromSeeds(rpc, seeds, config);
|
|
556
|
+
assertAccountExists2(maybeAccount);
|
|
557
|
+
return maybeAccount;
|
|
558
|
+
}
|
|
559
|
+
async function fetchMaybeFixedDelegationFromSeeds(rpc, seeds, config = {}) {
|
|
560
|
+
const { programAddress, ...fetchConfig } = config;
|
|
561
|
+
const [address] = await findFixedDelegationPda(seeds, { programAddress });
|
|
562
|
+
return await fetchMaybeFixedDelegation(rpc, address, fetchConfig);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// src/generated/accounts/plan.ts
|
|
566
|
+
import {
|
|
567
|
+
assertAccountExists as assertAccountExists3,
|
|
568
|
+
assertAccountsExist as assertAccountsExist3,
|
|
569
|
+
combineCodec as combineCodec13,
|
|
570
|
+
decodeAccount as decodeAccount3,
|
|
571
|
+
fetchEncodedAccount as fetchEncodedAccount3,
|
|
572
|
+
fetchEncodedAccounts as fetchEncodedAccounts3,
|
|
573
|
+
getAddressDecoder as getAddressDecoder7,
|
|
574
|
+
getAddressEncoder as getAddressEncoder12,
|
|
575
|
+
getStructDecoder as getStructDecoder11,
|
|
576
|
+
getStructEncoder as getStructEncoder11,
|
|
577
|
+
getU8Decoder as getU8Decoder4,
|
|
578
|
+
getU8Encoder as getU8Encoder4
|
|
579
|
+
} from "@solana/kit";
|
|
580
|
+
function getPlanEncoder() {
|
|
581
|
+
return getStructEncoder11([
|
|
582
|
+
["discriminator", getU8Encoder4()],
|
|
583
|
+
["owner", getAddressEncoder12()],
|
|
584
|
+
["bump", getU8Encoder4()],
|
|
585
|
+
["status", getU8Encoder4()],
|
|
586
|
+
["data", getPlanDataEncoder()]
|
|
587
|
+
]);
|
|
588
|
+
}
|
|
589
|
+
function getPlanDecoder() {
|
|
590
|
+
return getStructDecoder11([
|
|
591
|
+
["discriminator", getU8Decoder4()],
|
|
592
|
+
["owner", getAddressDecoder7()],
|
|
593
|
+
["bump", getU8Decoder4()],
|
|
594
|
+
["status", getU8Decoder4()],
|
|
595
|
+
["data", getPlanDataDecoder()]
|
|
596
|
+
]);
|
|
597
|
+
}
|
|
598
|
+
function getPlanCodec() {
|
|
599
|
+
return combineCodec13(getPlanEncoder(), getPlanDecoder());
|
|
600
|
+
}
|
|
601
|
+
function decodePlan(encodedAccount) {
|
|
602
|
+
return decodeAccount3(encodedAccount, getPlanDecoder());
|
|
603
|
+
}
|
|
604
|
+
async function fetchPlan(rpc, address, config) {
|
|
605
|
+
const maybeAccount = await fetchMaybePlan(rpc, address, config);
|
|
606
|
+
assertAccountExists3(maybeAccount);
|
|
607
|
+
return maybeAccount;
|
|
608
|
+
}
|
|
609
|
+
async function fetchMaybePlan(rpc, address, config) {
|
|
610
|
+
const maybeAccount = await fetchEncodedAccount3(rpc, address, config);
|
|
611
|
+
return decodePlan(maybeAccount);
|
|
612
|
+
}
|
|
613
|
+
async function fetchAllPlan(rpc, addresses, config) {
|
|
614
|
+
const maybeAccounts = await fetchAllMaybePlan(rpc, addresses, config);
|
|
615
|
+
assertAccountsExist3(maybeAccounts);
|
|
616
|
+
return maybeAccounts;
|
|
617
|
+
}
|
|
618
|
+
async function fetchAllMaybePlan(rpc, addresses, config) {
|
|
619
|
+
const maybeAccounts = await fetchEncodedAccounts3(rpc, addresses, config);
|
|
620
|
+
return maybeAccounts.map((maybeAccount) => decodePlan(maybeAccount));
|
|
621
|
+
}
|
|
622
|
+
async function fetchPlanFromSeeds(rpc, seeds, config = {}) {
|
|
623
|
+
const maybeAccount = await fetchMaybePlanFromSeeds(rpc, seeds, config);
|
|
624
|
+
assertAccountExists3(maybeAccount);
|
|
625
|
+
return maybeAccount;
|
|
626
|
+
}
|
|
627
|
+
async function fetchMaybePlanFromSeeds(rpc, seeds, config = {}) {
|
|
628
|
+
const { programAddress, ...fetchConfig } = config;
|
|
629
|
+
const [address] = await findPlanPda(seeds, { programAddress });
|
|
630
|
+
return await fetchMaybePlan(rpc, address, fetchConfig);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// src/generated/accounts/recurringDelegation.ts
|
|
634
|
+
import {
|
|
635
|
+
assertAccountExists as assertAccountExists4,
|
|
636
|
+
assertAccountsExist as assertAccountsExist4,
|
|
637
|
+
combineCodec as combineCodec14,
|
|
638
|
+
decodeAccount as decodeAccount4,
|
|
639
|
+
fetchEncodedAccount as fetchEncodedAccount4,
|
|
640
|
+
fetchEncodedAccounts as fetchEncodedAccounts4,
|
|
641
|
+
getAddressDecoder as getAddressDecoder8,
|
|
642
|
+
getAddressEncoder as getAddressEncoder13,
|
|
643
|
+
getI64Decoder as getI64Decoder9,
|
|
644
|
+
getI64Encoder as getI64Encoder9,
|
|
645
|
+
getStructDecoder as getStructDecoder12,
|
|
646
|
+
getStructEncoder as getStructEncoder12,
|
|
647
|
+
getU64Decoder as getU64Decoder8,
|
|
648
|
+
getU64Encoder as getU64Encoder11
|
|
649
|
+
} from "@solana/kit";
|
|
650
|
+
function getRecurringDelegationEncoder() {
|
|
651
|
+
return getStructEncoder12([
|
|
652
|
+
["header", getHeaderEncoder()],
|
|
653
|
+
["subscriptionAuthority", getAddressEncoder13()],
|
|
654
|
+
["mint", getAddressEncoder13()],
|
|
655
|
+
["currentPeriodStartTs", getI64Encoder9()],
|
|
656
|
+
["periodLengthS", getU64Encoder11()],
|
|
657
|
+
["expiryTs", getI64Encoder9()],
|
|
658
|
+
["amountPerPeriod", getU64Encoder11()],
|
|
659
|
+
["amountPulledInPeriod", getU64Encoder11()]
|
|
660
|
+
]);
|
|
661
|
+
}
|
|
662
|
+
function getRecurringDelegationDecoder() {
|
|
663
|
+
return getStructDecoder12([
|
|
664
|
+
["header", getHeaderDecoder()],
|
|
665
|
+
["subscriptionAuthority", getAddressDecoder8()],
|
|
666
|
+
["mint", getAddressDecoder8()],
|
|
667
|
+
["currentPeriodStartTs", getI64Decoder9()],
|
|
668
|
+
["periodLengthS", getU64Decoder8()],
|
|
669
|
+
["expiryTs", getI64Decoder9()],
|
|
670
|
+
["amountPerPeriod", getU64Decoder8()],
|
|
671
|
+
["amountPulledInPeriod", getU64Decoder8()]
|
|
672
|
+
]);
|
|
673
|
+
}
|
|
674
|
+
function getRecurringDelegationCodec() {
|
|
675
|
+
return combineCodec14(getRecurringDelegationEncoder(), getRecurringDelegationDecoder());
|
|
676
|
+
}
|
|
677
|
+
function decodeRecurringDelegation(encodedAccount) {
|
|
678
|
+
return decodeAccount4(encodedAccount, getRecurringDelegationDecoder());
|
|
679
|
+
}
|
|
680
|
+
async function fetchRecurringDelegation(rpc, address, config) {
|
|
681
|
+
const maybeAccount = await fetchMaybeRecurringDelegation(rpc, address, config);
|
|
682
|
+
assertAccountExists4(maybeAccount);
|
|
683
|
+
return maybeAccount;
|
|
684
|
+
}
|
|
685
|
+
async function fetchMaybeRecurringDelegation(rpc, address, config) {
|
|
686
|
+
const maybeAccount = await fetchEncodedAccount4(rpc, address, config);
|
|
687
|
+
return decodeRecurringDelegation(maybeAccount);
|
|
688
|
+
}
|
|
689
|
+
async function fetchAllRecurringDelegation(rpc, addresses, config) {
|
|
690
|
+
const maybeAccounts = await fetchAllMaybeRecurringDelegation(rpc, addresses, config);
|
|
691
|
+
assertAccountsExist4(maybeAccounts);
|
|
692
|
+
return maybeAccounts;
|
|
693
|
+
}
|
|
694
|
+
async function fetchAllMaybeRecurringDelegation(rpc, addresses, config) {
|
|
695
|
+
const maybeAccounts = await fetchEncodedAccounts4(rpc, addresses, config);
|
|
696
|
+
return maybeAccounts.map((maybeAccount) => decodeRecurringDelegation(maybeAccount));
|
|
697
|
+
}
|
|
698
|
+
async function fetchRecurringDelegationFromSeeds(rpc, seeds, config = {}) {
|
|
699
|
+
const maybeAccount = await fetchMaybeRecurringDelegationFromSeeds(rpc, seeds, config);
|
|
700
|
+
assertAccountExists4(maybeAccount);
|
|
701
|
+
return maybeAccount;
|
|
702
|
+
}
|
|
703
|
+
async function fetchMaybeRecurringDelegationFromSeeds(rpc, seeds, config = {}) {
|
|
704
|
+
const { programAddress, ...fetchConfig } = config;
|
|
705
|
+
const [address] = await findRecurringDelegationPda(seeds, { programAddress });
|
|
706
|
+
return await fetchMaybeRecurringDelegation(rpc, address, fetchConfig);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// src/generated/accounts/subscriptionAuthority.ts
|
|
710
|
+
import {
|
|
711
|
+
assertAccountExists as assertAccountExists5,
|
|
712
|
+
assertAccountsExist as assertAccountsExist5,
|
|
713
|
+
combineCodec as combineCodec15,
|
|
714
|
+
decodeAccount as decodeAccount5,
|
|
715
|
+
fetchEncodedAccount as fetchEncodedAccount5,
|
|
716
|
+
fetchEncodedAccounts as fetchEncodedAccounts5,
|
|
717
|
+
getAddressDecoder as getAddressDecoder9,
|
|
718
|
+
getAddressEncoder as getAddressEncoder14,
|
|
719
|
+
getI64Decoder as getI64Decoder10,
|
|
720
|
+
getI64Encoder as getI64Encoder10,
|
|
721
|
+
getStructDecoder as getStructDecoder13,
|
|
722
|
+
getStructEncoder as getStructEncoder13,
|
|
723
|
+
getU8Decoder as getU8Decoder5,
|
|
724
|
+
getU8Encoder as getU8Encoder5
|
|
725
|
+
} from "@solana/kit";
|
|
726
|
+
function getSubscriptionAuthorityEncoder() {
|
|
727
|
+
return getStructEncoder13([
|
|
728
|
+
["discriminator", getU8Encoder5()],
|
|
729
|
+
["user", getAddressEncoder14()],
|
|
730
|
+
["tokenMint", getAddressEncoder14()],
|
|
731
|
+
["payer", getAddressEncoder14()],
|
|
732
|
+
["bump", getU8Encoder5()],
|
|
733
|
+
["initId", getI64Encoder10()]
|
|
734
|
+
]);
|
|
735
|
+
}
|
|
736
|
+
function getSubscriptionAuthorityDecoder() {
|
|
737
|
+
return getStructDecoder13([
|
|
738
|
+
["discriminator", getU8Decoder5()],
|
|
739
|
+
["user", getAddressDecoder9()],
|
|
740
|
+
["tokenMint", getAddressDecoder9()],
|
|
741
|
+
["payer", getAddressDecoder9()],
|
|
742
|
+
["bump", getU8Decoder5()],
|
|
743
|
+
["initId", getI64Decoder10()]
|
|
744
|
+
]);
|
|
745
|
+
}
|
|
746
|
+
function getSubscriptionAuthorityCodec() {
|
|
747
|
+
return combineCodec15(getSubscriptionAuthorityEncoder(), getSubscriptionAuthorityDecoder());
|
|
748
|
+
}
|
|
749
|
+
function decodeSubscriptionAuthority(encodedAccount) {
|
|
750
|
+
return decodeAccount5(encodedAccount, getSubscriptionAuthorityDecoder());
|
|
751
|
+
}
|
|
752
|
+
async function fetchSubscriptionAuthority(rpc, address, config) {
|
|
753
|
+
const maybeAccount = await fetchMaybeSubscriptionAuthority(rpc, address, config);
|
|
754
|
+
assertAccountExists5(maybeAccount);
|
|
755
|
+
return maybeAccount;
|
|
756
|
+
}
|
|
757
|
+
async function fetchMaybeSubscriptionAuthority(rpc, address, config) {
|
|
758
|
+
const maybeAccount = await fetchEncodedAccount5(rpc, address, config);
|
|
759
|
+
return decodeSubscriptionAuthority(maybeAccount);
|
|
760
|
+
}
|
|
761
|
+
async function fetchAllSubscriptionAuthority(rpc, addresses, config) {
|
|
762
|
+
const maybeAccounts = await fetchAllMaybeSubscriptionAuthority(rpc, addresses, config);
|
|
763
|
+
assertAccountsExist5(maybeAccounts);
|
|
764
|
+
return maybeAccounts;
|
|
765
|
+
}
|
|
766
|
+
async function fetchAllMaybeSubscriptionAuthority(rpc, addresses, config) {
|
|
767
|
+
const maybeAccounts = await fetchEncodedAccounts5(rpc, addresses, config);
|
|
768
|
+
return maybeAccounts.map((maybeAccount) => decodeSubscriptionAuthority(maybeAccount));
|
|
769
|
+
}
|
|
770
|
+
async function fetchSubscriptionAuthorityFromSeeds(rpc, seeds, config = {}) {
|
|
771
|
+
const maybeAccount = await fetchMaybeSubscriptionAuthorityFromSeeds(rpc, seeds, config);
|
|
772
|
+
assertAccountExists5(maybeAccount);
|
|
773
|
+
return maybeAccount;
|
|
774
|
+
}
|
|
775
|
+
async function fetchMaybeSubscriptionAuthorityFromSeeds(rpc, seeds, config = {}) {
|
|
776
|
+
const { programAddress, ...fetchConfig } = config;
|
|
777
|
+
const [address] = await findSubscriptionAuthorityPda(seeds, { programAddress });
|
|
778
|
+
return await fetchMaybeSubscriptionAuthority(rpc, address, fetchConfig);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// src/generated/accounts/subscriptionDelegation.ts
|
|
782
|
+
import {
|
|
783
|
+
assertAccountExists as assertAccountExists6,
|
|
784
|
+
assertAccountsExist as assertAccountsExist6,
|
|
785
|
+
combineCodec as combineCodec16,
|
|
786
|
+
decodeAccount as decodeAccount6,
|
|
787
|
+
fetchEncodedAccount as fetchEncodedAccount6,
|
|
788
|
+
fetchEncodedAccounts as fetchEncodedAccounts6,
|
|
789
|
+
getI64Decoder as getI64Decoder11,
|
|
790
|
+
getI64Encoder as getI64Encoder11,
|
|
791
|
+
getStructDecoder as getStructDecoder14,
|
|
792
|
+
getStructEncoder as getStructEncoder14,
|
|
793
|
+
getU64Decoder as getU64Decoder9,
|
|
794
|
+
getU64Encoder as getU64Encoder12
|
|
795
|
+
} from "@solana/kit";
|
|
796
|
+
function getSubscriptionDelegationEncoder() {
|
|
797
|
+
return getStructEncoder14([
|
|
798
|
+
["header", getHeaderEncoder()],
|
|
799
|
+
["terms", getPlanTermsEncoder()],
|
|
800
|
+
["amountPulledInPeriod", getU64Encoder12()],
|
|
801
|
+
["currentPeriodStartTs", getI64Encoder11()],
|
|
802
|
+
["expiresAtTs", getI64Encoder11()]
|
|
803
|
+
]);
|
|
804
|
+
}
|
|
805
|
+
function getSubscriptionDelegationDecoder() {
|
|
806
|
+
return getStructDecoder14([
|
|
807
|
+
["header", getHeaderDecoder()],
|
|
808
|
+
["terms", getPlanTermsDecoder()],
|
|
809
|
+
["amountPulledInPeriod", getU64Decoder9()],
|
|
810
|
+
["currentPeriodStartTs", getI64Decoder11()],
|
|
811
|
+
["expiresAtTs", getI64Decoder11()]
|
|
812
|
+
]);
|
|
813
|
+
}
|
|
814
|
+
function getSubscriptionDelegationCodec() {
|
|
815
|
+
return combineCodec16(getSubscriptionDelegationEncoder(), getSubscriptionDelegationDecoder());
|
|
816
|
+
}
|
|
817
|
+
function decodeSubscriptionDelegation(encodedAccount) {
|
|
818
|
+
return decodeAccount6(encodedAccount, getSubscriptionDelegationDecoder());
|
|
819
|
+
}
|
|
820
|
+
async function fetchSubscriptionDelegation(rpc, address, config) {
|
|
821
|
+
const maybeAccount = await fetchMaybeSubscriptionDelegation(rpc, address, config);
|
|
822
|
+
assertAccountExists6(maybeAccount);
|
|
823
|
+
return maybeAccount;
|
|
824
|
+
}
|
|
825
|
+
async function fetchMaybeSubscriptionDelegation(rpc, address, config) {
|
|
826
|
+
const maybeAccount = await fetchEncodedAccount6(rpc, address, config);
|
|
827
|
+
return decodeSubscriptionDelegation(maybeAccount);
|
|
828
|
+
}
|
|
829
|
+
async function fetchAllSubscriptionDelegation(rpc, addresses, config) {
|
|
830
|
+
const maybeAccounts = await fetchAllMaybeSubscriptionDelegation(rpc, addresses, config);
|
|
831
|
+
assertAccountsExist6(maybeAccounts);
|
|
832
|
+
return maybeAccounts;
|
|
833
|
+
}
|
|
834
|
+
async function fetchAllMaybeSubscriptionDelegation(rpc, addresses, config) {
|
|
835
|
+
const maybeAccounts = await fetchEncodedAccounts6(rpc, addresses, config);
|
|
836
|
+
return maybeAccounts.map((maybeAccount) => decodeSubscriptionDelegation(maybeAccount));
|
|
837
|
+
}
|
|
838
|
+
async function fetchSubscriptionDelegationFromSeeds(rpc, seeds, config = {}) {
|
|
839
|
+
const maybeAccount = await fetchMaybeSubscriptionDelegationFromSeeds(rpc, seeds, config);
|
|
840
|
+
assertAccountExists6(maybeAccount);
|
|
841
|
+
return maybeAccount;
|
|
842
|
+
}
|
|
843
|
+
async function fetchMaybeSubscriptionDelegationFromSeeds(rpc, seeds, config = {}) {
|
|
844
|
+
const { programAddress, ...fetchConfig } = config;
|
|
845
|
+
const [address] = await findSubscriptionDelegationPda(seeds, { programAddress });
|
|
846
|
+
return await fetchMaybeSubscriptionDelegation(rpc, address, fetchConfig);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// src/generated/errors/subscriptions.ts
|
|
850
|
+
import {
|
|
851
|
+
isProgramError
|
|
852
|
+
} from "@solana/kit";
|
|
853
|
+
|
|
854
|
+
// src/generated/programs/subscriptions.ts
|
|
855
|
+
import {
|
|
856
|
+
assertIsInstructionWithAccounts,
|
|
857
|
+
containsBytes,
|
|
858
|
+
extendClient,
|
|
859
|
+
getU8Encoder as getU8Encoder19,
|
|
860
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
|
|
861
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
|
|
862
|
+
SolanaError as SolanaError14
|
|
863
|
+
} from "@solana/kit";
|
|
864
|
+
import {
|
|
865
|
+
addSelfFetchFunctions,
|
|
866
|
+
addSelfPlanAndSendFunctions
|
|
867
|
+
} from "@solana/program-client-core";
|
|
868
|
+
|
|
869
|
+
// src/generated/instructions/cancelSubscription.ts
|
|
870
|
+
import {
|
|
871
|
+
combineCodec as combineCodec17,
|
|
872
|
+
getStructDecoder as getStructDecoder15,
|
|
873
|
+
getStructEncoder as getStructEncoder15,
|
|
874
|
+
getU8Decoder as getU8Decoder6,
|
|
875
|
+
getU8Encoder as getU8Encoder6,
|
|
876
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
877
|
+
SolanaError,
|
|
878
|
+
transformEncoder
|
|
879
|
+
} from "@solana/kit";
|
|
880
|
+
import {
|
|
881
|
+
getAccountMetaFactory,
|
|
882
|
+
getAddressFromResolvedInstructionAccount
|
|
883
|
+
} from "@solana/program-client-core";
|
|
884
|
+
var CANCEL_SUBSCRIPTION_DISCRIMINATOR = 12;
|
|
885
|
+
function getCancelSubscriptionDiscriminatorBytes() {
|
|
886
|
+
return getU8Encoder6().encode(CANCEL_SUBSCRIPTION_DISCRIMINATOR);
|
|
887
|
+
}
|
|
888
|
+
function getCancelSubscriptionInstructionDataEncoder() {
|
|
889
|
+
return transformEncoder(getStructEncoder15([["discriminator", getU8Encoder6()]]), (value) => ({
|
|
890
|
+
...value,
|
|
891
|
+
discriminator: CANCEL_SUBSCRIPTION_DISCRIMINATOR
|
|
892
|
+
}));
|
|
893
|
+
}
|
|
894
|
+
function getCancelSubscriptionInstructionDataDecoder() {
|
|
895
|
+
return getStructDecoder15([["discriminator", getU8Decoder6()]]);
|
|
896
|
+
}
|
|
897
|
+
function getCancelSubscriptionInstructionDataCodec() {
|
|
898
|
+
return combineCodec17(getCancelSubscriptionInstructionDataEncoder(), getCancelSubscriptionInstructionDataDecoder());
|
|
899
|
+
}
|
|
900
|
+
async function getCancelSubscriptionInstructionAsync(input, config) {
|
|
901
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
902
|
+
const originalAccounts = {
|
|
903
|
+
subscriber: { value: input.subscriber ?? null, isWritable: false },
|
|
904
|
+
planPda: { value: input.planPda ?? null, isWritable: false },
|
|
905
|
+
subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
|
|
906
|
+
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
907
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
908
|
+
};
|
|
909
|
+
const accounts = originalAccounts;
|
|
910
|
+
if (!accounts.subscriptionPda.value) {
|
|
911
|
+
accounts.subscriptionPda.value = await findSubscriptionDelegationPda({
|
|
912
|
+
planPda: getAddressFromResolvedInstructionAccount("planPda", accounts.planPda.value),
|
|
913
|
+
subscriber: getAddressFromResolvedInstructionAccount("subscriber", accounts.subscriber.value)
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
if (!accounts.eventAuthority.value) {
|
|
917
|
+
accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
|
|
918
|
+
}
|
|
919
|
+
if (!accounts.selfProgram.value) {
|
|
920
|
+
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
921
|
+
}
|
|
922
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
923
|
+
return Object.freeze({
|
|
924
|
+
accounts: [
|
|
925
|
+
getAccountMeta("subscriber", accounts.subscriber),
|
|
926
|
+
getAccountMeta("planPda", accounts.planPda),
|
|
927
|
+
getAccountMeta("subscriptionPda", accounts.subscriptionPda),
|
|
928
|
+
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
929
|
+
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
930
|
+
],
|
|
931
|
+
data: getCancelSubscriptionInstructionDataEncoder().encode({}),
|
|
932
|
+
programAddress
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
function getCancelSubscriptionInstruction(input, config) {
|
|
936
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
937
|
+
const originalAccounts = {
|
|
938
|
+
subscriber: { value: input.subscriber ?? null, isWritable: false },
|
|
939
|
+
planPda: { value: input.planPda ?? null, isWritable: false },
|
|
940
|
+
subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
|
|
941
|
+
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
942
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
943
|
+
};
|
|
944
|
+
const accounts = originalAccounts;
|
|
945
|
+
if (!accounts.eventAuthority.value) {
|
|
946
|
+
accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
|
|
947
|
+
}
|
|
948
|
+
if (!accounts.selfProgram.value) {
|
|
949
|
+
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
950
|
+
}
|
|
951
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
952
|
+
return Object.freeze({
|
|
953
|
+
accounts: [
|
|
954
|
+
getAccountMeta("subscriber", accounts.subscriber),
|
|
955
|
+
getAccountMeta("planPda", accounts.planPda),
|
|
956
|
+
getAccountMeta("subscriptionPda", accounts.subscriptionPda),
|
|
957
|
+
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
958
|
+
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
959
|
+
],
|
|
960
|
+
data: getCancelSubscriptionInstructionDataEncoder().encode({}),
|
|
961
|
+
programAddress
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
function parseCancelSubscriptionInstruction(instruction) {
|
|
965
|
+
if (instruction.accounts.length < 5) {
|
|
966
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
967
|
+
actualAccountMetas: instruction.accounts.length,
|
|
968
|
+
expectedAccountMetas: 5
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
let accountIndex = 0;
|
|
972
|
+
const getNextAccount = () => {
|
|
973
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
974
|
+
accountIndex += 1;
|
|
975
|
+
return accountMeta;
|
|
976
|
+
};
|
|
977
|
+
return {
|
|
978
|
+
programAddress: instruction.programAddress,
|
|
979
|
+
accounts: {
|
|
980
|
+
subscriber: getNextAccount(),
|
|
981
|
+
planPda: getNextAccount(),
|
|
982
|
+
subscriptionPda: getNextAccount(),
|
|
983
|
+
eventAuthority: getNextAccount(),
|
|
984
|
+
selfProgram: getNextAccount()
|
|
985
|
+
},
|
|
986
|
+
data: getCancelSubscriptionInstructionDataDecoder().decode(instruction.data)
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// src/generated/instructions/closeSubscriptionAuthority.ts
|
|
991
|
+
import {
|
|
992
|
+
combineCodec as combineCodec18,
|
|
993
|
+
getStructDecoder as getStructDecoder16,
|
|
994
|
+
getStructEncoder as getStructEncoder16,
|
|
995
|
+
getU8Decoder as getU8Decoder7,
|
|
996
|
+
getU8Encoder as getU8Encoder7,
|
|
997
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS2,
|
|
998
|
+
SolanaError as SolanaError2,
|
|
999
|
+
transformEncoder as transformEncoder2
|
|
1000
|
+
} from "@solana/kit";
|
|
1001
|
+
import { getAccountMetaFactory as getAccountMetaFactory2 } from "@solana/program-client-core";
|
|
1002
|
+
var CLOSE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR = 6;
|
|
1003
|
+
function getCloseSubscriptionAuthorityDiscriminatorBytes() {
|
|
1004
|
+
return getU8Encoder7().encode(CLOSE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR);
|
|
1005
|
+
}
|
|
1006
|
+
function getCloseSubscriptionAuthorityInstructionDataEncoder() {
|
|
1007
|
+
return transformEncoder2(getStructEncoder16([["discriminator", getU8Encoder7()]]), (value) => ({
|
|
1008
|
+
...value,
|
|
1009
|
+
discriminator: CLOSE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR
|
|
1010
|
+
}));
|
|
1011
|
+
}
|
|
1012
|
+
function getCloseSubscriptionAuthorityInstructionDataDecoder() {
|
|
1013
|
+
return getStructDecoder16([["discriminator", getU8Decoder7()]]);
|
|
1014
|
+
}
|
|
1015
|
+
function getCloseSubscriptionAuthorityInstructionDataCodec() {
|
|
1016
|
+
return combineCodec18(
|
|
1017
|
+
getCloseSubscriptionAuthorityInstructionDataEncoder(),
|
|
1018
|
+
getCloseSubscriptionAuthorityInstructionDataDecoder()
|
|
1019
|
+
);
|
|
1020
|
+
}
|
|
1021
|
+
function getCloseSubscriptionAuthorityInstruction(input, config) {
|
|
1022
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1023
|
+
const originalAccounts = {
|
|
1024
|
+
user: { value: input.user ?? null, isWritable: true },
|
|
1025
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: true }
|
|
1026
|
+
};
|
|
1027
|
+
const accounts = originalAccounts;
|
|
1028
|
+
const getAccountMeta = getAccountMetaFactory2(programAddress, "programId");
|
|
1029
|
+
return Object.freeze({
|
|
1030
|
+
accounts: [
|
|
1031
|
+
getAccountMeta("user", accounts.user),
|
|
1032
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority)
|
|
1033
|
+
],
|
|
1034
|
+
data: getCloseSubscriptionAuthorityInstructionDataEncoder().encode({}),
|
|
1035
|
+
programAddress
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
function parseCloseSubscriptionAuthorityInstruction(instruction) {
|
|
1039
|
+
if (instruction.accounts.length < 2) {
|
|
1040
|
+
throw new SolanaError2(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS2, {
|
|
1041
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1042
|
+
expectedAccountMetas: 2
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
let accountIndex = 0;
|
|
1046
|
+
const getNextAccount = () => {
|
|
1047
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1048
|
+
accountIndex += 1;
|
|
1049
|
+
return accountMeta;
|
|
1050
|
+
};
|
|
1051
|
+
return {
|
|
1052
|
+
programAddress: instruction.programAddress,
|
|
1053
|
+
accounts: { user: getNextAccount(), subscriptionAuthority: getNextAccount() },
|
|
1054
|
+
data: getCloseSubscriptionAuthorityInstructionDataDecoder().decode(instruction.data)
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// src/generated/instructions/createFixedDelegation.ts
|
|
1059
|
+
import {
|
|
1060
|
+
combineCodec as combineCodec19,
|
|
1061
|
+
getStructDecoder as getStructDecoder17,
|
|
1062
|
+
getStructEncoder as getStructEncoder17,
|
|
1063
|
+
getU8Decoder as getU8Decoder8,
|
|
1064
|
+
getU8Encoder as getU8Encoder8,
|
|
1065
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS3,
|
|
1066
|
+
SolanaError as SolanaError3,
|
|
1067
|
+
transformEncoder as transformEncoder3
|
|
1068
|
+
} from "@solana/kit";
|
|
1069
|
+
import { getAccountMetaFactory as getAccountMetaFactory3 } from "@solana/program-client-core";
|
|
1070
|
+
var CREATE_FIXED_DELEGATION_DISCRIMINATOR = 1;
|
|
1071
|
+
function getCreateFixedDelegationDiscriminatorBytes() {
|
|
1072
|
+
return getU8Encoder8().encode(CREATE_FIXED_DELEGATION_DISCRIMINATOR);
|
|
1073
|
+
}
|
|
1074
|
+
function getCreateFixedDelegationInstructionDataEncoder() {
|
|
1075
|
+
return transformEncoder3(
|
|
1076
|
+
getStructEncoder17([
|
|
1077
|
+
["discriminator", getU8Encoder8()],
|
|
1078
|
+
["fixedDelegation", getCreateFixedDelegationDataEncoder()]
|
|
1079
|
+
]),
|
|
1080
|
+
(value) => ({ ...value, discriminator: CREATE_FIXED_DELEGATION_DISCRIMINATOR })
|
|
1081
|
+
);
|
|
1082
|
+
}
|
|
1083
|
+
function getCreateFixedDelegationInstructionDataDecoder() {
|
|
1084
|
+
return getStructDecoder17([
|
|
1085
|
+
["discriminator", getU8Decoder8()],
|
|
1086
|
+
["fixedDelegation", getCreateFixedDelegationDataDecoder()]
|
|
1087
|
+
]);
|
|
1088
|
+
}
|
|
1089
|
+
function getCreateFixedDelegationInstructionDataCodec() {
|
|
1090
|
+
return combineCodec19(
|
|
1091
|
+
getCreateFixedDelegationInstructionDataEncoder(),
|
|
1092
|
+
getCreateFixedDelegationInstructionDataDecoder()
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
function getCreateFixedDelegationInstruction(input, config) {
|
|
1096
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1097
|
+
const originalAccounts = {
|
|
1098
|
+
delegator: { value: input.delegator ?? null, isWritable: true },
|
|
1099
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
1100
|
+
delegationAccount: { value: input.delegationAccount ?? null, isWritable: true },
|
|
1101
|
+
delegatee: { value: input.delegatee ?? null, isWritable: false },
|
|
1102
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false }
|
|
1103
|
+
};
|
|
1104
|
+
const accounts = originalAccounts;
|
|
1105
|
+
const args = { ...input };
|
|
1106
|
+
if (!accounts.systemProgram.value) {
|
|
1107
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1108
|
+
}
|
|
1109
|
+
const getAccountMeta = getAccountMetaFactory3(programAddress, "programId");
|
|
1110
|
+
return Object.freeze({
|
|
1111
|
+
accounts: [
|
|
1112
|
+
getAccountMeta("delegator", accounts.delegator),
|
|
1113
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1114
|
+
getAccountMeta("delegationAccount", accounts.delegationAccount),
|
|
1115
|
+
getAccountMeta("delegatee", accounts.delegatee),
|
|
1116
|
+
getAccountMeta("systemProgram", accounts.systemProgram)
|
|
1117
|
+
],
|
|
1118
|
+
data: getCreateFixedDelegationInstructionDataEncoder().encode(args),
|
|
1119
|
+
programAddress
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
function parseCreateFixedDelegationInstruction(instruction) {
|
|
1123
|
+
if (instruction.accounts.length < 5) {
|
|
1124
|
+
throw new SolanaError3(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS3, {
|
|
1125
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1126
|
+
expectedAccountMetas: 5
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
let accountIndex = 0;
|
|
1130
|
+
const getNextAccount = () => {
|
|
1131
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1132
|
+
accountIndex += 1;
|
|
1133
|
+
return accountMeta;
|
|
1134
|
+
};
|
|
1135
|
+
return {
|
|
1136
|
+
programAddress: instruction.programAddress,
|
|
1137
|
+
accounts: {
|
|
1138
|
+
delegator: getNextAccount(),
|
|
1139
|
+
subscriptionAuthority: getNextAccount(),
|
|
1140
|
+
delegationAccount: getNextAccount(),
|
|
1141
|
+
delegatee: getNextAccount(),
|
|
1142
|
+
systemProgram: getNextAccount()
|
|
1143
|
+
},
|
|
1144
|
+
data: getCreateFixedDelegationInstructionDataDecoder().decode(instruction.data)
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// src/generated/instructions/createPlan.ts
|
|
1149
|
+
import {
|
|
1150
|
+
combineCodec as combineCodec20,
|
|
1151
|
+
getStructDecoder as getStructDecoder18,
|
|
1152
|
+
getStructEncoder as getStructEncoder18,
|
|
1153
|
+
getU8Decoder as getU8Decoder9,
|
|
1154
|
+
getU8Encoder as getU8Encoder9,
|
|
1155
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS4,
|
|
1156
|
+
SolanaError as SolanaError4,
|
|
1157
|
+
transformEncoder as transformEncoder4
|
|
1158
|
+
} from "@solana/kit";
|
|
1159
|
+
import { getAccountMetaFactory as getAccountMetaFactory4 } from "@solana/program-client-core";
|
|
1160
|
+
var CREATE_PLAN_DISCRIMINATOR = 7;
|
|
1161
|
+
function getCreatePlanDiscriminatorBytes() {
|
|
1162
|
+
return getU8Encoder9().encode(CREATE_PLAN_DISCRIMINATOR);
|
|
1163
|
+
}
|
|
1164
|
+
function getCreatePlanInstructionDataEncoder() {
|
|
1165
|
+
return transformEncoder4(
|
|
1166
|
+
getStructEncoder18([
|
|
1167
|
+
["discriminator", getU8Encoder9()],
|
|
1168
|
+
["planData", getPlanDataEncoder()]
|
|
1169
|
+
]),
|
|
1170
|
+
(value) => ({ ...value, discriminator: CREATE_PLAN_DISCRIMINATOR })
|
|
1171
|
+
);
|
|
1172
|
+
}
|
|
1173
|
+
function getCreatePlanInstructionDataDecoder() {
|
|
1174
|
+
return getStructDecoder18([
|
|
1175
|
+
["discriminator", getU8Decoder9()],
|
|
1176
|
+
["planData", getPlanDataDecoder()]
|
|
1177
|
+
]);
|
|
1178
|
+
}
|
|
1179
|
+
function getCreatePlanInstructionDataCodec() {
|
|
1180
|
+
return combineCodec20(getCreatePlanInstructionDataEncoder(), getCreatePlanInstructionDataDecoder());
|
|
1181
|
+
}
|
|
1182
|
+
function getCreatePlanInstruction(input, config) {
|
|
1183
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1184
|
+
const originalAccounts = {
|
|
1185
|
+
merchant: { value: input.merchant ?? null, isWritable: true },
|
|
1186
|
+
planPda: { value: input.planPda ?? null, isWritable: true },
|
|
1187
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
1188
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1189
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }
|
|
1190
|
+
};
|
|
1191
|
+
const accounts = originalAccounts;
|
|
1192
|
+
const args = { ...input };
|
|
1193
|
+
if (!accounts.systemProgram.value) {
|
|
1194
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1195
|
+
}
|
|
1196
|
+
if (!accounts.tokenProgram.value) {
|
|
1197
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
1198
|
+
}
|
|
1199
|
+
const getAccountMeta = getAccountMetaFactory4(programAddress, "programId");
|
|
1200
|
+
return Object.freeze({
|
|
1201
|
+
accounts: [
|
|
1202
|
+
getAccountMeta("merchant", accounts.merchant),
|
|
1203
|
+
getAccountMeta("planPda", accounts.planPda),
|
|
1204
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
1205
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
1206
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram)
|
|
1207
|
+
],
|
|
1208
|
+
data: getCreatePlanInstructionDataEncoder().encode(args),
|
|
1209
|
+
programAddress
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
function parseCreatePlanInstruction(instruction) {
|
|
1213
|
+
if (instruction.accounts.length < 5) {
|
|
1214
|
+
throw new SolanaError4(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS4, {
|
|
1215
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1216
|
+
expectedAccountMetas: 5
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
let accountIndex = 0;
|
|
1220
|
+
const getNextAccount = () => {
|
|
1221
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1222
|
+
accountIndex += 1;
|
|
1223
|
+
return accountMeta;
|
|
1224
|
+
};
|
|
1225
|
+
return {
|
|
1226
|
+
programAddress: instruction.programAddress,
|
|
1227
|
+
accounts: {
|
|
1228
|
+
merchant: getNextAccount(),
|
|
1229
|
+
planPda: getNextAccount(),
|
|
1230
|
+
tokenMint: getNextAccount(),
|
|
1231
|
+
systemProgram: getNextAccount(),
|
|
1232
|
+
tokenProgram: getNextAccount()
|
|
1233
|
+
},
|
|
1234
|
+
data: getCreatePlanInstructionDataDecoder().decode(instruction.data)
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
// src/generated/instructions/createRecurringDelegation.ts
|
|
1239
|
+
import {
|
|
1240
|
+
combineCodec as combineCodec21,
|
|
1241
|
+
getStructDecoder as getStructDecoder19,
|
|
1242
|
+
getStructEncoder as getStructEncoder19,
|
|
1243
|
+
getU8Decoder as getU8Decoder10,
|
|
1244
|
+
getU8Encoder as getU8Encoder10,
|
|
1245
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS5,
|
|
1246
|
+
SolanaError as SolanaError5,
|
|
1247
|
+
transformEncoder as transformEncoder5
|
|
1248
|
+
} from "@solana/kit";
|
|
1249
|
+
import { getAccountMetaFactory as getAccountMetaFactory5 } from "@solana/program-client-core";
|
|
1250
|
+
var CREATE_RECURRING_DELEGATION_DISCRIMINATOR = 2;
|
|
1251
|
+
function getCreateRecurringDelegationDiscriminatorBytes() {
|
|
1252
|
+
return getU8Encoder10().encode(CREATE_RECURRING_DELEGATION_DISCRIMINATOR);
|
|
1253
|
+
}
|
|
1254
|
+
function getCreateRecurringDelegationInstructionDataEncoder() {
|
|
1255
|
+
return transformEncoder5(
|
|
1256
|
+
getStructEncoder19([
|
|
1257
|
+
["discriminator", getU8Encoder10()],
|
|
1258
|
+
["recurringDelegation", getCreateRecurringDelegationDataEncoder()]
|
|
1259
|
+
]),
|
|
1260
|
+
(value) => ({ ...value, discriminator: CREATE_RECURRING_DELEGATION_DISCRIMINATOR })
|
|
1261
|
+
);
|
|
1262
|
+
}
|
|
1263
|
+
function getCreateRecurringDelegationInstructionDataDecoder() {
|
|
1264
|
+
return getStructDecoder19([
|
|
1265
|
+
["discriminator", getU8Decoder10()],
|
|
1266
|
+
["recurringDelegation", getCreateRecurringDelegationDataDecoder()]
|
|
1267
|
+
]);
|
|
1268
|
+
}
|
|
1269
|
+
function getCreateRecurringDelegationInstructionDataCodec() {
|
|
1270
|
+
return combineCodec21(
|
|
1271
|
+
getCreateRecurringDelegationInstructionDataEncoder(),
|
|
1272
|
+
getCreateRecurringDelegationInstructionDataDecoder()
|
|
1273
|
+
);
|
|
1274
|
+
}
|
|
1275
|
+
function getCreateRecurringDelegationInstruction(input, config) {
|
|
1276
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1277
|
+
const originalAccounts = {
|
|
1278
|
+
delegator: { value: input.delegator ?? null, isWritable: true },
|
|
1279
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
1280
|
+
delegationAccount: { value: input.delegationAccount ?? null, isWritable: true },
|
|
1281
|
+
delegatee: { value: input.delegatee ?? null, isWritable: false },
|
|
1282
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false }
|
|
1283
|
+
};
|
|
1284
|
+
const accounts = originalAccounts;
|
|
1285
|
+
const args = { ...input };
|
|
1286
|
+
if (!accounts.systemProgram.value) {
|
|
1287
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1288
|
+
}
|
|
1289
|
+
const getAccountMeta = getAccountMetaFactory5(programAddress, "programId");
|
|
1290
|
+
return Object.freeze({
|
|
1291
|
+
accounts: [
|
|
1292
|
+
getAccountMeta("delegator", accounts.delegator),
|
|
1293
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1294
|
+
getAccountMeta("delegationAccount", accounts.delegationAccount),
|
|
1295
|
+
getAccountMeta("delegatee", accounts.delegatee),
|
|
1296
|
+
getAccountMeta("systemProgram", accounts.systemProgram)
|
|
1297
|
+
],
|
|
1298
|
+
data: getCreateRecurringDelegationInstructionDataEncoder().encode(
|
|
1299
|
+
args
|
|
1300
|
+
),
|
|
1301
|
+
programAddress
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
function parseCreateRecurringDelegationInstruction(instruction) {
|
|
1305
|
+
if (instruction.accounts.length < 5) {
|
|
1306
|
+
throw new SolanaError5(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS5, {
|
|
1307
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1308
|
+
expectedAccountMetas: 5
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
let accountIndex = 0;
|
|
1312
|
+
const getNextAccount = () => {
|
|
1313
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1314
|
+
accountIndex += 1;
|
|
1315
|
+
return accountMeta;
|
|
1316
|
+
};
|
|
1317
|
+
return {
|
|
1318
|
+
programAddress: instruction.programAddress,
|
|
1319
|
+
accounts: {
|
|
1320
|
+
delegator: getNextAccount(),
|
|
1321
|
+
subscriptionAuthority: getNextAccount(),
|
|
1322
|
+
delegationAccount: getNextAccount(),
|
|
1323
|
+
delegatee: getNextAccount(),
|
|
1324
|
+
systemProgram: getNextAccount()
|
|
1325
|
+
},
|
|
1326
|
+
data: getCreateRecurringDelegationInstructionDataDecoder().decode(instruction.data)
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
// src/generated/instructions/deletePlan.ts
|
|
1331
|
+
import {
|
|
1332
|
+
combineCodec as combineCodec22,
|
|
1333
|
+
getStructDecoder as getStructDecoder20,
|
|
1334
|
+
getStructEncoder as getStructEncoder20,
|
|
1335
|
+
getU8Decoder as getU8Decoder11,
|
|
1336
|
+
getU8Encoder as getU8Encoder11,
|
|
1337
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS6,
|
|
1338
|
+
SolanaError as SolanaError6,
|
|
1339
|
+
transformEncoder as transformEncoder6
|
|
1340
|
+
} from "@solana/kit";
|
|
1341
|
+
import { getAccountMetaFactory as getAccountMetaFactory6 } from "@solana/program-client-core";
|
|
1342
|
+
var DELETE_PLAN_DISCRIMINATOR = 9;
|
|
1343
|
+
function getDeletePlanDiscriminatorBytes() {
|
|
1344
|
+
return getU8Encoder11().encode(DELETE_PLAN_DISCRIMINATOR);
|
|
1345
|
+
}
|
|
1346
|
+
function getDeletePlanInstructionDataEncoder() {
|
|
1347
|
+
return transformEncoder6(getStructEncoder20([["discriminator", getU8Encoder11()]]), (value) => ({
|
|
1348
|
+
...value,
|
|
1349
|
+
discriminator: DELETE_PLAN_DISCRIMINATOR
|
|
1350
|
+
}));
|
|
1351
|
+
}
|
|
1352
|
+
function getDeletePlanInstructionDataDecoder() {
|
|
1353
|
+
return getStructDecoder20([["discriminator", getU8Decoder11()]]);
|
|
1354
|
+
}
|
|
1355
|
+
function getDeletePlanInstructionDataCodec() {
|
|
1356
|
+
return combineCodec22(getDeletePlanInstructionDataEncoder(), getDeletePlanInstructionDataDecoder());
|
|
1357
|
+
}
|
|
1358
|
+
function getDeletePlanInstruction(input, config) {
|
|
1359
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1360
|
+
const originalAccounts = {
|
|
1361
|
+
owner: { value: input.owner ?? null, isWritable: true },
|
|
1362
|
+
planPda: { value: input.planPda ?? null, isWritable: true }
|
|
1363
|
+
};
|
|
1364
|
+
const accounts = originalAccounts;
|
|
1365
|
+
const getAccountMeta = getAccountMetaFactory6(programAddress, "programId");
|
|
1366
|
+
return Object.freeze({
|
|
1367
|
+
accounts: [getAccountMeta("owner", accounts.owner), getAccountMeta("planPda", accounts.planPda)],
|
|
1368
|
+
data: getDeletePlanInstructionDataEncoder().encode({}),
|
|
1369
|
+
programAddress
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
function parseDeletePlanInstruction(instruction) {
|
|
1373
|
+
if (instruction.accounts.length < 2) {
|
|
1374
|
+
throw new SolanaError6(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS6, {
|
|
1375
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1376
|
+
expectedAccountMetas: 2
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
let accountIndex = 0;
|
|
1380
|
+
const getNextAccount = () => {
|
|
1381
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1382
|
+
accountIndex += 1;
|
|
1383
|
+
return accountMeta;
|
|
1384
|
+
};
|
|
1385
|
+
return {
|
|
1386
|
+
programAddress: instruction.programAddress,
|
|
1387
|
+
accounts: { owner: getNextAccount(), planPda: getNextAccount() },
|
|
1388
|
+
data: getDeletePlanInstructionDataDecoder().decode(instruction.data)
|
|
1389
|
+
};
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
// src/generated/instructions/initSubscriptionAuthority.ts
|
|
1393
|
+
import {
|
|
1394
|
+
combineCodec as combineCodec23,
|
|
1395
|
+
getStructDecoder as getStructDecoder21,
|
|
1396
|
+
getStructEncoder as getStructEncoder21,
|
|
1397
|
+
getU8Decoder as getU8Decoder12,
|
|
1398
|
+
getU8Encoder as getU8Encoder12,
|
|
1399
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS7,
|
|
1400
|
+
SolanaError as SolanaError7,
|
|
1401
|
+
transformEncoder as transformEncoder7
|
|
1402
|
+
} from "@solana/kit";
|
|
1403
|
+
import {
|
|
1404
|
+
getAccountMetaFactory as getAccountMetaFactory7,
|
|
1405
|
+
getAddressFromResolvedInstructionAccount as getAddressFromResolvedInstructionAccount2
|
|
1406
|
+
} from "@solana/program-client-core";
|
|
1407
|
+
var INIT_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR = 0;
|
|
1408
|
+
function getInitSubscriptionAuthorityDiscriminatorBytes() {
|
|
1409
|
+
return getU8Encoder12().encode(INIT_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR);
|
|
1410
|
+
}
|
|
1411
|
+
function getInitSubscriptionAuthorityInstructionDataEncoder() {
|
|
1412
|
+
return transformEncoder7(getStructEncoder21([["discriminator", getU8Encoder12()]]), (value) => ({
|
|
1413
|
+
...value,
|
|
1414
|
+
discriminator: INIT_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR
|
|
1415
|
+
}));
|
|
1416
|
+
}
|
|
1417
|
+
function getInitSubscriptionAuthorityInstructionDataDecoder() {
|
|
1418
|
+
return getStructDecoder21([["discriminator", getU8Decoder12()]]);
|
|
1419
|
+
}
|
|
1420
|
+
function getInitSubscriptionAuthorityInstructionDataCodec() {
|
|
1421
|
+
return combineCodec23(
|
|
1422
|
+
getInitSubscriptionAuthorityInstructionDataEncoder(),
|
|
1423
|
+
getInitSubscriptionAuthorityInstructionDataDecoder()
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1426
|
+
async function getInitSubscriptionAuthorityInstructionAsync(input, config) {
|
|
1427
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1428
|
+
const originalAccounts = {
|
|
1429
|
+
owner: { value: input.owner ?? null, isWritable: true },
|
|
1430
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: true },
|
|
1431
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
1432
|
+
userAta: { value: input.userAta ?? null, isWritable: true },
|
|
1433
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1434
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }
|
|
1435
|
+
};
|
|
1436
|
+
const accounts = originalAccounts;
|
|
1437
|
+
if (!accounts.subscriptionAuthority.value) {
|
|
1438
|
+
accounts.subscriptionAuthority.value = await findSubscriptionAuthorityPda({
|
|
1439
|
+
user: getAddressFromResolvedInstructionAccount2("owner", accounts.owner.value),
|
|
1440
|
+
tokenMint: getAddressFromResolvedInstructionAccount2("tokenMint", accounts.tokenMint.value)
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
if (!accounts.systemProgram.value) {
|
|
1444
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1445
|
+
}
|
|
1446
|
+
const getAccountMeta = getAccountMetaFactory7(programAddress, "programId");
|
|
1447
|
+
return Object.freeze({
|
|
1448
|
+
accounts: [
|
|
1449
|
+
getAccountMeta("owner", accounts.owner),
|
|
1450
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1451
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
1452
|
+
getAccountMeta("userAta", accounts.userAta),
|
|
1453
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
1454
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram)
|
|
1455
|
+
],
|
|
1456
|
+
data: getInitSubscriptionAuthorityInstructionDataEncoder().encode({}),
|
|
1457
|
+
programAddress
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
function getInitSubscriptionAuthorityInstruction(input, config) {
|
|
1461
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1462
|
+
const originalAccounts = {
|
|
1463
|
+
owner: { value: input.owner ?? null, isWritable: true },
|
|
1464
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: true },
|
|
1465
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
1466
|
+
userAta: { value: input.userAta ?? null, isWritable: true },
|
|
1467
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1468
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }
|
|
1469
|
+
};
|
|
1470
|
+
const accounts = originalAccounts;
|
|
1471
|
+
if (!accounts.systemProgram.value) {
|
|
1472
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1473
|
+
}
|
|
1474
|
+
const getAccountMeta = getAccountMetaFactory7(programAddress, "programId");
|
|
1475
|
+
return Object.freeze({
|
|
1476
|
+
accounts: [
|
|
1477
|
+
getAccountMeta("owner", accounts.owner),
|
|
1478
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1479
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
1480
|
+
getAccountMeta("userAta", accounts.userAta),
|
|
1481
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
1482
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram)
|
|
1483
|
+
],
|
|
1484
|
+
data: getInitSubscriptionAuthorityInstructionDataEncoder().encode({}),
|
|
1485
|
+
programAddress
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
function parseInitSubscriptionAuthorityInstruction(instruction) {
|
|
1489
|
+
if (instruction.accounts.length < 6) {
|
|
1490
|
+
throw new SolanaError7(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS7, {
|
|
1491
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1492
|
+
expectedAccountMetas: 6
|
|
1493
|
+
});
|
|
1494
|
+
}
|
|
1495
|
+
let accountIndex = 0;
|
|
1496
|
+
const getNextAccount = () => {
|
|
1497
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1498
|
+
accountIndex += 1;
|
|
1499
|
+
return accountMeta;
|
|
1500
|
+
};
|
|
1501
|
+
return {
|
|
1502
|
+
programAddress: instruction.programAddress,
|
|
1503
|
+
accounts: {
|
|
1504
|
+
owner: getNextAccount(),
|
|
1505
|
+
subscriptionAuthority: getNextAccount(),
|
|
1506
|
+
tokenMint: getNextAccount(),
|
|
1507
|
+
userAta: getNextAccount(),
|
|
1508
|
+
systemProgram: getNextAccount(),
|
|
1509
|
+
tokenProgram: getNextAccount()
|
|
1510
|
+
},
|
|
1511
|
+
data: getInitSubscriptionAuthorityInstructionDataDecoder().decode(instruction.data)
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
// src/generated/instructions/revokeDelegation.ts
|
|
1516
|
+
import {
|
|
1517
|
+
combineCodec as combineCodec24,
|
|
1518
|
+
getStructDecoder as getStructDecoder22,
|
|
1519
|
+
getStructEncoder as getStructEncoder22,
|
|
1520
|
+
getU8Decoder as getU8Decoder13,
|
|
1521
|
+
getU8Encoder as getU8Encoder13,
|
|
1522
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS8,
|
|
1523
|
+
SolanaError as SolanaError8,
|
|
1524
|
+
transformEncoder as transformEncoder8
|
|
1525
|
+
} from "@solana/kit";
|
|
1526
|
+
import { getAccountMetaFactory as getAccountMetaFactory8 } from "@solana/program-client-core";
|
|
1527
|
+
var REVOKE_DELEGATION_DISCRIMINATOR = 3;
|
|
1528
|
+
function getRevokeDelegationDiscriminatorBytes() {
|
|
1529
|
+
return getU8Encoder13().encode(REVOKE_DELEGATION_DISCRIMINATOR);
|
|
1530
|
+
}
|
|
1531
|
+
function getRevokeDelegationInstructionDataEncoder() {
|
|
1532
|
+
return transformEncoder8(getStructEncoder22([["discriminator", getU8Encoder13()]]), (value) => ({
|
|
1533
|
+
...value,
|
|
1534
|
+
discriminator: REVOKE_DELEGATION_DISCRIMINATOR
|
|
1535
|
+
}));
|
|
1536
|
+
}
|
|
1537
|
+
function getRevokeDelegationInstructionDataDecoder() {
|
|
1538
|
+
return getStructDecoder22([["discriminator", getU8Decoder13()]]);
|
|
1539
|
+
}
|
|
1540
|
+
function getRevokeDelegationInstructionDataCodec() {
|
|
1541
|
+
return combineCodec24(getRevokeDelegationInstructionDataEncoder(), getRevokeDelegationInstructionDataDecoder());
|
|
1542
|
+
}
|
|
1543
|
+
function getRevokeDelegationInstruction(input, config) {
|
|
1544
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1545
|
+
const originalAccounts = {
|
|
1546
|
+
authority: { value: input.authority ?? null, isWritable: true },
|
|
1547
|
+
delegationAccount: { value: input.delegationAccount ?? null, isWritable: true }
|
|
1548
|
+
};
|
|
1549
|
+
const accounts = originalAccounts;
|
|
1550
|
+
const getAccountMeta = getAccountMetaFactory8(programAddress, "programId");
|
|
1551
|
+
return Object.freeze({
|
|
1552
|
+
accounts: [
|
|
1553
|
+
getAccountMeta("authority", accounts.authority),
|
|
1554
|
+
getAccountMeta("delegationAccount", accounts.delegationAccount)
|
|
1555
|
+
],
|
|
1556
|
+
data: getRevokeDelegationInstructionDataEncoder().encode({}),
|
|
1557
|
+
programAddress
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
function parseRevokeDelegationInstruction(instruction) {
|
|
1561
|
+
if (instruction.accounts.length < 2) {
|
|
1562
|
+
throw new SolanaError8(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS8, {
|
|
1563
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1564
|
+
expectedAccountMetas: 2
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
let accountIndex = 0;
|
|
1568
|
+
const getNextAccount = () => {
|
|
1569
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1570
|
+
accountIndex += 1;
|
|
1571
|
+
return accountMeta;
|
|
1572
|
+
};
|
|
1573
|
+
return {
|
|
1574
|
+
programAddress: instruction.programAddress,
|
|
1575
|
+
accounts: { authority: getNextAccount(), delegationAccount: getNextAccount() },
|
|
1576
|
+
data: getRevokeDelegationInstructionDataDecoder().decode(instruction.data)
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
// src/generated/instructions/subscribe.ts
|
|
1581
|
+
import {
|
|
1582
|
+
combineCodec as combineCodec25,
|
|
1583
|
+
getStructDecoder as getStructDecoder23,
|
|
1584
|
+
getStructEncoder as getStructEncoder23,
|
|
1585
|
+
getU8Decoder as getU8Decoder14,
|
|
1586
|
+
getU8Encoder as getU8Encoder14,
|
|
1587
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS9,
|
|
1588
|
+
SolanaError as SolanaError9,
|
|
1589
|
+
transformEncoder as transformEncoder9
|
|
1590
|
+
} from "@solana/kit";
|
|
1591
|
+
import {
|
|
1592
|
+
getAccountMetaFactory as getAccountMetaFactory9,
|
|
1593
|
+
getAddressFromResolvedInstructionAccount as getAddressFromResolvedInstructionAccount3
|
|
1594
|
+
} from "@solana/program-client-core";
|
|
1595
|
+
var SUBSCRIBE_DISCRIMINATOR = 11;
|
|
1596
|
+
function getSubscribeDiscriminatorBytes() {
|
|
1597
|
+
return getU8Encoder14().encode(SUBSCRIBE_DISCRIMINATOR);
|
|
1598
|
+
}
|
|
1599
|
+
function getSubscribeInstructionDataEncoder() {
|
|
1600
|
+
return transformEncoder9(
|
|
1601
|
+
getStructEncoder23([
|
|
1602
|
+
["discriminator", getU8Encoder14()],
|
|
1603
|
+
["subscribeData", getSubscribeDataEncoder()]
|
|
1604
|
+
]),
|
|
1605
|
+
(value) => ({ ...value, discriminator: SUBSCRIBE_DISCRIMINATOR })
|
|
1606
|
+
);
|
|
1607
|
+
}
|
|
1608
|
+
function getSubscribeInstructionDataDecoder() {
|
|
1609
|
+
return getStructDecoder23([
|
|
1610
|
+
["discriminator", getU8Decoder14()],
|
|
1611
|
+
["subscribeData", getSubscribeDataDecoder()]
|
|
1612
|
+
]);
|
|
1613
|
+
}
|
|
1614
|
+
function getSubscribeInstructionDataCodec() {
|
|
1615
|
+
return combineCodec25(getSubscribeInstructionDataEncoder(), getSubscribeInstructionDataDecoder());
|
|
1616
|
+
}
|
|
1617
|
+
async function getSubscribeInstructionAsync(input, config) {
|
|
1618
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1619
|
+
const originalAccounts = {
|
|
1620
|
+
subscriber: { value: input.subscriber ?? null, isWritable: true },
|
|
1621
|
+
merchant: { value: input.merchant ?? null, isWritable: false },
|
|
1622
|
+
planPda: { value: input.planPda ?? null, isWritable: false },
|
|
1623
|
+
subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
|
|
1624
|
+
subscriptionAuthorityPda: { value: input.subscriptionAuthorityPda ?? null, isWritable: false },
|
|
1625
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1626
|
+
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
1627
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
1628
|
+
};
|
|
1629
|
+
const accounts = originalAccounts;
|
|
1630
|
+
const args = { ...input };
|
|
1631
|
+
if (!accounts.subscriptionPda.value) {
|
|
1632
|
+
accounts.subscriptionPda.value = await findSubscriptionDelegationPda({
|
|
1633
|
+
planPda: getAddressFromResolvedInstructionAccount3("planPda", accounts.planPda.value),
|
|
1634
|
+
subscriber: getAddressFromResolvedInstructionAccount3("subscriber", accounts.subscriber.value)
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
if (!accounts.systemProgram.value) {
|
|
1638
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1639
|
+
}
|
|
1640
|
+
if (!accounts.eventAuthority.value) {
|
|
1641
|
+
accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
|
|
1642
|
+
}
|
|
1643
|
+
if (!accounts.selfProgram.value) {
|
|
1644
|
+
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1645
|
+
}
|
|
1646
|
+
const getAccountMeta = getAccountMetaFactory9(programAddress, "programId");
|
|
1647
|
+
return Object.freeze({
|
|
1648
|
+
accounts: [
|
|
1649
|
+
getAccountMeta("subscriber", accounts.subscriber),
|
|
1650
|
+
getAccountMeta("merchant", accounts.merchant),
|
|
1651
|
+
getAccountMeta("planPda", accounts.planPda),
|
|
1652
|
+
getAccountMeta("subscriptionPda", accounts.subscriptionPda),
|
|
1653
|
+
getAccountMeta("subscriptionAuthorityPda", accounts.subscriptionAuthorityPda),
|
|
1654
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
1655
|
+
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
1656
|
+
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
1657
|
+
],
|
|
1658
|
+
data: getSubscribeInstructionDataEncoder().encode(args),
|
|
1659
|
+
programAddress
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
function getSubscribeInstruction(input, config) {
|
|
1663
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1664
|
+
const originalAccounts = {
|
|
1665
|
+
subscriber: { value: input.subscriber ?? null, isWritable: true },
|
|
1666
|
+
merchant: { value: input.merchant ?? null, isWritable: false },
|
|
1667
|
+
planPda: { value: input.planPda ?? null, isWritable: false },
|
|
1668
|
+
subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
|
|
1669
|
+
subscriptionAuthorityPda: { value: input.subscriptionAuthorityPda ?? null, isWritable: false },
|
|
1670
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1671
|
+
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
1672
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
1673
|
+
};
|
|
1674
|
+
const accounts = originalAccounts;
|
|
1675
|
+
const args = { ...input };
|
|
1676
|
+
if (!accounts.systemProgram.value) {
|
|
1677
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1678
|
+
}
|
|
1679
|
+
if (!accounts.eventAuthority.value) {
|
|
1680
|
+
accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
|
|
1681
|
+
}
|
|
1682
|
+
if (!accounts.selfProgram.value) {
|
|
1683
|
+
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1684
|
+
}
|
|
1685
|
+
const getAccountMeta = getAccountMetaFactory9(programAddress, "programId");
|
|
1686
|
+
return Object.freeze({
|
|
1687
|
+
accounts: [
|
|
1688
|
+
getAccountMeta("subscriber", accounts.subscriber),
|
|
1689
|
+
getAccountMeta("merchant", accounts.merchant),
|
|
1690
|
+
getAccountMeta("planPda", accounts.planPda),
|
|
1691
|
+
getAccountMeta("subscriptionPda", accounts.subscriptionPda),
|
|
1692
|
+
getAccountMeta("subscriptionAuthorityPda", accounts.subscriptionAuthorityPda),
|
|
1693
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
1694
|
+
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
1695
|
+
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
1696
|
+
],
|
|
1697
|
+
data: getSubscribeInstructionDataEncoder().encode(args),
|
|
1698
|
+
programAddress
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
function parseSubscribeInstruction(instruction) {
|
|
1702
|
+
if (instruction.accounts.length < 8) {
|
|
1703
|
+
throw new SolanaError9(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS9, {
|
|
1704
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1705
|
+
expectedAccountMetas: 8
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
let accountIndex = 0;
|
|
1709
|
+
const getNextAccount = () => {
|
|
1710
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1711
|
+
accountIndex += 1;
|
|
1712
|
+
return accountMeta;
|
|
1713
|
+
};
|
|
1714
|
+
return {
|
|
1715
|
+
programAddress: instruction.programAddress,
|
|
1716
|
+
accounts: {
|
|
1717
|
+
subscriber: getNextAccount(),
|
|
1718
|
+
merchant: getNextAccount(),
|
|
1719
|
+
planPda: getNextAccount(),
|
|
1720
|
+
subscriptionPda: getNextAccount(),
|
|
1721
|
+
subscriptionAuthorityPda: getNextAccount(),
|
|
1722
|
+
systemProgram: getNextAccount(),
|
|
1723
|
+
eventAuthority: getNextAccount(),
|
|
1724
|
+
selfProgram: getNextAccount()
|
|
1725
|
+
},
|
|
1726
|
+
data: getSubscribeInstructionDataDecoder().decode(instruction.data)
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
// src/generated/instructions/transferFixed.ts
|
|
1731
|
+
import {
|
|
1732
|
+
combineCodec as combineCodec26,
|
|
1733
|
+
getStructDecoder as getStructDecoder24,
|
|
1734
|
+
getStructEncoder as getStructEncoder24,
|
|
1735
|
+
getU8Decoder as getU8Decoder15,
|
|
1736
|
+
getU8Encoder as getU8Encoder15,
|
|
1737
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS10,
|
|
1738
|
+
SolanaError as SolanaError10,
|
|
1739
|
+
transformEncoder as transformEncoder10
|
|
1740
|
+
} from "@solana/kit";
|
|
1741
|
+
import { getAccountMetaFactory as getAccountMetaFactory10 } from "@solana/program-client-core";
|
|
1742
|
+
var TRANSFER_FIXED_DISCRIMINATOR = 4;
|
|
1743
|
+
function getTransferFixedDiscriminatorBytes() {
|
|
1744
|
+
return getU8Encoder15().encode(TRANSFER_FIXED_DISCRIMINATOR);
|
|
1745
|
+
}
|
|
1746
|
+
function getTransferFixedInstructionDataEncoder() {
|
|
1747
|
+
return transformEncoder10(
|
|
1748
|
+
getStructEncoder24([
|
|
1749
|
+
["discriminator", getU8Encoder15()],
|
|
1750
|
+
["transferData", getTransferDataEncoder()]
|
|
1751
|
+
]),
|
|
1752
|
+
(value) => ({ ...value, discriminator: TRANSFER_FIXED_DISCRIMINATOR })
|
|
1753
|
+
);
|
|
1754
|
+
}
|
|
1755
|
+
function getTransferFixedInstructionDataDecoder() {
|
|
1756
|
+
return getStructDecoder24([
|
|
1757
|
+
["discriminator", getU8Decoder15()],
|
|
1758
|
+
["transferData", getTransferDataDecoder()]
|
|
1759
|
+
]);
|
|
1760
|
+
}
|
|
1761
|
+
function getTransferFixedInstructionDataCodec() {
|
|
1762
|
+
return combineCodec26(getTransferFixedInstructionDataEncoder(), getTransferFixedInstructionDataDecoder());
|
|
1763
|
+
}
|
|
1764
|
+
function getTransferFixedInstruction(input, config) {
|
|
1765
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1766
|
+
const originalAccounts = {
|
|
1767
|
+
delegationPda: { value: input.delegationPda ?? null, isWritable: true },
|
|
1768
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
1769
|
+
delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
|
|
1770
|
+
receiverAta: { value: input.receiverAta ?? null, isWritable: true },
|
|
1771
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
1772
|
+
delegatee: { value: input.delegatee ?? null, isWritable: false },
|
|
1773
|
+
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
1774
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
1775
|
+
};
|
|
1776
|
+
const accounts = originalAccounts;
|
|
1777
|
+
const args = { ...input };
|
|
1778
|
+
if (!accounts.eventAuthority.value) {
|
|
1779
|
+
accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
|
|
1780
|
+
}
|
|
1781
|
+
if (!accounts.selfProgram.value) {
|
|
1782
|
+
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1783
|
+
}
|
|
1784
|
+
const getAccountMeta = getAccountMetaFactory10(programAddress, "programId");
|
|
1785
|
+
return Object.freeze({
|
|
1786
|
+
accounts: [
|
|
1787
|
+
getAccountMeta("delegationPda", accounts.delegationPda),
|
|
1788
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1789
|
+
getAccountMeta("delegatorAta", accounts.delegatorAta),
|
|
1790
|
+
getAccountMeta("receiverAta", accounts.receiverAta),
|
|
1791
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
1792
|
+
getAccountMeta("delegatee", accounts.delegatee),
|
|
1793
|
+
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
1794
|
+
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
1795
|
+
],
|
|
1796
|
+
data: getTransferFixedInstructionDataEncoder().encode(args),
|
|
1797
|
+
programAddress
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
function parseTransferFixedInstruction(instruction) {
|
|
1801
|
+
if (instruction.accounts.length < 8) {
|
|
1802
|
+
throw new SolanaError10(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS10, {
|
|
1803
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1804
|
+
expectedAccountMetas: 8
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
let accountIndex = 0;
|
|
1808
|
+
const getNextAccount = () => {
|
|
1809
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1810
|
+
accountIndex += 1;
|
|
1811
|
+
return accountMeta;
|
|
1812
|
+
};
|
|
1813
|
+
return {
|
|
1814
|
+
programAddress: instruction.programAddress,
|
|
1815
|
+
accounts: {
|
|
1816
|
+
delegationPda: getNextAccount(),
|
|
1817
|
+
subscriptionAuthority: getNextAccount(),
|
|
1818
|
+
delegatorAta: getNextAccount(),
|
|
1819
|
+
receiverAta: getNextAccount(),
|
|
1820
|
+
tokenProgram: getNextAccount(),
|
|
1821
|
+
delegatee: getNextAccount(),
|
|
1822
|
+
eventAuthority: getNextAccount(),
|
|
1823
|
+
selfProgram: getNextAccount()
|
|
1824
|
+
},
|
|
1825
|
+
data: getTransferFixedInstructionDataDecoder().decode(instruction.data)
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
// src/generated/instructions/transferRecurring.ts
|
|
1830
|
+
import {
|
|
1831
|
+
combineCodec as combineCodec27,
|
|
1832
|
+
getStructDecoder as getStructDecoder25,
|
|
1833
|
+
getStructEncoder as getStructEncoder25,
|
|
1834
|
+
getU8Decoder as getU8Decoder16,
|
|
1835
|
+
getU8Encoder as getU8Encoder16,
|
|
1836
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS11,
|
|
1837
|
+
SolanaError as SolanaError11,
|
|
1838
|
+
transformEncoder as transformEncoder11
|
|
1839
|
+
} from "@solana/kit";
|
|
1840
|
+
import { getAccountMetaFactory as getAccountMetaFactory11 } from "@solana/program-client-core";
|
|
1841
|
+
var TRANSFER_RECURRING_DISCRIMINATOR = 5;
|
|
1842
|
+
function getTransferRecurringDiscriminatorBytes() {
|
|
1843
|
+
return getU8Encoder16().encode(TRANSFER_RECURRING_DISCRIMINATOR);
|
|
1844
|
+
}
|
|
1845
|
+
function getTransferRecurringInstructionDataEncoder() {
|
|
1846
|
+
return transformEncoder11(
|
|
1847
|
+
getStructEncoder25([
|
|
1848
|
+
["discriminator", getU8Encoder16()],
|
|
1849
|
+
["transferData", getTransferDataEncoder()]
|
|
1850
|
+
]),
|
|
1851
|
+
(value) => ({ ...value, discriminator: TRANSFER_RECURRING_DISCRIMINATOR })
|
|
1852
|
+
);
|
|
1853
|
+
}
|
|
1854
|
+
function getTransferRecurringInstructionDataDecoder() {
|
|
1855
|
+
return getStructDecoder25([
|
|
1856
|
+
["discriminator", getU8Decoder16()],
|
|
1857
|
+
["transferData", getTransferDataDecoder()]
|
|
1858
|
+
]);
|
|
1859
|
+
}
|
|
1860
|
+
function getTransferRecurringInstructionDataCodec() {
|
|
1861
|
+
return combineCodec27(getTransferRecurringInstructionDataEncoder(), getTransferRecurringInstructionDataDecoder());
|
|
1862
|
+
}
|
|
1863
|
+
function getTransferRecurringInstruction(input, config) {
|
|
1864
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1865
|
+
const originalAccounts = {
|
|
1866
|
+
delegationPda: { value: input.delegationPda ?? null, isWritable: true },
|
|
1867
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
1868
|
+
delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
|
|
1869
|
+
receiverAta: { value: input.receiverAta ?? null, isWritable: true },
|
|
1870
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
1871
|
+
delegatee: { value: input.delegatee ?? null, isWritable: false },
|
|
1872
|
+
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
1873
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
1874
|
+
};
|
|
1875
|
+
const accounts = originalAccounts;
|
|
1876
|
+
const args = { ...input };
|
|
1877
|
+
if (!accounts.eventAuthority.value) {
|
|
1878
|
+
accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
|
|
1879
|
+
}
|
|
1880
|
+
if (!accounts.selfProgram.value) {
|
|
1881
|
+
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1882
|
+
}
|
|
1883
|
+
const getAccountMeta = getAccountMetaFactory11(programAddress, "programId");
|
|
1884
|
+
return Object.freeze({
|
|
1885
|
+
accounts: [
|
|
1886
|
+
getAccountMeta("delegationPda", accounts.delegationPda),
|
|
1887
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1888
|
+
getAccountMeta("delegatorAta", accounts.delegatorAta),
|
|
1889
|
+
getAccountMeta("receiverAta", accounts.receiverAta),
|
|
1890
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
1891
|
+
getAccountMeta("delegatee", accounts.delegatee),
|
|
1892
|
+
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
1893
|
+
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
1894
|
+
],
|
|
1895
|
+
data: getTransferRecurringInstructionDataEncoder().encode(args),
|
|
1896
|
+
programAddress
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1899
|
+
function parseTransferRecurringInstruction(instruction) {
|
|
1900
|
+
if (instruction.accounts.length < 8) {
|
|
1901
|
+
throw new SolanaError11(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS11, {
|
|
1902
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1903
|
+
expectedAccountMetas: 8
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
let accountIndex = 0;
|
|
1907
|
+
const getNextAccount = () => {
|
|
1908
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1909
|
+
accountIndex += 1;
|
|
1910
|
+
return accountMeta;
|
|
1911
|
+
};
|
|
1912
|
+
return {
|
|
1913
|
+
programAddress: instruction.programAddress,
|
|
1914
|
+
accounts: {
|
|
1915
|
+
delegationPda: getNextAccount(),
|
|
1916
|
+
subscriptionAuthority: getNextAccount(),
|
|
1917
|
+
delegatorAta: getNextAccount(),
|
|
1918
|
+
receiverAta: getNextAccount(),
|
|
1919
|
+
tokenProgram: getNextAccount(),
|
|
1920
|
+
delegatee: getNextAccount(),
|
|
1921
|
+
eventAuthority: getNextAccount(),
|
|
1922
|
+
selfProgram: getNextAccount()
|
|
1923
|
+
},
|
|
1924
|
+
data: getTransferRecurringInstructionDataDecoder().decode(instruction.data)
|
|
1925
|
+
};
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
// src/generated/instructions/transferSubscription.ts
|
|
1929
|
+
import {
|
|
1930
|
+
combineCodec as combineCodec28,
|
|
1931
|
+
getStructDecoder as getStructDecoder26,
|
|
1932
|
+
getStructEncoder as getStructEncoder26,
|
|
1933
|
+
getU8Decoder as getU8Decoder17,
|
|
1934
|
+
getU8Encoder as getU8Encoder17,
|
|
1935
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS12,
|
|
1936
|
+
SolanaError as SolanaError12,
|
|
1937
|
+
transformEncoder as transformEncoder12
|
|
1938
|
+
} from "@solana/kit";
|
|
1939
|
+
import { getAccountMetaFactory as getAccountMetaFactory12 } from "@solana/program-client-core";
|
|
1940
|
+
var TRANSFER_SUBSCRIPTION_DISCRIMINATOR = 10;
|
|
1941
|
+
function getTransferSubscriptionDiscriminatorBytes() {
|
|
1942
|
+
return getU8Encoder17().encode(TRANSFER_SUBSCRIPTION_DISCRIMINATOR);
|
|
1943
|
+
}
|
|
1944
|
+
function getTransferSubscriptionInstructionDataEncoder() {
|
|
1945
|
+
return transformEncoder12(
|
|
1946
|
+
getStructEncoder26([
|
|
1947
|
+
["discriminator", getU8Encoder17()],
|
|
1948
|
+
["transferData", getTransferDataEncoder()]
|
|
1949
|
+
]),
|
|
1950
|
+
(value) => ({ ...value, discriminator: TRANSFER_SUBSCRIPTION_DISCRIMINATOR })
|
|
1951
|
+
);
|
|
1952
|
+
}
|
|
1953
|
+
function getTransferSubscriptionInstructionDataDecoder() {
|
|
1954
|
+
return getStructDecoder26([
|
|
1955
|
+
["discriminator", getU8Decoder17()],
|
|
1956
|
+
["transferData", getTransferDataDecoder()]
|
|
1957
|
+
]);
|
|
1958
|
+
}
|
|
1959
|
+
function getTransferSubscriptionInstructionDataCodec() {
|
|
1960
|
+
return combineCodec28(
|
|
1961
|
+
getTransferSubscriptionInstructionDataEncoder(),
|
|
1962
|
+
getTransferSubscriptionInstructionDataDecoder()
|
|
1963
|
+
);
|
|
1964
|
+
}
|
|
1965
|
+
function getTransferSubscriptionInstruction(input, config) {
|
|
1966
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1967
|
+
const originalAccounts = {
|
|
1968
|
+
subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
|
|
1969
|
+
planPda: { value: input.planPda ?? null, isWritable: false },
|
|
1970
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
1971
|
+
delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
|
|
1972
|
+
receiverAta: { value: input.receiverAta ?? null, isWritable: true },
|
|
1973
|
+
caller: { value: input.caller ?? null, isWritable: false },
|
|
1974
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
1975
|
+
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
1976
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
1977
|
+
};
|
|
1978
|
+
const accounts = originalAccounts;
|
|
1979
|
+
const args = { ...input };
|
|
1980
|
+
if (!accounts.eventAuthority.value) {
|
|
1981
|
+
accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
|
|
1982
|
+
}
|
|
1983
|
+
if (!accounts.selfProgram.value) {
|
|
1984
|
+
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1985
|
+
}
|
|
1986
|
+
const getAccountMeta = getAccountMetaFactory12(programAddress, "programId");
|
|
1987
|
+
return Object.freeze({
|
|
1988
|
+
accounts: [
|
|
1989
|
+
getAccountMeta("subscriptionPda", accounts.subscriptionPda),
|
|
1990
|
+
getAccountMeta("planPda", accounts.planPda),
|
|
1991
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1992
|
+
getAccountMeta("delegatorAta", accounts.delegatorAta),
|
|
1993
|
+
getAccountMeta("receiverAta", accounts.receiverAta),
|
|
1994
|
+
getAccountMeta("caller", accounts.caller),
|
|
1995
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
1996
|
+
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
1997
|
+
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
1998
|
+
],
|
|
1999
|
+
data: getTransferSubscriptionInstructionDataEncoder().encode(args),
|
|
2000
|
+
programAddress
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
function parseTransferSubscriptionInstruction(instruction) {
|
|
2004
|
+
if (instruction.accounts.length < 9) {
|
|
2005
|
+
throw new SolanaError12(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS12, {
|
|
2006
|
+
actualAccountMetas: instruction.accounts.length,
|
|
2007
|
+
expectedAccountMetas: 9
|
|
2008
|
+
});
|
|
2009
|
+
}
|
|
2010
|
+
let accountIndex = 0;
|
|
2011
|
+
const getNextAccount = () => {
|
|
2012
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
2013
|
+
accountIndex += 1;
|
|
2014
|
+
return accountMeta;
|
|
2015
|
+
};
|
|
2016
|
+
return {
|
|
2017
|
+
programAddress: instruction.programAddress,
|
|
2018
|
+
accounts: {
|
|
2019
|
+
subscriptionPda: getNextAccount(),
|
|
2020
|
+
planPda: getNextAccount(),
|
|
2021
|
+
subscriptionAuthority: getNextAccount(),
|
|
2022
|
+
delegatorAta: getNextAccount(),
|
|
2023
|
+
receiverAta: getNextAccount(),
|
|
2024
|
+
caller: getNextAccount(),
|
|
2025
|
+
tokenProgram: getNextAccount(),
|
|
2026
|
+
eventAuthority: getNextAccount(),
|
|
2027
|
+
selfProgram: getNextAccount()
|
|
2028
|
+
},
|
|
2029
|
+
data: getTransferSubscriptionInstructionDataDecoder().decode(instruction.data)
|
|
2030
|
+
};
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
// src/generated/instructions/updatePlan.ts
|
|
2034
|
+
import {
|
|
2035
|
+
combineCodec as combineCodec29,
|
|
2036
|
+
getStructDecoder as getStructDecoder27,
|
|
2037
|
+
getStructEncoder as getStructEncoder27,
|
|
2038
|
+
getU8Decoder as getU8Decoder18,
|
|
2039
|
+
getU8Encoder as getU8Encoder18,
|
|
2040
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS13,
|
|
2041
|
+
SolanaError as SolanaError13,
|
|
2042
|
+
transformEncoder as transformEncoder13
|
|
2043
|
+
} from "@solana/kit";
|
|
2044
|
+
import { getAccountMetaFactory as getAccountMetaFactory13 } from "@solana/program-client-core";
|
|
2045
|
+
var UPDATE_PLAN_DISCRIMINATOR = 8;
|
|
2046
|
+
function getUpdatePlanDiscriminatorBytes() {
|
|
2047
|
+
return getU8Encoder18().encode(UPDATE_PLAN_DISCRIMINATOR);
|
|
2048
|
+
}
|
|
2049
|
+
function getUpdatePlanInstructionDataEncoder() {
|
|
2050
|
+
return transformEncoder13(
|
|
2051
|
+
getStructEncoder27([
|
|
2052
|
+
["discriminator", getU8Encoder18()],
|
|
2053
|
+
["updatePlanData", getUpdatePlanDataEncoder()]
|
|
2054
|
+
]),
|
|
2055
|
+
(value) => ({ ...value, discriminator: UPDATE_PLAN_DISCRIMINATOR })
|
|
2056
|
+
);
|
|
2057
|
+
}
|
|
2058
|
+
function getUpdatePlanInstructionDataDecoder() {
|
|
2059
|
+
return getStructDecoder27([
|
|
2060
|
+
["discriminator", getU8Decoder18()],
|
|
2061
|
+
["updatePlanData", getUpdatePlanDataDecoder()]
|
|
2062
|
+
]);
|
|
2063
|
+
}
|
|
2064
|
+
function getUpdatePlanInstructionDataCodec() {
|
|
2065
|
+
return combineCodec29(getUpdatePlanInstructionDataEncoder(), getUpdatePlanInstructionDataDecoder());
|
|
2066
|
+
}
|
|
2067
|
+
function getUpdatePlanInstruction(input, config) {
|
|
2068
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2069
|
+
const originalAccounts = {
|
|
2070
|
+
owner: { value: input.owner ?? null, isWritable: false },
|
|
2071
|
+
planPda: { value: input.planPda ?? null, isWritable: true }
|
|
2072
|
+
};
|
|
2073
|
+
const accounts = originalAccounts;
|
|
2074
|
+
const args = { ...input };
|
|
2075
|
+
const getAccountMeta = getAccountMetaFactory13(programAddress, "programId");
|
|
2076
|
+
return Object.freeze({
|
|
2077
|
+
accounts: [getAccountMeta("owner", accounts.owner), getAccountMeta("planPda", accounts.planPda)],
|
|
2078
|
+
data: getUpdatePlanInstructionDataEncoder().encode(args),
|
|
2079
|
+
programAddress
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
function parseUpdatePlanInstruction(instruction) {
|
|
2083
|
+
if (instruction.accounts.length < 2) {
|
|
2084
|
+
throw new SolanaError13(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS13, {
|
|
2085
|
+
actualAccountMetas: instruction.accounts.length,
|
|
2086
|
+
expectedAccountMetas: 2
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
let accountIndex = 0;
|
|
2090
|
+
const getNextAccount = () => {
|
|
2091
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
2092
|
+
accountIndex += 1;
|
|
2093
|
+
return accountMeta;
|
|
2094
|
+
};
|
|
2095
|
+
return {
|
|
2096
|
+
programAddress: instruction.programAddress,
|
|
2097
|
+
accounts: { owner: getNextAccount(), planPda: getNextAccount() },
|
|
2098
|
+
data: getUpdatePlanInstructionDataDecoder().decode(instruction.data)
|
|
2099
|
+
};
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
// src/generated/programs/subscriptions.ts
|
|
2103
|
+
var SUBSCRIPTIONS_PROGRAM_ADDRESS = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
2104
|
+
var SubscriptionsAccount = /* @__PURE__ */ ((SubscriptionsAccount2) => {
|
|
2105
|
+
SubscriptionsAccount2[SubscriptionsAccount2["FixedDelegation"] = 0] = "FixedDelegation";
|
|
2106
|
+
SubscriptionsAccount2[SubscriptionsAccount2["Plan"] = 1] = "Plan";
|
|
2107
|
+
SubscriptionsAccount2[SubscriptionsAccount2["RecurringDelegation"] = 2] = "RecurringDelegation";
|
|
2108
|
+
SubscriptionsAccount2[SubscriptionsAccount2["SubscriptionAuthority"] = 3] = "SubscriptionAuthority";
|
|
2109
|
+
SubscriptionsAccount2[SubscriptionsAccount2["SubscriptionDelegation"] = 4] = "SubscriptionDelegation";
|
|
2110
|
+
SubscriptionsAccount2[SubscriptionsAccount2["EventAuthority"] = 5] = "EventAuthority";
|
|
2111
|
+
return SubscriptionsAccount2;
|
|
2112
|
+
})(SubscriptionsAccount || {});
|
|
2113
|
+
var SubscriptionsInstruction = /* @__PURE__ */ ((SubscriptionsInstruction2) => {
|
|
2114
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["InitSubscriptionAuthority"] = 0] = "InitSubscriptionAuthority";
|
|
2115
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["CreateFixedDelegation"] = 1] = "CreateFixedDelegation";
|
|
2116
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["CreateRecurringDelegation"] = 2] = "CreateRecurringDelegation";
|
|
2117
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeDelegation"] = 3] = "RevokeDelegation";
|
|
2118
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["TransferFixed"] = 4] = "TransferFixed";
|
|
2119
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["TransferRecurring"] = 5] = "TransferRecurring";
|
|
2120
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["CloseSubscriptionAuthority"] = 6] = "CloseSubscriptionAuthority";
|
|
2121
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["CreatePlan"] = 7] = "CreatePlan";
|
|
2122
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["UpdatePlan"] = 8] = "UpdatePlan";
|
|
2123
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["DeletePlan"] = 9] = "DeletePlan";
|
|
2124
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["TransferSubscription"] = 10] = "TransferSubscription";
|
|
2125
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["Subscribe"] = 11] = "Subscribe";
|
|
2126
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["CancelSubscription"] = 12] = "CancelSubscription";
|
|
2127
|
+
return SubscriptionsInstruction2;
|
|
2128
|
+
})(SubscriptionsInstruction || {});
|
|
2129
|
+
function identifySubscriptionsInstruction(instruction) {
|
|
2130
|
+
const data = "data" in instruction ? instruction.data : instruction;
|
|
2131
|
+
if (containsBytes(data, getU8Encoder19().encode(0), 0)) {
|
|
2132
|
+
return 0 /* InitSubscriptionAuthority */;
|
|
2133
|
+
}
|
|
2134
|
+
if (containsBytes(data, getU8Encoder19().encode(1), 0)) {
|
|
2135
|
+
return 1 /* CreateFixedDelegation */;
|
|
2136
|
+
}
|
|
2137
|
+
if (containsBytes(data, getU8Encoder19().encode(2), 0)) {
|
|
2138
|
+
return 2 /* CreateRecurringDelegation */;
|
|
2139
|
+
}
|
|
2140
|
+
if (containsBytes(data, getU8Encoder19().encode(3), 0)) {
|
|
2141
|
+
return 3 /* RevokeDelegation */;
|
|
2142
|
+
}
|
|
2143
|
+
if (containsBytes(data, getU8Encoder19().encode(4), 0)) {
|
|
2144
|
+
return 4 /* TransferFixed */;
|
|
2145
|
+
}
|
|
2146
|
+
if (containsBytes(data, getU8Encoder19().encode(5), 0)) {
|
|
2147
|
+
return 5 /* TransferRecurring */;
|
|
2148
|
+
}
|
|
2149
|
+
if (containsBytes(data, getU8Encoder19().encode(6), 0)) {
|
|
2150
|
+
return 6 /* CloseSubscriptionAuthority */;
|
|
2151
|
+
}
|
|
2152
|
+
if (containsBytes(data, getU8Encoder19().encode(7), 0)) {
|
|
2153
|
+
return 7 /* CreatePlan */;
|
|
2154
|
+
}
|
|
2155
|
+
if (containsBytes(data, getU8Encoder19().encode(8), 0)) {
|
|
2156
|
+
return 8 /* UpdatePlan */;
|
|
2157
|
+
}
|
|
2158
|
+
if (containsBytes(data, getU8Encoder19().encode(9), 0)) {
|
|
2159
|
+
return 9 /* DeletePlan */;
|
|
2160
|
+
}
|
|
2161
|
+
if (containsBytes(data, getU8Encoder19().encode(10), 0)) {
|
|
2162
|
+
return 10 /* TransferSubscription */;
|
|
2163
|
+
}
|
|
2164
|
+
if (containsBytes(data, getU8Encoder19().encode(11), 0)) {
|
|
2165
|
+
return 11 /* Subscribe */;
|
|
2166
|
+
}
|
|
2167
|
+
if (containsBytes(data, getU8Encoder19().encode(12), 0)) {
|
|
2168
|
+
return 12 /* CancelSubscription */;
|
|
2169
|
+
}
|
|
2170
|
+
throw new SolanaError14(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
|
|
2171
|
+
instructionData: data,
|
|
2172
|
+
programName: "subscriptions"
|
|
2173
|
+
});
|
|
2174
|
+
}
|
|
2175
|
+
function parseSubscriptionsInstruction(instruction) {
|
|
2176
|
+
const instructionType = identifySubscriptionsInstruction(instruction);
|
|
2177
|
+
switch (instructionType) {
|
|
2178
|
+
case 0 /* InitSubscriptionAuthority */: {
|
|
2179
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2180
|
+
return {
|
|
2181
|
+
instructionType: 0 /* InitSubscriptionAuthority */,
|
|
2182
|
+
...parseInitSubscriptionAuthorityInstruction(instruction)
|
|
2183
|
+
};
|
|
2184
|
+
}
|
|
2185
|
+
case 1 /* CreateFixedDelegation */: {
|
|
2186
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2187
|
+
return {
|
|
2188
|
+
instructionType: 1 /* CreateFixedDelegation */,
|
|
2189
|
+
...parseCreateFixedDelegationInstruction(instruction)
|
|
2190
|
+
};
|
|
2191
|
+
}
|
|
2192
|
+
case 2 /* CreateRecurringDelegation */: {
|
|
2193
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2194
|
+
return {
|
|
2195
|
+
instructionType: 2 /* CreateRecurringDelegation */,
|
|
2196
|
+
...parseCreateRecurringDelegationInstruction(instruction)
|
|
2197
|
+
};
|
|
2198
|
+
}
|
|
2199
|
+
case 3 /* RevokeDelegation */: {
|
|
2200
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2201
|
+
return {
|
|
2202
|
+
instructionType: 3 /* RevokeDelegation */,
|
|
2203
|
+
...parseRevokeDelegationInstruction(instruction)
|
|
2204
|
+
};
|
|
2205
|
+
}
|
|
2206
|
+
case 4 /* TransferFixed */: {
|
|
2207
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2208
|
+
return {
|
|
2209
|
+
instructionType: 4 /* TransferFixed */,
|
|
2210
|
+
...parseTransferFixedInstruction(instruction)
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
case 5 /* TransferRecurring */: {
|
|
2214
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2215
|
+
return {
|
|
2216
|
+
instructionType: 5 /* TransferRecurring */,
|
|
2217
|
+
...parseTransferRecurringInstruction(instruction)
|
|
2218
|
+
};
|
|
2219
|
+
}
|
|
2220
|
+
case 6 /* CloseSubscriptionAuthority */: {
|
|
2221
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2222
|
+
return {
|
|
2223
|
+
instructionType: 6 /* CloseSubscriptionAuthority */,
|
|
2224
|
+
...parseCloseSubscriptionAuthorityInstruction(instruction)
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2227
|
+
case 7 /* CreatePlan */: {
|
|
2228
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2229
|
+
return { instructionType: 7 /* CreatePlan */, ...parseCreatePlanInstruction(instruction) };
|
|
2230
|
+
}
|
|
2231
|
+
case 8 /* UpdatePlan */: {
|
|
2232
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2233
|
+
return { instructionType: 8 /* UpdatePlan */, ...parseUpdatePlanInstruction(instruction) };
|
|
2234
|
+
}
|
|
2235
|
+
case 9 /* DeletePlan */: {
|
|
2236
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2237
|
+
return { instructionType: 9 /* DeletePlan */, ...parseDeletePlanInstruction(instruction) };
|
|
2238
|
+
}
|
|
2239
|
+
case 10 /* TransferSubscription */: {
|
|
2240
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2241
|
+
return {
|
|
2242
|
+
instructionType: 10 /* TransferSubscription */,
|
|
2243
|
+
...parseTransferSubscriptionInstruction(instruction)
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2246
|
+
case 11 /* Subscribe */: {
|
|
2247
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2248
|
+
return { instructionType: 11 /* Subscribe */, ...parseSubscribeInstruction(instruction) };
|
|
2249
|
+
}
|
|
2250
|
+
case 12 /* CancelSubscription */: {
|
|
2251
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2252
|
+
return {
|
|
2253
|
+
instructionType: 12 /* CancelSubscription */,
|
|
2254
|
+
...parseCancelSubscriptionInstruction(instruction)
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
default:
|
|
2258
|
+
throw new SolanaError14(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
|
|
2259
|
+
instructionType,
|
|
2260
|
+
programName: "subscriptions"
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
function subscriptionsProgram() {
|
|
2265
|
+
return (client) => {
|
|
2266
|
+
return extendClient(client, {
|
|
2267
|
+
subscriptions: {
|
|
2268
|
+
accounts: {
|
|
2269
|
+
fixedDelegation: addSelfFetchFunctions(client, getFixedDelegationCodec()),
|
|
2270
|
+
plan: addSelfFetchFunctions(client, getPlanCodec()),
|
|
2271
|
+
recurringDelegation: addSelfFetchFunctions(client, getRecurringDelegationCodec()),
|
|
2272
|
+
subscriptionAuthority: addSelfFetchFunctions(client, getSubscriptionAuthorityCodec()),
|
|
2273
|
+
subscriptionDelegation: addSelfFetchFunctions(client, getSubscriptionDelegationCodec()),
|
|
2274
|
+
eventAuthority: addSelfFetchFunctions(client, getEventAuthorityCodec())
|
|
2275
|
+
},
|
|
2276
|
+
instructions: {
|
|
2277
|
+
initSubscriptionAuthority: (input) => addSelfPlanAndSendFunctions(client, getInitSubscriptionAuthorityInstructionAsync(input)),
|
|
2278
|
+
createFixedDelegation: (input) => addSelfPlanAndSendFunctions(client, getCreateFixedDelegationInstruction(input)),
|
|
2279
|
+
createRecurringDelegation: (input) => addSelfPlanAndSendFunctions(client, getCreateRecurringDelegationInstruction(input)),
|
|
2280
|
+
revokeDelegation: (input) => addSelfPlanAndSendFunctions(client, getRevokeDelegationInstruction(input)),
|
|
2281
|
+
transferFixed: (input) => addSelfPlanAndSendFunctions(client, getTransferFixedInstruction(input)),
|
|
2282
|
+
transferRecurring: (input) => addSelfPlanAndSendFunctions(client, getTransferRecurringInstruction(input)),
|
|
2283
|
+
closeSubscriptionAuthority: (input) => addSelfPlanAndSendFunctions(client, getCloseSubscriptionAuthorityInstruction(input)),
|
|
2284
|
+
createPlan: (input) => addSelfPlanAndSendFunctions(client, getCreatePlanInstruction(input)),
|
|
2285
|
+
updatePlan: (input) => addSelfPlanAndSendFunctions(client, getUpdatePlanInstruction(input)),
|
|
2286
|
+
deletePlan: (input) => addSelfPlanAndSendFunctions(client, getDeletePlanInstruction(input)),
|
|
2287
|
+
transferSubscription: (input) => addSelfPlanAndSendFunctions(client, getTransferSubscriptionInstruction(input)),
|
|
2288
|
+
subscribe: (input) => addSelfPlanAndSendFunctions(client, getSubscribeInstructionAsync(input)),
|
|
2289
|
+
cancelSubscription: (input) => addSelfPlanAndSendFunctions(client, getCancelSubscriptionInstructionAsync(input))
|
|
2290
|
+
},
|
|
2291
|
+
pdas: {
|
|
2292
|
+
fixedDelegation: findFixedDelegationPda,
|
|
2293
|
+
plan: findPlanPda,
|
|
2294
|
+
recurringDelegation: findRecurringDelegationPda,
|
|
2295
|
+
subscriptionAuthority: findSubscriptionAuthorityPda,
|
|
2296
|
+
subscriptionDelegation: findSubscriptionDelegationPda,
|
|
2297
|
+
eventAuthority: findEventAuthorityPda
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
});
|
|
2301
|
+
};
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
// src/generated/errors/subscriptions.ts
|
|
2305
|
+
var SUBSCRIPTIONS_ERROR__NOT_SIGNER = 100;
|
|
2306
|
+
var SUBSCRIPTIONS_ERROR__INVALID_ADDRESS = 101;
|
|
2307
|
+
var SUBSCRIPTIONS_ERROR__INVALID_ESCROW_PDA = 102;
|
|
2308
|
+
var SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_AUTHORITY_PDA = 103;
|
|
2309
|
+
var SUBSCRIPTIONS_ERROR__NOT_SYSTEM_PROGRAM = 104;
|
|
2310
|
+
var SUBSCRIPTIONS_ERROR__INVALID_TOKEN_PROGRAM = 105;
|
|
2311
|
+
var SUBSCRIPTIONS_ERROR__INVALID_TOKEN2022_MINT_ACCOUNT_DATA = 106;
|
|
2312
|
+
var SUBSCRIPTIONS_ERROR__INVALID_TOKEN2022_TOKEN_ACCOUNT_DATA = 107;
|
|
2313
|
+
var SUBSCRIPTIONS_ERROR__INVALID_ASSOCIATED_TOKEN_ACCOUNT_DERIVED_ADDRESS = 108;
|
|
2314
|
+
var SUBSCRIPTIONS_ERROR__INVALID_TOKEN_SPL_MINT_ACCOUNT_DATA = 109;
|
|
2315
|
+
var SUBSCRIPTIONS_ERROR__INVALID_TOKEN_SPL_TOKEN_ACCOUNT_DATA = 110;
|
|
2316
|
+
var SUBSCRIPTIONS_ERROR__INVALID_ACCOUNT_DATA = 111;
|
|
2317
|
+
var SUBSCRIPTIONS_ERROR__INVALID_INSTRUCTION_DATA = 112;
|
|
2318
|
+
var SUBSCRIPTIONS_ERROR__NOT_ENOUGH_ACCOUNT_KEYS = 113;
|
|
2319
|
+
var SUBSCRIPTIONS_ERROR__INVALID_INSTRUCTION = 114;
|
|
2320
|
+
var SUBSCRIPTIONS_ERROR__ARITHMETIC_OVERFLOW = 115;
|
|
2321
|
+
var SUBSCRIPTIONS_ERROR__ARITHMETIC_UNDERFLOW = 116;
|
|
2322
|
+
var SUBSCRIPTIONS_ERROR__INVALID_ACCOUNT_DISCRIMINATOR = 117;
|
|
2323
|
+
var SUBSCRIPTIONS_ERROR__MINT_HAS_CONFIDENTIAL_TRANSFER = 118;
|
|
2324
|
+
var SUBSCRIPTIONS_ERROR__MINT_HAS_NON_TRANSFERABLE = 119;
|
|
2325
|
+
var SUBSCRIPTIONS_ERROR__MINT_HAS_PERMANENT_DELEGATE = 120;
|
|
2326
|
+
var SUBSCRIPTIONS_ERROR__MINT_HAS_TRANSFER_HOOK = 121;
|
|
2327
|
+
var SUBSCRIPTIONS_ERROR__MINT_HAS_TRANSFER_FEE = 122;
|
|
2328
|
+
var SUBSCRIPTIONS_ERROR__MINT_HAS_MINT_CLOSE_AUTHORITY = 123;
|
|
2329
|
+
var SUBSCRIPTIONS_ERROR__MINT_HAS_PAUSABLE = 124;
|
|
2330
|
+
var SUBSCRIPTIONS_ERROR__MINT_MISMATCH = 125;
|
|
2331
|
+
var SUBSCRIPTIONS_ERROR__INVALID_DELEGATE_PDA = 126;
|
|
2332
|
+
var SUBSCRIPTIONS_ERROR__INVALID_HEADER_DATA = 127;
|
|
2333
|
+
var SUBSCRIPTIONS_ERROR__DELEGATION_EXPIRED = 128;
|
|
2334
|
+
var SUBSCRIPTIONS_ERROR__INVALID_AMOUNT = 129;
|
|
2335
|
+
var SUBSCRIPTIONS_ERROR__UNAUTHORIZED = 130;
|
|
2336
|
+
var SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE = 131;
|
|
2337
|
+
var SUBSCRIPTIONS_ERROR__ATA_OWNER_MISMATCH = 132;
|
|
2338
|
+
var SUBSCRIPTIONS_ERROR__DELEGATION_VERSION_MISMATCH = 133;
|
|
2339
|
+
var SUBSCRIPTIONS_ERROR__MIGRATION_REQUIRED = 134;
|
|
2340
|
+
var SUBSCRIPTIONS_ERROR__DELEGATION_ALREADY_EXISTS = 135;
|
|
2341
|
+
var SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY = 136;
|
|
2342
|
+
var SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_LIMIT = 300;
|
|
2343
|
+
var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_EXPIRY_IN_PAST = 301;
|
|
2344
|
+
var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_AMOUNT_ZERO = 302;
|
|
2345
|
+
var SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_PERIOD_LIMIT = 400;
|
|
2346
|
+
var SUBSCRIPTIONS_ERROR__PERIOD_NOT_ELAPSED = 401;
|
|
2347
|
+
var SUBSCRIPTIONS_ERROR__INVALID_PERIOD_LENGTH = 402;
|
|
2348
|
+
var SUBSCRIPTIONS_ERROR__INVALID_PAYER_DATA = 403;
|
|
2349
|
+
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST = 404;
|
|
2350
|
+
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY = 405;
|
|
2351
|
+
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO = 406;
|
|
2352
|
+
var SUBSCRIPTIONS_ERROR__DELEGATION_NOT_STARTED = 407;
|
|
2353
|
+
var SUBSCRIPTIONS_ERROR__PLAN_SUNSET = 500;
|
|
2354
|
+
var SUBSCRIPTIONS_ERROR__PLAN_EXPIRED = 501;
|
|
2355
|
+
var SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA = 502;
|
|
2356
|
+
var SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_PDA = 503;
|
|
2357
|
+
var SUBSCRIPTIONS_ERROR__NOT_PLAN_OWNER = 504;
|
|
2358
|
+
var SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH = 505;
|
|
2359
|
+
var SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION = 506;
|
|
2360
|
+
var SUBSCRIPTIONS_ERROR__INVALID_NUM_DESTINATIONS = 507;
|
|
2361
|
+
var SUBSCRIPTIONS_ERROR__SUBSCRIPTION_CANCELLED = 508;
|
|
2362
|
+
var SUBSCRIPTIONS_ERROR__SUBSCRIPTION_ALREADY_CANCELLED = 509;
|
|
2363
|
+
var SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED = 510;
|
|
2364
|
+
var SUBSCRIPTIONS_ERROR__INVALID_END_TS = 511;
|
|
2365
|
+
var SUBSCRIPTIONS_ERROR__INVALID_PLAN_STATUS = 512;
|
|
2366
|
+
var SUBSCRIPTIONS_ERROR__PLAN_IMMUTABLE_AFTER_SUNSET = 513;
|
|
2367
|
+
var SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS = 514;
|
|
2368
|
+
var SUBSCRIPTIONS_ERROR__PLAN_NOT_EXPIRED = 515;
|
|
2369
|
+
var SUBSCRIPTIONS_ERROR__PLAN_CLOSED = 516;
|
|
2370
|
+
var SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED = 517;
|
|
2371
|
+
var SUBSCRIPTIONS_ERROR__PLAN_ALREADY_EXISTS = 518;
|
|
2372
|
+
var SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH = 519;
|
|
2373
|
+
var SUBSCRIPTIONS_ERROR__INVALID_EVENT_AUTHORITY = 600;
|
|
2374
|
+
var SUBSCRIPTIONS_ERROR__INVALID_EVENT_DATA = 601;
|
|
2375
|
+
var SUBSCRIPTIONS_ERROR__INVALID_EVENT_TAG = 602;
|
|
2376
|
+
var SUBSCRIPTIONS_ERROR__INVALID_EVENT_DISCRIMINATOR = 603;
|
|
2377
|
+
var subscriptionsErrorMessages;
|
|
2378
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
2379
|
+
subscriptionsErrorMessages = {
|
|
2380
|
+
[SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE]: `Account must be writable`,
|
|
2381
|
+
[SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED]: `Already subscribed to this plan`,
|
|
2382
|
+
[SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_LIMIT]: `Transfer amount exceeds delegation limit`,
|
|
2383
|
+
[SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_PERIOD_LIMIT]: `Transfer amount exceeds period limit`,
|
|
2384
|
+
[SUBSCRIPTIONS_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic Overflow`,
|
|
2385
|
+
[SUBSCRIPTIONS_ERROR__ARITHMETIC_UNDERFLOW]: `Arithmetic Underflow`,
|
|
2386
|
+
[SUBSCRIPTIONS_ERROR__ATA_OWNER_MISMATCH]: `Token account owner does not match expected`,
|
|
2387
|
+
[SUBSCRIPTIONS_ERROR__DELEGATION_ALREADY_EXISTS]: `Delegation account already exists`,
|
|
2388
|
+
[SUBSCRIPTIONS_ERROR__DELEGATION_EXPIRED]: `Delegation has expired`,
|
|
2389
|
+
[SUBSCRIPTIONS_ERROR__DELEGATION_NOT_STARTED]: `Delegation period has not started yet`,
|
|
2390
|
+
[SUBSCRIPTIONS_ERROR__DELEGATION_VERSION_MISMATCH]: `Delegation header version is not compatible`,
|
|
2391
|
+
[SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_AMOUNT_ZERO]: `zero amount specified`,
|
|
2392
|
+
[SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_EXPIRY_IN_PAST]: `Expiry time specified is less than current time`,
|
|
2393
|
+
[SUBSCRIPTIONS_ERROR__INVALID_ACCOUNT_DATA]: `Invalid account data`,
|
|
2394
|
+
[SUBSCRIPTIONS_ERROR__INVALID_ACCOUNT_DISCRIMINATOR]: `Invalid account discriminator`,
|
|
2395
|
+
[SUBSCRIPTIONS_ERROR__INVALID_ADDRESS]: `Invalid account address`,
|
|
2396
|
+
[SUBSCRIPTIONS_ERROR__INVALID_AMOUNT]: `Invalid amount specified`,
|
|
2397
|
+
[SUBSCRIPTIONS_ERROR__INVALID_ASSOCIATED_TOKEN_ACCOUNT_DERIVED_ADDRESS]: `Invalid associated token account address`,
|
|
2398
|
+
[SUBSCRIPTIONS_ERROR__INVALID_DELEGATE_PDA]: `Invalid delegation PDA derivation`,
|
|
2399
|
+
[SUBSCRIPTIONS_ERROR__INVALID_END_TS]: `End timestamp must be zero or in the future`,
|
|
2400
|
+
[SUBSCRIPTIONS_ERROR__INVALID_ESCROW_PDA]: `Invalid escrow PDA derivation`,
|
|
2401
|
+
[SUBSCRIPTIONS_ERROR__INVALID_EVENT_AUTHORITY]: `Invalid event authority PDA`,
|
|
2402
|
+
[SUBSCRIPTIONS_ERROR__INVALID_EVENT_DATA]: `Invalid event data`,
|
|
2403
|
+
[SUBSCRIPTIONS_ERROR__INVALID_EVENT_DISCRIMINATOR]: `Unknown event discriminator`,
|
|
2404
|
+
[SUBSCRIPTIONS_ERROR__INVALID_EVENT_TAG]: `Invalid event tag prefix`,
|
|
2405
|
+
[SUBSCRIPTIONS_ERROR__INVALID_HEADER_DATA]: `Invalid header data`,
|
|
2406
|
+
[SUBSCRIPTIONS_ERROR__INVALID_INSTRUCTION]: `Invalid instruction`,
|
|
2407
|
+
[SUBSCRIPTIONS_ERROR__INVALID_INSTRUCTION_DATA]: `Invalid instruction data`,
|
|
2408
|
+
[SUBSCRIPTIONS_ERROR__INVALID_NUM_DESTINATIONS]: `No valid destinations provided`,
|
|
2409
|
+
[SUBSCRIPTIONS_ERROR__INVALID_PAYER_DATA]: `Payer provided does not match delegation`,
|
|
2410
|
+
[SUBSCRIPTIONS_ERROR__INVALID_PERIOD_LENGTH]: `Invalid Period length`,
|
|
2411
|
+
[SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA]: `Invalid Plan PDA derivation`,
|
|
2412
|
+
[SUBSCRIPTIONS_ERROR__INVALID_PLAN_STATUS]: `Invalid plan status value`,
|
|
2413
|
+
[SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_AUTHORITY_PDA]: `Invalid subscription-authority PDA derivation`,
|
|
2414
|
+
[SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_PDA]: `Invalid subscription PDA derivation`,
|
|
2415
|
+
[SUBSCRIPTIONS_ERROR__INVALID_TOKEN2022_MINT_ACCOUNT_DATA]: `Invalid Token-2022 mint account data`,
|
|
2416
|
+
[SUBSCRIPTIONS_ERROR__INVALID_TOKEN2022_TOKEN_ACCOUNT_DATA]: `Invalid Token-2022 token account data`,
|
|
2417
|
+
[SUBSCRIPTIONS_ERROR__INVALID_TOKEN_PROGRAM]: `Token Program does not match other accounts`,
|
|
2418
|
+
[SUBSCRIPTIONS_ERROR__INVALID_TOKEN_SPL_MINT_ACCOUNT_DATA]: `Invalid SPL Token mint account data`,
|
|
2419
|
+
[SUBSCRIPTIONS_ERROR__INVALID_TOKEN_SPL_TOKEN_ACCOUNT_DATA]: `Invalid SPL Token account data`,
|
|
2420
|
+
[SUBSCRIPTIONS_ERROR__MIGRATION_REQUIRED]: `Account requires explicit migration`,
|
|
2421
|
+
[SUBSCRIPTIONS_ERROR__MINT_HAS_CONFIDENTIAL_TRANSFER]: `Mint has ConfidentialTransfer extension`,
|
|
2422
|
+
[SUBSCRIPTIONS_ERROR__MINT_HAS_MINT_CLOSE_AUTHORITY]: `Mint has MintCloseAuthority extension`,
|
|
2423
|
+
[SUBSCRIPTIONS_ERROR__MINT_HAS_NON_TRANSFERABLE]: `Mint has NonTransferable extension`,
|
|
2424
|
+
[SUBSCRIPTIONS_ERROR__MINT_HAS_PAUSABLE]: `Mint has Pausable extension`,
|
|
2425
|
+
[SUBSCRIPTIONS_ERROR__MINT_HAS_PERMANENT_DELEGATE]: `Mint has PermanentDelegate extension`,
|
|
2426
|
+
[SUBSCRIPTIONS_ERROR__MINT_HAS_TRANSFER_FEE]: `Mint has TransferFee extension`,
|
|
2427
|
+
[SUBSCRIPTIONS_ERROR__MINT_HAS_TRANSFER_HOOK]: `Mint has TransferHook extension`,
|
|
2428
|
+
[SUBSCRIPTIONS_ERROR__MINT_MISMATCH]: `Token mint mismatch`,
|
|
2429
|
+
[SUBSCRIPTIONS_ERROR__NOT_ENOUGH_ACCOUNT_KEYS]: `Not enough account keys provided`,
|
|
2430
|
+
[SUBSCRIPTIONS_ERROR__NOT_PLAN_OWNER]: `Caller is not the plan owner`,
|
|
2431
|
+
[SUBSCRIPTIONS_ERROR__NOT_SIGNER]: `Account must be a signer`,
|
|
2432
|
+
[SUBSCRIPTIONS_ERROR__NOT_SYSTEM_PROGRAM]: `Expected system program`,
|
|
2433
|
+
[SUBSCRIPTIONS_ERROR__PERIOD_NOT_ELAPSED]: `Period has not elapsed yet`,
|
|
2434
|
+
[SUBSCRIPTIONS_ERROR__PLAN_ALREADY_EXISTS]: `Plan account already exists`,
|
|
2435
|
+
[SUBSCRIPTIONS_ERROR__PLAN_CLOSED]: `Plan account has been closed`,
|
|
2436
|
+
[SUBSCRIPTIONS_ERROR__PLAN_EXPIRED]: `Plan has expired`,
|
|
2437
|
+
[SUBSCRIPTIONS_ERROR__PLAN_IMMUTABLE_AFTER_SUNSET]: `Plan cannot be updated after sunset`,
|
|
2438
|
+
[SUBSCRIPTIONS_ERROR__PLAN_NOT_EXPIRED]: `Plan must be expired to delete`,
|
|
2439
|
+
[SUBSCRIPTIONS_ERROR__PLAN_SUNSET]: `Plan is in sunset status`,
|
|
2440
|
+
[SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH]: `Subscription plan terms do not match the current plan`,
|
|
2441
|
+
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO]: `zero amount specified`,
|
|
2442
|
+
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY]: `start time specified is greater than expiry`,
|
|
2443
|
+
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST]: `Past start time specified`,
|
|
2444
|
+
[SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY]: `Delegation init_id does not match current SubscriptionAuthority`,
|
|
2445
|
+
[SUBSCRIPTIONS_ERROR__SUBSCRIPTION_ALREADY_CANCELLED]: `Subscription already cancelled`,
|
|
2446
|
+
[SUBSCRIPTIONS_ERROR__SUBSCRIPTION_CANCELLED]: `Subscription cancelled and past valid period`,
|
|
2447
|
+
[SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED]: `Subscription must be cancelled before revoke`,
|
|
2448
|
+
[SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH]: `Subscription does not belong to this plan`,
|
|
2449
|
+
[SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS]: `Sunset requires a non-zero end timestamp`,
|
|
2450
|
+
[SUBSCRIPTIONS_ERROR__UNAUTHORIZED]: `Caller not authorized for this action`,
|
|
2451
|
+
[SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION]: `Destination not in plan whitelist`
|
|
2452
|
+
};
|
|
2453
|
+
}
|
|
2454
|
+
function getSubscriptionsErrorMessage(code) {
|
|
2455
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
2456
|
+
return subscriptionsErrorMessages[code];
|
|
2457
|
+
}
|
|
2458
|
+
return "Error message not available in production bundles.";
|
|
2459
|
+
}
|
|
2460
|
+
function isSubscriptionsError(error, transactionMessage, code) {
|
|
2461
|
+
return isProgramError(error, transactionMessage, SUBSCRIPTIONS_PROGRAM_ADDRESS, code);
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
// src/constants.ts
|
|
2465
|
+
var PROGRAM_ID = SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2466
|
+
var CURRENT_PROGRAM_VERSION = 1;
|
|
2467
|
+
var ZERO_ADDRESS = "11111111111111111111111111111111";
|
|
2468
|
+
var DISCRIMINATOR_OFFSET = 0;
|
|
2469
|
+
var DELEGATOR_OFFSET = 3;
|
|
2470
|
+
var DELEGATEE_OFFSET = 35;
|
|
2471
|
+
var U64_BYTE_SIZE = 8;
|
|
2472
|
+
var SUBSCRIPTION_AUTHORITY_SEED = "SubscriptionAuthority";
|
|
2473
|
+
var DELEGATION_SEED = "delegation";
|
|
2474
|
+
var PLAN_SEED = "plan";
|
|
2475
|
+
var SUBSCRIPTION_SEED = "subscription";
|
|
2476
|
+
var EVENT_AUTHORITY_SEED = "event_authority";
|
|
2477
|
+
var PLAN_SIZE = 491;
|
|
2478
|
+
var SUBSCRIPTION_SIZE = 155;
|
|
2479
|
+
var PLAN_OWNER_OFFSET = 1;
|
|
2480
|
+
var MAX_PLAN_DESTINATIONS = 4;
|
|
2481
|
+
var MAX_PLAN_PULLERS = 4;
|
|
2482
|
+
var METADATA_URI_LEN = 128;
|
|
2483
|
+
|
|
2484
|
+
// src/accounts/decode.ts
|
|
2485
|
+
function toEncodedAccount(raw, programAddress) {
|
|
2486
|
+
const base64Encoder = getBase64Encoder();
|
|
2487
|
+
const data = base64Encoder.encode(raw.account.data[0]);
|
|
2488
|
+
return {
|
|
2489
|
+
address: raw.pubkey,
|
|
2490
|
+
data,
|
|
2491
|
+
executable: raw.account.executable,
|
|
2492
|
+
lamports: raw.account.lamports,
|
|
2493
|
+
programAddress,
|
|
2494
|
+
space: raw.account.space
|
|
2495
|
+
};
|
|
2496
|
+
}
|
|
2497
|
+
function decodeDelegationAccount(raw, programAddress) {
|
|
2498
|
+
const encoded = toEncodedAccount(raw, programAddress);
|
|
2499
|
+
const kind = encoded.data[DISCRIMINATOR_OFFSET];
|
|
2500
|
+
switch (kind) {
|
|
2501
|
+
case 2 /* FixedDelegation */: {
|
|
2502
|
+
const decoded = decodeFixedDelegation(encoded);
|
|
2503
|
+
return {
|
|
2504
|
+
address: raw.pubkey,
|
|
2505
|
+
data: decoded.data,
|
|
2506
|
+
kind: "fixed"
|
|
2507
|
+
};
|
|
2508
|
+
}
|
|
2509
|
+
case 3 /* RecurringDelegation */: {
|
|
2510
|
+
const decoded = decodeRecurringDelegation(encoded);
|
|
2511
|
+
return {
|
|
2512
|
+
address: raw.pubkey,
|
|
2513
|
+
data: decoded.data,
|
|
2514
|
+
kind: "recurring"
|
|
2515
|
+
};
|
|
2516
|
+
}
|
|
2517
|
+
case 4 /* SubscriptionDelegation */: {
|
|
2518
|
+
const decoded = decodeSubscriptionDelegation(encoded);
|
|
2519
|
+
return {
|
|
2520
|
+
address: raw.pubkey,
|
|
2521
|
+
data: decoded.data,
|
|
2522
|
+
kind: "subscription"
|
|
2523
|
+
};
|
|
2524
|
+
}
|
|
2525
|
+
default:
|
|
2526
|
+
console.warn(`Unknown delegation discriminator: ${kind}`);
|
|
2527
|
+
return null;
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
// src/accounts/delegations.ts
|
|
2532
|
+
async function fetchDelegationsByDelegator(rpc, wallet, programAddress) {
|
|
2533
|
+
return await fetchDelegationsByOffset(rpc, wallet, DELEGATOR_OFFSET, programAddress);
|
|
2534
|
+
}
|
|
2535
|
+
async function fetchDelegationsByDelegatee(rpc, wallet, programAddress) {
|
|
2536
|
+
return await fetchDelegationsByOffset(rpc, wallet, DELEGATEE_OFFSET, programAddress);
|
|
2537
|
+
}
|
|
2538
|
+
async function fetchDelegationsByOffset(rpc, wallet, offset, programAddress) {
|
|
2539
|
+
const progAddr = programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2540
|
+
const response = await rpc.getProgramAccounts(progAddr, {
|
|
2541
|
+
encoding: "base64",
|
|
2542
|
+
filters: [
|
|
2543
|
+
{
|
|
2544
|
+
memcmp: {
|
|
2545
|
+
bytes: wallet,
|
|
2546
|
+
encoding: "base58",
|
|
2547
|
+
offset: BigInt(offset)
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
]
|
|
2551
|
+
}).send();
|
|
2552
|
+
return response.map((account) => decodeDelegationAccount(account, progAddr)).filter((d) => d !== null);
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2555
|
+
// src/accounts/plans.ts
|
|
2556
|
+
async function fetchPlansForOwner(rpc, owner, programAddress) {
|
|
2557
|
+
const progAddr = programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2558
|
+
const response = await rpc.getProgramAccounts(progAddr, {
|
|
2559
|
+
encoding: "base64",
|
|
2560
|
+
filters: [
|
|
2561
|
+
{ dataSize: BigInt(PLAN_SIZE) },
|
|
2562
|
+
{
|
|
2563
|
+
memcmp: {
|
|
2564
|
+
bytes: owner,
|
|
2565
|
+
encoding: "base58",
|
|
2566
|
+
offset: BigInt(PLAN_OWNER_OFFSET)
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
]
|
|
2570
|
+
}).send();
|
|
2571
|
+
return response.map((account) => {
|
|
2572
|
+
const encoded = toEncodedAccount(account, progAddr);
|
|
2573
|
+
const { address, data } = decodePlan(encoded);
|
|
2574
|
+
return { address, data };
|
|
2575
|
+
});
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
// src/accounts/subscriptions.ts
|
|
2579
|
+
async function fetchSubscriptionsForUser(rpc, user, programAddress) {
|
|
2580
|
+
const progAddr = programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2581
|
+
const response = await rpc.getProgramAccounts(progAddr, {
|
|
2582
|
+
encoding: "base64",
|
|
2583
|
+
filters: [
|
|
2584
|
+
{ dataSize: BigInt(SUBSCRIPTION_SIZE) },
|
|
2585
|
+
{
|
|
2586
|
+
memcmp: {
|
|
2587
|
+
bytes: user,
|
|
2588
|
+
encoding: "base58",
|
|
2589
|
+
offset: BigInt(DELEGATOR_OFFSET)
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
]
|
|
2593
|
+
}).send();
|
|
2594
|
+
return response.map((account) => {
|
|
2595
|
+
const raw = account;
|
|
2596
|
+
const encoded = toEncodedAccount(raw, progAddr);
|
|
2597
|
+
const decoded = decodeSubscriptionDelegation(encoded);
|
|
2598
|
+
return { address: raw.pubkey, data: decoded.data };
|
|
2599
|
+
});
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
// src/plugin.ts
|
|
2603
|
+
import {
|
|
2604
|
+
AccountRole,
|
|
2605
|
+
pipe
|
|
2606
|
+
} from "@solana/kit";
|
|
2607
|
+
import { addSelfPlanAndSendFunctions as addSelfPlanAndSendFunctions2 } from "@solana/program-client-core";
|
|
2608
|
+
import { findAssociatedTokenPda } from "@solana-program/token";
|
|
2609
|
+
|
|
2610
|
+
// src/validators.ts
|
|
2611
|
+
var textEncoder = new TextEncoder();
|
|
2612
|
+
var ValidationError = class extends Error {
|
|
2613
|
+
constructor(message) {
|
|
2614
|
+
super(message);
|
|
2615
|
+
this.name = "ValidationError";
|
|
2616
|
+
}
|
|
2617
|
+
};
|
|
2618
|
+
function assertPositive(value, name) {
|
|
2619
|
+
if (BigInt(value) <= 0n) throw new ValidationError(`${name} must be greater than zero`);
|
|
2620
|
+
}
|
|
2621
|
+
function assertMetadataUri(metadataUri) {
|
|
2622
|
+
if (textEncoder.encode(metadataUri).length > METADATA_URI_LEN)
|
|
2623
|
+
throw new ValidationError(`metadataUri exceeds ${METADATA_URI_LEN} bytes`);
|
|
2624
|
+
}
|
|
2625
|
+
function assertMaxLen(arr, max, name) {
|
|
2626
|
+
if (arr.length > max) throw new ValidationError(`${name} must have at most ${max} entries`);
|
|
2627
|
+
}
|
|
2628
|
+
function padAddresses(addresses, maxLen) {
|
|
2629
|
+
return Array.from({ length: maxLen }, (_, i) => addresses[i] ?? ZERO_ADDRESS);
|
|
2630
|
+
}
|
|
2631
|
+
function padPlanDestinations(addresses) {
|
|
2632
|
+
assertMaxLen(addresses, MAX_PLAN_DESTINATIONS, "destinations");
|
|
2633
|
+
return padAddresses(addresses, MAX_PLAN_DESTINATIONS);
|
|
2634
|
+
}
|
|
2635
|
+
function padPlanPullers(addresses) {
|
|
2636
|
+
assertMaxLen(addresses, MAX_PLAN_PULLERS, "pullers");
|
|
2637
|
+
return padAddresses(addresses, MAX_PLAN_PULLERS);
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
// src/plugin.ts
|
|
2641
|
+
function pdaConfig(programAddress) {
|
|
2642
|
+
return programAddress ? { programAddress } : {};
|
|
2643
|
+
}
|
|
2644
|
+
function withTrailing(instruction, trailing) {
|
|
2645
|
+
if (trailing.length === 0) return instruction;
|
|
2646
|
+
const accounts = [
|
|
2647
|
+
...instruction.accounts ?? [],
|
|
2648
|
+
...trailing
|
|
2649
|
+
];
|
|
2650
|
+
return { ...instruction, accounts };
|
|
2651
|
+
}
|
|
2652
|
+
function appendPayer(instruction, payer) {
|
|
2653
|
+
if (!payer) return instruction;
|
|
2654
|
+
return withTrailing(instruction, [
|
|
2655
|
+
{
|
|
2656
|
+
address: payer.address,
|
|
2657
|
+
role: AccountRole.WRITABLE_SIGNER,
|
|
2658
|
+
signer: payer
|
|
2659
|
+
}
|
|
2660
|
+
]);
|
|
2661
|
+
}
|
|
2662
|
+
async function getInitSubscriptionAuthorityOverlayInstructionAsync(input) {
|
|
2663
|
+
return appendPayer(
|
|
2664
|
+
await getInitSubscriptionAuthorityInstructionAsync(
|
|
2665
|
+
{
|
|
2666
|
+
owner: input.owner,
|
|
2667
|
+
tokenMint: input.tokenMint,
|
|
2668
|
+
tokenProgram: input.tokenProgram,
|
|
2669
|
+
userAta: input.userAta
|
|
2670
|
+
},
|
|
2671
|
+
pdaConfig(input.programAddress)
|
|
2672
|
+
),
|
|
2673
|
+
input.payer
|
|
2674
|
+
);
|
|
2675
|
+
}
|
|
2676
|
+
async function getCloseSubscriptionAuthorityOverlayInstructionAsync(input) {
|
|
2677
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
2678
|
+
{ tokenMint: input.tokenMint, user: input.user.address },
|
|
2679
|
+
pdaConfig(input.programAddress)
|
|
2680
|
+
);
|
|
2681
|
+
let ix = getCloseSubscriptionAuthorityInstruction(
|
|
2682
|
+
{ subscriptionAuthority, user: input.user },
|
|
2683
|
+
pdaConfig(input.programAddress)
|
|
2684
|
+
);
|
|
2685
|
+
if (input.receiver) {
|
|
2686
|
+
ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole.WRITABLE }]);
|
|
2687
|
+
}
|
|
2688
|
+
return ix;
|
|
2689
|
+
}
|
|
2690
|
+
async function getCreateFixedDelegationOverlayInstructionAsync(input) {
|
|
2691
|
+
assertPositive(input.amount, "amount");
|
|
2692
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
2693
|
+
{ tokenMint: input.tokenMint, user: input.delegator.address },
|
|
2694
|
+
pdaConfig(input.programAddress)
|
|
2695
|
+
);
|
|
2696
|
+
const [delegationPda] = await findFixedDelegationPda(
|
|
2697
|
+
{
|
|
2698
|
+
delegatee: input.delegatee,
|
|
2699
|
+
delegator: input.delegator.address,
|
|
2700
|
+
nonce: input.nonce,
|
|
2701
|
+
subscriptionAuthority
|
|
2702
|
+
},
|
|
2703
|
+
pdaConfig(input.programAddress)
|
|
2704
|
+
);
|
|
2705
|
+
return appendPayer(
|
|
2706
|
+
getCreateFixedDelegationInstruction(
|
|
2707
|
+
{
|
|
2708
|
+
delegatee: input.delegatee,
|
|
2709
|
+
delegationAccount: delegationPda,
|
|
2710
|
+
delegator: input.delegator,
|
|
2711
|
+
fixedDelegation: {
|
|
2712
|
+
amount: input.amount,
|
|
2713
|
+
expiryTs: input.expiryTs,
|
|
2714
|
+
nonce: input.nonce
|
|
2715
|
+
},
|
|
2716
|
+
subscriptionAuthority
|
|
2717
|
+
},
|
|
2718
|
+
pdaConfig(input.programAddress)
|
|
2719
|
+
),
|
|
2720
|
+
input.payer
|
|
2721
|
+
);
|
|
2722
|
+
}
|
|
2723
|
+
async function getCreateRecurringDelegationOverlayInstructionAsync(input) {
|
|
2724
|
+
assertPositive(input.amountPerPeriod, "amountPerPeriod");
|
|
2725
|
+
assertPositive(input.periodLengthS, "periodLengthS");
|
|
2726
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
2727
|
+
{ tokenMint: input.tokenMint, user: input.delegator.address },
|
|
2728
|
+
pdaConfig(input.programAddress)
|
|
2729
|
+
);
|
|
2730
|
+
const [delegationPda] = await findRecurringDelegationPda(
|
|
2731
|
+
{
|
|
2732
|
+
delegatee: input.delegatee,
|
|
2733
|
+
delegator: input.delegator.address,
|
|
2734
|
+
nonce: input.nonce,
|
|
2735
|
+
subscriptionAuthority
|
|
2736
|
+
},
|
|
2737
|
+
pdaConfig(input.programAddress)
|
|
2738
|
+
);
|
|
2739
|
+
return appendPayer(
|
|
2740
|
+
getCreateRecurringDelegationInstruction(
|
|
2741
|
+
{
|
|
2742
|
+
delegatee: input.delegatee,
|
|
2743
|
+
delegationAccount: delegationPda,
|
|
2744
|
+
delegator: input.delegator,
|
|
2745
|
+
recurringDelegation: {
|
|
2746
|
+
amountPerPeriod: input.amountPerPeriod,
|
|
2747
|
+
expiryTs: input.expiryTs,
|
|
2748
|
+
nonce: input.nonce,
|
|
2749
|
+
periodLengthS: input.periodLengthS,
|
|
2750
|
+
startTs: input.startTs
|
|
2751
|
+
},
|
|
2752
|
+
subscriptionAuthority
|
|
2753
|
+
},
|
|
2754
|
+
pdaConfig(input.programAddress)
|
|
2755
|
+
),
|
|
2756
|
+
input.payer
|
|
2757
|
+
);
|
|
2758
|
+
}
|
|
2759
|
+
function getRevokeDelegationOverlayInstruction(input) {
|
|
2760
|
+
let ix = getRevokeDelegationInstruction(
|
|
2761
|
+
{
|
|
2762
|
+
authority: input.authority,
|
|
2763
|
+
delegationAccount: input.delegationAccount
|
|
2764
|
+
},
|
|
2765
|
+
pdaConfig(input.programAddress)
|
|
2766
|
+
);
|
|
2767
|
+
if (input.receiver) {
|
|
2768
|
+
ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole.WRITABLE }]);
|
|
2769
|
+
}
|
|
2770
|
+
return ix;
|
|
2771
|
+
}
|
|
2772
|
+
function getRevokeSubscriptionOverlayInstruction(input) {
|
|
2773
|
+
const trailing = [{ address: input.planPda, role: AccountRole.READONLY }];
|
|
2774
|
+
if (input.receiver) {
|
|
2775
|
+
trailing.push({ address: input.receiver, role: AccountRole.WRITABLE });
|
|
2776
|
+
}
|
|
2777
|
+
return withTrailing(
|
|
2778
|
+
getRevokeDelegationInstruction(
|
|
2779
|
+
{
|
|
2780
|
+
authority: input.authority,
|
|
2781
|
+
delegationAccount: input.subscriptionPda
|
|
2782
|
+
},
|
|
2783
|
+
pdaConfig(input.programAddress)
|
|
2784
|
+
),
|
|
2785
|
+
trailing
|
|
2786
|
+
);
|
|
2787
|
+
}
|
|
2788
|
+
async function getTransferDelegationOverlayInstructionAsync(input, getInstruction) {
|
|
2789
|
+
assertPositive(input.amount, "amount");
|
|
2790
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
2791
|
+
{ tokenMint: input.tokenMint, user: input.delegator },
|
|
2792
|
+
pdaConfig(input.programAddress)
|
|
2793
|
+
);
|
|
2794
|
+
return getInstruction(
|
|
2795
|
+
{
|
|
2796
|
+
delegatee: input.delegatee,
|
|
2797
|
+
delegationPda: input.delegationPda,
|
|
2798
|
+
delegatorAta: input.delegatorAta,
|
|
2799
|
+
receiverAta: input.receiverAta,
|
|
2800
|
+
subscriptionAuthority,
|
|
2801
|
+
tokenProgram: input.tokenProgram,
|
|
2802
|
+
transferData: {
|
|
2803
|
+
amount: input.amount,
|
|
2804
|
+
delegator: input.delegator,
|
|
2805
|
+
mint: input.tokenMint
|
|
2806
|
+
}
|
|
2807
|
+
},
|
|
2808
|
+
pdaConfig(input.programAddress)
|
|
2809
|
+
);
|
|
2810
|
+
}
|
|
2811
|
+
function getTransferFixedOverlayInstructionAsync(input) {
|
|
2812
|
+
return getTransferDelegationOverlayInstructionAsync(input, getTransferFixedInstruction);
|
|
2813
|
+
}
|
|
2814
|
+
function getTransferRecurringOverlayInstructionAsync(input) {
|
|
2815
|
+
return getTransferDelegationOverlayInstructionAsync(input, getTransferRecurringInstruction);
|
|
2816
|
+
}
|
|
2817
|
+
async function getTransferSubscriptionOverlayInstructionAsync(input) {
|
|
2818
|
+
assertPositive(input.amount, "amount");
|
|
2819
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
2820
|
+
{ tokenMint: input.tokenMint, user: input.delegator },
|
|
2821
|
+
pdaConfig(input.programAddress)
|
|
2822
|
+
);
|
|
2823
|
+
const [delegatorAta] = await findAssociatedTokenPda({
|
|
2824
|
+
mint: input.tokenMint,
|
|
2825
|
+
owner: input.delegator,
|
|
2826
|
+
tokenProgram: input.tokenProgram
|
|
2827
|
+
});
|
|
2828
|
+
return getTransferSubscriptionInstruction(
|
|
2829
|
+
{
|
|
2830
|
+
caller: input.caller,
|
|
2831
|
+
delegatorAta,
|
|
2832
|
+
planPda: input.planPda,
|
|
2833
|
+
receiverAta: input.receiverAta,
|
|
2834
|
+
subscriptionAuthority,
|
|
2835
|
+
subscriptionPda: input.subscriptionPda,
|
|
2836
|
+
tokenProgram: input.tokenProgram,
|
|
2837
|
+
transferData: {
|
|
2838
|
+
amount: input.amount,
|
|
2839
|
+
delegator: input.delegator,
|
|
2840
|
+
mint: input.tokenMint
|
|
2841
|
+
}
|
|
2842
|
+
},
|
|
2843
|
+
pdaConfig(input.programAddress)
|
|
2844
|
+
);
|
|
2845
|
+
}
|
|
2846
|
+
async function getCreatePlanOverlayInstructionAsync(input) {
|
|
2847
|
+
assertPositive(input.amount, "amount");
|
|
2848
|
+
assertPositive(input.periodHours, "periodHours");
|
|
2849
|
+
assertMetadataUri(input.metadataUri);
|
|
2850
|
+
const destinations = padPlanDestinations(input.destinations);
|
|
2851
|
+
const pullers = padPlanPullers(input.pullers);
|
|
2852
|
+
const [planPda] = await findPlanPda(
|
|
2853
|
+
{ owner: input.owner.address, planId: input.planId },
|
|
2854
|
+
pdaConfig(input.programAddress)
|
|
2855
|
+
);
|
|
2856
|
+
return getCreatePlanInstruction(
|
|
2857
|
+
{
|
|
2858
|
+
merchant: input.owner,
|
|
2859
|
+
planData: {
|
|
2860
|
+
destinations,
|
|
2861
|
+
endTs: input.endTs,
|
|
2862
|
+
metadataUri: input.metadataUri,
|
|
2863
|
+
mint: input.mint,
|
|
2864
|
+
planId: input.planId,
|
|
2865
|
+
pullers,
|
|
2866
|
+
terms: {
|
|
2867
|
+
amount: input.amount,
|
|
2868
|
+
createdAt: 0n,
|
|
2869
|
+
periodHours: input.periodHours
|
|
2870
|
+
}
|
|
2871
|
+
},
|
|
2872
|
+
planPda,
|
|
2873
|
+
tokenMint: input.mint,
|
|
2874
|
+
tokenProgram: input.tokenProgram
|
|
2875
|
+
},
|
|
2876
|
+
pdaConfig(input.programAddress)
|
|
2877
|
+
);
|
|
2878
|
+
}
|
|
2879
|
+
function getUpdatePlanOverlayInstruction(input) {
|
|
2880
|
+
assertMetadataUri(input.metadataUri);
|
|
2881
|
+
const pullers = padPlanPullers(input.pullers ?? []);
|
|
2882
|
+
return getUpdatePlanInstruction(
|
|
2883
|
+
{
|
|
2884
|
+
owner: input.owner,
|
|
2885
|
+
planPda: input.planPda,
|
|
2886
|
+
updatePlanData: {
|
|
2887
|
+
endTs: input.endTs,
|
|
2888
|
+
metadataUri: input.metadataUri,
|
|
2889
|
+
pullers,
|
|
2890
|
+
status: input.status
|
|
2891
|
+
}
|
|
2892
|
+
},
|
|
2893
|
+
pdaConfig(input.programAddress)
|
|
2894
|
+
);
|
|
2895
|
+
}
|
|
2896
|
+
function getDeletePlanOverlayInstruction(input) {
|
|
2897
|
+
return getDeletePlanInstruction({ owner: input.owner, planPda: input.planPda }, pdaConfig(input.programAddress));
|
|
2898
|
+
}
|
|
2899
|
+
async function getSubscribeOverlayInstructionAsync(input) {
|
|
2900
|
+
if (input.expectedAmount === void 0 || input.expectedPeriodHours === void 0 || input.expectedCreatedAt === void 0) {
|
|
2901
|
+
throw new Error(
|
|
2902
|
+
"getSubscribeOverlayInstructionAsync requires expectedAmount, expectedPeriodHours, and expectedCreatedAt. Use the plugin client `subscriptions.instructions.subscribe(...)` to auto-fetch from the live plan."
|
|
2903
|
+
);
|
|
2904
|
+
}
|
|
2905
|
+
const [planPda, planBump] = await findPlanPda(
|
|
2906
|
+
{ owner: input.merchant, planId: input.planId },
|
|
2907
|
+
pdaConfig(input.programAddress)
|
|
2908
|
+
);
|
|
2909
|
+
const [subscriptionAuthorityPda] = await findSubscriptionAuthorityPda(
|
|
2910
|
+
{ tokenMint: input.tokenMint, user: input.subscriber.address },
|
|
2911
|
+
pdaConfig(input.programAddress)
|
|
2912
|
+
);
|
|
2913
|
+
return appendPayer(
|
|
2914
|
+
await getSubscribeInstructionAsync(
|
|
2915
|
+
{
|
|
2916
|
+
merchant: input.merchant,
|
|
2917
|
+
planPda,
|
|
2918
|
+
subscribeData: {
|
|
2919
|
+
expectedAmount: input.expectedAmount,
|
|
2920
|
+
expectedCreatedAt: input.expectedCreatedAt,
|
|
2921
|
+
expectedMint: input.tokenMint,
|
|
2922
|
+
expectedPeriodHours: input.expectedPeriodHours,
|
|
2923
|
+
planBump,
|
|
2924
|
+
planId: input.planId
|
|
2925
|
+
},
|
|
2926
|
+
subscriber: input.subscriber,
|
|
2927
|
+
subscriptionAuthorityPda
|
|
2928
|
+
},
|
|
2929
|
+
pdaConfig(input.programAddress)
|
|
2930
|
+
),
|
|
2931
|
+
input.payer
|
|
2932
|
+
);
|
|
2933
|
+
}
|
|
2934
|
+
function getCancelSubscriptionOverlayInstructionAsync(input) {
|
|
2935
|
+
return getCancelSubscriptionInstructionAsync(
|
|
2936
|
+
{
|
|
2937
|
+
planPda: input.planPda,
|
|
2938
|
+
subscriber: input.subscriber,
|
|
2939
|
+
subscriptionPda: input.subscriptionPda
|
|
2940
|
+
},
|
|
2941
|
+
pdaConfig(input.programAddress)
|
|
2942
|
+
);
|
|
2943
|
+
}
|
|
2944
|
+
function subscriptionsProgram2() {
|
|
2945
|
+
return (client) => {
|
|
2946
|
+
return pipe(client, subscriptionsProgram(), (c) => {
|
|
2947
|
+
const queries = {
|
|
2948
|
+
activeDelegationSummary: async (wallet) => {
|
|
2949
|
+
const delegations = await fetchDelegationsByDelegator(c.rpc, wallet);
|
|
2950
|
+
let fixed = 0;
|
|
2951
|
+
let recurring = 0;
|
|
2952
|
+
let subscriptions = 0;
|
|
2953
|
+
for (const d of delegations) {
|
|
2954
|
+
if (d.kind === "fixed") fixed++;
|
|
2955
|
+
else if (d.kind === "recurring") recurring++;
|
|
2956
|
+
else if (d.kind === "subscription") subscriptions++;
|
|
2957
|
+
}
|
|
2958
|
+
return { fixed, recurring, subscriptions, total: delegations.length };
|
|
2959
|
+
},
|
|
2960
|
+
delegationsByDelegatee: (wallet) => fetchDelegationsByDelegatee(c.rpc, wallet),
|
|
2961
|
+
delegationsByDelegator: (wallet) => fetchDelegationsByDelegator(c.rpc, wallet),
|
|
2962
|
+
isSubscriptionAuthorityInitialized: async (user, tokenMint, programAddress) => {
|
|
2963
|
+
const [pda] = await findSubscriptionAuthorityPda({ tokenMint, user }, pdaConfig(programAddress));
|
|
2964
|
+
const account = await fetchMaybeSubscriptionAuthority(c.rpc, pda);
|
|
2965
|
+
return { initialized: account.exists, pda };
|
|
2966
|
+
},
|
|
2967
|
+
plansForOwner: (owner) => fetchPlansForOwner(c.rpc, owner)
|
|
2968
|
+
};
|
|
2969
|
+
const instructions = {
|
|
2970
|
+
cancelSubscription: (input) => addSelfPlanAndSendFunctions2(
|
|
2971
|
+
client,
|
|
2972
|
+
getCancelSubscriptionOverlayInstructionAsync({
|
|
2973
|
+
...input,
|
|
2974
|
+
subscriber: input.subscriber ?? client.identity
|
|
2975
|
+
})
|
|
2976
|
+
),
|
|
2977
|
+
closeSubscriptionAuthority: (input) => addSelfPlanAndSendFunctions2(
|
|
2978
|
+
client,
|
|
2979
|
+
getCloseSubscriptionAuthorityOverlayInstructionAsync({
|
|
2980
|
+
...input,
|
|
2981
|
+
user: input.user ?? client.identity
|
|
2982
|
+
})
|
|
2983
|
+
),
|
|
2984
|
+
createFixedDelegation: (input) => addSelfPlanAndSendFunctions2(
|
|
2985
|
+
client,
|
|
2986
|
+
getCreateFixedDelegationOverlayInstructionAsync({
|
|
2987
|
+
...input,
|
|
2988
|
+
delegator: input.delegator ?? client.identity,
|
|
2989
|
+
payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer)
|
|
2990
|
+
})
|
|
2991
|
+
),
|
|
2992
|
+
createPlan: (input) => addSelfPlanAndSendFunctions2(
|
|
2993
|
+
client,
|
|
2994
|
+
getCreatePlanOverlayInstructionAsync({
|
|
2995
|
+
...input,
|
|
2996
|
+
owner: input.owner ?? client.identity
|
|
2997
|
+
})
|
|
2998
|
+
),
|
|
2999
|
+
createRecurringDelegation: (input) => addSelfPlanAndSendFunctions2(
|
|
3000
|
+
client,
|
|
3001
|
+
getCreateRecurringDelegationOverlayInstructionAsync({
|
|
3002
|
+
...input,
|
|
3003
|
+
delegator: input.delegator ?? client.identity,
|
|
3004
|
+
payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer)
|
|
3005
|
+
})
|
|
3006
|
+
),
|
|
3007
|
+
deletePlan: (input) => addSelfPlanAndSendFunctions2(
|
|
3008
|
+
client,
|
|
3009
|
+
getDeletePlanOverlayInstruction({
|
|
3010
|
+
...input,
|
|
3011
|
+
owner: input.owner ?? client.identity
|
|
3012
|
+
})
|
|
3013
|
+
),
|
|
3014
|
+
initSubscriptionAuthority: (input) => addSelfPlanAndSendFunctions2(
|
|
3015
|
+
client,
|
|
3016
|
+
getInitSubscriptionAuthorityOverlayInstructionAsync({
|
|
3017
|
+
...input,
|
|
3018
|
+
owner: input.owner ?? client.identity,
|
|
3019
|
+
payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer)
|
|
3020
|
+
})
|
|
3021
|
+
),
|
|
3022
|
+
revokeDelegation: (input) => addSelfPlanAndSendFunctions2(
|
|
3023
|
+
client,
|
|
3024
|
+
getRevokeDelegationOverlayInstruction({
|
|
3025
|
+
...input,
|
|
3026
|
+
authority: input.authority ?? client.identity
|
|
3027
|
+
})
|
|
3028
|
+
),
|
|
3029
|
+
revokeSubscription: (input) => addSelfPlanAndSendFunctions2(
|
|
3030
|
+
client,
|
|
3031
|
+
getRevokeSubscriptionOverlayInstruction({
|
|
3032
|
+
...input,
|
|
3033
|
+
authority: input.authority ?? client.identity
|
|
3034
|
+
})
|
|
3035
|
+
),
|
|
3036
|
+
subscribe: (input) => addSelfPlanAndSendFunctions2(
|
|
3037
|
+
client,
|
|
3038
|
+
(async () => {
|
|
3039
|
+
let { expectedAmount, expectedPeriodHours, expectedCreatedAt } = input;
|
|
3040
|
+
if (expectedAmount === void 0 || expectedPeriodHours === void 0 || expectedCreatedAt === void 0) {
|
|
3041
|
+
const subscriber = input.subscriber ?? client.identity;
|
|
3042
|
+
const [planPda] = await findPlanPda(
|
|
3043
|
+
{ owner: input.merchant, planId: input.planId },
|
|
3044
|
+
pdaConfig(input.programAddress)
|
|
3045
|
+
);
|
|
3046
|
+
const plan = await fetchPlan(c.rpc, planPda);
|
|
3047
|
+
expectedAmount = expectedAmount ?? plan.data.data.terms.amount;
|
|
3048
|
+
expectedPeriodHours = expectedPeriodHours ?? plan.data.data.terms.periodHours;
|
|
3049
|
+
expectedCreatedAt = expectedCreatedAt ?? plan.data.data.terms.createdAt;
|
|
3050
|
+
return await getSubscribeOverlayInstructionAsync({
|
|
3051
|
+
...input,
|
|
3052
|
+
expectedAmount,
|
|
3053
|
+
expectedCreatedAt,
|
|
3054
|
+
expectedPeriodHours,
|
|
3055
|
+
payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer),
|
|
3056
|
+
subscriber
|
|
3057
|
+
});
|
|
3058
|
+
}
|
|
3059
|
+
return await getSubscribeOverlayInstructionAsync({
|
|
3060
|
+
...input,
|
|
3061
|
+
expectedAmount,
|
|
3062
|
+
expectedCreatedAt,
|
|
3063
|
+
expectedPeriodHours,
|
|
3064
|
+
payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer),
|
|
3065
|
+
subscriber: input.subscriber ?? client.identity
|
|
3066
|
+
});
|
|
3067
|
+
})()
|
|
3068
|
+
),
|
|
3069
|
+
transferFixed: (input) => addSelfPlanAndSendFunctions2(
|
|
3070
|
+
client,
|
|
3071
|
+
getTransferFixedOverlayInstructionAsync({
|
|
3072
|
+
...input,
|
|
3073
|
+
delegatee: input.delegatee ?? client.identity
|
|
3074
|
+
})
|
|
3075
|
+
),
|
|
3076
|
+
transferRecurring: (input) => addSelfPlanAndSendFunctions2(
|
|
3077
|
+
client,
|
|
3078
|
+
getTransferRecurringOverlayInstructionAsync({
|
|
3079
|
+
...input,
|
|
3080
|
+
delegatee: input.delegatee ?? client.identity
|
|
3081
|
+
})
|
|
3082
|
+
),
|
|
3083
|
+
transferSubscription: (input) => addSelfPlanAndSendFunctions2(
|
|
3084
|
+
client,
|
|
3085
|
+
getTransferSubscriptionOverlayInstructionAsync({
|
|
3086
|
+
...input,
|
|
3087
|
+
caller: input.caller ?? client.identity
|
|
3088
|
+
})
|
|
3089
|
+
),
|
|
3090
|
+
updatePlan: (input) => addSelfPlanAndSendFunctions2(
|
|
3091
|
+
client,
|
|
3092
|
+
getUpdatePlanOverlayInstruction({
|
|
3093
|
+
...input,
|
|
3094
|
+
owner: input.owner ?? client.identity
|
|
3095
|
+
})
|
|
3096
|
+
)
|
|
3097
|
+
};
|
|
3098
|
+
return {
|
|
3099
|
+
...c,
|
|
3100
|
+
subscriptions: {
|
|
3101
|
+
...c.subscriptions,
|
|
3102
|
+
instructions,
|
|
3103
|
+
queries
|
|
3104
|
+
}
|
|
3105
|
+
};
|
|
3106
|
+
});
|
|
3107
|
+
};
|
|
3108
|
+
}
|
|
3109
|
+
export {
|
|
3110
|
+
AccountDiscriminator,
|
|
3111
|
+
CANCEL_SUBSCRIPTION_DISCRIMINATOR,
|
|
3112
|
+
CLOSE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR,
|
|
3113
|
+
CREATE_FIXED_DELEGATION_DISCRIMINATOR,
|
|
3114
|
+
CREATE_PLAN_DISCRIMINATOR,
|
|
3115
|
+
CREATE_RECURRING_DELEGATION_DISCRIMINATOR,
|
|
3116
|
+
CURRENT_PROGRAM_VERSION,
|
|
3117
|
+
DELEGATEE_OFFSET,
|
|
3118
|
+
DELEGATION_SEED,
|
|
3119
|
+
DELEGATOR_OFFSET,
|
|
3120
|
+
DELETE_PLAN_DISCRIMINATOR,
|
|
3121
|
+
DISCRIMINATOR_OFFSET,
|
|
3122
|
+
EVENT_AUTHORITY_SEED,
|
|
3123
|
+
INIT_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR,
|
|
3124
|
+
MAX_PLAN_DESTINATIONS,
|
|
3125
|
+
MAX_PLAN_PULLERS,
|
|
3126
|
+
METADATA_URI_LEN,
|
|
3127
|
+
PLAN_OWNER_OFFSET,
|
|
3128
|
+
PLAN_SEED,
|
|
3129
|
+
PLAN_SIZE,
|
|
3130
|
+
PROGRAM_ID,
|
|
3131
|
+
PlanStatus,
|
|
3132
|
+
REVOKE_DELEGATION_DISCRIMINATOR,
|
|
3133
|
+
SUBSCRIBE_DISCRIMINATOR,
|
|
3134
|
+
SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE,
|
|
3135
|
+
SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED,
|
|
3136
|
+
SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_LIMIT,
|
|
3137
|
+
SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_PERIOD_LIMIT,
|
|
3138
|
+
SUBSCRIPTIONS_ERROR__ARITHMETIC_OVERFLOW,
|
|
3139
|
+
SUBSCRIPTIONS_ERROR__ARITHMETIC_UNDERFLOW,
|
|
3140
|
+
SUBSCRIPTIONS_ERROR__ATA_OWNER_MISMATCH,
|
|
3141
|
+
SUBSCRIPTIONS_ERROR__DELEGATION_ALREADY_EXISTS,
|
|
3142
|
+
SUBSCRIPTIONS_ERROR__DELEGATION_EXPIRED,
|
|
3143
|
+
SUBSCRIPTIONS_ERROR__DELEGATION_NOT_STARTED,
|
|
3144
|
+
SUBSCRIPTIONS_ERROR__DELEGATION_VERSION_MISMATCH,
|
|
3145
|
+
SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_AMOUNT_ZERO,
|
|
3146
|
+
SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_EXPIRY_IN_PAST,
|
|
3147
|
+
SUBSCRIPTIONS_ERROR__INVALID_ACCOUNT_DATA,
|
|
3148
|
+
SUBSCRIPTIONS_ERROR__INVALID_ACCOUNT_DISCRIMINATOR,
|
|
3149
|
+
SUBSCRIPTIONS_ERROR__INVALID_ADDRESS,
|
|
3150
|
+
SUBSCRIPTIONS_ERROR__INVALID_AMOUNT,
|
|
3151
|
+
SUBSCRIPTIONS_ERROR__INVALID_ASSOCIATED_TOKEN_ACCOUNT_DERIVED_ADDRESS,
|
|
3152
|
+
SUBSCRIPTIONS_ERROR__INVALID_DELEGATE_PDA,
|
|
3153
|
+
SUBSCRIPTIONS_ERROR__INVALID_END_TS,
|
|
3154
|
+
SUBSCRIPTIONS_ERROR__INVALID_ESCROW_PDA,
|
|
3155
|
+
SUBSCRIPTIONS_ERROR__INVALID_EVENT_AUTHORITY,
|
|
3156
|
+
SUBSCRIPTIONS_ERROR__INVALID_EVENT_DATA,
|
|
3157
|
+
SUBSCRIPTIONS_ERROR__INVALID_EVENT_DISCRIMINATOR,
|
|
3158
|
+
SUBSCRIPTIONS_ERROR__INVALID_EVENT_TAG,
|
|
3159
|
+
SUBSCRIPTIONS_ERROR__INVALID_HEADER_DATA,
|
|
3160
|
+
SUBSCRIPTIONS_ERROR__INVALID_INSTRUCTION,
|
|
3161
|
+
SUBSCRIPTIONS_ERROR__INVALID_INSTRUCTION_DATA,
|
|
3162
|
+
SUBSCRIPTIONS_ERROR__INVALID_NUM_DESTINATIONS,
|
|
3163
|
+
SUBSCRIPTIONS_ERROR__INVALID_PAYER_DATA,
|
|
3164
|
+
SUBSCRIPTIONS_ERROR__INVALID_PERIOD_LENGTH,
|
|
3165
|
+
SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA,
|
|
3166
|
+
SUBSCRIPTIONS_ERROR__INVALID_PLAN_STATUS,
|
|
3167
|
+
SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_AUTHORITY_PDA,
|
|
3168
|
+
SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_PDA,
|
|
3169
|
+
SUBSCRIPTIONS_ERROR__INVALID_TOKEN2022_MINT_ACCOUNT_DATA,
|
|
3170
|
+
SUBSCRIPTIONS_ERROR__INVALID_TOKEN2022_TOKEN_ACCOUNT_DATA,
|
|
3171
|
+
SUBSCRIPTIONS_ERROR__INVALID_TOKEN_PROGRAM,
|
|
3172
|
+
SUBSCRIPTIONS_ERROR__INVALID_TOKEN_SPL_MINT_ACCOUNT_DATA,
|
|
3173
|
+
SUBSCRIPTIONS_ERROR__INVALID_TOKEN_SPL_TOKEN_ACCOUNT_DATA,
|
|
3174
|
+
SUBSCRIPTIONS_ERROR__MIGRATION_REQUIRED,
|
|
3175
|
+
SUBSCRIPTIONS_ERROR__MINT_HAS_CONFIDENTIAL_TRANSFER,
|
|
3176
|
+
SUBSCRIPTIONS_ERROR__MINT_HAS_MINT_CLOSE_AUTHORITY,
|
|
3177
|
+
SUBSCRIPTIONS_ERROR__MINT_HAS_NON_TRANSFERABLE,
|
|
3178
|
+
SUBSCRIPTIONS_ERROR__MINT_HAS_PAUSABLE,
|
|
3179
|
+
SUBSCRIPTIONS_ERROR__MINT_HAS_PERMANENT_DELEGATE,
|
|
3180
|
+
SUBSCRIPTIONS_ERROR__MINT_HAS_TRANSFER_FEE,
|
|
3181
|
+
SUBSCRIPTIONS_ERROR__MINT_HAS_TRANSFER_HOOK,
|
|
3182
|
+
SUBSCRIPTIONS_ERROR__MINT_MISMATCH,
|
|
3183
|
+
SUBSCRIPTIONS_ERROR__NOT_ENOUGH_ACCOUNT_KEYS,
|
|
3184
|
+
SUBSCRIPTIONS_ERROR__NOT_PLAN_OWNER,
|
|
3185
|
+
SUBSCRIPTIONS_ERROR__NOT_SIGNER,
|
|
3186
|
+
SUBSCRIPTIONS_ERROR__NOT_SYSTEM_PROGRAM,
|
|
3187
|
+
SUBSCRIPTIONS_ERROR__PERIOD_NOT_ELAPSED,
|
|
3188
|
+
SUBSCRIPTIONS_ERROR__PLAN_ALREADY_EXISTS,
|
|
3189
|
+
SUBSCRIPTIONS_ERROR__PLAN_CLOSED,
|
|
3190
|
+
SUBSCRIPTIONS_ERROR__PLAN_EXPIRED,
|
|
3191
|
+
SUBSCRIPTIONS_ERROR__PLAN_IMMUTABLE_AFTER_SUNSET,
|
|
3192
|
+
SUBSCRIPTIONS_ERROR__PLAN_NOT_EXPIRED,
|
|
3193
|
+
SUBSCRIPTIONS_ERROR__PLAN_SUNSET,
|
|
3194
|
+
SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH,
|
|
3195
|
+
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO,
|
|
3196
|
+
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY,
|
|
3197
|
+
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST,
|
|
3198
|
+
SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY,
|
|
3199
|
+
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_ALREADY_CANCELLED,
|
|
3200
|
+
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_CANCELLED,
|
|
3201
|
+
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED,
|
|
3202
|
+
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH,
|
|
3203
|
+
SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS,
|
|
3204
|
+
SUBSCRIPTIONS_ERROR__UNAUTHORIZED,
|
|
3205
|
+
SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION,
|
|
3206
|
+
SUBSCRIPTIONS_PROGRAM_ADDRESS,
|
|
3207
|
+
SUBSCRIPTION_AUTHORITY_SEED,
|
|
3208
|
+
SUBSCRIPTION_SEED,
|
|
3209
|
+
SUBSCRIPTION_SIZE,
|
|
3210
|
+
SubscriptionsAccount,
|
|
3211
|
+
SubscriptionsInstruction,
|
|
3212
|
+
TRANSFER_FIXED_DISCRIMINATOR,
|
|
3213
|
+
TRANSFER_RECURRING_DISCRIMINATOR,
|
|
3214
|
+
TRANSFER_SUBSCRIPTION_DISCRIMINATOR,
|
|
3215
|
+
U64_BYTE_SIZE,
|
|
3216
|
+
UPDATE_PLAN_DISCRIMINATOR,
|
|
3217
|
+
ValidationError,
|
|
3218
|
+
ZERO_ADDRESS,
|
|
3219
|
+
decodeDelegationAccount,
|
|
3220
|
+
decodeEventAuthority,
|
|
3221
|
+
decodeFixedDelegation,
|
|
3222
|
+
decodePlan,
|
|
3223
|
+
decodeRecurringDelegation,
|
|
3224
|
+
decodeSubscriptionAuthority,
|
|
3225
|
+
decodeSubscriptionDelegation,
|
|
3226
|
+
fetchAllEventAuthority,
|
|
3227
|
+
fetchAllFixedDelegation,
|
|
3228
|
+
fetchAllMaybeEventAuthority,
|
|
3229
|
+
fetchAllMaybeFixedDelegation,
|
|
3230
|
+
fetchAllMaybePlan,
|
|
3231
|
+
fetchAllMaybeRecurringDelegation,
|
|
3232
|
+
fetchAllMaybeSubscriptionAuthority,
|
|
3233
|
+
fetchAllMaybeSubscriptionDelegation,
|
|
3234
|
+
fetchAllPlan,
|
|
3235
|
+
fetchAllRecurringDelegation,
|
|
3236
|
+
fetchAllSubscriptionAuthority,
|
|
3237
|
+
fetchAllSubscriptionDelegation,
|
|
3238
|
+
fetchDelegationsByDelegatee,
|
|
3239
|
+
fetchDelegationsByDelegator,
|
|
3240
|
+
fetchEventAuthority,
|
|
3241
|
+
fetchEventAuthorityFromSeeds,
|
|
3242
|
+
fetchFixedDelegation,
|
|
3243
|
+
fetchFixedDelegationFromSeeds,
|
|
3244
|
+
fetchMaybeEventAuthority,
|
|
3245
|
+
fetchMaybeEventAuthorityFromSeeds,
|
|
3246
|
+
fetchMaybeFixedDelegation,
|
|
3247
|
+
fetchMaybeFixedDelegationFromSeeds,
|
|
3248
|
+
fetchMaybePlan,
|
|
3249
|
+
fetchMaybePlanFromSeeds,
|
|
3250
|
+
fetchMaybeRecurringDelegation,
|
|
3251
|
+
fetchMaybeRecurringDelegationFromSeeds,
|
|
3252
|
+
fetchMaybeSubscriptionAuthority,
|
|
3253
|
+
fetchMaybeSubscriptionAuthorityFromSeeds,
|
|
3254
|
+
fetchMaybeSubscriptionDelegation,
|
|
3255
|
+
fetchMaybeSubscriptionDelegationFromSeeds,
|
|
3256
|
+
fetchPlan,
|
|
3257
|
+
fetchPlanFromSeeds,
|
|
3258
|
+
fetchPlansForOwner,
|
|
3259
|
+
fetchRecurringDelegation,
|
|
3260
|
+
fetchRecurringDelegationFromSeeds,
|
|
3261
|
+
fetchSubscriptionAuthority,
|
|
3262
|
+
fetchSubscriptionAuthorityFromSeeds,
|
|
3263
|
+
fetchSubscriptionDelegation,
|
|
3264
|
+
fetchSubscriptionDelegationFromSeeds,
|
|
3265
|
+
fetchSubscriptionsForUser,
|
|
3266
|
+
findEventAuthorityPda,
|
|
3267
|
+
findFixedDelegationPda,
|
|
3268
|
+
findPlanPda,
|
|
3269
|
+
findRecurringDelegationPda,
|
|
3270
|
+
findSubscriptionAuthorityPda,
|
|
3271
|
+
findSubscriptionDelegationPda,
|
|
3272
|
+
getAccountDiscriminatorCodec,
|
|
3273
|
+
getAccountDiscriminatorDecoder,
|
|
3274
|
+
getAccountDiscriminatorEncoder,
|
|
3275
|
+
getCancelSubscriptionDiscriminatorBytes,
|
|
3276
|
+
getCancelSubscriptionInstruction,
|
|
3277
|
+
getCancelSubscriptionInstructionAsync,
|
|
3278
|
+
getCancelSubscriptionInstructionDataCodec,
|
|
3279
|
+
getCancelSubscriptionInstructionDataDecoder,
|
|
3280
|
+
getCancelSubscriptionInstructionDataEncoder,
|
|
3281
|
+
getCancelSubscriptionOverlayInstructionAsync,
|
|
3282
|
+
getCloseSubscriptionAuthorityDiscriminatorBytes,
|
|
3283
|
+
getCloseSubscriptionAuthorityInstruction,
|
|
3284
|
+
getCloseSubscriptionAuthorityInstructionDataCodec,
|
|
3285
|
+
getCloseSubscriptionAuthorityInstructionDataDecoder,
|
|
3286
|
+
getCloseSubscriptionAuthorityInstructionDataEncoder,
|
|
3287
|
+
getCloseSubscriptionAuthorityOverlayInstructionAsync,
|
|
3288
|
+
getCreateFixedDelegationDataCodec,
|
|
3289
|
+
getCreateFixedDelegationDataDecoder,
|
|
3290
|
+
getCreateFixedDelegationDataEncoder,
|
|
3291
|
+
getCreateFixedDelegationDiscriminatorBytes,
|
|
3292
|
+
getCreateFixedDelegationInstruction,
|
|
3293
|
+
getCreateFixedDelegationInstructionDataCodec,
|
|
3294
|
+
getCreateFixedDelegationInstructionDataDecoder,
|
|
3295
|
+
getCreateFixedDelegationInstructionDataEncoder,
|
|
3296
|
+
getCreateFixedDelegationOverlayInstructionAsync,
|
|
3297
|
+
getCreatePlanDiscriminatorBytes,
|
|
3298
|
+
getCreatePlanInstruction,
|
|
3299
|
+
getCreatePlanInstructionDataCodec,
|
|
3300
|
+
getCreatePlanInstructionDataDecoder,
|
|
3301
|
+
getCreatePlanInstructionDataEncoder,
|
|
3302
|
+
getCreatePlanOverlayInstructionAsync,
|
|
3303
|
+
getCreateRecurringDelegationDataCodec,
|
|
3304
|
+
getCreateRecurringDelegationDataDecoder,
|
|
3305
|
+
getCreateRecurringDelegationDataEncoder,
|
|
3306
|
+
getCreateRecurringDelegationDiscriminatorBytes,
|
|
3307
|
+
getCreateRecurringDelegationInstruction,
|
|
3308
|
+
getCreateRecurringDelegationInstructionDataCodec,
|
|
3309
|
+
getCreateRecurringDelegationInstructionDataDecoder,
|
|
3310
|
+
getCreateRecurringDelegationInstructionDataEncoder,
|
|
3311
|
+
getCreateRecurringDelegationOverlayInstructionAsync,
|
|
3312
|
+
getDeletePlanDiscriminatorBytes,
|
|
3313
|
+
getDeletePlanInstruction,
|
|
3314
|
+
getDeletePlanInstructionDataCodec,
|
|
3315
|
+
getDeletePlanInstructionDataDecoder,
|
|
3316
|
+
getDeletePlanInstructionDataEncoder,
|
|
3317
|
+
getDeletePlanOverlayInstruction,
|
|
3318
|
+
getEventAuthorityCodec,
|
|
3319
|
+
getEventAuthorityDecoder,
|
|
3320
|
+
getEventAuthorityEncoder,
|
|
3321
|
+
getFixedDelegationCodec,
|
|
3322
|
+
getFixedDelegationDecoder,
|
|
3323
|
+
getFixedDelegationEncoder,
|
|
3324
|
+
getHeaderCodec,
|
|
3325
|
+
getHeaderDecoder,
|
|
3326
|
+
getHeaderEncoder,
|
|
3327
|
+
getInitSubscriptionAuthorityDiscriminatorBytes,
|
|
3328
|
+
getInitSubscriptionAuthorityInstruction,
|
|
3329
|
+
getInitSubscriptionAuthorityInstructionAsync,
|
|
3330
|
+
getInitSubscriptionAuthorityInstructionDataCodec,
|
|
3331
|
+
getInitSubscriptionAuthorityInstructionDataDecoder,
|
|
3332
|
+
getInitSubscriptionAuthorityInstructionDataEncoder,
|
|
3333
|
+
getInitSubscriptionAuthorityOverlayInstructionAsync,
|
|
3334
|
+
getPlanCodec,
|
|
3335
|
+
getPlanDataCodec,
|
|
3336
|
+
getPlanDataDecoder,
|
|
3337
|
+
getPlanDataEncoder,
|
|
3338
|
+
getPlanDecoder,
|
|
3339
|
+
getPlanEncoder,
|
|
3340
|
+
getPlanStatusCodec,
|
|
3341
|
+
getPlanStatusDecoder,
|
|
3342
|
+
getPlanStatusEncoder,
|
|
3343
|
+
getPlanTermsCodec,
|
|
3344
|
+
getPlanTermsDecoder,
|
|
3345
|
+
getPlanTermsEncoder,
|
|
3346
|
+
getRecurringDelegationCodec,
|
|
3347
|
+
getRecurringDelegationDecoder,
|
|
3348
|
+
getRecurringDelegationEncoder,
|
|
3349
|
+
getRevokeDelegationDiscriminatorBytes,
|
|
3350
|
+
getRevokeDelegationInstruction,
|
|
3351
|
+
getRevokeDelegationInstructionDataCodec,
|
|
3352
|
+
getRevokeDelegationInstructionDataDecoder,
|
|
3353
|
+
getRevokeDelegationInstructionDataEncoder,
|
|
3354
|
+
getRevokeDelegationOverlayInstruction,
|
|
3355
|
+
getRevokeSubscriptionOverlayInstruction,
|
|
3356
|
+
getSubscribeDataCodec,
|
|
3357
|
+
getSubscribeDataDecoder,
|
|
3358
|
+
getSubscribeDataEncoder,
|
|
3359
|
+
getSubscribeDiscriminatorBytes,
|
|
3360
|
+
getSubscribeInstruction,
|
|
3361
|
+
getSubscribeInstructionAsync,
|
|
3362
|
+
getSubscribeInstructionDataCodec,
|
|
3363
|
+
getSubscribeInstructionDataDecoder,
|
|
3364
|
+
getSubscribeInstructionDataEncoder,
|
|
3365
|
+
getSubscribeOverlayInstructionAsync,
|
|
3366
|
+
getSubscriptionAuthorityCodec,
|
|
3367
|
+
getSubscriptionAuthorityDecoder,
|
|
3368
|
+
getSubscriptionAuthorityEncoder,
|
|
3369
|
+
getSubscriptionDelegationCodec,
|
|
3370
|
+
getSubscriptionDelegationDecoder,
|
|
3371
|
+
getSubscriptionDelegationEncoder,
|
|
3372
|
+
getSubscriptionsErrorMessage,
|
|
3373
|
+
getTransferDataCodec,
|
|
3374
|
+
getTransferDataDecoder,
|
|
3375
|
+
getTransferDataEncoder,
|
|
3376
|
+
getTransferFixedDiscriminatorBytes,
|
|
3377
|
+
getTransferFixedInstruction,
|
|
3378
|
+
getTransferFixedInstructionDataCodec,
|
|
3379
|
+
getTransferFixedInstructionDataDecoder,
|
|
3380
|
+
getTransferFixedInstructionDataEncoder,
|
|
3381
|
+
getTransferFixedOverlayInstructionAsync,
|
|
3382
|
+
getTransferRecurringDiscriminatorBytes,
|
|
3383
|
+
getTransferRecurringInstruction,
|
|
3384
|
+
getTransferRecurringInstructionDataCodec,
|
|
3385
|
+
getTransferRecurringInstructionDataDecoder,
|
|
3386
|
+
getTransferRecurringInstructionDataEncoder,
|
|
3387
|
+
getTransferRecurringOverlayInstructionAsync,
|
|
3388
|
+
getTransferSubscriptionDiscriminatorBytes,
|
|
3389
|
+
getTransferSubscriptionInstruction,
|
|
3390
|
+
getTransferSubscriptionInstructionDataCodec,
|
|
3391
|
+
getTransferSubscriptionInstructionDataDecoder,
|
|
3392
|
+
getTransferSubscriptionInstructionDataEncoder,
|
|
3393
|
+
getTransferSubscriptionOverlayInstructionAsync,
|
|
3394
|
+
getUpdatePlanDataCodec,
|
|
3395
|
+
getUpdatePlanDataDecoder,
|
|
3396
|
+
getUpdatePlanDataEncoder,
|
|
3397
|
+
getUpdatePlanDiscriminatorBytes,
|
|
3398
|
+
getUpdatePlanInstruction,
|
|
3399
|
+
getUpdatePlanInstructionDataCodec,
|
|
3400
|
+
getUpdatePlanInstructionDataDecoder,
|
|
3401
|
+
getUpdatePlanInstructionDataEncoder,
|
|
3402
|
+
getUpdatePlanOverlayInstruction,
|
|
3403
|
+
identifySubscriptionsInstruction,
|
|
3404
|
+
isSubscriptionsError,
|
|
3405
|
+
parseCancelSubscriptionInstruction,
|
|
3406
|
+
parseCloseSubscriptionAuthorityInstruction,
|
|
3407
|
+
parseCreateFixedDelegationInstruction,
|
|
3408
|
+
parseCreatePlanInstruction,
|
|
3409
|
+
parseCreateRecurringDelegationInstruction,
|
|
3410
|
+
parseDeletePlanInstruction,
|
|
3411
|
+
parseInitSubscriptionAuthorityInstruction,
|
|
3412
|
+
parseRevokeDelegationInstruction,
|
|
3413
|
+
parseSubscribeInstruction,
|
|
3414
|
+
parseSubscriptionsInstruction,
|
|
3415
|
+
parseTransferFixedInstruction,
|
|
3416
|
+
parseTransferRecurringInstruction,
|
|
3417
|
+
parseTransferSubscriptionInstruction,
|
|
3418
|
+
parseUpdatePlanInstruction,
|
|
3419
|
+
subscriptionsProgram2 as subscriptionsProgram,
|
|
3420
|
+
toEncodedAccount
|
|
3421
|
+
};
|
|
3422
|
+
//# sourceMappingURL=index.js.map
|