@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/dist/index.js CHANGED
@@ -227,14 +227,16 @@ function getCreateFixedDelegationDataEncoder() {
227
227
  return getStructEncoder2([
228
228
  ["nonce", getU64Encoder4()],
229
229
  ["amount", getU64Encoder4()],
230
- ["expiryTs", getI64Encoder()]
230
+ ["expiryTs", getI64Encoder()],
231
+ ["expectedSubscriptionAuthorityInitId", getI64Encoder()]
231
232
  ]);
232
233
  }
233
234
  function getCreateFixedDelegationDataDecoder() {
234
235
  return getStructDecoder2([
235
236
  ["nonce", getU64Decoder()],
236
237
  ["amount", getU64Decoder()],
237
- ["expiryTs", getI64Decoder()]
238
+ ["expiryTs", getI64Decoder()],
239
+ ["expectedSubscriptionAuthorityInitId", getI64Decoder()]
238
240
  ]);
239
241
  }
240
242
  function getCreateFixedDelegationDataCodec() {
@@ -257,7 +259,8 @@ function getCreateRecurringDelegationDataEncoder() {
257
259
  ["amountPerPeriod", getU64Encoder5()],
258
260
  ["periodLengthS", getU64Encoder5()],
259
261
  ["startTs", getI64Encoder2()],
260
- ["expiryTs", getI64Encoder2()]
262
+ ["expiryTs", getI64Encoder2()],
263
+ ["expectedSubscriptionAuthorityInitId", getI64Encoder2()]
261
264
  ]);
262
265
  }
263
266
  function getCreateRecurringDelegationDataDecoder() {
@@ -266,7 +269,8 @@ function getCreateRecurringDelegationDataDecoder() {
266
269
  ["amountPerPeriod", getU64Decoder2()],
267
270
  ["periodLengthS", getU64Decoder2()],
268
271
  ["startTs", getI64Decoder2()],
269
- ["expiryTs", getI64Decoder2()]
272
+ ["expiryTs", getI64Decoder2()],
273
+ ["expectedSubscriptionAuthorityInitId", getI64Decoder2()]
270
274
  ]);
271
275
  }
272
276
  function getCreateRecurringDelegationDataCodec() {
@@ -425,7 +429,8 @@ function getSubscribeDataEncoder() {
425
429
  ["expectedMint", getAddressEncoder8()],
426
430
  ["expectedAmount", getU64Encoder8()],
427
431
  ["expectedPeriodHours", getU64Encoder8()],
428
- ["expectedCreatedAt", getI64Encoder6()]
432
+ ["expectedCreatedAt", getI64Encoder6()],
433
+ ["expectedSubscriptionAuthorityInitId", getI64Encoder6()]
429
434
  ]);
430
435
  }
431
436
  function getSubscribeDataDecoder() {
@@ -435,7 +440,8 @@ function getSubscribeDataDecoder() {
435
440
  ["expectedMint", getAddressDecoder3()],
436
441
  ["expectedAmount", getU64Decoder5()],
437
442
  ["expectedPeriodHours", getU64Decoder5()],
438
- ["expectedCreatedAt", getI64Decoder6()]
443
+ ["expectedCreatedAt", getI64Decoder6()],
444
+ ["expectedSubscriptionAuthorityInitId", getI64Decoder6()]
439
445
  ]);
440
446
  }
441
447
  function getSubscribeDataCodec() {
@@ -856,10 +862,10 @@ import {
856
862
  assertIsInstructionWithAccounts,
857
863
  containsBytes,
858
864
  extendClient,
859
- getU8Encoder as getU8Encoder20,
865
+ getU8Encoder as getU8Encoder22,
860
866
  SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
861
867
  SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
862
- SolanaError as SolanaError15
868
+ SolanaError as SolanaError17
863
869
  } from "@solana/kit";
864
870
  import {
865
871
  addSelfFetchFunctions,
@@ -1633,7 +1639,7 @@ function parseResumeSubscriptionInstruction(instruction) {
1633
1639
  };
1634
1640
  }
1635
1641
 
1636
- // src/generated/instructions/revokeDelegation.ts
1642
+ // src/generated/instructions/revokeAbandonedDelegation.ts
1637
1643
  import {
1638
1644
  combineCodec as combineCodec25,
1639
1645
  getStructDecoder as getStructDecoder23,
@@ -1645,21 +1651,95 @@ import {
1645
1651
  transformEncoder as transformEncoder9
1646
1652
  } from "@solana/kit";
1647
1653
  import { getAccountMetaFactory as getAccountMetaFactory9 } from "@solana/program-client-core";
1654
+ var REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR = 15;
1655
+ function getRevokeAbandonedDelegationDiscriminatorBytes() {
1656
+ return getU8Encoder14().encode(REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR);
1657
+ }
1658
+ function getRevokeAbandonedDelegationInstructionDataEncoder() {
1659
+ return transformEncoder9(getStructEncoder23([["discriminator", getU8Encoder14()]]), (value) => ({
1660
+ ...value,
1661
+ discriminator: REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR
1662
+ }));
1663
+ }
1664
+ function getRevokeAbandonedDelegationInstructionDataDecoder() {
1665
+ return getStructDecoder23([["discriminator", getU8Decoder14()]]);
1666
+ }
1667
+ function getRevokeAbandonedDelegationInstructionDataCodec() {
1668
+ return combineCodec25(
1669
+ getRevokeAbandonedDelegationInstructionDataEncoder(),
1670
+ getRevokeAbandonedDelegationInstructionDataDecoder()
1671
+ );
1672
+ }
1673
+ function getRevokeAbandonedDelegationInstruction(input, config) {
1674
+ const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
1675
+ const originalAccounts = {
1676
+ payer: { value: input.payer ?? null, isWritable: true },
1677
+ delegationAccount: { value: input.delegationAccount ?? null, isWritable: true },
1678
+ subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false }
1679
+ };
1680
+ const accounts = originalAccounts;
1681
+ const getAccountMeta = getAccountMetaFactory9(programAddress, "programId");
1682
+ return Object.freeze({
1683
+ accounts: [
1684
+ getAccountMeta("payer", accounts.payer),
1685
+ getAccountMeta("delegationAccount", accounts.delegationAccount),
1686
+ getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority)
1687
+ ],
1688
+ data: getRevokeAbandonedDelegationInstructionDataEncoder().encode({}),
1689
+ programAddress
1690
+ });
1691
+ }
1692
+ function parseRevokeAbandonedDelegationInstruction(instruction) {
1693
+ if (instruction.accounts.length < 3) {
1694
+ throw new SolanaError9(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS9, {
1695
+ actualAccountMetas: instruction.accounts.length,
1696
+ expectedAccountMetas: 3
1697
+ });
1698
+ }
1699
+ let accountIndex = 0;
1700
+ const getNextAccount = () => {
1701
+ const accountMeta = instruction.accounts[accountIndex];
1702
+ accountIndex += 1;
1703
+ return accountMeta;
1704
+ };
1705
+ return {
1706
+ programAddress: instruction.programAddress,
1707
+ accounts: {
1708
+ payer: getNextAccount(),
1709
+ delegationAccount: getNextAccount(),
1710
+ subscriptionAuthority: getNextAccount()
1711
+ },
1712
+ data: getRevokeAbandonedDelegationInstructionDataDecoder().decode(instruction.data)
1713
+ };
1714
+ }
1715
+
1716
+ // src/generated/instructions/revokeDelegation.ts
1717
+ import {
1718
+ combineCodec as combineCodec26,
1719
+ getStructDecoder as getStructDecoder24,
1720
+ getStructEncoder as getStructEncoder24,
1721
+ getU8Decoder as getU8Decoder15,
1722
+ getU8Encoder as getU8Encoder15,
1723
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS10,
1724
+ SolanaError as SolanaError10,
1725
+ transformEncoder as transformEncoder10
1726
+ } from "@solana/kit";
1727
+ import { getAccountMetaFactory as getAccountMetaFactory10 } from "@solana/program-client-core";
1648
1728
  var REVOKE_DELEGATION_DISCRIMINATOR = 3;
1649
1729
  function getRevokeDelegationDiscriminatorBytes() {
1650
- return getU8Encoder14().encode(REVOKE_DELEGATION_DISCRIMINATOR);
1730
+ return getU8Encoder15().encode(REVOKE_DELEGATION_DISCRIMINATOR);
1651
1731
  }
