@solana/subscriptions 0.3.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 +602 -189
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +165 -6
- package/dist/index.d.ts +165 -6
- package/dist/index.js +585 -167
- 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");
|
|
@@ -1001,11 +1020,11 @@ async function fetchMaybeSubscriptionDelegationFromSeeds(rpc, seeds, config = {}
|
|
|
1001
1020
|
}
|
|
1002
1021
|
|
|
1003
1022
|
// src/generated/errors/subscriptions.ts
|
|
1004
|
-
var
|
|
1023
|
+
var import_kit40 = require("@solana/kit");
|
|
1005
1024
|
|
|
1006
1025
|
// src/generated/programs/subscriptions.ts
|
|
1007
|
-
var
|
|
1008
|
-
var
|
|
1026
|
+
var import_kit39 = require("@solana/kit");
|
|
1027
|
+
var import_program_client_core17 = require("@solana/program-client-core");
|
|
1009
1028
|
|
|
1010
1029
|
// src/generated/instructions/cancelSubscription.ts
|
|
1011
1030
|
var import_kit23 = require("@solana/kit");
|
|
@@ -1693,24 +1712,89 @@ function parseResumeSubscriptionInstruction(instruction) {
|
|
|
1693
1712
|
};
|
|
1694
1713
|
}
|
|
1695
1714
|
|
|
1696
|
-
// src/generated/instructions/
|
|
1715
|
+
// src/generated/instructions/revokeAbandonedDelegation.ts
|
|
1697
1716
|
var import_kit31 = require("@solana/kit");
|
|
1698
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");
|
|
1699
1783
|
var REVOKE_DELEGATION_DISCRIMINATOR = 3;
|
|
1700
1784
|
function getRevokeDelegationDiscriminatorBytes() {
|
|
1701
|
-
return (0,
|
|
1785
|
+
return (0, import_kit32.getU8Encoder)().encode(REVOKE_DELEGATION_DISCRIMINATOR);
|
|
1702
1786
|
}
|
|
1703
1787
|
function getRevokeDelegationInstructionDataEncoder() {
|
|
1704
|
-
return (0,
|
|
1788
|
+
return (0, import_kit32.transformEncoder)((0, import_kit32.getStructEncoder)([["discriminator", (0, import_kit32.getU8Encoder)()]]), (value) => ({
|
|
1705
1789
|
...value,
|
|
1706
1790
|
discriminator: REVOKE_DELEGATION_DISCRIMINATOR
|
|
1707
1791
|
}));
|
|
1708
1792
|
}
|
|
1709
1793
|
function getRevokeDelegationInstructionDataDecoder() {
|
|
1710
|
-
return (0,
|
|
1794
|
+
return (0, import_kit32.getStructDecoder)([["discriminator", (0, import_kit32.getU8Decoder)()]]);
|
|
1711
1795
|
}
|
|
1712
1796
|
function getRevokeDelegationInstructionDataCodec() {
|
|
1713
|
-
return (0,
|
|
1797
|
+
return (0, import_kit32.combineCodec)(getRevokeDelegationInstructionDataEncoder(), getRevokeDelegationInstructionDataDecoder());
|
|
1714
1798
|
}
|
|
1715
1799
|
function getRevokeDelegationInstruction(input, config) {
|
|
1716
1800
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -1719,7 +1803,7 @@ function getRevokeDelegationInstruction(input, config) {
|
|
|
1719
1803
|
delegationAccount: { value: input.delegationAccount ?? null, isWritable: true }
|
|
1720
1804
|
};
|
|
1721
1805
|
const accounts = originalAccounts;
|
|
1722
|
-
const getAccountMeta = (0,
|
|
1806
|
+
const getAccountMeta = (0, import_program_client_core10.getAccountMetaFactory)(programAddress, "programId");
|
|
1723
1807
|
return Object.freeze({
|
|
1724
1808
|
accounts: [
|
|
1725
1809
|
getAccountMeta("authority", accounts.authority),
|
|
@@ -1731,7 +1815,7 @@ function getRevokeDelegationInstruction(input, config) {
|
|
|
1731
1815
|
}
|
|
1732
1816
|
function parseRevokeDelegationInstruction(instruction) {
|
|
1733
1817
|
if (instruction.accounts.length < 2) {
|
|
1734
|
-
throw new
|
|
1818
|
+
throw new import_kit32.SolanaError(import_kit32.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1735
1819
|
actualAccountMetas: instruction.accounts.length,
|
|
1736
1820
|
expectedAccountMetas: 2
|
|
1737
1821
|
});
|
|
@@ -1749,30 +1833,98 @@ function parseRevokeDelegationInstruction(instruction) {
|
|
|
1749
1833
|
};
|
|
1750
1834
|
}
|
|
1751
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
|
+
|
|
1752
1904
|
// src/generated/instructions/subscribe.ts
|
|
1753
|
-
var
|
|
1754
|
-
var
|
|
1905
|
+
var import_kit34 = require("@solana/kit");
|
|
1906
|
+
var import_program_client_core12 = require("@solana/program-client-core");
|
|
1755
1907
|
var SUBSCRIBE_DISCRIMINATOR = 11;
|
|
1756
1908
|
function getSubscribeDiscriminatorBytes() {
|
|
1757
|
-
return (0,
|
|
1909
|
+
return (0, import_kit34.getU8Encoder)().encode(SUBSCRIBE_DISCRIMINATOR);
|
|
1758
1910
|
}
|
|
1759
1911
|
function getSubscribeInstructionDataEncoder() {
|
|
1760
|
-
return (0,
|
|
1761
|
-
(0,
|
|
1762
|
-
["discriminator", (0,
|
|
1912
|
+
return (0, import_kit34.transformEncoder)(
|
|
1913
|
+
(0, import_kit34.getStructEncoder)([
|
|
1914
|
+
["discriminator", (0, import_kit34.getU8Encoder)()],
|
|
1763
1915
|
["subscribeData", getSubscribeDataEncoder()]
|
|
1764
1916
|
]),
|
|
1765
1917
|
(value) => ({ ...value, discriminator: SUBSCRIBE_DISCRIMINATOR })
|
|
1766
1918
|
);
|
|
1767
1919
|
}
|
|
1768
1920
|
function getSubscribeInstructionDataDecoder() {
|
|
1769
|
-
return (0,
|
|
1770
|
-
["discriminator", (0,
|
|
1921
|
+
return (0, import_kit34.getStructDecoder)([
|
|
1922
|
+
["discriminator", (0, import_kit34.getU8Decoder)()],
|
|
1771
1923
|
["subscribeData", getSubscribeDataDecoder()]
|
|
1772
1924
|
]);
|
|
1773
1925
|
}
|
|
1774
1926
|
function getSubscribeInstructionDataCodec() {
|
|
1775
|
-
return (0,
|
|
1927
|
+
return (0, import_kit34.combineCodec)(getSubscribeInstructionDataEncoder(), getSubscribeInstructionDataDecoder());
|
|
1776
1928
|
}
|
|
1777
1929
|
async function getSubscribeInstructionAsync(input, config) {
|
|
1778
1930
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -1790,8 +1942,8 @@ async function getSubscribeInstructionAsync(input, config) {
|
|
|
1790
1942
|
const args = { ...input };
|
|
1791
1943
|
if (!accounts.subscriptionPda.value) {
|
|
1792
1944
|
accounts.subscriptionPda.value = await findSubscriptionDelegationPda({
|
|
1793
|
-
planPda: (0,
|
|
1794
|
-
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)
|
|
1795
1947
|
});
|
|
1796
1948
|
}
|
|
1797
1949
|
if (!accounts.systemProgram.value) {
|
|
@@ -1803,7 +1955,7 @@ async function getSubscribeInstructionAsync(input, config) {
|
|
|
1803
1955
|
if (!accounts.selfProgram.value) {
|
|
1804
1956
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1805
1957
|
}
|
|
1806
|
-
const getAccountMeta = (0,
|
|
1958
|
+
const getAccountMeta = (0, import_program_client_core12.getAccountMetaFactory)(programAddress, "programId");
|
|
1807
1959
|
return Object.freeze({
|
|
1808
1960
|
accounts: [
|
|
1809
1961
|
getAccountMeta("subscriber", accounts.subscriber),
|
|
@@ -1842,7 +1994,7 @@ function getSubscribeInstruction(input, config) {
|
|
|
1842
1994
|
if (!accounts.selfProgram.value) {
|
|
1843
1995
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1844
1996
|
}
|
|
1845
|
-
const getAccountMeta = (0,
|
|
1997
|
+
const getAccountMeta = (0, import_program_client_core12.getAccountMetaFactory)(programAddress, "programId");
|
|
1846
1998
|
return Object.freeze({
|
|
1847
1999
|
accounts: [
|
|
1848
2000
|
getAccountMeta("subscriber", accounts.subscriber),
|
|
@@ -1860,7 +2012,7 @@ function getSubscribeInstruction(input, config) {
|
|
|
1860
2012
|
}
|
|
1861
2013
|
function parseSubscribeInstruction(instruction) {
|
|
1862
2014
|
if (instruction.accounts.length < 8) {
|
|
1863
|
-
throw new
|
|
2015
|
+
throw new import_kit34.SolanaError(import_kit34.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1864
2016
|
actualAccountMetas: instruction.accounts.length,
|
|
1865
2017
|
expectedAccountMetas: 8
|
|
1866
2018
|
});
|
|
@@ -1888,29 +2040,29 @@ function parseSubscribeInstruction(instruction) {
|
|
|
1888
2040
|
}
|
|
1889
2041
|
|
|
1890
2042
|
// src/generated/instructions/transferFixed.ts
|
|
1891
|
-
var
|
|
1892
|
-
var
|
|
2043
|
+
var import_kit35 = require("@solana/kit");
|
|
2044
|
+
var import_program_client_core13 = require("@solana/program-client-core");
|
|
1893
2045
|
var TRANSFER_FIXED_DISCRIMINATOR = 4;
|
|
1894
2046
|
function getTransferFixedDiscriminatorBytes() {
|
|
1895
|
-
return (0,
|
|
2047
|
+
return (0, import_kit35.getU8Encoder)().encode(TRANSFER_FIXED_DISCRIMINATOR);
|
|
1896
2048
|
}
|
|
1897
2049
|
function getTransferFixedInstructionDataEncoder() {
|
|
1898
|
-
return (0,
|
|
1899
|
-
(0,
|
|
1900
|
-
["discriminator", (0,
|
|
2050
|
+
return (0, import_kit35.transformEncoder)(
|
|
2051
|
+
(0, import_kit35.getStructEncoder)([
|
|
2052
|
+
["discriminator", (0, import_kit35.getU8Encoder)()],
|
|
1901
2053
|
["transferData", getTransferDataEncoder()]
|
|
1902
2054
|
]),
|
|
1903
2055
|
(value) => ({ ...value, discriminator: TRANSFER_FIXED_DISCRIMINATOR })
|
|
1904
2056
|
);
|
|
1905
2057
|
}
|
|
1906
2058
|
function getTransferFixedInstructionDataDecoder() {
|
|
1907
|
-
return (0,
|
|
1908
|
-
["discriminator", (0,
|
|
2059
|
+
return (0, import_kit35.getStructDecoder)([
|
|
2060
|
+
["discriminator", (0, import_kit35.getU8Decoder)()],
|
|
1909
2061
|
["transferData", getTransferDataDecoder()]
|
|
1910
2062
|
]);
|
|
1911
2063
|
}
|
|
1912
2064
|
function getTransferFixedInstructionDataCodec() {
|
|
1913
|
-
return (0,
|
|
2065
|
+
return (0, import_kit35.combineCodec)(getTransferFixedInstructionDataEncoder(), getTransferFixedInstructionDataDecoder());
|
|
1914
2066
|
}
|
|
1915
2067
|
function getTransferFixedInstruction(input, config) {
|
|
1916
2068
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -1933,7 +2085,7 @@ function getTransferFixedInstruction(input, config) {
|
|
|
1933
2085
|
if (!accounts.selfProgram.value) {
|
|
1934
2086
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1935
2087
|
}
|
|
1936
|
-
const getAccountMeta = (0,
|
|
2088
|
+
const getAccountMeta = (0, import_program_client_core13.getAccountMetaFactory)(programAddress, "programId");
|
|
1937
2089
|
return Object.freeze({
|
|
1938
2090
|
accounts: [
|
|
1939
2091
|
getAccountMeta("delegationPda", accounts.delegationPda),
|
|
@@ -1952,7 +2104,7 @@ function getTransferFixedInstruction(input, config) {
|
|
|
1952
2104
|
}
|
|
1953
2105
|
function parseTransferFixedInstruction(instruction) {
|
|
1954
2106
|
if (instruction.accounts.length < 9) {
|
|
1955
|
-
throw new
|
|
2107
|
+
throw new import_kit35.SolanaError(import_kit35.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
1956
2108
|
actualAccountMetas: instruction.accounts.length,
|
|
1957
2109
|
expectedAccountMetas: 9
|
|
1958
2110
|
});
|
|
@@ -1981,29 +2133,29 @@ function parseTransferFixedInstruction(instruction) {
|
|
|
1981
2133
|
}
|
|
1982
2134
|
|
|
1983
2135
|
// src/generated/instructions/transferRecurring.ts
|
|
1984
|
-
var
|
|
1985
|
-
var
|
|
2136
|
+
var import_kit36 = require("@solana/kit");
|
|
2137
|
+
var import_program_client_core14 = require("@solana/program-client-core");
|
|
1986
2138
|
var TRANSFER_RECURRING_DISCRIMINATOR = 5;
|
|
1987
2139
|
function getTransferRecurringDiscriminatorBytes() {
|
|
1988
|
-
return (0,
|
|
2140
|
+
return (0, import_kit36.getU8Encoder)().encode(TRANSFER_RECURRING_DISCRIMINATOR);
|
|
1989
2141
|
}
|
|
1990
2142
|
function getTransferRecurringInstructionDataEncoder() {
|
|
1991
|
-
return (0,
|
|
1992
|
-
(0,
|
|
1993
|
-
["discriminator", (0,
|
|
2143
|
+
return (0, import_kit36.transformEncoder)(
|
|
2144
|
+
(0, import_kit36.getStructEncoder)([
|
|
2145
|
+
["discriminator", (0, import_kit36.getU8Encoder)()],
|
|
1994
2146
|
["transferData", getTransferDataEncoder()]
|
|
1995
2147
|
]),
|
|
1996
2148
|
(value) => ({ ...value, discriminator: TRANSFER_RECURRING_DISCRIMINATOR })
|
|
1997
2149
|
);
|
|
1998
2150
|
}
|
|
1999
2151
|
function getTransferRecurringInstructionDataDecoder() {
|
|
2000
|
-
return (0,
|
|
2001
|
-
["discriminator", (0,
|
|
2152
|
+
return (0, import_kit36.getStructDecoder)([
|
|
2153
|
+
["discriminator", (0, import_kit36.getU8Decoder)()],
|
|
2002
2154
|
["transferData", getTransferDataDecoder()]
|
|
2003
2155
|
]);
|
|
2004
2156
|
}
|
|
2005
2157
|
function getTransferRecurringInstructionDataCodec() {
|
|
2006
|
-
return (0,
|
|
2158
|
+
return (0, import_kit36.combineCodec)(getTransferRecurringInstructionDataEncoder(), getTransferRecurringInstructionDataDecoder());
|
|
2007
2159
|
}
|
|
2008
2160
|
function getTransferRecurringInstruction(input, config) {
|
|
2009
2161
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -2026,7 +2178,7 @@ function getTransferRecurringInstruction(input, config) {
|
|
|
2026
2178
|
if (!accounts.selfProgram.value) {
|
|
2027
2179
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
2028
2180
|
}
|
|
2029
|
-
const getAccountMeta = (0,
|
|
2181
|
+
const getAccountMeta = (0, import_program_client_core14.getAccountMetaFactory)(programAddress, "programId");
|
|
2030
2182
|
return Object.freeze({
|
|
2031
2183
|
accounts: [
|
|
2032
2184
|
getAccountMeta("delegationPda", accounts.delegationPda),
|
|
@@ -2045,7 +2197,7 @@ function getTransferRecurringInstruction(input, config) {
|
|
|
2045
2197
|
}
|
|
2046
2198
|
function parseTransferRecurringInstruction(instruction) {
|
|
2047
2199
|
if (instruction.accounts.length < 9) {
|
|
2048
|
-
throw new
|
|
2200
|
+
throw new import_kit36.SolanaError(import_kit36.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
2049
2201
|
actualAccountMetas: instruction.accounts.length,
|
|
2050
2202
|
expectedAccountMetas: 9
|
|
2051
2203
|
});
|
|
@@ -2074,29 +2226,29 @@ function parseTransferRecurringInstruction(instruction) {
|
|
|
2074
2226
|
}
|
|
2075
2227
|
|
|
2076
2228
|
// src/generated/instructions/transferSubscription.ts
|
|
2077
|
-
var
|
|
2078
|
-
var
|
|
2229
|
+
var import_kit37 = require("@solana/kit");
|
|
2230
|
+
var import_program_client_core15 = require("@solana/program-client-core");
|
|
2079
2231
|
var TRANSFER_SUBSCRIPTION_DISCRIMINATOR = 10;
|
|
2080
2232
|
function getTransferSubscriptionDiscriminatorBytes() {
|
|
2081
|
-
return (0,
|
|
2233
|
+
return (0, import_kit37.getU8Encoder)().encode(TRANSFER_SUBSCRIPTION_DISCRIMINATOR);
|
|
2082
2234
|
}
|
|
2083
2235
|
function getTransferSubscriptionInstructionDataEncoder() {
|
|
2084
|
-
return (0,
|
|
2085
|
-
(0,
|
|
2086
|
-
["discriminator", (0,
|
|
2236
|
+
return (0, import_kit37.transformEncoder)(
|
|
2237
|
+
(0, import_kit37.getStructEncoder)([
|
|
2238
|
+
["discriminator", (0, import_kit37.getU8Encoder)()],
|
|
2087
2239
|
["transferData", getTransferDataEncoder()]
|
|
2088
2240
|
]),
|
|
2089
2241
|
(value) => ({ ...value, discriminator: TRANSFER_SUBSCRIPTION_DISCRIMINATOR })
|
|
2090
2242
|
);
|
|
2091
2243
|
}
|
|
2092
2244
|
function getTransferSubscriptionInstructionDataDecoder() {
|
|
2093
|
-
return (0,
|
|
2094
|
-
["discriminator", (0,
|
|
2245
|
+
return (0, import_kit37.getStructDecoder)([
|
|
2246
|
+
["discriminator", (0, import_kit37.getU8Decoder)()],
|
|
2095
2247
|
["transferData", getTransferDataDecoder()]
|
|
2096
2248
|
]);
|
|
2097
2249
|
}
|
|
2098
2250
|
function getTransferSubscriptionInstructionDataCodec() {
|
|
2099
|
-
return (0,
|
|
2251
|
+
return (0, import_kit37.combineCodec)(
|
|
2100
2252
|
getTransferSubscriptionInstructionDataEncoder(),
|
|
2101
2253
|
getTransferSubscriptionInstructionDataDecoder()
|
|
2102
2254
|
);
|
|
@@ -2123,7 +2275,7 @@ function getTransferSubscriptionInstruction(input, config) {
|
|
|
2123
2275
|
if (!accounts.selfProgram.value) {
|
|
2124
2276
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
2125
2277
|
}
|
|
2126
|
-
const getAccountMeta = (0,
|
|
2278
|
+
const getAccountMeta = (0, import_program_client_core15.getAccountMetaFactory)(programAddress, "programId");
|
|
2127
2279
|
return Object.freeze({
|
|
2128
2280
|
accounts: [
|
|
2129
2281
|
getAccountMeta("subscriptionPda", accounts.subscriptionPda),
|
|
@@ -2143,7 +2295,7 @@ function getTransferSubscriptionInstruction(input, config) {
|
|
|
2143
2295
|
}
|
|
2144
2296
|
function parseTransferSubscriptionInstruction(instruction) {
|
|
2145
2297
|
if (instruction.accounts.length < 10) {
|
|
2146
|
-
throw new
|
|
2298
|
+
throw new import_kit37.SolanaError(import_kit37.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
2147
2299
|
actualAccountMetas: instruction.accounts.length,
|
|
2148
2300
|
expectedAccountMetas: 10
|
|
2149
2301
|
});
|
|
@@ -2173,29 +2325,29 @@ function parseTransferSubscriptionInstruction(instruction) {
|
|
|
2173
2325
|
}
|
|
2174
2326
|
|
|
2175
2327
|
// src/generated/instructions/updatePlan.ts
|
|
2176
|
-
var
|
|
2177
|
-
var
|
|
2328
|
+
var import_kit38 = require("@solana/kit");
|
|
2329
|
+
var import_program_client_core16 = require("@solana/program-client-core");
|
|
2178
2330
|
var UPDATE_PLAN_DISCRIMINATOR = 8;
|
|
2179
2331
|
function getUpdatePlanDiscriminatorBytes() {
|
|
2180
|
-
return (0,
|
|
2332
|
+
return (0, import_kit38.getU8Encoder)().encode(UPDATE_PLAN_DISCRIMINATOR);
|
|
2181
2333
|
}
|
|
2182
2334
|
function getUpdatePlanInstructionDataEncoder() {
|
|
2183
|
-
return (0,
|
|
2184
|
-
(0,
|
|
2185
|
-
["discriminator", (0,
|
|
2335
|
+
return (0, import_kit38.transformEncoder)(
|
|
2336
|
+
(0, import_kit38.getStructEncoder)([
|
|
2337
|
+
["discriminator", (0, import_kit38.getU8Encoder)()],
|
|
2186
2338
|
["updatePlanData", getUpdatePlanDataEncoder()]
|
|
2187
2339
|
]),
|
|
2188
2340
|
(value) => ({ ...value, discriminator: UPDATE_PLAN_DISCRIMINATOR })
|
|
2189
2341
|
);
|
|
2190
2342
|
}
|
|
2191
2343
|
function getUpdatePlanInstructionDataDecoder() {
|
|
2192
|
-
return (0,
|
|
2193
|
-
["discriminator", (0,
|
|
2344
|
+
return (0, import_kit38.getStructDecoder)([
|
|
2345
|
+
["discriminator", (0, import_kit38.getU8Decoder)()],
|
|
2194
2346
|
["updatePlanData", getUpdatePlanDataDecoder()]
|
|
2195
2347
|
]);
|
|
2196
2348
|
}
|
|
2197
2349
|
function getUpdatePlanInstructionDataCodec() {
|
|
2198
|
-
return (0,
|
|
2350
|
+
return (0, import_kit38.combineCodec)(getUpdatePlanInstructionDataEncoder(), getUpdatePlanInstructionDataDecoder());
|
|
2199
2351
|
}
|
|
2200
2352
|
function getUpdatePlanInstruction(input, config) {
|
|
2201
2353
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -2205,7 +2357,7 @@ function getUpdatePlanInstruction(input, config) {
|
|
|
2205
2357
|
};
|
|
2206
2358
|
const accounts = originalAccounts;
|
|
2207
2359
|
const args = { ...input };
|
|
2208
|
-
const getAccountMeta = (0,
|
|
2360
|
+
const getAccountMeta = (0, import_program_client_core16.getAccountMetaFactory)(programAddress, "programId");
|
|
2209
2361
|
return Object.freeze({
|
|
2210
2362
|
accounts: [getAccountMeta("owner", accounts.owner), getAccountMeta("planPda", accounts.planPda)],
|
|
2211
2363
|
data: getUpdatePlanInstructionDataEncoder().encode(args),
|
|
@@ -2214,7 +2366,7 @@ function getUpdatePlanInstruction(input, config) {
|
|
|
2214
2366
|
}
|
|
2215
2367
|
function parseUpdatePlanInstruction(instruction) {
|
|
2216
2368
|
if (instruction.accounts.length < 2) {
|
|
2217
|
-
throw new
|
|
2369
|
+
throw new import_kit38.SolanaError(import_kit38.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
2218
2370
|
actualAccountMetas: instruction.accounts.length,
|
|
2219
2371
|
expectedAccountMetas: 2
|
|
2220
2372
|
});
|
|
@@ -2258,53 +2410,61 @@ var SubscriptionsInstruction = /* @__PURE__ */ ((SubscriptionsInstruction2) => {
|
|
|
2258
2410
|
SubscriptionsInstruction2[SubscriptionsInstruction2["Subscribe"] = 11] = "Subscribe";
|
|
2259
2411
|
SubscriptionsInstruction2[SubscriptionsInstruction2["CancelSubscription"] = 12] = "CancelSubscription";
|
|
2260
2412
|
SubscriptionsInstruction2[SubscriptionsInstruction2["ResumeSubscription"] = 13] = "ResumeSubscription";
|
|
2413
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeSubscriptionAuthority"] = 14] = "RevokeSubscriptionAuthority";
|
|
2414
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeAbandonedDelegation"] = 15] = "RevokeAbandonedDelegation";
|
|
2261
2415
|
return SubscriptionsInstruction2;
|
|
2262
2416
|
})(SubscriptionsInstruction || {});
|
|
2263
2417
|
function identifySubscriptionsInstruction(instruction) {
|
|
2264
2418
|
const data = "data" in instruction ? instruction.data : instruction;
|
|
2265
|
-
if ((0,
|
|
2419
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(0), 0)) {
|
|
2266
2420
|
return 0 /* InitSubscriptionAuthority */;
|
|
2267
2421
|
}
|
|
2268
|
-
if ((0,
|
|
2422
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(1), 0)) {
|
|
2269
2423
|
return 1 /* CreateFixedDelegation */;
|
|
2270
2424
|
}
|
|
2271
|
-
if ((0,
|
|
2425
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(2), 0)) {
|
|
2272
2426
|
return 2 /* CreateRecurringDelegation */;
|
|
2273
2427
|
}
|
|
2274
|
-
if ((0,
|
|
2428
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(3), 0)) {
|
|
2275
2429
|
return 3 /* RevokeDelegation */;
|
|
2276
2430
|
}
|
|
2277
|
-
if ((0,
|
|
2431
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(4), 0)) {
|
|
2278
2432
|
return 4 /* TransferFixed */;
|
|
2279
2433
|
}
|
|
2280
|
-
if ((0,
|
|
2434
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(5), 0)) {
|
|
2281
2435
|
return 5 /* TransferRecurring */;
|
|
2282
2436
|
}
|
|
2283
|
-
if ((0,
|
|
2437
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(6), 0)) {
|
|
2284
2438
|
return 6 /* CloseSubscriptionAuthority */;
|
|
2285
2439
|
}
|
|
2286
|
-
if ((0,
|
|
2440
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(7), 0)) {
|
|
2287
2441
|
return 7 /* CreatePlan */;
|
|
2288
2442
|
}
|
|
2289
|
-
if ((0,
|
|
2443
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(8), 0)) {
|
|
2290
2444
|
return 8 /* UpdatePlan */;
|
|
2291
2445
|
}
|
|
2292
|
-
if ((0,
|
|
2446
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(9), 0)) {
|
|
2293
2447
|
return 9 /* DeletePlan */;
|
|
2294
2448
|
}
|
|
2295
|
-
if ((0,
|
|
2449
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(10), 0)) {
|
|
2296
2450
|
return 10 /* TransferSubscription */;
|
|
2297
2451
|
}
|
|
2298
|
-
if ((0,
|
|
2452
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(11), 0)) {
|
|
2299
2453
|
return 11 /* Subscribe */;
|
|
2300
2454
|
}
|
|
2301
|
-
if ((0,
|
|
2455
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(12), 0)) {
|
|
2302
2456
|
return 12 /* CancelSubscription */;
|
|
2303
2457
|
}
|
|
2304
|
-
if ((0,
|
|
2458
|
+
if ((0, import_kit39.containsBytes)(data, (0, import_kit39.getU8Encoder)().encode(13), 0)) {
|
|
2305
2459
|
return 13 /* ResumeSubscription */;
|
|
2306
2460
|
}
|
|
2307
|
-
|
|
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, {
|
|
2308
2468
|
instructionData: data,
|
|
2309
2469
|
programName: "subscriptions"
|
|
2310
2470
|
});
|
|
@@ -2313,93 +2473,107 @@ function parseSubscriptionsInstruction(instruction) {
|
|
|
2313
2473
|
const instructionType = identifySubscriptionsInstruction(instruction);
|
|
2314
2474
|
switch (instructionType) {
|
|
2315
2475
|
case 0 /* InitSubscriptionAuthority */: {
|
|
2316
|
-
(0,
|
|
2476
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2317
2477
|
return {
|
|
2318
2478
|
instructionType: 0 /* InitSubscriptionAuthority */,
|
|
2319
2479
|
...parseInitSubscriptionAuthorityInstruction(instruction)
|
|
2320
2480
|
};
|
|
2321
2481
|
}
|
|
2322
2482
|
case 1 /* CreateFixedDelegation */: {
|
|
2323
|
-
(0,
|
|
2483
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2324
2484
|
return {
|
|
2325
2485
|
instructionType: 1 /* CreateFixedDelegation */,
|
|
2326
2486
|
...parseCreateFixedDelegationInstruction(instruction)
|
|
2327
2487
|
};
|
|
2328
2488
|
}
|
|
2329
2489
|
case 2 /* CreateRecurringDelegation */: {
|
|
2330
|
-
(0,
|
|
2490
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2331
2491
|
return {
|
|
2332
2492
|
instructionType: 2 /* CreateRecurringDelegation */,
|
|
2333
2493
|
...parseCreateRecurringDelegationInstruction(instruction)
|
|
2334
2494
|
};
|
|
2335
2495
|
}
|
|
2336
2496
|
case 3 /* RevokeDelegation */: {
|
|
2337
|
-
(0,
|
|
2497
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2338
2498
|
return {
|
|
2339
2499
|
instructionType: 3 /* RevokeDelegation */,
|
|
2340
2500
|
...parseRevokeDelegationInstruction(instruction)
|
|
2341
2501
|
};
|
|
2342
2502
|
}
|
|
2343
2503
|
case 4 /* TransferFixed */: {
|
|
2344
|
-
(0,
|
|
2504
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2345
2505
|
return {
|
|
2346
2506
|
instructionType: 4 /* TransferFixed */,
|
|
2347
2507
|
...parseTransferFixedInstruction(instruction)
|
|
2348
2508
|
};
|
|
2349
2509
|
}
|
|
2350
2510
|
case 5 /* TransferRecurring */: {
|
|
2351
|
-
(0,
|
|
2511
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2352
2512
|
return {
|
|
2353
2513
|
instructionType: 5 /* TransferRecurring */,
|
|
2354
2514
|
...parseTransferRecurringInstruction(instruction)
|
|
2355
2515
|
};
|
|
2356
2516
|
}
|
|
2357
2517
|
case 6 /* CloseSubscriptionAuthority */: {
|
|
2358
|
-
(0,
|
|
2518
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2359
2519
|
return {
|
|
2360
2520
|
instructionType: 6 /* CloseSubscriptionAuthority */,
|
|
2361
2521
|
...parseCloseSubscriptionAuthorityInstruction(instruction)
|
|
2362
2522
|
};
|
|
2363
2523
|
}
|
|
2364
2524
|
case 7 /* CreatePlan */: {
|
|
2365
|
-
(0,
|
|
2525
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2366
2526
|
return { instructionType: 7 /* CreatePlan */, ...parseCreatePlanInstruction(instruction) };
|
|
2367
2527
|
}
|
|
2368
2528
|
case 8 /* UpdatePlan */: {
|
|
2369
|
-
(0,
|
|
2529
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2370
2530
|
return { instructionType: 8 /* UpdatePlan */, ...parseUpdatePlanInstruction(instruction) };
|
|
2371
2531
|
}
|
|
2372
2532
|
case 9 /* DeletePlan */: {
|
|
2373
|
-
(0,
|
|
2533
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2374
2534
|
return { instructionType: 9 /* DeletePlan */, ...parseDeletePlanInstruction(instruction) };
|
|
2375
2535
|
}
|
|
2376
2536
|
case 10 /* TransferSubscription */: {
|
|
2377
|
-
(0,
|
|
2537
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2378
2538
|
return {
|
|
2379
2539
|
instructionType: 10 /* TransferSubscription */,
|
|
2380
2540
|
...parseTransferSubscriptionInstruction(instruction)
|
|
2381
2541
|
};
|
|
2382
2542
|
}
|
|
2383
2543
|
case 11 /* Subscribe */: {
|
|
2384
|
-
(0,
|
|
2544
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2385
2545
|
return { instructionType: 11 /* Subscribe */, ...parseSubscribeInstruction(instruction) };
|
|
2386
2546
|
}
|
|
2387
2547
|
case 12 /* CancelSubscription */: {
|
|
2388
|
-
(0,
|
|
2548
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2389
2549
|
return {
|
|
2390
2550
|
instructionType: 12 /* CancelSubscription */,
|
|
2391
2551
|
...parseCancelSubscriptionInstruction(instruction)
|
|
2392
2552
|
};
|
|
2393
2553
|
}
|
|
2394
2554
|
case 13 /* ResumeSubscription */: {
|
|
2395
|
-
(0,
|
|
2555
|
+
(0, import_kit39.assertIsInstructionWithAccounts)(instruction);
|
|
2396
2556
|
return {
|
|
2397
2557
|
instructionType: 13 /* ResumeSubscription */,
|
|
2398
2558
|
...parseResumeSubscriptionInstruction(instruction)
|
|
2399
2559
|
};
|
|
2400
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
|
+
}
|
|
2401
2575
|
default:
|
|
2402
|
-
throw new
|
|
2576
|
+
throw new import_kit39.SolanaError(import_kit39.SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
|
|
2403
2577
|
instructionType,
|
|
2404
2578
|
programName: "subscriptions"
|
|
2405
2579
|
});
|
|
@@ -2407,31 +2581,33 @@ function parseSubscriptionsInstruction(instruction) {
|
|
|
2407
2581
|
}
|
|
2408
2582
|
function subscriptionsProgram() {
|
|
2409
2583
|
return (client) => {
|
|
2410
|
-
return (0,
|
|
2584
|
+
return (0, import_kit39.extendClient)(client, {
|
|
2411
2585
|
subscriptions: {
|
|
2412
2586
|
accounts: {
|
|
2413
|
-
fixedDelegation: (0,
|
|
2414
|
-
plan: (0,
|
|
2415
|
-
recurringDelegation: (0,
|
|
2416
|
-
subscriptionAuthority: (0,
|
|
2417
|
-
subscriptionDelegation: (0,
|
|
2418
|
-
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())
|
|
2419
2593
|
},
|
|
2420
2594
|
instructions: {
|
|
2421
|
-
initSubscriptionAuthority: (input) => (0,
|
|
2422
|
-
createFixedDelegation: (input) => (0,
|
|
2423
|
-
createRecurringDelegation: (input) => (0,
|
|
2424
|
-
revokeDelegation: (input) => (0,
|
|
2425
|
-
transferFixed: (input) => (0,
|
|
2426
|
-
transferRecurring: (input) => (0,
|
|
2427
|
-
closeSubscriptionAuthority: (input) => (0,
|
|
2428
|
-
createPlan: (input) => (0,
|
|
2429
|
-
updatePlan: (input) => (0,
|
|
2430
|
-
deletePlan: (input) => (0,
|
|
2431
|
-
transferSubscription: (input) => (0,
|
|
2432
|
-
subscribe: (input) => (0,
|
|
2433
|
-
cancelSubscription: (input) => (0,
|
|
2434
|
-
resumeSubscription: (input) => (0,
|
|
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))
|
|
2435
2611
|
},
|
|
2436
2612
|
pdas: {
|
|
2437
2613
|
fixedDelegation: findFixedDelegationPda,
|
|
@@ -2484,6 +2660,8 @@ var SUBSCRIPTIONS_ERROR__DELEGATION_VERSION_MISMATCH = 133;
|
|
|
2484
2660
|
var SUBSCRIPTIONS_ERROR__MIGRATION_REQUIRED = 134;
|
|
2485
2661
|
var SUBSCRIPTIONS_ERROR__DELEGATION_ALREADY_EXISTS = 135;
|
|
2486
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;
|
|
2487
2665
|
var SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_LIMIT = 300;
|
|
2488
2666
|
var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_EXPIRY_IN_PAST = 301;
|
|
2489
2667
|
var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_AMOUNT_ZERO = 302;
|
|
@@ -2495,6 +2673,7 @@ var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST = 404;
|
|
|
2495
2673
|
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY = 405;
|
|
2496
2674
|
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO = 406;
|
|
2497
2675
|
var SUBSCRIPTIONS_ERROR__DELEGATION_NOT_STARTED = 407;
|
|
2676
|
+
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY = 408;
|
|
2498
2677
|
var SUBSCRIPTIONS_ERROR__PLAN_SUNSET = 500;
|
|
2499
2678
|
var SUBSCRIPTIONS_ERROR__PLAN_EXPIRED = 501;
|
|
2500
2679
|
var SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA = 502;
|
|
@@ -2584,6 +2763,7 @@ if (process.env["NODE_ENV"] !== "production") {
|
|
|
2584
2763
|
[SUBSCRIPTIONS_ERROR__PLAN_SUNSET]: `Plan is in sunset status`,
|
|
2585
2764
|
[SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH]: `Subscription plan terms do not match the current plan`,
|
|
2586
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`,
|
|
2587
2767
|
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY]: `start time specified is greater than expiry`,
|
|
2588
2768
|
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST]: `Past start time specified`,
|
|
2589
2769
|
[SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY]: `Delegation init_id does not match current SubscriptionAuthority`,
|
|
@@ -2592,6 +2772,8 @@ if (process.env["NODE_ENV"] !== "production") {
|
|
|
2592
2772
|
[SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED]: `Subscription is not cancelled`,
|
|
2593
2773
|
[SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH]: `Subscription does not belong to this plan`,
|
|
2594
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`,
|
|
2595
2777
|
[SUBSCRIPTIONS_ERROR__UNAUTHORIZED]: `Caller not authorized for this action`,
|
|
2596
2778
|
[SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION]: `Destination not in plan whitelist`
|
|
2597
2779
|
};
|
|
@@ -2603,7 +2785,7 @@ function getSubscriptionsErrorMessage(code) {
|
|
|
2603
2785
|
return "Error message not available in production bundles.";
|
|
2604
2786
|
}
|
|
2605
2787
|
function isSubscriptionsError(error, transactionMessage, code) {
|
|
2606
|
-
return (0,
|
|
2788
|
+
return (0, import_kit40.isProgramError)(error, transactionMessage, SUBSCRIPTIONS_PROGRAM_ADDRESS, code);
|
|
2607
2789
|
}
|
|
2608
2790
|
|
|
2609
2791
|
// src/constants.ts
|
|
@@ -2628,7 +2810,7 @@ var METADATA_URI_LEN = 128;
|
|
|
2628
2810
|
|
|
2629
2811
|
// src/accounts/decode.ts
|
|
2630
2812
|
function toEncodedAccount(raw, programAddress) {
|
|
2631
|
-
const base64Encoder = (0,
|
|
2813
|
+
const base64Encoder = (0, import_kit41.getBase64Encoder)();
|
|
2632
2814
|
const data = base64Encoder.encode(raw.account.data[0]);
|
|
2633
2815
|
return {
|
|
2634
2816
|
address: raw.pubkey,
|
|
@@ -2745,10 +2927,148 @@ async function fetchSubscriptionsForUser(rpc, user, programAddress) {
|
|
|
2745
2927
|
}
|
|
2746
2928
|
|
|
2747
2929
|
// src/plugin.ts
|
|
2748
|
-
var
|
|
2749
|
-
var
|
|
2930
|
+
var import_kit43 = require("@solana/kit");
|
|
2931
|
+
var import_program_client_core18 = require("@solana/program-client-core");
|
|
2750
2932
|
var import_token = require("@solana-program/token");
|
|
2751
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
|
+
|
|
2752
3072
|
// src/validators.ts
|
|
2753
3073
|
var textEncoder = new TextEncoder();
|
|
2754
3074
|
var ValidationError = class extends Error {
|
|
@@ -2760,6 +3080,10 @@ var ValidationError = class extends Error {
|
|
|
2760
3080
|
function assertPositive(value, name) {
|
|
2761
3081
|
if (BigInt(value) <= 0n) throw new ValidationError(`${name} must be greater than zero`);
|
|
2762
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
|
+
}
|
|
2763
3087
|
function assertMetadataUri(metadataUri) {
|
|
2764
3088
|
if (textEncoder.encode(metadataUri).length > METADATA_URI_LEN)
|
|
2765
3089
|
throw new ValidationError(`metadataUri exceeds ${METADATA_URI_LEN} bytes`);
|
|
@@ -2796,7 +3120,7 @@ function appendPayer(instruction, payer) {
|
|
|
2796
3120
|
return withTrailing(instruction, [
|
|
2797
3121
|
{
|
|
2798
3122
|
address: payer.address,
|
|
2799
|
-
role:
|
|
3123
|
+
role: import_kit43.AccountRole.WRITABLE_SIGNER,
|
|
2800
3124
|
signer: payer
|
|
2801
3125
|
}
|
|
2802
3126
|
]);
|
|
@@ -2825,10 +3149,26 @@ async function getCloseSubscriptionAuthorityOverlayInstructionAsync(input) {
|
|
|
2825
3149
|
pdaConfig(input.programAddress)
|
|
2826
3150
|
);
|
|
2827
3151
|
if (input.receiver) {
|
|
2828
|
-
ix = withTrailing(ix, [{ address: input.receiver, role:
|
|
3152
|
+
ix = withTrailing(ix, [{ address: input.receiver, role: import_kit43.AccountRole.WRITABLE }]);
|
|
2829
3153
|
}
|
|
2830
3154
|
return ix;
|
|
2831
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
|
+
}
|
|
2832
3172
|
async function getCreateFixedDelegationOverlayInstructionAsync(input) {
|
|
2833
3173
|
assertPositive(input.amount, "amount");
|
|
2834
3174
|
if (input.expectedSubscriptionAuthorityInitId === void 0) {
|
|
@@ -2919,14 +3259,14 @@ function getRevokeDelegationOverlayInstruction(input) {
|
|
|
2919
3259
|
pdaConfig(input.programAddress)
|
|
2920
3260
|
);
|
|
2921
3261
|
if (input.receiver) {
|
|
2922
|
-
ix = withTrailing(ix, [{ address: input.receiver, role:
|
|
3262
|
+
ix = withTrailing(ix, [{ address: input.receiver, role: import_kit43.AccountRole.WRITABLE }]);
|
|
2923
3263
|
}
|
|
2924
3264
|
return ix;
|
|
2925
3265
|
}
|
|
2926
3266
|
function getRevokeSubscriptionOverlayInstruction(input) {
|
|
2927
|
-
const trailing = [{ address: input.planPda, role:
|
|
3267
|
+
const trailing = [{ address: input.planPda, role: import_kit43.AccountRole.READONLY }];
|
|
2928
3268
|
if (input.receiver) {
|
|
2929
|
-
trailing.push({ address: input.receiver, role:
|
|
3269
|
+
trailing.push({ address: input.receiver, role: import_kit43.AccountRole.WRITABLE });
|
|
2930
3270
|
}
|
|
2931
3271
|
return withTrailing(
|
|
2932
3272
|
getRevokeDelegationInstruction(
|
|
@@ -2945,22 +3285,25 @@ async function getTransferDelegationOverlayInstructionAsync(input, getInstructio
|
|
|
2945
3285
|
{ tokenMint: input.tokenMint, user: input.delegator },
|
|
2946
3286
|
pdaConfig(input.programAddress)
|
|
2947
3287
|
);
|
|
2948
|
-
return
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
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 ?? []
|
|
2964
3307
|
);
|
|
2965
3308
|
}
|
|
2966
3309
|
function getTransferFixedOverlayInstructionAsync(input) {
|
|
@@ -2980,28 +3323,32 @@ async function getTransferSubscriptionOverlayInstructionAsync(input) {
|
|
|
2980
3323
|
owner: input.delegator,
|
|
2981
3324
|
tokenProgram: input.tokenProgram
|
|
2982
3325
|
});
|
|
2983
|
-
return
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
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 ?? []
|
|
3000
3346
|
);
|
|
3001
3347
|
}
|
|
3002
3348
|
async function getCreatePlanOverlayInstructionAsync(input) {
|
|
3003
3349
|
assertPositive(input.amount, "amount");
|
|
3004
3350
|
assertPositive(input.periodHours, "periodHours");
|
|
3351
|
+
assertSafeU64(input.planId, "planId");
|
|
3005
3352
|
assertMetadataUri(input.metadataUri);
|
|
3006
3353
|
const destinations = padPlanDestinations(input.destinations);
|
|
3007
3354
|
const pullers = padPlanPullers(input.pullers);
|
|
@@ -3034,7 +3381,7 @@ async function getCreatePlanOverlayInstructionAsync(input) {
|
|
|
3034
3381
|
}
|
|
3035
3382
|
function getUpdatePlanOverlayInstruction(input) {
|
|
3036
3383
|
assertMetadataUri(input.metadataUri);
|
|
3037
|
-
const pullers = padPlanPullers(input.pullers
|
|
3384
|
+
const pullers = padPlanPullers(input.pullers);
|
|
3038
3385
|
return getUpdatePlanInstruction(
|
|
3039
3386
|
{
|
|
3040
3387
|
owner: input.owner,
|
|
@@ -3058,6 +3405,7 @@ async function getSubscribeOverlayInstructionAsync(input) {
|
|
|
3058
3405
|
"getSubscribeOverlayInstructionAsync requires expectedAmount, expectedPeriodHours, expectedCreatedAt, and expectedSubscriptionAuthorityInitId. Use the plugin client `subscriptions.instructions.subscribe(...)` to auto-fetch from the live plan and authority."
|
|
3059
3406
|
);
|
|
3060
3407
|
}
|
|
3408
|
+
assertSafeU64(input.planId, "planId");
|
|
3061
3409
|
const [planPda, planBump] = await findPlanPda(
|
|
3062
3410
|
{ owner: input.merchant, planId: input.planId },
|
|
3063
3411
|
pdaConfig(input.programAddress)
|
|
@@ -3110,7 +3458,7 @@ function getResumeSubscriptionOverlayInstructionAsync(input) {
|
|
|
3110
3458
|
}
|
|
3111
3459
|
function subscriptionsProgram2() {
|
|
3112
3460
|
return (client) => {
|
|
3113
|
-
return (0,
|
|
3461
|
+
return (0, import_kit43.pipe)(client, subscriptionsProgram(), (c) => {
|
|
3114
3462
|
const queries = {
|
|
3115
3463
|
activeDelegationSummary: async (wallet) => {
|
|
3116
3464
|
const delegations = await fetchDelegationsByDelegator(c.rpc, wallet);
|
|
@@ -3147,22 +3495,37 @@ function subscriptionsProgram2() {
|
|
|
3147
3495
|
}
|
|
3148
3496
|
return subscriptionAuthority.data.initId;
|
|
3149
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
|
+
};
|
|
3150
3513
|
const instructions = {
|
|
3151
|
-
cancelSubscription: (input) => (0,
|
|
3514
|
+
cancelSubscription: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3152
3515
|
client,
|
|
3153
3516
|
getCancelSubscriptionOverlayInstructionAsync({
|
|
3154
3517
|
...input,
|
|
3155
3518
|
subscriber: input.subscriber ?? client.identity
|
|
3156
3519
|
})
|
|
3157
3520
|
),
|
|
3158
|
-
closeSubscriptionAuthority: (input) => (0,
|
|
3521
|
+
closeSubscriptionAuthority: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3159
3522
|
client,
|
|
3160
3523
|
getCloseSubscriptionAuthorityOverlayInstructionAsync({
|
|
3161
3524
|
...input,
|
|
3162
3525
|
user: input.user ?? client.identity
|
|
3163
3526
|
})
|
|
3164
3527
|
),
|
|
3165
|
-
createFixedDelegation: (input) => (0,
|
|
3528
|
+
createFixedDelegation: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3166
3529
|
client,
|
|
3167
3530
|
(async () => {
|
|
3168
3531
|
const delegator = input.delegator ?? client.identity;
|
|
@@ -3180,14 +3543,14 @@ function subscriptionsProgram2() {
|
|
|
3180
3543
|
});
|
|
3181
3544
|
})()
|
|
3182
3545
|
),
|
|
3183
|
-
createPlan: (input) => (0,
|
|
3546
|
+
createPlan: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3184
3547
|
client,
|
|
3185
3548
|
getCreatePlanOverlayInstructionAsync({
|
|
3186
3549
|
...input,
|
|
3187
3550
|
owner: input.owner ?? client.identity
|
|
3188
3551
|
})
|
|
3189
3552
|
),
|
|
3190
|
-
createRecurringDelegation: (input) => (0,
|
|
3553
|
+
createRecurringDelegation: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3191
3554
|
client,
|
|
3192
3555
|
(async () => {
|
|
3193
3556
|
const delegator = input.delegator ?? client.identity;
|
|
@@ -3205,14 +3568,14 @@ function subscriptionsProgram2() {
|
|
|
3205
3568
|
});
|
|
3206
3569
|
})()
|
|
3207
3570
|
),
|
|
3208
|
-
deletePlan: (input) => (0,
|
|
3571
|
+
deletePlan: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3209
3572
|
client,
|
|
3210
3573
|
getDeletePlanOverlayInstruction({
|
|
3211
3574
|
...input,
|
|
3212
3575
|
owner: input.owner ?? client.identity
|
|
3213
3576
|
})
|
|
3214
3577
|
),
|
|
3215
|
-
initSubscriptionAuthority: (input) => (0,
|
|
3578
|
+
initSubscriptionAuthority: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3216
3579
|
client,
|
|
3217
3580
|
getInitSubscriptionAuthorityOverlayInstructionAsync({
|
|
3218
3581
|
...input,
|
|
@@ -3220,31 +3583,39 @@ function subscriptionsProgram2() {
|
|
|
3220
3583
|
payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer)
|
|
3221
3584
|
})
|
|
3222
3585
|
),
|
|
3223
|
-
resumeSubscription: (input) => (0,
|
|
3586
|
+
resumeSubscription: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3224
3587
|
client,
|
|
3225
3588
|
getResumeSubscriptionOverlayInstructionAsync({
|
|
3226
3589
|
...input,
|
|
3227
3590
|
subscriber: input.subscriber ?? client.identity
|
|
3228
3591
|
})
|
|
3229
3592
|
),
|
|
3230
|
-
revokeDelegation: (input) => (0,
|
|
3593
|
+
revokeDelegation: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3231
3594
|
client,
|
|
3232
3595
|
getRevokeDelegationOverlayInstruction({
|
|
3233
3596
|
...input,
|
|
3234
3597
|
authority: input.authority ?? client.identity
|
|
3235
3598
|
})
|
|
3236
3599
|
),
|
|
3237
|
-
revokeSubscription: (input) => (0,
|
|
3600
|
+
revokeSubscription: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3238
3601
|
client,
|
|
3239
3602
|
getRevokeSubscriptionOverlayInstruction({
|
|
3240
3603
|
...input,
|
|
3241
3604
|
authority: input.authority ?? client.identity
|
|
3242
3605
|
})
|
|
3243
3606
|
),
|
|
3244
|
-
|
|
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)(
|
|
3245
3615
|
client,
|
|
3246
3616
|
(async () => {
|
|
3247
3617
|
const subscriber = input.subscriber ?? client.identity;
|
|
3618
|
+
assertSafeU64(input.planId, "planId");
|
|
3248
3619
|
let {
|
|
3249
3620
|
expectedAmount,
|
|
3250
3621
|
expectedCreatedAt,
|
|
@@ -3288,28 +3659,51 @@ function subscriptionsProgram2() {
|
|
|
3288
3659
|
});
|
|
3289
3660
|
})()
|
|
3290
3661
|
),
|
|
3291
|
-
transferFixed: (input) => (0,
|
|
3662
|
+
transferFixed: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3292
3663
|
client,
|
|
3293
|
-
getTransferFixedOverlayInstructionAsync({
|
|
3664
|
+
(async () => await getTransferFixedOverlayInstructionAsync({
|
|
3294
3665
|
...input,
|
|
3295
|
-
delegatee: input.delegatee ?? client.identity
|
|
3296
|
-
|
|
3666
|
+
delegatee: input.delegatee ?? client.identity,
|
|
3667
|
+
transferHookAccounts: await resolveDelegationHookAccounts(input)
|
|
3668
|
+
}))()
|
|
3297
3669
|
),
|
|
3298
|
-
transferRecurring: (input) => (0,
|
|
3670
|
+
transferRecurring: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3299
3671
|
client,
|
|
3300
|
-
getTransferRecurringOverlayInstructionAsync({
|
|
3672
|
+
(async () => await getTransferRecurringOverlayInstructionAsync({
|
|
3301
3673
|
...input,
|
|
3302
|
-
delegatee: input.delegatee ?? client.identity
|
|
3303
|
-
|
|
3674
|
+
delegatee: input.delegatee ?? client.identity,
|
|
3675
|
+
transferHookAccounts: await resolveDelegationHookAccounts(input)
|
|
3676
|
+
}))()
|
|
3304
3677
|
),
|
|
3305
|
-
transferSubscription: (input) => (0,
|
|
3678
|
+
transferSubscription: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3306
3679
|
client,
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
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
|
+
})()
|
|
3311
3705
|
),
|
|
3312
|
-
updatePlan: (input) => (0,
|
|
3706
|
+
updatePlan: (input) => (0, import_program_client_core18.addSelfPlanAndSendFunctions)(
|
|
3313
3707
|
client,
|
|
3314
3708
|
getUpdatePlanOverlayInstruction({
|
|
3315
3709
|
...input,
|
|
@@ -3353,7 +3747,9 @@ function subscriptionsProgram2() {
|
|
|
3353
3747
|
PROGRAM_ID,
|
|
3354
3748
|
PlanStatus,
|
|
3355
3749
|
RESUME_SUBSCRIPTION_DISCRIMINATOR,
|
|
3750
|
+
REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR,
|
|
3356
3751
|
REVOKE_DELEGATION_DISCRIMINATOR,
|
|
3752
|
+
REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR,
|
|
3357
3753
|
SUBSCRIBE_DISCRIMINATOR,
|
|
3358
3754
|
SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE,
|
|
3359
3755
|
SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED,
|
|
@@ -3417,6 +3813,7 @@ function subscriptionsProgram2() {
|
|
|
3417
3813
|
SUBSCRIPTIONS_ERROR__PLAN_SUNSET,
|
|
3418
3814
|
SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH,
|
|
3419
3815
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO,
|
|
3816
|
+
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY,
|
|
3420
3817
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY,
|
|
3421
3818
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST,
|
|
3422
3819
|
SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY,
|
|
@@ -3425,6 +3822,8 @@ function subscriptionsProgram2() {
|
|
|
3425
3822
|
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED,
|
|
3426
3823
|
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH,
|
|
3427
3824
|
SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS,
|
|
3825
|
+
SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS,
|
|
3826
|
+
SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_VALIDATION_ACCOUNT_MISSING,
|
|
3428
3827
|
SUBSCRIPTIONS_ERROR__UNAUTHORIZED,
|
|
3429
3828
|
SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION,
|
|
3430
3829
|
SUBSCRIPTIONS_PROGRAM_ADDRESS,
|
|
@@ -3577,12 +3976,23 @@ function subscriptionsProgram2() {
|
|
|
3577
3976
|
getResumeSubscriptionInstructionDataDecoder,
|
|
3578
3977
|
getResumeSubscriptionInstructionDataEncoder,
|
|
3579
3978
|
getResumeSubscriptionOverlayInstructionAsync,
|
|
3979
|
+
getRevokeAbandonedDelegationDiscriminatorBytes,
|
|
3980
|
+
getRevokeAbandonedDelegationInstruction,
|
|
3981
|
+
getRevokeAbandonedDelegationInstructionDataCodec,
|
|
3982
|
+
getRevokeAbandonedDelegationInstructionDataDecoder,
|
|
3983
|
+
getRevokeAbandonedDelegationInstructionDataEncoder,
|
|
3580
3984
|
getRevokeDelegationDiscriminatorBytes,
|
|
3581
3985
|
getRevokeDelegationInstruction,
|
|
3582
3986
|
getRevokeDelegationInstructionDataCodec,
|
|
3583
3987
|
getRevokeDelegationInstructionDataDecoder,
|
|
3584
3988
|
getRevokeDelegationInstructionDataEncoder,
|
|
3585
3989
|
getRevokeDelegationOverlayInstruction,
|
|
3990
|
+
getRevokeSubscriptionAuthorityDiscriminatorBytes,
|
|
3991
|
+
getRevokeSubscriptionAuthorityInstruction,
|
|
3992
|
+
getRevokeSubscriptionAuthorityInstructionDataCodec,
|
|
3993
|
+
getRevokeSubscriptionAuthorityInstructionDataDecoder,
|
|
3994
|
+
getRevokeSubscriptionAuthorityInstructionDataEncoder,
|
|
3995
|
+
getRevokeSubscriptionAuthorityOverlayInstructionAsync,
|
|
3586
3996
|
getRevokeSubscriptionOverlayInstruction,
|
|
3587
3997
|
getSubscribeDataCodec,
|
|
3588
3998
|
getSubscribeDataDecoder,
|
|
@@ -3641,13 +4051,16 @@ function subscriptionsProgram2() {
|
|
|
3641
4051
|
parseDeletePlanInstruction,
|
|
3642
4052
|
parseInitSubscriptionAuthorityInstruction,
|
|
3643
4053
|
parseResumeSubscriptionInstruction,
|
|
4054
|
+
parseRevokeAbandonedDelegationInstruction,
|
|
3644
4055
|
parseRevokeDelegationInstruction,
|
|
4056
|
+
parseRevokeSubscriptionAuthorityInstruction,
|
|
3645
4057
|
parseSubscribeInstruction,
|
|
3646
4058
|
parseSubscriptionsInstruction,
|
|
3647
4059
|
parseTransferFixedInstruction,
|
|
3648
4060
|
parseTransferRecurringInstruction,
|
|
3649
4061
|
parseTransferSubscriptionInstruction,
|
|
3650
4062
|
parseUpdatePlanInstruction,
|
|
4063
|
+
resolveTransferHookAccounts,
|
|
3651
4064
|
subscriptionsProgram,
|
|
3652
4065
|
toEncodedAccount
|
|
3653
4066
|
});
|