@solana/subscriptions 0.3.0 → 0.4.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -11
- package/dist/index.cjs +1082 -261
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +450 -61
- package/dist/index.d.ts +450 -61
- package/dist/index.js +1084 -245
- package/dist/index.js.map +1 -1
- package/package.json +9 -6
package/dist/index.cjs
CHANGED
|
@@ -43,7 +43,10 @@ __export(index_exports, {
|
|
|
43
43
|
PROGRAM_ID: () => PROGRAM_ID,
|
|
44
44
|
PlanStatus: () => PlanStatus,
|
|
45
45
|
RESUME_SUBSCRIPTION_DISCRIMINATOR: () => RESUME_SUBSCRIPTION_DISCRIMINATOR,
|
|
46
|
+
REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR: () => REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR,
|
|
47
|
+
REVOKE_ABANDONED_SUBSCRIPTION_DISCRIMINATOR: () => REVOKE_ABANDONED_SUBSCRIPTION_DISCRIMINATOR,
|
|
46
48
|
REVOKE_DELEGATION_DISCRIMINATOR: () => REVOKE_DELEGATION_DISCRIMINATOR,
|
|
49
|
+
REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR: () => REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR,
|
|
47
50
|
SUBSCRIBE_DISCRIMINATOR: () => SUBSCRIBE_DISCRIMINATOR,
|
|
48
51
|
SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE: () => SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE,
|
|
49
52
|
SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED: () => SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED,
|
|
@@ -78,6 +81,7 @@ __export(index_exports, {
|
|
|
78
81
|
SUBSCRIPTIONS_ERROR__INVALID_PERIOD_LENGTH: () => SUBSCRIPTIONS_ERROR__INVALID_PERIOD_LENGTH,
|
|
79
82
|
SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA: () => SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA,
|
|
80
83
|
SUBSCRIPTIONS_ERROR__INVALID_PLAN_STATUS: () => SUBSCRIPTIONS_ERROR__INVALID_PLAN_STATUS,
|
|
84
|
+
SUBSCRIPTIONS_ERROR__INVALID_SELF_PROGRAM: () => SUBSCRIPTIONS_ERROR__INVALID_SELF_PROGRAM,
|
|
81
85
|
SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_AUTHORITY_PDA: () => SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_AUTHORITY_PDA,
|
|
82
86
|
SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_PDA: () => SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_PDA,
|
|
83
87
|
SUBSCRIPTIONS_ERROR__INVALID_TOKEN2022_MINT_ACCOUNT_DATA: () => SUBSCRIPTIONS_ERROR__INVALID_TOKEN2022_MINT_ACCOUNT_DATA,
|
|
@@ -101,12 +105,14 @@ __export(index_exports, {
|
|
|
101
105
|
SUBSCRIPTIONS_ERROR__PERIOD_NOT_ELAPSED: () => SUBSCRIPTIONS_ERROR__PERIOD_NOT_ELAPSED,
|
|
102
106
|
SUBSCRIPTIONS_ERROR__PLAN_ALREADY_EXISTS: () => SUBSCRIPTIONS_ERROR__PLAN_ALREADY_EXISTS,
|
|
103
107
|
SUBSCRIPTIONS_ERROR__PLAN_CLOSED: () => SUBSCRIPTIONS_ERROR__PLAN_CLOSED,
|
|
108
|
+
SUBSCRIPTIONS_ERROR__PLAN_END_TS_CANNOT_EXTEND: () => SUBSCRIPTIONS_ERROR__PLAN_END_TS_CANNOT_EXTEND,
|
|
104
109
|
SUBSCRIPTIONS_ERROR__PLAN_EXPIRED: () => SUBSCRIPTIONS_ERROR__PLAN_EXPIRED,
|
|
105
110
|
SUBSCRIPTIONS_ERROR__PLAN_IMMUTABLE_AFTER_SUNSET: () => SUBSCRIPTIONS_ERROR__PLAN_IMMUTABLE_AFTER_SUNSET,
|
|
106
111
|
SUBSCRIPTIONS_ERROR__PLAN_NOT_EXPIRED: () => SUBSCRIPTIONS_ERROR__PLAN_NOT_EXPIRED,
|
|
107
112
|
SUBSCRIPTIONS_ERROR__PLAN_SUNSET: () => SUBSCRIPTIONS_ERROR__PLAN_SUNSET,
|
|
108
113
|
SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH: () => SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH,
|
|
109
114
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO: () => SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO,
|
|
115
|
+
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY: () => SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY,
|
|
110
116
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY: () => SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY,
|
|
111
117
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST: () => SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST,
|
|
112
118
|
SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY: () => SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY,
|
|
@@ -115,6 +121,7 @@ __export(index_exports, {
|
|
|
115
121
|
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED: () => SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED,
|
|
116
122
|
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH: () => SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH,
|
|
117
123
|
SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS: () => SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS,
|
|
124
|
+
SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS: () => SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS,
|
|
118
125
|
SUBSCRIPTIONS_ERROR__UNAUTHORIZED: () => SUBSCRIPTIONS_ERROR__UNAUTHORIZED,
|
|
119
126
|
SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION: () => SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION,
|
|
120
127
|
SUBSCRIPTIONS_PROGRAM_ADDRESS: () => SUBSCRIPTIONS_PROGRAM_ADDRESS,
|
|
@@ -267,12 +274,29 @@ __export(index_exports, {
|
|
|
267
274
|
getResumeSubscriptionInstructionDataDecoder: () => getResumeSubscriptionInstructionDataDecoder,
|
|
268
275
|
getResumeSubscriptionInstructionDataEncoder: () => getResumeSubscriptionInstructionDataEncoder,
|
|
269
276
|
getResumeSubscriptionOverlayInstructionAsync: () => getResumeSubscriptionOverlayInstructionAsync,
|
|
277
|
+
getRevokeAbandonedDelegationDiscriminatorBytes: () => getRevokeAbandonedDelegationDiscriminatorBytes,
|
|
278
|
+
getRevokeAbandonedDelegationInstruction: () => getRevokeAbandonedDelegationInstruction,
|
|
279
|
+
getRevokeAbandonedDelegationInstructionDataCodec: () => getRevokeAbandonedDelegationInstructionDataCodec,
|
|
280
|
+
getRevokeAbandonedDelegationInstructionDataDecoder: () => getRevokeAbandonedDelegationInstructionDataDecoder,
|
|
281
|
+
getRevokeAbandonedDelegationInstructionDataEncoder: () => getRevokeAbandonedDelegationInstructionDataEncoder,
|
|
282
|
+
getRevokeAbandonedSubscriptionDiscriminatorBytes: () => getRevokeAbandonedSubscriptionDiscriminatorBytes,
|
|
283
|
+
getRevokeAbandonedSubscriptionInstruction: () => getRevokeAbandonedSubscriptionInstruction,
|
|
284
|
+
getRevokeAbandonedSubscriptionInstructionDataCodec: () => getRevokeAbandonedSubscriptionInstructionDataCodec,
|
|
285
|
+
getRevokeAbandonedSubscriptionInstructionDataDecoder: () => getRevokeAbandonedSubscriptionInstructionDataDecoder,
|
|
286
|
+
getRevokeAbandonedSubscriptionInstructionDataEncoder: () => getRevokeAbandonedSubscriptionInstructionDataEncoder,
|
|
270
287
|
getRevokeDelegationDiscriminatorBytes: () => getRevokeDelegationDiscriminatorBytes,
|
|
271
288
|
getRevokeDelegationInstruction: () => getRevokeDelegationInstruction,
|
|
272
289
|
getRevokeDelegationInstructionDataCodec: () => getRevokeDelegationInstructionDataCodec,
|
|
273
290
|
getRevokeDelegationInstructionDataDecoder: () => getRevokeDelegationInstructionDataDecoder,
|
|
274
291
|
getRevokeDelegationInstructionDataEncoder: () => getRevokeDelegationInstructionDataEncoder,
|
|
275
292
|
getRevokeDelegationOverlayInstruction: () => getRevokeDelegationOverlayInstruction,
|
|
293
|
+
getRevokeSubscriptionAuthorityDiscriminatorBytes: () => getRevokeSubscriptionAuthorityDiscriminatorBytes,
|
|
294
|
+
getRevokeSubscriptionAuthorityInstruction: () => getRevokeSubscriptionAuthorityInstruction,
|
|
295
|
+
getRevokeSubscriptionAuthorityInstructionAsync: () => getRevokeSubscriptionAuthorityInstructionAsync,
|
|
296
|
+
getRevokeSubscriptionAuthorityInstructionDataCodec: () => getRevokeSubscriptionAuthorityInstructionDataCodec,
|
|
297
|
+
getRevokeSubscriptionAuthorityInstructionDataDecoder: () => getRevokeSubscriptionAuthorityInstructionDataDecoder,
|
|
298
|
+
getRevokeSubscriptionAuthorityInstructionDataEncoder: () => getRevokeSubscriptionAuthorityInstructionDataEncoder,
|
|
299
|
+
getRevokeSubscriptionAuthorityOverlayInstructionAsync: () => getRevokeSubscriptionAuthorityOverlayInstructionAsync,
|
|
276
300
|
getRevokeSubscriptionOverlayInstruction: () => getRevokeSubscriptionOverlayInstruction,
|
|
277
301
|
getSubscribeDataCodec: () => getSubscribeDataCodec,
|
|
278
302
|
getSubscribeDataDecoder: () => getSubscribeDataDecoder,
|
|
@@ -296,18 +320,21 @@ __export(index_exports, {
|
|
|
296
320
|
getTransferDataEncoder: () => getTransferDataEncoder,
|
|
297
321
|
getTransferFixedDiscriminatorBytes: () => getTransferFixedDiscriminatorBytes,
|
|
298
322
|
getTransferFixedInstruction: () => getTransferFixedInstruction,
|
|
323
|
+
getTransferFixedInstructionAsync: () => getTransferFixedInstructionAsync,
|
|
299
324
|
getTransferFixedInstructionDataCodec: () => getTransferFixedInstructionDataCodec,
|
|
300
325
|
getTransferFixedInstructionDataDecoder: () => getTransferFixedInstructionDataDecoder,
|
|
301
326
|
getTransferFixedInstructionDataEncoder: () => getTransferFixedInstructionDataEncoder,
|
|
302
327
|
getTransferFixedOverlayInstructionAsync: () => getTransferFixedOverlayInstructionAsync,
|
|
303
328
|
getTransferRecurringDiscriminatorBytes: () => getTransferRecurringDiscriminatorBytes,
|
|
304
329
|
getTransferRecurringInstruction: () => getTransferRecurringInstruction,
|
|
330
|
+
getTransferRecurringInstructionAsync: () => getTransferRecurringInstructionAsync,
|
|
305
331
|
getTransferRecurringInstructionDataCodec: () => getTransferRecurringInstructionDataCodec,
|
|
306
332
|
getTransferRecurringInstructionDataDecoder: () => getTransferRecurringInstructionDataDecoder,
|
|
307
333
|
getTransferRecurringInstructionDataEncoder: () => getTransferRecurringInstructionDataEncoder,
|
|
308
334
|
getTransferRecurringOverlayInstructionAsync: () => getTransferRecurringOverlayInstructionAsync,
|
|
309
335
|
getTransferSubscriptionDiscriminatorBytes: () => getTransferSubscriptionDiscriminatorBytes,
|
|
310
336
|
getTransferSubscriptionInstruction: () => getTransferSubscriptionInstruction,
|
|
337
|
+
getTransferSubscriptionInstructionAsync: () => getTransferSubscriptionInstructionAsync,
|
|
311
338
|
getTransferSubscriptionInstructionDataCodec: () => getTransferSubscriptionInstructionDataCodec,
|
|
312
339
|
getTransferSubscriptionInstructionDataDecoder: () => getTransferSubscriptionInstructionDataDecoder,
|
|
313
340
|
getTransferSubscriptionInstructionDataEncoder: () => getTransferSubscriptionInstructionDataEncoder,
|
|
@@ -317,6 +344,7 @@ __export(index_exports, {
|
|
|
317
344
|
getUpdatePlanDataEncoder: () => getUpdatePlanDataEncoder,
|
|
318
345
|
getUpdatePlanDiscriminatorBytes: () => getUpdatePlanDiscriminatorBytes,
|
|
319
346
|
getUpdatePlanInstruction: () => getUpdatePlanInstruction,
|
|
347
|
+
getUpdatePlanInstructionAsync: () => getUpdatePlanInstructionAsync,
|
|
320
348
|
getUpdatePlanInstructionDataCodec: () => getUpdatePlanInstructionDataCodec,
|
|
321
349
|
getUpdatePlanInstructionDataDecoder: () => getUpdatePlanInstructionDataDecoder,
|
|
322
350
|
getUpdatePlanInstructionDataEncoder: () => getUpdatePlanInstructionDataEncoder,
|
|
@@ -331,20 +359,24 @@ __export(index_exports, {
|
|
|
331
359
|
parseDeletePlanInstruction: () => parseDeletePlanInstruction,
|
|
332
360
|
parseInitSubscriptionAuthorityInstruction: () => parseInitSubscriptionAuthorityInstruction,
|
|
333
361
|
parseResumeSubscriptionInstruction: () => parseResumeSubscriptionInstruction,
|
|
362
|
+
parseRevokeAbandonedDelegationInstruction: () => parseRevokeAbandonedDelegationInstruction,
|
|
363
|
+
parseRevokeAbandonedSubscriptionInstruction: () => parseRevokeAbandonedSubscriptionInstruction,
|
|
334
364
|
parseRevokeDelegationInstruction: () => parseRevokeDelegationInstruction,
|
|
365
|
+
parseRevokeSubscriptionAuthorityInstruction: () => parseRevokeSubscriptionAuthorityInstruction,
|
|
335
366
|
parseSubscribeInstruction: () => parseSubscribeInstruction,
|
|
336
367
|
parseSubscriptionsInstruction: () => parseSubscriptionsInstruction,
|
|
337
368
|
parseTransferFixedInstruction: () => parseTransferFixedInstruction,
|
|
338
369
|
parseTransferRecurringInstruction: () => parseTransferRecurringInstruction,
|
|
339
370
|
parseTransferSubscriptionInstruction: () => parseTransferSubscriptionInstruction,
|
|
340
371
|
parseUpdatePlanInstruction: () => parseUpdatePlanInstruction,
|
|
372
|
+
resolveTransferHookAccounts: () => resolveTransferHookAccounts,
|
|
341
373
|
subscriptionsProgram: () => subscriptionsProgram2,
|
|
342
374
|
toEncodedAccount: () => toEncodedAccount
|
|
343
375
|
});
|
|
344
376
|
module.exports = __toCommonJS(index_exports);
|
|
345
377
|
|
|
346
378
|
// src/accounts/decode.ts
|
|
347
|
-
var
|
|
379
|
+
var import_kit42 = require("@solana/kit");
|
|
348
380
|
|
|
349
381
|
// src/generated/accounts/eventAuthority.ts
|
|
350
382
|
var import_kit7 = require("@solana/kit");
|
|
@@ -1001,11 +1033,11 @@ async function fetchMaybeSubscriptionDelegationFromSeeds(rpc, seeds, config = {}
|
|
|
1001
1033
|
}
|
|
1002
1034
|
|
|
1003
1035
|
// src/generated/errors/subscriptions.ts
|
|
1004
|
-
var
|
|
1036
|
+
var import_kit41 = require("@solana/kit");
|
|
1005
1037
|
|
|
1006
1038
|
// src/generated/programs/subscriptions.ts
|
|
1007
|
-
var
|
|
1008
|
-
var
|
|
1039
|
+
var import_kit40 = require("@solana/kit");
|
|
1040
|
+
var import_program_client_core18 = require("@solana/program-client-core");
|
|
1009
1041
|
|
|
1010
1042
|
// src/generated/instructions/cancelSubscription.ts
|
|
1011
1043
|
var import_kit23 = require("@solana/kit");
|
|
@@ -1043,10 +1075,14 @@ async function getCancelSubscriptionInstructionAsync(input, config) {
|
|
|
1043
1075
|
});
|
|
1044
1076
|
}
|
|
1045
1077
|
if (!accounts.eventAuthority.value) {
|
|
1046
|
-
accounts.eventAuthority.value =
|
|
1078
|
+
accounts.eventAuthority.value = await (0, import_kit23.getProgramDerivedAddress)({
|
|
1079
|
+
programAddress,
|
|
1080
|
+
seeds: [(0, import_kit23.getUtf8Encoder)().encode("event_authority")]
|
|
1081
|
+
});
|
|
1047
1082
|
}
|
|
1048
1083
|
if (!accounts.selfProgram.value) {
|
|
1049
|
-
accounts.selfProgram.value =
|
|
1084
|
+
accounts.selfProgram.value = programAddress;
|
|
1085
|
+
accounts.selfProgram.isWritable = false;
|
|
1050
1086
|
}
|
|
1051
1087
|
const getAccountMeta = (0, import_program_client_core.getAccountMetaFactory)(programAddress, "programId");
|
|
1052
1088
|
return Object.freeze({
|
|
@@ -1071,11 +1107,9 @@ function getCancelSubscriptionInstruction(input, config) {
|
|
|
1071
1107
|
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
1072
1108
|
};
|
|
1073
1109
|
const accounts = originalAccounts;
|
|
1074
|
-
if (!accounts.eventAuthority.value) {
|
|
1075
|
-
accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
|
|
1076
|
-
}
|
|
1077
1110
|
if (!accounts.selfProgram.value) {
|
|
1078
|
-
accounts.selfProgram.value =
|
|
1111
|
+
accounts.selfProgram.value = programAddress;
|
|
1112
|
+
accounts.selfProgram.isWritable = false;
|
|
1079
1113
|
}
|
|
1080
1114
|
const getAccountMeta = (0, import_program_client_core.getAccountMetaFactory)(programAddress, "programId");
|
|
1081
1115
|
return Object.freeze({
|
|
@@ -1142,15 +1176,17 @@ function getCloseSubscriptionAuthorityInstruction(input, config) {
|
|
|
1142
1176
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1143
1177
|
const originalAccounts = {
|
|
1144
1178
|
user: { value: input.user ?? null, isWritable: true },
|
|
1145
|
-
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: true }
|
|
1179
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: true },
|
|
1180
|
+
receiver: { value: input.receiver ?? null, isWritable: true }
|
|
1146
1181
|
};
|
|
1147
1182
|
const accounts = originalAccounts;
|
|
1148
|
-
const getAccountMeta = (0, import_program_client_core2.getAccountMetaFactory)(programAddress, "
|
|
1183
|
+
const getAccountMeta = (0, import_program_client_core2.getAccountMetaFactory)(programAddress, "omitted");
|
|
1149
1184
|
return Object.freeze({
|
|
1150
1185
|
accounts: [
|
|
1151
1186
|
getAccountMeta("user", accounts.user),
|
|
1152
|
-
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority)
|
|
1153
|
-
|
|
1187
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1188
|
+
getAccountMeta("receiver", accounts.receiver)
|
|
1189
|
+
].filter((x) => x !== void 0),
|
|
1154
1190
|
data: getCloseSubscriptionAuthorityInstructionDataEncoder().encode({}),
|
|
1155
1191
|
programAddress
|
|
1156
1192
|
});
|
|
@@ -1168,9 +1204,19 @@ function parseCloseSubscriptionAuthorityInstruction(instruction) {
|
|
|
1168
1204
|
accountIndex += 1;
|
|
1169
1205
|
return accountMeta;
|
|
1170
1206
|
};
|
|
1207
|
+
let optionalAccountsRemaining = instruction.accounts.length - 2;
|
|
1208
|
+
const getNextOptionalAccount = () => {
|
|
1209
|
+
if (optionalAccountsRemaining === 0) return void 0;
|
|
1210
|
+
optionalAccountsRemaining -= 1;
|
|
1211
|
+
return getNextAccount();
|
|
1212
|
+
};
|
|
1171
1213
|
return {
|
|
1172
1214
|
programAddress: instruction.programAddress,
|
|
1173
|
-
accounts: {
|
|
1215
|
+
accounts: {
|
|
1216
|
+
user: getNextAccount(),
|
|
1217
|
+
subscriptionAuthority: getNextAccount(),
|
|
1218
|
+
receiver: getNextOptionalAccount()
|
|
1219
|
+
},
|
|
1174
1220
|
data: getCloseSubscriptionAuthorityInstructionDataDecoder().decode(instruction.data)
|
|
1175
1221
|
};
|
|
1176
1222
|
}
|
|
@@ -1210,22 +1256,24 @@ function getCreateFixedDelegationInstruction(input, config) {
|
|
|
1210
1256
|
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
1211
1257
|
delegationAccount: { value: input.delegationAccount ?? null, isWritable: true },
|
|
1212
1258
|
delegatee: { value: input.delegatee ?? null, isWritable: false },
|
|
1213
|
-
systemProgram: { value: input.systemProgram ?? null, isWritable: false }
|
|
1259
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1260
|
+
payer: { value: input.payer ?? null, isWritable: true }
|
|
1214
1261
|
};
|
|
1215
1262
|
const accounts = originalAccounts;
|
|
1216
1263
|
const args = { ...input };
|
|
1217
1264
|
if (!accounts.systemProgram.value) {
|
|
1218
1265
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1219
1266
|
}
|
|
1220
|
-
const getAccountMeta = (0, import_program_client_core3.getAccountMetaFactory)(programAddress, "
|
|
1267
|
+
const getAccountMeta = (0, import_program_client_core3.getAccountMetaFactory)(programAddress, "omitted");
|
|
1221
1268
|
return Object.freeze({
|
|
1222
1269
|
accounts: [
|
|
1223
1270
|
getAccountMeta("delegator", accounts.delegator),
|
|
1224
1271
|
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1225
1272
|
getAccountMeta("delegationAccount", accounts.delegationAccount),
|
|
1226
1273
|
getAccountMeta("delegatee", accounts.delegatee),
|
|
1227
|
-
getAccountMeta("systemProgram", accounts.systemProgram)
|
|
1228
|
-
|
|
1274
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
1275
|
+
getAccountMeta("payer", accounts.payer)
|
|
1276
|
+
].filter((x) => x !== void 0),
|
|
1229
1277
|
data: getCreateFixedDelegationInstructionDataEncoder().encode(args),
|
|
1230
1278
|
programAddress
|
|
1231
1279
|
});
|
|
@@ -1243,6 +1291,12 @@ function parseCreateFixedDelegationInstruction(instruction) {
|
|
|
1243
1291
|
accountIndex += 1;
|
|
1244
1292
|
return accountMeta;
|
|
1245
1293
|
};
|
|
1294
|
+
let optionalAccountsRemaining = instruction.accounts.length - 5;
|
|
1295
|
+
const getNextOptionalAccount = () => {
|
|
1296
|
+
if (optionalAccountsRemaining === 0) return void 0;
|
|
1297
|
+
optionalAccountsRemaining -= 1;
|
|
1298
|
+
return getNextAccount();
|
|
1299
|
+
};
|
|
1246
1300
|
return {
|
|
1247
1301
|
programAddress: instruction.programAddress,
|
|
1248
1302
|
accounts: {
|
|
@@ -1250,7 +1304,8 @@ function parseCreateFixedDelegationInstruction(instruction) {
|
|
|
1250
1304
|
subscriptionAuthority: getNextAccount(),
|
|
1251
1305
|
delegationAccount: getNextAccount(),
|
|
1252
1306
|
delegatee: getNextAccount(),
|
|
1253
|
-
systemProgram: getNextAccount()
|
|
1307
|
+
systemProgram: getNextAccount(),
|
|
1308
|
+
payer: getNextOptionalAccount()
|
|
1254
1309
|
},
|
|
1255
1310
|
data: getCreateFixedDelegationInstructionDataDecoder().decode(instruction.data)
|
|
1256
1311
|
};
|
|
@@ -1372,22 +1427,24 @@ function getCreateRecurringDelegationInstruction(input, config) {
|
|
|
1372
1427
|
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
1373
1428
|
delegationAccount: { value: input.delegationAccount ?? null, isWritable: true },
|
|
1374
1429
|
delegatee: { value: input.delegatee ?? null, isWritable: false },
|
|
1375
|
-
systemProgram: { value: input.systemProgram ?? null, isWritable: false }
|
|
1430
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1431
|
+
payer: { value: input.payer ?? null, isWritable: true }
|
|
1376
1432
|
};
|
|
1377
1433
|
const accounts = originalAccounts;
|
|
1378
1434
|
const args = { ...input };
|
|
1379
1435
|
if (!accounts.systemProgram.value) {
|
|
1380
1436
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1381
1437
|
}
|
|
1382
|
-
const getAccountMeta = (0, import_program_client_core5.getAccountMetaFactory)(programAddress, "
|
|
1438
|
+
const getAccountMeta = (0, import_program_client_core5.getAccountMetaFactory)(programAddress, "omitted");
|
|
1383
1439
|
return Object.freeze({
|
|
1384
1440
|
accounts: [
|
|
1385
1441
|
getAccountMeta("delegator", accounts.delegator),
|
|
1386
1442
|
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1387
1443
|
getAccountMeta("delegationAccount", accounts.delegationAccount),
|
|
1388
1444
|
getAccountMeta("delegatee", accounts.delegatee),
|
|
1389
|
-
getAccountMeta("systemProgram", accounts.systemProgram)
|
|
1390
|
-
|
|
1445
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
1446
|
+
getAccountMeta("payer", accounts.payer)
|
|
1447
|
+
].filter((x) => x !== void 0),
|
|
1391
1448
|
data: getCreateRecurringDelegationInstructionDataEncoder().encode(
|
|
1392
1449
|
args
|
|
1393
1450
|
),
|
|
@@ -1407,6 +1464,12 @@ function parseCreateRecurringDelegationInstruction(instruction) {
|
|
|
1407
1464
|
accountIndex += 1;
|
|
1408
1465
|
return accountMeta;
|
|
1409
1466
|
};
|
|
1467
|
+
let optionalAccountsRemaining = instruction.accounts.length - 5;
|
|
1468
|
+
const getNextOptionalAccount = () => {
|
|
1469
|
+
if (optionalAccountsRemaining === 0) return void 0;
|
|
1470
|
+
optionalAccountsRemaining -= 1;
|
|
1471
|
+
return getNextAccount();
|
|
1472
|
+
};
|
|
1410
1473
|
return {
|
|
1411
1474
|
programAddress: instruction.programAddress,
|
|
1412
1475
|
accounts: {
|
|
@@ -1414,7 +1477,8 @@ function parseCreateRecurringDelegationInstruction(instruction) {
|
|
|
1414
1477
|
subscriptionAuthority: getNextAccount(),
|
|
1415
1478
|
delegationAccount: getNextAccount(),
|
|
1416
1479
|
delegatee: getNextAccount(),
|
|
1417
|
-
systemProgram: getNextAccount()
|
|
1480
|
+
systemProgram: getNextAccount(),
|
|
1481
|
+
payer: getNextOptionalAccount()
|
|
1418
1482
|
},
|
|
1419
1483
|
data: getCreateRecurringDelegationInstructionDataDecoder().decode(instruction.data)
|
|
1420
1484
|
};
|
|
@@ -1503,7 +1567,8 @@ async function getInitSubscriptionAuthorityInstructionAsync(input, config) {
|
|
|
1503
1567
|
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
1504
1568
|
userAta: { value: input.userAta ?? null, isWritable: true },
|
|
1505
1569
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1506
|
-
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }
|
|
1570
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
1571
|
+
payer: { value: input.payer ?? null, isWritable: true }
|
|
1507
1572
|
};
|
|
1508
1573
|
const accounts = originalAccounts;
|
|
1509
1574
|
if (!accounts.subscriptionAuthority.value) {
|
|
@@ -1515,7 +1580,7 @@ async function getInitSubscriptionAuthorityInstructionAsync(input, config) {
|
|
|
1515
1580
|
if (!accounts.systemProgram.value) {
|
|
1516
1581
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1517
1582
|
}
|
|
1518
|
-
const getAccountMeta = (0, import_program_client_core7.getAccountMetaFactory)(programAddress, "
|
|
1583
|
+
const getAccountMeta = (0, import_program_client_core7.getAccountMetaFactory)(programAddress, "omitted");
|
|
1519
1584
|
return Object.freeze({
|
|
1520
1585
|
accounts: [
|
|
1521
1586
|
getAccountMeta("owner", accounts.owner),
|
|
@@ -1523,8 +1588,9 @@ async function getInitSubscriptionAuthorityInstructionAsync(input, config) {
|
|
|
1523
1588
|
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
1524
1589
|
getAccountMeta("userAta", accounts.userAta),
|
|
1525
1590
|
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
1526
|
-
getAccountMeta("tokenProgram", accounts.tokenProgram)
|
|
1527
|
-
|
|
1591
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
1592
|
+
getAccountMeta("payer", accounts.payer)
|
|
1593
|
+
].filter((x) => x !== void 0),
|
|
1528
1594
|
data: getInitSubscriptionAuthorityInstructionDataEncoder().encode({}),
|
|
1529
1595
|
programAddress
|
|
1530
1596
|
});
|
|
@@ -1537,13 +1603,14 @@ function getInitSubscriptionAuthorityInstruction(input, config) {
|
|
|
1537
1603
|
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
1538
1604
|
userAta: { value: input.userAta ?? null, isWritable: true },
|
|
1539
1605
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1540
|
-
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }
|
|
1606
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
1607
|
+
payer: { value: input.payer ?? null, isWritable: true }
|
|
1541
1608
|
};
|
|
1542
1609
|
const accounts = originalAccounts;
|
|
1543
1610
|
if (!accounts.systemProgram.value) {
|
|
1544
1611
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1545
1612
|
}
|
|
1546
|
-
const getAccountMeta = (0, import_program_client_core7.getAccountMetaFactory)(programAddress, "
|
|
1613
|
+
const getAccountMeta = (0, import_program_client_core7.getAccountMetaFactory)(programAddress, "omitted");
|
|
1547
1614
|
return Object.freeze({
|
|
1548
1615
|
accounts: [
|
|
1549
1616
|
getAccountMeta("owner", accounts.owner),
|
|
@@ -1551,8 +1618,9 @@ function getInitSubscriptionAuthorityInstruction(input, config) {
|
|
|
1551
1618
|
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
1552
1619
|
getAccountMeta("userAta", accounts.userAta),
|
|
1553
1620
|
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
1554
|
-
getAccountMeta("tokenProgram", accounts.tokenProgram)
|
|
1555
|
-
|
|
1621
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
1622
|
+
getAccountMeta("payer", accounts.payer)
|
|
1623
|
+
].filter((x) => x !== void 0),
|
|
1556
1624
|
data: getInitSubscriptionAuthorityInstructionDataEncoder().encode({}),
|
|
1557
1625
|
programAddress
|
|
1558
1626
|
});
|
|
@@ -1570,6 +1638,12 @@ function parseInitSubscriptionAuthorityInstruction(instruction) {
|
|
|
1570
1638
|
accountIndex += 1;
|
|
1571
1639
|
return accountMeta;
|
|
1572
1640
|
};
|
|
1641
|
+
let optionalAccountsRemaining = instruction.accounts.length - 6;
|
|
1642
|
+
const getNextOptionalAccount = () => {
|
|
1643
|
+
if (optionalAccountsRemaining === 0) return void 0;
|
|
1644
|
+
optionalAccountsRemaining -= 1;
|
|
1645
|
+
return getNextAccount();
|
|
1646
|
+
};
|
|
1573
1647
|
return {
|
|
1574
1648
|
programAddress: instruction.programAddress,
|
|
1575
1649
|
accounts: {
|
|
@@ -1578,7 +1652,8 @@ function parseInitSubscriptionAuthorityInstruction(instruction) {
|
|
|
1578
1652
|
tokenMint: getNextAccount(),
|
|
1579
1653
|
userAta: getNextAccount(),
|
|
1580
1654
|
systemProgram: getNextAccount(),
|
|
1581
|
-
tokenProgram: getNextAccount()
|
|
1655
|
+
tokenProgram: getNextAccount(),
|
|
1656
|
+
payer: getNextOptionalAccount()
|
|
1582
1657
|
},
|
|
1583
1658
|
data: getInitSubscriptionAuthorityInstructionDataDecoder().decode(instruction.data)
|
|
1584
1659
|
};
|
|
@@ -1609,6 +1684,7 @@ async function getResumeSubscriptionInstructionAsync(input, config) {
|
|
|
1609
1684
|
subscriber: { value: input.subscriber ?? null, isWritable: false },
|
|
1610
1685
|
planPda: { value: input.planPda ?? null, isWritable: false },
|
|
1611
1686
|
subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
|
|
1687
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
1612
1688
|
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
1613
1689
|
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
1614
1690
|
};
|
|
@@ -1620,10 +1696,14 @@ async function getResumeSubscriptionInstructionAsync(input, config) {
|
|
|
1620
1696
|
});
|
|
1621
1697
|
}
|
|
1622
1698
|
if (!accounts.eventAuthority.value) {
|
|
1623
|
-
accounts.eventAuthority.value =
|
|
1699
|
+
accounts.eventAuthority.value = await (0, import_kit30.getProgramDerivedAddress)({
|
|
1700
|
+
programAddress,
|
|
1701
|
+
seeds: [(0, import_kit30.getUtf8Encoder)().encode("event_authority")]
|
|
1702
|
+
});
|
|
1624
1703
|
}
|
|
1625
1704
|
if (!accounts.selfProgram.value) {
|
|
1626
|
-
accounts.selfProgram.value =
|
|
1705
|
+
accounts.selfProgram.value = programAddress;
|
|
1706
|
+
accounts.selfProgram.isWritable = false;
|
|
1627
1707
|
}
|
|
1628
1708
|
const getAccountMeta = (0, import_program_client_core8.getAccountMetaFactory)(programAddress, "programId");
|
|
1629
1709
|
return Object.freeze({
|
|
@@ -1631,6 +1711,7 @@ async function getResumeSubscriptionInstructionAsync(input, config) {
|
|
|
1631
1711
|
getAccountMeta("subscriber", accounts.subscriber),
|
|
1632
1712
|
getAccountMeta("planPda", accounts.planPda),
|
|
1633
1713
|
getAccountMeta("subscriptionPda", accounts.subscriptionPda),
|
|
1714
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1634
1715
|
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
1635
1716
|
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
1636
1717
|
],
|
|
@@ -1644,15 +1725,14 @@ function getResumeSubscriptionInstruction(input, config) {
|
|
|
1644
1725
|
subscriber: { value: input.subscriber ?? null, isWritable: false },
|
|
1645
1726
|
planPda: { value: input.planPda ?? null, isWritable: false },
|
|
1646
1727
|
subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
|
|
1728
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
1647
1729
|
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
1648
1730
|
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
1649
1731
|
};
|
|
1650
1732
|
const accounts = originalAccounts;
|
|
1651
|
-
if (!accounts.eventAuthority.value) {
|
|
1652
|
-
accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
|
|
1653
|
-
}
|
|
1654
1733
|
if (!accounts.selfProgram.value) {
|
|
1655
|
-
accounts.selfProgram.value =
|
|
1734
|
+
accounts.selfProgram.value = programAddress;
|
|
1735
|
+
accounts.selfProgram.isWritable = false;
|
|
1656
1736
|
}
|
|
1657
1737
|
const getAccountMeta = (0, import_program_client_core8.getAccountMetaFactory)(programAddress, "programId");
|
|
1658
1738
|
return Object.freeze({
|
|
@@ -1660,6 +1740,7 @@ function getResumeSubscriptionInstruction(input, config) {
|
|
|
1660
1740
|
getAccountMeta("subscriber", accounts.subscriber),
|
|
1661
1741
|
getAccountMeta("planPda", accounts.planPda),
|
|
1662
1742
|
getAccountMeta("subscriptionPda", accounts.subscriptionPda),
|
|
1743
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1663
1744
|
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
1664
1745
|
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
1665
1746
|
],
|
|
@@ -1668,10 +1749,10 @@ function getResumeSubscriptionInstruction(input, config) {
|
|
|
1668
1749
|
});
|
|
1669
1750
|
}
|
|
1670
1751
|
function parseResumeSubscriptionInstruction(instruction) {
|
|
1671
|
-
if (instruction.accounts.length <
|
|
1752
|
+
if (instruction.accounts.length < 6) {
|
|
1672
1753
|
throw new import_kit30.SolanaError(import_kit30.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1673
1754
|
actualAccountMetas: instruction.accounts.length,
|
|
1674
|
-
expectedAccountMetas:
|
|
1755
|
+
expectedAccountMetas: 6
|
|
1675
1756
|
});
|
|
1676
1757
|
}
|
|
1677
1758
|
let accountIndex = 0;
|
|
@@ -1686,6 +1767,7 @@ function parseResumeSubscriptionInstruction(instruction) {
|
|
|
1686
1767
|
subscriber: getNextAccount(),
|
|
1687
1768
|
planPda: getNextAccount(),
|
|
1688
1769
|
subscriptionPda: getNextAccount(),
|
|
1770
|
+
subscriptionAuthority: getNextAccount(),
|
|
1689
1771
|
eventAuthority: getNextAccount(),
|
|
1690
1772
|
selfProgram: getNextAccount()
|
|
1691
1773
|
},
|
|
@@ -1693,24 +1775,157 @@ function parseResumeSubscriptionInstruction(instruction) {
|
|
|
1693
1775
|
};
|
|
1694
1776
|
}
|
|
1695
1777
|
|
|
1696
|
-
// src/generated/instructions/
|
|
1778
|
+
// src/generated/instructions/revokeAbandonedDelegation.ts
|
|
1697
1779
|
var import_kit31 = require("@solana/kit");
|
|
1698
1780
|
var import_program_client_core9 = require("@solana/program-client-core");
|
|
1781
|
+
var REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR = 15;
|
|
1782
|
+
function getRevokeAbandonedDelegationDiscriminatorBytes() {
|
|
1783
|
+
return (0, import_kit31.getU8Encoder)().encode(REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR);
|
|
1784
|
+
}
|
|
1785
|
+
function getRevokeAbandonedDelegationInstructionDataEncoder() {
|
|
1786
|
+
return (0, import_kit31.transformEncoder)((0, import_kit31.getStructEncoder)([["discriminator", (0, import_kit31.getU8Encoder)()]]), (value) => ({
|
|
1787
|
+
...value,
|
|
1788
|
+
discriminator: REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR
|
|
1789
|
+
}));
|
|
1790
|
+
}
|
|
1791
|
+
function getRevokeAbandonedDelegationInstructionDataDecoder() {
|
|
1792
|
+
return (0, import_kit31.getStructDecoder)([["discriminator", (0, import_kit31.getU8Decoder)()]]);
|
|
1793
|
+
}
|
|
1794
|
+
function getRevokeAbandonedDelegationInstructionDataCodec() {
|
|
1795
|
+
return (0, import_kit31.combineCodec)(
|
|
1796
|
+
getRevokeAbandonedDelegationInstructionDataEncoder(),
|
|
1797
|
+
getRevokeAbandonedDelegationInstructionDataDecoder()
|
|
1798
|
+
);
|
|
1799
|
+
}
|
|
1800
|
+
function getRevokeAbandonedDelegationInstruction(input, config) {
|
|
1801
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1802
|
+
const originalAccounts = {
|
|
1803
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
1804
|
+
delegationAccount: { value: input.delegationAccount ?? null, isWritable: true },
|
|
1805
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false }
|
|
1806
|
+
};
|
|
1807
|
+
const accounts = originalAccounts;
|
|
1808
|
+
const getAccountMeta = (0, import_program_client_core9.getAccountMetaFactory)(programAddress, "programId");
|
|
1809
|
+
return Object.freeze({
|
|
1810
|
+
accounts: [
|
|
1811
|
+
getAccountMeta("payer", accounts.payer),
|
|
1812
|
+
getAccountMeta("delegationAccount", accounts.delegationAccount),
|
|
1813
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority)
|
|
1814
|
+
],
|
|
1815
|
+
data: getRevokeAbandonedDelegationInstructionDataEncoder().encode({}),
|
|
1816
|
+
programAddress
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
function parseRevokeAbandonedDelegationInstruction(instruction) {
|
|
1820
|
+
if (instruction.accounts.length < 3) {
|
|
1821
|
+
throw new import_kit31.SolanaError(import_kit31.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1822
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1823
|
+
expectedAccountMetas: 3
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
let accountIndex = 0;
|
|
1827
|
+
const getNextAccount = () => {
|
|
1828
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1829
|
+
accountIndex += 1;
|
|
1830
|
+
return accountMeta;
|
|
1831
|
+
};
|
|
1832
|
+
return {
|
|
1833
|
+
programAddress: instruction.programAddress,
|
|
1834
|
+
accounts: {
|
|
1835
|
+
payer: getNextAccount(),
|
|
1836
|
+
delegationAccount: getNextAccount(),
|
|
1837
|
+
subscriptionAuthority: getNextAccount()
|
|
1838
|
+
},
|
|
1839
|
+
data: getRevokeAbandonedDelegationInstructionDataDecoder().decode(instruction.data)
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
// src/generated/instructions/revokeAbandonedSubscription.ts
|
|
1844
|
+
var import_kit32 = require("@solana/kit");
|
|
1845
|
+
var import_program_client_core10 = require("@solana/program-client-core");
|
|
1846
|
+
var REVOKE_ABANDONED_SUBSCRIPTION_DISCRIMINATOR = 16;
|
|
1847
|
+
function getRevokeAbandonedSubscriptionDiscriminatorBytes() {
|
|
1848
|
+
return (0, import_kit32.getU8Encoder)().encode(REVOKE_ABANDONED_SUBSCRIPTION_DISCRIMINATOR);
|
|
1849
|
+
}
|
|
1850
|
+
function getRevokeAbandonedSubscriptionInstructionDataEncoder() {
|
|
1851
|
+
return (0, import_kit32.transformEncoder)((0, import_kit32.getStructEncoder)([["discriminator", (0, import_kit32.getU8Encoder)()]]), (value) => ({
|
|
1852
|
+
...value,
|
|
1853
|
+
discriminator: REVOKE_ABANDONED_SUBSCRIPTION_DISCRIMINATOR
|
|
1854
|
+
}));
|
|
1855
|
+
}
|
|
1856
|
+
function getRevokeAbandonedSubscriptionInstructionDataDecoder() {
|
|
1857
|
+
return (0, import_kit32.getStructDecoder)([["discriminator", (0, import_kit32.getU8Decoder)()]]);
|
|
1858
|
+
}
|
|
1859
|
+
function getRevokeAbandonedSubscriptionInstructionDataCodec() {
|
|
1860
|
+
return (0, import_kit32.combineCodec)(
|
|
1861
|
+
getRevokeAbandonedSubscriptionInstructionDataEncoder(),
|
|
1862
|
+
getRevokeAbandonedSubscriptionInstructionDataDecoder()
|
|
1863
|
+
);
|
|
1864
|
+
}
|
|
1865
|
+
function getRevokeAbandonedSubscriptionInstruction(input, config) {
|
|
1866
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1867
|
+
const originalAccounts = {
|
|
1868
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
1869
|
+
subscriptionAccount: { value: input.subscriptionAccount ?? null, isWritable: true },
|
|
1870
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
1871
|
+
planPda: { value: input.planPda ?? null, isWritable: false }
|
|
1872
|
+
};
|
|
1873
|
+
const accounts = originalAccounts;
|
|
1874
|
+
const getAccountMeta = (0, import_program_client_core10.getAccountMetaFactory)(programAddress, "programId");
|
|
1875
|
+
return Object.freeze({
|
|
1876
|
+
accounts: [
|
|
1877
|
+
getAccountMeta("payer", accounts.payer),
|
|
1878
|
+
getAccountMeta("subscriptionAccount", accounts.subscriptionAccount),
|
|
1879
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1880
|
+
getAccountMeta("planPda", accounts.planPda)
|
|
1881
|
+
],
|
|
1882
|
+
data: getRevokeAbandonedSubscriptionInstructionDataEncoder().encode({}),
|
|
1883
|
+
programAddress
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
function parseRevokeAbandonedSubscriptionInstruction(instruction) {
|
|
1887
|
+
if (instruction.accounts.length < 4) {
|
|
1888
|
+
throw new import_kit32.SolanaError(import_kit32.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1889
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1890
|
+
expectedAccountMetas: 4
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
let accountIndex = 0;
|
|
1894
|
+
const getNextAccount = () => {
|
|
1895
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1896
|
+
accountIndex += 1;
|
|
1897
|
+
return accountMeta;
|
|
1898
|
+
};
|
|
1899
|
+
return {
|
|
1900
|
+
programAddress: instruction.programAddress,
|
|
1901
|
+
accounts: {
|
|
1902
|
+
payer: getNextAccount(),
|
|
1903
|
+
subscriptionAccount: getNextAccount(),
|
|
1904
|
+
subscriptionAuthority: getNextAccount(),
|
|
1905
|
+
planPda: getNextAccount()
|
|
1906
|
+
},
|
|
1907
|
+
data: getRevokeAbandonedSubscriptionInstructionDataDecoder().decode(instruction.data)
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
// src/generated/instructions/revokeDelegation.ts
|
|
1912
|
+
var import_kit33 = require("@solana/kit");
|
|
1913
|
+
var import_program_client_core11 = require("@solana/program-client-core");
|
|
1699
1914
|
var REVOKE_DELEGATION_DISCRIMINATOR = 3;
|
|
1700
1915
|
function getRevokeDelegationDiscriminatorBytes() {
|
|
1701
|
-
return (0,
|
|
1916
|
+
return (0, import_kit33.getU8Encoder)().encode(REVOKE_DELEGATION_DISCRIMINATOR);
|
|
1702
1917
|
}
|
|
1703
1918
|
function getRevokeDelegationInstructionDataEncoder() {
|
|
1704
|
-
return (0,
|
|
1919
|
+
return (0, import_kit33.transformEncoder)((0, import_kit33.getStructEncoder)([["discriminator", (0, import_kit33.getU8Encoder)()]]), (value) => ({
|
|
1705
1920
|
...value,
|
|
1706
1921
|
discriminator: REVOKE_DELEGATION_DISCRIMINATOR
|
|
1707
1922
|
}));
|
|
1708
1923
|
}
|
|
1709
1924
|
function getRevokeDelegationInstructionDataDecoder() {
|
|
1710
|
-
return (0,
|
|
1925
|
+
return (0, import_kit33.getStructDecoder)([["discriminator", (0, import_kit33.getU8Decoder)()]]);
|
|
1711
1926
|
}
|
|
1712
1927
|
function getRevokeDelegationInstructionDataCodec() {
|
|
1713
|
-
return (0,
|
|
1928
|
+
return (0, import_kit33.combineCodec)(getRevokeDelegationInstructionDataEncoder(), getRevokeDelegationInstructionDataDecoder());
|
|
1714
1929
|
}
|
|
1715
1930
|
function getRevokeDelegationInstruction(input, config) {
|
|
1716
1931
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -1719,7 +1934,7 @@ function getRevokeDelegationInstruction(input, config) {
|
|
|
1719
1934
|
delegationAccount: { value: input.delegationAccount ?? null, isWritable: true }
|
|
1720
1935
|
};
|
|
1721
1936
|
const accounts = originalAccounts;
|
|
1722
|
-
const getAccountMeta = (0,
|
|
1937
|
+
const getAccountMeta = (0, import_program_client_core11.getAccountMetaFactory)(programAddress, "programId");
|
|
1723
1938
|
return Object.freeze({
|
|
1724
1939
|
accounts: [
|
|
1725
1940
|
getAccountMeta("authority", accounts.authority),
|
|
@@ -1731,7 +1946,7 @@ function getRevokeDelegationInstruction(input, config) {
|
|
|
1731
1946
|
}
|
|
1732
1947
|
function parseRevokeDelegationInstruction(instruction) {
|
|
1733
1948
|
if (instruction.accounts.length < 2) {
|
|
1734
|
-
throw new
|
|
1949
|
+
throw new import_kit33.SolanaError(import_kit33.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1735
1950
|
actualAccountMetas: instruction.accounts.length,
|
|
1736
1951
|
expectedAccountMetas: 2
|
|
1737
1952
|
});
|
|
@@ -1749,30 +1964,141 @@ function parseRevokeDelegationInstruction(instruction) {
|
|
|
1749
1964
|
};
|
|
1750
1965
|
}
|
|
1751
1966
|
|
|
1967
|
+
// src/generated/instructions/revokeSubscriptionAuthority.ts
|
|
1968
|
+
var import_kit34 = require("@solana/kit");
|
|
1969
|
+
var import_program_client_core12 = require("@solana/program-client-core");
|
|
1970
|
+
var REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR = 14;
|
|
1971
|
+
function getRevokeSubscriptionAuthorityDiscriminatorBytes() {
|
|
1972
|
+
return (0, import_kit34.getU8Encoder)().encode(REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR);
|
|
1973
|
+
}
|
|
1974
|
+
function getRevokeSubscriptionAuthorityInstructionDataEncoder() {
|
|
1975
|
+
return (0, import_kit34.transformEncoder)((0, import_kit34.getStructEncoder)([["discriminator", (0, import_kit34.getU8Encoder)()]]), (value) => ({
|
|
1976
|
+
...value,
|
|
1977
|
+
discriminator: REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR
|
|
1978
|
+
}));
|
|
1979
|
+
}
|
|
1980
|
+
function getRevokeSubscriptionAuthorityInstructionDataDecoder() {
|
|
1981
|
+
return (0, import_kit34.getStructDecoder)([["discriminator", (0, import_kit34.getU8Decoder)()]]);
|
|
1982
|
+
}
|
|
1983
|
+
function getRevokeSubscriptionAuthorityInstructionDataCodec() {
|
|
1984
|
+
return (0, import_kit34.combineCodec)(
|
|
1985
|
+
getRevokeSubscriptionAuthorityInstructionDataEncoder(),
|
|
1986
|
+
getRevokeSubscriptionAuthorityInstructionDataDecoder()
|
|
1987
|
+
);
|
|
1988
|
+
}
|
|
1989
|
+
async function getRevokeSubscriptionAuthorityInstructionAsync(input, config) {
|
|
1990
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1991
|
+
const originalAccounts = {
|
|
1992
|
+
user: { value: input.user ?? null, isWritable: true },
|
|
1993
|
+
userAta: { value: input.userAta ?? null, isWritable: true },
|
|
1994
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
1995
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
1996
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: true },
|
|
1997
|
+
receiver: { value: input.receiver ?? null, isWritable: true }
|
|
1998
|
+
};
|
|
1999
|
+
const accounts = originalAccounts;
|
|
2000
|
+
if (!accounts.subscriptionAuthority.value) {
|
|
2001
|
+
accounts.subscriptionAuthority.value = await findSubscriptionAuthorityPda({
|
|
2002
|
+
user: (0, import_program_client_core12.getAddressFromResolvedInstructionAccount)("user", accounts.user.value),
|
|
2003
|
+
tokenMint: (0, import_program_client_core12.getAddressFromResolvedInstructionAccount)("tokenMint", accounts.tokenMint.value)
|
|
2004
|
+
});
|
|
2005
|
+
}
|
|
2006
|
+
const getAccountMeta = (0, import_program_client_core12.getAccountMetaFactory)(programAddress, "omitted");
|
|
2007
|
+
return Object.freeze({
|
|
2008
|
+
accounts: [
|
|
2009
|
+
getAccountMeta("user", accounts.user),
|
|
2010
|
+
getAccountMeta("userAta", accounts.userAta),
|
|
2011
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
2012
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
2013
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
2014
|
+
getAccountMeta("receiver", accounts.receiver)
|
|
2015
|
+
].filter((x) => x !== void 0),
|
|
2016
|
+
data: getRevokeSubscriptionAuthorityInstructionDataEncoder().encode({}),
|
|
2017
|
+
programAddress
|
|
2018
|
+
});
|
|
2019
|
+
}
|
|
2020
|
+
function getRevokeSubscriptionAuthorityInstruction(input, config) {
|
|
2021
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2022
|
+
const originalAccounts = {
|
|
2023
|
+
user: { value: input.user ?? null, isWritable: true },
|
|
2024
|
+
userAta: { value: input.userAta ?? null, isWritable: true },
|
|
2025
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
2026
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
2027
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: true },
|
|
2028
|
+
receiver: { value: input.receiver ?? null, isWritable: true }
|
|
2029
|
+
};
|
|
2030
|
+
const accounts = originalAccounts;
|
|
2031
|
+
const getAccountMeta = (0, import_program_client_core12.getAccountMetaFactory)(programAddress, "omitted");
|
|
2032
|
+
return Object.freeze({
|
|
2033
|
+
accounts: [
|
|
2034
|
+
getAccountMeta("user", accounts.user),
|
|
2035
|
+
getAccountMeta("userAta", accounts.userAta),
|
|
2036
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
2037
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
2038
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
2039
|
+
getAccountMeta("receiver", accounts.receiver)
|
|
2040
|
+
].filter((x) => x !== void 0),
|
|
2041
|
+
data: getRevokeSubscriptionAuthorityInstructionDataEncoder().encode({}),
|
|
2042
|
+
programAddress
|
|
2043
|
+
});
|
|
2044
|
+
}
|
|
2045
|
+
function parseRevokeSubscriptionAuthorityInstruction(instruction) {
|
|
2046
|
+
if (instruction.accounts.length < 5) {
|
|
2047
|
+
throw new import_kit34.SolanaError(import_kit34.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
2048
|
+
actualAccountMetas: instruction.accounts.length,
|
|
2049
|
+
expectedAccountMetas: 5
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
let accountIndex = 0;
|
|
2053
|
+
const getNextAccount = () => {
|
|
2054
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
2055
|
+
accountIndex += 1;
|
|
2056
|
+
return accountMeta;
|
|
2057
|
+
};
|
|
2058
|
+
let optionalAccountsRemaining = instruction.accounts.length - 5;
|
|
2059
|
+
const getNextOptionalAccount = () => {
|
|
2060
|
+
if (optionalAccountsRemaining === 0) return void 0;
|
|
2061
|
+
optionalAccountsRemaining -= 1;
|
|
2062
|
+
return getNextAccount();
|
|
2063
|
+
};
|
|
2064
|
+
return {
|
|
2065
|
+
programAddress: instruction.programAddress,
|
|
2066
|
+
accounts: {
|
|
2067
|
+
user: getNextAccount(),
|
|
2068
|
+
userAta: getNextAccount(),
|
|
2069
|
+
tokenMint: getNextAccount(),
|
|
2070
|
+
tokenProgram: getNextAccount(),
|
|
2071
|
+
subscriptionAuthority: getNextAccount(),
|
|
2072
|
+
receiver: getNextOptionalAccount()
|
|
2073
|
+
},
|
|
2074
|
+
data: getRevokeSubscriptionAuthorityInstructionDataDecoder().decode(instruction.data)
|
|
2075
|
+
};
|
|
2076
|
+
}
|
|
2077
|
+
|
|
1752
2078
|
// src/generated/instructions/subscribe.ts
|
|
1753
|
-
var
|
|
1754
|
-
var
|
|
2079
|
+
var import_kit35 = require("@solana/kit");
|
|
2080
|
+
var import_program_client_core13 = require("@solana/program-client-core");
|
|
1755
2081
|
var SUBSCRIBE_DISCRIMINATOR = 11;
|
|
1756
2082
|
function getSubscribeDiscriminatorBytes() {
|
|
1757
|
-
return (0,
|
|
2083
|
+
return (0, import_kit35.getU8Encoder)().encode(SUBSCRIBE_DISCRIMINATOR);
|
|
1758
2084
|
}
|
|
1759
2085
|
function getSubscribeInstructionDataEncoder() {
|
|
1760
|
-
return (0,
|
|
1761
|
-
(0,
|
|
1762
|
-
["discriminator", (0,
|
|
2086
|
+
return (0, import_kit35.transformEncoder)(
|
|
2087
|
+
(0, import_kit35.getStructEncoder)([
|
|
2088
|
+
["discriminator", (0, import_kit35.getU8Encoder)()],
|
|
1763
2089
|
["subscribeData", getSubscribeDataEncoder()]
|
|
1764
2090
|
]),
|
|
1765
2091
|
(value) => ({ ...value, discriminator: SUBSCRIBE_DISCRIMINATOR })
|
|
1766
2092
|
);
|
|
1767
2093
|
}
|
|
1768
2094
|
function getSubscribeInstructionDataDecoder() {
|
|
1769
|
-
return (0,
|
|
1770
|
-
["discriminator", (0,
|
|
2095
|
+
return (0, import_kit35.getStructDecoder)([
|
|
2096
|
+
["discriminator", (0, import_kit35.getU8Decoder)()],
|
|
1771
2097
|
["subscribeData", getSubscribeDataDecoder()]
|
|
1772
2098
|
]);
|
|
1773
2099
|
}
|
|
1774
2100
|
function getSubscribeInstructionDataCodec() {
|
|
1775
|
-
return (0,
|
|
2101
|
+
return (0, import_kit35.combineCodec)(getSubscribeInstructionDataEncoder(), getSubscribeInstructionDataDecoder());
|
|
1776
2102
|
}
|
|
1777
2103
|
async function getSubscribeInstructionAsync(input, config) {
|
|
1778
2104
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -1784,26 +2110,31 @@ async function getSubscribeInstructionAsync(input, config) {
|
|
|
1784
2110
|
subscriptionAuthorityPda: { value: input.subscriptionAuthorityPda ?? null, isWritable: false },
|
|
1785
2111
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1786
2112
|
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
1787
|
-
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
2113
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false },
|
|
2114
|
+
payer: { value: input.payer ?? null, isWritable: true }
|
|
1788
2115
|
};
|
|
1789
2116
|
const accounts = originalAccounts;
|
|
1790
2117
|
const args = { ...input };
|
|
1791
2118
|
if (!accounts.subscriptionPda.value) {
|
|
1792
2119
|
accounts.subscriptionPda.value = await findSubscriptionDelegationPda({
|
|
1793
|
-
planPda: (0,
|
|
1794
|
-
subscriber: (0,
|
|
2120
|
+
planPda: (0, import_program_client_core13.getAddressFromResolvedInstructionAccount)("planPda", accounts.planPda.value),
|
|
2121
|
+
subscriber: (0, import_program_client_core13.getAddressFromResolvedInstructionAccount)("subscriber", accounts.subscriber.value)
|
|
1795
2122
|
});
|
|
1796
2123
|
}
|
|
1797
2124
|
if (!accounts.systemProgram.value) {
|
|
1798
2125
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1799
2126
|
}
|
|
1800
2127
|
if (!accounts.eventAuthority.value) {
|
|
1801
|
-
accounts.eventAuthority.value =
|
|
2128
|
+
accounts.eventAuthority.value = await (0, import_kit35.getProgramDerivedAddress)({
|
|
2129
|
+
programAddress,
|
|
2130
|
+
seeds: [(0, import_kit35.getUtf8Encoder)().encode("event_authority")]
|
|
2131
|
+
});
|
|
1802
2132
|
}
|
|
1803
2133
|
if (!accounts.selfProgram.value) {
|
|
1804
|
-
accounts.selfProgram.value =
|
|
2134
|
+
accounts.selfProgram.value = programAddress;
|
|
2135
|
+
accounts.selfProgram.isWritable = false;
|
|
1805
2136
|
}
|
|
1806
|
-
const getAccountMeta = (0,
|
|
2137
|
+
const getAccountMeta = (0, import_program_client_core13.getAccountMetaFactory)(programAddress, "omitted");
|
|
1807
2138
|
return Object.freeze({
|
|
1808
2139
|
accounts: [
|
|
1809
2140
|
getAccountMeta("subscriber", accounts.subscriber),
|
|
@@ -1813,8 +2144,9 @@ async function getSubscribeInstructionAsync(input, config) {
|
|
|
1813
2144
|
getAccountMeta("subscriptionAuthorityPda", accounts.subscriptionAuthorityPda),
|
|
1814
2145
|
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
1815
2146
|
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
1816
|
-
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
1817
|
-
|
|
2147
|
+
getAccountMeta("selfProgram", accounts.selfProgram),
|
|
2148
|
+
getAccountMeta("payer", accounts.payer)
|
|
2149
|
+
].filter((x) => x !== void 0),
|
|
1818
2150
|
data: getSubscribeInstructionDataEncoder().encode(args),
|
|
1819
2151
|
programAddress
|
|
1820
2152
|
});
|
|
@@ -1829,20 +2161,19 @@ function getSubscribeInstruction(input, config) {
|
|
|
1829
2161
|
subscriptionAuthorityPda: { value: input.subscriptionAuthorityPda ?? null, isWritable: false },
|
|
1830
2162
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1831
2163
|
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
1832
|
-
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
2164
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false },
|
|
2165
|
+
payer: { value: input.payer ?? null, isWritable: true }
|
|
1833
2166
|
};
|
|
1834
2167
|
const accounts = originalAccounts;
|
|
1835
2168
|
const args = { ...input };
|
|
1836
2169
|
if (!accounts.systemProgram.value) {
|
|
1837
2170
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1838
2171
|
}
|
|
1839
|
-
if (!accounts.eventAuthority.value) {
|
|
1840
|
-
accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
|
|
1841
|
-
}
|
|
1842
2172
|
if (!accounts.selfProgram.value) {
|
|
1843
|
-
accounts.selfProgram.value =
|
|
2173
|
+
accounts.selfProgram.value = programAddress;
|
|
2174
|
+
accounts.selfProgram.isWritable = false;
|
|
1844
2175
|
}
|
|
1845
|
-
const getAccountMeta = (0,
|
|
2176
|
+
const getAccountMeta = (0, import_program_client_core13.getAccountMetaFactory)(programAddress, "omitted");
|
|
1846
2177
|
return Object.freeze({
|
|
1847
2178
|
accounts: [
|
|
1848
2179
|
getAccountMeta("subscriber", accounts.subscriber),
|
|
@@ -1852,15 +2183,16 @@ function getSubscribeInstruction(input, config) {
|
|
|
1852
2183
|
getAccountMeta("subscriptionAuthorityPda", accounts.subscriptionAuthorityPda),
|
|
1853
2184
|
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
1854
2185
|
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
1855
|
-
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
1856
|
-
|
|
2186
|
+
getAccountMeta("selfProgram", accounts.selfProgram),
|
|
2187
|
+
getAccountMeta("payer", accounts.payer)
|
|
2188
|
+
].filter((x) => x !== void 0),
|
|
1857
2189
|
data: getSubscribeInstructionDataEncoder().encode(args),
|
|
1858
2190
|
programAddress
|
|
1859
2191
|
});
|
|
1860
2192
|
}
|
|
1861
2193
|
function parseSubscribeInstruction(instruction) {
|
|
1862
2194
|
if (instruction.accounts.length < 8) {
|
|
1863
|
-
throw new
|
|
2195
|
+
throw new import_kit35.SolanaError(import_kit35.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1864
2196
|
actualAccountMetas: instruction.accounts.length,
|
|
1865
2197
|
expectedAccountMetas: 8
|
|
1866
2198
|
});
|
|
@@ -1871,6 +2203,12 @@ function parseSubscribeInstruction(instruction) {
|
|
|
1871
2203
|
accountIndex += 1;
|
|
1872
2204
|
return accountMeta;
|
|
1873
2205
|
};
|
|
2206
|
+
let optionalAccountsRemaining = instruction.accounts.length - 8;
|
|
2207
|
+
const getNextOptionalAccount = () => {
|
|
2208
|
+
if (optionalAccountsRemaining === 0) return void 0;
|
|
2209
|
+
optionalAccountsRemaining -= 1;
|
|
2210
|
+
return getNextAccount();
|
|
2211
|
+
};
|
|
1874
2212
|
return {
|
|
1875
2213
|
programAddress: instruction.programAddress,
|
|
1876
2214
|
accounts: {
|
|
@@ -1881,38 +2219,39 @@ function parseSubscribeInstruction(instruction) {
|
|
|
1881
2219
|
subscriptionAuthorityPda: getNextAccount(),
|
|
1882
2220
|
systemProgram: getNextAccount(),
|
|
1883
2221
|
eventAuthority: getNextAccount(),
|
|
1884
|
-
selfProgram: getNextAccount()
|
|
2222
|
+
selfProgram: getNextAccount(),
|
|
2223
|
+
payer: getNextOptionalAccount()
|
|
1885
2224
|
},
|
|
1886
2225
|
data: getSubscribeInstructionDataDecoder().decode(instruction.data)
|
|
1887
2226
|
};
|
|
1888
2227
|
}
|
|
1889
2228
|
|
|
1890
2229
|
// src/generated/instructions/transferFixed.ts
|
|
1891
|
-
var
|
|
1892
|
-
var
|
|
2230
|
+
var import_kit36 = require("@solana/kit");
|
|
2231
|
+
var import_program_client_core14 = require("@solana/program-client-core");
|
|
1893
2232
|
var TRANSFER_FIXED_DISCRIMINATOR = 4;
|
|
1894
2233
|
function getTransferFixedDiscriminatorBytes() {
|
|
1895
|
-
return (0,
|
|
2234
|
+
return (0, import_kit36.getU8Encoder)().encode(TRANSFER_FIXED_DISCRIMINATOR);
|
|
1896
2235
|
}
|
|
1897
2236
|
function getTransferFixedInstructionDataEncoder() {
|
|
1898
|
-
return (0,
|
|
1899
|
-
(0,
|
|
1900
|
-
["discriminator", (0,
|
|
2237
|
+
return (0, import_kit36.transformEncoder)(
|
|
2238
|
+
(0, import_kit36.getStructEncoder)([
|
|
2239
|
+
["discriminator", (0, import_kit36.getU8Encoder)()],
|
|
1901
2240
|
["transferData", getTransferDataEncoder()]
|
|
1902
2241
|
]),
|
|
1903
2242
|
(value) => ({ ...value, discriminator: TRANSFER_FIXED_DISCRIMINATOR })
|
|
1904
2243
|
);
|
|
1905
2244
|
}
|
|
1906
2245
|
function getTransferFixedInstructionDataDecoder() {
|
|
1907
|
-
return (0,
|
|
1908
|
-
["discriminator", (0,
|
|
2246
|
+
return (0, import_kit36.getStructDecoder)([
|
|
2247
|
+
["discriminator", (0, import_kit36.getU8Decoder)()],
|
|
1909
2248
|
["transferData", getTransferDataDecoder()]
|
|
1910
2249
|
]);
|
|
1911
2250
|
}
|
|
1912
2251
|
function getTransferFixedInstructionDataCodec() {
|
|
1913
|
-
return (0,
|
|
2252
|
+
return (0, import_kit36.combineCodec)(getTransferFixedInstructionDataEncoder(), getTransferFixedInstructionDataDecoder());
|
|
1914
2253
|
}
|
|
1915
|
-
function
|
|
2254
|
+
async function getTransferFixedInstructionAsync(input, config) {
|
|
1916
2255
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1917
2256
|
const originalAccounts = {
|
|
1918
2257
|
delegationPda: { value: input.delegationPda ?? null, isWritable: true },
|
|
@@ -1928,12 +2267,16 @@ function getTransferFixedInstruction(input, config) {
|
|
|
1928
2267
|
const accounts = originalAccounts;
|
|
1929
2268
|
const args = { ...input };
|
|
1930
2269
|
if (!accounts.eventAuthority.value) {
|
|
1931
|
-
accounts.eventAuthority.value =
|
|
2270
|
+
accounts.eventAuthority.value = await (0, import_kit36.getProgramDerivedAddress)({
|
|
2271
|
+
programAddress,
|
|
2272
|
+
seeds: [(0, import_kit36.getUtf8Encoder)().encode("event_authority")]
|
|
2273
|
+
});
|
|
1932
2274
|
}
|
|
1933
2275
|
if (!accounts.selfProgram.value) {
|
|
1934
|
-
accounts.selfProgram.value =
|
|
2276
|
+
accounts.selfProgram.value = programAddress;
|
|
2277
|
+
accounts.selfProgram.isWritable = false;
|
|
1935
2278
|
}
|
|
1936
|
-
const getAccountMeta = (0,
|
|
2279
|
+
const getAccountMeta = (0, import_program_client_core14.getAccountMetaFactory)(programAddress, "programId");
|
|
1937
2280
|
return Object.freeze({
|
|
1938
2281
|
accounts: [
|
|
1939
2282
|
getAccountMeta("delegationPda", accounts.delegationPda),
|
|
@@ -1950,9 +2293,45 @@ function getTransferFixedInstruction(input, config) {
|
|
|
1950
2293
|
programAddress
|
|
1951
2294
|
});
|
|
1952
2295
|
}
|
|
1953
|
-
function
|
|
1954
|
-
|
|
1955
|
-
|
|
2296
|
+
function getTransferFixedInstruction(input, config) {
|
|
2297
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2298
|
+
const originalAccounts = {
|
|
2299
|
+
delegationPda: { value: input.delegationPda ?? null, isWritable: true },
|
|
2300
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
2301
|
+
delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
|
|
2302
|
+
receiverAta: { value: input.receiverAta ?? null, isWritable: true },
|
|
2303
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
2304
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
2305
|
+
delegatee: { value: input.delegatee ?? null, isWritable: false },
|
|
2306
|
+
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
2307
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
2308
|
+
};
|
|
2309
|
+
const accounts = originalAccounts;
|
|
2310
|
+
const args = { ...input };
|
|
2311
|
+
if (!accounts.selfProgram.value) {
|
|
2312
|
+
accounts.selfProgram.value = programAddress;
|
|
2313
|
+
accounts.selfProgram.isWritable = false;
|
|
2314
|
+
}
|
|
2315
|
+
const getAccountMeta = (0, import_program_client_core14.getAccountMetaFactory)(programAddress, "programId");
|
|
2316
|
+
return Object.freeze({
|
|
2317
|
+
accounts: [
|
|
2318
|
+
getAccountMeta("delegationPda", accounts.delegationPda),
|
|
2319
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
2320
|
+
getAccountMeta("delegatorAta", accounts.delegatorAta),
|
|
2321
|
+
getAccountMeta("receiverAta", accounts.receiverAta),
|
|
2322
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
2323
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
2324
|
+
getAccountMeta("delegatee", accounts.delegatee),
|
|
2325
|
+
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
2326
|
+
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
2327
|
+
],
|
|
2328
|
+
data: getTransferFixedInstructionDataEncoder().encode(args),
|
|
2329
|
+
programAddress
|
|
2330
|
+
});
|
|
2331
|
+
}
|
|
2332
|
+
function parseTransferFixedInstruction(instruction) {
|
|
2333
|
+
if (instruction.accounts.length < 9) {
|
|
2334
|
+
throw new import_kit36.SolanaError(import_kit36.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1956
2335
|
actualAccountMetas: instruction.accounts.length,
|
|
1957
2336
|
expectedAccountMetas: 9
|
|
1958
2337
|
});
|
|
@@ -1981,31 +2360,31 @@ function parseTransferFixedInstruction(instruction) {
|
|
|
1981
2360
|
}
|
|
1982
2361
|
|
|
1983
2362
|
// src/generated/instructions/transferRecurring.ts
|
|
1984
|
-
var
|
|
1985
|
-
var
|
|
2363
|
+
var import_kit37 = require("@solana/kit");
|
|
2364
|
+
var import_program_client_core15 = require("@solana/program-client-core");
|
|
1986
2365
|
var TRANSFER_RECURRING_DISCRIMINATOR = 5;
|
|
1987
2366
|
function getTransferRecurringDiscriminatorBytes() {
|
|
1988
|
-
return (0,
|
|
2367
|
+
return (0, import_kit37.getU8Encoder)().encode(TRANSFER_RECURRING_DISCRIMINATOR);
|
|
1989
2368
|
}
|
|
1990
2369
|
function getTransferRecurringInstructionDataEncoder() {
|
|
1991
|
-
return (0,
|
|
1992
|
-
(0,
|
|
1993
|
-
["discriminator", (0,
|
|
2370
|
+
return (0, import_kit37.transformEncoder)(
|
|
2371
|
+
(0, import_kit37.getStructEncoder)([
|
|
2372
|
+
["discriminator", (0, import_kit37.getU8Encoder)()],
|
|
1994
2373
|
["transferData", getTransferDataEncoder()]
|
|
1995
2374
|
]),
|
|
1996
2375
|
(value) => ({ ...value, discriminator: TRANSFER_RECURRING_DISCRIMINATOR })
|
|
1997
2376
|
);
|
|
1998
2377
|
}
|
|
1999
2378
|
function getTransferRecurringInstructionDataDecoder() {
|
|
2000
|
-
return (0,
|
|
2001
|
-
["discriminator", (0,
|
|
2379
|
+
return (0, import_kit37.getStructDecoder)([
|
|
2380
|
+
["discriminator", (0, import_kit37.getU8Decoder)()],
|
|
2002
2381
|
["transferData", getTransferDataDecoder()]
|
|
2003
2382
|
]);
|
|
2004
2383
|
}
|
|
2005
2384
|
function getTransferRecurringInstructionDataCodec() {
|
|
2006
|
-
return (0,
|
|
2385
|
+
return (0, import_kit37.combineCodec)(getTransferRecurringInstructionDataEncoder(), getTransferRecurringInstructionDataDecoder());
|
|
2007
2386
|
}
|
|
2008
|
-
function
|
|
2387
|
+
async function getTransferRecurringInstructionAsync(input, config) {
|
|
2009
2388
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2010
2389
|
const originalAccounts = {
|
|
2011
2390
|
delegationPda: { value: input.delegationPda ?? null, isWritable: true },
|
|
@@ -2021,12 +2400,52 @@ function getTransferRecurringInstruction(input, config) {
|
|
|
2021
2400
|
const accounts = originalAccounts;
|
|
2022
2401
|
const args = { ...input };
|
|
2023
2402
|
if (!accounts.eventAuthority.value) {
|
|
2024
|
-
accounts.eventAuthority.value =
|
|
2403
|
+
accounts.eventAuthority.value = await (0, import_kit37.getProgramDerivedAddress)({
|
|
2404
|
+
programAddress,
|
|
2405
|
+
seeds: [(0, import_kit37.getUtf8Encoder)().encode("event_authority")]
|
|
2406
|
+
});
|
|
2025
2407
|
}
|
|
2026
2408
|
if (!accounts.selfProgram.value) {
|
|
2027
|
-
accounts.selfProgram.value =
|
|
2409
|
+
accounts.selfProgram.value = programAddress;
|
|
2410
|
+
accounts.selfProgram.isWritable = false;
|
|
2411
|
+
}
|
|
2412
|
+
const getAccountMeta = (0, import_program_client_core15.getAccountMetaFactory)(programAddress, "programId");
|
|
2413
|
+
return Object.freeze({
|
|
2414
|
+
accounts: [
|
|
2415
|
+
getAccountMeta("delegationPda", accounts.delegationPda),
|
|
2416
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
2417
|
+
getAccountMeta("delegatorAta", accounts.delegatorAta),
|
|
2418
|
+
getAccountMeta("receiverAta", accounts.receiverAta),
|
|
2419
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
2420
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
2421
|
+
getAccountMeta("delegatee", accounts.delegatee),
|
|
2422
|
+
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
2423
|
+
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
2424
|
+
],
|
|
2425
|
+
data: getTransferRecurringInstructionDataEncoder().encode(args),
|
|
2426
|
+
programAddress
|
|
2427
|
+
});
|
|
2428
|
+
}
|
|
2429
|
+
function getTransferRecurringInstruction(input, config) {
|
|
2430
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2431
|
+
const originalAccounts = {
|
|
2432
|
+
delegationPda: { value: input.delegationPda ?? null, isWritable: true },
|
|
2433
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
2434
|
+
delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
|
|
2435
|
+
receiverAta: { value: input.receiverAta ?? null, isWritable: true },
|
|
2436
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
2437
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
2438
|
+
delegatee: { value: input.delegatee ?? null, isWritable: false },
|
|
2439
|
+
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
2440
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
2441
|
+
};
|
|
2442
|
+
const accounts = originalAccounts;
|
|
2443
|
+
const args = { ...input };
|
|
2444
|
+
if (!accounts.selfProgram.value) {
|
|
2445
|
+
accounts.selfProgram.value = programAddress;
|
|
2446
|
+
accounts.selfProgram.isWritable = false;
|
|
2028
2447
|
}
|
|
2029
|
-
const getAccountMeta = (0,
|
|
2448
|
+
const getAccountMeta = (0, import_program_client_core15.getAccountMetaFactory)(programAddress, "programId");
|
|
2030
2449
|
return Object.freeze({
|
|
2031
2450
|
accounts: [
|
|
2032
2451
|
getAccountMeta("delegationPda", accounts.delegationPda),
|
|
@@ -2045,7 +2464,7 @@ function getTransferRecurringInstruction(input, config) {
|
|
|
2045
2464
|
}
|
|
2046
2465
|
function parseTransferRecurringInstruction(instruction) {
|
|
2047
2466
|
if (instruction.accounts.length < 9) {
|
|
2048
|
-
throw new
|
|
2467
|
+
throw new import_kit37.SolanaError(import_kit37.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
2049
2468
|
actualAccountMetas: instruction.accounts.length,
|
|
2050
2469
|
expectedAccountMetas: 9
|
|
2051
2470
|
});
|
|
@@ -2074,34 +2493,34 @@ function parseTransferRecurringInstruction(instruction) {
|
|
|
2074
2493
|
}
|
|
2075
2494
|
|
|
2076
2495
|
// src/generated/instructions/transferSubscription.ts
|
|
2077
|
-
var
|
|
2078
|
-
var
|
|
2496
|
+
var import_kit38 = require("@solana/kit");
|
|
2497
|
+
var import_program_client_core16 = require("@solana/program-client-core");
|
|
2079
2498
|
var TRANSFER_SUBSCRIPTION_DISCRIMINATOR = 10;
|
|
2080
2499
|
function getTransferSubscriptionDiscriminatorBytes() {
|
|
2081
|
-
return (0,
|
|
2500
|
+
return (0, import_kit38.getU8Encoder)().encode(TRANSFER_SUBSCRIPTION_DISCRIMINATOR);
|
|
2082
2501
|
}
|
|
2083
2502
|
function getTransferSubscriptionInstructionDataEncoder() {
|
|
2084
|
-
return (0,
|
|
2085
|
-
(0,
|
|
2086
|
-
["discriminator", (0,
|
|
2503
|
+
return (0, import_kit38.transformEncoder)(
|
|
2504
|
+
(0, import_kit38.getStructEncoder)([
|
|
2505
|
+
["discriminator", (0, import_kit38.getU8Encoder)()],
|
|
2087
2506
|
["transferData", getTransferDataEncoder()]
|
|
2088
2507
|
]),
|
|
2089
2508
|
(value) => ({ ...value, discriminator: TRANSFER_SUBSCRIPTION_DISCRIMINATOR })
|
|
2090
2509
|
);
|
|
2091
2510
|
}
|
|
2092
2511
|
function getTransferSubscriptionInstructionDataDecoder() {
|
|
2093
|
-
return (0,
|
|
2094
|
-
["discriminator", (0,
|
|
2512
|
+
return (0, import_kit38.getStructDecoder)([
|
|
2513
|
+
["discriminator", (0, import_kit38.getU8Decoder)()],
|
|
2095
2514
|
["transferData", getTransferDataDecoder()]
|
|
2096
2515
|
]);
|
|
2097
2516
|
}
|
|
2098
2517
|
function getTransferSubscriptionInstructionDataCodec() {
|
|
2099
|
-
return (0,
|
|
2518
|
+
return (0, import_kit38.combineCodec)(
|
|
2100
2519
|
getTransferSubscriptionInstructionDataEncoder(),
|
|
2101
2520
|
getTransferSubscriptionInstructionDataDecoder()
|
|
2102
2521
|
);
|
|
2103
2522
|
}
|
|
2104
|
-
function
|
|
2523
|
+
async function getTransferSubscriptionInstructionAsync(input, config) {
|
|
2105
2524
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2106
2525
|
const originalAccounts = {
|
|
2107
2526
|
subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
|
|
@@ -2118,12 +2537,54 @@ function getTransferSubscriptionInstruction(input, config) {
|
|
|
2118
2537
|
const accounts = originalAccounts;
|
|
2119
2538
|
const args = { ...input };
|
|
2120
2539
|
if (!accounts.eventAuthority.value) {
|
|
2121
|
-
accounts.eventAuthority.value =
|
|
2540
|
+
accounts.eventAuthority.value = await (0, import_kit38.getProgramDerivedAddress)({
|
|
2541
|
+
programAddress,
|
|
2542
|
+
seeds: [(0, import_kit38.getUtf8Encoder)().encode("event_authority")]
|
|
2543
|
+
});
|
|
2122
2544
|
}
|
|
2123
2545
|
if (!accounts.selfProgram.value) {
|
|
2124
|
-
accounts.selfProgram.value =
|
|
2546
|
+
accounts.selfProgram.value = programAddress;
|
|
2547
|
+
accounts.selfProgram.isWritable = false;
|
|
2548
|
+
}
|
|
2549
|
+
const getAccountMeta = (0, import_program_client_core16.getAccountMetaFactory)(programAddress, "programId");
|
|
2550
|
+
return Object.freeze({
|
|
2551
|
+
accounts: [
|
|
2552
|
+
getAccountMeta("subscriptionPda", accounts.subscriptionPda),
|
|
2553
|
+
getAccountMeta("planPda", accounts.planPda),
|
|
2554
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
2555
|
+
getAccountMeta("delegatorAta", accounts.delegatorAta),
|
|
2556
|
+
getAccountMeta("receiverAta", accounts.receiverAta),
|
|
2557
|
+
getAccountMeta("caller", accounts.caller),
|
|
2558
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
2559
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
2560
|
+
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
2561
|
+
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
2562
|
+
],
|
|
2563
|
+
data: getTransferSubscriptionInstructionDataEncoder().encode(args),
|
|
2564
|
+
programAddress
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2567
|
+
function getTransferSubscriptionInstruction(input, config) {
|
|
2568
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2569
|
+
const originalAccounts = {
|
|
2570
|
+
subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
|
|
2571
|
+
planPda: { value: input.planPda ?? null, isWritable: false },
|
|
2572
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
2573
|
+
delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
|
|
2574
|
+
receiverAta: { value: input.receiverAta ?? null, isWritable: true },
|
|
2575
|
+
caller: { value: input.caller ?? null, isWritable: false },
|
|
2576
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
2577
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
2578
|
+
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
2579
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
2580
|
+
};
|
|
2581
|
+
const accounts = originalAccounts;
|
|
2582
|
+
const args = { ...input };
|
|
2583
|
+
if (!accounts.selfProgram.value) {
|
|
2584
|
+
accounts.selfProgram.value = programAddress;
|
|
2585
|
+
accounts.selfProgram.isWritable = false;
|
|
2125
2586
|
}
|
|
2126
|
-
const getAccountMeta = (0,
|
|
2587
|
+
const getAccountMeta = (0, import_program_client_core16.getAccountMetaFactory)(programAddress, "programId");
|
|
2127
2588
|
return Object.freeze({
|
|
2128
2589
|
accounts: [
|
|
2129
2590
|
getAccountMeta("subscriptionPda", accounts.subscriptionPda),
|
|
@@ -2143,7 +2604,7 @@ function getTransferSubscriptionInstruction(input, config) {
|
|
|
2143
2604
|
}
|
|
2144
2605
|
function parseTransferSubscriptionInstruction(instruction) {
|
|
2145
2606
|
if (instruction.accounts.length < 10) {
|
|
2146
|
-
throw new
|
|
2607
|
+
throw new import_kit38.SolanaError(import_kit38.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
2147
2608
|
actualAccountMetas: instruction.accounts.length,
|
|
2148
2609
|
expectedAccountMetas: 10
|
|
2149
2610
|
});
|
|
@@ -2173,50 +2634,93 @@ function parseTransferSubscriptionInstruction(instruction) {
|
|
|
2173
2634
|
}
|
|
2174
2635
|
|
|
2175
2636
|
// src/generated/instructions/updatePlan.ts
|
|
2176
|
-
var
|
|
2177
|
-
var
|
|
2637
|
+
var import_kit39 = require("@solana/kit");
|
|
2638
|
+
var import_program_client_core17 = require("@solana/program-client-core");
|
|
2178
2639
|
var UPDATE_PLAN_DISCRIMINATOR = 8;
|
|
2179
2640
|
function getUpdatePlanDiscriminatorBytes() {
|
|
2180
|
-
return (0,
|
|
2641
|
+
return (0, import_kit39.getU8Encoder)().encode(UPDATE_PLAN_DISCRIMINATOR);
|
|
2181
2642
|
}
|
|
2182
2643
|
function getUpdatePlanInstructionDataEncoder() {
|
|
2183
|
-
return (0,
|
|
2184
|
-
(0,
|
|
2185
|
-
["discriminator", (0,
|
|
2644
|
+
return (0, import_kit39.transformEncoder)(
|
|
2645
|
+
(0, import_kit39.getStructEncoder)([
|
|
2646
|
+
["discriminator", (0, import_kit39.getU8Encoder)()],
|
|
2186
2647
|
["updatePlanData", getUpdatePlanDataEncoder()]
|
|
2187
2648
|
]),
|
|
2188
2649
|
(value) => ({ ...value, discriminator: UPDATE_PLAN_DISCRIMINATOR })
|
|
2189
2650
|
);
|
|
2190
2651
|
}
|
|
2191
2652
|
function getUpdatePlanInstructionDataDecoder() {
|
|
2192
|
-
return (0,
|
|
2193
|
-
["discriminator", (0,
|
|
2653
|
+
return (0, import_kit39.getStructDecoder)([
|
|
2654
|
+
["discriminator", (0, import_kit39.getU8Decoder)()],
|
|
2194
2655
|
["updatePlanData", getUpdatePlanDataDecoder()]
|
|
2195
2656
|
]);
|
|
2196
2657
|
}
|
|
2197
2658
|
function getUpdatePlanInstructionDataCodec() {
|
|
2198
|
-
return (0,
|
|
2659
|
+
return (0, import_kit39.combineCodec)(getUpdatePlanInstructionDataEncoder(), getUpdatePlanInstructionDataDecoder());
|
|
2660
|
+
}
|
|
2661
|
+
async function getUpdatePlanInstructionAsync(input, config) {
|
|
2662
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2663
|
+
const originalAccounts = {
|
|
2664
|
+
owner: { value: input.owner ?? null, isWritable: false },
|
|
2665
|
+
planPda: { value: input.planPda ?? null, isWritable: true },
|
|
2666
|
+
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
2667
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
2668
|
+
};
|
|
2669
|
+
const accounts = originalAccounts;
|
|
2670
|
+
const args = { ...input };
|
|
2671
|
+
if (!accounts.eventAuthority.value) {
|
|
2672
|
+
accounts.eventAuthority.value = await (0, import_kit39.getProgramDerivedAddress)({
|
|
2673
|
+
programAddress,
|
|
2674
|
+
seeds: [(0, import_kit39.getUtf8Encoder)().encode("event_authority")]
|
|
2675
|
+
});
|
|
2676
|
+
}
|
|
2677
|
+
if (!accounts.selfProgram.value) {
|
|
2678
|
+
accounts.selfProgram.value = programAddress;
|
|
2679
|
+
accounts.selfProgram.isWritable = false;
|
|
2680
|
+
}
|
|
2681
|
+
const getAccountMeta = (0, import_program_client_core17.getAccountMetaFactory)(programAddress, "programId");
|
|
2682
|
+
return Object.freeze({
|
|
2683
|
+
accounts: [
|
|
2684
|
+
getAccountMeta("owner", accounts.owner),
|
|
2685
|
+
getAccountMeta("planPda", accounts.planPda),
|
|
2686
|
+
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
2687
|
+
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
2688
|
+
],
|
|
2689
|
+
data: getUpdatePlanInstructionDataEncoder().encode(args),
|
|
2690
|
+
programAddress
|
|
2691
|
+
});
|
|
2199
2692
|
}
|
|
2200
2693
|
function getUpdatePlanInstruction(input, config) {
|
|
2201
2694
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
2202
2695
|
const originalAccounts = {
|
|
2203
2696
|
owner: { value: input.owner ?? null, isWritable: false },
|
|
2204
|
-
planPda: { value: input.planPda ?? null, isWritable: true }
|
|
2697
|
+
planPda: { value: input.planPda ?? null, isWritable: true },
|
|
2698
|
+
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
2699
|
+
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
2205
2700
|
};
|
|
2206
2701
|
const accounts = originalAccounts;
|
|
2207
2702
|
const args = { ...input };
|
|
2208
|
-
|
|
2703
|
+
if (!accounts.selfProgram.value) {
|
|
2704
|
+
accounts.selfProgram.value = programAddress;
|
|
2705
|
+
accounts.selfProgram.isWritable = false;
|
|
2706
|
+
}
|
|
2707
|
+
const getAccountMeta = (0, import_program_client_core17.getAccountMetaFactory)(programAddress, "programId");
|
|
2209
2708
|
return Object.freeze({
|
|
2210
|
-
accounts: [
|
|
2709
|
+
accounts: [
|
|
2710
|
+
getAccountMeta("owner", accounts.owner),
|
|
2711
|
+
getAccountMeta("planPda", accounts.planPda),
|
|
2712
|
+
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
2713
|
+
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
2714
|
+
],
|
|
2211
2715
|
data: getUpdatePlanInstructionDataEncoder().encode(args),
|
|
2212
2716
|
programAddress
|
|
2213
2717
|
});
|
|
2214
2718
|
}
|
|
2215
2719
|
function parseUpdatePlanInstruction(instruction) {
|
|
2216
|
-
if (instruction.accounts.length <
|
|
2217
|
-
throw new
|
|
2720
|
+
if (instruction.accounts.length < 4) {
|
|
2721
|
+
throw new import_kit39.SolanaError(import_kit39.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
2218
2722
|
actualAccountMetas: instruction.accounts.length,
|
|
2219
|
-
expectedAccountMetas:
|
|
2723
|
+
expectedAccountMetas: 4
|
|
2220
2724
|
});
|
|
2221
2725
|
}
|
|
2222
2726
|
let accountIndex = 0;
|
|
@@ -2227,7 +2731,12 @@ function parseUpdatePlanInstruction(instruction) {
|
|
|
2227
2731
|
};
|
|
2228
2732
|
return {
|
|
2229
2733
|
programAddress: instruction.programAddress,
|
|
2230
|
-
accounts: {
|
|
2734
|
+
accounts: {
|
|
2735
|
+
owner: getNextAccount(),
|
|
2736
|
+
planPda: getNextAccount(),
|
|
2737
|
+
eventAuthority: getNextAccount(),
|
|
2738
|
+
selfProgram: getNextAccount()
|
|
2739
|
+
},
|
|
2231
2740
|
data: getUpdatePlanInstructionDataDecoder().decode(instruction.data)
|
|
2232
2741
|
};
|
|
2233
2742
|
}
|
|
@@ -2258,53 +2767,65 @@ var SubscriptionsInstruction = /* @__PURE__ */ ((SubscriptionsInstruction2) => {
|
|
|
2258
2767
|
SubscriptionsInstruction2[SubscriptionsInstruction2["Subscribe"] = 11] = "Subscribe";
|
|
2259
2768
|
SubscriptionsInstruction2[SubscriptionsInstruction2["CancelSubscription"] = 12] = "CancelSubscription";
|
|
2260
2769
|
SubscriptionsInstruction2[SubscriptionsInstruction2["ResumeSubscription"] = 13] = "ResumeSubscription";
|
|
2770
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeSubscriptionAuthority"] = 14] = "RevokeSubscriptionAuthority";
|
|
2771
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeAbandonedDelegation"] = 15] = "RevokeAbandonedDelegation";
|
|
2772
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeAbandonedSubscription"] = 16] = "RevokeAbandonedSubscription";
|
|
2261
2773
|
return SubscriptionsInstruction2;
|
|
2262
2774
|
})(SubscriptionsInstruction || {});
|
|
2263
2775
|
function identifySubscriptionsInstruction(instruction) {
|
|
2264
2776
|
const data = "data" in instruction ? instruction.data : instruction;
|
|
2265
|
-
if ((0,
|
|
2777
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(0), 0)) {
|
|
2266
2778
|
return 0 /* InitSubscriptionAuthority */;
|
|
2267
2779
|
}
|
|
2268
|
-
if ((0,
|
|
2780
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(1), 0)) {
|
|
2269
2781
|
return 1 /* CreateFixedDelegation */;
|
|
2270
2782
|
}
|
|
2271
|
-
if ((0,
|
|
2783
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(2), 0)) {
|
|
2272
2784
|
return 2 /* CreateRecurringDelegation */;
|
|
2273
2785
|
}
|
|
2274
|
-
if ((0,
|
|
2786
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(3), 0)) {
|
|
2275
2787
|
return 3 /* RevokeDelegation */;
|
|
2276
2788
|
}
|
|
2277
|
-
if ((0,
|
|
2789
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(4), 0)) {
|
|
2278
2790
|
return 4 /* TransferFixed */;
|
|
2279
2791
|
}
|
|
2280
|
-
if ((0,
|
|
2792
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(5), 0)) {
|
|
2281
2793
|
return 5 /* TransferRecurring */;
|
|
2282
2794
|
}
|
|
2283
|
-
if ((0,
|
|
2795
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(6), 0)) {
|
|
2284
2796
|
return 6 /* CloseSubscriptionAuthority */;
|
|
2285
2797
|
}
|
|
2286
|
-
if ((0,
|
|
2798
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(7), 0)) {
|
|
2287
2799
|
return 7 /* CreatePlan */;
|
|
2288
2800
|
}
|
|
2289
|
-
if ((0,
|
|
2801
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(8), 0)) {
|
|
2290
2802
|
return 8 /* UpdatePlan */;
|
|
2291
2803
|
}
|
|
2292
|
-
if ((0,
|
|
2804
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(9), 0)) {
|
|
2293
2805
|
return 9 /* DeletePlan */;
|
|
2294
2806
|
}
|
|
2295
|
-
if ((0,
|
|
2807
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(10), 0)) {
|
|
2296
2808
|
return 10 /* TransferSubscription */;
|
|
2297
2809
|
}
|
|
2298
|
-
if ((0,
|
|
2810
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(11), 0)) {
|
|
2299
2811
|
return 11 /* Subscribe */;
|
|
2300
2812
|
}
|
|
2301
|
-
if ((0,
|
|
2813
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(12), 0)) {
|
|
2302
2814
|
return 12 /* CancelSubscription */;
|
|
2303
2815
|
}
|
|
2304
|
-
if ((0,
|
|
2816
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(13), 0)) {
|
|
2305
2817
|
return 13 /* ResumeSubscription */;
|
|
2306
2818
|
}
|
|
2307
|
-
|
|
2819
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(14), 0)) {
|
|
2820
|
+
return 14 /* RevokeSubscriptionAuthority */;
|
|
2821
|
+
}
|
|
2822
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(15), 0)) {
|
|
2823
|
+
return 15 /* RevokeAbandonedDelegation */;
|
|
2824
|
+
}
|
|
2825
|
+
if ((0, import_kit40.containsBytes)(data, (0, import_kit40.getU8Encoder)().encode(16), 0)) {
|
|
2826
|
+
return 16 /* RevokeAbandonedSubscription */;
|
|
2827
|
+
}
|
|
2828
|
+
throw new import_kit40.SolanaError(import_kit40.SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
|
|
2308
2829
|
instructionData: data,
|
|
2309
2830
|
programName: "subscriptions"
|
|
2310
2831
|
});
|
|
@@ -2313,93 +2834,114 @@ function parseSubscriptionsInstruction(instruction) {
|
|
|
2313
2834
|
const instructionType = identifySubscriptionsInstruction(instruction);
|
|
2314
2835
|
switch (instructionType) {
|
|
2315
2836
|
case 0 /* InitSubscriptionAuthority */: {
|
|
2316
|
-
(0,
|
|
2837
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2317
2838
|
return {
|
|
2318
2839
|
instructionType: 0 /* InitSubscriptionAuthority */,
|
|
2319
2840
|
...parseInitSubscriptionAuthorityInstruction(instruction)
|
|
2320
2841
|
};
|
|
2321
2842
|
}
|
|
2322
2843
|
case 1 /* CreateFixedDelegation */: {
|
|
2323
|
-
(0,
|
|
2844
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2324
2845
|
return {
|
|
2325
2846
|
instructionType: 1 /* CreateFixedDelegation */,
|
|
2326
2847
|
...parseCreateFixedDelegationInstruction(instruction)
|
|
2327
2848
|
};
|
|
2328
2849
|
}
|
|
2329
2850
|
case 2 /* CreateRecurringDelegation */: {
|
|
2330
|
-
(0,
|
|
2851
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2331
2852
|
return {
|
|
2332
2853
|
instructionType: 2 /* CreateRecurringDelegation */,
|
|
2333
2854
|
...parseCreateRecurringDelegationInstruction(instruction)
|
|
2334
2855
|
};
|
|
2335
2856
|
}
|
|
2336
2857
|
case 3 /* RevokeDelegation */: {
|
|
2337
|
-
(0,
|
|
2858
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2338
2859
|
return {
|
|
2339
2860
|
instructionType: 3 /* RevokeDelegation */,
|
|
2340
2861
|
...parseRevokeDelegationInstruction(instruction)
|
|
2341
2862
|
};
|
|
2342
2863
|
}
|
|
2343
2864
|
case 4 /* TransferFixed */: {
|
|
2344
|
-
(0,
|
|
2865
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2345
2866
|
return {
|
|
2346
2867
|
instructionType: 4 /* TransferFixed */,
|
|
2347
2868
|
...parseTransferFixedInstruction(instruction)
|
|
2348
2869
|
};
|
|
2349
2870
|
}
|
|
2350
2871
|
case 5 /* TransferRecurring */: {
|
|
2351
|
-
(0,
|
|
2872
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2352
2873
|
return {
|
|
2353
2874
|
instructionType: 5 /* TransferRecurring */,
|
|
2354
2875
|
...parseTransferRecurringInstruction(instruction)
|
|
2355
2876
|
};
|
|
2356
2877
|
}
|
|
2357
2878
|
case 6 /* CloseSubscriptionAuthority */: {
|
|
2358
|
-
(0,
|
|
2879
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2359
2880
|
return {
|
|
2360
2881
|
instructionType: 6 /* CloseSubscriptionAuthority */,
|
|
2361
2882
|
...parseCloseSubscriptionAuthorityInstruction(instruction)
|
|
2362
2883
|
};
|
|
2363
2884
|
}
|
|
2364
2885
|
case 7 /* CreatePlan */: {
|
|
2365
|
-
(0,
|
|
2886
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2366
2887
|
return { instructionType: 7 /* CreatePlan */, ...parseCreatePlanInstruction(instruction) };
|
|
2367
2888
|
}
|
|
2368
2889
|
case 8 /* UpdatePlan */: {
|
|
2369
|
-
(0,
|
|
2890
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2370
2891
|
return { instructionType: 8 /* UpdatePlan */, ...parseUpdatePlanInstruction(instruction) };
|
|
2371
2892
|
}
|
|
2372
2893
|
case 9 /* DeletePlan */: {
|
|
2373
|
-
(0,
|
|
2894
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2374
2895
|
return { instructionType: 9 /* DeletePlan */, ...parseDeletePlanInstruction(instruction) };
|
|
2375
2896
|
}
|
|
2376
2897
|
case 10 /* TransferSubscription */: {
|
|
2377
|
-
(0,
|
|
2898
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2378
2899
|
return {
|
|
2379
2900
|
instructionType: 10 /* TransferSubscription */,
|
|
2380
2901
|
...parseTransferSubscriptionInstruction(instruction)
|
|
2381
2902
|
};
|
|
2382
2903
|
}
|
|
2383
2904
|
case 11 /* Subscribe */: {
|
|
2384
|
-
(0,
|
|
2905
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2385
2906
|
return { instructionType: 11 /* Subscribe */, ...parseSubscribeInstruction(instruction) };
|
|
2386
2907
|
}
|
|
2387
2908
|
case 12 /* CancelSubscription */: {
|
|
2388
|
-
(0,
|
|
2909
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2389
2910
|
return {
|
|
2390
2911
|
instructionType: 12 /* CancelSubscription */,
|
|
2391
2912
|
...parseCancelSubscriptionInstruction(instruction)
|
|
2392
2913
|
};
|
|
2393
2914
|
}
|
|
2394
2915
|
case 13 /* ResumeSubscription */: {
|
|
2395
|
-
(0,
|
|
2916
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2396
2917
|
return {
|
|
2397
2918
|
instructionType: 13 /* ResumeSubscription */,
|
|
2398
2919
|
...parseResumeSubscriptionInstruction(instruction)
|
|
2399
2920
|
};
|
|
2400
2921
|
}
|
|
2922
|
+
case 14 /* RevokeSubscriptionAuthority */: {
|
|
2923
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2924
|
+
return {
|
|
2925
|
+
instructionType: 14 /* RevokeSubscriptionAuthority */,
|
|
2926
|
+
...parseRevokeSubscriptionAuthorityInstruction(instruction)
|
|
2927
|
+
};
|
|
2928
|
+
}
|
|
2929
|
+
case 15 /* RevokeAbandonedDelegation */: {
|
|
2930
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2931
|
+
return {
|
|
2932
|
+
instructionType: 15 /* RevokeAbandonedDelegation */,
|
|
2933
|
+
...parseRevokeAbandonedDelegationInstruction(instruction)
|
|
2934
|
+
};
|
|
2935
|
+
}
|
|
2936
|
+
case 16 /* RevokeAbandonedSubscription */: {
|
|
2937
|
+
(0, import_kit40.assertIsInstructionWithAccounts)(instruction);
|
|
2938
|
+
return {
|
|
2939
|
+
instructionType: 16 /* RevokeAbandonedSubscription */,
|
|
2940
|
+
...parseRevokeAbandonedSubscriptionInstruction(instruction)
|
|
2941
|
+
};
|
|
2942
|
+
}
|
|
2401
2943
|
default:
|
|
2402
|
-
throw new
|
|
2944
|
+
throw new import_kit40.SolanaError(import_kit40.SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
|
|
2403
2945
|
instructionType,
|
|
2404
2946
|
programName: "subscriptions"
|
|
2405
2947
|
});
|
|
@@ -2407,31 +2949,34 @@ function parseSubscriptionsInstruction(instruction) {
|
|
|
2407
2949
|
}
|
|
2408
2950
|
function subscriptionsProgram() {
|
|
2409
2951
|
return (client) => {
|
|
2410
|
-
return (0,
|
|
2952
|
+
return (0, import_kit40.extendClient)(client, {
|
|
2411
2953
|
subscriptions: {
|
|
2412
2954
|
accounts: {
|
|
2413
|
-
fixedDelegation: (0,
|
|
2414
|
-
plan: (0,
|
|
2415
|
-
recurringDelegation: (0,
|
|
2416
|
-
subscriptionAuthority: (0,
|
|
2417
|
-
subscriptionDelegation: (0,
|
|
2418
|
-
eventAuthority: (0,
|
|
2955
|
+
fixedDelegation: (0, import_program_client_core18.addSelfFetchFunctions)(client, getFixedDelegationCodec()),
|
|
2956
|
+
plan: (0, import_program_client_core18.addSelfFetchFunctions)(client, getPlanCodec()),
|
|
2957
|
+
recurringDelegation: (0, import_program_client_core18.addSelfFetchFunctions)(client, getRecurringDelegationCodec()),
|
|
2958
|
+
subscriptionAuthority: (0, import_program_client_core18.addSelfFetchFunctions)(client, getSubscriptionAuthorityCodec()),
|
|
2959
|
+
subscriptionDelegation: (0, import_program_client_core18.addSelfFetchFunctions)(client, getSubscriptionDelegationCodec()),
|
|
2960
|
+
eventAuthority: (0, import_program_client_core18.addSelfFetchFunctions)(client, getEventAuthorityCodec())
|
|
2419
2961
|
},
|
|
2420
2962
|
instructions: {
|
|
2421
|
-
initSubscriptionAuthority: (input) => (0,
|
|
2422
|
-
createFixedDelegation: (input) => (0,
|
|
2423
|
-
createRecurringDelegation: (input) => (0,
|
|
2424
|
-
revokeDelegation: (input) => (0,
|
|
2425
|
-
transferFixed: (input) => (0,
|
|
2426
|
-
transferRecurring: (input) => (0,
|
|
2427
|
-
closeSubscriptionAuthority: (input) => (0,
|
|
2428
|
-
createPlan: (input) => (0,
|
|
2429
|
-
updatePlan: (input) => (0,
|
|
2430
|
-
deletePlan: (input) => (0,
|
|
2431
|
-
transferSubscription: (input) => (0,
|
|
2432
|
-
subscribe: (input) => (0,
|
|
2433
|
-
cancelSubscription: (input) => (0,
|
|
2434
|
-
resumeSubscription: (input) => (0,
|
|
2963
|
+
initSubscriptionAuthority: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getInitSubscriptionAuthorityInstructionAsync(input)),
|
|
2964
|
+
createFixedDelegation: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getCreateFixedDelegationInstruction(input)),
|
|
2965
|
+
createRecurringDelegation: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getCreateRecurringDelegationInstruction(input)),
|
|
2966
|
+
revokeDelegation: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getRevokeDelegationInstruction(input)),
|
|
2967
|
+
transferFixed: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getTransferFixedInstructionAsync(input)),
|
|
2968
|
+
transferRecurring: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getTransferRecurringInstructionAsync(input)),
|
|
2969
|
+
closeSubscriptionAuthority: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getCloseSubscriptionAuthorityInstruction(input)),
|
|
2970
|
+
createPlan: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getCreatePlanInstruction(input)),
|
|
2971
|
+
updatePlan: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getUpdatePlanInstructionAsync(input)),
|
|
2972
|
+
deletePlan: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getDeletePlanInstruction(input)),
|
|
2973
|
+
transferSubscription: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getTransferSubscriptionInstructionAsync(input)),
|
|
2974
|
+
subscribe: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getSubscribeInstructionAsync(input)),
|
|
2975
|
+
cancelSubscription: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getCancelSubscriptionInstructionAsync(input)),
|
|
2976
|
+
resumeSubscription: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getResumeSubscriptionInstructionAsync(input)),
|
|
2977
|
+
revokeSubscriptionAuthority: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getRevokeSubscriptionAuthorityInstructionAsync(input)),
|
|
2978
|
+
revokeAbandonedDelegation: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getRevokeAbandonedDelegationInstruction(input)),
|
|
2979
|
+
revokeAbandonedSubscription: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(client, getRevokeAbandonedSubscriptionInstruction(input))
|
|
2435
2980
|
},
|
|
2436
2981
|
pdas: {
|
|
2437
2982
|
fixedDelegation: findFixedDelegationPda,
|
|
@@ -2484,6 +3029,7 @@ var SUBSCRIPTIONS_ERROR__DELEGATION_VERSION_MISMATCH = 133;
|
|
|
2484
3029
|
var SUBSCRIPTIONS_ERROR__MIGRATION_REQUIRED = 134;
|
|
2485
3030
|
var SUBSCRIPTIONS_ERROR__DELEGATION_ALREADY_EXISTS = 135;
|
|
2486
3031
|
var SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY = 136;
|
|
3032
|
+
var SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS = 137;
|
|
2487
3033
|
var SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_LIMIT = 300;
|
|
2488
3034
|
var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_EXPIRY_IN_PAST = 301;
|
|
2489
3035
|
var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_AMOUNT_ZERO = 302;
|
|
@@ -2495,6 +3041,7 @@ var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST = 404;
|
|
|
2495
3041
|
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY = 405;
|
|
2496
3042
|
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO = 406;
|
|
2497
3043
|
var SUBSCRIPTIONS_ERROR__DELEGATION_NOT_STARTED = 407;
|
|
3044
|
+
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY = 408;
|
|
2498
3045
|
var SUBSCRIPTIONS_ERROR__PLAN_SUNSET = 500;
|
|
2499
3046
|
var SUBSCRIPTIONS_ERROR__PLAN_EXPIRED = 501;
|
|
2500
3047
|
var SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA = 502;
|
|
@@ -2515,10 +3062,12 @@ var SUBSCRIPTIONS_ERROR__PLAN_CLOSED = 516;
|
|
|
2515
3062
|
var SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED = 517;
|
|
2516
3063
|
var SUBSCRIPTIONS_ERROR__PLAN_ALREADY_EXISTS = 518;
|
|
2517
3064
|
var SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH = 519;
|
|
3065
|
+
var SUBSCRIPTIONS_ERROR__PLAN_END_TS_CANNOT_EXTEND = 520;
|
|
2518
3066
|
var SUBSCRIPTIONS_ERROR__INVALID_EVENT_AUTHORITY = 600;
|
|
2519
3067
|
var SUBSCRIPTIONS_ERROR__INVALID_EVENT_DATA = 601;
|
|
2520
3068
|
var SUBSCRIPTIONS_ERROR__INVALID_EVENT_TAG = 602;
|
|
2521
3069
|
var SUBSCRIPTIONS_ERROR__INVALID_EVENT_DISCRIMINATOR = 603;
|
|
3070
|
+
var SUBSCRIPTIONS_ERROR__INVALID_SELF_PROGRAM = 604;
|
|
2522
3071
|
var subscriptionsErrorMessages;
|
|
2523
3072
|
if (process.env["NODE_ENV"] !== "production") {
|
|
2524
3073
|
subscriptionsErrorMessages = {
|
|
@@ -2555,6 +3104,7 @@ if (process.env["NODE_ENV"] !== "production") {
|
|
|
2555
3104
|
[SUBSCRIPTIONS_ERROR__INVALID_PERIOD_LENGTH]: `Invalid Period length`,
|
|
2556
3105
|
[SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA]: `Invalid Plan PDA derivation`,
|
|
2557
3106
|
[SUBSCRIPTIONS_ERROR__INVALID_PLAN_STATUS]: `Invalid plan status value`,
|
|
3107
|
+
[SUBSCRIPTIONS_ERROR__INVALID_SELF_PROGRAM]: `Self program account does not match this program`,
|
|
2558
3108
|
[SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_AUTHORITY_PDA]: `Invalid subscription-authority PDA derivation`,
|
|
2559
3109
|
[SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_PDA]: `Invalid subscription PDA derivation`,
|
|
2560
3110
|
[SUBSCRIPTIONS_ERROR__INVALID_TOKEN2022_MINT_ACCOUNT_DATA]: `Invalid Token-2022 mint account data`,
|
|
@@ -2578,12 +3128,14 @@ if (process.env["NODE_ENV"] !== "production") {
|
|
|
2578
3128
|
[SUBSCRIPTIONS_ERROR__PERIOD_NOT_ELAPSED]: `Period has not elapsed yet`,
|
|
2579
3129
|
[SUBSCRIPTIONS_ERROR__PLAN_ALREADY_EXISTS]: `Plan account already exists`,
|
|
2580
3130
|
[SUBSCRIPTIONS_ERROR__PLAN_CLOSED]: `Plan account has been closed`,
|
|
3131
|
+
[SUBSCRIPTIONS_ERROR__PLAN_END_TS_CANNOT_EXTEND]: `A finite plan end timestamp can only be shortened, not removed or extended`,
|
|
2581
3132
|
[SUBSCRIPTIONS_ERROR__PLAN_EXPIRED]: `Plan has expired`,
|
|
2582
3133
|
[SUBSCRIPTIONS_ERROR__PLAN_IMMUTABLE_AFTER_SUNSET]: `Plan cannot be updated after sunset`,
|
|
2583
3134
|
[SUBSCRIPTIONS_ERROR__PLAN_NOT_EXPIRED]: `Plan must be expired to delete`,
|
|
2584
3135
|
[SUBSCRIPTIONS_ERROR__PLAN_SUNSET]: `Plan is in sunset status`,
|
|
2585
3136
|
[SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH]: `Subscription plan terms do not match the current plan`,
|
|
2586
3137
|
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO]: `zero amount specified`,
|
|
3138
|
+
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY]: `start_ts of 0 (start on landing) requires a non-zero expiry`,
|
|
2587
3139
|
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY]: `start time specified is greater than expiry`,
|
|
2588
3140
|
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST]: `Past start time specified`,
|
|
2589
3141
|
[SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY]: `Delegation init_id does not match current SubscriptionAuthority`,
|
|
@@ -2592,6 +3144,7 @@ if (process.env["NODE_ENV"] !== "production") {
|
|
|
2592
3144
|
[SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED]: `Subscription is not cancelled`,
|
|
2593
3145
|
[SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH]: `Subscription does not belong to this plan`,
|
|
2594
3146
|
[SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS]: `Sunset requires a non-zero end timestamp`,
|
|
3147
|
+
[SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS]: `Too many transfer hook accounts provided`,
|
|
2595
3148
|
[SUBSCRIPTIONS_ERROR__UNAUTHORIZED]: `Caller not authorized for this action`,
|
|
2596
3149
|
[SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION]: `Destination not in plan whitelist`
|
|
2597
3150
|
};
|
|
@@ -2603,7 +3156,7 @@ function getSubscriptionsErrorMessage(code) {
|
|
|
2603
3156
|
return "Error message not available in production bundles.";
|
|
2604
3157
|
}
|
|
2605
3158
|
function isSubscriptionsError(error, transactionMessage, code) {
|
|
2606
|
-
return (0,
|
|
3159
|
+
return (0, import_kit41.isProgramError)(error, transactionMessage, SUBSCRIPTIONS_PROGRAM_ADDRESS, code);
|
|
2607
3160
|
}
|
|
2608
3161
|
|
|
2609
3162
|
// src/constants.ts
|
|
@@ -2628,7 +3181,7 @@ var METADATA_URI_LEN = 128;
|
|
|
2628
3181
|
|
|
2629
3182
|
// src/accounts/decode.ts
|
|
2630
3183
|
function toEncodedAccount(raw, programAddress) {
|
|
2631
|
-
const base64Encoder = (0,
|
|
3184
|
+
const base64Encoder = (0, import_kit42.getBase64Encoder)();
|
|
2632
3185
|
const data = base64Encoder.encode(raw.account.data[0]);
|
|
2633
3186
|
return {
|
|
2634
3187
|
address: raw.pubkey,
|
|
@@ -2745,10 +3298,148 @@ async function fetchSubscriptionsForUser(rpc, user, programAddress) {
|
|
|
2745
3298
|
}
|
|
2746
3299
|
|
|
2747
3300
|
// src/plugin.ts
|
|
2748
|
-
var
|
|
2749
|
-
var
|
|
3301
|
+
var import_kit44 = require("@solana/kit");
|
|
3302
|
+
var import_program_client_core19 = require("@solana/program-client-core");
|
|
2750
3303
|
var import_token = require("@solana-program/token");
|
|
2751
3304
|
|
|
3305
|
+
// src/transfer-hook.ts
|
|
3306
|
+
var import_kit43 = require("@solana/kit");
|
|
3307
|
+
var import_token_2022 = require("@solana-program/token-2022");
|
|
3308
|
+
var DEFAULT_ADDRESS = "11111111111111111111111111111111";
|
|
3309
|
+
var EXTRA_ACCOUNT_METAS_SEED = "extra-account-metas";
|
|
3310
|
+
var TLV_HEADER_LEN = 12;
|
|
3311
|
+
var POD_SLICE_COUNT_LEN = 4;
|
|
3312
|
+
var EXTRA_ACCOUNT_META_LEN = 35;
|
|
3313
|
+
var PUBKEY_LEN = 32;
|
|
3314
|
+
var PDA_PROGRAM_INDEX_OFFSET = 1 << 7;
|
|
3315
|
+
var EXECUTE_DISCRIMINATOR = Uint8Array.from([105, 37, 101, 197, 75, 251, 102, 26]);
|
|
3316
|
+
var addressDecoder = (0, import_kit43.getAddressDecoder)();
|
|
3317
|
+
var addressEncoder = (0, import_kit43.getAddressEncoder)();
|
|
3318
|
+
function roleFor(isSigner, isWritable) {
|
|
3319
|
+
if (isSigner && isWritable) return import_kit43.AccountRole.WRITABLE_SIGNER;
|
|
3320
|
+
if (isSigner) return import_kit43.AccountRole.READONLY_SIGNER;
|
|
3321
|
+
if (isWritable) return import_kit43.AccountRole.WRITABLE;
|
|
3322
|
+
return import_kit43.AccountRole.READONLY;
|
|
3323
|
+
}
|
|
3324
|
+
async function fetchData(rpc, address) {
|
|
3325
|
+
const account = await (0, import_kit43.fetchEncodedAccount)(rpc, address);
|
|
3326
|
+
if (!account.exists) throw new Error("transfer hook: referenced account not found");
|
|
3327
|
+
return account.data;
|
|
3328
|
+
}
|
|
3329
|
+
function executeInstructionData(amount) {
|
|
3330
|
+
const data = new Uint8Array(EXECUTE_DISCRIMINATOR.length + 8);
|
|
3331
|
+
data.set(EXECUTE_DISCRIMINATOR, 0);
|
|
3332
|
+
new DataView(data.buffer).setBigUint64(EXECUTE_DISCRIMINATOR.length, BigInt(amount), true);
|
|
3333
|
+
return data;
|
|
3334
|
+
}
|
|
3335
|
+
function readMetas(data) {
|
|
3336
|
+
if (data.length < TLV_HEADER_LEN || !EXECUTE_DISCRIMINATOR.every((byte, i) => data[i] === byte)) {
|
|
3337
|
+
return [];
|
|
3338
|
+
}
|
|
3339
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
3340
|
+
const count = view.getUint32(TLV_HEADER_LEN, true);
|
|
3341
|
+
const metas = [];
|
|
3342
|
+
let offset = TLV_HEADER_LEN + POD_SLICE_COUNT_LEN;
|
|
3343
|
+
for (let n = 0; n < count && offset + EXTRA_ACCOUNT_META_LEN <= data.length; n++) {
|
|
3344
|
+
metas.push({
|
|
3345
|
+
addressConfig: data.subarray(offset + 1, offset + 33),
|
|
3346
|
+
discriminator: data[offset],
|
|
3347
|
+
isSigner: data[offset + 33] === 1,
|
|
3348
|
+
isWritable: data[offset + 34] === 1
|
|
3349
|
+
});
|
|
3350
|
+
offset += EXTRA_ACCOUNT_META_LEN;
|
|
3351
|
+
}
|
|
3352
|
+
return metas;
|
|
3353
|
+
}
|
|
3354
|
+
async function unpackSeeds(config, previous, instructionData, rpc) {
|
|
3355
|
+
const seeds = [];
|
|
3356
|
+
let i = 0;
|
|
3357
|
+
while (i < 32) {
|
|
3358
|
+
const discriminator = config[i];
|
|
3359
|
+
const rest = config.subarray(i + 1);
|
|
3360
|
+
if (discriminator === 0) break;
|
|
3361
|
+
if (discriminator === 1) {
|
|
3362
|
+
const length = rest[0];
|
|
3363
|
+
seeds.push(rest.subarray(1, 1 + length));
|
|
3364
|
+
i += 2 + length;
|
|
3365
|
+
} else if (discriminator === 2) {
|
|
3366
|
+
const [index, length] = [rest[0], rest[1]];
|
|
3367
|
+
seeds.push(instructionData.subarray(index, index + length));
|
|
3368
|
+
i += 3;
|
|
3369
|
+
} else if (discriminator === 3) {
|
|
3370
|
+
seeds.push(addressEncoder.encode(previous[rest[0]].address));
|
|
3371
|
+
i += 2;
|
|
3372
|
+
} else if (discriminator === 4) {
|
|
3373
|
+
const [accountIndex, dataIndex, length] = [rest[0], rest[1], rest[2]];
|
|
3374
|
+
const data = await fetchData(rpc, previous[accountIndex].address);
|
|
3375
|
+
seeds.push(data.subarray(dataIndex, dataIndex + length));
|
|
3376
|
+
i += 4;
|
|
3377
|
+
} else {
|
|
3378
|
+
throw new Error("transfer hook: invalid seed");
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
return seeds;
|
|
3382
|
+
}
|
|
3383
|
+
async function unpackPubkeyData(config, previous, instructionData, rpc) {
|
|
3384
|
+
const rest = config.subarray(1);
|
|
3385
|
+
if (config[0] === 1) {
|
|
3386
|
+
const offset = rest[0];
|
|
3387
|
+
return addressDecoder.decode(instructionData.subarray(offset, offset + PUBKEY_LEN));
|
|
3388
|
+
}
|
|
3389
|
+
if (config[0] === 2) {
|
|
3390
|
+
const [accountIndex, offset] = [rest[0], rest[1]];
|
|
3391
|
+
const data = await fetchData(rpc, previous[accountIndex].address);
|
|
3392
|
+
return addressDecoder.decode(data.subarray(offset, offset + PUBKEY_LEN));
|
|
3393
|
+
}
|
|
3394
|
+
throw new Error("transfer hook: invalid pubkey data");
|
|
3395
|
+
}
|
|
3396
|
+
async function resolveMeta(meta, previous, instructionData, hookProgram, rpc) {
|
|
3397
|
+
const role = roleFor(meta.isSigner, meta.isWritable);
|
|
3398
|
+
if (meta.discriminator === 0) {
|
|
3399
|
+
return { address: addressDecoder.decode(meta.addressConfig), role };
|
|
3400
|
+
}
|
|
3401
|
+
if (meta.discriminator === 2) {
|
|
3402
|
+
return { address: await unpackPubkeyData(meta.addressConfig, previous, instructionData, rpc), role };
|
|
3403
|
+
}
|
|
3404
|
+
const programId = meta.discriminator === 1 ? hookProgram : previous[meta.discriminator - PDA_PROGRAM_INDEX_OFFSET].address;
|
|
3405
|
+
const seeds = await unpackSeeds(meta.addressConfig, previous, instructionData, rpc);
|
|
3406
|
+
const [pda] = await (0, import_kit43.getProgramDerivedAddress)({ programAddress: programId, seeds });
|
|
3407
|
+
return { address: pda, role };
|
|
3408
|
+
}
|
|
3409
|
+
async function resolveTransferHookAccounts(rpc, args) {
|
|
3410
|
+
if (args.transferHookAccounts?.length) return args.transferHookAccounts;
|
|
3411
|
+
if (args.tokenProgram !== import_token_2022.TOKEN_2022_PROGRAM_ADDRESS) return [];
|
|
3412
|
+
const { data } = await (0, import_token_2022.fetchMint)(rpc, args.mint);
|
|
3413
|
+
const extensions = data.extensions.__option === "Some" ? data.extensions.value : [];
|
|
3414
|
+
const hook = extensions.find((extension) => extension.__kind === "TransferHook");
|
|
3415
|
+
if (!hook || hook.programId === DEFAULT_ADDRESS) return [];
|
|
3416
|
+
const hookProgram = hook.programId;
|
|
3417
|
+
const [validationPda] = await (0, import_kit43.getProgramDerivedAddress)({
|
|
3418
|
+
programAddress: hookProgram,
|
|
3419
|
+
seeds: [EXTRA_ACCOUNT_METAS_SEED, addressEncoder.encode(args.mint)]
|
|
3420
|
+
});
|
|
3421
|
+
const trailing = [
|
|
3422
|
+
{ address: hookProgram, role: import_kit43.AccountRole.READONLY },
|
|
3423
|
+
{ address: validationPda, role: import_kit43.AccountRole.READONLY }
|
|
3424
|
+
];
|
|
3425
|
+
const validationAccount = await (0, import_kit43.fetchEncodedAccount)(rpc, validationPda);
|
|
3426
|
+
if (!validationAccount.exists) return trailing;
|
|
3427
|
+
const instructionData = executeInstructionData(args.amount);
|
|
3428
|
+
const previous = [
|
|
3429
|
+
{ address: args.source, role: import_kit43.AccountRole.READONLY },
|
|
3430
|
+
{ address: args.mint, role: import_kit43.AccountRole.READONLY },
|
|
3431
|
+
{ address: args.destination, role: import_kit43.AccountRole.READONLY },
|
|
3432
|
+
{ address: args.authority, role: import_kit43.AccountRole.READONLY },
|
|
3433
|
+
{ address: validationPda, role: import_kit43.AccountRole.READONLY }
|
|
3434
|
+
];
|
|
3435
|
+
for (const meta of readMetas(validationAccount.data)) {
|
|
3436
|
+
const resolved = await resolveMeta(meta, previous, instructionData, hookProgram, rpc);
|
|
3437
|
+
previous.push(resolved);
|
|
3438
|
+
trailing.push(resolved);
|
|
3439
|
+
}
|
|
3440
|
+
return trailing;
|
|
3441
|
+
}
|
|
3442
|
+
|
|
2752
3443
|
// src/validators.ts
|
|
2753
3444
|
var textEncoder = new TextEncoder();
|
|
2754
3445
|
var ValidationError = class extends Error {
|
|
@@ -2760,6 +3451,10 @@ var ValidationError = class extends Error {
|
|
|
2760
3451
|
function assertPositive(value, name) {
|
|
2761
3452
|
if (BigInt(value) <= 0n) throw new ValidationError(`${name} must be greater than zero`);
|
|
2762
3453
|
}
|
|
3454
|
+
function assertSafeU64(value, name) {
|
|
3455
|
+
if (typeof value === "number" && !Number.isSafeInteger(value))
|
|
3456
|
+
throw new ValidationError(`${name} must be a bigint or a safe integer (numbers above 2^53-1 lose precision)`);
|
|
3457
|
+
}
|
|
2763
3458
|
function assertMetadataUri(metadataUri) {
|
|
2764
3459
|
if (textEncoder.encode(metadataUri).length > METADATA_URI_LEN)
|
|
2765
3460
|
throw new ValidationError(`metadataUri exceeds ${METADATA_URI_LEN} bytes`);
|
|
@@ -2783,6 +3478,10 @@ function padPlanPullers(addresses) {
|
|
|
2783
3478
|
function pdaConfig(programAddress) {
|
|
2784
3479
|
return programAddress ? { programAddress } : {};
|
|
2785
3480
|
}
|
|
3481
|
+
async function eventAccounts(programAddress) {
|
|
3482
|
+
const [eventAuthority] = await findEventAuthorityPda(pdaConfig(programAddress));
|
|
3483
|
+
return { eventAuthority, selfProgram: programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS };
|
|
3484
|
+
}
|
|
2786
3485
|
function withTrailing(instruction, trailing) {
|
|
2787
3486
|
if (trailing.length === 0) return instruction;
|
|
2788
3487
|
const accounts = [
|
|
@@ -2796,7 +3495,7 @@ function appendPayer(instruction, payer) {
|
|
|
2796
3495
|
return withTrailing(instruction, [
|
|
2797
3496
|
{
|
|
2798
3497
|
address: payer.address,
|
|
2799
|
-
role:
|
|
3498
|
+
role: import_kit44.AccountRole.WRITABLE_SIGNER,
|
|
2800
3499
|
signer: payer
|
|
2801
3500
|
}
|
|
2802
3501
|
]);
|
|
@@ -2825,7 +3524,32 @@ async function getCloseSubscriptionAuthorityOverlayInstructionAsync(input) {
|
|
|
2825
3524
|
pdaConfig(input.programAddress)
|
|
2826
3525
|
);
|
|
2827
3526
|
if (input.receiver) {
|
|
2828
|
-
ix = withTrailing(ix, [{ address: input.receiver, role:
|
|
3527
|
+
ix = withTrailing(ix, [{ address: input.receiver, role: import_kit44.AccountRole.WRITABLE }]);
|
|
3528
|
+
}
|
|
3529
|
+
return ix;
|
|
3530
|
+
}
|
|
3531
|
+
async function getRevokeSubscriptionAuthorityOverlayInstructionAsync(input) {
|
|
3532
|
+
const [userAta] = await (0, import_token.findAssociatedTokenPda)({
|
|
3533
|
+
mint: input.tokenMint,
|
|
3534
|
+
owner: input.user.address,
|
|
3535
|
+
tokenProgram: input.tokenProgram
|
|
3536
|
+
});
|
|
3537
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
3538
|
+
{ tokenMint: input.tokenMint, user: input.user.address },
|
|
3539
|
+
pdaConfig(input.programAddress)
|
|
3540
|
+
);
|
|
3541
|
+
let ix = getRevokeSubscriptionAuthorityInstruction(
|
|
3542
|
+
{
|
|
3543
|
+
subscriptionAuthority,
|
|
3544
|
+
tokenMint: input.tokenMint,
|
|
3545
|
+
tokenProgram: input.tokenProgram,
|
|
3546
|
+
user: input.user,
|
|
3547
|
+
userAta
|
|
3548
|
+
},
|
|
3549
|
+
pdaConfig(input.programAddress)
|
|
3550
|
+
);
|
|
3551
|
+
if (input.receiver) {
|
|
3552
|
+
ix = withTrailing(ix, [{ address: input.receiver, role: import_kit44.AccountRole.WRITABLE }]);
|
|
2829
3553
|
}
|
|
2830
3554
|
return ix;
|
|
2831
3555
|
}
|
|
@@ -2919,14 +3643,14 @@ function getRevokeDelegationOverlayInstruction(input) {
|
|
|
2919
3643
|
pdaConfig(input.programAddress)
|
|
2920
3644
|
);
|
|
2921
3645
|
if (input.receiver) {
|
|
2922
|
-
ix = withTrailing(ix, [{ address: input.receiver, role:
|
|
3646
|
+
ix = withTrailing(ix, [{ address: input.receiver, role: import_kit44.AccountRole.WRITABLE }]);
|
|
2923
3647
|
}
|
|
2924
3648
|
return ix;
|
|
2925
3649
|
}
|
|
2926
3650
|
function getRevokeSubscriptionOverlayInstruction(input) {
|
|
2927
|
-
const trailing = [{ address: input.planPda, role:
|
|
3651
|
+
const trailing = [{ address: input.planPda, role: import_kit44.AccountRole.READONLY }];
|
|
2928
3652
|
if (input.receiver) {
|
|
2929
|
-
trailing.push({ address: input.receiver, role:
|
|
3653
|
+
trailing.push({ address: input.receiver, role: import_kit44.AccountRole.WRITABLE });
|
|
2930
3654
|
}
|
|
2931
3655
|
return withTrailing(
|
|
2932
3656
|
getRevokeDelegationInstruction(
|
|
@@ -2945,22 +3669,26 @@ async function getTransferDelegationOverlayInstructionAsync(input, getInstructio
|
|
|
2945
3669
|
{ tokenMint: input.tokenMint, user: input.delegator },
|
|
2946
3670
|
pdaConfig(input.programAddress)
|
|
2947
3671
|
);
|
|
2948
|
-
return
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
3672
|
+
return withTrailing(
|
|
3673
|
+
getInstruction(
|
|
3674
|
+
{
|
|
3675
|
+
...await eventAccounts(input.programAddress),
|
|
3676
|
+
delegatee: input.delegatee,
|
|
3677
|
+
delegationPda: input.delegationPda,
|
|
3678
|
+
delegatorAta: input.delegatorAta,
|
|
3679
|
+
receiverAta: input.receiverAta,
|
|
3680
|
+
subscriptionAuthority,
|
|
3681
|
+
tokenMint: input.tokenMint,
|
|
3682
|
+
tokenProgram: input.tokenProgram,
|
|
3683
|
+
transferData: {
|
|
3684
|
+
amount: input.amount,
|
|
3685
|
+
delegator: input.delegator,
|
|
3686
|
+
mint: input.tokenMint
|
|
3687
|
+
}
|
|
3688
|
+
},
|
|
3689
|
+
pdaConfig(input.programAddress)
|
|
3690
|
+
),
|
|
3691
|
+
input.transferHookAccounts ?? []
|
|
2964
3692
|
);
|
|
2965
3693
|
}
|
|
2966
3694
|
function getTransferFixedOverlayInstructionAsync(input) {
|
|
@@ -2980,28 +3708,33 @@ async function getTransferSubscriptionOverlayInstructionAsync(input) {
|
|
|
2980
3708
|
owner: input.delegator,
|
|
2981
3709
|
tokenProgram: input.tokenProgram
|
|
2982
3710
|
});
|
|
2983
|
-
return
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3711
|
+
return withTrailing(
|
|
3712
|
+
getTransferSubscriptionInstruction(
|
|
3713
|
+
{
|
|
3714
|
+
...await eventAccounts(input.programAddress),
|
|
3715
|
+
caller: input.caller,
|
|
3716
|
+
delegatorAta,
|
|
3717
|
+
planPda: input.planPda,
|
|
3718
|
+
receiverAta: input.receiverAta,
|
|
3719
|
+
subscriptionAuthority,
|
|
3720
|
+
subscriptionPda: input.subscriptionPda,
|
|
3721
|
+
tokenMint: input.tokenMint,
|
|
3722
|
+
tokenProgram: input.tokenProgram,
|
|
3723
|
+
transferData: {
|
|
3724
|
+
amount: input.amount,
|
|
3725
|
+
delegator: input.delegator,
|
|
3726
|
+
mint: input.tokenMint
|
|
3727
|
+
}
|
|
3728
|
+
},
|
|
3729
|
+
pdaConfig(input.programAddress)
|
|
3730
|
+
),
|
|
3731
|
+
input.transferHookAccounts ?? []
|
|
3000
3732
|
);
|
|
3001
3733
|
}
|
|
3002
3734
|
async function getCreatePlanOverlayInstructionAsync(input) {
|
|
3003
3735
|
assertPositive(input.amount, "amount");
|
|
3004
3736
|
assertPositive(input.periodHours, "periodHours");
|
|
3737
|
+
assertSafeU64(input.planId, "planId");
|
|
3005
3738
|
assertMetadataUri(input.metadataUri);
|
|
3006
3739
|
const destinations = padPlanDestinations(input.destinations);
|
|
3007
3740
|
const pullers = padPlanPullers(input.pullers);
|
|
@@ -3032,11 +3765,12 @@ async function getCreatePlanOverlayInstructionAsync(input) {
|
|
|
3032
3765
|
pdaConfig(input.programAddress)
|
|
3033
3766
|
);
|
|
3034
3767
|
}
|
|
3035
|
-
function getUpdatePlanOverlayInstruction(input) {
|
|
3768
|
+
async function getUpdatePlanOverlayInstruction(input) {
|
|
3036
3769
|
assertMetadataUri(input.metadataUri);
|
|
3037
|
-
const pullers = padPlanPullers(input.pullers
|
|
3770
|
+
const pullers = padPlanPullers(input.pullers);
|
|
3038
3771
|
return getUpdatePlanInstruction(
|
|
3039
3772
|
{
|
|
3773
|
+
...await eventAccounts(input.programAddress),
|
|
3040
3774
|
owner: input.owner,
|
|
3041
3775
|
planPda: input.planPda,
|
|
3042
3776
|
updatePlanData: {
|
|
@@ -3058,6 +3792,7 @@ async function getSubscribeOverlayInstructionAsync(input) {
|
|
|
3058
3792
|
"getSubscribeOverlayInstructionAsync requires expectedAmount, expectedPeriodHours, expectedCreatedAt, and expectedSubscriptionAuthorityInitId. Use the plugin client `subscriptions.instructions.subscribe(...)` to auto-fetch from the live plan and authority."
|
|
3059
3793
|
);
|
|
3060
3794
|
}
|
|
3795
|
+
assertSafeU64(input.planId, "planId");
|
|
3061
3796
|
const [planPda, planBump] = await findPlanPda(
|
|
3062
3797
|
{ owner: input.merchant, planId: input.planId },
|
|
3063
3798
|
pdaConfig(input.programAddress)
|
|
@@ -3069,6 +3804,7 @@ async function getSubscribeOverlayInstructionAsync(input) {
|
|
|
3069
3804
|
return appendPayer(
|
|
3070
3805
|
await getSubscribeInstructionAsync(
|
|
3071
3806
|
{
|
|
3807
|
+
...await eventAccounts(input.programAddress),
|
|
3072
3808
|
merchant: input.merchant,
|
|
3073
3809
|
planPda,
|
|
3074
3810
|
subscribeData: {
|
|
@@ -3088,9 +3824,10 @@ async function getSubscribeOverlayInstructionAsync(input) {
|
|
|
3088
3824
|
input.payer
|
|
3089
3825
|
);
|
|
3090
3826
|
}
|
|
3091
|
-
function getCancelSubscriptionOverlayInstructionAsync(input) {
|
|
3092
|
-
return getCancelSubscriptionInstructionAsync(
|
|
3827
|
+
async function getCancelSubscriptionOverlayInstructionAsync(input) {
|
|
3828
|
+
return await getCancelSubscriptionInstructionAsync(
|
|
3093
3829
|
{
|
|
3830
|
+
...await eventAccounts(input.programAddress),
|
|
3094
3831
|
planPda: input.planPda,
|
|
3095
3832
|
subscriber: input.subscriber,
|
|
3096
3833
|
subscriptionPda: input.subscriptionPda
|
|
@@ -3098,11 +3835,17 @@ function getCancelSubscriptionOverlayInstructionAsync(input) {
|
|
|
3098
3835
|
pdaConfig(input.programAddress)
|
|
3099
3836
|
);
|
|
3100
3837
|
}
|
|
3101
|
-
function getResumeSubscriptionOverlayInstructionAsync(input) {
|
|
3102
|
-
|
|
3838
|
+
async function getResumeSubscriptionOverlayInstructionAsync(input) {
|
|
3839
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
3840
|
+
{ tokenMint: input.tokenMint, user: input.subscriber.address },
|
|
3841
|
+
pdaConfig(input.programAddress)
|
|
3842
|
+
);
|
|
3843
|
+
return await getResumeSubscriptionInstructionAsync(
|
|
3103
3844
|
{
|
|
3845
|
+
...await eventAccounts(input.programAddress),
|
|
3104
3846
|
planPda: input.planPda,
|
|
3105
3847
|
subscriber: input.subscriber,
|
|
3848
|
+
subscriptionAuthority,
|
|
3106
3849
|
subscriptionPda: input.subscriptionPda
|
|
3107
3850
|
},
|
|
3108
3851
|
pdaConfig(input.programAddress)
|
|
@@ -3110,7 +3853,7 @@ function getResumeSubscriptionOverlayInstructionAsync(input) {
|
|
|
3110
3853
|
}
|
|
3111
3854
|
function subscriptionsProgram2() {
|
|
3112
3855
|
return (client) => {
|
|
3113
|
-
return (0,
|
|
3856
|
+
return (0, import_kit44.pipe)(client, subscriptionsProgram(), (c) => {
|
|
3114
3857
|
const queries = {
|
|
3115
3858
|
activeDelegationSummary: async (wallet) => {
|
|
3116
3859
|
const delegations = await fetchDelegationsByDelegator(c.rpc, wallet);
|
|
@@ -3147,22 +3890,37 @@ function subscriptionsProgram2() {
|
|
|
3147
3890
|
}
|
|
3148
3891
|
return subscriptionAuthority.data.initId;
|
|
3149
3892
|
};
|
|
3893
|
+
const resolveDelegationHookAccounts = async (input) => {
|
|
3894
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
3895
|
+
{ tokenMint: input.tokenMint, user: input.delegator },
|
|
3896
|
+
pdaConfig(input.programAddress)
|
|
3897
|
+
);
|
|
3898
|
+
return await resolveTransferHookAccounts(c.rpc, {
|
|
3899
|
+
amount: input.amount,
|
|
3900
|
+
authority: subscriptionAuthority,
|
|
3901
|
+
destination: input.receiverAta,
|
|
3902
|
+
mint: input.tokenMint,
|
|
3903
|
+
source: input.delegatorAta,
|
|
3904
|
+
tokenProgram: input.tokenProgram,
|
|
3905
|
+
transferHookAccounts: input.transferHookAccounts
|
|
3906
|
+
});
|
|
3907
|
+
};
|
|
3150
3908
|
const instructions = {
|
|
3151
|
-
cancelSubscription: (input) => (0,
|
|
3909
|
+
cancelSubscription: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3152
3910
|
client,
|
|
3153
3911
|
getCancelSubscriptionOverlayInstructionAsync({
|
|
3154
3912
|
...input,
|
|
3155
3913
|
subscriber: input.subscriber ?? client.identity
|
|
3156
3914
|
})
|
|
3157
3915
|
),
|
|
3158
|
-
closeSubscriptionAuthority: (input) => (0,
|
|
3916
|
+
closeSubscriptionAuthority: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3159
3917
|
client,
|
|
3160
3918
|
getCloseSubscriptionAuthorityOverlayInstructionAsync({
|
|
3161
3919
|
...input,
|
|
3162
3920
|
user: input.user ?? client.identity
|
|
3163
3921
|
})
|
|
3164
3922
|
),
|
|
3165
|
-
createFixedDelegation: (input) => (0,
|
|
3923
|
+
createFixedDelegation: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3166
3924
|
client,
|
|
3167
3925
|
(async () => {
|
|
3168
3926
|
const delegator = input.delegator ?? client.identity;
|
|
@@ -3180,14 +3938,14 @@ function subscriptionsProgram2() {
|
|
|
3180
3938
|
});
|
|
3181
3939
|
})()
|
|
3182
3940
|
),
|
|
3183
|
-
createPlan: (input) => (0,
|
|
3941
|
+
createPlan: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3184
3942
|
client,
|
|
3185
3943
|
getCreatePlanOverlayInstructionAsync({
|
|
3186
3944
|
...input,
|
|
3187
3945
|
owner: input.owner ?? client.identity
|
|
3188
3946
|
})
|
|
3189
3947
|
),
|
|
3190
|
-
createRecurringDelegation: (input) => (0,
|
|
3948
|
+
createRecurringDelegation: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3191
3949
|
client,
|
|
3192
3950
|
(async () => {
|
|
3193
3951
|
const delegator = input.delegator ?? client.identity;
|
|
@@ -3205,14 +3963,14 @@ function subscriptionsProgram2() {
|
|
|
3205
3963
|
});
|
|
3206
3964
|
})()
|
|
3207
3965
|
),
|
|
3208
|
-
deletePlan: (input) => (0,
|
|
3966
|
+
deletePlan: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3209
3967
|
client,
|
|
3210
3968
|
getDeletePlanOverlayInstruction({
|
|
3211
3969
|
...input,
|
|
3212
3970
|
owner: input.owner ?? client.identity
|
|
3213
3971
|
})
|
|
3214
3972
|
),
|
|
3215
|
-
initSubscriptionAuthority: (input) => (0,
|
|
3973
|
+
initSubscriptionAuthority: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3216
3974
|
client,
|
|
3217
3975
|
getInitSubscriptionAuthorityOverlayInstructionAsync({
|
|
3218
3976
|
...input,
|
|
@@ -3220,31 +3978,39 @@ function subscriptionsProgram2() {
|
|
|
3220
3978
|
payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer)
|
|
3221
3979
|
})
|
|
3222
3980
|
),
|
|
3223
|
-
resumeSubscription: (input) => (0,
|
|
3981
|
+
resumeSubscription: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3224
3982
|
client,
|
|
3225
3983
|
getResumeSubscriptionOverlayInstructionAsync({
|
|
3226
3984
|
...input,
|
|
3227
3985
|
subscriber: input.subscriber ?? client.identity
|
|
3228
3986
|
})
|
|
3229
3987
|
),
|
|
3230
|
-
revokeDelegation: (input) => (0,
|
|
3988
|
+
revokeDelegation: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3231
3989
|
client,
|
|
3232
3990
|
getRevokeDelegationOverlayInstruction({
|
|
3233
3991
|
...input,
|
|
3234
3992
|
authority: input.authority ?? client.identity
|
|
3235
3993
|
})
|
|
3236
3994
|
),
|
|
3237
|
-
revokeSubscription: (input) => (0,
|
|
3995
|
+
revokeSubscription: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3238
3996
|
client,
|
|
3239
3997
|
getRevokeSubscriptionOverlayInstruction({
|
|
3240
3998
|
...input,
|
|
3241
3999
|
authority: input.authority ?? client.identity
|
|
3242
4000
|
})
|
|
3243
4001
|
),
|
|
3244
|
-
|
|
4002
|
+
revokeSubscriptionAuthority: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
4003
|
+
client,
|
|
4004
|
+
getRevokeSubscriptionAuthorityOverlayInstructionAsync({
|
|
4005
|
+
...input,
|
|
4006
|
+
user: input.user ?? client.identity
|
|
4007
|
+
})
|
|
4008
|
+
),
|
|
4009
|
+
subscribe: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3245
4010
|
client,
|
|
3246
4011
|
(async () => {
|
|
3247
4012
|
const subscriber = input.subscriber ?? client.identity;
|
|
4013
|
+
assertSafeU64(input.planId, "planId");
|
|
3248
4014
|
let {
|
|
3249
4015
|
expectedAmount,
|
|
3250
4016
|
expectedCreatedAt,
|
|
@@ -3288,28 +4054,51 @@ function subscriptionsProgram2() {
|
|
|
3288
4054
|
});
|
|
3289
4055
|
})()
|
|
3290
4056
|
),
|
|
3291
|
-
transferFixed: (input) => (0,
|
|
4057
|
+
transferFixed: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3292
4058
|
client,
|
|
3293
|
-
getTransferFixedOverlayInstructionAsync({
|
|
4059
|
+
(async () => await getTransferFixedOverlayInstructionAsync({
|
|
3294
4060
|
...input,
|
|
3295
|
-
delegatee: input.delegatee ?? client.identity
|
|
3296
|
-
|
|
4061
|
+
delegatee: input.delegatee ?? client.identity,
|
|
4062
|
+
transferHookAccounts: await resolveDelegationHookAccounts(input)
|
|
4063
|
+
}))()
|
|
3297
4064
|
),
|
|
3298
|
-
transferRecurring: (input) => (0,
|
|
4065
|
+
transferRecurring: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3299
4066
|
client,
|
|
3300
|
-
getTransferRecurringOverlayInstructionAsync({
|
|
4067
|
+
(async () => await getTransferRecurringOverlayInstructionAsync({
|
|
3301
4068
|
...input,
|
|
3302
|
-
delegatee: input.delegatee ?? client.identity
|
|
3303
|
-
|
|
4069
|
+
delegatee: input.delegatee ?? client.identity,
|
|
4070
|
+
transferHookAccounts: await resolveDelegationHookAccounts(input)
|
|
4071
|
+
}))()
|
|
3304
4072
|
),
|
|
3305
|
-
transferSubscription: (input) => (0,
|
|
4073
|
+
transferSubscription: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3306
4074
|
client,
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
4075
|
+
(async () => {
|
|
4076
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
4077
|
+
{ tokenMint: input.tokenMint, user: input.delegator },
|
|
4078
|
+
pdaConfig(input.programAddress)
|
|
4079
|
+
);
|
|
4080
|
+
const [delegatorAta] = await (0, import_token.findAssociatedTokenPda)({
|
|
4081
|
+
mint: input.tokenMint,
|
|
4082
|
+
owner: input.delegator,
|
|
4083
|
+
tokenProgram: input.tokenProgram
|
|
4084
|
+
});
|
|
4085
|
+
const transferHookAccounts = await resolveTransferHookAccounts(c.rpc, {
|
|
4086
|
+
amount: input.amount,
|
|
4087
|
+
authority: subscriptionAuthority,
|
|
4088
|
+
destination: input.receiverAta,
|
|
4089
|
+
mint: input.tokenMint,
|
|
4090
|
+
source: delegatorAta,
|
|
4091
|
+
tokenProgram: input.tokenProgram,
|
|
4092
|
+
transferHookAccounts: input.transferHookAccounts
|
|
4093
|
+
});
|
|
4094
|
+
return await getTransferSubscriptionOverlayInstructionAsync({
|
|
4095
|
+
...input,
|
|
4096
|
+
caller: input.caller ?? client.identity,
|
|
4097
|
+
transferHookAccounts
|
|
4098
|
+
});
|
|
4099
|
+
})()
|
|
3311
4100
|
),
|
|
3312
|
-
updatePlan: (input) => (0,
|
|
4101
|
+
updatePlan: (input) => (0, import_program_client_core19.addSelfPlanAndSendFunctions)(
|
|
3313
4102
|
client,
|
|
3314
4103
|
getUpdatePlanOverlayInstruction({
|
|
3315
4104
|
...input,
|
|
@@ -3353,7 +4142,10 @@ function subscriptionsProgram2() {
|
|
|
3353
4142
|
PROGRAM_ID,
|
|
3354
4143
|
PlanStatus,
|
|
3355
4144
|
RESUME_SUBSCRIPTION_DISCRIMINATOR,
|
|
4145
|
+
REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR,
|
|
4146
|
+
REVOKE_ABANDONED_SUBSCRIPTION_DISCRIMINATOR,
|
|
3356
4147
|
REVOKE_DELEGATION_DISCRIMINATOR,
|
|
4148
|
+
REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR,
|
|
3357
4149
|
SUBSCRIBE_DISCRIMINATOR,
|
|
3358
4150
|
SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE,
|
|
3359
4151
|
SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED,
|
|
@@ -3388,6 +4180,7 @@ function subscriptionsProgram2() {
|
|
|
3388
4180
|
SUBSCRIPTIONS_ERROR__INVALID_PERIOD_LENGTH,
|
|
3389
4181
|
SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA,
|
|
3390
4182
|
SUBSCRIPTIONS_ERROR__INVALID_PLAN_STATUS,
|
|
4183
|
+
SUBSCRIPTIONS_ERROR__INVALID_SELF_PROGRAM,
|
|
3391
4184
|
SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_AUTHORITY_PDA,
|
|
3392
4185
|
SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_PDA,
|
|
3393
4186
|
SUBSCRIPTIONS_ERROR__INVALID_TOKEN2022_MINT_ACCOUNT_DATA,
|
|
@@ -3411,12 +4204,14 @@ function subscriptionsProgram2() {
|
|
|
3411
4204
|
SUBSCRIPTIONS_ERROR__PERIOD_NOT_ELAPSED,
|
|
3412
4205
|
SUBSCRIPTIONS_ERROR__PLAN_ALREADY_EXISTS,
|
|
3413
4206
|
SUBSCRIPTIONS_ERROR__PLAN_CLOSED,
|
|
4207
|
+
SUBSCRIPTIONS_ERROR__PLAN_END_TS_CANNOT_EXTEND,
|
|
3414
4208
|
SUBSCRIPTIONS_ERROR__PLAN_EXPIRED,
|
|
3415
4209
|
SUBSCRIPTIONS_ERROR__PLAN_IMMUTABLE_AFTER_SUNSET,
|
|
3416
4210
|
SUBSCRIPTIONS_ERROR__PLAN_NOT_EXPIRED,
|
|
3417
4211
|
SUBSCRIPTIONS_ERROR__PLAN_SUNSET,
|
|
3418
4212
|
SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH,
|
|
3419
4213
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO,
|
|
4214
|
+
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY,
|
|
3420
4215
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY,
|
|
3421
4216
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST,
|
|
3422
4217
|
SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY,
|
|
@@ -3425,6 +4220,7 @@ function subscriptionsProgram2() {
|
|
|
3425
4220
|
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED,
|
|
3426
4221
|
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH,
|
|
3427
4222
|
SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS,
|
|
4223
|
+
SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS,
|
|
3428
4224
|
SUBSCRIPTIONS_ERROR__UNAUTHORIZED,
|
|
3429
4225
|
SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION,
|
|
3430
4226
|
SUBSCRIPTIONS_PROGRAM_ADDRESS,
|
|
@@ -3577,12 +4373,29 @@ function subscriptionsProgram2() {
|
|
|
3577
4373
|
getResumeSubscriptionInstructionDataDecoder,
|
|
3578
4374
|
getResumeSubscriptionInstructionDataEncoder,
|
|
3579
4375
|
getResumeSubscriptionOverlayInstructionAsync,
|
|
4376
|
+
getRevokeAbandonedDelegationDiscriminatorBytes,
|
|
4377
|
+
getRevokeAbandonedDelegationInstruction,
|
|
4378
|
+
getRevokeAbandonedDelegationInstructionDataCodec,
|
|
4379
|
+
getRevokeAbandonedDelegationInstructionDataDecoder,
|
|
4380
|
+
getRevokeAbandonedDelegationInstructionDataEncoder,
|
|
4381
|
+
getRevokeAbandonedSubscriptionDiscriminatorBytes,
|
|
4382
|
+
getRevokeAbandonedSubscriptionInstruction,
|
|
4383
|
+
getRevokeAbandonedSubscriptionInstructionDataCodec,
|
|
4384
|
+
getRevokeAbandonedSubscriptionInstructionDataDecoder,
|
|
4385
|
+
getRevokeAbandonedSubscriptionInstructionDataEncoder,
|
|
3580
4386
|
getRevokeDelegationDiscriminatorBytes,
|
|
3581
4387
|
getRevokeDelegationInstruction,
|
|
3582
4388
|
getRevokeDelegationInstructionDataCodec,
|
|
3583
4389
|
getRevokeDelegationInstructionDataDecoder,
|
|
3584
4390
|
getRevokeDelegationInstructionDataEncoder,
|
|
3585
4391
|
getRevokeDelegationOverlayInstruction,
|
|
4392
|
+
getRevokeSubscriptionAuthorityDiscriminatorBytes,
|
|
4393
|
+
getRevokeSubscriptionAuthorityInstruction,
|
|
4394
|
+
getRevokeSubscriptionAuthorityInstructionAsync,
|
|
4395
|
+
getRevokeSubscriptionAuthorityInstructionDataCodec,
|
|
4396
|
+
getRevokeSubscriptionAuthorityInstructionDataDecoder,
|
|
4397
|
+
getRevokeSubscriptionAuthorityInstructionDataEncoder,
|
|
4398
|
+
getRevokeSubscriptionAuthorityOverlayInstructionAsync,
|
|
3586
4399
|
getRevokeSubscriptionOverlayInstruction,
|
|
3587
4400
|
getSubscribeDataCodec,
|
|
3588
4401
|
getSubscribeDataDecoder,
|
|
@@ -3606,18 +4419,21 @@ function subscriptionsProgram2() {
|
|
|
3606
4419
|
getTransferDataEncoder,
|
|
3607
4420
|
getTransferFixedDiscriminatorBytes,
|
|
3608
4421
|
getTransferFixedInstruction,
|
|
4422
|
+
getTransferFixedInstructionAsync,
|
|
3609
4423
|
getTransferFixedInstructionDataCodec,
|
|
3610
4424
|
getTransferFixedInstructionDataDecoder,
|
|
3611
4425
|
getTransferFixedInstructionDataEncoder,
|
|
3612
4426
|
getTransferFixedOverlayInstructionAsync,
|
|
3613
4427
|
getTransferRecurringDiscriminatorBytes,
|
|
3614
4428
|
getTransferRecurringInstruction,
|
|
4429
|
+
getTransferRecurringInstructionAsync,
|
|
3615
4430
|
getTransferRecurringInstructionDataCodec,
|
|
3616
4431
|
getTransferRecurringInstructionDataDecoder,
|
|
3617
4432
|
getTransferRecurringInstructionDataEncoder,
|
|
3618
4433
|
getTransferRecurringOverlayInstructionAsync,
|
|
3619
4434
|
getTransferSubscriptionDiscriminatorBytes,
|
|
3620
4435
|
getTransferSubscriptionInstruction,
|
|
4436
|
+
getTransferSubscriptionInstructionAsync,
|
|
3621
4437
|
getTransferSubscriptionInstructionDataCodec,
|
|
3622
4438
|
getTransferSubscriptionInstructionDataDecoder,
|
|
3623
4439
|
getTransferSubscriptionInstructionDataEncoder,
|
|
@@ -3627,6 +4443,7 @@ function subscriptionsProgram2() {
|
|
|
3627
4443
|
getUpdatePlanDataEncoder,
|
|
3628
4444
|
getUpdatePlanDiscriminatorBytes,
|
|
3629
4445
|
getUpdatePlanInstruction,
|
|
4446
|
+
getUpdatePlanInstructionAsync,
|
|
3630
4447
|
getUpdatePlanInstructionDataCodec,
|
|
3631
4448
|
getUpdatePlanInstructionDataDecoder,
|
|
3632
4449
|
getUpdatePlanInstructionDataEncoder,
|
|
@@ -3641,13 +4458,17 @@ function subscriptionsProgram2() {
|
|
|
3641
4458
|
parseDeletePlanInstruction,
|
|
3642
4459
|
parseInitSubscriptionAuthorityInstruction,
|
|
3643
4460
|
parseResumeSubscriptionInstruction,
|
|
4461
|
+
parseRevokeAbandonedDelegationInstruction,
|
|
4462
|
+
parseRevokeAbandonedSubscriptionInstruction,
|
|
3644
4463
|
parseRevokeDelegationInstruction,
|
|
4464
|
+
parseRevokeSubscriptionAuthorityInstruction,
|
|
3645
4465
|
parseSubscribeInstruction,
|
|
3646
4466
|
parseSubscriptionsInstruction,
|
|
3647
4467
|
parseTransferFixedInstruction,
|
|
3648
4468
|
parseTransferRecurringInstruction,
|
|
3649
4469
|
parseTransferSubscriptionInstruction,
|
|
3650
4470
|
parseUpdatePlanInstruction,
|
|
4471
|
+
resolveTransferHookAccounts,
|
|
3651
4472
|
subscriptionsProgram,
|
|
3652
4473
|
toEncodedAccount
|
|
3653
4474
|
});
|