@solana/subscriptions 0.2.0 → 0.4.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.cjs +713 -222
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +212 -29
- package/dist/index.d.ts +212 -29
- package/dist/index.js +696 -200
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
package/dist/index.cjs
CHANGED
|
@@ -43,7 +43,9 @@ __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,
|
|
46
47
|
REVOKE_DELEGATION_DISCRIMINATOR: () => REVOKE_DELEGATION_DISCRIMINATOR,
|
|
48
|
+
REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR: () => REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR,
|
|
47
49
|
SUBSCRIBE_DISCRIMINATOR: () => SUBSCRIBE_DISCRIMINATOR,
|
|
48
50
|
SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE: () => SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE,
|
|
49
51
|
SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED: () => SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED,
|
|
@@ -107,6 +109,7 @@ __export(index_exports, {
|
|
|
107
109
|
SUBSCRIPTIONS_ERROR__PLAN_SUNSET: () => SUBSCRIPTIONS_ERROR__PLAN_SUNSET,
|
|
108
110
|
SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH: () => SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH,
|
|
109
111
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO: () => SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO,
|
|
112
|
+
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY: () => SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY,
|
|
110
113
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY: () => SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY,
|
|
111
114
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST: () => SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST,
|
|
112
115
|
SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY: () => SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY,
|
|
@@ -115,6 +118,8 @@ __export(index_exports, {
|
|
|
115
118
|
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED: () => SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED,
|
|
116
119
|
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH: () => SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH,
|
|
117
120
|
SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS: () => SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS,
|
|
121
|
+
SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS: () => SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS,
|
|
122
|
+
SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_VALIDATION_ACCOUNT_MISSING: () => SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_VALIDATION_ACCOUNT_MISSING,
|
|
118
123
|
SUBSCRIPTIONS_ERROR__UNAUTHORIZED: () => SUBSCRIPTIONS_ERROR__UNAUTHORIZED,
|
|
119
124
|
SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION: () => SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION,
|
|
120
125
|
SUBSCRIPTIONS_PROGRAM_ADDRESS: () => SUBSCRIPTIONS_PROGRAM_ADDRESS,
|
|
@@ -267,12 +272,23 @@ __export(index_exports, {
|
|
|
267
272
|
getResumeSubscriptionInstructionDataDecoder: () => getResumeSubscriptionInstructionDataDecoder,
|
|
268
273
|
getResumeSubscriptionInstructionDataEncoder: () => getResumeSubscriptionInstructionDataEncoder,
|
|
269
274
|
getResumeSubscriptionOverlayInstructionAsync: () => getResumeSubscriptionOverlayInstructionAsync,
|
|
275
|
+
getRevokeAbandonedDelegationDiscriminatorBytes: () => getRevokeAbandonedDelegationDiscriminatorBytes,
|
|
276
|
+
getRevokeAbandonedDelegationInstruction: () => getRevokeAbandonedDelegationInstruction,
|
|
277
|
+
getRevokeAbandonedDelegationInstructionDataCodec: () => getRevokeAbandonedDelegationInstructionDataCodec,
|
|
278
|
+
getRevokeAbandonedDelegationInstructionDataDecoder: () => getRevokeAbandonedDelegationInstructionDataDecoder,
|
|
279
|
+
getRevokeAbandonedDelegationInstructionDataEncoder: () => getRevokeAbandonedDelegationInstructionDataEncoder,
|
|
270
280
|
getRevokeDelegationDiscriminatorBytes: () => getRevokeDelegationDiscriminatorBytes,
|
|
271
281
|
getRevokeDelegationInstruction: () => getRevokeDelegationInstruction,
|
|
272
282
|
getRevokeDelegationInstructionDataCodec: () => getRevokeDelegationInstructionDataCodec,
|
|
273
283
|
getRevokeDelegationInstructionDataDecoder: () => getRevokeDelegationInstructionDataDecoder,
|
|
274
284
|
getRevokeDelegationInstructionDataEncoder: () => getRevokeDelegationInstructionDataEncoder,
|
|
275
285
|
getRevokeDelegationOverlayInstruction: () => getRevokeDelegationOverlayInstruction,
|
|
286
|
+
getRevokeSubscriptionAuthorityDiscriminatorBytes: () => getRevokeSubscriptionAuthorityDiscriminatorBytes,
|
|
287
|
+
getRevokeSubscriptionAuthorityInstruction: () => getRevokeSubscriptionAuthorityInstruction,
|
|
288
|
+
getRevokeSubscriptionAuthorityInstructionDataCodec: () => getRevokeSubscriptionAuthorityInstructionDataCodec,
|
|
289
|
+
getRevokeSubscriptionAuthorityInstructionDataDecoder: () => getRevokeSubscriptionAuthorityInstructionDataDecoder,
|
|
290
|
+
getRevokeSubscriptionAuthorityInstructionDataEncoder: () => getRevokeSubscriptionAuthorityInstructionDataEncoder,
|
|
291
|
+
getRevokeSubscriptionAuthorityOverlayInstructionAsync: () => getRevokeSubscriptionAuthorityOverlayInstructionAsync,
|
|
276
292
|
getRevokeSubscriptionOverlayInstruction: () => getRevokeSubscriptionOverlayInstruction,
|
|
277
293
|
getSubscribeDataCodec: () => getSubscribeDataCodec,
|
|
278
294
|
getSubscribeDataDecoder: () => getSubscribeDataDecoder,
|
|
@@ -331,20 +347,23 @@ __export(index_exports, {
|
|
|
331
347
|
parseDeletePlanInstruction: () => parseDeletePlanInstruction,
|
|
332
348
|
parseInitSubscriptionAuthorityInstruction: () => parseInitSubscriptionAuthorityInstruction,
|
|
333
349
|
parseResumeSubscriptionInstruction: () => parseResumeSubscriptionInstruction,
|
|
350
|
+
parseRevokeAbandonedDelegationInstruction: () => parseRevokeAbandonedDelegationInstruction,
|
|
334
351
|
parseRevokeDelegationInstruction: () => parseRevokeDelegationInstruction,
|
|
352
|
+
parseRevokeSubscriptionAuthorityInstruction: () => parseRevokeSubscriptionAuthorityInstruction,
|
|
335
353
|
parseSubscribeInstruction: () => parseSubscribeInstruction,
|
|
336
354
|
parseSubscriptionsInstruction: () => parseSubscriptionsInstruction,
|
|
337
355
|
parseTransferFixedInstruction: () => parseTransferFixedInstruction,
|
|
338
356
|
parseTransferRecurringInstruction: () => parseTransferRecurringInstruction,
|
|
339
357
|
parseTransferSubscriptionInstruction: () => parseTransferSubscriptionInstruction,
|
|
340
358
|
parseUpdatePlanInstruction: () => parseUpdatePlanInstruction,
|
|
359
|
+
resolveTransferHookAccounts: () => resolveTransferHookAccounts,
|
|
341
360
|
subscriptionsProgram: () => subscriptionsProgram2,
|
|
342
361
|
toEncodedAccount: () => toEncodedAccount
|
|
343
362
|
});
|
|
344
363
|
module.exports = __toCommonJS(index_exports);
|
|
345
364
|
|
|
346
365
|
// src/accounts/decode.ts
|
|
347
|
-
var
|
|
366
|
+
var import_kit41 = require("@solana/kit");
|
|
348
367
|
|
|
349
368
|
// src/generated/accounts/eventAuthority.ts
|
|
350
369
|
var import_kit7 = require("@solana/kit");
|
|
@@ -513,14 +532,16 @@ function getCreateFixedDelegationDataEncoder() {
|
|
|
513
532
|
return (0, import_kit9.getStructEncoder)([
|
|
514
533
|
["nonce", (0, import_kit9.getU64Encoder)()],
|
|
515
534
|
["amount", (0, import_kit9.getU64Encoder)()],
|
|
516
|
-
["expiryTs", (0, import_kit9.getI64Encoder)()]
|
|
535
|
+
["expiryTs", (0, import_kit9.getI64Encoder)()],
|
|
536
|
+
["expectedSubscriptionAuthorityInitId", (0, import_kit9.getI64Encoder)()]
|
|
517
537
|
]);
|
|
518
538
|
}
|
|
519
539
|
function getCreateFixedDelegationDataDecoder() {
|
|
520
540
|
return (0, import_kit9.getStructDecoder)([
|
|
521
541
|
["nonce", (0, import_kit9.getU64Decoder)()],
|
|
522
542
|
["amount", (0, import_kit9.getU64Decoder)()],
|
|
523
|
-
["expiryTs", (0, import_kit9.getI64Decoder)()]
|
|
543
|
+
["expiryTs", (0, import_kit9.getI64Decoder)()],
|
|
544
|
+
["expectedSubscriptionAuthorityInitId", (0, import_kit9.getI64Decoder)()]
|
|
524
545
|
]);
|
|
525
546
|
}
|
|
526
547
|
function getCreateFixedDelegationDataCodec() {
|
|
@@ -535,7 +556,8 @@ function getCreateRecurringDelegationDataEncoder() {
|
|
|
535
556
|
["amountPerPeriod", (0, import_kit10.getU64Encoder)()],
|
|
536
557
|
["periodLengthS", (0, import_kit10.getU64Encoder)()],
|
|
537
558
|
["startTs", (0, import_kit10.getI64Encoder)()],
|
|
538
|
-
["expiryTs", (0, import_kit10.getI64Encoder)()]
|
|
559
|
+
["expiryTs", (0, import_kit10.getI64Encoder)()],
|
|
560
|
+
["expectedSubscriptionAuthorityInitId", (0, import_kit10.getI64Encoder)()]
|
|
539
561
|
]);
|
|
540
562
|
}
|
|
541
563
|
function getCreateRecurringDelegationDataDecoder() {
|
|
@@ -544,7 +566,8 @@ function getCreateRecurringDelegationDataDecoder() {
|
|
|
544
566
|
["amountPerPeriod", (0, import_kit10.getU64Decoder)()],
|
|
545
567
|
["periodLengthS", (0, import_kit10.getU64Decoder)()],
|
|
546
568
|
["startTs", (0, import_kit10.getI64Decoder)()],
|
|
547
|
-
["expiryTs", (0, import_kit10.getI64Decoder)()]
|
|
569
|
+
["expiryTs", (0, import_kit10.getI64Decoder)()],
|
|
570
|
+
["expectedSubscriptionAuthorityInitId", (0, import_kit10.getI64Decoder)()]
|
|
548
571
|
]);
|
|
549
572
|
}
|
|
550
573
|
function getCreateRecurringDelegationDataCodec() {
|
|
@@ -653,7 +676,8 @@ function getSubscribeDataEncoder() {
|
|
|
653
676
|
["expectedMint", (0, import_kit15.getAddressEncoder)()],
|
|
654
677
|
["expectedAmount", (0, import_kit15.getU64Encoder)()],
|
|
655
678
|
["expectedPeriodHours", (0, import_kit15.getU64Encoder)()],
|
|
656
|
-
["expectedCreatedAt", (0, import_kit15.getI64Encoder)()]
|
|
679
|
+
["expectedCreatedAt", (0, import_kit15.getI64Encoder)()],
|
|
680
|
+
["expectedSubscriptionAuthorityInitId", (0, import_kit15.getI64Encoder)()]
|
|
657
681
|
]);
|
|
658
682
|
}
|
|
659
683
|
function getSubscribeDataDecoder() {
|
|
@@ -663,7 +687,8 @@ function getSubscribeDataDecoder() {
|
|
|
663
687
|
["expectedMint", (0, import_kit15.getAddressDecoder)()],
|
|
664
688
|
["expectedAmount", (0, import_kit15.getU64Decoder)()],
|
|
665
689
|
["expectedPeriodHours", (0, import_kit15.getU64Decoder)()],
|
|
666
|
-
["expectedCreatedAt", (0, import_kit15.getI64Decoder)()]
|
|
690
|
+
["expectedCreatedAt", (0, import_kit15.getI64Decoder)()],
|
|
691
|
+
["expectedSubscriptionAuthorityInitId", (0, import_kit15.getI64Decoder)()]
|
|
667
692
|
]);
|
|
668
693
|
}
|
|
669
694
|
function getSubscribeDataCodec() {
|
|
@@ -995,11 +1020,11 @@ async function fetchMaybeSubscriptionDelegationFromSeeds(rpc, seeds, config = {}
|
|
|
995
1020
|
}
|
|
996
1021
|
|
|
997
1022
|
// src/generated/errors/subscriptions.ts
|
|
998
|
-
var
|
|
1023
|
+
var import_kit40 = require("@solana/kit");
|
|
999
1024
|
|
|
1000
1025
|
// src/generated/programs/subscriptions.ts
|
|
1001
|
-
var
|
|
1002
|
-
var
|
|
1026
|
+
var import_kit39 = require("@solana/kit");
|
|
1027
|
+
var import_program_client_core17 = require("@solana/program-client-core");
|
|
1003
1028
|
|
|
1004
1029
|
// src/generated/instructions/cancelSubscription.ts
|
|
1005
1030
|
var import_kit23 = require("@solana/kit");
|
|
@@ -1687,24 +1712,89 @@ function parseResumeSubscriptionInstruction(instruction) {
|
|
|
1687
1712
|
};
|
|
1688
1713
|
}
|
|
1689
1714
|
|
|
1690
|
-
// src/generated/instructions/
|
|
1715
|
+
// src/generated/instructions/revokeAbandonedDelegation.ts
|
|
1691
1716
|
var import_kit31 = require("@solana/kit");
|
|
1692
1717
|
var import_program_client_core9 = require("@solana/program-client-core");
|
|
1718
|
+
var REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR = 15;
|
|
1719
|
+
function getRevokeAbandonedDelegationDiscriminatorBytes() {
|
|
1720
|
+
return (0, import_kit31.getU8Encoder)().encode(REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR);
|
|
1721
|
+
}
|
|
1722
|
+
function getRevokeAbandonedDelegationInstructionDataEncoder() {
|
|
1723
|
+
return (0, import_kit31.transformEncoder)((0, import_kit31.getStructEncoder)([["discriminator", (0, import_kit31.getU8Encoder)()]]), (value) => ({
|
|
1724
|
+
...value,
|
|
1725
|
+
discriminator: REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR
|
|
1726
|
+
}));
|
|
1727
|
+
}
|
|
1728
|
+
function getRevokeAbandonedDelegationInstructionDataDecoder() {
|
|
1729
|
+
return (0, import_kit31.getStructDecoder)([["discriminator", (0, import_kit31.getU8Decoder)()]]);
|
|
1730
|
+
}
|
|
1731
|
+
function getRevokeAbandonedDelegationInstructionDataCodec() {
|
|
1732
|
+
return (0, import_kit31.combineCodec)(
|
|
1733
|
+
getRevokeAbandonedDelegationInstructionDataEncoder(),
|
|
1734
|
+
getRevokeAbandonedDelegationInstructionDataDecoder()
|
|
1735
|
+
);
|
|
1736
|
+
}
|
|
1737
|
+
function getRevokeAbandonedDelegationInstruction(input, config) {
|
|
1738
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1739
|
+
const originalAccounts = {
|
|
1740
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
1741
|
+
delegationAccount: { value: input.delegationAccount ?? null, isWritable: true },
|
|
1742
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false }
|
|
1743
|
+
};
|
|
1744
|
+
const accounts = originalAccounts;
|
|
1745
|
+
const getAccountMeta = (0, import_program_client_core9.getAccountMetaFactory)(programAddress, "programId");
|
|
1746
|
+
return Object.freeze({
|
|
1747
|
+
accounts: [
|
|
1748
|
+
getAccountMeta("payer", accounts.payer),
|
|
1749
|
+
getAccountMeta("delegationAccount", accounts.delegationAccount),
|
|
1750
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority)
|
|
1751
|
+
],
|
|
1752
|
+
data: getRevokeAbandonedDelegationInstructionDataEncoder().encode({}),
|
|
1753
|
+
programAddress
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
function parseRevokeAbandonedDelegationInstruction(instruction) {
|
|
1757
|
+
if (instruction.accounts.length < 3) {
|
|
1758
|
+
throw new import_kit31.SolanaError(import_kit31.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1759
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1760
|
+
expectedAccountMetas: 3
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1763
|
+
let accountIndex = 0;
|
|
1764
|
+
const getNextAccount = () => {
|
|
1765
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1766
|
+
accountIndex += 1;
|
|
1767
|
+
return accountMeta;
|
|
1768
|
+
};
|
|
1769
|
+
return {
|
|
1770
|
+
programAddress: instruction.programAddress,
|
|
1771
|
+
accounts: {
|
|
1772
|
+
payer: getNextAccount(),
|
|
1773
|
+
delegationAccount: getNextAccount(),
|
|
1774
|
+
subscriptionAuthority: getNextAccount()
|
|
1775
|
+
},
|
|
1776
|
+
data: getRevokeAbandonedDelegationInstructionDataDecoder().decode(instruction.data)
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
// src/generated/instructions/revokeDelegation.ts
|
|
1781
|
+
var import_kit32 = require("@solana/kit");
|
|
1782
|
+
var import_program_client_core10 = require("@solana/program-client-core");
|
|
1693
1783
|
var REVOKE_DELEGATION_DISCRIMINATOR = 3;
|
|
1694
1784
|
function getRevokeDelegationDiscriminatorBytes() {
|
|
1695
|
-
return (0,
|
|
1785
|
+
return (0, import_kit32.getU8Encoder)().encode(REVOKE_DELEGATION_DISCRIMINATOR);
|
|
1696
1786
|
}
|
|
1697
1787
|
function getRevokeDelegationInstructionDataEncoder() {
|
|
1698
|
-
return (0,
|
|
1788
|
+
return (0, import_kit32.transformEncoder)((0, import_kit32.getStructEncoder)([["discriminator", (0, import_kit32.getU8Encoder)()]]), (value) => ({
|
|
1699
1789
|
...value,
|
|
1700
1790
|
discriminator: REVOKE_DELEGATION_DISCRIMINATOR
|
|
1701
1791
|
}));
|
|
1702
1792
|
}
|
|
1703
1793
|
function getRevokeDelegationInstructionDataDecoder() {
|
|
1704
|
-
return (0,
|
|
1794
|
+
return (0, import_kit32.getStructDecoder)([["discriminator", (0, import_kit32.getU8Decoder)()]]);
|
|
1705
1795
|
}
|
|
1706
1796
|
function getRevokeDelegationInstructionDataCodec() {
|
|
1707
|
-
return (0,
|
|
1797
|
+
return (0, import_kit32.combineCodec)(getRevokeDelegationInstructionDataEncoder(), getRevokeDelegationInstructionDataDecoder());
|
|
1708
1798
|
}
|
|
1709
1799
|
function getRevokeDelegationInstruction(input, config) {
|
|
1710
1800
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -1713,7 +1803,7 @@ function getRevokeDelegationInstruction(input, config) {
|
|
|
1713
1803
|
delegationAccount: { value: input.delegationAccount ?? null, isWritable: true }
|
|
1714
1804
|
};
|
|
1715
1805
|
const accounts = originalAccounts;
|
|
1716
|
-
const getAccountMeta = (0,
|
|
1806
|
+
const getAccountMeta = (0, import_program_client_core10.getAccountMetaFactory)(programAddress, "programId");
|
|
1717
1807
|
return Object.freeze({
|
|
1718
1808
|
accounts: [
|
|
1719
1809
|
getAccountMeta("authority", accounts.authority),
|
|
@@ -1725,7 +1815,7 @@ function getRevokeDelegationInstruction(input, config) {
|
|
|
1725
1815
|
}
|
|
1726
1816
|
function parseRevokeDelegationInstruction(instruction) {
|
|
1727
1817
|
if (instruction.accounts.length < 2) {
|
|
1728
|
-
throw new
|
|
1818
|
+
throw new import_kit32.SolanaError(import_kit32.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1729
1819
|
actualAccountMetas: instruction.accounts.length,
|
|
1730
1820
|
expectedAccountMetas: 2
|
|
1731
1821
|
});
|
|
@@ -1743,30 +1833,98 @@ function parseRevokeDelegationInstruction(instruction) {
|
|
|
1743
1833
|
};
|
|
1744
1834
|
}
|
|
1745
1835
|
|
|
1836
|
+
// src/generated/instructions/revokeSubscriptionAuthority.ts
|
|
1837
|
+
var import_kit33 = require("@solana/kit");
|
|
1838
|
+
var import_program_client_core11 = require("@solana/program-client-core");
|
|
1839
|
+
var REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR = 14;
|
|
1840
|
+
function getRevokeSubscriptionAuthorityDiscriminatorBytes() {
|
|
1841
|
+
return (0, import_kit33.getU8Encoder)().encode(REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR);
|
|
1842
|
+
}
|
|
1843
|
+
function getRevokeSubscriptionAuthorityInstructionDataEncoder() {
|
|
1844
|
+
return (0, import_kit33.transformEncoder)((0, import_kit33.getStructEncoder)([["discriminator", (0, import_kit33.getU8Encoder)()]]), (value) => ({
|
|
1845
|
+
...value,
|
|
1846
|
+
discriminator: REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR
|
|
1847
|
+
}));
|
|
1848
|
+
}
|
|
1849
|
+
function getRevokeSubscriptionAuthorityInstructionDataDecoder() {
|
|
1850
|
+
return (0, import_kit33.getStructDecoder)([["discriminator", (0, import_kit33.getU8Decoder)()]]);
|
|
1851
|
+
}
|
|
1852
|
+
function getRevokeSubscriptionAuthorityInstructionDataCodec() {
|
|
1853
|
+
return (0, import_kit33.combineCodec)(
|
|
1854
|
+
getRevokeSubscriptionAuthorityInstructionDataEncoder(),
|
|
1855
|
+
getRevokeSubscriptionAuthorityInstructionDataDecoder()
|
|
1856
|
+
);
|
|
1857
|
+
}
|
|
1858
|
+
function getRevokeSubscriptionAuthorityInstruction(input, config) {
|
|
1859
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1860
|
+
const originalAccounts = {
|
|
1861
|
+
user: { value: input.user ?? null, isWritable: false },
|
|
1862
|
+
userAta: { value: input.userAta ?? null, isWritable: true },
|
|
1863
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
1864
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }
|
|
1865
|
+
};
|
|
1866
|
+
const accounts = originalAccounts;
|
|
1867
|
+
const getAccountMeta = (0, import_program_client_core11.getAccountMetaFactory)(programAddress, "programId");
|
|
1868
|
+
return Object.freeze({
|
|
1869
|
+
accounts: [
|
|
1870
|
+
getAccountMeta("user", accounts.user),
|
|
1871
|
+
getAccountMeta("userAta", accounts.userAta),
|
|
1872
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
1873
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram)
|
|
1874
|
+
],
|
|
1875
|
+
data: getRevokeSubscriptionAuthorityInstructionDataEncoder().encode({}),
|
|
1876
|
+
programAddress
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
function parseRevokeSubscriptionAuthorityInstruction(instruction) {
|
|
1880
|
+
if (instruction.accounts.length < 4) {
|
|
1881
|
+
throw new import_kit33.SolanaError(import_kit33.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1882
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1883
|
+
expectedAccountMetas: 4
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
let accountIndex = 0;
|
|
1887
|
+
const getNextAccount = () => {
|
|
1888
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1889
|
+
accountIndex += 1;
|
|
1890
|
+
return accountMeta;
|
|
1891
|
+
};
|
|
1892
|
+
return {
|
|
1893
|
+
programAddress: instruction.programAddress,
|
|
1894
|
+
accounts: {
|
|
1895
|
+
user: getNextAccount(),
|
|
1896
|
+
userAta: getNextAccount(),
|
|
1897
|
+
tokenMint: getNextAccount(),
|
|
1898
|
+
tokenProgram: getNextAccount()
|
|
1899
|
+
},
|
|
1900
|
+
data: getRevokeSubscriptionAuthorityInstructionDataDecoder().decode(instruction.data)
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1746
1904
|
// src/generated/instructions/subscribe.ts
|
|
1747
|
-
var
|
|
1748
|
-
var
|
|
1905
|
+
var import_kit34 = require("@solana/kit");
|
|
1906
|
+
var import_program_client_core12 = require("@solana/program-client-core");
|
|
1749
1907
|
var SUBSCRIBE_DISCRIMINATOR = 11;
|
|
1750
1908
|
function getSubscribeDiscriminatorBytes() {
|
|
1751
|
-
return (0,
|
|
1909
|
+
return (0, import_kit34.getU8Encoder)().encode(SUBSCRIBE_DISCRIMINATOR);
|
|
1752
1910
|
}
|
|
1753
1911
|
function getSubscribeInstructionDataEncoder() {
|
|
1754
|
-
return (0,
|
|
1755
|
-
(0,
|
|
1756
|
-
["discriminator", (0,
|
|
1912
|
+
return (0, import_kit34.transformEncoder)(
|
|
1913
|
+
(0, import_kit34.getStructEncoder)([
|
|
1914
|
+
["discriminator", (0, import_kit34.getU8Encoder)()],
|
|
1757
1915
|
["subscribeData", getSubscribeDataEncoder()]
|
|
1758
1916
|
]),
|
|
1759
1917
|
(value) => ({ ...value, discriminator: SUBSCRIBE_DISCRIMINATOR })
|
|
1760
1918
|
);
|
|
1761
1919
|
}
|
|
1762
1920
|
function getSubscribeInstructionDataDecoder() {
|
|
1763
|
-
return (0,
|
|
1764
|
-
["discriminator", (0,
|
|
1921
|
+
return (0, import_kit34.getStructDecoder)([
|
|
1922
|
+
["discriminator", (0, import_kit34.getU8Decoder)()],
|
|
1765
1923
|
["subscribeData", getSubscribeDataDecoder()]
|
|
1766
1924
|
]);
|
|
1767
1925
|
}
|
|
1768
1926
|
function getSubscribeInstructionDataCodec() {
|
|
1769
|
-
return (0,
|
|
1927
|
+
return (0, import_kit34.combineCodec)(getSubscribeInstructionDataEncoder(), getSubscribeInstructionDataDecoder());
|
|
1770
1928
|
}
|
|
1771
1929
|
async function getSubscribeInstructionAsync(input, config) {
|
|
1772
1930
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -1784,8 +1942,8 @@ async function getSubscribeInstructionAsync(input, config) {
|
|
|
1784
1942
|
const args = { ...input };
|
|
1785
1943
|
if (!accounts.subscriptionPda.value) {
|
|
1786
1944
|
accounts.subscriptionPda.value = await findSubscriptionDelegationPda({
|
|
1787
|
-
planPda: (0,
|
|
1788
|
-
subscriber: (0,
|
|
1945
|
+
planPda: (0, import_program_client_core12.getAddressFromResolvedInstructionAccount)("planPda", accounts.planPda.value),
|
|
1946
|
+
subscriber: (0, import_program_client_core12.getAddressFromResolvedInstructionAccount)("subscriber", accounts.subscriber.value)
|
|
1789
1947
|
});
|
|
1790
1948
|
}
|
|
1791
1949
|
if (!accounts.systemProgram.value) {
|
|
@@ -1797,7 +1955,7 @@ async function getSubscribeInstructionAsync(input, config) {
|
|
|
1797
1955
|
if (!accounts.selfProgram.value) {
|
|
1798
1956
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1799
1957
|
}
|
|
1800
|
-
const getAccountMeta = (0,
|
|
1958
|
+
const getAccountMeta = (0, import_program_client_core12.getAccountMetaFactory)(programAddress, "programId");
|
|
1801
1959
|
return Object.freeze({
|
|
1802
1960
|
accounts: [
|
|
1803
1961
|
getAccountMeta("subscriber", accounts.subscriber),
|
|
@@ -1836,7 +1994,7 @@ function getSubscribeInstruction(input, config) {
|
|
|
1836
1994
|
if (!accounts.selfProgram.value) {
|
|
1837
1995
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1838
1996
|
}
|
|
1839
|
-
const getAccountMeta = (0,
|
|
1997
|
+
const getAccountMeta = (0, import_program_client_core12.getAccountMetaFactory)(programAddress, "programId");
|
|
1840
1998
|
return Object.freeze({
|
|
1841
1999
|
accounts: [
|
|
1842
2000
|
getAccountMeta("subscriber", accounts.subscriber),
|
|
@@ -1854,7 +2012,7 @@ function getSubscribeInstruction(input, config) {
|
|
|
1854
2012
|
}
|
|
1855
2013
|
function parseSubscribeInstruction(instruction) {
|
|
1856
2014
|
if (instruction.accounts.length < 8) {
|
|
1857
|
-
throw new
|
|
2015
|
+
throw new import_kit34.SolanaError(import_kit34.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1858
2016
|
actualAccountMetas: instruction.accounts.length,
|
|
1859
2017
|
expectedAccountMetas: 8
|
|
1860
2018
|
});
|
|
@@ -1882,29 +2040,29 @@ function parseSubscribeInstruction(instruction) {
|
|
|
1882
2040
|
}
|
|
1883
2041
|
|
|
1884
2042
|
// src/generated/instructions/transferFixed.ts
|
|
1885
|
-
var
|
|
1886
|
-
var
|
|
2043
|
+
var import_kit35 = require("@solana/kit");
|
|
2044
|
+
var import_program_client_core13 = require("@solana/program-client-core");
|
|
1887
2045
|
var TRANSFER_FIXED_DISCRIMINATOR = 4;
|
|
1888
2046
|
function getTransferFixedDiscriminatorBytes() {
|
|
1889
|
-
return (0,
|
|
2047
|
+
return (0, import_kit35.getU8Encoder)().encode(TRANSFER_FIXED_DISCRIMINATOR);
|
|
1890
2048
|
}
|
|
1891
2049
|
function getTransferFixedInstructionDataEncoder() {
|
|
1892
|
-
return (0,
|
|
1893
|
-
(0,
|
|
1894
|
-
["discriminator", (0,
|
|
2050
|
+
return (0, import_kit35.transformEncoder)(
|
|
2051
|
+
(0, import_kit35.getStructEncoder)([
|
|
2052
|
+
["discriminator", (0, import_kit35.getU8Encoder)()],
|
|
1895
2053
|
["transferData", getTransferDataEncoder()]
|
|
1896
2054
|
]),
|
|
1897
2055
|
(value) => ({ ...value, discriminator: TRANSFER_FIXED_DISCRIMINATOR })
|
|
1898
2056
|
);
|
|
1899
2057
|
}
|
|
1900
2058
|
function getTransferFixedInstructionDataDecoder() {
|
|
1901
|
-
return (0,
|
|
1902
|
-
["discriminator", (0,
|
|
2059
|
+
return (0, import_kit35.getStructDecoder)([
|
|
2060
|
+
["discriminator", (0, import_kit35.getU8Decoder)()],
|
|
1903
2061
|
["transferData", getTransferDataDecoder()]
|
|
1904
2062
|
]);
|
|
1905
2063
|
}
|
|
1906
2064
|
function getTransferFixedInstructionDataCodec() {
|
|
1907
|
-
return (0,
|
|
2065
|
+
return (0, import_kit35.combineCodec)(getTransferFixedInstructionDataEncoder(), getTransferFixedInstructionDataDecoder());
|
|
1908
2066
|
}
|
|
1909
2067
|
function getTransferFixedInstruction(input, config) {
|
|
1910
2068
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -1913,6 +2071,7 @@ function getTransferFixedInstruction(input, config) {
|
|
|
1913
2071
|
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
1914
2072
|
delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
|
|
1915
2073
|
receiverAta: { value: input.receiverAta ?? null, isWritable: true },
|
|
2074
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
1916
2075
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
1917
2076
|
delegatee: { value: input.delegatee ?? null, isWritable: false },
|
|
1918
2077
|
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
@@ -1926,13 +2085,14 @@ function getTransferFixedInstruction(input, config) {
|
|
|
1926
2085
|
if (!accounts.selfProgram.value) {
|
|
1927
2086
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1928
2087
|
}
|
|
1929
|
-
const getAccountMeta = (0,
|
|
2088
|
+
const getAccountMeta = (0, import_program_client_core13.getAccountMetaFactory)(programAddress, "programId");
|
|
1930
2089
|
return Object.freeze({
|
|
1931
2090
|
accounts: [
|
|
1932
2091
|
getAccountMeta("delegationPda", accounts.delegationPda),
|
|
1933
2092
|
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
1934
2093
|
getAccountMeta("delegatorAta", accounts.delegatorAta),
|
|
1935
2094
|
getAccountMeta("receiverAta", accounts.receiverAta),
|
|
2095
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
1936
2096
|
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
1937
2097
|
getAccountMeta("delegatee", accounts.delegatee),
|
|
1938
2098
|
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
@@ -1943,10 +2103,10 @@ function getTransferFixedInstruction(input, config) {
|
|
|
1943
2103
|
});
|
|
1944
2104
|
}
|
|
1945
2105
|
function parseTransferFixedInstruction(instruction) {
|
|
1946
|
-
if (instruction.accounts.length <
|
|
1947
|
-
throw new
|
|
2106
|
+
if (instruction.accounts.length < 9) {
|
|
2107
|
+
throw new import_kit35.SolanaError(import_kit35.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1948
2108
|
actualAccountMetas: instruction.accounts.length,
|
|
1949
|
-
expectedAccountMetas:
|
|
2109
|
+
expectedAccountMetas: 9
|
|
1950
2110
|
});
|
|
1951
2111
|
}
|
|
1952
2112
|
let accountIndex = 0;
|
|
@@ -1962,6 +2122,7 @@ function parseTransferFixedInstruction(instruction) {
|
|
|
1962
2122
|
subscriptionAuthority: getNextAccount(),
|
|
1963
2123
|
delegatorAta: getNextAccount(),
|
|
1964
2124
|
receiverAta: getNextAccount(),
|
|
2125
|
+
tokenMint: getNextAccount(),
|
|
1965
2126
|
tokenProgram: getNextAccount(),
|
|
1966
2127
|
delegatee: getNextAccount(),
|
|
1967
2128
|
eventAuthority: getNextAccount(),
|
|
@@ -1972,29 +2133,29 @@ function parseTransferFixedInstruction(instruction) {
|
|
|
1972
2133
|
}
|
|
1973
2134
|
|
|
1974
2135
|
// src/generated/instructions/transferRecurring.ts
|
|
1975
|
-
var
|
|
1976
|
-
var
|
|
2136
|
+
var import_kit36 = require("@solana/kit");
|
|
2137
|
+
var import_program_client_core14 = require("@solana/program-client-core");
|
|
1977
2138
|
var TRANSFER_RECURRING_DISCRIMINATOR = 5;
|
|
1978
2139
|
function getTransferRecurringDiscriminatorBytes() {
|
|
1979
|
-
return (0,
|
|
2140
|
+
return (0, import_kit36.getU8Encoder)().encode(TRANSFER_RECURRING_DISCRIMINATOR);
|
|
1980
2141
|
}
|
|
1981
2142
|
function getTransferRecurringInstructionDataEncoder() {
|
|
1982
|
-
return (0,
|
|
1983
|
-
(0,
|
|
1984
|
-
["discriminator", (0,
|
|
2143
|
+
return (0, import_kit36.transformEncoder)(
|
|
2144
|
+
(0, import_kit36.getStructEncoder)([
|
|
2145
|
+
["discriminator", (0, import_kit36.getU8Encoder)()],
|
|
1985
2146
|
["transferData", getTransferDataEncoder()]
|
|
1986
2147
|
]),
|
|
1987
2148
|
(value) => ({ ...value, discriminator: TRANSFER_RECURRING_DISCRIMINATOR })
|
|
1988
2149
|
);
|
|
1989
2150
|
}
|
|
1990
2151
|
function getTransferRecurringInstructionDataDecoder() {
|
|
1991
|
-
return (0,
|
|
1992
|
-
["discriminator", (0,
|
|
2152
|
+
return (0, import_kit36.getStructDecoder)([
|
|
2153
|
+
["discriminator", (0, import_kit36.getU8Decoder)()],
|
|
1993
2154
|
["transferData", getTransferDataDecoder()]
|
|
1994
2155
|
]);
|
|
1995
2156
|
}
|
|
1996
2157
|
function getTransferRecurringInstructionDataCodec() {
|
|
1997
|
-
return (0,
|
|
2158
|
+
return (0, import_kit36.combineCodec)(getTransferRecurringInstructionDataEncoder(), getTransferRecurringInstructionDataDecoder());
|
|
1998
2159
|
}
|
|
1999
2160
|
function getTransferRecurringInstruction(input, config) {
|
|
2000
2161
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -2003,6 +2164,7 @@ function getTransferRecurringInstruction(input, config) {
|
|
|
2003
2164
|
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
|
|
2004
2165
|
delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
|
|
2005
2166
|
receiverAta: { value: input.receiverAta ?? null, isWritable: true },
|
|
2167
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
2006
2168
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
2007
2169
|
delegatee: { value: input.delegatee ?? null, isWritable: false },
|
|
2008
2170
|
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
@@ -2016,13 +2178,14 @@ function getTransferRecurringInstruction(input, config) {
|
|
|
2016
2178
|
if (!accounts.selfProgram.value) {
|
|
2017
2179
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
2018
2180
|
}
|
|
2019
|
-
const getAccountMeta = (0,
|
|
2181
|
+
const getAccountMeta = (0, import_program_client_core14.getAccountMetaFactory)(programAddress, "programId");
|
|
2020
2182
|
return Object.freeze({
|
|
2021
2183
|
accounts: [
|
|
2022
2184
|
getAccountMeta("delegationPda", accounts.delegationPda),
|
|
2023
2185
|
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
|
|
2024
2186
|
getAccountMeta("delegatorAta", accounts.delegatorAta),
|
|
2025
2187
|
getAccountMeta("receiverAta", accounts.receiverAta),
|
|
2188
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
2026
2189
|
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
2027
2190
|
getAccountMeta("delegatee", accounts.delegatee),
|
|
2028
2191
|
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
@@ -2033,10 +2196,10 @@ function getTransferRecurringInstruction(input, config) {
|
|
|
2033
2196
|
});
|
|
2034
2197
|
}
|
|
2035
2198
|
function parseTransferRecurringInstruction(instruction) {
|
|
2036
|
-
if (instruction.accounts.length <
|
|
2037
|
-
throw new
|
|
2199
|
+
if (instruction.accounts.length < 9) {
|
|
2200
|
+
throw new import_kit36.SolanaError(import_kit36.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
2038
2201
|
actualAccountMetas: instruction.accounts.length,
|
|
2039
|
-
expectedAccountMetas:
|
|
2202
|
+
expectedAccountMetas: 9
|
|
2040
2203
|
});
|
|
2041
2204
|
}
|
|
2042
2205
|
let accountIndex = 0;
|
|
@@ -2052,6 +2215,7 @@ function parseTransferRecurringInstruction(instruction) {
|
|
|
2052
2215
|
subscriptionAuthority: getNextAccount(),
|
|
2053
2216
|
delegatorAta: getNextAccount(),
|
|
2054
2217
|
receiverAta: getNextAccount(),
|
|
2218
|
+
tokenMint: getNextAccount(),
|
|
2055
2219
|
tokenProgram: getNextAccount(),
|
|
2056
2220
|
delegatee: getNextAccount(),
|
|
2057
2221
|
eventAuthority: getNextAccount(),
|
|
@@ -2062,29 +2226,29 @@ function parseTransferRecurringInstruction(instruction) {
|
|
|
2062
2226
|
}
|
|
2063
2227
|
|
|
2064
2228
|
// src/generated/instructions/transferSubscription.ts
|
|
2065
|
-
var
|
|
2066
|
-
var
|
|
2229
|
+
var import_kit37 = require("@solana/kit");
|
|
2230
|
+
var import_program_client_core15 = require("@solana/program-client-core");
|
|
2067
2231
|
var TRANSFER_SUBSCRIPTION_DISCRIMINATOR = 10;
|
|
2068
2232
|
function getTransferSubscriptionDiscriminatorBytes() {
|
|
2069
|
-
return (0,
|
|
2233
|
+
return (0, import_kit37.getU8Encoder)().encode(TRANSFER_SUBSCRIPTION_DISCRIMINATOR);
|
|
2070
2234
|
}
|
|
2071
2235
|
function getTransferSubscriptionInstructionDataEncoder() {
|
|
2072
|
-
return (0,
|
|
2073
|
-
(0,
|
|
2074
|
-
["discriminator", (0,
|
|
2236
|
+
return (0, import_kit37.transformEncoder)(
|
|
2237
|
+
(0, import_kit37.getStructEncoder)([
|
|
2238
|
+
["discriminator", (0, import_kit37.getU8Encoder)()],
|
|
2075
2239
|
["transferData", getTransferDataEncoder()]
|
|
2076
2240
|
]),
|
|
2077
2241
|
(value) => ({ ...value, discriminator: TRANSFER_SUBSCRIPTION_DISCRIMINATOR })
|
|
2078
2242
|
);
|
|
2079
2243
|
}
|
|
2080
2244
|
function getTransferSubscriptionInstructionDataDecoder() {
|
|
2081
|
-
return (0,
|
|
2082
|
-
["discriminator", (0,
|
|
2245
|
+
return (0, import_kit37.getStructDecoder)([
|
|
2246
|
+
["discriminator", (0, import_kit37.getU8Decoder)()],
|
|
2083
2247
|
["transferData", getTransferDataDecoder()]
|
|
2084
2248
|
]);
|
|
2085
2249
|
}
|
|
2086
2250
|
function getTransferSubscriptionInstructionDataCodec() {
|
|
2087
|
-
return (0,
|
|
2251
|
+
return (0, import_kit37.combineCodec)(
|
|
2088
2252
|
getTransferSubscriptionInstructionDataEncoder(),
|
|
2089
2253
|
getTransferSubscriptionInstructionDataDecoder()
|
|
2090
2254
|
);
|
|
@@ -2098,6 +2262,7 @@ function getTransferSubscriptionInstruction(input, config) {
|
|
|
2098
2262
|
delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
|
|
2099
2263
|
receiverAta: { value: input.receiverAta ?? null, isWritable: true },
|
|
2100
2264
|
caller: { value: input.caller ?? null, isWritable: false },
|
|
2265
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
2101
2266
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
2102
2267
|
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
2103
2268
|
selfProgram: { value: input.selfProgram ?? null, isWritable: false }
|
|
@@ -2110,7 +2275,7 @@ function getTransferSubscriptionInstruction(input, config) {
|
|
|
2110
2275
|
if (!accounts.selfProgram.value) {
|
|
2111
2276
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
2112
2277
|
}
|
|
2113
|
-
const getAccountMeta = (0,
|
|
2278
|
+
const getAccountMeta = (0, import_program_client_core15.getAccountMetaFactory)(programAddress, "programId");
|
|
2114
2279
|
return Object.freeze({
|
|
2115
2280
|
accounts: [
|
|
2116
2281
|
getAccountMeta("subscriptionPda", accounts.subscriptionPda),
|
|
@@ -2119,6 +2284,7 @@ function getTransferSubscriptionInstruction(input, config) {
|
|
|
2119
2284
|
getAccountMeta("delegatorAta", accounts.delegatorAta),
|
|
2120
2285
|
getAccountMeta("receiverAta", accounts.receiverAta),
|
|
2121
2286
|
getAccountMeta("caller", accounts.caller),
|
|
2287
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
2122
2288
|
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
2123
2289
|
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
2124
2290
|
getAccountMeta("selfProgram", accounts.selfProgram)
|
|
@@ -2128,10 +2294,10 @@ function getTransferSubscriptionInstruction(input, config) {
|
|
|
2128
2294
|
});
|
|
2129
2295
|
}
|
|
2130
2296
|
function parseTransferSubscriptionInstruction(instruction) {
|
|
2131
|
-
if (instruction.accounts.length <
|
|
2132
|
-
throw new
|
|
2297
|
+
if (instruction.accounts.length < 10) {
|
|
2298
|
+
throw new import_kit37.SolanaError(import_kit37.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
2133
2299
|
actualAccountMetas: instruction.accounts.length,
|
|
2134
|
-
expectedAccountMetas:
|
|
2300
|
+
expectedAccountMetas: 10
|
|
2135
2301
|
});
|
|
2136
2302
|
}
|
|
2137
2303
|
let accountIndex = 0;
|
|
@@ -2149,6 +2315,7 @@ function parseTransferSubscriptionInstruction(instruction) {
|
|
|
2149
2315
|
delegatorAta: getNextAccount(),
|
|
2150
2316
|
receiverAta: getNextAccount(),
|
|
2151
2317
|
caller: getNextAccount(),
|
|
2318
|
+
tokenMint: getNextAccount(),
|
|
2152
2319
|
tokenProgram: getNextAccount(),
|
|
2153
2320
|
eventAuthority: getNextAccount(),
|
|
2154
2321
|
selfProgram: getNextAccount()
|
|
@@ -2158,29 +2325,29 @@ function parseTransferSubscriptionInstruction(instruction) {
|
|
|
2158
2325
|
}
|
|
2159
2326
|
|
|
2160
2327
|
// src/generated/instructions/updatePlan.ts
|
|
2161
|
-
var
|
|
2162
|
-
var
|
|
2328
|
+
var import_kit38 = require("@solana/kit");
|
|
2329
|
+
var import_program_client_core16 = require("@solana/program-client-core");
|
|
2163
2330
|
var UPDATE_PLAN_DISCRIMINATOR = 8;
|
|
2164
2331
|
function getUpdatePlanDiscriminatorBytes() {
|
|
2165
|
-
return (0,
|
|
2332
|
+
return (0, import_kit38.getU8Encoder)().encode(UPDATE_PLAN_DISCRIMINATOR);
|
|
2166
2333
|
}
|
|
2167
2334
|
function getUpdatePlanInstructionDataEncoder() {
|
|
2168
|
-
return (0,
|
|
2169
|
-
(0,
|
|
2170
|
-
["discriminator", (0,
|
|
2335
|
+
return (0, import_kit38.transformEncoder)(
|
|
2336
|
+
(0, import_kit38.getStructEncoder)([
|
|
2337
|
+
["discriminator", (0, import_kit38.getU8Encoder)()],
|
|
2171
2338
|
["updatePlanData", getUpdatePlanDataEncoder()]
|
|
2172
2339
|
]),
|
|
2173
2340
|
(value) => ({ ...value, discriminator: UPDATE_PLAN_DISCRIMINATOR })
|
|
2174
2341
|
);
|
|
2175
2342
|
}
|
|
2176
2343
|
function getUpdatePlanInstructionDataDecoder() {
|
|
2177
|
-
return (0,
|
|
2178
|
-
["discriminator", (0,
|
|
2344
|
+
return (0, import_kit38.getStructDecoder)([
|
|
2345
|
+
["discriminator", (0, import_kit38.getU8Decoder)()],
|
|
2179
2346
|
["updatePlanData", getUpdatePlanDataDecoder()]
|
|
2180
2347
|
]);
|
|
2181
2348
|
}
|
|
2182
2349
|
function getUpdatePlanInstructionDataCodec() {
|
|
2183
|
-
return (0,
|
|
2350
|
+
return (0, import_kit38.combineCodec)(getUpdatePlanInstructionDataEncoder(), getUpdatePlanInstructionDataDecoder());
|
|
2184
2351
|
}
|
|
2185
2352
|
function getUpdatePlanInstruction(input, config) {
|
|
2186
2353
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -2190,7 +2357,7 @@ function getUpdatePlanInstruction(input, config) {
|
|
|
2190
2357
|
};
|
|
2191
2358
|
const accounts = originalAccounts;
|
|
2192
2359
|
const args = { ...input };
|
|
2193
|
-
const getAccountMeta = (0,
|
|
2360
|
+
const getAccountMeta = (0, import_program_client_core16.getAccountMetaFactory)(programAddress, "programId");
|
|
2194
2361
|
return Object.freeze({
|
|
2195
2362
|
accounts: [getAccountMeta("owner", accounts.owner), getAccountMeta("planPda", accounts.planPda)],
|
|
2196
2363
|
data: getUpdatePlanInstructionDataEncoder().encode(args),
|
|
@@ -2199,7 +2366,7 @@ function getUpdatePlanInstruction(input, config) {
|
|
|
2199
2366
|
}
|
|
2200
2367
|
function parseUpdatePlanInstruction(instruction) {
|
|
2201
2368
|
if (instruction.accounts.length < 2) {
|
|
2202
|
-
throw new
|
|
2369
|
+
throw new import_kit38.SolanaError(import_kit38.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
2203
2370
|
actualAccountMetas: instruction.accounts.length,
|
|
2204
2371
|
expectedAccountMetas: 2
|
|
2205
2372
|
});
|
|
@@ -2243,53 +2410,61 @@ var SubscriptionsInstruction = /* @__PURE__ */ ((SubscriptionsInstruction2) => {
|
|
|
2243
2410
|
SubscriptionsInstruction2[SubscriptionsInstruction2["Subscribe"] = 11] = "Subscribe";
|
|
2244
2411
|
SubscriptionsInstruction2[SubscriptionsInstruction2["CancelSubscription"] = 12] = "CancelSubscription";
|
|
2245
2412
|
SubscriptionsInstruction2[SubscriptionsInstruction2["ResumeSubscription"] = 13] = "ResumeSubscription";
|
|
2413
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeSubscriptionAuthority"] = 14] = "RevokeSubscriptionAuthority";
|
|
2414
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeAbandonedDelegation"] = 15] = "RevokeAbandonedDelegation";
|
|
2246
2415
|
return SubscriptionsInstruction2;
|
|
2247
2416
|
})(SubscriptionsInstruction || {});
|
|
2248
2417
|
function identifySubscriptionsInstruction(instruction) {
|
|
2249
2418
|
const data = "data" in instruction ? instruction.data : instruction;
|
|
2250
|
-
if ((0,
|
|
2419
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(0), 0)) {
|
|
2251
2420
|
return 0 /* InitSubscriptionAuthority */;
|
|
2252
2421
|
}
|
|
2253
|
-
if ((0,
|
|
2422
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(1), 0)) {
|
|
2254
2423
|
return 1 /* CreateFixedDelegation */;
|
|
2255
2424
|
}
|
|
2256
|
-
if ((0,
|
|
2425
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(2), 0)) {
|
|
2257
2426
|
return 2 /* CreateRecurringDelegation */;
|
|
2258
2427
|
}
|
|
2259
|
-
if ((0,
|
|
2428
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(3), 0)) {
|
|
2260
2429
|
return 3 /* RevokeDelegation */;
|
|
2261
2430
|
}
|
|
2262
|
-
if ((0,
|
|
2431
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(4), 0)) {
|
|
2263
2432
|
return 4 /* TransferFixed */;
|
|
2264
2433
|
}
|
|
2265
|
-
if ((0,
|
|
2434
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(5), 0)) {
|
|
2266
2435
|
return 5 /* TransferRecurring */;
|
|
2267
2436
|
}
|
|
2268
|
-
if ((0,
|
|
2437
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(6), 0)) {
|
|
2269
2438
|
return 6 /* CloseSubscriptionAuthority */;
|
|
2270
2439
|
}
|
|
2271
|
-
if ((0,
|
|
2440
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(7), 0)) {
|
|
2272
2441
|
return 7 /* CreatePlan */;
|
|
2273
2442
|
}
|
|
2274
|
-
if ((0,
|
|
2443
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(8), 0)) {
|
|
2275
2444
|
return 8 /* UpdatePlan */;
|
|
2276
2445
|
}
|
|
2277
|
-
if ((0,
|
|
2446
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(9), 0)) {
|
|
2278
2447
|
return 9 /* DeletePlan */;
|
|
2279
2448
|
}
|
|
2280
|
-
if ((0,
|
|
2449
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(10), 0)) {
|
|
2281
2450
|
return 10 /* TransferSubscription */;
|
|
2282
2451
|
}
|
|
2283
|
-
if ((0,
|
|
2452
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(11), 0)) {
|
|
2284
2453
|
return 11 /* Subscribe */;
|
|
2285
2454
|
}
|
|
2286
|
-
if ((0,
|
|
2455
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(12), 0)) {
|
|
2287
2456
|
return 12 /* CancelSubscription */;
|
|
2288
2457
|
}
|
|
2289
|
-
if ((0,
|
|
2458
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(13), 0)) {
|
|
2290
2459
|
return 13 /* ResumeSubscription */;
|
|
2291
2460
|
}
|
|
2292
|
-
|
|
2461
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(14), 0)) {
|
|
2462
|
+
return 14 /* RevokeSubscriptionAuthority */;
|
|
2463
|
+
}
|
|
2464
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(15), 0)) {
|
|
2465
|
+
return 15 /* RevokeAbandonedDelegation */;
|
|
2466
|
+
}
|
|
2467
|
+
throw new import_kit39.SolanaError(import_kit39.SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
|
|
2293
2468
|
instructionData: data,
|
|
2294
2469
|
programName: "subscriptions"
|
|
2295
2470
|
});
|
|
@@ -2298,93 +2473,107 @@ function parseSubscriptionsInstruction(instruction) {
|
|
|
2298
2473
|
const instructionType = identifySubscriptionsInstruction(instruction);
|
|
2299
2474
|
switch (instructionType) {
|
|
2300
2475
|
case 0 /* InitSubscriptionAuthority */: {
|
|
2301
|
-
(0,
|
|
2476
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2302
2477
|
return {
|
|
2303
2478
|
instructionType: 0 /* InitSubscriptionAuthority */,
|
|
2304
2479
|
...parseInitSubscriptionAuthorityInstruction(instruction)
|
|
2305
2480
|
};
|
|
2306
2481
|
}
|
|
2307
2482
|
case 1 /* CreateFixedDelegation */: {
|
|
2308
|
-
(0,
|
|
2483
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2309
2484
|
return {
|
|
2310
2485
|
instructionType: 1 /* CreateFixedDelegation */,
|
|
2311
2486
|
...parseCreateFixedDelegationInstruction(instruction)
|
|
2312
2487
|
};
|
|
2313
2488
|
}
|
|
2314
2489
|
case 2 /* CreateRecurringDelegation */: {
|
|
2315
|
-
(0,
|
|
2490
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2316
2491
|
return {
|
|
2317
2492
|
instructionType: 2 /* CreateRecurringDelegation */,
|
|
2318
2493
|
...parseCreateRecurringDelegationInstruction(instruction)
|
|
2319
2494
|
};
|
|
2320
2495
|
}
|
|
2321
2496
|
case 3 /* RevokeDelegation */: {
|
|
2322
|
-
(0,
|
|
2497
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2323
2498
|
return {
|
|
2324
2499
|
instructionType: 3 /* RevokeDelegation */,
|
|
2325
2500
|
...parseRevokeDelegationInstruction(instruction)
|
|
2326
2501
|
};
|
|
2327
2502
|
}
|
|
2328
2503
|
case 4 /* TransferFixed */: {
|
|
2329
|
-
(0,
|
|
2504
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2330
2505
|
return {
|
|
2331
2506
|
instructionType: 4 /* TransferFixed */,
|
|
2332
2507
|
...parseTransferFixedInstruction(instruction)
|
|
2333
2508
|
};
|
|
2334
2509
|
}
|
|
2335
2510
|
case 5 /* TransferRecurring */: {
|
|
2336
|
-
(0,
|
|
2511
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2337
2512
|
return {
|
|
2338
2513
|
instructionType: 5 /* TransferRecurring */,
|
|
2339
2514
|
...parseTransferRecurringInstruction(instruction)
|
|
2340
2515
|
};
|
|
2341
2516
|
}
|
|
2342
2517
|
case 6 /* CloseSubscriptionAuthority */: {
|
|
2343
|
-
(0,
|
|
2518
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2344
2519
|
return {
|
|
2345
2520
|
instructionType: 6 /* CloseSubscriptionAuthority */,
|
|
2346
2521
|
...parseCloseSubscriptionAuthorityInstruction(instruction)
|
|
2347
2522
|
};
|
|
2348
2523
|
}
|
|
2349
2524
|
case 7 /* CreatePlan */: {
|
|
2350
|
-
(0,
|
|
2525
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2351
2526
|
return { instructionType: 7 /* CreatePlan */, ...parseCreatePlanInstruction(instruction) };
|
|
2352
2527
|
}
|
|
2353
2528
|
case 8 /* UpdatePlan */: {
|
|
2354
|
-
(0,
|
|
2529
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2355
2530
|
return { instructionType: 8 /* UpdatePlan */, ...parseUpdatePlanInstruction(instruction) };
|
|
2356
2531
|
}
|
|
2357
2532
|
case 9 /* DeletePlan */: {
|
|
2358
|
-
(0,
|
|
2533
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2359
2534
|
return { instructionType: 9 /* DeletePlan */, ...parseDeletePlanInstruction(instruction) };
|
|
2360
2535
|
}
|
|
2361
2536
|
case 10 /* TransferSubscription */: {
|
|
2362
|
-
(0,
|
|
2537
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2363
2538
|
return {
|
|
2364
2539
|
instructionType: 10 /* TransferSubscription */,
|
|
2365
2540
|
...parseTransferSubscriptionInstruction(instruction)
|
|
2366
2541
|
};
|
|
2367
2542
|
}
|
|
2368
2543
|
case 11 /* Subscribe */: {
|
|
2369
|
-
(0,
|
|
2544
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2370
2545
|
return { instructionType: 11 /* Subscribe */, ...parseSubscribeInstruction(instruction) };
|
|
2371
2546
|
}
|
|
2372
2547
|
case 12 /* CancelSubscription */: {
|
|
2373
|
-
(0,
|
|
2548
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2374
2549
|
return {
|
|
2375
2550
|
instructionType: 12 /* CancelSubscription */,
|
|
2376
2551
|
...parseCancelSubscriptionInstruction(instruction)
|
|
2377
2552
|
};
|
|
2378
2553
|
}
|
|
2379
2554
|
case 13 /* ResumeSubscription */: {
|
|
2380
|
-
(0,
|
|
2555
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2381
2556
|
return {
|
|
2382
2557
|
instructionType: 13 /* ResumeSubscription */,
|
|
2383
2558
|
...parseResumeSubscriptionInstruction(instruction)
|
|
2384
2559
|
};
|
|
2385
2560
|
}
|
|
2561
|
+
case 14 /* RevokeSubscriptionAuthority */: {
|
|
2562
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2563
|
+
return {
|
|
2564
|
+
instructionType: 14 /* RevokeSubscriptionAuthority */,
|
|
2565
|
+
...parseRevokeSubscriptionAuthorityInstruction(instruction)
|
|
2566
|
+
};
|
|
2567
|
+
}
|
|
2568
|
+
case 15 /* RevokeAbandonedDelegation */: {
|
|
2569
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2570
|
+
return {
|
|
2571
|
+
instructionType: 15 /* RevokeAbandonedDelegation */,
|
|
2572
|
+
...parseRevokeAbandonedDelegationInstruction(instruction)
|
|
2573
|
+
};
|
|
2574
|
+
}
|
|
2386
2575
|
default:
|
|
2387
|
-
throw new
|
|
2576
|
+
throw new import_kit39.SolanaError(import_kit39.SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
|
|
2388
2577
|
instructionType,
|
|
2389
2578
|
programName: "subscriptions"
|
|
2390
2579
|
});
|
|
@@ -2392,31 +2581,33 @@ function parseSubscriptionsInstruction(instruction) {
|
|
|
2392
2581
|
}
|
|
2393
2582
|
function subscriptionsProgram() {
|
|
2394
2583
|
return (client) => {
|
|
2395
|
-
return (0,
|
|
2584
|
+
return (0, import_kit39.extendClient)(client, {
|
|
2396
2585
|
subscriptions: {
|
|
2397
2586
|
accounts: {
|
|
2398
|
-
fixedDelegation: (0,
|
|
2399
|
-
plan: (0,
|
|
2400
|
-
recurringDelegation: (0,
|
|
2401
|
-
subscriptionAuthority: (0,
|
|
2402
|
-
subscriptionDelegation: (0,
|
|
2403
|
-
eventAuthority: (0,
|
|
2587
|
+
fixedDelegation: (0, import_program_client_core17.addSelfFetchFunctions)(client, getFixedDelegationCodec()),
|
|
2588
|
+
plan: (0, import_program_client_core17.addSelfFetchFunctions)(client, getPlanCodec()),
|
|
2589
|
+
recurringDelegation: (0, import_program_client_core17.addSelfFetchFunctions)(client, getRecurringDelegationCodec()),
|
|
2590
|
+
subscriptionAuthority: (0, import_program_client_core17.addSelfFetchFunctions)(client, getSubscriptionAuthorityCodec()),
|
|
2591
|
+
subscriptionDelegation: (0, import_program_client_core17.addSelfFetchFunctions)(client, getSubscriptionDelegationCodec()),
|
|
2592
|
+
eventAuthority: (0, import_program_client_core17.addSelfFetchFunctions)(client, getEventAuthorityCodec())
|
|
2404
2593
|
},
|
|
2405
2594
|
instructions: {
|
|
2406
|
-
initSubscriptionAuthority: (input) => (0,
|
|
2407
|
-
createFixedDelegation: (input) => (0,
|
|
2408
|
-
createRecurringDelegation: (input) => (0,
|
|
2409
|
-
revokeDelegation: (input) => (0,
|
|
2410
|
-
transferFixed: (input) => (0,
|
|
2411
|
-
transferRecurring: (input) => (0,
|
|
2412
|
-
closeSubscriptionAuthority: (input) => (0,
|
|
2413
|
-
createPlan: (input) => (0,
|
|
2414
|
-
updatePlan: (input) => (0,
|
|
2415
|
-
deletePlan: (input) => (0,
|
|
2416
|
-
transferSubscription: (input) => (0,
|
|
2417
|
-
subscribe: (input) => (0,
|
|
2418
|
-
cancelSubscription: (input) => (0,
|
|
2419
|
-
resumeSubscription: (input) => (0,
|
|
2595
|
+
initSubscriptionAuthority: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getInitSubscriptionAuthorityInstructionAsync(input)),
|
|
2596
|
+
createFixedDelegation: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getCreateFixedDelegationInstruction(input)),
|
|
2597
|
+
createRecurringDelegation: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getCreateRecurringDelegationInstruction(input)),
|
|
2598
|
+
revokeDelegation: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getRevokeDelegationInstruction(input)),
|
|
2599
|
+
transferFixed: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getTransferFixedInstruction(input)),
|
|
2600
|
+
transferRecurring: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getTransferRecurringInstruction(input)),
|
|
2601
|
+
closeSubscriptionAuthority: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getCloseSubscriptionAuthorityInstruction(input)),
|
|
2602
|
+
createPlan: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getCreatePlanInstruction(input)),
|
|
2603
|
+
updatePlan: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getUpdatePlanInstruction(input)),
|
|
2604
|
+
deletePlan: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getDeletePlanInstruction(input)),
|
|
2605
|
+
transferSubscription: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getTransferSubscriptionInstruction(input)),
|
|
2606
|
+
subscribe: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getSubscribeInstructionAsync(input)),
|
|
2607
|
+
cancelSubscription: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getCancelSubscriptionInstructionAsync(input)),
|
|
2608
|
+
resumeSubscription: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getResumeSubscriptionInstructionAsync(input)),
|
|
2609
|
+
revokeSubscriptionAuthority: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getRevokeSubscriptionAuthorityInstruction(input)),
|
|
2610
|
+
revokeAbandonedDelegation: (input) => (0, import_program_client_core17.addSelfPlanAndSendFunctions)(client, getRevokeAbandonedDelegationInstruction(input))
|
|
2420
2611
|
},
|
|
2421
2612
|
pdas: {
|
|
2422
2613
|
fixedDelegation: findFixedDelegationPda,
|
|
@@ -2469,6 +2660,8 @@ var SUBSCRIPTIONS_ERROR__DELEGATION_VERSION_MISMATCH = 133;
|
|
|
2469
2660
|
var SUBSCRIPTIONS_ERROR__MIGRATION_REQUIRED = 134;
|
|
2470
2661
|
var SUBSCRIPTIONS_ERROR__DELEGATION_ALREADY_EXISTS = 135;
|
|
2471
2662
|
var SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY = 136;
|
|
2663
|
+
var SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS = 137;
|
|
2664
|
+
var SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_VALIDATION_ACCOUNT_MISSING = 138;
|
|
2472
2665
|
var SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_LIMIT = 300;
|
|
2473
2666
|
var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_EXPIRY_IN_PAST = 301;
|
|
2474
2667
|
var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_AMOUNT_ZERO = 302;
|
|
@@ -2480,6 +2673,7 @@ var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST = 404;
|
|
|
2480
2673
|
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY = 405;
|
|
2481
2674
|
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO = 406;
|
|
2482
2675
|
var SUBSCRIPTIONS_ERROR__DELEGATION_NOT_STARTED = 407;
|
|
2676
|
+
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY = 408;
|
|
2483
2677
|
var SUBSCRIPTIONS_ERROR__PLAN_SUNSET = 500;
|
|
2484
2678
|
var SUBSCRIPTIONS_ERROR__PLAN_EXPIRED = 501;
|
|
2485
2679
|
var SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA = 502;
|
|
@@ -2569,6 +2763,7 @@ if (process.env["NODE_ENV"] !== "production") {
|
|
|
2569
2763
|
[SUBSCRIPTIONS_ERROR__PLAN_SUNSET]: `Plan is in sunset status`,
|
|
2570
2764
|
[SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH]: `Subscription plan terms do not match the current plan`,
|
|
2571
2765
|
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO]: `zero amount specified`,
|
|
2766
|
+
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY]: `start_ts of 0 (start on landing) requires a non-zero expiry`,
|
|
2572
2767
|
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY]: `start time specified is greater than expiry`,
|
|
2573
2768
|
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST]: `Past start time specified`,
|
|
2574
2769
|
[SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY]: `Delegation init_id does not match current SubscriptionAuthority`,
|
|
@@ -2577,6 +2772,8 @@ if (process.env["NODE_ENV"] !== "production") {
|
|
|
2577
2772
|
[SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED]: `Subscription is not cancelled`,
|
|
2578
2773
|
[SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH]: `Subscription does not belong to this plan`,
|
|
2579
2774
|
[SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS]: `Sunset requires a non-zero end timestamp`,
|
|
2775
|
+
[SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS]: `Too many transfer hook accounts provided`,
|
|
2776
|
+
[SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_VALIDATION_ACCOUNT_MISSING]: `Transfer hook validation account missing from provided accounts`,
|
|
2580
2777
|
[SUBSCRIPTIONS_ERROR__UNAUTHORIZED]: `Caller not authorized for this action`,
|
|
2581
2778
|
[SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION]: `Destination not in plan whitelist`
|
|
2582
2779
|
};
|
|
@@ -2588,7 +2785,7 @@ function getSubscriptionsErrorMessage(code) {
|
|
|
2588
2785
|
return "Error message not available in production bundles.";
|
|
2589
2786
|
}
|
|
2590
2787
|
function isSubscriptionsError(error, transactionMessage, code) {
|
|
2591
|
-
return (0,
|
|
2788
|
+
return (0, import_kit40.isProgramError)(error, transactionMessage, SUBSCRIPTIONS_PROGRAM_ADDRESS, code);
|
|
2592
2789
|
}
|
|
2593
2790
|
|
|
2594
2791
|
// src/constants.ts
|
|
@@ -2613,7 +2810,7 @@ var METADATA_URI_LEN = 128;
|
|
|
2613
2810
|
|
|
2614
2811
|
// src/accounts/decode.ts
|
|
2615
2812
|
function toEncodedAccount(raw, programAddress) {
|
|
2616
|
-
const base64Encoder = (0,
|
|
2813
|
+
const base64Encoder = (0, import_kit41.getBase64Encoder)();
|
|
2617
2814
|
const data = base64Encoder.encode(raw.account.data[0]);
|
|
2618
2815
|
return {
|
|
2619
2816
|
address: raw.pubkey,
|
|
@@ -2730,10 +2927,148 @@ async function fetchSubscriptionsForUser(rpc, user, programAddress) {
|
|
|
2730
2927
|
}
|
|
2731
2928
|
|
|
2732
2929
|
// src/plugin.ts
|
|
2733
|
-
var
|
|
2734
|
-
var
|
|
2930
|
+
var import_kit43 = require("@solana/kit");
|
|
2931
|
+
var import_program_client_core18 = require("@solana/program-client-core");
|
|
2735
2932
|
var import_token = require("@solana-program/token");
|
|
2736
2933
|
|
|
2934
|
+
// src/transfer-hook.ts
|
|
2935
|
+
var import_kit42 = require("@solana/kit");
|
|
2936
|
+
var import_token_2022 = require("@solana-program/token-2022");
|
|
2937
|
+
var DEFAULT_ADDRESS = "11111111111111111111111111111111";
|
|
2938
|
+
var EXTRA_ACCOUNT_METAS_SEED = "extra-account-metas";
|
|
2939
|
+
var TLV_HEADER_LEN = 12;
|
|
2940
|
+
var POD_SLICE_COUNT_LEN = 4;
|
|
2941
|
+
var EXTRA_ACCOUNT_META_LEN = 35;
|
|
2942
|
+
var PUBKEY_LEN = 32;
|
|
2943
|
+
var PDA_PROGRAM_INDEX_OFFSET = 1 << 7;
|
|
2944
|
+
var EXECUTE_DISCRIMINATOR = Uint8Array.from([105, 37, 101, 197, 75, 251, 102, 26]);
|
|
2945
|
+
var addressDecoder = (0, import_kit42.getAddressDecoder)();
|
|
2946
|
+
var addressEncoder = (0, import_kit42.getAddressEncoder)();
|
|
2947
|
+
function roleFor(isSigner, isWritable) {
|
|
2948
|
+
if (isSigner && isWritable) return import_kit42.AccountRole.WRITABLE_SIGNER;
|
|
2949
|
+
if (isSigner) return import_kit42.AccountRole.READONLY_SIGNER;
|
|
2950
|
+
if (isWritable) return import_kit42.AccountRole.WRITABLE;
|
|
2951
|
+
return import_kit42.AccountRole.READONLY;
|
|
2952
|
+
}
|
|
2953
|
+
async function fetchData(rpc, address) {
|
|
2954
|
+
const account = await (0, import_kit42.fetchEncodedAccount)(rpc, address);
|
|
2955
|
+
if (!account.exists) throw new Error("transfer hook: referenced account not found");
|
|
2956
|
+
return account.data;
|
|
2957
|
+
}
|
|
2958
|
+
function executeInstructionData(amount) {
|
|
2959
|
+
const data = new Uint8Array(EXECUTE_DISCRIMINATOR.length + 8);
|
|
2960
|
+
data.set(EXECUTE_DISCRIMINATOR, 0);
|
|
2961
|
+
new DataView(data.buffer).setBigUint64(EXECUTE_DISCRIMINATOR.length, BigInt(amount), true);
|
|
2962
|
+
return data;
|
|
2963
|
+
}
|
|
2964
|
+
function readMetas(data) {
|
|
2965
|
+
if (data.length < TLV_HEADER_LEN || !EXECUTE_DISCRIMINATOR.every((byte, i) => data[i] === byte)) {
|
|
2966
|
+
return [];
|
|
2967
|
+
}
|
|
2968
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
2969
|
+
const count = view.getUint32(TLV_HEADER_LEN, true);
|
|
2970
|
+
const metas = [];
|
|
2971
|
+
let offset = TLV_HEADER_LEN + POD_SLICE_COUNT_LEN;
|
|
2972
|
+
for (let n = 0; n < count && offset + EXTRA_ACCOUNT_META_LEN <= data.length; n++) {
|
|
2973
|
+
metas.push({
|
|
2974
|
+
addressConfig: data.subarray(offset + 1, offset + 33),
|
|
2975
|
+
discriminator: data[offset],
|
|
2976
|
+
isSigner: data[offset + 33] === 1,
|
|
2977
|
+
isWritable: data[offset + 34] === 1
|
|
2978
|
+
});
|
|
2979
|
+
offset += EXTRA_ACCOUNT_META_LEN;
|
|
2980
|
+
}
|
|
2981
|
+
return metas;
|
|
2982
|
+
}
|
|
2983
|
+
async function unpackSeeds(config, previous, instructionData, rpc) {
|
|
2984
|
+
const seeds = [];
|
|
2985
|
+
let i = 0;
|
|
2986
|
+
while (i < 32) {
|
|
2987
|
+
const discriminator = config[i];
|
|
2988
|
+
const rest = config.subarray(i + 1);
|
|
2989
|
+
if (discriminator === 0) break;
|
|
2990
|
+
if (discriminator === 1) {
|
|
2991
|
+
const length = rest[0];
|
|
2992
|
+
seeds.push(rest.subarray(1, 1 + length));
|
|
2993
|
+
i += 2 + length;
|
|
2994
|
+
} else if (discriminator === 2) {
|
|
2995
|
+
const [index, length] = [rest[0], rest[1]];
|
|
2996
|
+
seeds.push(instructionData.subarray(index, index + length));
|
|
2997
|
+
i += 3;
|
|
2998
|
+
} else if (discriminator === 3) {
|
|
2999
|
+
seeds.push(addressEncoder.encode(previous[rest[0]].address));
|
|
3000
|
+
i += 2;
|
|
3001
|
+
} else if (discriminator === 4) {
|
|
3002
|
+
const [accountIndex, dataIndex, length] = [rest[0], rest[1], rest[2]];
|
|
3003
|
+
const data = await fetchData(rpc, previous[accountIndex].address);
|
|
3004
|
+
seeds.push(data.subarray(dataIndex, dataIndex + length));
|
|
3005
|
+
i += 4;
|
|
3006
|
+
} else {
|
|
3007
|
+
throw new Error("transfer hook: invalid seed");
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
return seeds;
|
|
3011
|
+
}
|
|
3012
|
+
async function unpackPubkeyData(config, previous, instructionData, rpc) {
|
|
3013
|
+
const rest = config.subarray(1);
|
|
3014
|
+
if (config[0] === 1) {
|
|
3015
|
+
const offset = rest[0];
|
|
3016
|
+
return addressDecoder.decode(instructionData.subarray(offset, offset + PUBKEY_LEN));
|
|
3017
|
+
}
|
|
3018
|
+
if (config[0] === 2) {
|
|
3019
|
+
const [accountIndex, offset] = [rest[0], rest[1]];
|
|
3020
|
+
const data = await fetchData(rpc, previous[accountIndex].address);
|
|
3021
|
+
return addressDecoder.decode(data.subarray(offset, offset + PUBKEY_LEN));
|
|
3022
|
+
}
|
|
3023
|
+
throw new Error("transfer hook: invalid pubkey data");
|
|
3024
|
+
}
|
|
3025
|
+
async function resolveMeta(meta, previous, instructionData, hookProgram, rpc) {
|
|
3026
|
+
const role = roleFor(meta.isSigner, meta.isWritable);
|
|
3027
|
+
if (meta.discriminator === 0) {
|
|
3028
|
+
return { address: addressDecoder.decode(meta.addressConfig), role };
|
|
3029
|
+
}
|
|
3030
|
+
if (meta.discriminator === 2) {
|
|
3031
|
+
return { address: await unpackPubkeyData(meta.addressConfig, previous, instructionData, rpc), role };
|
|
3032
|
+
}
|
|
3033
|
+
const programId = meta.discriminator === 1 ? hookProgram : previous[meta.discriminator - PDA_PROGRAM_INDEX_OFFSET].address;
|
|
3034
|
+
const seeds = await unpackSeeds(meta.addressConfig, previous, instructionData, rpc);
|
|
3035
|
+
const [pda] = await (0, import_kit42.getProgramDerivedAddress)({ programAddress: programId, seeds });
|
|
3036
|
+
return { address: pda, role };
|
|
3037
|
+
}
|
|
3038
|
+
async function resolveTransferHookAccounts(rpc, args) {
|
|
3039
|
+
if (args.transferHookAccounts?.length) return args.transferHookAccounts;
|
|
3040
|
+
if (args.tokenProgram !== import_token_2022.TOKEN_2022_PROGRAM_ADDRESS) return [];
|
|
3041
|
+
const { data } = await (0, import_token_2022.fetchMint)(rpc, args.mint);
|
|
3042
|
+
const extensions = data.extensions.__option === "Some" ? data.extensions.value : [];
|
|
3043
|
+
const hook = extensions.find((extension) => extension.__kind === "TransferHook");
|
|
3044
|
+
if (!hook || hook.programId === DEFAULT_ADDRESS) return [];
|
|
3045
|
+
const hookProgram = hook.programId;
|
|
3046
|
+
const [validationPda] = await (0, import_kit42.getProgramDerivedAddress)({
|
|
3047
|
+
programAddress: hookProgram,
|
|
3048
|
+
seeds: [EXTRA_ACCOUNT_METAS_SEED, addressEncoder.encode(args.mint)]
|
|
3049
|
+
});
|
|
3050
|
+
const trailing = [
|
|
3051
|
+
{ address: hookProgram, role: import_kit42.AccountRole.READONLY },
|
|
3052
|
+
{ address: validationPda, role: import_kit42.AccountRole.READONLY }
|
|
3053
|
+
];
|
|
3054
|
+
const validationAccount = await (0, import_kit42.fetchEncodedAccount)(rpc, validationPda);
|
|
3055
|
+
if (!validationAccount.exists) return trailing;
|
|
3056
|
+
const instructionData = executeInstructionData(args.amount);
|
|
3057
|
+
const previous = [
|
|
3058
|
+
{ address: args.source, role: import_kit42.AccountRole.READONLY },
|
|
3059
|
+
{ address: args.mint, role: import_kit42.AccountRole.READONLY },
|
|
3060
|
+
{ address: args.destination, role: import_kit42.AccountRole.READONLY },
|
|
3061
|
+
{ address: args.authority, role: import_kit42.AccountRole.READONLY },
|
|
3062
|
+
{ address: validationPda, role: import_kit42.AccountRole.READONLY }
|
|
3063
|
+
];
|
|
3064
|
+
for (const meta of readMetas(validationAccount.data)) {
|
|
3065
|
+
const resolved = await resolveMeta(meta, previous, instructionData, hookProgram, rpc);
|
|
3066
|
+
previous.push(resolved);
|
|
3067
|
+
trailing.push(resolved);
|
|
3068
|
+
}
|
|
3069
|
+
return trailing;
|
|
3070
|
+
}
|
|
3071
|
+
|
|
2737
3072
|
// src/validators.ts
|
|
2738
3073
|
var textEncoder = new TextEncoder();
|
|
2739
3074
|
var ValidationError = class extends Error {
|
|
@@ -2745,6 +3080,10 @@ var ValidationError = class extends Error {
|
|
|
2745
3080
|
function assertPositive(value, name) {
|
|
2746
3081
|
if (BigInt(value) <= 0n) throw new ValidationError(`${name} must be greater than zero`);
|
|
2747
3082
|
}
|
|
3083
|
+
function assertSafeU64(value, name) {
|
|
3084
|
+
if (typeof value === "number" && !Number.isSafeInteger(value))
|
|
3085
|
+
throw new ValidationError(`${name} must be a bigint or a safe integer (numbers above 2^53-1 lose precision)`);
|
|
3086
|
+
}
|
|
2748
3087
|
function assertMetadataUri(metadataUri) {
|
|
2749
3088
|
if (textEncoder.encode(metadataUri).length > METADATA_URI_LEN)
|
|
2750
3089
|
throw new ValidationError(`metadataUri exceeds ${METADATA_URI_LEN} bytes`);
|
|
@@ -2781,7 +3120,7 @@ function appendPayer(instruction, payer) {
|
|
|
2781
3120
|
return withTrailing(instruction, [
|
|
2782
3121
|
{
|
|
2783
3122
|
address: payer.address,
|
|
2784
|
-
role:
|
|
3123
|
+
role: import_kit43.AccountRole.WRITABLE_SIGNER,
|
|
2785
3124
|
signer: payer
|
|
2786
3125
|
}
|
|
2787
3126
|
]);
|
|
@@ -2810,12 +3149,33 @@ async function getCloseSubscriptionAuthorityOverlayInstructionAsync(input) {
|
|
|
2810
3149
|
pdaConfig(input.programAddress)
|
|
2811
3150
|
);
|
|
2812
3151
|
if (input.receiver) {
|
|
2813
|
-
ix = withTrailing(ix, [{ address: input.receiver, role:
|
|
3152
|
+
ix = withTrailing(ix, [{ address: input.receiver, role: import_kit43.AccountRole.WRITABLE }]);
|
|
2814
3153
|
}
|
|
2815
3154
|
return ix;
|
|
2816
3155
|
}
|
|
3156
|
+
async function getRevokeSubscriptionAuthorityOverlayInstructionAsync(input) {
|
|
3157
|
+
const [userAta] = await (0, import_token.findAssociatedTokenPda)({
|
|
3158
|
+
mint: input.tokenMint,
|
|
3159
|
+
owner: input.user.address,
|
|
3160
|
+
tokenProgram: input.tokenProgram
|
|
3161
|
+
});
|
|
3162
|
+
return getRevokeSubscriptionAuthorityInstruction(
|
|
3163
|
+
{
|
|
3164
|
+
tokenMint: input.tokenMint,
|
|
3165
|
+
tokenProgram: input.tokenProgram,
|
|
3166
|
+
user: input.user,
|
|
3167
|
+
userAta
|
|
3168
|
+
},
|
|
3169
|
+
pdaConfig(input.programAddress)
|
|
3170
|
+
);
|
|
3171
|
+
}
|
|
2817
3172
|
async function getCreateFixedDelegationOverlayInstructionAsync(input) {
|
|
2818
3173
|
assertPositive(input.amount, "amount");
|
|
3174
|
+
if (input.expectedSubscriptionAuthorityInitId === void 0) {
|
|
3175
|
+
throw new Error(
|
|
3176
|
+
"getCreateFixedDelegationOverlayInstructionAsync requires expectedSubscriptionAuthorityInitId. Use the plugin client `subscriptions.instructions.createFixedDelegation(...)` to auto-fetch from the live authority."
|
|
3177
|
+
);
|
|
3178
|
+
}
|
|
2819
3179
|
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
2820
3180
|
{ tokenMint: input.tokenMint, user: input.delegator.address },
|
|
2821
3181
|
pdaConfig(input.programAddress)
|
|
@@ -2837,6 +3197,7 @@ async function getCreateFixedDelegationOverlayInstructionAsync(input) {
|
|
|
2837
3197
|
delegator: input.delegator,
|
|
2838
3198
|
fixedDelegation: {
|
|
2839
3199
|
amount: input.amount,
|
|
3200
|
+
expectedSubscriptionAuthorityInitId: input.expectedSubscriptionAuthorityInitId,
|
|
2840
3201
|
expiryTs: input.expiryTs,
|
|
2841
3202
|
nonce: input.nonce
|
|
2842
3203
|
},
|
|
@@ -2850,6 +3211,11 @@ async function getCreateFixedDelegationOverlayInstructionAsync(input) {
|
|
|
2850
3211
|
async function getCreateRecurringDelegationOverlayInstructionAsync(input) {
|
|
2851
3212
|
assertPositive(input.amountPerPeriod, "amountPerPeriod");
|
|
2852
3213
|
assertPositive(input.periodLengthS, "periodLengthS");
|
|
3214
|
+
if (input.expectedSubscriptionAuthorityInitId === void 0) {
|
|
3215
|
+
throw new Error(
|
|
3216
|
+
"getCreateRecurringDelegationOverlayInstructionAsync requires expectedSubscriptionAuthorityInitId. Use the plugin client `subscriptions.instructions.createRecurringDelegation(...)` to auto-fetch from the live authority."
|
|
3217
|
+
);
|
|
3218
|
+
}
|
|
2853
3219
|
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
2854
3220
|
{ tokenMint: input.tokenMint, user: input.delegator.address },
|
|
2855
3221
|
pdaConfig(input.programAddress)
|
|
@@ -2871,6 +3237,7 @@ async function getCreateRecurringDelegationOverlayInstructionAsync(input) {
|
|
|
2871
3237
|
delegator: input.delegator,
|
|
2872
3238
|
recurringDelegation: {
|
|
2873
3239
|
amountPerPeriod: input.amountPerPeriod,
|
|
3240
|
+
expectedSubscriptionAuthorityInitId: input.expectedSubscriptionAuthorityInitId,
|
|
2874
3241
|
expiryTs: input.expiryTs,
|
|
2875
3242
|
nonce: input.nonce,
|
|
2876
3243
|
periodLengthS: input.periodLengthS,
|
|
@@ -2892,14 +3259,14 @@ function getRevokeDelegationOverlayInstruction(input) {
|
|
|
2892
3259
|
pdaConfig(input.programAddress)
|
|
2893
3260
|
);
|
|
2894
3261
|
if (input.receiver) {
|
|
2895
|
-
ix = withTrailing(ix, [{ address: input.receiver, role:
|
|
3262
|
+
ix = withTrailing(ix, [{ address: input.receiver, role: import_kit43.AccountRole.WRITABLE }]);
|
|
2896
3263
|
}
|
|
2897
3264
|
return ix;
|
|
2898
3265
|
}
|
|
2899
3266
|
function getRevokeSubscriptionOverlayInstruction(input) {
|
|
2900
|
-
const trailing = [{ address: input.planPda, role:
|
|
3267
|
+
const trailing = [{ address: input.planPda, role: import_kit43.AccountRole.READONLY }];
|
|
2901
3268
|
if (input.receiver) {
|
|
2902
|
-
trailing.push({ address: input.receiver, role:
|
|
3269
|
+
trailing.push({ address: input.receiver, role: import_kit43.AccountRole.WRITABLE });
|
|
2903
3270
|
}
|
|
2904
3271
|
return withTrailing(
|
|
2905
3272
|
getRevokeDelegationInstruction(
|
|
@@ -2918,21 +3285,25 @@ async function getTransferDelegationOverlayInstructionAsync(input, getInstructio
|
|
|
2918
3285
|
{ tokenMint: input.tokenMint, user: input.delegator },
|
|
2919
3286
|
pdaConfig(input.programAddress)
|
|
2920
3287
|
);
|
|
2921
|
-
return
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
3288
|
+
return withTrailing(
|
|
3289
|
+
getInstruction(
|
|
3290
|
+
{
|
|
3291
|
+
delegatee: input.delegatee,
|
|
3292
|
+
delegationPda: input.delegationPda,
|
|
3293
|
+
delegatorAta: input.delegatorAta,
|
|
3294
|
+
receiverAta: input.receiverAta,
|
|
3295
|
+
subscriptionAuthority,
|
|
3296
|
+
tokenMint: input.tokenMint,
|
|
3297
|
+
tokenProgram: input.tokenProgram,
|
|
3298
|
+
transferData: {
|
|
3299
|
+
amount: input.amount,
|
|
3300
|
+
delegator: input.delegator,
|
|
3301
|
+
mint: input.tokenMint
|
|
3302
|
+
}
|
|
3303
|
+
},
|
|
3304
|
+
pdaConfig(input.programAddress)
|
|
3305
|
+
),
|
|
3306
|
+
input.transferHookAccounts ?? []
|
|
2936
3307
|
);
|
|
2937
3308
|
}
|
|
2938
3309
|
function getTransferFixedOverlayInstructionAsync(input) {
|
|
@@ -2952,27 +3323,32 @@ async function getTransferSubscriptionOverlayInstructionAsync(input) {
|
|
|
2952
3323
|
owner: input.delegator,
|
|
2953
3324
|
tokenProgram: input.tokenProgram
|
|
2954
3325
|
});
|
|
2955
|
-
return
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
3326
|
+
return withTrailing(
|
|
3327
|
+
getTransferSubscriptionInstruction(
|
|
3328
|
+
{
|
|
3329
|
+
caller: input.caller,
|
|
3330
|
+
delegatorAta,
|
|
3331
|
+
planPda: input.planPda,
|
|
3332
|
+
receiverAta: input.receiverAta,
|
|
3333
|
+
subscriptionAuthority,
|
|
3334
|
+
subscriptionPda: input.subscriptionPda,
|
|
3335
|
+
tokenMint: input.tokenMint,
|
|
3336
|
+
tokenProgram: input.tokenProgram,
|
|
3337
|
+
transferData: {
|
|
3338
|
+
amount: input.amount,
|
|
3339
|
+
delegator: input.delegator,
|
|
3340
|
+
mint: input.tokenMint
|
|
3341
|
+
}
|
|
3342
|
+
},
|
|
3343
|
+
pdaConfig(input.programAddress)
|
|
3344
|
+
),
|
|
3345
|
+
input.transferHookAccounts ?? []
|
|
2971
3346
|
);
|
|
2972
3347
|
}
|
|
2973
3348
|
async function getCreatePlanOverlayInstructionAsync(input) {
|
|
2974
3349
|
assertPositive(input.amount, "amount");
|
|
2975
3350
|
assertPositive(input.periodHours, "periodHours");
|
|
3351
|
+
assertSafeU64(input.planId, "planId");
|
|
2976
3352
|
assertMetadataUri(input.metadataUri);
|
|
2977
3353
|
const destinations = padPlanDestinations(input.destinations);
|
|
2978
3354
|
const pullers = padPlanPullers(input.pullers);
|
|
@@ -3005,7 +3381,7 @@ async function getCreatePlanOverlayInstructionAsync(input) {
|
|
|
3005
3381
|
}
|
|
3006
3382
|
function getUpdatePlanOverlayInstruction(input) {
|
|
3007
3383
|
assertMetadataUri(input.metadataUri);
|
|
3008
|
-
const pullers = padPlanPullers(input.pullers
|
|
3384
|
+
const pullers = padPlanPullers(input.pullers);
|
|
3009
3385
|
return getUpdatePlanInstruction(
|
|
3010
3386
|
{
|
|
3011
3387
|
owner: input.owner,
|
|
@@ -3024,11 +3400,12 @@ function getDeletePlanOverlayInstruction(input) {
|
|
|
3024
3400
|
return getDeletePlanInstruction({ owner: input.owner, planPda: input.planPda }, pdaConfig(input.programAddress));
|
|
3025
3401
|
}
|
|
3026
3402
|
async function getSubscribeOverlayInstructionAsync(input) {
|
|
3027
|
-
if (input.expectedAmount === void 0 || input.expectedPeriodHours === void 0 || input.expectedCreatedAt === void 0) {
|
|
3403
|
+
if (input.expectedAmount === void 0 || input.expectedPeriodHours === void 0 || input.expectedCreatedAt === void 0 || input.expectedSubscriptionAuthorityInitId === void 0) {
|
|
3028
3404
|
throw new Error(
|
|
3029
|
-
"getSubscribeOverlayInstructionAsync requires expectedAmount, expectedPeriodHours, and
|
|
3405
|
+
"getSubscribeOverlayInstructionAsync requires expectedAmount, expectedPeriodHours, expectedCreatedAt, and expectedSubscriptionAuthorityInitId. Use the plugin client `subscriptions.instructions.subscribe(...)` to auto-fetch from the live plan and authority."
|
|
3030
3406
|
);
|
|
3031
3407
|
}
|
|
3408
|
+
assertSafeU64(input.planId, "planId");
|
|
3032
3409
|
const [planPda, planBump] = await findPlanPda(
|
|
3033
3410
|
{ owner: input.merchant, planId: input.planId },
|
|
3034
3411
|
pdaConfig(input.programAddress)
|
|
@@ -3047,6 +3424,7 @@ async function getSubscribeOverlayInstructionAsync(input) {
|
|
|
3047
3424
|
expectedCreatedAt: input.expectedCreatedAt,
|
|
3048
3425
|
expectedMint: input.tokenMint,
|
|
3049
3426
|
expectedPeriodHours: input.expectedPeriodHours,
|
|
3427
|
+
expectedSubscriptionAuthorityInitId: input.expectedSubscriptionAuthorityInitId,
|
|
3050
3428
|
planBump,
|
|
3051
3429
|
planId: input.planId
|
|
3052
3430
|
},
|
|
@@ -3080,7 +3458,7 @@ function getResumeSubscriptionOverlayInstructionAsync(input) {
|
|
|
3080
3458
|
}
|
|
3081
3459
|
function subscriptionsProgram2() {
|
|
3082
3460
|
return (client) => {
|
|
3083
|
-
return (0,
|
|
3461
|
+
return (0, import_kit43.pipe)(client, subscriptionsProgram(), (c) => {
|
|
3084
3462
|
const queries = {
|
|
3085
3463
|
activeDelegationSummary: async (wallet) => {
|
|
3086
3464
|
const delegations = await fetchDelegationsByDelegator(c.rpc, wallet);
|
|
@@ -3103,52 +3481,101 @@ function subscriptionsProgram2() {
|
|
|
3103
3481
|
},
|
|
3104
3482
|
plansForOwner: (owner) => fetchPlansForOwner(c.rpc, owner)
|
|
3105
3483
|
};
|
|
3484
|
+
const resolveExpectedSubscriptionAuthorityInitId = async (tokenMint, user, programAddress, expectedSubscriptionAuthorityInitId) => {
|
|
3485
|
+
if (expectedSubscriptionAuthorityInitId !== void 0) {
|
|
3486
|
+
return expectedSubscriptionAuthorityInitId;
|
|
3487
|
+
}
|
|
3488
|
+
const [subscriptionAuthorityPda] = await findSubscriptionAuthorityPda(
|
|
3489
|
+
{ tokenMint, user },
|
|
3490
|
+
pdaConfig(programAddress)
|
|
3491
|
+
);
|
|
3492
|
+
const subscriptionAuthority = await fetchMaybeSubscriptionAuthority(c.rpc, subscriptionAuthorityPda);
|
|
3493
|
+
if (!subscriptionAuthority.exists) {
|
|
3494
|
+
throw new Error("SubscriptionAuthority is not initialized for this delegator and token mint.");
|
|
3495
|
+
}
|
|
3496
|
+
return subscriptionAuthority.data.initId;
|
|
3497
|
+
};
|
|
3498
|
+
const resolveDelegationHookAccounts = async (input) => {
|
|
3499
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
3500
|
+
{ tokenMint: input.tokenMint, user: input.delegator },
|
|
3501
|
+
pdaConfig(input.programAddress)
|
|
3502
|
+
);
|
|
3503
|
+
return await resolveTransferHookAccounts(c.rpc, {
|
|
3504
|
+
amount: input.amount,
|
|
3505
|
+
authority: subscriptionAuthority,
|
|
3506
|
+
destination: input.receiverAta,
|
|
3507
|
+
mint: input.tokenMint,
|
|
3508
|
+
source: input.delegatorAta,
|
|
3509
|
+
tokenProgram: input.tokenProgram,
|
|
3510
|
+
transferHookAccounts: input.transferHookAccounts
|
|
3511
|
+
});
|
|
3512
|
+
};
|
|
3106
3513
|
const instructions = {
|
|
3107
|
-
cancelSubscription: (input) => (0,
|
|
3514
|
+
cancelSubscription: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3108
3515
|
client,
|
|
3109
3516
|
getCancelSubscriptionOverlayInstructionAsync({
|
|
3110
3517
|
...input,
|
|
3111
3518
|
subscriber: input.subscriber ?? client.identity
|
|
3112
3519
|
})
|
|
3113
3520
|
),
|
|
3114
|
-
closeSubscriptionAuthority: (input) => (0,
|
|
3521
|
+
closeSubscriptionAuthority: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3115
3522
|
client,
|
|
3116
3523
|
getCloseSubscriptionAuthorityOverlayInstructionAsync({
|
|
3117
3524
|
...input,
|
|
3118
3525
|
user: input.user ?? client.identity
|
|
3119
3526
|
})
|
|
3120
3527
|
),
|
|
3121
|
-
createFixedDelegation: (input) => (0,
|
|
3528
|
+
createFixedDelegation: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3122
3529
|
client,
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3530
|
+
(async () => {
|
|
3531
|
+
const delegator = input.delegator ?? client.identity;
|
|
3532
|
+
const expectedSubscriptionAuthorityInitId = await resolveExpectedSubscriptionAuthorityInitId(
|
|
3533
|
+
input.tokenMint,
|
|
3534
|
+
delegator.address,
|
|
3535
|
+
input.programAddress,
|
|
3536
|
+
input.expectedSubscriptionAuthorityInitId
|
|
3537
|
+
);
|
|
3538
|
+
return await getCreateFixedDelegationOverlayInstructionAsync({
|
|
3539
|
+
...input,
|
|
3540
|
+
delegator,
|
|
3541
|
+
expectedSubscriptionAuthorityInitId,
|
|
3542
|
+
payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer)
|
|
3543
|
+
});
|
|
3544
|
+
})()
|
|
3128
3545
|
),
|
|
3129
|
-
createPlan: (input) => (0,
|
|
3546
|
+
createPlan: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3130
3547
|
client,
|
|
3131
3548
|
getCreatePlanOverlayInstructionAsync({
|
|
3132
3549
|
...input,
|
|
3133
3550
|
owner: input.owner ?? client.identity
|
|
3134
3551
|
})
|
|
3135
3552
|
),
|
|
3136
|
-
createRecurringDelegation: (input) => (0,
|
|
3553
|
+
createRecurringDelegation: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3137
3554
|
client,
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3555
|
+
(async () => {
|
|
3556
|
+
const delegator = input.delegator ?? client.identity;
|
|
3557
|
+
const expectedSubscriptionAuthorityInitId = await resolveExpectedSubscriptionAuthorityInitId(
|
|
3558
|
+
input.tokenMint,
|
|
3559
|
+
delegator.address,
|
|
3560
|
+
input.programAddress,
|
|
3561
|
+
input.expectedSubscriptionAuthorityInitId
|
|
3562
|
+
);
|
|
3563
|
+
return await getCreateRecurringDelegationOverlayInstructionAsync({
|
|
3564
|
+
...input,
|
|
3565
|
+
delegator,
|
|
3566
|
+
expectedSubscriptionAuthorityInitId,
|
|
3567
|
+
payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer)
|
|
3568
|
+
});
|
|
3569
|
+
})()
|
|
3143
3570
|
),
|
|
3144
|
-
deletePlan: (input) => (0,
|
|
3571
|
+
deletePlan: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3145
3572
|
client,
|
|
3146
3573
|
getDeletePlanOverlayInstruction({
|
|
3147
3574
|
...input,
|
|
3148
3575
|
owner: input.owner ?? client.identity
|
|
3149
3576
|
})
|
|
3150
3577
|
),
|
|
3151
|
-
initSubscriptionAuthority: (input) => (0,
|
|
3578
|
+
initSubscriptionAuthority: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3152
3579
|
client,
|
|
3153
3580
|
getInitSubscriptionAuthorityOverlayInstructionAsync({
|
|
3154
3581
|
...input,
|
|
@@ -3156,33 +3583,46 @@ function subscriptionsProgram2() {
|
|
|
3156
3583
|
payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer)
|
|
3157
3584
|
})
|
|
3158
3585
|
),
|
|
3159
|
-
resumeSubscription: (input) => (0,
|
|
3586
|
+
resumeSubscription: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3160
3587
|
client,
|
|
3161
3588
|
getResumeSubscriptionOverlayInstructionAsync({
|
|
3162
3589
|
...input,
|
|
3163
3590
|
subscriber: input.subscriber ?? client.identity
|
|
3164
3591
|
})
|
|
3165
3592
|
),
|
|
3166
|
-
revokeDelegation: (input) => (0,
|
|
3593
|
+
revokeDelegation: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3167
3594
|
client,
|
|
3168
3595
|
getRevokeDelegationOverlayInstruction({
|
|
3169
3596
|
...input,
|
|
3170
3597
|
authority: input.authority ?? client.identity
|
|
3171
3598
|
})
|
|
3172
3599
|
),
|
|
3173
|
-
revokeSubscription: (input) => (0,
|
|
3600
|
+
revokeSubscription: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3174
3601
|
client,
|
|
3175
3602
|
getRevokeSubscriptionOverlayInstruction({
|
|
3176
3603
|
...input,
|
|
3177
3604
|
authority: input.authority ?? client.identity
|
|
3178
3605
|
})
|
|
3179
3606
|
),
|
|
3180
|
-
|
|
3607
|
+
revokeSubscriptionAuthority: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3608
|
+
client,
|
|
3609
|
+
getRevokeSubscriptionAuthorityOverlayInstructionAsync({
|
|
3610
|
+
...input,
|
|
3611
|
+
user: input.user ?? client.identity
|
|
3612
|
+
})
|
|
3613
|
+
),
|
|
3614
|
+
subscribe: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3181
3615
|
client,
|
|
3182
3616
|
(async () => {
|
|
3183
|
-
|
|
3617
|
+
const subscriber = input.subscriber ?? client.identity;
|
|
3618
|
+
assertSafeU64(input.planId, "planId");
|
|
3619
|
+
let {
|
|
3620
|
+
expectedAmount,
|
|
3621
|
+
expectedCreatedAt,
|
|
3622
|
+
expectedPeriodHours,
|
|
3623
|
+
expectedSubscriptionAuthorityInitId
|
|
3624
|
+
} = input;
|
|
3184
3625
|
if (expectedAmount === void 0 || expectedPeriodHours === void 0 || expectedCreatedAt === void 0) {
|
|
3185
|
-
const subscriber = input.subscriber ?? client.identity;
|
|
3186
3626
|
const [planPda] = await findPlanPda(
|
|
3187
3627
|
{ owner: input.merchant, planId: input.planId },
|
|
3188
3628
|
pdaConfig(input.programAddress)
|
|
@@ -3191,47 +3631,79 @@ function subscriptionsProgram2() {
|
|
|
3191
3631
|
expectedAmount = expectedAmount ?? plan.data.data.terms.amount;
|
|
3192
3632
|
expectedPeriodHours = expectedPeriodHours ?? plan.data.data.terms.periodHours;
|
|
3193
3633
|
expectedCreatedAt = expectedCreatedAt ?? plan.data.data.terms.createdAt;
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3634
|
+
}
|
|
3635
|
+
if (expectedSubscriptionAuthorityInitId === void 0) {
|
|
3636
|
+
const [subscriptionAuthorityPda] = await findSubscriptionAuthorityPda(
|
|
3637
|
+
{ tokenMint: input.tokenMint, user: subscriber.address },
|
|
3638
|
+
pdaConfig(input.programAddress)
|
|
3639
|
+
);
|
|
3640
|
+
const subscriptionAuthority = await fetchMaybeSubscriptionAuthority(
|
|
3641
|
+
c.rpc,
|
|
3642
|
+
subscriptionAuthorityPda
|
|
3643
|
+
);
|
|
3644
|
+
if (!subscriptionAuthority.exists) {
|
|
3645
|
+
throw new Error(
|
|
3646
|
+
"SubscriptionAuthority is not initialized for this subscriber and token mint."
|
|
3647
|
+
);
|
|
3648
|
+
}
|
|
3649
|
+
expectedSubscriptionAuthorityInitId = subscriptionAuthority.data.initId;
|
|
3202
3650
|
}
|
|
3203
3651
|
return await getSubscribeOverlayInstructionAsync({
|
|
3204
3652
|
...input,
|
|
3205
3653
|
expectedAmount,
|
|
3206
3654
|
expectedCreatedAt,
|
|
3207
3655
|
expectedPeriodHours,
|
|
3656
|
+
expectedSubscriptionAuthorityInitId,
|
|
3208
3657
|
payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer),
|
|
3209
|
-
subscriber
|
|
3658
|
+
subscriber
|
|
3210
3659
|
});
|
|
3211
3660
|
})()
|
|
3212
3661
|
),
|
|
3213
|
-
transferFixed: (input) => (0,
|
|
3662
|
+
transferFixed: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3214
3663
|
client,
|
|
3215
|
-
getTransferFixedOverlayInstructionAsync({
|
|
3664
|
+
(async () => await getTransferFixedOverlayInstructionAsync({
|
|
3216
3665
|
...input,
|
|
3217
|
-
delegatee: input.delegatee ?? client.identity
|
|
3218
|
-
|
|
3666
|
+
delegatee: input.delegatee ?? client.identity,
|
|
3667
|
+
transferHookAccounts: await resolveDelegationHookAccounts(input)
|
|
3668
|
+
}))()
|
|
3219
3669
|
),
|
|
3220
|
-
transferRecurring: (input) => (0,
|
|
3670
|
+
transferRecurring: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3221
3671
|
client,
|
|
3222
|
-
getTransferRecurringOverlayInstructionAsync({
|
|
3672
|
+
(async () => await getTransferRecurringOverlayInstructionAsync({
|
|
3223
3673
|
...input,
|
|
3224
|
-
delegatee: input.delegatee ?? client.identity
|
|
3225
|
-
|
|
3674
|
+
delegatee: input.delegatee ?? client.identity,
|
|
3675
|
+
transferHookAccounts: await resolveDelegationHookAccounts(input)
|
|
3676
|
+
}))()
|
|
3226
3677
|
),
|
|
3227
|
-
transferSubscription: (input) => (0,
|
|
3678
|
+
transferSubscription: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3228
3679
|
client,
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3680
|
+
(async () => {
|
|
3681
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
3682
|
+
{ tokenMint: input.tokenMint, user: input.delegator },
|
|
3683
|
+
pdaConfig(input.programAddress)
|
|
3684
|
+
);
|
|
3685
|
+
const [delegatorAta] = await (0, import_token.findAssociatedTokenPda)({
|
|
3686
|
+
mint: input.tokenMint,
|
|
3687
|
+
owner: input.delegator,
|
|
3688
|
+
tokenProgram: input.tokenProgram
|
|
3689
|
+
});
|
|
3690
|
+
const transferHookAccounts = await resolveTransferHookAccounts(c.rpc, {
|
|
3691
|
+
amount: input.amount,
|
|
3692
|
+
authority: subscriptionAuthority,
|
|
3693
|
+
destination: input.receiverAta,
|
|
3694
|
+
mint: input.tokenMint,
|
|
3695
|
+
source: delegatorAta,
|
|
3696
|
+
tokenProgram: input.tokenProgram,
|
|
3697
|
+
transferHookAccounts: input.transferHookAccounts
|
|
3698
|
+
});
|
|
3699
|
+
return await getTransferSubscriptionOverlayInstructionAsync({
|
|
3700
|
+
...input,
|
|
3701
|
+
caller: input.caller ?? client.identity,
|
|
3702
|
+
transferHookAccounts
|
|
3703
|
+
});
|
|
3704
|
+
})()
|
|
3233
3705
|
),
|
|
3234
|
-
updatePlan: (input) => (0,
|
|
3706
|
+
updatePlan: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3235
3707
|
client,
|
|
3236
3708
|
getUpdatePlanOverlayInstruction({
|
|
3237
3709
|
...input,
|
|
@@ -3275,7 +3747,9 @@ function subscriptionsProgram2() {
|
|
|
3275
3747
|
PROGRAM_ID,
|
|
3276
3748
|
PlanStatus,
|
|
3277
3749
|
RESUME_SUBSCRIPTION_DISCRIMINATOR,
|
|
3750
|
+
REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR,
|
|
3278
3751
|
REVOKE_DELEGATION_DISCRIMINATOR,
|
|
3752
|
+
REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR,
|
|
3279
3753
|
SUBSCRIBE_DISCRIMINATOR,
|
|
3280
3754
|
SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE,
|
|
3281
3755
|
SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED,
|
|
@@ -3339,6 +3813,7 @@ function subscriptionsProgram2() {
|
|
|
3339
3813
|
SUBSCRIPTIONS_ERROR__PLAN_SUNSET,
|
|
3340
3814
|
SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH,
|
|
3341
3815
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO,
|
|
3816
|
+
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY,
|
|
3342
3817
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY,
|
|
3343
3818
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST,
|
|
3344
3819
|
SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY,
|
|
@@ -3347,6 +3822,8 @@ function subscriptionsProgram2() {
|
|
|
3347
3822
|
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED,
|
|
3348
3823
|
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH,
|
|
3349
3824
|
SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS,
|
|
3825
|
+
SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS,
|
|
3826
|
+
SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_VALIDATION_ACCOUNT_MISSING,
|
|
3350
3827
|
SUBSCRIPTIONS_ERROR__UNAUTHORIZED,
|
|
3351
3828
|
SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION,
|
|
3352
3829
|
SUBSCRIPTIONS_PROGRAM_ADDRESS,
|
|
@@ -3499,12 +3976,23 @@ function subscriptionsProgram2() {
|
|
|
3499
3976
|
getResumeSubscriptionInstructionDataDecoder,
|
|
3500
3977
|
getResumeSubscriptionInstructionDataEncoder,
|
|
3501
3978
|
getResumeSubscriptionOverlayInstructionAsync,
|
|
3979
|
+
getRevokeAbandonedDelegationDiscriminatorBytes,
|
|
3980
|
+
getRevokeAbandonedDelegationInstruction,
|
|
3981
|
+
getRevokeAbandonedDelegationInstructionDataCodec,
|
|
3982
|
+
getRevokeAbandonedDelegationInstructionDataDecoder,
|
|
3983
|
+
getRevokeAbandonedDelegationInstructionDataEncoder,
|
|
3502
3984
|
getRevokeDelegationDiscriminatorBytes,
|
|
3503
3985
|
getRevokeDelegationInstruction,
|
|
3504
3986
|
getRevokeDelegationInstructionDataCodec,
|
|
3505
3987
|
getRevokeDelegationInstructionDataDecoder,
|
|
3506
3988
|
getRevokeDelegationInstructionDataEncoder,
|
|
3507
3989
|
getRevokeDelegationOverlayInstruction,
|
|
3990
|
+
getRevokeSubscriptionAuthorityDiscriminatorBytes,
|
|
3991
|
+
getRevokeSubscriptionAuthorityInstruction,
|
|
3992
|
+
getRevokeSubscriptionAuthorityInstructionDataCodec,
|
|
3993
|
+
getRevokeSubscriptionAuthorityInstructionDataDecoder,
|
|
3994
|
+
getRevokeSubscriptionAuthorityInstructionDataEncoder,
|
|
3995
|
+
getRevokeSubscriptionAuthorityOverlayInstructionAsync,
|
|
3508
3996
|
getRevokeSubscriptionOverlayInstruction,
|
|
3509
3997
|
getSubscribeDataCodec,
|
|
3510
3998
|
getSubscribeDataDecoder,
|
|
@@ -3563,13 +4051,16 @@ function subscriptionsProgram2() {
|
|
|
3563
4051
|
parseDeletePlanInstruction,
|
|
3564
4052
|
parseInitSubscriptionAuthorityInstruction,
|
|
3565
4053
|
parseResumeSubscriptionInstruction,
|
|
4054
|
+
parseRevokeAbandonedDelegationInstruction,
|
|
3566
4055
|
parseRevokeDelegationInstruction,
|
|
4056
|
+
parseRevokeSubscriptionAuthorityInstruction,
|
|
3567
4057
|
parseSubscribeInstruction,
|
|
3568
4058
|
parseSubscriptionsInstruction,
|
|
3569
4059
|
parseTransferFixedInstruction,
|
|
3570
4060
|
parseTransferRecurringInstruction,
|
|
3571
4061
|
parseTransferSubscriptionInstruction,
|
|
3572
4062
|
parseUpdatePlanInstruction,
|
|
4063
|
+
resolveTransferHookAccounts,
|
|
3573
4064
|
subscriptionsProgram,
|
|
3574
4065
|
toEncodedAccount
|
|
3575
4066
|
});
|