1652
1732
  function getRevokeDelegationInstructionDataEncoder() {
1653
- return transformEncoder9(getStructEncoder23([["discriminator", getU8Encoder14()]]), (value) => ({
1733
+ return transformEncoder10(getStructEncoder24([["discriminator", getU8Encoder15()]]), (value) => ({
1654
1734
  ...value,
1655
1735
  discriminator: REVOKE_DELEGATION_DISCRIMINATOR
1656
1736
  }));
1657
1737
  }
1658
1738
  function getRevokeDelegationInstructionDataDecoder() {
1659
- return getStructDecoder23([["discriminator", getU8Decoder14()]]);
1739
+ return getStructDecoder24([["discriminator", getU8Decoder15()]]);
1660
1740
  }
1661
1741
  function getRevokeDelegationInstructionDataCodec() {
1662
- return combineCodec25(getRevokeDelegationInstructionDataEncoder(), getRevokeDelegationInstructionDataDecoder());
1742
+ return combineCodec26(getRevokeDelegationInstructionDataEncoder(), getRevokeDelegationInstructionDataDecoder());
1663
1743
  }
1664
1744
  function getRevokeDelegationInstruction(input, config) {
1665
1745
  const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
@@ -1668,7 +1748,7 @@ function getRevokeDelegationInstruction(input, config) {
1668
1748
  delegationAccount: { value: input.delegationAccount ?? null, isWritable: true }
1669
1749
  };
1670
1750
  const accounts = originalAccounts;
1671
- const getAccountMeta = getAccountMetaFactory9(programAddress, "programId");
1751
+ const getAccountMeta = getAccountMetaFactory10(programAddress, "programId");
1672
1752
  return Object.freeze({
1673
1753
  accounts: [
1674
1754
  getAccountMeta("authority", accounts.authority),
@@ -1680,7 +1760,7 @@ function getRevokeDelegationInstruction(input, config) {
1680
1760
  }
1681
1761
  function parseRevokeDelegationInstruction(instruction) {
1682
1762
  if (instruction.accounts.length < 2) {
1683
- throw new SolanaError9(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS9, {
1763
+ throw new SolanaError10(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS10, {
1684
1764
  actualAccountMetas: instruction.accounts.length,
1685
1765
  expectedAccountMetas: 2
1686
1766
  });
@@ -1698,42 +1778,119 @@ function parseRevokeDelegationInstruction(instruction) {
1698
1778
  };
1699
1779
  }
1700
1780
 
1781
+ // src/generated/instructions/revokeSubscriptionAuthority.ts
1782
+ import {
1783
+ combineCodec as combineCodec27,
1784
+ getStructDecoder as getStructDecoder25,
1785
+ getStructEncoder as getStructEncoder25,
1786
+ getU8Decoder as getU8Decoder16,
1787
+ getU8Encoder as getU8Encoder16,
1788
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS11,
1789
+ SolanaError as SolanaError11,
1790
+ transformEncoder as transformEncoder11
1791
+ } from "@solana/kit";
1792
+ import { getAccountMetaFactory as getAccountMetaFactory11 } from "@solana/program-client-core";
1793
+ var REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR = 14;
1794
+ function getRevokeSubscriptionAuthorityDiscriminatorBytes() {
1795
+ return getU8Encoder16().encode(REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR);
1796
+ }
1797
+ function getRevokeSubscriptionAuthorityInstructionDataEncoder() {
1798
+ return transformEncoder11(getStructEncoder25([["discriminator", getU8Encoder16()]]), (value) => ({
1799
+ ...value,
1800
+ discriminator: REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR
1801
+ }));
1802
+ }
1803
+ function getRevokeSubscriptionAuthorityInstructionDataDecoder() {
1804
+ return getStructDecoder25([["discriminator", getU8Decoder16()]]);
1805
+ }
1806
+ function getRevokeSubscriptionAuthorityInstructionDataCodec() {
1807
+ return combineCodec27(
1808
+ getRevokeSubscriptionAuthorityInstructionDataEncoder(),
1809
+ getRevokeSubscriptionAuthorityInstructionDataDecoder()
1810
+ );
1811
+ }
1812
+ function getRevokeSubscriptionAuthorityInstruction(input, config) {
1813
+ const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
1814
+ const originalAccounts = {
1815
+ user: { value: input.user ?? null, isWritable: false },
1816
+ userAta: { value: input.userAta ?? null, isWritable: true },
1817
+ tokenMint: { value: input.tokenMint ?? null, isWritable: false },
1818
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }
1819
+ };
1820
+ const accounts = originalAccounts;
1821
+ const getAccountMeta = getAccountMetaFactory11(programAddress, "programId");
1822
+ return Object.freeze({
1823
+ accounts: [
1824
+ getAccountMeta("user", accounts.user),
1825
+ getAccountMeta("userAta", accounts.userAta),
1826
+ getAccountMeta("tokenMint", accounts.tokenMint),
1827
+ getAccountMeta("tokenProgram", accounts.tokenProgram)
1828
+ ],
1829
+ data: getRevokeSubscriptionAuthorityInstructionDataEncoder().encode({}),
1830
+ programAddress
1831
+ });
1832
+ }
1833
+ function parseRevokeSubscriptionAuthorityInstruction(instruction) {
1834
+ if (instruction.accounts.length < 4) {
1835
+ throw new SolanaError11(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS11, {
1836
+ actualAccountMetas: instruction.accounts.length,
1837
+ expectedAccountMetas: 4
1838
+ });
1839
+ }
1840
+ let accountIndex = 0;
1841
+ const getNextAccount = () => {
1842
+ const accountMeta = instruction.accounts[accountIndex];
1843
+ accountIndex += 1;
1844
+ return accountMeta;
1845
+ };
1846
+ return {
1847
+ programAddress: instruction.programAddress,
1848
+ accounts: {
1849
+ user: getNextAccount(),
1850
+ userAta: getNextAccount(),
1851
+ tokenMint: getNextAccount(),
1852
+ tokenProgram: getNextAccount()
1853
+ },
1854
+ data: getRevokeSubscriptionAuthorityInstructionDataDecoder().decode(instruction.data)
1855
+ };
1856
+ }
1857
+
1701
1858
  // src/generated/instructions/subscribe.ts
1702
1859
  import {
1703
- combineCodec as combineCodec26,
1704
- getStructDecoder as getStructDecoder24,
1705
- getStructEncoder as getStructEncoder24,
1706
- getU8Decoder as getU8Decoder15,
1707
- getU8Encoder as getU8Encoder15,
1708
- SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS10,
1709
- SolanaError as SolanaError10,
1710
- transformEncoder as transformEncoder10
1860
+ combineCodec as combineCodec28,
1861
+ getStructDecoder as getStructDecoder26,
1862
+ getStructEncoder as getStructEncoder26,
1863
+ getU8Decoder as getU8Decoder17,
1864
+ getU8Encoder as getU8Encoder17,
1865
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS12,
1866
+ SolanaError as SolanaError12,
1867
+ transformEncoder as transformEncoder12
1711
1868
  } from "@solana/kit";
1712
1869
  import {
1713
- getAccountMetaFactory as getAccountMetaFactory10,
1870
+ getAccountMetaFactory as getAccountMetaFactory12,
1714
1871
  getAddressFromResolvedInstructionAccount as getAddressFromResolvedInstructionAccount4
1715
1872
  } from "@solana/program-client-core";
1716
1873
  var SUBSCRIBE_DISCRIMINATOR = 11;
1717
1874
  function getSubscribeDiscriminatorBytes() {
1718
- return getU8Encoder15().encode(SUBSCRIBE_DISCRIMINATOR);
1875
+ return getU8Encoder17().encode(SUBSCRIBE_DISCRIMINATOR);
1719
1876
  }
1720
1877
  function getSubscribeInstructionDataEncoder() {
1721
- return transformEncoder10(
1722
- getStructEncoder24([
1723
- ["discriminator", getU8Encoder15()],
1878
+ return transformEncoder12(
1879
+ getStructEncoder26([
1880
+ ["discriminator", getU8Encoder17()],
1724
1881
  ["subscribeData", getSubscribeDataEncoder()]
1725
1882
  ]),
1726
1883
  (value) => ({ ...value, discriminator: SUBSCRIBE_DISCRIMINATOR })
1727
1884
  );
1728
1885
  }
1729
1886
  function getSubscribeInstructionDataDecoder() {
1730
- return getStructDecoder24([
1731
- ["discriminator", getU8Decoder15()],
1887
+ return getStructDecoder26([
1888
+ ["discriminator", getU8Decoder17()],
1732
1889
  ["subscribeData", getSubscribeDataDecoder()]
1733
1890
  ]);
1734
1891
  }
1735
1892
  function getSubscribeInstructionDataCodec() {
1736
- return combineCodec26(getSubscribeInstructionDataEncoder(), getSubscribeInstructionDataDecoder());
1893
+ return combineCodec28(getSubscribeInstructionDataEncoder(), getSubscribeInstructionDataDecoder());
1737
1894
  }
1738
1895
  async function getSubscribeInstructionAsync(input, config) {
1739
1896
  const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
@@ -1764,7 +1921,7 @@ async function getSubscribeInstructionAsync(input, config) {
1764
1921
  if (!accounts.selfProgram.value) {
1765
1922
  accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
1766
1923
  }
1767
- const getAccountMeta = getAccountMetaFactory10(programAddress, "programId");
1924
+ const getAccountMeta = getAccountMetaFactory12(programAddress, "programId");
1768
1925
  return Object.freeze({
1769
1926
  accounts: [
1770
1927
  getAccountMeta("subscriber", accounts.subscriber),
@@ -1803,7 +1960,7 @@ function getSubscribeInstruction(input, config) {
1803
1960
  if (!accounts.selfProgram.value) {
1804
1961
  accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
1805
1962
  }
1806
- const getAccountMeta = getAccountMetaFactory10(programAddress, "programId");
1963
+ const getAccountMeta = getAccountMetaFactory12(programAddress, "programId");
1807
1964
  return Object.freeze({
1808
1965
  accounts: [
1809
1966
  getAccountMeta("subscriber", accounts.subscriber),
@@ -1821,7 +1978,7 @@ function getSubscribeInstruction(input, config) {
1821
1978
  }
1822
1979
  function parseSubscribeInstruction(instruction) {
1823
1980
  if (instruction.accounts.length < 8) {
1824
- throw new SolanaError10(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS10, {
1981
+ throw new SolanaError12(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS12, {
1825
1982
  actualAccountMetas: instruction.accounts.length,
1826
1983
  expectedAccountMetas: 8
1827
1984
  });
@@ -1850,37 +2007,37 @@ function parseSubscribeInstruction(instruction) {
1850
2007
 
1851
2008
  // src/generated/instructions/transferFixed.ts
1852
2009
  import {
1853
- combineCodec as combineCodec27,
1854
- getStructDecoder as getStructDecoder25,
1855
- getStructEncoder as getStructEncoder25,
1856
- getU8Decoder as getU8Decoder16,
1857
- getU8Encoder as getU8Encoder16,
1858
- SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS11,
1859
- SolanaError as SolanaError11,
1860
- transformEncoder as transformEncoder11
2010
+ combineCodec as combineCodec29,
2011
+ getStructDecoder as getStructDecoder27,
2012
+ getStructEncoder as getStructEncoder27,
2013
+ getU8Decoder as getU8Decoder18,
2014
+ getU8Encoder as getU8Encoder18,
2015
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS13,
2016
+ SolanaError as SolanaError13,
2017
+ transformEncoder as transformEncoder13
1861
2018
  } from "@solana/kit";
1862
- import { getAccountMetaFactory as getAccountMetaFactory11 } from "@solana/program-client-core";
2019
+ import { getAccountMetaFactory as getAccountMetaFactory13 } from "@solana/program-client-core";
1863
2020
  var TRANSFER_FIXED_DISCRIMINATOR = 4;
1864
2021
  function getTransferFixedDiscriminatorBytes() {
1865
- return getU8Encoder16().encode(TRANSFER_FIXED_DISCRIMINATOR);
2022
+ return getU8Encoder18().encode(TRANSFER_FIXED_DISCRIMINATOR);
1866
2023
  }
1867
2024
  function getTransferFixedInstructionDataEncoder() {
1868
- return transformEncoder11(
1869
- getStructEncoder25([
1870
- ["discriminator", getU8Encoder16()],
2025
+ return transformEncoder13(
2026
+ getStructEncoder27([
2027
+ ["discriminator", getU8Encoder18()],
1871
2028
  ["transferData", getTransferDataEncoder()]
1872
2029
  ]),
1873
2030
  (value) => ({ ...value, discriminator: TRANSFER_FIXED_DISCRIMINATOR })
1874
2031
  );
1875
2032
  }
1876
2033
  function getTransferFixedInstructionDataDecoder() {
1877
- return getStructDecoder25([
1878
- ["discriminator", getU8Decoder16()],
2034
+ return getStructDecoder27([
2035
+ ["discriminator", getU8Decoder18()],
1879
2036
  ["transferData", getTransferDataDecoder()]
1880
2037
  ]);
1881
2038
  }
1882
2039
  function getTransferFixedInstructionDataCodec() {
1883
- return combineCodec27(getTransferFixedInstructionDataEncoder(), getTransferFixedInstructionDataDecoder());
2040
+ return combineCodec29(getTransferFixedInstructionDataEncoder(), getTransferFixedInstructionDataDecoder());
1884
2041
  }
1885
2042
  function getTransferFixedInstruction(input, config) {
1886
2043
  const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
@@ -1889,6 +2046,7 @@ function getTransferFixedInstruction(input, config) {
1889
2046
  subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
1890
2047
  delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
1891
2048
  receiverAta: { value: input.receiverAta ?? null, isWritable: true },
2049
+ tokenMint: { value: input.tokenMint ?? null, isWritable: false },
1892
2050
  tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
1893
2051
  delegatee: { value: input.delegatee ?? null, isWritable: false },
1894
2052
  eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
@@ -1902,13 +2060,14 @@ function getTransferFixedInstruction(input, config) {
1902
2060
  if (!accounts.selfProgram.value) {
1903
2061
  accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
1904
2062
  }
1905
- const getAccountMeta = getAccountMetaFactory11(programAddress, "programId");
2063
+ const getAccountMeta = getAccountMetaFactory13(programAddress, "programId");
1906
2064
  return Object.freeze({
1907
2065
  accounts: [
1908
2066
  getAccountMeta("delegationPda", accounts.delegationPda),
1909
2067
  getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
1910
2068
  getAccountMeta("delegatorAta", accounts.delegatorAta),
1911
2069
  getAccountMeta("receiverAta", accounts.receiverAta),
2070
+ getAccountMeta("tokenMint", accounts.tokenMint),
1912
2071
  getAccountMeta("tokenProgram", accounts.tokenProgram),
1913
2072
  getAccountMeta("delegatee", accounts.delegatee),
1914
2073
  getAccountMeta("eventAuthority", accounts.eventAuthority),
@@ -1919,10 +2078,10 @@ function getTransferFixedInstruction(input, config) {
1919
2078
  });
1920
2079
  }
1921
2080
  function parseTransferFixedInstruction(instruction) {
1922
- if (instruction.accounts.length < 8) {
1923
- throw new SolanaError11(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS11, {
2081
+ if (instruction.accounts.length < 9) {
2082
+ throw new SolanaError13(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS13, {
1924
2083
  actualAccountMetas: instruction.accounts.length,
1925
- expectedAccountMetas: 8
2084
+ expectedAccountMetas: 9
1926
2085
  });
1927
2086
  }
1928
2087
  let accountIndex = 0;
@@ -1938,6 +2097,7 @@ function parseTransferFixedInstruction(instruction) {
1938
2097
  subscriptionAuthority: getNextAccount(),
1939
2098
  delegatorAta: getNextAccount(),
1940
2099
  receiverAta: getNextAccount(),
2100
+ tokenMint: getNextAccount(),
1941
2101
  tokenProgram: getNextAccount(),
1942
2102
  delegatee: getNextAccount(),
1943
2103
  eventAuthority: getNextAccount(),
@@ -1949,37 +2109,37 @@ function parseTransferFixedInstruction(instruction) {
1949
2109
 
1950
2110
  // src/generated/instructions/transferRecurring.ts
1951
2111
  import {
1952
- combineCodec as combineCodec28,
1953
- getStructDecoder as getStructDecoder26,
1954
- getStructEncoder as getStructEncoder26,
1955
- getU8Decoder as getU8Decoder17,
1956
- getU8Encoder as getU8Encoder17,
1957
- SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS12,
1958
- SolanaError as SolanaError12,
1959
- transformEncoder as transformEncoder12
2112
+ combineCodec as combineCodec30,
2113
+ getStructDecoder as getStructDecoder28,
2114
+ getStructEncoder as getStructEncoder28,
2115
+ getU8Decoder as getU8Decoder19,
2116
+ getU8Encoder as getU8Encoder19,
2117
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS14,
2118
+ SolanaError as SolanaError14,
2119
+ transformEncoder as transformEncoder14
1960
2120
  } from "@solana/kit";
1961
- import { getAccountMetaFactory as getAccountMetaFactory12 } from "@solana/program-client-core";
2121
+ import { getAccountMetaFactory as getAccountMetaFactory14 } from "@solana/program-client-core";
1962
2122
  var TRANSFER_RECURRING_DISCRIMINATOR = 5;
1963
2123
  function getTransferRecurringDiscriminatorBytes() {
1964
- return getU8Encoder17().encode(TRANSFER_RECURRING_DISCRIMINATOR);
2124
+ return getU8Encoder19().encode(TRANSFER_RECURRING_DISCRIMINATOR);
1965
2125
  }
1966
2126
  function getTransferRecurringInstructionDataEncoder() {
1967
- return transformEncoder12(
1968
- getStructEncoder26([
1969
- ["discriminator", getU8Encoder17()],
2127
+ return transformEncoder14(
2128
+ getStructEncoder28([
2129
+ ["discriminator", getU8Encoder19()],
1970
2130
  ["transferData", getTransferDataEncoder()]
1971
2131
  ]),
1972
2132
  (value) => ({ ...value, discriminator: TRANSFER_RECURRING_DISCRIMINATOR })
1973
2133
  );
1974
2134
  }
1975
2135
  function getTransferRecurringInstructionDataDecoder() {
1976
- return getStructDecoder26([
1977
- ["discriminator", getU8Decoder17()],
2136
+ return getStructDecoder28([
2137
+ ["discriminator", getU8Decoder19()],
1978
2138
  ["transferData", getTransferDataDecoder()]
1979
2139
  ]);
1980
2140
  }
1981
2141
  function getTransferRecurringInstructionDataCodec() {
1982
- return combineCodec28(getTransferRecurringInstructionDataEncoder(), getTransferRecurringInstructionDataDecoder());
2142
+ return combineCodec30(getTransferRecurringInstructionDataEncoder(), getTransferRecurringInstructionDataDecoder());
1983
2143
  }
1984
2144
  function getTransferRecurringInstruction(input, config) {
1985
2145
  const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
@@ -1988,6 +2148,7 @@ function getTransferRecurringInstruction(input, config) {
1988
2148
  subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
1989
2149
  delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
1990
2150
  receiverAta: { value: input.receiverAta ?? null, isWritable: true },
2151
+ tokenMint: { value: input.tokenMint ?? null, isWritable: false },
1991
2152
  tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
1992
2153
  delegatee: { value: input.delegatee ?? null, isWritable: false },
1993
2154
  eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
@@ -2001,13 +2162,14 @@ function getTransferRecurringInstruction(input, config) {
2001
2162
  if (!accounts.selfProgram.value) {
2002
2163
  accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
2003
2164
  }
2004
- const getAccountMeta = getAccountMetaFactory12(programAddress, "programId");
2165
+ const getAccountMeta = getAccountMetaFactory14(programAddress, "programId");
2005
2166
  return Object.freeze({
2006
2167
  accounts: [
2007
2168
  getAccountMeta("delegationPda", accounts.delegationPda),
2008
2169
  getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
2009
2170
  getAccountMeta("delegatorAta", accounts.delegatorAta),
2010
2171
  getAccountMeta("receiverAta", accounts.receiverAta),
2172
+ getAccountMeta("tokenMint", accounts.tokenMint),
2011
2173
  getAccountMeta("tokenProgram", accounts.tokenProgram),
2012
2174
  getAccountMeta("delegatee", accounts.delegatee),
2013
2175
  getAccountMeta("eventAuthority", accounts.eventAuthority),
@@ -2018,10 +2180,10 @@ function getTransferRecurringInstruction(input, config) {
2018
2180
  });
2019
2181
  }
2020
2182
  function parseTransferRecurringInstruction(instruction) {
2021
- if (instruction.accounts.length < 8) {
2022
- throw new SolanaError12(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS12, {
2183
+ if (instruction.accounts.length < 9) {
2184
+ throw new SolanaError14(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS14, {
2023
2185
  actualAccountMetas: instruction.accounts.length,
2024
- expectedAccountMetas: 8
2186
+ expectedAccountMetas: 9
2025
2187
  });
2026
2188
  }
2027
2189
  let accountIndex = 0;
@@ -2037,6 +2199,7 @@ function parseTransferRecurringInstruction(instruction) {
2037
2199
  subscriptionAuthority: getNextAccount(),
2038
2200
  delegatorAta: getNextAccount(),
2039
2201
  receiverAta: getNextAccount(),
2202
+ tokenMint: getNextAccount(),
2040
2203
  tokenProgram: getNextAccount(),
2041
2204
  delegatee: getNextAccount(),
2042
2205
  eventAuthority: getNextAccount(),
@@ -2048,37 +2211,37 @@ function parseTransferRecurringInstruction(instruction) {
2048
2211
 
2049
2212
  // src/generated/instructions/transferSubscription.ts
2050
2213
  import {
2051
- combineCodec as combineCodec29,
2052
- getStructDecoder as getStructDecoder27,
2053
- getStructEncoder as getStructEncoder27,
2054
- getU8Decoder as getU8Decoder18,
2055
- getU8Encoder as getU8Encoder18,
2056
- SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS13,
2057
- SolanaError as SolanaError13,
2058
- transformEncoder as transformEncoder13
2214
+ combineCodec as combineCodec31,
2215
+ getStructDecoder as getStructDecoder29,
2216
+ getStructEncoder as getStructEncoder29,
2217
+ getU8Decoder as getU8Decoder20,
2218
+ getU8Encoder as getU8Encoder20,
2219
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS15,
2220
+ SolanaError as SolanaError15,
2221
+ transformEncoder as transformEncoder15
2059
2222
  } from "@solana/kit";
2060
- import { getAccountMetaFactory as getAccountMetaFactory13 } from "@solana/program-client-core";
2223
+ import { getAccountMetaFactory as getAccountMetaFactory15 } from "@solana/program-client-core";
2061
2224
  var TRANSFER_SUBSCRIPTION_DISCRIMINATOR = 10;
2062
2225
  function getTransferSubscriptionDiscriminatorBytes() {
2063
- return getU8Encoder18().encode(TRANSFER_SUBSCRIPTION_DISCRIMINATOR);
2226
+ return getU8Encoder20().encode(TRANSFER_SUBSCRIPTION_DISCRIMINATOR);
2064
2227
  }
2065
2228
  function getTransferSubscriptionInstructionDataEncoder() {
2066
- return transformEncoder13(
2067
- getStructEncoder27([
2068
- ["discriminator", getU8Encoder18()],
2229
+ return transformEncoder15(
2230
+ getStructEncoder29([
2231
+ ["discriminator", getU8Encoder20()],
2069
2232
  ["transferData", getTransferDataEncoder()]
2070
2233
  ]),
2071
2234
  (value) => ({ ...value, discriminator: TRANSFER_SUBSCRIPTION_DISCRIMINATOR })
2072
2235
  );
2073
2236
  }
2074
2237
  function getTransferSubscriptionInstructionDataDecoder() {
2075
- return getStructDecoder27([
2076
- ["discriminator", getU8Decoder18()],
2238
+ return getStructDecoder29([
2239
+ ["discriminator", getU8Decoder20()],
2077
2240
  ["transferData", getTransferDataDecoder()]
2078
2241
  ]);
2079
2242
  }
2080
2243
  function getTransferSubscriptionInstructionDataCodec() {
2081
- return combineCodec29(
2244
+ return combineCodec31(
2082
2245
  getTransferSubscriptionInstructionDataEncoder(),
2083
2246
  getTransferSubscriptionInstructionDataDecoder()
2084
2247
  );
@@ -2092,6 +2255,7 @@ function getTransferSubscriptionInstruction(input, config) {
2092
2255
  delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
2093
2256
  receiverAta: { value: input.receiverAta ?? null, isWritable: true },
2094
2257
  caller: { value: input.caller ?? null, isWritable: false },
2258
+ tokenMint: { value: input.tokenMint ?? null, isWritable: false },
2095
2259
  tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
2096
2260
  eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
2097
2261
  selfProgram: { value: input.selfProgram ?? null, isWritable: false }
@@ -2104,7 +2268,7 @@ function getTransferSubscriptionInstruction(input, config) {
2104
2268
  if (!accounts.selfProgram.value) {
2105
2269
  accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
2106
2270
  }
2107
- const getAccountMeta = getAccountMetaFactory13(programAddress, "programId");
2271
+ const getAccountMeta = getAccountMetaFactory15(programAddress, "programId");
2108
2272
  return Object.freeze({
2109
2273
  accounts: [
2110
2274
  getAccountMeta("subscriptionPda", accounts.subscriptionPda),
@@ -2113,6 +2277,7 @@ function getTransferSubscriptionInstruction(input, config) {
2113
2277
  getAccountMeta("delegatorAta", accounts.delegatorAta),
2114
2278
  getAccountMeta("receiverAta", accounts.receiverAta),
2115
2279
  getAccountMeta("caller", accounts.caller),
2280
+ getAccountMeta("tokenMint", accounts.tokenMint),
2116
2281
  getAccountMeta("tokenProgram", accounts.tokenProgram),
2117
2282
  getAccountMeta("eventAuthority", accounts.eventAuthority),
2118
2283
  getAccountMeta("selfProgram", accounts.selfProgram)
@@ -2122,10 +2287,10 @@ function getTransferSubscriptionInstruction(input, config) {
2122
2287
  });
2123
2288
  }
2124
2289
  function parseTransferSubscriptionInstruction(instruction) {
2125
- if (instruction.accounts.length < 9) {
2126
- throw new SolanaError13(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS13, {
2290
+ if (instruction.accounts.length < 10) {
2291
+ throw new SolanaError15(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS15, {
2127
2292
  actualAccountMetas: instruction.accounts.length,
2128
- expectedAccountMetas: 9
2293
+ expectedAccountMetas: 10
2129
2294
  });
2130
2295
  }
2131
2296
  let accountIndex = 0;
@@ -2143,6 +2308,7 @@ function parseTransferSubscriptionInstruction(instruction) {
2143
2308
  delegatorAta: getNextAccount(),
2144
2309
  receiverAta: getNextAccount(),
2145
2310
  caller: getNextAccount(),
2311
+ tokenMint: getNextAccount(),
2146
2312
  tokenProgram: getNextAccount(),
2147
2313
  eventAuthority: getNextAccount(),
2148
2314
  selfProgram: getNextAccount()
@@ -2153,37 +2319,37 @@ function parseTransferSubscriptionInstruction(instruction) {
2153
2319
 
2154
2320
  // src/generated/instructions/updatePlan.ts
2155
2321
  import {
2156
- combineCodec as combineCodec30,
2157
- getStructDecoder as getStructDecoder28,
2158
- getStructEncoder as getStructEncoder28,
2159
- getU8Decoder as getU8Decoder19,
2160
- getU8Encoder as getU8Encoder19,
2161
- SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS14,
2162
- SolanaError as SolanaError14,
2163
- transformEncoder as transformEncoder14
2322
+ combineCodec as combineCodec32,
2323
+ getStructDecoder as getStructDecoder30,
2324
+ getStructEncoder as getStructEncoder30,
2325
+ getU8Decoder as getU8Decoder21,
2326
+ getU8Encoder as getU8Encoder21,
2327
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS16,
2328
+ SolanaError as SolanaError16,
2329
+ transformEncoder as transformEncoder16
2164
2330
  } from "@solana/kit";
2165
- import { getAccountMetaFactory as getAccountMetaFactory14 } from "@solana/program-client-core";
2331
+ import { getAccountMetaFactory as getAccountMetaFactory16 } from "@solana/program-client-core";
2166
2332
  var UPDATE_PLAN_DISCRIMINATOR = 8;
2167
2333
  function getUpdatePlanDiscriminatorBytes() {
2168
- return getU8Encoder19().encode(UPDATE_PLAN_DISCRIMINATOR);
2334
+ return getU8Encoder21().encode(UPDATE_PLAN_DISCRIMINATOR);
2169
2335
  }
2170
2336
  function getUpdatePlanInstructionDataEncoder() {
2171
- return transformEncoder14(
2172
- getStructEncoder28([
2173
- ["discriminator", getU8Encoder19()],
2337
+ return transformEncoder16(
2338
+ getStructEncoder30([
2339
+ ["discriminator", getU8Encoder21()],
2174
2340
  ["updatePlanData", getUpdatePlanDataEncoder()]
2175
2341
  ]),
2176
2342
  (value) => ({ ...value, discriminator: UPDATE_PLAN_DISCRIMINATOR })
2177
2343
  );
2178
2344
  }
2179
2345
  function getUpdatePlanInstructionDataDecoder() {
2180
- return getStructDecoder28([
2181
- ["discriminator", getU8Decoder19()],
2346
+ return getStructDecoder30([
2347
+ ["discriminator", getU8Decoder21()],
2182
2348
  ["updatePlanData", getUpdatePlanDataDecoder()]
2183
2349
  ]);
2184
2350
  }
2185
2351
  function getUpdatePlanInstructionDataCodec() {
2186
- return combineCodec30(getUpdatePlanInstructionDataEncoder(), getUpdatePlanInstructionDataDecoder());
2352
+ return combineCodec32(getUpdatePlanInstructionDataEncoder(), getUpdatePlanInstructionDataDecoder());
2187
2353
  }
2188
2354
  function getUpdatePlanInstruction(input, config) {
2189
2355
  const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
@@ -2193,7 +2359,7 @@ function getUpdatePlanInstruction(input, config) {
2193
2359
  };
2194
2360
  const accounts = originalAccounts;
2195
2361
  const args = { ...input };
2196
- const getAccountMeta = getAccountMetaFactory14(programAddress, "programId");
2362
+ const getAccountMeta = getAccountMetaFactory16(programAddress, "programId");
2197
2363
  return Object.freeze({
2198
2364
  accounts: [getAccountMeta("owner", accounts.owner), getAccountMeta("planPda", accounts.planPda)],
2199
2365
  data: getUpdatePlanInstructionDataEncoder().encode(args),
@@ -2202,7 +2368,7 @@ function getUpdatePlanInstruction(input, config) {
2202
2368
  }
2203
2369
  function parseUpdatePlanInstruction(instruction) {
2204
2370
  if (instruction.accounts.length < 2) {
2205
- throw new SolanaError14(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS14, {
2371
+ throw new SolanaError16(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS16, {
2206
2372
  actualAccountMetas: instruction.accounts.length,
2207
2373
  expectedAccountMetas: 2
2208
2374
  });
@@ -2246,53 +2412,61 @@ var SubscriptionsInstruction = /* @__PURE__ */ ((SubscriptionsInstruction2) => {
2246
2412
  SubscriptionsInstruction2[SubscriptionsInstruction2["Subscribe"] = 11] = "Subscribe";
2247
2413
  SubscriptionsInstruction2[SubscriptionsInstruction2["CancelSubscription"] = 12] = "CancelSubscription";
2248
2414
  SubscriptionsInstruction2[SubscriptionsInstruction2["ResumeSubscription"] = 13] = "ResumeSubscription";
2415
+ SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeSubscriptionAuthority"] = 14] = "RevokeSubscriptionAuthority";
2416
+ SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeAbandonedDelegation"] = 15] = "RevokeAbandonedDelegation";
2249
2417
  return SubscriptionsInstruction2;
2250
2418
  })(SubscriptionsInstruction || {});
2251
2419
  function identifySubscriptionsInstruction(instruction) {
2252
2420
  const data = "data" in instruction ? instruction.data : instruction;
2253
- if (containsBytes(data, getU8Encoder20().encode(0), 0)) {
2421
+ if (containsBytes(data, getU8Encoder22().encode(0), 0)) {
2254
2422
  return 0 /* InitSubscriptionAuthority */;
2255
2423
  }
2256
- if (containsBytes(data, getU8Encoder20().encode(1), 0)) {
2424
+ if (containsBytes(data, getU8Encoder22().encode(1), 0)) {
2257
2425
  return 1 /* CreateFixedDelegation */;
2258
2426
  }
2259
- if (containsBytes(data, getU8Encoder20().encode(2), 0)) {
2427
+ if (containsBytes(data, getU8Encoder22().encode(2), 0)) {
2260
2428
  return 2 /* CreateRecurringDelegation */;
2261
2429
  }
2262
- if (containsBytes(data, getU8Encoder20().encode(3), 0)) {
2430
+ if (containsBytes(data, getU8Encoder22().encode(3), 0)) {
2263
2431
  return 3 /* RevokeDelegation */;
2264
2432
  }
2265
- if (containsBytes(data, getU8Encoder20().encode(4), 0)) {
2433
+ if (containsBytes(data, getU8Encoder22().encode(4), 0)) {
2266
2434
  return 4 /* TransferFixed */;
2267
2435
  }
2268
- if (containsBytes(data, getU8Encoder20().encode(5), 0)) {
2436
+ if (containsBytes(data, getU8Encoder22().encode(5), 0)) {
2269
2437
  return 5 /* TransferRecurring */;
2270
2438
  }
2271
- if (containsBytes(data, getU8Encoder20().encode(6), 0)) {
2439
+ if (containsBytes(data, getU8Encoder22().encode(6), 0)) {
2272
2440
  return 6 /* CloseSubscriptionAuthority */;
2273
2441
  }
2274
- if (containsBytes(data, getU8Encoder20().encode(7), 0)) {
2442
+ if (containsBytes(data, getU8Encoder22().encode(7), 0)) {
2275
2443
  return 7 /* CreatePlan */;
2276
2444
  }
2277
- if (containsBytes(data, getU8Encoder20().encode(8), 0)) {
2445
+ if (containsBytes(data, getU8Encoder22().encode(8), 0)) {
2278
2446
  return 8 /* UpdatePlan */;
2279
2447
  }
2280
- if (containsBytes(data, getU8Encoder20().encode(9), 0)) {
2448
+ if (containsBytes(data, getU8Encoder22().encode(9), 0)) {
2281
2449
  return 9 /* DeletePlan */;
2282
2450
  }
2283
- if (containsBytes(data, getU8Encoder20().encode(10), 0)) {
2451
+ if (containsBytes(data, getU8Encoder22().encode(10), 0)) {
2284
2452
  return 10 /* TransferSubscription */;
2285
2453
  }
2286
- if (containsBytes(data, getU8Encoder20().encode(11), 0)) {
2454
+ if (containsBytes(data, getU8Encoder22().encode(11), 0)) {
2287
2455
  return 11 /* Subscribe */;
2288
2456
  }
2289
- if (containsBytes(data, getU8Encoder20().encode(12), 0)) {
2457
+ if (containsBytes(data, getU8Encoder22().encode(12), 0)) {
2290
2458
  return 12 /* CancelSubscription */;
2291
2459
  }
2292
- if (containsBytes(data, getU8Encoder20().encode(13), 0)) {
2460
+ if (containsBytes(data, getU8Encoder22().encode(13), 0)) {
2293
2461
  return 13 /* ResumeSubscription */;
2294
2462
  }
2295
- throw new SolanaError15(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
2463
+ if (containsBytes(data, getU8Encoder22().encode(14), 0)) {
2464
+ return 14 /* RevokeSubscriptionAuthority */;
2465
+ }
2466
+ if (containsBytes(data, getU8Encoder22().encode(15), 0)) {
2467
+ return 15 /* RevokeAbandonedDelegation */;
2468
+ }
2469
+ throw new SolanaError17(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
2296
2470
  instructionData: data,
2297
2471
  programName: "subscriptions"
2298
2472
  });
@@ -2386,8 +2560,22 @@ function parseSubscriptionsInstruction(instruction) {
2386
2560
  ...parseResumeSubscriptionInstruction(instruction)
2387
2561
  };
2388
2562
  }
2563
+ case 14 /* RevokeSubscriptionAuthority */: {
2564
+ assertIsInstructionWithAccounts(instruction);
2565
+ return {
2566
+ instructionType: 14 /* RevokeSubscriptionAuthority */,
2567
+ ...parseRevokeSubscriptionAuthorityInstruction(instruction)
2568
+ };
2569
+ }
2570
+ case 15 /* RevokeAbandonedDelegation */: {
2571
+ assertIsInstructionWithAccounts(instruction);
2572
+ return {
2573
+ instructionType: 15 /* RevokeAbandonedDelegation */,
2574
+ ...parseRevokeAbandonedDelegationInstruction(instruction)
2575
+ };
2576
+ }
2389
2577
  default:
2390
- throw new SolanaError15(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
2578
+ throw new SolanaError17(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
2391
2579
  instructionType,
2392
2580
  programName: "subscriptions"
2393
2581
  });
@@ -2419,7 +2607,9 @@ function subscriptionsProgram() {
2419
2607
  transferSubscription: (input) => addSelfPlanAndSendFunctions(client, getTransferSubscriptionInstruction(input)),
2420
2608
  subscribe: (input) => addSelfPlanAndSendFunctions(client, getSubscribeInstructionAsync(input)),
2421
2609
  cancelSubscription: (input) => addSelfPlanAndSendFunctions(client, getCancelSubscriptionInstructionAsync(input)),
2422
- resumeSubscription: (input) => addSelfPlanAndSendFunctions(client, getResumeSubscriptionInstructionAsync(input))
2610
+ resumeSubscription: (input) => addSelfPlanAndSendFunctions(client, getResumeSubscriptionInstructionAsync(input)),
2611
+ revokeSubscriptionAuthority: (input) => addSelfPlanAndSendFunctions(client, getRevokeSubscriptionAuthorityInstruction(input)),
2612
+ revokeAbandonedDelegation: (input) => addSelfPlanAndSendFunctions(client, getRevokeAbandonedDelegationInstruction(input))
2423
2613
  },
2424
2614
  pdas: {
2425
2615
  fixedDelegation: findFixedDelegationPda,
@@ -2472,6 +2662,8 @@ var SUBSCRIPTIONS_ERROR__DELEGATION_VERSION_MISMATCH = 133;
2472
2662
  var SUBSCRIPTIONS_ERROR__MIGRATION_REQUIRED = 134;
2473
2663
  var SUBSCRIPTIONS_ERROR__DELEGATION_ALREADY_EXISTS = 135;
2474
2664
  var SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY = 136;
2665
+ var SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS = 137;
2666
+ var SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_VALIDATION_ACCOUNT_MISSING = 138;
2475
2667
  var SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_LIMIT = 300;
2476
2668
  var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_EXPIRY_IN_PAST = 301;
2477
2669
  var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_AMOUNT_ZERO = 302;
@@ -2483,6 +2675,7 @@ var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST = 404;
2483
2675
  var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY = 405;
2484
2676
  var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO = 406;
2485
2677
  var SUBSCRIPTIONS_ERROR__DELEGATION_NOT_STARTED = 407;
2678
+ var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY = 408;
2486
2679
  var SUBSCRIPTIONS_ERROR__PLAN_SUNSET = 500;
2487
2680
  var SUBSCRIPTIONS_ERROR__PLAN_EXPIRED = 501;
2488
2681
  var SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA = 502;
@@ -2572,6 +2765,7 @@ if (process.env["NODE_ENV"] !== "production") {
2572
2765
  [SUBSCRIPTIONS_ERROR__PLAN_SUNSET]: `Plan is in sunset status`,
2573
2766
  [SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH]: `Subscription plan terms do not match the current plan`,
2574
2767
  [SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO]: `zero amount specified`,
2768
+ [SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY]: `start_ts of 0 (start on landing) requires a non-zero expiry`,
2575
2769
  [SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY]: `start time specified is greater than expiry`,
2576
2770
  [SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST]: `Past start time specified`,
2577
2771
  [SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY]: `Delegation init_id does not match current SubscriptionAuthority`,
@@ -2580,6 +2774,8 @@ if (process.env["NODE_ENV"] !== "production") {
2580
2774
  [SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED]: `Subscription is not cancelled`,
2581
2775
  [SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH]: `Subscription does not belong to this plan`,
2582
2776
  [SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS]: `Sunset requires a non-zero end timestamp`,
2777
+ [SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS]: `Too many transfer hook accounts provided`,
2778
+ [SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_VALIDATION_ACCOUNT_MISSING]: `Transfer hook validation account missing from provided accounts`,
2583
2779
  [SUBSCRIPTIONS_ERROR__UNAUTHORIZED]: `Caller not authorized for this action`,
2584
2780
  [SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION]: `Destination not in plan whitelist`
2585
2781
  };
@@ -2734,12 +2930,156 @@ async function fetchSubscriptionsForUser(rpc, user, programAddress) {
2734
2930
 
2735
2931
  // src/plugin.ts
2736
2932
  import {
2737
- AccountRole,
2933
+ AccountRole as AccountRole2,
2738
2934
  pipe
2739
2935
  } from "@solana/kit";
2740
2936
  import { addSelfPlanAndSendFunctions as addSelfPlanAndSendFunctions2 } from "@solana/program-client-core";
2741
2937
  import { findAssociatedTokenPda } from "@solana-program/token";
2742
2938
 
2939
+ // src/transfer-hook.ts
2940
+ import {
2941
+ AccountRole,
2942
+ fetchEncodedAccount as fetchEncodedAccount7,
2943
+ getAddressDecoder as getAddressDecoder10,
2944
+ getAddressEncoder as getAddressEncoder15,
2945
+ getProgramDerivedAddress as getProgramDerivedAddress7
2946
+ } from "@solana/kit";
2947
+ import { fetchMint, TOKEN_2022_PROGRAM_ADDRESS } from "@solana-program/token-2022";
2948
+ var DEFAULT_ADDRESS = "11111111111111111111111111111111";
2949
+ var EXTRA_ACCOUNT_METAS_SEED = "extra-account-metas";
2950
+ var TLV_HEADER_LEN = 12;
2951
+ var POD_SLICE_COUNT_LEN = 4;
2952
+ var EXTRA_ACCOUNT_META_LEN = 35;
2953
+ var PUBKEY_LEN = 32;
2954
+ var PDA_PROGRAM_INDEX_OFFSET = 1 << 7;
2955
+ var EXECUTE_DISCRIMINATOR = Uint8Array.from([105, 37, 101, 197, 75, 251, 102, 26]);
2956
+ var addressDecoder = getAddressDecoder10();
2957
+ var addressEncoder = getAddressEncoder15();
2958
+ function roleFor(isSigner, isWritable) {
2959
+ if (isSigner && isWritable) return AccountRole.WRITABLE_SIGNER;
2960
+ if (isSigner) return AccountRole.READONLY_SIGNER;
2961
+ if (isWritable) return AccountRole.WRITABLE;
2962
+ return AccountRole.READONLY;
2963
+ }
2964
+ async function fetchData(rpc, address) {
2965
+ const account = await fetchEncodedAccount7(rpc, address);
2966
+ if (!account.exists) throw new Error("transfer hook: referenced account not found");
2967
+ return account.data;
2968
+ }
2969
+ function executeInstructionData(amount) {
2970
+ const data = new Uint8Array(EXECUTE_DISCRIMINATOR.length + 8);
2971
+ data.set(EXECUTE_DISCRIMINATOR, 0);
2972
+ new DataView(data.buffer).setBigUint64(EXECUTE_DISCRIMINATOR.length, BigInt(amount), true);
2973
+ return data;
2974
+ }
2975
+ function readMetas(data) {
2976
+ if (data.length < TLV_HEADER_LEN || !EXECUTE_DISCRIMINATOR.every((byte, i) => data[i] === byte)) {
2977
+ return [];
2978
+ }
2979
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
2980
+ const count = view.getUint32(TLV_HEADER_LEN, true);
2981
+ const metas = [];
2982
+ let offset = TLV_HEADER_LEN + POD_SLICE_COUNT_LEN;
2983
+ for (let n = 0; n < count && offset + EXTRA_ACCOUNT_META_LEN <= data.length; n++) {
2984
+ metas.push({
2985
+ addressConfig: data.subarray(offset + 1, offset + 33),
2986
+ discriminator: data[offset],
2987
+ isSigner: data[offset + 33] === 1,
2988
+ isWritable: data[offset + 34] === 1
2989
+ });
2990
+ offset += EXTRA_ACCOUNT_META_LEN;
2991
+ }
2992
+ return metas;
2993
+ }
2994
+ async function unpackSeeds(config, previous, instructionData, rpc) {
2995
+ const seeds = [];
2996
+ let i = 0;
2997
+ while (i < 32) {
2998
+ const discriminator = config[i];
2999
+ const rest = config.subarray(i + 1);
3000
+ if (discriminator === 0) break;
3001
+ if (discriminator === 1) {
3002
+ const length = rest[0];
3003
+ seeds.push(rest.subarray(1, 1 + length));
3004
+ i += 2 + length;
3005
+ } else if (discriminator === 2) {
3006
+ const [index, length] = [rest[0], rest[1]];
3007
+ seeds.push(instructionData.subarray(index, index + length));
3008
+ i += 3;
3009
+ } else if (discriminator === 3) {
3010
+ seeds.push(addressEncoder.encode(previous[rest[0]].address));
3011
+ i += 2;
3012
+ } else if (discriminator === 4) {
3013
+ const [accountIndex, dataIndex, length] = [rest[0], rest[1], rest[2]];
3014
+ const data = await fetchData(rpc, previous[accountIndex].address);
3015
+ seeds.push(data.subarray(dataIndex, dataIndex + length));
3016
+ i += 4;
3017
+ } else {
3018
+ throw new Error("transfer hook: invalid seed");
3019
+ }
3020
+ }
3021
+ return seeds;
3022
+ }
3023
+ async function unpackPubkeyData(config, previous, instructionData, rpc) {
3024
+ const rest = config.subarray(1);
3025
+ if (config[0] === 1) {
3026
+ const offset = rest[0];
3027
+ return addressDecoder.decode(instructionData.subarray(offset, offset + PUBKEY_LEN));
3028
+ }
3029
+ if (config[0] === 2) {
3030
+ const [accountIndex, offset] = [rest[0], rest[1]];
3031
+ const data = await fetchData(rpc, previous[accountIndex].address);
3032
+ return addressDecoder.decode(data.subarray(offset, offset + PUBKEY_LEN));
3033
+ }
3034
+ throw new Error("transfer hook: invalid pubkey data");
3035
+ }
3036
+ async function resolveMeta(meta, previous, instructionData, hookProgram, rpc) {
3037
+ const role = roleFor(meta.isSigner, meta.isWritable);
3038
+ if (meta.discriminator === 0) {
3039
+ return { address: addressDecoder.decode(meta.addressConfig), role };
3040
+ }
3041
+ if (meta.discriminator === 2) {
3042
+ return { address: await unpackPubkeyData(meta.addressConfig, previous, instructionData, rpc), role };
3043
+ }
3044
+ const programId = meta.discriminator === 1 ? hookProgram : previous[meta.discriminator - PDA_PROGRAM_INDEX_OFFSET].address;
3045
+ const seeds = await unpackSeeds(meta.addressConfig, previous, instructionData, rpc);
3046
+ const [pda] = await getProgramDerivedAddress7({ programAddress: programId, seeds });
3047
+ return { address: pda, role };
3048
+ }
3049
+ async function resolveTransferHookAccounts(rpc, args) {
3050
+ if (args.transferHookAccounts?.length) return args.transferHookAccounts;
3051
+ if (args.tokenProgram !== TOKEN_2022_PROGRAM_ADDRESS) return [];
3052
+ const { data } = await fetchMint(rpc, args.mint);
3053
+ const extensions = data.extensions.__option === "Some" ? data.extensions.value : [];
3054
+ const hook = extensions.find((extension) => extension.__kind === "TransferHook");
3055
+ if (!hook || hook.programId === DEFAULT_ADDRESS) return [];
3056
+ const hookProgram = hook.programId;
3057
+ const [validationPda] = await getProgramDerivedAddress7({
3058
+ programAddress: hookProgram,
3059
+ seeds: [EXTRA_ACCOUNT_METAS_SEED, addressEncoder.encode(args.mint)]
3060
+ });
3061
+ const trailing = [
3062
+ { address: hookProgram, role: AccountRole.READONLY },
3063
+ { address: validationPda, role: AccountRole.READONLY }
3064
+ ];
3065
+ const validationAccount = await fetchEncodedAccount7(rpc, validationPda);
3066
+ if (!validationAccount.exists) return trailing;
3067
+ const instructionData = executeInstructionData(args.amount);
3068
+ const previous = [
3069
+ { address: args.source, role: AccountRole.READONLY },
3070
+ { address: args.mint, role: AccountRole.READONLY },
3071
+ { address: args.destination, role: AccountRole.READONLY },
3072
+ { address: args.authority, role: AccountRole.READONLY },
3073
+ { address: validationPda, role: AccountRole.READONLY }
3074
+ ];
3075
+ for (const meta of readMetas(validationAccount.data)) {
3076
+ const resolved = await resolveMeta(meta, previous, instructionData, hookProgram, rpc);
3077
+ previous.push(resolved);
3078
+ trailing.push(resolved);
3079
+ }
3080
+ return trailing;
3081
+ }
3082
+
2743
3083
  // src/validators.ts
2744
3084
  var textEncoder = new TextEncoder();
2745
3085
  var ValidationError = class extends Error {
@@ -2751,6 +3091,10 @@ var ValidationError = class extends Error {
2751
3091
  function assertPositive(value, name) {
2752
3092
  if (BigInt(value) <= 0n) throw new ValidationError(`${name} must be greater than zero`);
2753
3093
  }
3094
+ function assertSafeU64(value, name) {
3095
+ if (typeof value === "number" && !Number.isSafeInteger(value))
3096
+ throw new ValidationError(`${name} must be a bigint or a safe integer (numbers above 2^53-1 lose precision)`);
3097
+ }
2754
3098
  function assertMetadataUri(metadataUri) {
2755
3099
  if (textEncoder.encode(metadataUri).length > METADATA_URI_LEN)
2756
3100
  throw new ValidationError(`metadataUri exceeds ${METADATA_URI_LEN} bytes`);
@@ -2787,7 +3131,7 @@ function appendPayer(instruction, payer) {
2787
3131
  return withTrailing(instruction, [
2788
3132
  {
2789
3133
  address: payer.address,
2790
- role: AccountRole.WRITABLE_SIGNER,
3134
+ role: AccountRole2.WRITABLE_SIGNER,
2791
3135
  signer: payer
2792
3136
  }
2793
3137
  ]);
@@ -2816,12 +3160,33 @@ async function getCloseSubscriptionAuthorityOverlayInstructionAsync(input) {
2816
3160
  pdaConfig(input.programAddress)
2817
3161
  );
2818
3162
  if (input.receiver) {
2819
- ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole.WRITABLE }]);
3163
+ ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole2.WRITABLE }]);
2820
3164
  }
2821
3165
  return ix;
2822
3166
  }
3167
+ async function getRevokeSubscriptionAuthorityOverlayInstructionAsync(input) {
3168
+ const [userAta] = await findAssociatedTokenPda({
3169
+ mint: input.tokenMint,
3170
+ owner: input.user.address,
3171
+ tokenProgram: input.tokenProgram
3172
+ });
3173
+ return getRevokeSubscriptionAuthorityInstruction(
3174
+ {
3175
+ tokenMint: input.tokenMint,
3176
+ tokenProgram: input.tokenProgram,
3177
+ user: input.user,
3178
+ userAta
3179
+ },
3180
+ pdaConfig(input.programAddress)
3181
+ );
3182
+ }
2823
3183
  async function getCreateFixedDelegationOverlayInstructionAsync(input) {
2824
3184
  assertPositive(input.amount, "amount");
3185
+ if (input.expectedSubscriptionAuthorityInitId === void 0) {
3186
+ throw new Error(
3187
+ "getCreateFixedDelegationOverlayInstructionAsync requires expectedSubscriptionAuthorityInitId. Use the plugin client `subscriptions.instructions.createFixedDelegation(...)` to auto-fetch from the live authority."
3188
+ );
3189
+ }
2825
3190
  const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
2826
3191
  { tokenMint: input.tokenMint, user: input.delegator.address },
2827
3192
  pdaConfig(input.programAddress)
@@ -2843,6 +3208,7 @@ async function getCreateFixedDelegationOverlayInstructionAsync(input) {
2843
3208
  delegator: input.delegator,
2844
3209
  fixedDelegation: {
2845
3210
  amount: input.amount,
3211
+ expectedSubscriptionAuthorityInitId: input.expectedSubscriptionAuthorityInitId,
2846
3212
  expiryTs: input.expiryTs,
2847
3213
  nonce: input.nonce
2848
3214
  },
@@ -2856,6 +3222,11 @@ async function getCreateFixedDelegationOverlayInstructionAsync(input) {
2856
3222
  async function getCreateRecurringDelegationOverlayInstructionAsync(input) {
2857
3223
  assertPositive(input.amountPerPeriod, "amountPerPeriod");
2858
3224
  assertPositive(input.periodLengthS, "periodLengthS");
3225
+ if (input.expectedSubscriptionAuthorityInitId === void 0) {
3226
+ throw new Error(
3227
+ "getCreateRecurringDelegationOverlayInstructionAsync requires expectedSubscriptionAuthorityInitId. Use the plugin client `subscriptions.instructions.createRecurringDelegation(...)` to auto-fetch from the live authority."
3228
+ );
3229
+ }
2859
3230
  const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
2860
3231
  { tokenMint: input.tokenMint, user: input.delegator.address },
2861
3232
  pdaConfig(input.programAddress)
@@ -2877,6 +3248,7 @@ async function getCreateRecurringDelegationOverlayInstructionAsync(input) {
2877
3248
  delegator: input.delegator,
2878
3249
  recurringDelegation: {
2879
3250
  amountPerPeriod: input.amountPerPeriod,
3251
+ expectedSubscriptionAuthorityInitId: input.expectedSubscriptionAuthorityInitId,
2880
3252
  expiryTs: input.expiryTs,
2881
3253
  nonce: input.nonce,
2882
3254
  periodLengthS: input.periodLengthS,
@@ -2898,14 +3270,14 @@ function getRevokeDelegationOverlayInstruction(input) {
2898
3270
  pdaConfig(input.programAddress)
2899
3271
  );
2900
3272
  if (input.receiver) {
2901
- ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole.WRITABLE }]);
3273
+ ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole2.WRITABLE }]);
2902
3274
  }
2903
3275
  return ix;
2904
3276
  }
2905
3277
  function getRevokeSubscriptionOverlayInstruction(input) {
2906
- const trailing = [{ address: input.planPda, role: AccountRole.READONLY }];
3278
+ const trailing = [{ address: input.planPda, role: AccountRole2.READONLY }];
2907
3279
  if (input.receiver) {
2908
- trailing.push({ address: input.receiver, role: AccountRole.WRITABLE });
3280
+ trailing.push({ address: input.receiver, role: AccountRole2.WRITABLE });
2909
3281
  }
2910
3282
  return withTrailing(
2911
3283
  getRevokeDelegationInstruction(
@@ -2924,21 +3296,25 @@ async function getTransferDelegationOverlayInstructionAsync(input, getInstructio
2924
3296
  { tokenMint: input.tokenMint, user: input.delegator },
2925
3297
  pdaConfig(input.programAddress)
2926
3298
  );
2927
- return getInstruction(
2928
- {
2929
- delegatee: input.delegatee,
2930
- delegationPda: input.delegationPda,
2931
- delegatorAta: input.delegatorAta,
2932
- receiverAta: input.receiverAta,
2933
- subscriptionAuthority,
2934
- tokenProgram: input.tokenProgram,
2935
- transferData: {
2936
- amount: input.amount,
2937
- delegator: input.delegator,
2938
- mint: input.tokenMint
2939
- }
2940
- },
2941
- pdaConfig(input.programAddress)
3299
+ return withTrailing(
3300
+ getInstruction(
3301
+ {
3302
+ delegatee: input.delegatee,
3303
+ delegationPda: input.delegationPda,
3304
+ delegatorAta: input.delegatorAta,
3305
+ receiverAta: input.receiverAta,
3306
+ subscriptionAuthority,
3307
+ tokenMint: input.tokenMint,
3308
+ tokenProgram: input.tokenProgram,
3309
+ transferData: {
3310
+ amount: input.amount,
3311
+ delegator: input.delegator,
3312
+ mint: input.tokenMint
3313
+ }
3314
+ },
3315
+ pdaConfig(input.programAddress)
3316
+ ),
3317
+ input.transferHookAccounts ?? []
2942
3318
  );
2943
3319
  }
2944
3320
  function getTransferFixedOverlayInstructionAsync(input) {
@@ -2958,27 +3334,32 @@ async function getTransferSubscriptionOverlayInstructionAsync(input) {
2958
3334
  owner: input.delegator,
2959
3335
  tokenProgram: input.tokenProgram
2960
3336
  });
2961
- return getTransferSubscriptionInstruction(
2962
- {
2963
- caller: input.caller,
2964
- delegatorAta,
2965
- planPda: input.planPda,
2966
- receiverAta: input.receiverAta,
2967
- subscriptionAuthority,
2968
- subscriptionPda: input.subscriptionPda,
2969
- tokenProgram: input.tokenProgram,
2970
- transferData: {
2971
- amount: input.amount,
2972
- delegator: input.delegator,
2973
- mint: input.tokenMint
2974
- }
2975
- },
2976
- pdaConfig(input.programAddress)
3337
+ return withTrailing(
3338
+ getTransferSubscriptionInstruction(
3339
+ {
3340
+ caller: input.caller,
3341
+ delegatorAta,
3342
+ planPda: input.planPda,
3343
+ receiverAta: input.receiverAta,
3344
+ subscriptionAuthority,
3345
+ subscriptionPda: input.subscriptionPda,
3346
+ tokenMint: input.tokenMint,
3347
+ tokenProgram: input.tokenProgram,
3348
+ transferData: {
3349
+ amount: input.amount,
3350
+ delegator: input.delegator,
3351
+ mint: input.tokenMint
3352
+ }
3353
+ },
3354
+ pdaConfig(input.programAddress)
3355
+ ),
3356
+ input.transferHookAccounts ?? []
2977
3357
  );
2978
3358
  }
2979
3359
  async function getCreatePlanOverlayInstructionAsync(input) {
2980
3360
  assertPositive(input.amount, "amount");
2981
3361
  assertPositive(input.periodHours, "periodHours");
3362
+ assertSafeU64(input.planId, "planId");
2982
3363
  assertMetadataUri(input.metadataUri);
2983
3364
  const destinations = padPlanDestinations(input.destinations);
2984
3365
  const pullers = padPlanPullers(input.pullers);
@@ -3011,7 +3392,7 @@ async function getCreatePlanOverlayInstructionAsync(input) {
3011
3392
  }
3012
3393
  function getUpdatePlanOverlayInstruction(input) {
3013
3394
  assertMetadataUri(input.metadataUri);
3014
- const pullers = padPlanPullers(input.pullers ?? []);
3395
+ const pullers = padPlanPullers(input.pullers);
3015
3396
  return getUpdatePlanInstruction(
3016
3397
  {
3017
3398
  owner: input.owner,
@@ -3030,11 +3411,12 @@ function getDeletePlanOverlayInstruction(input) {
3030
3411
  return getDeletePlanInstruction({ owner: input.owner, planPda: input.planPda }, pdaConfig(input.programAddress));
3031
3412
  }
3032
3413
  async function getSubscribeOverlayInstructionAsync(input) {
3033
- if (input.expectedAmount === void 0 || input.expectedPeriodHours === void 0 || input.expectedCreatedAt === void 0) {
3414
+ if (input.expectedAmount === void 0 || input.expectedPeriodHours === void 0 || input.expectedCreatedAt === void 0 || input.expectedSubscriptionAuthorityInitId === void 0) {
3034
3415
  throw new Error(
3035
- "getSubscribeOverlayInstructionAsync requires expectedAmount, expectedPeriodHours, and expectedCreatedAt. Use the plugin client `subscriptions.instructions.subscribe(...)` to auto-fetch from the live plan."
3416
+ "getSubscribeOverlayInstructionAsync requires expectedAmount, expectedPeriodHours, expectedCreatedAt, and expectedSubscriptionAuthorityInitId. Use the plugin client `subscriptions.instructions.subscribe(...)` to auto-fetch from the live plan and authority."
3036
3417
  );
3037
3418
  }
3419
+ assertSafeU64(input.planId, "planId");
3038
3420
  const [planPda, planBump] = await findPlanPda(
3039
3421
  { owner: input.merchant, planId: input.planId },
3040
3422
  pdaConfig(input.programAddress)
@@ -3053,6 +3435,7 @@ async function getSubscribeOverlayInstructionAsync(input) {
3053
3435
  expectedCreatedAt: input.expectedCreatedAt,
3054
3436
  expectedMint: input.tokenMint,
3055
3437
  expectedPeriodHours: input.expectedPeriodHours,
3438
+ expectedSubscriptionAuthorityInitId: input.expectedSubscriptionAuthorityInitId,
3056
3439
  planBump,
3057
3440
  planId: input.planId
3058
3441
  },
@@ -3109,6 +3492,35 @@ function subscriptionsProgram2() {
3109
3492
  },
3110
3493
  plansForOwner: (owner) => fetchPlansForOwner(c.rpc, owner)
3111
3494
  };
3495
+ const resolveExpectedSubscriptionAuthorityInitId = async (tokenMint, user, programAddress, expectedSubscriptionAuthorityInitId) => {
3496
+ if (expectedSubscriptionAuthorityInitId !== void 0) {
3497
+ return expectedSubscriptionAuthorityInitId;
3498
+ }
3499
+ const [subscriptionAuthorityPda] = await findSubscriptionAuthorityPda(
3500
+ { tokenMint, user },
3501
+ pdaConfig(programAddress)
3502
+ );
3503
+ const subscriptionAuthority = await fetchMaybeSubscriptionAuthority(c.rpc, subscriptionAuthorityPda);
3504
+ if (!subscriptionAuthority.exists) {
3505
+ throw new Error("SubscriptionAuthority is not initialized for this delegator and token mint.");
3506
+ }
3507
+ return subscriptionAuthority.data.initId;
3508
+ };
3509
+ const resolveDelegationHookAccounts = async (input) => {
3510
+ const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
3511
+ { tokenMint: input.tokenMint, user: input.delegator },
3512
+ pdaConfig(input.programAddress)
3513
+ );
3514
+ return await resolveTransferHookAccounts(c.rpc, {
3515
+ amount: input.amount,
3516
+ authority: subscriptionAuthority,
3517
+ destination: input.receiverAta,
3518
+ mint: input.tokenMint,
3519
+ source: input.delegatorAta,
3520
+ tokenProgram: input.tokenProgram,
3521
+ transferHookAccounts: input.transferHookAccounts
3522
+ });
3523
+ };
3112
3524
  const instructions = {
3113
3525
  cancelSubscription: (input) => addSelfPlanAndSendFunctions2(
3114
3526
  client,
@@ -3126,11 +3538,21 @@ function subscriptionsProgram2() {
3126
3538
  ),
3127
3539
  createFixedDelegation: (input) => addSelfPlanAndSendFunctions2(
3128
3540
  client,
3129
- getCreateFixedDelegationOverlayInstructionAsync({
3130
- ...input,
3131
- delegator: input.delegator ?? client.identity,
3132
- payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer)
3133
- })
3541
+ (async () => {
3542
+ const delegator = input.delegator ?? client.identity;
3543
+ const expectedSubscriptionAuthorityInitId = await resolveExpectedSubscriptionAuthorityInitId(
3544
+ input.tokenMint,
3545
+ delegator.address,
3546
+ input.programAddress,
3547
+ input.expectedSubscriptionAuthorityInitId
3548
+ );
3549
+ return await getCreateFixedDelegationOverlayInstructionAsync({
3550
+ ...input,
3551
+ delegator,
3552
+ expectedSubscriptionAuthorityInitId,
3553
+ payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer)
3554
+ });
3555
+ })()
3134
3556
  ),
3135
3557
  createPlan: (input) => addSelfPlanAndSendFunctions2(
3136
3558
  client,
@@ -3141,11 +3563,21 @@ function subscriptionsProgram2() {
3141
3563
  ),
3142
3564
  createRecurringDelegation: (input) => addSelfPlanAndSendFunctions2(
3143
3565
  client,
3144
- getCreateRecurringDelegationOverlayInstructionAsync({
3145
- ...input,
3146
- delegator: input.delegator ?? client.identity,
3147
- payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer)
3148
- })
3566
+ (async () => {
3567
+ const delegator = input.delegator ?? client.identity;
3568
+ const expectedSubscriptionAuthorityInitId = await resolveExpectedSubscriptionAuthorityInitId(
3569
+ input.tokenMint,
3570
+ delegator.address,
3571
+ input.programAddress,
3572
+ input.expectedSubscriptionAuthorityInitId
3573
+ );
3574
+ return await getCreateRecurringDelegationOverlayInstructionAsync({
3575
+ ...input,
3576
+ delegator,
3577
+ expectedSubscriptionAuthorityInitId,
3578
+ payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer)
3579
+ });
3580
+ })()
3149
3581
  ),
3150
3582
  deletePlan: (input) => addSelfPlanAndSendFunctions2(
3151
3583
  client,
@@ -3183,12 +3615,25 @@ function subscriptionsProgram2() {
3183
3615
  authority: input.authority ?? client.identity
3184
3616
  })
3185
3617
  ),
3618
+ revokeSubscriptionAuthority: (input) => addSelfPlanAndSendFunctions2(
3619
+ client,
3620
+ getRevokeSubscriptionAuthorityOverlayInstructionAsync({
3621
+ ...input,
3622
+ user: input.user ?? client.identity
3623
+ })
3624
+ ),
3186
3625
  subscribe: (input) => addSelfPlanAndSendFunctions2(
3187
3626
  client,
3188
3627
  (async () => {
3189
- let { expectedAmount, expectedPeriodHours, expectedCreatedAt } = input;
3628
+ const subscriber = input.subscriber ?? client.identity;
3629
+ assertSafeU64(input.planId, "planId");
3630
+ let {
3631
+ expectedAmount,
3632
+ expectedCreatedAt,
3633
+ expectedPeriodHours,
3634
+ expectedSubscriptionAuthorityInitId
3635
+ } = input;
3190
3636
  if (expectedAmount === void 0 || expectedPeriodHours === void 0 || expectedCreatedAt === void 0) {
3191
- const subscriber = input.subscriber ?? client.identity;
3192
3637
  const [planPda] = await findPlanPda(
3193
3638
  { owner: input.merchant, planId: input.planId },
3194
3639
  pdaConfig(input.programAddress)
@@ -3197,45 +3642,77 @@ function subscriptionsProgram2() {
3197
3642
  expectedAmount = expectedAmount ?? plan.data.data.terms.amount;
3198
3643
  expectedPeriodHours = expectedPeriodHours ?? plan.data.data.terms.periodHours;
3199
3644
  expectedCreatedAt = expectedCreatedAt ?? plan.data.data.terms.createdAt;
3200
- return await getSubscribeOverlayInstructionAsync({
3201
- ...input,
3202
- expectedAmount,
3203
- expectedCreatedAt,
3204
- expectedPeriodHours,
3205
- payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer),
3206
- subscriber
3207
- });
3645
+ }
3646
+ if (expectedSubscriptionAuthorityInitId === void 0) {
3647
+ const [subscriptionAuthorityPda] = await findSubscriptionAuthorityPda(
3648
+ { tokenMint: input.tokenMint, user: subscriber.address },
3649
+ pdaConfig(input.programAddress)
3650
+ );
3651
+ const subscriptionAuthority = await fetchMaybeSubscriptionAuthority(
3652
+ c.rpc,
3653
+ subscriptionAuthorityPda
3654
+ );
3655
+ if (!subscriptionAuthority.exists) {
3656
+ throw new Error(
3657
+ "SubscriptionAuthority is not initialized for this subscriber and token mint."
3658
+ );
3659
+ }
3660
+ expectedSubscriptionAuthorityInitId = subscriptionAuthority.data.initId;
3208
3661
  }
3209
3662
  return await getSubscribeOverlayInstructionAsync({
3210
3663
  ...input,
3211
3664
  expectedAmount,
3212
3665
  expectedCreatedAt,
3213
3666
  expectedPeriodHours,
3667
+ expectedSubscriptionAuthorityInitId,
3214
3668
  payer: input.payer ?? (client.payer === client.identity ? void 0 : client.payer),
3215
- subscriber: input.subscriber ?? client.identity
3669
+ subscriber
3216
3670
  });
3217
3671
  })()
3218
3672
  ),
3219
3673
  transferFixed: (input) => addSelfPlanAndSendFunctions2(
3220
3674
  client,
3221
- getTransferFixedOverlayInstructionAsync({
3675
+ (async () => await getTransferFixedOverlayInstructionAsync({
3222
3676
  ...input,
3223
- delegatee: input.delegatee ?? client.identity
3224
- })
3677
+ delegatee: input.delegatee ?? client.identity,
3678
+ transferHookAccounts: await resolveDelegationHookAccounts(input)
3679
+ }))()
3225
3680
  ),
3226
3681
  transferRecurring: (input) => addSelfPlanAndSendFunctions2(
3227
3682
  client,
3228
- getTransferRecurringOverlayInstructionAsync({
3683
+ (async () => await getTransferRecurringOverlayInstructionAsync({
3229
3684
  ...input,
3230
- delegatee: input.delegatee ?? client.identity
3231
- })
3685
+ delegatee: input.delegatee ?? client.identity,
3686
+ transferHookAccounts: await resolveDelegationHookAccounts(input)
3687
+ }))()
3232
3688
  ),
3233
3689
  transferSubscription: (input) => addSelfPlanAndSendFunctions2(
3234
3690
  client,
3235
- getTransferSubscriptionOverlayInstructionAsync({
3236
- ...input,
3237
- caller: input.caller ?? client.identity
3238
- })
3691
+ (async () => {
3692
+ const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
3693
+ { tokenMint: input.tokenMint, user: input.delegator },
3694
+ pdaConfig(input.programAddress)
3695
+ );
3696
+ const [delegatorAta] = await findAssociatedTokenPda({
3697
+ mint: input.tokenMint,
3698
+ owner: input.delegator,
3699
+ tokenProgram: input.tokenProgram
3700
+ });
3701
+ const transferHookAccounts = await resolveTransferHookAccounts(c.rpc, {
3702
+ amount: input.amount,
3703
+ authority: subscriptionAuthority,
3704
+ destination: input.receiverAta,
3705
+ mint: input.tokenMint,
3706
+ source: delegatorAta,
3707
+ tokenProgram: input.tokenProgram,
3708
+ transferHookAccounts: input.transferHookAccounts
3709
+ });
3710
+ return await getTransferSubscriptionOverlayInstructionAsync({
3711
+ ...input,
3712
+ caller: input.caller ?? client.identity,
3713
+ transferHookAccounts
3714
+ });
3715
+ })()
3239
3716
  ),
3240
3717
  updatePlan: (input) => addSelfPlanAndSendFunctions2(
3241
3718
  client,
@@ -3280,7 +3757,9 @@ export {
3280
3757
  PROGRAM_ID,
3281
3758
  PlanStatus,
3282
3759
  RESUME_SUBSCRIPTION_DISCRIMINATOR,
3760
+ REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR,
3283
3761
  REVOKE_DELEGATION_DISCRIMINATOR,
3762
+ REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR,
3284
3763
  SUBSCRIBE_DISCRIMINATOR,
3285
3764
  SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE,
3286
3765
  SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED,
@@ -3344,6 +3823,7 @@ export {
3344
3823
  SUBSCRIPTIONS_ERROR__PLAN_SUNSET,
3345
3824
  SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH,
3346
3825
  SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO,
3826
+ SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY,
3347
3827
  SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY,
3348
3828
  SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST,
3349
3829
  SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY,
@@ -3352,6 +3832,8 @@ export {
3352
3832
  SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED,
3353
3833
  SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH,
3354
3834
  SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS,
3835
+ SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS,
3836
+ SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_VALIDATION_ACCOUNT_MISSING,
3355
3837
  SUBSCRIPTIONS_ERROR__UNAUTHORIZED,
3356
3838
  SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION,
3357
3839
  SUBSCRIPTIONS_PROGRAM_ADDRESS,
@@ -3504,12 +3986,23 @@ export {
3504
3986
  getResumeSubscriptionInstructionDataDecoder,
3505
3987
  getResumeSubscriptionInstructionDataEncoder,
3506
3988
  getResumeSubscriptionOverlayInstructionAsync,
3989
+ getRevokeAbandonedDelegationDiscriminatorBytes,
3990
+ getRevokeAbandonedDelegationInstruction,
3991
+ getRevokeAbandonedDelegationInstructionDataCodec,
3992
+ getRevokeAbandonedDelegationInstructionDataDecoder,
3993
+ getRevokeAbandonedDelegationInstructionDataEncoder,
3507
3994
  getRevokeDelegationDiscriminatorBytes,
3508
3995
  getRevokeDelegationInstruction,
3509
3996
  getRevokeDelegationInstructionDataCodec,
3510
3997
  getRevokeDelegationInstructionDataDecoder,
3511
3998
  getRevokeDelegationInstructionDataEncoder,
3512
3999
  getRevokeDelegationOverlayInstruction,
4000
+ getRevokeSubscriptionAuthorityDiscriminatorBytes,
4001
+ getRevokeSubscriptionAuthorityInstruction,
4002
+ getRevokeSubscriptionAuthorityInstructionDataCodec,
4003
+ getRevokeSubscriptionAuthorityInstructionDataDecoder,
4004
+ getRevokeSubscriptionAuthorityInstructionDataEncoder,
4005
+ getRevokeSubscriptionAuthorityOverlayInstructionAsync,
3513
4006
  getRevokeSubscriptionOverlayInstruction,
3514
4007
  getSubscribeDataCodec,
3515
4008
  getSubscribeDataDecoder,
@@ -3568,13 +4061,16 @@ export {
3568
4061
  parseDeletePlanInstruction,
3569
4062
  parseInitSubscriptionAuthorityInstruction,
3570
4063
  parseResumeSubscriptionInstruction,
4064
+ parseRevokeAbandonedDelegationInstruction,
3571
4065
  parseRevokeDelegationInstruction,
4066
+ parseRevokeSubscriptionAuthorityInstruction,
3572
4067
  parseSubscribeInstruction,
3573
4068
  parseSubscriptionsInstruction,
3574
4069
  parseTransferFixedInstruction,
3575
4070
  parseTransferRecurringInstruction,
3576
4071
  parseTransferSubscriptionInstruction,
3577
4072
  parseUpdatePlanInstruction,
4073
+ resolveTransferHookAccounts,
3578
4074
  subscriptionsProgram2 as subscriptionsProgram,
3579
4075
  toEncodedAccount
3580
4076
  };