@solana/subscriptions 0.3.0 → 0.4.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -862,10 +862,10 @@ import {
862
862
  assertIsInstructionWithAccounts,
863
863
  containsBytes,
864
864
  extendClient,
865
- getU8Encoder as getU8Encoder20,
865
+ getU8Encoder as getU8Encoder23,
866
866
  SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
867
867
  SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
868
- SolanaError as SolanaError15
868
+ SolanaError as SolanaError18
869
869
  } from "@solana/kit";
870
870
  import {
871
871
  addSelfFetchFunctions,
@@ -875,10 +875,12 @@ import {
875
875
  // src/generated/instructions/cancelSubscription.ts
876
876
  import {
877
877
  combineCodec as combineCodec17,
878
+ getProgramDerivedAddress as getProgramDerivedAddress7,
878
879
  getStructDecoder as getStructDecoder15,
879
880
  getStructEncoder as getStructEncoder15,
880
881
  getU8Decoder as getU8Decoder6,
881
882
  getU8Encoder as getU8Encoder6,
883
+ getUtf8Encoder as getUtf8Encoder9,
882
884
  SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
883
885
  SolanaError,
884
886
  transformEncoder
@@ -920,10 +922,14 @@ async function getCancelSubscriptionInstructionAsync(input, config) {
920
922
  });
921
923
  }
922
924
  if (!accounts.eventAuthority.value) {
923
- accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
925
+ accounts.eventAuthority.value = await getProgramDerivedAddress7({
926
+ programAddress,
927
+ seeds: [getUtf8Encoder9().encode("event_authority")]
928
+ });
924
929
  }
925
930
  if (!accounts.selfProgram.value) {
926
- accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
931
+ accounts.selfProgram.value = programAddress;
932
+ accounts.selfProgram.isWritable = false;
927
933
  }
928
934
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
929
935
  return Object.freeze({
@@ -948,11 +954,9 @@ function getCancelSubscriptionInstruction(input, config) {
948
954
  selfProgram: { value: input.selfProgram ?? null, isWritable: false }
949
955
  };
950
956
  const accounts = originalAccounts;
951
- if (!accounts.eventAuthority.value) {
952
- accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
953
- }
954
957
  if (!accounts.selfProgram.value) {
955
- accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
958
+ accounts.selfProgram.value = programAddress;
959
+ accounts.selfProgram.isWritable = false;
956
960
  }
957
961
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
958
962
  return Object.freeze({
@@ -1028,15 +1032,17 @@ function getCloseSubscriptionAuthorityInstruction(input, config) {
1028
1032
  const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
1029
1033
  const originalAccounts = {
1030
1034
  user: { value: input.user ?? null, isWritable: true },
1031
- subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: true }
1035
+ subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: true },
1036
+ receiver: { value: input.receiver ?? null, isWritable: true }
1032
1037
  };
1033
1038
  const accounts = originalAccounts;
1034
- const getAccountMeta = getAccountMetaFactory2(programAddress, "programId");
1039
+ const getAccountMeta = getAccountMetaFactory2(programAddress, "omitted");
1035
1040
  return Object.freeze({
1036
1041
  accounts: [
1037
1042
  getAccountMeta("user", accounts.user),
1038
- getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority)
1039
- ],
1043
+ getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
1044
+ getAccountMeta("receiver", accounts.receiver)
1045
+ ].filter((x) => x !== void 0),
1040
1046
  data: getCloseSubscriptionAuthorityInstructionDataEncoder().encode({}),
1041
1047
  programAddress
1042
1048
  });
@@ -1054,9 +1060,19 @@ function parseCloseSubscriptionAuthorityInstruction(instruction) {
1054
1060
  accountIndex += 1;
1055
1061
  return accountMeta;
1056
1062
  };
1063
+ let optionalAccountsRemaining = instruction.accounts.length - 2;
1064
+ const getNextOptionalAccount = () => {
1065
+ if (optionalAccountsRemaining === 0) return void 0;
1066
+ optionalAccountsRemaining -= 1;
1067
+ return getNextAccount();
1068
+ };
1057
1069
  return {
1058
1070
  programAddress: instruction.programAddress,
1059
- accounts: { user: getNextAccount(), subscriptionAuthority: getNextAccount() },
1071
+ accounts: {
1072
+ user: getNextAccount(),
1073
+ subscriptionAuthority: getNextAccount(),
1074
+ receiver: getNextOptionalAccount()
1075
+ },
1060
1076
  data: getCloseSubscriptionAuthorityInstructionDataDecoder().decode(instruction.data)
1061
1077
  };
1062
1078
  }
@@ -1105,22 +1121,24 @@ function getCreateFixedDelegationInstruction(input, config) {
1105
1121
  subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
1106
1122
  delegationAccount: { value: input.delegationAccount ?? null, isWritable: true },
1107
1123
  delegatee: { value: input.delegatee ?? null, isWritable: false },
1108
- systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1124
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1125
+ payer: { value: input.payer ?? null, isWritable: true }
1109
1126
  };
1110
1127
  const accounts = originalAccounts;
1111
1128
  const args = { ...input };
1112
1129
  if (!accounts.systemProgram.value) {
1113
1130
  accounts.systemProgram.value = "11111111111111111111111111111111";
1114
1131
  }
1115
- const getAccountMeta = getAccountMetaFactory3(programAddress, "programId");
1132
+ const getAccountMeta = getAccountMetaFactory3(programAddress, "omitted");
1116
1133
  return Object.freeze({
1117
1134
  accounts: [
1118
1135
  getAccountMeta("delegator", accounts.delegator),
1119
1136
  getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
1120
1137
  getAccountMeta("delegationAccount", accounts.delegationAccount),
1121
1138
  getAccountMeta("delegatee", accounts.delegatee),
1122
- getAccountMeta("systemProgram", accounts.systemProgram)
1123
- ],
1139
+ getAccountMeta("systemProgram", accounts.systemProgram),
1140
+ getAccountMeta("payer", accounts.payer)
1141
+ ].filter((x) => x !== void 0),
1124
1142
  data: getCreateFixedDelegationInstructionDataEncoder().encode(args),
1125
1143
  programAddress
1126
1144
  });
@@ -1138,6 +1156,12 @@ function parseCreateFixedDelegationInstruction(instruction) {
1138
1156
  accountIndex += 1;
1139
1157
  return accountMeta;
1140
1158
  };
1159
+ let optionalAccountsRemaining = instruction.accounts.length - 5;
1160
+ const getNextOptionalAccount = () => {
1161
+ if (optionalAccountsRemaining === 0) return void 0;
1162
+ optionalAccountsRemaining -= 1;
1163
+ return getNextAccount();
1164
+ };
1141
1165
  return {
1142
1166
  programAddress: instruction.programAddress,
1143
1167
  accounts: {
@@ -1145,7 +1169,8 @@ function parseCreateFixedDelegationInstruction(instruction) {
1145
1169
  subscriptionAuthority: getNextAccount(),
1146
1170
  delegationAccount: getNextAccount(),
1147
1171
  delegatee: getNextAccount(),
1148
- systemProgram: getNextAccount()
1172
+ systemProgram: getNextAccount(),
1173
+ payer: getNextOptionalAccount()
1149
1174
  },
1150
1175
  data: getCreateFixedDelegationInstructionDataDecoder().decode(instruction.data)
1151
1176
  };
@@ -1285,22 +1310,24 @@ function getCreateRecurringDelegationInstruction(input, config) {
1285
1310
  subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
1286
1311
  delegationAccount: { value: input.delegationAccount ?? null, isWritable: true },
1287
1312
  delegatee: { value: input.delegatee ?? null, isWritable: false },
1288
- systemProgram: { value: input.systemProgram ?? null, isWritable: false }
1313
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1314
+ payer: { value: input.payer ?? null, isWritable: true }
1289
1315
  };
1290
1316
  const accounts = originalAccounts;
1291
1317
  const args = { ...input };
1292
1318
  if (!accounts.systemProgram.value) {
1293
1319
  accounts.systemProgram.value = "11111111111111111111111111111111";
1294
1320
  }
1295
- const getAccountMeta = getAccountMetaFactory5(programAddress, "programId");
1321
+ const getAccountMeta = getAccountMetaFactory5(programAddress, "omitted");
1296
1322
  return Object.freeze({
1297
1323
  accounts: [
1298
1324
  getAccountMeta("delegator", accounts.delegator),
1299
1325
  getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
1300
1326
  getAccountMeta("delegationAccount", accounts.delegationAccount),
1301
1327
  getAccountMeta("delegatee", accounts.delegatee),
1302
- getAccountMeta("systemProgram", accounts.systemProgram)
1303
- ],
1328
+ getAccountMeta("systemProgram", accounts.systemProgram),
1329
+ getAccountMeta("payer", accounts.payer)
1330
+ ].filter((x) => x !== void 0),
1304
1331
  data: getCreateRecurringDelegationInstructionDataEncoder().encode(
1305
1332
  args
1306
1333
  ),
@@ -1320,6 +1347,12 @@ function parseCreateRecurringDelegationInstruction(instruction) {
1320
1347
  accountIndex += 1;
1321
1348
  return accountMeta;
1322
1349
  };
1350
+ let optionalAccountsRemaining = instruction.accounts.length - 5;
1351
+ const getNextOptionalAccount = () => {
1352
+ if (optionalAccountsRemaining === 0) return void 0;
1353
+ optionalAccountsRemaining -= 1;
1354
+ return getNextAccount();
1355
+ };
1323
1356
  return {
1324
1357
  programAddress: instruction.programAddress,
1325
1358
  accounts: {
@@ -1327,7 +1360,8 @@ function parseCreateRecurringDelegationInstruction(instruction) {
1327
1360
  subscriptionAuthority: getNextAccount(),
1328
1361
  delegationAccount: getNextAccount(),
1329
1362
  delegatee: getNextAccount(),
1330
- systemProgram: getNextAccount()
1363
+ systemProgram: getNextAccount(),
1364
+ payer: getNextOptionalAccount()
1331
1365
  },
1332
1366
  data: getCreateRecurringDelegationInstructionDataDecoder().decode(instruction.data)
1333
1367
  };
@@ -1437,7 +1471,8 @@ async function getInitSubscriptionAuthorityInstructionAsync(input, config) {
1437
1471
  tokenMint: { value: input.tokenMint ?? null, isWritable: false },
1438
1472
  userAta: { value: input.userAta ?? null, isWritable: true },
1439
1473
  systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1440
- tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }
1474
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
1475
+ payer: { value: input.payer ?? null, isWritable: true }
1441
1476
  };
1442
1477
  const accounts = originalAccounts;
1443
1478
  if (!accounts.subscriptionAuthority.value) {
@@ -1449,7 +1484,7 @@ async function getInitSubscriptionAuthorityInstructionAsync(input, config) {
1449
1484
  if (!accounts.systemProgram.value) {
1450
1485
  accounts.systemProgram.value = "11111111111111111111111111111111";
1451
1486
  }
1452
- const getAccountMeta = getAccountMetaFactory7(programAddress, "programId");
1487
+ const getAccountMeta = getAccountMetaFactory7(programAddress, "omitted");
1453
1488
  return Object.freeze({
1454
1489
  accounts: [
1455
1490
  getAccountMeta("owner", accounts.owner),
@@ -1457,8 +1492,9 @@ async function getInitSubscriptionAuthorityInstructionAsync(input, config) {
1457
1492
  getAccountMeta("tokenMint", accounts.tokenMint),
1458
1493
  getAccountMeta("userAta", accounts.userAta),
1459
1494
  getAccountMeta("systemProgram", accounts.systemProgram),
1460
- getAccountMeta("tokenProgram", accounts.tokenProgram)
1461
- ],
1495
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
1496
+ getAccountMeta("payer", accounts.payer)
1497
+ ].filter((x) => x !== void 0),
1462
1498
  data: getInitSubscriptionAuthorityInstructionDataEncoder().encode({}),
1463
1499
  programAddress
1464
1500
  });
@@ -1471,13 +1507,14 @@ function getInitSubscriptionAuthorityInstruction(input, config) {
1471
1507
  tokenMint: { value: input.tokenMint ?? null, isWritable: false },
1472
1508
  userAta: { value: input.userAta ?? null, isWritable: true },
1473
1509
  systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1474
- tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }
1510
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
1511
+ payer: { value: input.payer ?? null, isWritable: true }
1475
1512
  };
1476
1513
  const accounts = originalAccounts;
1477
1514
  if (!accounts.systemProgram.value) {
1478
1515
  accounts.systemProgram.value = "11111111111111111111111111111111";
1479
1516
  }
1480
- const getAccountMeta = getAccountMetaFactory7(programAddress, "programId");
1517
+ const getAccountMeta = getAccountMetaFactory7(programAddress, "omitted");
1481
1518
  return Object.freeze({
1482
1519
  accounts: [
1483
1520
  getAccountMeta("owner", accounts.owner),
@@ -1485,8 +1522,9 @@ function getInitSubscriptionAuthorityInstruction(input, config) {
1485
1522
  getAccountMeta("tokenMint", accounts.tokenMint),
1486
1523
  getAccountMeta("userAta", accounts.userAta),
1487
1524
  getAccountMeta("systemProgram", accounts.systemProgram),
1488
- getAccountMeta("tokenProgram", accounts.tokenProgram)
1489
- ],
1525
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
1526
+ getAccountMeta("payer", accounts.payer)
1527
+ ].filter((x) => x !== void 0),
1490
1528
  data: getInitSubscriptionAuthorityInstructionDataEncoder().encode({}),
1491
1529
  programAddress
1492
1530
  });
@@ -1504,6 +1542,12 @@ function parseInitSubscriptionAuthorityInstruction(instruction) {
1504
1542
  accountIndex += 1;
1505
1543
  return accountMeta;
1506
1544
  };
1545
+ let optionalAccountsRemaining = instruction.accounts.length - 6;
1546
+ const getNextOptionalAccount = () => {
1547
+ if (optionalAccountsRemaining === 0) return void 0;
1548
+ optionalAccountsRemaining -= 1;
1549
+ return getNextAccount();
1550
+ };
1507
1551
  return {
1508
1552
  programAddress: instruction.programAddress,
1509
1553
  accounts: {
@@ -1512,7 +1556,8 @@ function parseInitSubscriptionAuthorityInstruction(instruction) {
1512
1556
  tokenMint: getNextAccount(),
1513
1557
  userAta: getNextAccount(),
1514
1558
  systemProgram: getNextAccount(),
1515
- tokenProgram: getNextAccount()
1559
+ tokenProgram: getNextAccount(),
1560
+ payer: getNextOptionalAccount()
1516
1561
  },
1517
1562
  data: getInitSubscriptionAuthorityInstructionDataDecoder().decode(instruction.data)
1518
1563
  };
@@ -1521,10 +1566,12 @@ function parseInitSubscriptionAuthorityInstruction(instruction) {
1521
1566
  // src/generated/instructions/resumeSubscription.ts
1522
1567
  import {
1523
1568
  combineCodec as combineCodec24,
1569
+ getProgramDerivedAddress as getProgramDerivedAddress8,
1524
1570
  getStructDecoder as getStructDecoder22,
1525
1571
  getStructEncoder as getStructEncoder22,
1526
1572
  getU8Decoder as getU8Decoder13,
1527
1573
  getU8Encoder as getU8Encoder13,
1574
+ getUtf8Encoder as getUtf8Encoder10,
1528
1575
  SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS8,
1529
1576
  SolanaError as SolanaError8,
1530
1577
  transformEncoder as transformEncoder8
@@ -1555,6 +1602,7 @@ async function getResumeSubscriptionInstructionAsync(input, config) {
1555
1602
  subscriber: { value: input.subscriber ?? null, isWritable: false },
1556
1603
  planPda: { value: input.planPda ?? null, isWritable: false },
1557
1604
  subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
1605
+ subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
1558
1606
  eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
1559
1607
  selfProgram: { value: input.selfProgram ?? null, isWritable: false }
1560
1608
  };
@@ -1566,10 +1614,14 @@ async function getResumeSubscriptionInstructionAsync(input, config) {
1566
1614
  });
1567
1615
  }
1568
1616
  if (!accounts.eventAuthority.value) {
1569
- accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
1617
+ accounts.eventAuthority.value = await getProgramDerivedAddress8({
1618
+ programAddress,
1619
+ seeds: [getUtf8Encoder10().encode("event_authority")]
1620
+ });
1570
1621
  }
1571
1622
  if (!accounts.selfProgram.value) {
1572
- accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
1623
+ accounts.selfProgram.value = programAddress;
1624
+ accounts.selfProgram.isWritable = false;
1573
1625
  }
1574
1626
  const getAccountMeta = getAccountMetaFactory8(programAddress, "programId");
1575
1627
  return Object.freeze({
@@ -1577,6 +1629,7 @@ async function getResumeSubscriptionInstructionAsync(input, config) {
1577
1629
  getAccountMeta("subscriber", accounts.subscriber),
1578
1630
  getAccountMeta("planPda", accounts.planPda),
1579
1631
  getAccountMeta("subscriptionPda", accounts.subscriptionPda),
1632
+ getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
1580
1633
  getAccountMeta("eventAuthority", accounts.eventAuthority),
1581
1634
  getAccountMeta("selfProgram", accounts.selfProgram)
1582
1635
  ],
@@ -1590,15 +1643,14 @@ function getResumeSubscriptionInstruction(input, config) {
1590
1643
  subscriber: { value: input.subscriber ?? null, isWritable: false },
1591
1644
  planPda: { value: input.planPda ?? null, isWritable: false },
1592
1645
  subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
1646
+ subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
1593
1647
  eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
1594
1648
  selfProgram: { value: input.selfProgram ?? null, isWritable: false }
1595
1649
  };
1596
1650
  const accounts = originalAccounts;
1597
- if (!accounts.eventAuthority.value) {
1598
- accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
1599
- }
1600
1651
  if (!accounts.selfProgram.value) {
1601
- accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
1652
+ accounts.selfProgram.value = programAddress;
1653
+ accounts.selfProgram.isWritable = false;
1602
1654
  }
1603
1655
  const getAccountMeta = getAccountMetaFactory8(programAddress, "programId");
1604
1656
  return Object.freeze({
@@ -1606,6 +1658,7 @@ function getResumeSubscriptionInstruction(input, config) {
1606
1658
  getAccountMeta("subscriber", accounts.subscriber),
1607
1659
  getAccountMeta("planPda", accounts.planPda),
1608
1660
  getAccountMeta("subscriptionPda", accounts.subscriptionPda),
1661
+ getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
1609
1662
  getAccountMeta("eventAuthority", accounts.eventAuthority),
1610
1663
  getAccountMeta("selfProgram", accounts.selfProgram)
1611
1664
  ],
@@ -1614,10 +1667,10 @@ function getResumeSubscriptionInstruction(input, config) {
1614
1667
  });
1615
1668
  }
1616
1669
  function parseResumeSubscriptionInstruction(instruction) {
1617
- if (instruction.accounts.length < 5) {
1670
+ if (instruction.accounts.length < 6) {
1618
1671
  throw new SolanaError8(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS8, {
1619
1672
  actualAccountMetas: instruction.accounts.length,
1620
- expectedAccountMetas: 5
1673
+ expectedAccountMetas: 6
1621
1674
  });
1622
1675
  }
1623
1676
  let accountIndex = 0;
@@ -1632,6 +1685,7 @@ function parseResumeSubscriptionInstruction(instruction) {
1632
1685
  subscriber: getNextAccount(),
1633
1686
  planPda: getNextAccount(),
1634
1687
  subscriptionPda: getNextAccount(),
1688
+ subscriptionAuthority: getNextAccount(),
1635
1689
  eventAuthority: getNextAccount(),
1636
1690
  selfProgram: getNextAccount()
1637
1691
  },
@@ -1639,7 +1693,7 @@ function parseResumeSubscriptionInstruction(instruction) {
1639
1693
  };
1640
1694
  }
1641
1695
 
1642
- // src/generated/instructions/revokeDelegation.ts
1696
+ // src/generated/instructions/revokeAbandonedDelegation.ts
1643
1697
  import {
1644
1698
  combineCodec as combineCodec25,
1645
1699
  getStructDecoder as getStructDecoder23,
@@ -1651,21 +1705,172 @@ import {
1651
1705
  transformEncoder as transformEncoder9
1652
1706
  } from "@solana/kit";
1653
1707
  import { getAccountMetaFactory as getAccountMetaFactory9 } from "@solana/program-client-core";
1708
+ var REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR = 15;
1709
+ function getRevokeAbandonedDelegationDiscriminatorBytes() {
1710
+ return getU8Encoder14().encode(REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR);
1711
+ }
1712
+ function getRevokeAbandonedDelegationInstructionDataEncoder() {
1713
+ return transformEncoder9(getStructEncoder23([["discriminator", getU8Encoder14()]]), (value) => ({
1714
+ ...value,
1715
+ discriminator: REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR
1716
+ }));
1717
+ }
1718
+ function getRevokeAbandonedDelegationInstructionDataDecoder() {
1719
+ return getStructDecoder23([["discriminator", getU8Decoder14()]]);
1720
+ }
1721
+ function getRevokeAbandonedDelegationInstructionDataCodec() {
1722
+ return combineCodec25(
1723
+ getRevokeAbandonedDelegationInstructionDataEncoder(),
1724
+ getRevokeAbandonedDelegationInstructionDataDecoder()
1725
+ );
1726
+ }
1727
+ function getRevokeAbandonedDelegationInstruction(input, config) {
1728
+ const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
1729
+ const originalAccounts = {
1730
+ payer: { value: input.payer ?? null, isWritable: true },
1731
+ delegationAccount: { value: input.delegationAccount ?? null, isWritable: true },
1732
+ subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false }
1733
+ };
1734
+ const accounts = originalAccounts;
1735
+ const getAccountMeta = getAccountMetaFactory9(programAddress, "programId");
1736
+ return Object.freeze({
1737
+ accounts: [
1738
+ getAccountMeta("payer", accounts.payer),
1739
+ getAccountMeta("delegationAccount", accounts.delegationAccount),
1740
+ getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority)
1741
+ ],
1742
+ data: getRevokeAbandonedDelegationInstructionDataEncoder().encode({}),
1743
+ programAddress
1744
+ });
1745
+ }
1746
+ function parseRevokeAbandonedDelegationInstruction(instruction) {
1747
+ if (instruction.accounts.length < 3) {
1748
+ throw new SolanaError9(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS9, {
1749
+ actualAccountMetas: instruction.accounts.length,
1750
+ expectedAccountMetas: 3
1751
+ });
1752
+ }
1753
+ let accountIndex = 0;
1754
+ const getNextAccount = () => {
1755
+ const accountMeta = instruction.accounts[accountIndex];
1756
+ accountIndex += 1;
1757
+ return accountMeta;
1758
+ };
1759
+ return {
1760
+ programAddress: instruction.programAddress,
1761
+ accounts: {
1762
+ payer: getNextAccount(),
1763
+ delegationAccount: getNextAccount(),
1764
+ subscriptionAuthority: getNextAccount()
1765
+ },
1766
+ data: getRevokeAbandonedDelegationInstructionDataDecoder().decode(instruction.data)
1767
+ };
1768
+ }
1769
+
1770
+ // src/generated/instructions/revokeAbandonedSubscription.ts
1771
+ import {
1772
+ combineCodec as combineCodec26,
1773
+ getStructDecoder as getStructDecoder24,
1774
+ getStructEncoder as getStructEncoder24,
1775
+ getU8Decoder as getU8Decoder15,
1776
+ getU8Encoder as getU8Encoder15,
1777
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS10,
1778
+ SolanaError as SolanaError10,
1779
+ transformEncoder as transformEncoder10
1780
+ } from "@solana/kit";
1781
+ import { getAccountMetaFactory as getAccountMetaFactory10 } from "@solana/program-client-core";
1782
+ var REVOKE_ABANDONED_SUBSCRIPTION_DISCRIMINATOR = 16;
1783
+ function getRevokeAbandonedSubscriptionDiscriminatorBytes() {
1784
+ return getU8Encoder15().encode(REVOKE_ABANDONED_SUBSCRIPTION_DISCRIMINATOR);
1785
+ }
1786
+ function getRevokeAbandonedSubscriptionInstructionDataEncoder() {
1787
+ return transformEncoder10(getStructEncoder24([["discriminator", getU8Encoder15()]]), (value) => ({
1788
+ ...value,
1789
+ discriminator: REVOKE_ABANDONED_SUBSCRIPTION_DISCRIMINATOR
1790
+ }));
1791
+ }
1792
+ function getRevokeAbandonedSubscriptionInstructionDataDecoder() {
1793
+ return getStructDecoder24([["discriminator", getU8Decoder15()]]);
1794
+ }
1795
+ function getRevokeAbandonedSubscriptionInstructionDataCodec() {
1796
+ return combineCodec26(
1797
+ getRevokeAbandonedSubscriptionInstructionDataEncoder(),
1798
+ getRevokeAbandonedSubscriptionInstructionDataDecoder()
1799
+ );
1800
+ }
1801
+ function getRevokeAbandonedSubscriptionInstruction(input, config) {
1802
+ const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
1803
+ const originalAccounts = {
1804
+ payer: { value: input.payer ?? null, isWritable: true },
1805
+ subscriptionAccount: { value: input.subscriptionAccount ?? null, isWritable: true },
1806
+ subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
1807
+ planPda: { value: input.planPda ?? null, isWritable: false }
1808
+ };
1809
+ const accounts = originalAccounts;
1810
+ const getAccountMeta = getAccountMetaFactory10(programAddress, "programId");
1811
+ return Object.freeze({
1812
+ accounts: [
1813
+ getAccountMeta("payer", accounts.payer),
1814
+ getAccountMeta("subscriptionAccount", accounts.subscriptionAccount),
1815
+ getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
1816
+ getAccountMeta("planPda", accounts.planPda)
1817
+ ],
1818
+ data: getRevokeAbandonedSubscriptionInstructionDataEncoder().encode({}),
1819
+ programAddress
1820
+ });
1821
+ }
1822
+ function parseRevokeAbandonedSubscriptionInstruction(instruction) {
1823
+ if (instruction.accounts.length < 4) {
1824
+ throw new SolanaError10(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS10, {
1825
+ actualAccountMetas: instruction.accounts.length,
1826
+ expectedAccountMetas: 4
1827
+ });
1828
+ }
1829
+ let accountIndex = 0;
1830
+ const getNextAccount = () => {
1831
+ const accountMeta = instruction.accounts[accountIndex];
1832
+ accountIndex += 1;
1833
+ return accountMeta;
1834
+ };
1835
+ return {
1836
+ programAddress: instruction.programAddress,
1837
+ accounts: {
1838
+ payer: getNextAccount(),
1839
+ subscriptionAccount: getNextAccount(),
1840
+ subscriptionAuthority: getNextAccount(),
1841
+ planPda: getNextAccount()
1842
+ },
1843
+ data: getRevokeAbandonedSubscriptionInstructionDataDecoder().decode(instruction.data)
1844
+ };
1845
+ }
1846
+
1847
+ // src/generated/instructions/revokeDelegation.ts
1848
+ import {
1849
+ combineCodec as combineCodec27,
1850
+ getStructDecoder as getStructDecoder25,
1851
+ getStructEncoder as getStructEncoder25,
1852
+ getU8Decoder as getU8Decoder16,
1853
+ getU8Encoder as getU8Encoder16,
1854
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS11,
1855
+ SolanaError as SolanaError11,
1856
+ transformEncoder as transformEncoder11
1857
+ } from "@solana/kit";
1858
+ import { getAccountMetaFactory as getAccountMetaFactory11 } from "@solana/program-client-core";
1654
1859
  var REVOKE_DELEGATION_DISCRIMINATOR = 3;
1655
1860
  function getRevokeDelegationDiscriminatorBytes() {
1656
- return getU8Encoder14().encode(REVOKE_DELEGATION_DISCRIMINATOR);
1861
+ return getU8Encoder16().encode(REVOKE_DELEGATION_DISCRIMINATOR);
1657
1862
  }
1658
1863
  function getRevokeDelegationInstructionDataEncoder() {
1659
- return transformEncoder9(getStructEncoder23([["discriminator", getU8Encoder14()]]), (value) => ({
1864
+ return transformEncoder11(getStructEncoder25([["discriminator", getU8Encoder16()]]), (value) => ({
1660
1865
  ...value,
1661
1866
  discriminator: REVOKE_DELEGATION_DISCRIMINATOR
1662
1867
  }));
1663
1868
  }
1664
1869
  function getRevokeDelegationInstructionDataDecoder() {
1665
- return getStructDecoder23([["discriminator", getU8Decoder14()]]);
1870
+ return getStructDecoder25([["discriminator", getU8Decoder16()]]);
1666
1871
  }
1667
1872
  function getRevokeDelegationInstructionDataCodec() {
1668
- return combineCodec25(getRevokeDelegationInstructionDataEncoder(), getRevokeDelegationInstructionDataDecoder());
1873
+ return combineCodec27(getRevokeDelegationInstructionDataEncoder(), getRevokeDelegationInstructionDataDecoder());
1669
1874
  }
1670
1875
  function getRevokeDelegationInstruction(input, config) {
1671
1876
  const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
@@ -1674,7 +1879,7 @@ function getRevokeDelegationInstruction(input, config) {
1674
1879
  delegationAccount: { value: input.delegationAccount ?? null, isWritable: true }
1675
1880
  };
1676
1881
  const accounts = originalAccounts;
1677
- const getAccountMeta = getAccountMetaFactory9(programAddress, "programId");
1882
+ const getAccountMeta = getAccountMetaFactory11(programAddress, "programId");
1678
1883
  return Object.freeze({
1679
1884
  accounts: [
1680
1885
  getAccountMeta("authority", accounts.authority),
@@ -1686,7 +1891,7 @@ function getRevokeDelegationInstruction(input, config) {
1686
1891
  }
1687
1892
  function parseRevokeDelegationInstruction(instruction) {
1688
1893
  if (instruction.accounts.length < 2) {
1689
- throw new SolanaError9(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS9, {
1894
+ throw new SolanaError11(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS11, {
1690
1895
  actualAccountMetas: instruction.accounts.length,
1691
1896
  expectedAccountMetas: 2
1692
1897
  });
@@ -1704,42 +1909,167 @@ function parseRevokeDelegationInstruction(instruction) {
1704
1909
  };
1705
1910
  }
1706
1911
 
1707
- // src/generated/instructions/subscribe.ts
1912
+ // src/generated/instructions/revokeSubscriptionAuthority.ts
1708
1913
  import {
1709
- combineCodec as combineCodec26,
1710
- getStructDecoder as getStructDecoder24,
1711
- getStructEncoder as getStructEncoder24,
1712
- getU8Decoder as getU8Decoder15,
1713
- getU8Encoder as getU8Encoder15,
1714
- SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS10,
1715
- SolanaError as SolanaError10,
1716
- transformEncoder as transformEncoder10
1914
+ combineCodec as combineCodec28,
1915
+ getStructDecoder as getStructDecoder26,
1916
+ getStructEncoder as getStructEncoder26,
1917
+ getU8Decoder as getU8Decoder17,
1918
+ getU8Encoder as getU8Encoder17,
1919
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS12,
1920
+ SolanaError as SolanaError12,
1921
+ transformEncoder as transformEncoder12
1717
1922
  } from "@solana/kit";
1718
1923
  import {
1719
- getAccountMetaFactory as getAccountMetaFactory10,
1924
+ getAccountMetaFactory as getAccountMetaFactory12,
1720
1925
  getAddressFromResolvedInstructionAccount as getAddressFromResolvedInstructionAccount4
1721
1926
  } from "@solana/program-client-core";
1927
+ var REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR = 14;
1928
+ function getRevokeSubscriptionAuthorityDiscriminatorBytes() {
1929
+ return getU8Encoder17().encode(REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR);
1930
+ }
1931
+ function getRevokeSubscriptionAuthorityInstructionDataEncoder() {
1932
+ return transformEncoder12(getStructEncoder26([["discriminator", getU8Encoder17()]]), (value) => ({
1933
+ ...value,
1934
+ discriminator: REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR
1935
+ }));
1936
+ }
1937
+ function getRevokeSubscriptionAuthorityInstructionDataDecoder() {
1938
+ return getStructDecoder26([["discriminator", getU8Decoder17()]]);
1939
+ }
1940
+ function getRevokeSubscriptionAuthorityInstructionDataCodec() {
1941
+ return combineCodec28(
1942
+ getRevokeSubscriptionAuthorityInstructionDataEncoder(),
1943
+ getRevokeSubscriptionAuthorityInstructionDataDecoder()
1944
+ );
1945
+ }
1946
+ async function getRevokeSubscriptionAuthorityInstructionAsync(input, config) {
1947
+ const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
1948
+ const originalAccounts = {
1949
+ user: { value: input.user ?? null, isWritable: true },
1950
+ userAta: { value: input.userAta ?? null, isWritable: true },
1951
+ tokenMint: { value: input.tokenMint ?? null, isWritable: false },
1952
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
1953
+ subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: true },
1954
+ receiver: { value: input.receiver ?? null, isWritable: true }
1955
+ };
1956
+ const accounts = originalAccounts;
1957
+ if (!accounts.subscriptionAuthority.value) {
1958
+ accounts.subscriptionAuthority.value = await findSubscriptionAuthorityPda({
1959
+ user: getAddressFromResolvedInstructionAccount4("user", accounts.user.value),
1960
+ tokenMint: getAddressFromResolvedInstructionAccount4("tokenMint", accounts.tokenMint.value)
1961
+ });
1962
+ }
1963
+ const getAccountMeta = getAccountMetaFactory12(programAddress, "omitted");
1964
+ return Object.freeze({
1965
+ accounts: [
1966
+ getAccountMeta("user", accounts.user),
1967
+ getAccountMeta("userAta", accounts.userAta),
1968
+ getAccountMeta("tokenMint", accounts.tokenMint),
1969
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
1970
+ getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
1971
+ getAccountMeta("receiver", accounts.receiver)
1972
+ ].filter((x) => x !== void 0),
1973
+ data: getRevokeSubscriptionAuthorityInstructionDataEncoder().encode({}),
1974
+ programAddress
1975
+ });
1976
+ }
1977
+ function getRevokeSubscriptionAuthorityInstruction(input, config) {
1978
+ const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
1979
+ const originalAccounts = {
1980
+ user: { value: input.user ?? null, isWritable: true },
1981
+ userAta: { value: input.userAta ?? null, isWritable: true },
1982
+ tokenMint: { value: input.tokenMint ?? null, isWritable: false },
1983
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
1984
+ subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: true },
1985
+ receiver: { value: input.receiver ?? null, isWritable: true }
1986
+ };
1987
+ const accounts = originalAccounts;
1988
+ const getAccountMeta = getAccountMetaFactory12(programAddress, "omitted");
1989
+ return Object.freeze({
1990
+ accounts: [
1991
+ getAccountMeta("user", accounts.user),
1992
+ getAccountMeta("userAta", accounts.userAta),
1993
+ getAccountMeta("tokenMint", accounts.tokenMint),
1994
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
1995
+ getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
1996
+ getAccountMeta("receiver", accounts.receiver)
1997
+ ].filter((x) => x !== void 0),
1998
+ data: getRevokeSubscriptionAuthorityInstructionDataEncoder().encode({}),
1999
+ programAddress
2000
+ });
2001
+ }
2002
+ function parseRevokeSubscriptionAuthorityInstruction(instruction) {
2003
+ if (instruction.accounts.length < 5) {
2004
+ throw new SolanaError12(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS12, {
2005
+ actualAccountMetas: instruction.accounts.length,
2006
+ expectedAccountMetas: 5
2007
+ });
2008
+ }
2009
+ let accountIndex = 0;
2010
+ const getNextAccount = () => {
2011
+ const accountMeta = instruction.accounts[accountIndex];
2012
+ accountIndex += 1;
2013
+ return accountMeta;
2014
+ };
2015
+ let optionalAccountsRemaining = instruction.accounts.length - 5;
2016
+ const getNextOptionalAccount = () => {
2017
+ if (optionalAccountsRemaining === 0) return void 0;
2018
+ optionalAccountsRemaining -= 1;
2019
+ return getNextAccount();
2020
+ };
2021
+ return {
2022
+ programAddress: instruction.programAddress,
2023
+ accounts: {
2024
+ user: getNextAccount(),
2025
+ userAta: getNextAccount(),
2026
+ tokenMint: getNextAccount(),
2027
+ tokenProgram: getNextAccount(),
2028
+ subscriptionAuthority: getNextAccount(),
2029
+ receiver: getNextOptionalAccount()
2030
+ },
2031
+ data: getRevokeSubscriptionAuthorityInstructionDataDecoder().decode(instruction.data)
2032
+ };
2033
+ }
2034
+
2035
+ // src/generated/instructions/subscribe.ts
2036
+ import {
2037
+ combineCodec as combineCodec29,
2038
+ getProgramDerivedAddress as getProgramDerivedAddress9,
2039
+ getStructDecoder as getStructDecoder27,
2040
+ getStructEncoder as getStructEncoder27,
2041
+ getU8Decoder as getU8Decoder18,
2042
+ getU8Encoder as getU8Encoder18,
2043
+ getUtf8Encoder as getUtf8Encoder11,
2044
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS13,
2045
+ SolanaError as SolanaError13,
2046
+ transformEncoder as transformEncoder13
2047
+ } from "@solana/kit";
2048
+ import {
2049
+ getAccountMetaFactory as getAccountMetaFactory13,
2050
+ getAddressFromResolvedInstructionAccount as getAddressFromResolvedInstructionAccount5
2051
+ } from "@solana/program-client-core";
1722
2052
  var SUBSCRIBE_DISCRIMINATOR = 11;
1723
2053
  function getSubscribeDiscriminatorBytes() {
1724
- return getU8Encoder15().encode(SUBSCRIBE_DISCRIMINATOR);
2054
+ return getU8Encoder18().encode(SUBSCRIBE_DISCRIMINATOR);
1725
2055
  }
1726
2056
  function getSubscribeInstructionDataEncoder() {
1727
- return transformEncoder10(
1728
- getStructEncoder24([
1729
- ["discriminator", getU8Encoder15()],
2057
+ return transformEncoder13(
2058
+ getStructEncoder27([
2059
+ ["discriminator", getU8Encoder18()],
1730
2060
  ["subscribeData", getSubscribeDataEncoder()]
1731
2061
  ]),
1732
2062
  (value) => ({ ...value, discriminator: SUBSCRIBE_DISCRIMINATOR })
1733
2063
  );
1734
2064
  }
1735
2065
  function getSubscribeInstructionDataDecoder() {
1736
- return getStructDecoder24([
1737
- ["discriminator", getU8Decoder15()],
2066
+ return getStructDecoder27([
2067
+ ["discriminator", getU8Decoder18()],
1738
2068
  ["subscribeData", getSubscribeDataDecoder()]
1739
2069
  ]);
1740
2070
  }
1741
2071
  function getSubscribeInstructionDataCodec() {
1742
- return combineCodec26(getSubscribeInstructionDataEncoder(), getSubscribeInstructionDataDecoder());
2072
+ return combineCodec29(getSubscribeInstructionDataEncoder(), getSubscribeInstructionDataDecoder());
1743
2073
  }
1744
2074
  async function getSubscribeInstructionAsync(input, config) {
1745
2075
  const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
@@ -1751,26 +2081,31 @@ async function getSubscribeInstructionAsync(input, config) {
1751
2081
  subscriptionAuthorityPda: { value: input.subscriptionAuthorityPda ?? null, isWritable: false },
1752
2082
  systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1753
2083
  eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
1754
- selfProgram: { value: input.selfProgram ?? null, isWritable: false }
2084
+ selfProgram: { value: input.selfProgram ?? null, isWritable: false },
2085
+ payer: { value: input.payer ?? null, isWritable: true }
1755
2086
  };
1756
2087
  const accounts = originalAccounts;
1757
2088
  const args = { ...input };
1758
2089
  if (!accounts.subscriptionPda.value) {
1759
2090
  accounts.subscriptionPda.value = await findSubscriptionDelegationPda({
1760
- planPda: getAddressFromResolvedInstructionAccount4("planPda", accounts.planPda.value),
1761
- subscriber: getAddressFromResolvedInstructionAccount4("subscriber", accounts.subscriber.value)
2091
+ planPda: getAddressFromResolvedInstructionAccount5("planPda", accounts.planPda.value),
2092
+ subscriber: getAddressFromResolvedInstructionAccount5("subscriber", accounts.subscriber.value)
1762
2093
  });
1763
2094
  }
1764
2095
  if (!accounts.systemProgram.value) {
1765
2096
  accounts.systemProgram.value = "11111111111111111111111111111111";
1766
2097
  }
1767
2098
  if (!accounts.eventAuthority.value) {
1768
- accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
2099
+ accounts.eventAuthority.value = await getProgramDerivedAddress9({
2100
+ programAddress,
2101
+ seeds: [getUtf8Encoder11().encode("event_authority")]
2102
+ });
1769
2103
  }
1770
2104
  if (!accounts.selfProgram.value) {
1771
- accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
2105
+ accounts.selfProgram.value = programAddress;
2106
+ accounts.selfProgram.isWritable = false;
1772
2107
  }
1773
- const getAccountMeta = getAccountMetaFactory10(programAddress, "programId");
2108
+ const getAccountMeta = getAccountMetaFactory13(programAddress, "omitted");
1774
2109
  return Object.freeze({
1775
2110
  accounts: [
1776
2111
  getAccountMeta("subscriber", accounts.subscriber),
@@ -1780,8 +2115,9 @@ async function getSubscribeInstructionAsync(input, config) {
1780
2115
  getAccountMeta("subscriptionAuthorityPda", accounts.subscriptionAuthorityPda),
1781
2116
  getAccountMeta("systemProgram", accounts.systemProgram),
1782
2117
  getAccountMeta("eventAuthority", accounts.eventAuthority),
1783
- getAccountMeta("selfProgram", accounts.selfProgram)
1784
- ],
2118
+ getAccountMeta("selfProgram", accounts.selfProgram),
2119
+ getAccountMeta("payer", accounts.payer)
2120
+ ].filter((x) => x !== void 0),
1785
2121
  data: getSubscribeInstructionDataEncoder().encode(args),
1786
2122
  programAddress
1787
2123
  });
@@ -1796,20 +2132,19 @@ function getSubscribeInstruction(input, config) {
1796
2132
  subscriptionAuthorityPda: { value: input.subscriptionAuthorityPda ?? null, isWritable: false },
1797
2133
  systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1798
2134
  eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
1799
- selfProgram: { value: input.selfProgram ?? null, isWritable: false }
2135
+ selfProgram: { value: input.selfProgram ?? null, isWritable: false },
2136
+ payer: { value: input.payer ?? null, isWritable: true }
1800
2137
  };
1801
2138
  const accounts = originalAccounts;
1802
2139
  const args = { ...input };
1803
2140
  if (!accounts.systemProgram.value) {
1804
2141
  accounts.systemProgram.value = "11111111111111111111111111111111";
1805
2142
  }
1806
- if (!accounts.eventAuthority.value) {
1807
- accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
1808
- }
1809
2143
  if (!accounts.selfProgram.value) {
1810
- accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
2144
+ accounts.selfProgram.value = programAddress;
2145
+ accounts.selfProgram.isWritable = false;
1811
2146
  }
1812
- const getAccountMeta = getAccountMetaFactory10(programAddress, "programId");
2147
+ const getAccountMeta = getAccountMetaFactory13(programAddress, "omitted");
1813
2148
  return Object.freeze({
1814
2149
  accounts: [
1815
2150
  getAccountMeta("subscriber", accounts.subscriber),
@@ -1819,15 +2154,16 @@ function getSubscribeInstruction(input, config) {
1819
2154
  getAccountMeta("subscriptionAuthorityPda", accounts.subscriptionAuthorityPda),
1820
2155
  getAccountMeta("systemProgram", accounts.systemProgram),
1821
2156
  getAccountMeta("eventAuthority", accounts.eventAuthority),
1822
- getAccountMeta("selfProgram", accounts.selfProgram)
1823
- ],
2157
+ getAccountMeta("selfProgram", accounts.selfProgram),
2158
+ getAccountMeta("payer", accounts.payer)
2159
+ ].filter((x) => x !== void 0),
1824
2160
  data: getSubscribeInstructionDataEncoder().encode(args),
1825
2161
  programAddress
1826
2162
  });
1827
2163
  }
1828
2164
  function parseSubscribeInstruction(instruction) {
1829
2165
  if (instruction.accounts.length < 8) {
1830
- throw new SolanaError10(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS10, {
2166
+ throw new SolanaError13(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS13, {
1831
2167
  actualAccountMetas: instruction.accounts.length,
1832
2168
  expectedAccountMetas: 8
1833
2169
  });
@@ -1838,6 +2174,12 @@ function parseSubscribeInstruction(instruction) {
1838
2174
  accountIndex += 1;
1839
2175
  return accountMeta;
1840
2176
  };
2177
+ let optionalAccountsRemaining = instruction.accounts.length - 8;
2178
+ const getNextOptionalAccount = () => {
2179
+ if (optionalAccountsRemaining === 0) return void 0;
2180
+ optionalAccountsRemaining -= 1;
2181
+ return getNextAccount();
2182
+ };
1841
2183
  return {
1842
2184
  programAddress: instruction.programAddress,
1843
2185
  accounts: {
@@ -1848,7 +2190,8 @@ function parseSubscribeInstruction(instruction) {
1848
2190
  subscriptionAuthorityPda: getNextAccount(),
1849
2191
  systemProgram: getNextAccount(),
1850
2192
  eventAuthority: getNextAccount(),
1851
- selfProgram: getNextAccount()
2193
+ selfProgram: getNextAccount(),
2194
+ payer: getNextOptionalAccount()
1852
2195
  },
1853
2196
  data: getSubscribeInstructionDataDecoder().decode(instruction.data)
1854
2197
  };
@@ -1856,39 +2199,41 @@ function parseSubscribeInstruction(instruction) {
1856
2199
 
1857
2200
  // src/generated/instructions/transferFixed.ts
1858
2201
  import {
1859
- combineCodec as combineCodec27,
1860
- getStructDecoder as getStructDecoder25,
1861
- getStructEncoder as getStructEncoder25,
1862
- getU8Decoder as getU8Decoder16,
1863
- getU8Encoder as getU8Encoder16,
1864
- SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS11,
1865
- SolanaError as SolanaError11,
1866
- transformEncoder as transformEncoder11
2202
+ combineCodec as combineCodec30,
2203
+ getProgramDerivedAddress as getProgramDerivedAddress10,
2204
+ getStructDecoder as getStructDecoder28,
2205
+ getStructEncoder as getStructEncoder28,
2206
+ getU8Decoder as getU8Decoder19,
2207
+ getU8Encoder as getU8Encoder19,
2208
+ getUtf8Encoder as getUtf8Encoder12,
2209
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS14,
2210
+ SolanaError as SolanaError14,
2211
+ transformEncoder as transformEncoder14
1867
2212
  } from "@solana/kit";
1868
- import { getAccountMetaFactory as getAccountMetaFactory11 } from "@solana/program-client-core";
2213
+ import { getAccountMetaFactory as getAccountMetaFactory14 } from "@solana/program-client-core";
1869
2214
  var TRANSFER_FIXED_DISCRIMINATOR = 4;
1870
2215
  function getTransferFixedDiscriminatorBytes() {
1871
- return getU8Encoder16().encode(TRANSFER_FIXED_DISCRIMINATOR);
2216
+ return getU8Encoder19().encode(TRANSFER_FIXED_DISCRIMINATOR);
1872
2217
  }
1873
2218
  function getTransferFixedInstructionDataEncoder() {
1874
- return transformEncoder11(
1875
- getStructEncoder25([
1876
- ["discriminator", getU8Encoder16()],
2219
+ return transformEncoder14(
2220
+ getStructEncoder28([
2221
+ ["discriminator", getU8Encoder19()],
1877
2222
  ["transferData", getTransferDataEncoder()]
1878
2223
  ]),
1879
2224
  (value) => ({ ...value, discriminator: TRANSFER_FIXED_DISCRIMINATOR })
1880
2225
  );
1881
2226
  }
1882
2227
  function getTransferFixedInstructionDataDecoder() {
1883
- return getStructDecoder25([
1884
- ["discriminator", getU8Decoder16()],
2228
+ return getStructDecoder28([
2229
+ ["discriminator", getU8Decoder19()],
1885
2230
  ["transferData", getTransferDataDecoder()]
1886
2231
  ]);
1887
2232
  }
1888
2233
  function getTransferFixedInstructionDataCodec() {
1889
- return combineCodec27(getTransferFixedInstructionDataEncoder(), getTransferFixedInstructionDataDecoder());
2234
+ return combineCodec30(getTransferFixedInstructionDataEncoder(), getTransferFixedInstructionDataDecoder());
1890
2235
  }
1891
- function getTransferFixedInstruction(input, config) {
2236
+ async function getTransferFixedInstructionAsync(input, config) {
1892
2237
  const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
1893
2238
  const originalAccounts = {
1894
2239
  delegationPda: { value: input.delegationPda ?? null, isWritable: true },
@@ -1904,12 +2249,52 @@ function getTransferFixedInstruction(input, config) {
1904
2249
  const accounts = originalAccounts;
1905
2250
  const args = { ...input };
1906
2251
  if (!accounts.eventAuthority.value) {
1907
- accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
2252
+ accounts.eventAuthority.value = await getProgramDerivedAddress10({
2253
+ programAddress,
2254
+ seeds: [getUtf8Encoder12().encode("event_authority")]
2255
+ });
1908
2256
  }
1909
2257
  if (!accounts.selfProgram.value) {
1910
- accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
2258
+ accounts.selfProgram.value = programAddress;
2259
+ accounts.selfProgram.isWritable = false;
1911
2260
  }
1912
- const getAccountMeta = getAccountMetaFactory11(programAddress, "programId");
2261
+ const getAccountMeta = getAccountMetaFactory14(programAddress, "programId");
2262
+ return Object.freeze({
2263
+ accounts: [
2264
+ getAccountMeta("delegationPda", accounts.delegationPda),
2265
+ getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
2266
+ getAccountMeta("delegatorAta", accounts.delegatorAta),
2267
+ getAccountMeta("receiverAta", accounts.receiverAta),
2268
+ getAccountMeta("tokenMint", accounts.tokenMint),
2269
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
2270
+ getAccountMeta("delegatee", accounts.delegatee),
2271
+ getAccountMeta("eventAuthority", accounts.eventAuthority),
2272
+ getAccountMeta("selfProgram", accounts.selfProgram)
2273
+ ],
2274
+ data: getTransferFixedInstructionDataEncoder().encode(args),
2275
+ programAddress
2276
+ });
2277
+ }
2278
+ function getTransferFixedInstruction(input, config) {
2279
+ const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
2280
+ const originalAccounts = {
2281
+ delegationPda: { value: input.delegationPda ?? null, isWritable: true },
2282
+ subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
2283
+ delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
2284
+ receiverAta: { value: input.receiverAta ?? null, isWritable: true },
2285
+ tokenMint: { value: input.tokenMint ?? null, isWritable: false },
2286
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
2287
+ delegatee: { value: input.delegatee ?? null, isWritable: false },
2288
+ eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
2289
+ selfProgram: { value: input.selfProgram ?? null, isWritable: false }
2290
+ };
2291
+ const accounts = originalAccounts;
2292
+ const args = { ...input };
2293
+ if (!accounts.selfProgram.value) {
2294
+ accounts.selfProgram.value = programAddress;
2295
+ accounts.selfProgram.isWritable = false;
2296
+ }
2297
+ const getAccountMeta = getAccountMetaFactory14(programAddress, "programId");
1913
2298
  return Object.freeze({
1914
2299
  accounts: [
1915
2300
  getAccountMeta("delegationPda", accounts.delegationPda),
@@ -1928,7 +2313,7 @@ function getTransferFixedInstruction(input, config) {
1928
2313
  }
1929
2314
  function parseTransferFixedInstruction(instruction) {
1930
2315
  if (instruction.accounts.length < 9) {
1931
- throw new SolanaError11(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS11, {
2316
+ throw new SolanaError14(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS14, {
1932
2317
  actualAccountMetas: instruction.accounts.length,
1933
2318
  expectedAccountMetas: 9
1934
2319
  });
@@ -1958,37 +2343,81 @@ function parseTransferFixedInstruction(instruction) {
1958
2343
 
1959
2344
  // src/generated/instructions/transferRecurring.ts
1960
2345
  import {
1961
- combineCodec as combineCodec28,
1962
- getStructDecoder as getStructDecoder26,
1963
- getStructEncoder as getStructEncoder26,
1964
- getU8Decoder as getU8Decoder17,
1965
- getU8Encoder as getU8Encoder17,
1966
- SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS12,
1967
- SolanaError as SolanaError12,
1968
- transformEncoder as transformEncoder12
2346
+ combineCodec as combineCodec31,
2347
+ getProgramDerivedAddress as getProgramDerivedAddress11,
2348
+ getStructDecoder as getStructDecoder29,
2349
+ getStructEncoder as getStructEncoder29,
2350
+ getU8Decoder as getU8Decoder20,
2351
+ getU8Encoder as getU8Encoder20,
2352
+ getUtf8Encoder as getUtf8Encoder13,
2353
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS15,
2354
+ SolanaError as SolanaError15,
2355
+ transformEncoder as transformEncoder15
1969
2356
  } from "@solana/kit";
1970
- import { getAccountMetaFactory as getAccountMetaFactory12 } from "@solana/program-client-core";
2357
+ import { getAccountMetaFactory as getAccountMetaFactory15 } from "@solana/program-client-core";
1971
2358
  var TRANSFER_RECURRING_DISCRIMINATOR = 5;
1972
2359
  function getTransferRecurringDiscriminatorBytes() {
1973
- return getU8Encoder17().encode(TRANSFER_RECURRING_DISCRIMINATOR);
2360
+ return getU8Encoder20().encode(TRANSFER_RECURRING_DISCRIMINATOR);
1974
2361
  }
1975
2362
  function getTransferRecurringInstructionDataEncoder() {
1976
- return transformEncoder12(
1977
- getStructEncoder26([
1978
- ["discriminator", getU8Encoder17()],
2363
+ return transformEncoder15(
2364
+ getStructEncoder29([
2365
+ ["discriminator", getU8Encoder20()],
1979
2366
  ["transferData", getTransferDataEncoder()]
1980
2367
  ]),
1981
2368
  (value) => ({ ...value, discriminator: TRANSFER_RECURRING_DISCRIMINATOR })
1982
2369
  );
1983
2370
  }
1984
2371
  function getTransferRecurringInstructionDataDecoder() {
1985
- return getStructDecoder26([
1986
- ["discriminator", getU8Decoder17()],
2372
+ return getStructDecoder29([
2373
+ ["discriminator", getU8Decoder20()],
1987
2374
  ["transferData", getTransferDataDecoder()]
1988
2375
  ]);
1989
2376
  }
1990
2377
  function getTransferRecurringInstructionDataCodec() {
1991
- return combineCodec28(getTransferRecurringInstructionDataEncoder(), getTransferRecurringInstructionDataDecoder());
2378
+ return combineCodec31(getTransferRecurringInstructionDataEncoder(), getTransferRecurringInstructionDataDecoder());
2379
+ }
2380
+ async function getTransferRecurringInstructionAsync(input, config) {
2381
+ const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
2382
+ const originalAccounts = {
2383
+ delegationPda: { value: input.delegationPda ?? null, isWritable: true },
2384
+ subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
2385
+ delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
2386
+ receiverAta: { value: input.receiverAta ?? null, isWritable: true },
2387
+ tokenMint: { value: input.tokenMint ?? null, isWritable: false },
2388
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
2389
+ delegatee: { value: input.delegatee ?? null, isWritable: false },
2390
+ eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
2391
+ selfProgram: { value: input.selfProgram ?? null, isWritable: false }
2392
+ };
2393
+ const accounts = originalAccounts;
2394
+ const args = { ...input };
2395
+ if (!accounts.eventAuthority.value) {
2396
+ accounts.eventAuthority.value = await getProgramDerivedAddress11({
2397
+ programAddress,
2398
+ seeds: [getUtf8Encoder13().encode("event_authority")]
2399
+ });
2400
+ }
2401
+ if (!accounts.selfProgram.value) {
2402
+ accounts.selfProgram.value = programAddress;
2403
+ accounts.selfProgram.isWritable = false;
2404
+ }
2405
+ const getAccountMeta = getAccountMetaFactory15(programAddress, "programId");
2406
+ return Object.freeze({
2407
+ accounts: [
2408
+ getAccountMeta("delegationPda", accounts.delegationPda),
2409
+ getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
2410
+ getAccountMeta("delegatorAta", accounts.delegatorAta),
2411
+ getAccountMeta("receiverAta", accounts.receiverAta),
2412
+ getAccountMeta("tokenMint", accounts.tokenMint),
2413
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
2414
+ getAccountMeta("delegatee", accounts.delegatee),
2415
+ getAccountMeta("eventAuthority", accounts.eventAuthority),
2416
+ getAccountMeta("selfProgram", accounts.selfProgram)
2417
+ ],
2418
+ data: getTransferRecurringInstructionDataEncoder().encode(args),
2419
+ programAddress
2420
+ });
1992
2421
  }
1993
2422
  function getTransferRecurringInstruction(input, config) {
1994
2423
  const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
@@ -2005,13 +2434,11 @@ function getTransferRecurringInstruction(input, config) {
2005
2434
  };
2006
2435
  const accounts = originalAccounts;
2007
2436
  const args = { ...input };
2008
- if (!accounts.eventAuthority.value) {
2009
- accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
2010
- }
2011
2437
  if (!accounts.selfProgram.value) {
2012
- accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
2438
+ accounts.selfProgram.value = programAddress;
2439
+ accounts.selfProgram.isWritable = false;
2013
2440
  }
2014
- const getAccountMeta = getAccountMetaFactory12(programAddress, "programId");
2441
+ const getAccountMeta = getAccountMetaFactory15(programAddress, "programId");
2015
2442
  return Object.freeze({
2016
2443
  accounts: [
2017
2444
  getAccountMeta("delegationPda", accounts.delegationPda),
@@ -2030,7 +2457,7 @@ function getTransferRecurringInstruction(input, config) {
2030
2457
  }
2031
2458
  function parseTransferRecurringInstruction(instruction) {
2032
2459
  if (instruction.accounts.length < 9) {
2033
- throw new SolanaError12(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS12, {
2460
+ throw new SolanaError15(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS15, {
2034
2461
  actualAccountMetas: instruction.accounts.length,
2035
2462
  expectedAccountMetas: 9
2036
2463
  });
@@ -2060,42 +2487,44 @@ function parseTransferRecurringInstruction(instruction) {
2060
2487
 
2061
2488
  // src/generated/instructions/transferSubscription.ts
2062
2489
  import {
2063
- combineCodec as combineCodec29,
2064
- getStructDecoder as getStructDecoder27,
2065
- getStructEncoder as getStructEncoder27,
2066
- getU8Decoder as getU8Decoder18,
2067
- getU8Encoder as getU8Encoder18,
2068
- SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS13,
2069
- SolanaError as SolanaError13,
2070
- transformEncoder as transformEncoder13
2490
+ combineCodec as combineCodec32,
2491
+ getProgramDerivedAddress as getProgramDerivedAddress12,
2492
+ getStructDecoder as getStructDecoder30,
2493
+ getStructEncoder as getStructEncoder30,
2494
+ getU8Decoder as getU8Decoder21,
2495
+ getU8Encoder as getU8Encoder21,
2496
+ getUtf8Encoder as getUtf8Encoder14,
2497
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS16,
2498
+ SolanaError as SolanaError16,
2499
+ transformEncoder as transformEncoder16
2071
2500
  } from "@solana/kit";
2072
- import { getAccountMetaFactory as getAccountMetaFactory13 } from "@solana/program-client-core";
2501
+ import { getAccountMetaFactory as getAccountMetaFactory16 } from "@solana/program-client-core";
2073
2502
  var TRANSFER_SUBSCRIPTION_DISCRIMINATOR = 10;
2074
2503
  function getTransferSubscriptionDiscriminatorBytes() {
2075
- return getU8Encoder18().encode(TRANSFER_SUBSCRIPTION_DISCRIMINATOR);
2504
+ return getU8Encoder21().encode(TRANSFER_SUBSCRIPTION_DISCRIMINATOR);
2076
2505
  }
2077
2506
  function getTransferSubscriptionInstructionDataEncoder() {
2078
- return transformEncoder13(
2079
- getStructEncoder27([
2080
- ["discriminator", getU8Encoder18()],
2507
+ return transformEncoder16(
2508
+ getStructEncoder30([
2509
+ ["discriminator", getU8Encoder21()],
2081
2510
  ["transferData", getTransferDataEncoder()]
2082
2511
  ]),
2083
2512
  (value) => ({ ...value, discriminator: TRANSFER_SUBSCRIPTION_DISCRIMINATOR })
2084
2513
  );
2085
2514
  }
2086
2515
  function getTransferSubscriptionInstructionDataDecoder() {
2087
- return getStructDecoder27([
2088
- ["discriminator", getU8Decoder18()],
2516
+ return getStructDecoder30([
2517
+ ["discriminator", getU8Decoder21()],
2089
2518
  ["transferData", getTransferDataDecoder()]
2090
2519
  ]);
2091
2520
  }
2092
2521
  function getTransferSubscriptionInstructionDataCodec() {
2093
- return combineCodec29(
2522
+ return combineCodec32(
2094
2523
  getTransferSubscriptionInstructionDataEncoder(),
2095
2524
  getTransferSubscriptionInstructionDataDecoder()
2096
2525
  );
2097
2526
  }
2098
- function getTransferSubscriptionInstruction(input, config) {
2527
+ async function getTransferSubscriptionInstructionAsync(input, config) {
2099
2528
  const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
2100
2529
  const originalAccounts = {
2101
2530
  subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
@@ -2112,12 +2541,54 @@ function getTransferSubscriptionInstruction(input, config) {
2112
2541
  const accounts = originalAccounts;
2113
2542
  const args = { ...input };
2114
2543
  if (!accounts.eventAuthority.value) {
2115
- accounts.eventAuthority.value = "3Hnj4BYoDgtpBuqXfiy7Y8cNa3jXaNd4oqgSXBzkMcH7";
2544
+ accounts.eventAuthority.value = await getProgramDerivedAddress12({
2545
+ programAddress,
2546
+ seeds: [getUtf8Encoder14().encode("event_authority")]
2547
+ });
2548
+ }
2549
+ if (!accounts.selfProgram.value) {
2550
+ accounts.selfProgram.value = programAddress;
2551
+ accounts.selfProgram.isWritable = false;
2116
2552
  }
2553
+ const getAccountMeta = getAccountMetaFactory16(programAddress, "programId");
2554
+ return Object.freeze({
2555
+ accounts: [
2556
+ getAccountMeta("subscriptionPda", accounts.subscriptionPda),
2557
+ getAccountMeta("planPda", accounts.planPda),
2558
+ getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority),
2559
+ getAccountMeta("delegatorAta", accounts.delegatorAta),
2560
+ getAccountMeta("receiverAta", accounts.receiverAta),
2561
+ getAccountMeta("caller", accounts.caller),
2562
+ getAccountMeta("tokenMint", accounts.tokenMint),
2563
+ getAccountMeta("tokenProgram", accounts.tokenProgram),
2564
+ getAccountMeta("eventAuthority", accounts.eventAuthority),
2565
+ getAccountMeta("selfProgram", accounts.selfProgram)
2566
+ ],
2567
+ data: getTransferSubscriptionInstructionDataEncoder().encode(args),
2568
+ programAddress
2569
+ });
2570
+ }
2571
+ function getTransferSubscriptionInstruction(input, config) {
2572
+ const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
2573
+ const originalAccounts = {
2574
+ subscriptionPda: { value: input.subscriptionPda ?? null, isWritable: true },
2575
+ planPda: { value: input.planPda ?? null, isWritable: false },
2576
+ subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false },
2577
+ delegatorAta: { value: input.delegatorAta ?? null, isWritable: true },
2578
+ receiverAta: { value: input.receiverAta ?? null, isWritable: true },
2579
+ caller: { value: input.caller ?? null, isWritable: false },
2580
+ tokenMint: { value: input.tokenMint ?? null, isWritable: false },
2581
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
2582
+ eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
2583
+ selfProgram: { value: input.selfProgram ?? null, isWritable: false }
2584
+ };
2585
+ const accounts = originalAccounts;
2586
+ const args = { ...input };
2117
2587
  if (!accounts.selfProgram.value) {
2118
- accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
2588
+ accounts.selfProgram.value = programAddress;
2589
+ accounts.selfProgram.isWritable = false;
2119
2590
  }
2120
- const getAccountMeta = getAccountMetaFactory13(programAddress, "programId");
2591
+ const getAccountMeta = getAccountMetaFactory16(programAddress, "programId");
2121
2592
  return Object.freeze({
2122
2593
  accounts: [
2123
2594
  getAccountMeta("subscriptionPda", accounts.subscriptionPda),
@@ -2137,7 +2608,7 @@ function getTransferSubscriptionInstruction(input, config) {
2137
2608
  }
2138
2609
  function parseTransferSubscriptionInstruction(instruction) {
2139
2610
  if (instruction.accounts.length < 10) {
2140
- throw new SolanaError13(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS13, {
2611
+ throw new SolanaError16(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS16, {
2141
2612
  actualAccountMetas: instruction.accounts.length,
2142
2613
  expectedAccountMetas: 10
2143
2614
  });
@@ -2168,58 +2639,103 @@ function parseTransferSubscriptionInstruction(instruction) {
2168
2639
 
2169
2640
  // src/generated/instructions/updatePlan.ts
2170
2641
  import {
2171
- combineCodec as combineCodec30,
2172
- getStructDecoder as getStructDecoder28,
2173
- getStructEncoder as getStructEncoder28,
2174
- getU8Decoder as getU8Decoder19,
2175
- getU8Encoder as getU8Encoder19,
2176
- SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS14,
2177
- SolanaError as SolanaError14,
2178
- transformEncoder as transformEncoder14
2642
+ combineCodec as combineCodec33,
2643
+ getProgramDerivedAddress as getProgramDerivedAddress13,
2644
+ getStructDecoder as getStructDecoder31,
2645
+ getStructEncoder as getStructEncoder31,
2646
+ getU8Decoder as getU8Decoder22,
2647
+ getU8Encoder as getU8Encoder22,
2648
+ getUtf8Encoder as getUtf8Encoder15,
2649
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS17,
2650
+ SolanaError as SolanaError17,
2651
+ transformEncoder as transformEncoder17
2179
2652
  } from "@solana/kit";
2180
- import { getAccountMetaFactory as getAccountMetaFactory14 } from "@solana/program-client-core";
2653
+ import { getAccountMetaFactory as getAccountMetaFactory17 } from "@solana/program-client-core";
2181
2654
  var UPDATE_PLAN_DISCRIMINATOR = 8;
2182
2655
  function getUpdatePlanDiscriminatorBytes() {
2183
- return getU8Encoder19().encode(UPDATE_PLAN_DISCRIMINATOR);
2656
+ return getU8Encoder22().encode(UPDATE_PLAN_DISCRIMINATOR);
2184
2657
  }
2185
2658
  function getUpdatePlanInstructionDataEncoder() {
2186
- return transformEncoder14(
2187
- getStructEncoder28([
2188
- ["discriminator", getU8Encoder19()],
2659
+ return transformEncoder17(
2660
+ getStructEncoder31([
2661
+ ["discriminator", getU8Encoder22()],
2189
2662
  ["updatePlanData", getUpdatePlanDataEncoder()]
2190
2663
  ]),
2191
2664
  (value) => ({ ...value, discriminator: UPDATE_PLAN_DISCRIMINATOR })
2192
2665
  );
2193
2666
  }
2194
2667
  function getUpdatePlanInstructionDataDecoder() {
2195
- return getStructDecoder28([
2196
- ["discriminator", getU8Decoder19()],
2668
+ return getStructDecoder31([
2669
+ ["discriminator", getU8Decoder22()],
2197
2670
  ["updatePlanData", getUpdatePlanDataDecoder()]
2198
2671
  ]);
2199
2672
  }
2200
2673
  function getUpdatePlanInstructionDataCodec() {
2201
- return combineCodec30(getUpdatePlanInstructionDataEncoder(), getUpdatePlanInstructionDataDecoder());
2674
+ return combineCodec33(getUpdatePlanInstructionDataEncoder(), getUpdatePlanInstructionDataDecoder());
2675
+ }
2676
+ async function getUpdatePlanInstructionAsync(input, config) {
2677
+ const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
2678
+ const originalAccounts = {
2679
+ owner: { value: input.owner ?? null, isWritable: false },
2680
+ planPda: { value: input.planPda ?? null, isWritable: true },
2681
+ eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
2682
+ selfProgram: { value: input.selfProgram ?? null, isWritable: false }
2683
+ };
2684
+ const accounts = originalAccounts;
2685
+ const args = { ...input };
2686
+ if (!accounts.eventAuthority.value) {
2687
+ accounts.eventAuthority.value = await getProgramDerivedAddress13({
2688
+ programAddress,
2689
+ seeds: [getUtf8Encoder15().encode("event_authority")]
2690
+ });
2691
+ }
2692
+ if (!accounts.selfProgram.value) {
2693
+ accounts.selfProgram.value = programAddress;
2694
+ accounts.selfProgram.isWritable = false;
2695
+ }
2696
+ const getAccountMeta = getAccountMetaFactory17(programAddress, "programId");
2697
+ return Object.freeze({
2698
+ accounts: [
2699
+ getAccountMeta("owner", accounts.owner),
2700
+ getAccountMeta("planPda", accounts.planPda),
2701
+ getAccountMeta("eventAuthority", accounts.eventAuthority),
2702
+ getAccountMeta("selfProgram", accounts.selfProgram)
2703
+ ],
2704
+ data: getUpdatePlanInstructionDataEncoder().encode(args),
2705
+ programAddress
2706
+ });
2202
2707
  }
2203
2708
  function getUpdatePlanInstruction(input, config) {
2204
2709
  const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
2205
2710
  const originalAccounts = {
2206
2711
  owner: { value: input.owner ?? null, isWritable: false },
2207
- planPda: { value: input.planPda ?? null, isWritable: true }
2712
+ planPda: { value: input.planPda ?? null, isWritable: true },
2713
+ eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
2714
+ selfProgram: { value: input.selfProgram ?? null, isWritable: false }
2208
2715
  };
2209
2716
  const accounts = originalAccounts;
2210
2717
  const args = { ...input };
2211
- const getAccountMeta = getAccountMetaFactory14(programAddress, "programId");
2718
+ if (!accounts.selfProgram.value) {
2719
+ accounts.selfProgram.value = programAddress;
2720
+ accounts.selfProgram.isWritable = false;
2721
+ }
2722
+ const getAccountMeta = getAccountMetaFactory17(programAddress, "programId");
2212
2723
  return Object.freeze({
2213
- accounts: [getAccountMeta("owner", accounts.owner), getAccountMeta("planPda", accounts.planPda)],
2724
+ accounts: [
2725
+ getAccountMeta("owner", accounts.owner),
2726
+ getAccountMeta("planPda", accounts.planPda),
2727
+ getAccountMeta("eventAuthority", accounts.eventAuthority),
2728
+ getAccountMeta("selfProgram", accounts.selfProgram)
2729
+ ],
2214
2730
  data: getUpdatePlanInstructionDataEncoder().encode(args),
2215
2731
  programAddress
2216
2732
  });
2217
2733
  }
2218
2734
  function parseUpdatePlanInstruction(instruction) {
2219
- if (instruction.accounts.length < 2) {
2220
- throw new SolanaError14(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS14, {
2735
+ if (instruction.accounts.length < 4) {
2736
+ throw new SolanaError17(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS17, {
2221
2737
  actualAccountMetas: instruction.accounts.length,
2222
- expectedAccountMetas: 2
2738
+ expectedAccountMetas: 4
2223
2739
  });
2224
2740
  }
2225
2741
  let accountIndex = 0;
@@ -2230,7 +2746,12 @@ function parseUpdatePlanInstruction(instruction) {
2230
2746
  };
2231
2747
  return {
2232
2748
  programAddress: instruction.programAddress,
2233
- accounts: { owner: getNextAccount(), planPda: getNextAccount() },
2749
+ accounts: {
2750
+ owner: getNextAccount(),
2751
+ planPda: getNextAccount(),
2752
+ eventAuthority: getNextAccount(),
2753
+ selfProgram: getNextAccount()
2754
+ },
2234
2755
  data: getUpdatePlanInstructionDataDecoder().decode(instruction.data)
2235
2756
  };
2236
2757
  }
@@ -2261,53 +2782,65 @@ var SubscriptionsInstruction = /* @__PURE__ */ ((SubscriptionsInstruction2) => {
2261
2782
  SubscriptionsInstruction2[SubscriptionsInstruction2["Subscribe"] = 11] = "Subscribe";
2262
2783
  SubscriptionsInstruction2[SubscriptionsInstruction2["CancelSubscription"] = 12] = "CancelSubscription";
2263
2784
  SubscriptionsInstruction2[SubscriptionsInstruction2["ResumeSubscription"] = 13] = "ResumeSubscription";
2785
+ SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeSubscriptionAuthority"] = 14] = "RevokeSubscriptionAuthority";
2786
+ SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeAbandonedDelegation"] = 15] = "RevokeAbandonedDelegation";
2787
+ SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeAbandonedSubscription"] = 16] = "RevokeAbandonedSubscription";
2264
2788
  return SubscriptionsInstruction2;
2265
2789
  })(SubscriptionsInstruction || {});
2266
2790
  function identifySubscriptionsInstruction(instruction) {
2267
2791
  const data = "data" in instruction ? instruction.data : instruction;
2268
- if (containsBytes(data, getU8Encoder20().encode(0), 0)) {
2792
+ if (containsBytes(data, getU8Encoder23().encode(0), 0)) {
2269
2793
  return 0 /* InitSubscriptionAuthority */;
2270
2794
  }
2271
- if (containsBytes(data, getU8Encoder20().encode(1), 0)) {
2795
+ if (containsBytes(data, getU8Encoder23().encode(1), 0)) {
2272
2796
  return 1 /* CreateFixedDelegation */;
2273
2797
  }
2274
- if (containsBytes(data, getU8Encoder20().encode(2), 0)) {
2798
+ if (containsBytes(data, getU8Encoder23().encode(2), 0)) {
2275
2799
  return 2 /* CreateRecurringDelegation */;
2276
2800
  }
2277
- if (containsBytes(data, getU8Encoder20().encode(3), 0)) {
2801
+ if (containsBytes(data, getU8Encoder23().encode(3), 0)) {
2278
2802
  return 3 /* RevokeDelegation */;
2279
2803
  }
2280
- if (containsBytes(data, getU8Encoder20().encode(4), 0)) {
2804
+ if (containsBytes(data, getU8Encoder23().encode(4), 0)) {
2281
2805
  return 4 /* TransferFixed */;
2282
2806
  }
2283
- if (containsBytes(data, getU8Encoder20().encode(5), 0)) {
2807
+ if (containsBytes(data, getU8Encoder23().encode(5), 0)) {
2284
2808
  return 5 /* TransferRecurring */;
2285
2809
  }
2286
- if (containsBytes(data, getU8Encoder20().encode(6), 0)) {
2810
+ if (containsBytes(data, getU8Encoder23().encode(6), 0)) {
2287
2811
  return 6 /* CloseSubscriptionAuthority */;
2288
2812
  }
2289
- if (containsBytes(data, getU8Encoder20().encode(7), 0)) {
2813
+ if (containsBytes(data, getU8Encoder23().encode(7), 0)) {
2290
2814
  return 7 /* CreatePlan */;
2291
2815
  }
2292
- if (containsBytes(data, getU8Encoder20().encode(8), 0)) {
2816
+ if (containsBytes(data, getU8Encoder23().encode(8), 0)) {
2293
2817
  return 8 /* UpdatePlan */;
2294
2818
  }
2295
- if (containsBytes(data, getU8Encoder20().encode(9), 0)) {
2819
+ if (containsBytes(data, getU8Encoder23().encode(9), 0)) {
2296
2820
  return 9 /* DeletePlan */;
2297
2821
  }
2298
- if (containsBytes(data, getU8Encoder20().encode(10), 0)) {
2822
+ if (containsBytes(data, getU8Encoder23().encode(10), 0)) {
2299
2823
  return 10 /* TransferSubscription */;
2300
2824
  }
2301
- if (containsBytes(data, getU8Encoder20().encode(11), 0)) {
2825
+ if (containsBytes(data, getU8Encoder23().encode(11), 0)) {
2302
2826
  return 11 /* Subscribe */;
2303
2827
  }
2304
- if (containsBytes(data, getU8Encoder20().encode(12), 0)) {
2828
+ if (containsBytes(data, getU8Encoder23().encode(12), 0)) {
2305
2829
  return 12 /* CancelSubscription */;
2306
2830
  }
2307
- if (containsBytes(data, getU8Encoder20().encode(13), 0)) {
2831
+ if (containsBytes(data, getU8Encoder23().encode(13), 0)) {
2308
2832
  return 13 /* ResumeSubscription */;
2309
2833
  }
2310
- throw new SolanaError15(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
2834
+ if (containsBytes(data, getU8Encoder23().encode(14), 0)) {
2835
+ return 14 /* RevokeSubscriptionAuthority */;
2836
+ }
2837
+ if (containsBytes(data, getU8Encoder23().encode(15), 0)) {
2838
+ return 15 /* RevokeAbandonedDelegation */;
2839
+ }
2840
+ if (containsBytes(data, getU8Encoder23().encode(16), 0)) {
2841
+ return 16 /* RevokeAbandonedSubscription */;
2842
+ }
2843
+ throw new SolanaError18(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
2311
2844
  instructionData: data,
2312
2845
  programName: "subscriptions"
2313
2846
  });
@@ -2401,8 +2934,29 @@ function parseSubscriptionsInstruction(instruction) {
2401
2934
  ...parseResumeSubscriptionInstruction(instruction)
2402
2935
  };
2403
2936
  }
2937
+ case 14 /* RevokeSubscriptionAuthority */: {
2938
+ assertIsInstructionWithAccounts(instruction);
2939
+ return {
2940
+ instructionType: 14 /* RevokeSubscriptionAuthority */,
2941
+ ...parseRevokeSubscriptionAuthorityInstruction(instruction)
2942
+ };
2943
+ }
2944
+ case 15 /* RevokeAbandonedDelegation */: {
2945
+ assertIsInstructionWithAccounts(instruction);
2946
+ return {
2947
+ instructionType: 15 /* RevokeAbandonedDelegation */,
2948
+ ...parseRevokeAbandonedDelegationInstruction(instruction)
2949
+ };
2950
+ }
2951
+ case 16 /* RevokeAbandonedSubscription */: {
2952
+ assertIsInstructionWithAccounts(instruction);
2953
+ return {
2954
+ instructionType: 16 /* RevokeAbandonedSubscription */,
2955
+ ...parseRevokeAbandonedSubscriptionInstruction(instruction)
2956
+ };
2957
+ }
2404
2958
  default:
2405
- throw new SolanaError15(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
2959
+ throw new SolanaError18(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
2406
2960
  instructionType,
2407
2961
  programName: "subscriptions"
2408
2962
  });
@@ -2425,16 +2979,19 @@ function subscriptionsProgram() {
2425
2979
  createFixedDelegation: (input) => addSelfPlanAndSendFunctions(client, getCreateFixedDelegationInstruction(input)),
2426
2980
  createRecurringDelegation: (input) => addSelfPlanAndSendFunctions(client, getCreateRecurringDelegationInstruction(input)),
2427
2981
  revokeDelegation: (input) => addSelfPlanAndSendFunctions(client, getRevokeDelegationInstruction(input)),
2428
- transferFixed: (input) => addSelfPlanAndSendFunctions(client, getTransferFixedInstruction(input)),
2429
- transferRecurring: (input) => addSelfPlanAndSendFunctions(client, getTransferRecurringInstruction(input)),
2982
+ transferFixed: (input) => addSelfPlanAndSendFunctions(client, getTransferFixedInstructionAsync(input)),
2983
+ transferRecurring: (input) => addSelfPlanAndSendFunctions(client, getTransferRecurringInstructionAsync(input)),
2430
2984
  closeSubscriptionAuthority: (input) => addSelfPlanAndSendFunctions(client, getCloseSubscriptionAuthorityInstruction(input)),
2431
2985
  createPlan: (input) => addSelfPlanAndSendFunctions(client, getCreatePlanInstruction(input)),
2432
- updatePlan: (input) => addSelfPlanAndSendFunctions(client, getUpdatePlanInstruction(input)),
2986
+ updatePlan: (input) => addSelfPlanAndSendFunctions(client, getUpdatePlanInstructionAsync(input)),
2433
2987
  deletePlan: (input) => addSelfPlanAndSendFunctions(client, getDeletePlanInstruction(input)),
2434
- transferSubscription: (input) => addSelfPlanAndSendFunctions(client, getTransferSubscriptionInstruction(input)),
2988
+ transferSubscription: (input) => addSelfPlanAndSendFunctions(client, getTransferSubscriptionInstructionAsync(input)),
2435
2989
  subscribe: (input) => addSelfPlanAndSendFunctions(client, getSubscribeInstructionAsync(input)),
2436
2990
  cancelSubscription: (input) => addSelfPlanAndSendFunctions(client, getCancelSubscriptionInstructionAsync(input)),
2437
- resumeSubscription: (input) => addSelfPlanAndSendFunctions(client, getResumeSubscriptionInstructionAsync(input))
2991
+ resumeSubscription: (input) => addSelfPlanAndSendFunctions(client, getResumeSubscriptionInstructionAsync(input)),
2992
+ revokeSubscriptionAuthority: (input) => addSelfPlanAndSendFunctions(client, getRevokeSubscriptionAuthorityInstructionAsync(input)),
2993
+ revokeAbandonedDelegation: (input) => addSelfPlanAndSendFunctions(client, getRevokeAbandonedDelegationInstruction(input)),
2994
+ revokeAbandonedSubscription: (input) => addSelfPlanAndSendFunctions(client, getRevokeAbandonedSubscriptionInstruction(input))
2438
2995
  },
2439
2996
  pdas: {
2440
2997
  fixedDelegation: findFixedDelegationPda,
@@ -2487,6 +3044,7 @@ var SUBSCRIPTIONS_ERROR__DELEGATION_VERSION_MISMATCH = 133;
2487
3044
  var SUBSCRIPTIONS_ERROR__MIGRATION_REQUIRED = 134;
2488
3045
  var SUBSCRIPTIONS_ERROR__DELEGATION_ALREADY_EXISTS = 135;
2489
3046
  var SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY = 136;
3047
+ var SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS = 137;
2490
3048
  var SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_LIMIT = 300;
2491
3049
  var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_EXPIRY_IN_PAST = 301;
2492
3050
  var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_AMOUNT_ZERO = 302;
@@ -2498,6 +3056,7 @@ var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST = 404;
2498
3056
  var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY = 405;
2499
3057
  var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO = 406;
2500
3058
  var SUBSCRIPTIONS_ERROR__DELEGATION_NOT_STARTED = 407;
3059
+ var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY = 408;
2501
3060
  var SUBSCRIPTIONS_ERROR__PLAN_SUNSET = 500;
2502
3061
  var SUBSCRIPTIONS_ERROR__PLAN_EXPIRED = 501;
2503
3062
  var SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA = 502;
@@ -2518,10 +3077,12 @@ var SUBSCRIPTIONS_ERROR__PLAN_CLOSED = 516;
2518
3077
  var SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED = 517;
2519
3078
  var SUBSCRIPTIONS_ERROR__PLAN_ALREADY_EXISTS = 518;
2520
3079
  var SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH = 519;
3080
+ var SUBSCRIPTIONS_ERROR__PLAN_END_TS_CANNOT_EXTEND = 520;
2521
3081
  var SUBSCRIPTIONS_ERROR__INVALID_EVENT_AUTHORITY = 600;
2522
3082
  var SUBSCRIPTIONS_ERROR__INVALID_EVENT_DATA = 601;
2523
3083
  var SUBSCRIPTIONS_ERROR__INVALID_EVENT_TAG = 602;
2524
3084
  var SUBSCRIPTIONS_ERROR__INVALID_EVENT_DISCRIMINATOR = 603;
3085
+ var SUBSCRIPTIONS_ERROR__INVALID_SELF_PROGRAM = 604;
2525
3086
  var subscriptionsErrorMessages;
2526
3087
  if (process.env["NODE_ENV"] !== "production") {
2527
3088
  subscriptionsErrorMessages = {
@@ -2558,6 +3119,7 @@ if (process.env["NODE_ENV"] !== "production") {
2558
3119
  [SUBSCRIPTIONS_ERROR__INVALID_PERIOD_LENGTH]: `Invalid Period length`,
2559
3120
  [SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA]: `Invalid Plan PDA derivation`,
2560
3121
  [SUBSCRIPTIONS_ERROR__INVALID_PLAN_STATUS]: `Invalid plan status value`,
3122
+ [SUBSCRIPTIONS_ERROR__INVALID_SELF_PROGRAM]: `Self program account does not match this program`,
2561
3123
  [SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_AUTHORITY_PDA]: `Invalid subscription-authority PDA derivation`,
2562
3124
  [SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_PDA]: `Invalid subscription PDA derivation`,
2563
3125
  [SUBSCRIPTIONS_ERROR__INVALID_TOKEN2022_MINT_ACCOUNT_DATA]: `Invalid Token-2022 mint account data`,
@@ -2581,12 +3143,14 @@ if (process.env["NODE_ENV"] !== "production") {
2581
3143
  [SUBSCRIPTIONS_ERROR__PERIOD_NOT_ELAPSED]: `Period has not elapsed yet`,
2582
3144
  [SUBSCRIPTIONS_ERROR__PLAN_ALREADY_EXISTS]: `Plan account already exists`,
2583
3145
  [SUBSCRIPTIONS_ERROR__PLAN_CLOSED]: `Plan account has been closed`,
3146
+ [SUBSCRIPTIONS_ERROR__PLAN_END_TS_CANNOT_EXTEND]: `A finite plan end timestamp can only be shortened, not removed or extended`,
2584
3147
  [SUBSCRIPTIONS_ERROR__PLAN_EXPIRED]: `Plan has expired`,
2585
3148
  [SUBSCRIPTIONS_ERROR__PLAN_IMMUTABLE_AFTER_SUNSET]: `Plan cannot be updated after sunset`,
2586
3149
  [SUBSCRIPTIONS_ERROR__PLAN_NOT_EXPIRED]: `Plan must be expired to delete`,
2587
3150
  [SUBSCRIPTIONS_ERROR__PLAN_SUNSET]: `Plan is in sunset status`,
2588
3151
  [SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH]: `Subscription plan terms do not match the current plan`,
2589
3152
  [SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO]: `zero amount specified`,
3153
+ [SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY]: `start_ts of 0 (start on landing) requires a non-zero expiry`,
2590
3154
  [SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY]: `start time specified is greater than expiry`,
2591
3155
  [SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST]: `Past start time specified`,
2592
3156
  [SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY]: `Delegation init_id does not match current SubscriptionAuthority`,
@@ -2595,6 +3159,7 @@ if (process.env["NODE_ENV"] !== "production") {
2595
3159
  [SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED]: `Subscription is not cancelled`,
2596
3160
  [SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH]: `Subscription does not belong to this plan`,
2597
3161
  [SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS]: `Sunset requires a non-zero end timestamp`,
3162
+ [SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS]: `Too many transfer hook accounts provided`,
2598
3163
  [SUBSCRIPTIONS_ERROR__UNAUTHORIZED]: `Caller not authorized for this action`,
2599
3164
  [SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION]: `Destination not in plan whitelist`
2600
3165
  };
@@ -2749,12 +3314,156 @@ async function fetchSubscriptionsForUser(rpc, user, programAddress) {
2749
3314
 
2750
3315
  // src/plugin.ts
2751
3316
  import {
2752
- AccountRole,
3317
+ AccountRole as AccountRole2,
2753
3318
  pipe
2754
3319
  } from "@solana/kit";
2755
3320
  import { addSelfPlanAndSendFunctions as addSelfPlanAndSendFunctions2 } from "@solana/program-client-core";
2756
3321
  import { findAssociatedTokenPda } from "@solana-program/token";
2757
3322
 
3323
+ // src/transfer-hook.ts
3324
+ import {
3325
+ AccountRole,
3326
+ fetchEncodedAccount as fetchEncodedAccount7,
3327
+ getAddressDecoder as getAddressDecoder10,
3328
+ getAddressEncoder as getAddressEncoder15,
3329
+ getProgramDerivedAddress as getProgramDerivedAddress14
3330
+ } from "@solana/kit";
3331
+ import { fetchMint, TOKEN_2022_PROGRAM_ADDRESS } from "@solana-program/token-2022";
3332
+ var DEFAULT_ADDRESS = "11111111111111111111111111111111";
3333
+ var EXTRA_ACCOUNT_METAS_SEED = "extra-account-metas";
3334
+ var TLV_HEADER_LEN = 12;
3335
+ var POD_SLICE_COUNT_LEN = 4;
3336
+ var EXTRA_ACCOUNT_META_LEN = 35;
3337
+ var PUBKEY_LEN = 32;
3338
+ var PDA_PROGRAM_INDEX_OFFSET = 1 << 7;
3339
+ var EXECUTE_DISCRIMINATOR = Uint8Array.from([105, 37, 101, 197, 75, 251, 102, 26]);
3340
+ var addressDecoder = getAddressDecoder10();
3341
+ var addressEncoder = getAddressEncoder15();
3342
+ function roleFor(isSigner, isWritable) {
3343
+ if (isSigner && isWritable) return AccountRole.WRITABLE_SIGNER;
3344
+ if (isSigner) return AccountRole.READONLY_SIGNER;
3345
+ if (isWritable) return AccountRole.WRITABLE;
3346
+ return AccountRole.READONLY;
3347
+ }
3348
+ async function fetchData(rpc, address) {
3349
+ const account = await fetchEncodedAccount7(rpc, address);
3350
+ if (!account.exists) throw new Error("transfer hook: referenced account not found");
3351
+ return account.data;
3352
+ }
3353
+ function executeInstructionData(amount) {
3354
+ const data = new Uint8Array(EXECUTE_DISCRIMINATOR.length + 8);
3355
+ data.set(EXECUTE_DISCRIMINATOR, 0);
3356
+ new DataView(data.buffer).setBigUint64(EXECUTE_DISCRIMINATOR.length, BigInt(amount), true);
3357
+ return data;
3358
+ }
3359
+ function readMetas(data) {
3360
+ if (data.length < TLV_HEADER_LEN || !EXECUTE_DISCRIMINATOR.every((byte, i) => data[i] === byte)) {
3361
+ return [];
3362
+ }
3363
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
3364
+ const count = view.getUint32(TLV_HEADER_LEN, true);
3365
+ const metas = [];
3366
+ let offset = TLV_HEADER_LEN + POD_SLICE_COUNT_LEN;
3367
+ for (let n = 0; n < count && offset + EXTRA_ACCOUNT_META_LEN <= data.length; n++) {
3368
+ metas.push({
3369
+ addressConfig: data.subarray(offset + 1, offset + 33),
3370
+ discriminator: data[offset],
3371
+ isSigner: data[offset + 33] === 1,
3372
+ isWritable: data[offset + 34] === 1
3373
+ });
3374
+ offset += EXTRA_ACCOUNT_META_LEN;
3375
+ }
3376
+ return metas;
3377
+ }
3378
+ async function unpackSeeds(config, previous, instructionData, rpc) {
3379
+ const seeds = [];
3380
+ let i = 0;
3381
+ while (i < 32) {
3382
+ const discriminator = config[i];
3383
+ const rest = config.subarray(i + 1);
3384
+ if (discriminator === 0) break;
3385
+ if (discriminator === 1) {
3386
+ const length = rest[0];
3387
+ seeds.push(rest.subarray(1, 1 + length));
3388
+ i += 2 + length;
3389
+ } else if (discriminator === 2) {
3390
+ const [index, length] = [rest[0], rest[1]];
3391
+ seeds.push(instructionData.subarray(index, index + length));
3392
+ i += 3;
3393
+ } else if (discriminator === 3) {
3394
+ seeds.push(addressEncoder.encode(previous[rest[0]].address));
3395
+ i += 2;
3396
+ } else if (discriminator === 4) {
3397
+ const [accountIndex, dataIndex, length] = [rest[0], rest[1], rest[2]];
3398
+ const data = await fetchData(rpc, previous[accountIndex].address);
3399
+ seeds.push(data.subarray(dataIndex, dataIndex + length));
3400
+ i += 4;
3401
+ } else {
3402
+ throw new Error("transfer hook: invalid seed");
3403
+ }
3404
+ }
3405
+ return seeds;
3406
+ }
3407
+ async function unpackPubkeyData(config, previous, instructionData, rpc) {
3408
+ const rest = config.subarray(1);
3409
+ if (config[0] === 1) {
3410
+ const offset = rest[0];
3411
+ return addressDecoder.decode(instructionData.subarray(offset, offset + PUBKEY_LEN));
3412
+ }
3413
+ if (config[0] === 2) {
3414
+ const [accountIndex, offset] = [rest[0], rest[1]];
3415
+ const data = await fetchData(rpc, previous[accountIndex].address);
3416
+ return addressDecoder.decode(data.subarray(offset, offset + PUBKEY_LEN));
3417
+ }
3418
+ throw new Error("transfer hook: invalid pubkey data");
3419
+ }
3420
+ async function resolveMeta(meta, previous, instructionData, hookProgram, rpc) {
3421
+ const role = roleFor(meta.isSigner, meta.isWritable);
3422
+ if (meta.discriminator === 0) {
3423
+ return { address: addressDecoder.decode(meta.addressConfig), role };
3424
+ }
3425
+ if (meta.discriminator === 2) {
3426
+ return { address: await unpackPubkeyData(meta.addressConfig, previous, instructionData, rpc), role };
3427
+ }
3428
+ const programId = meta.discriminator === 1 ? hookProgram : previous[meta.discriminator - PDA_PROGRAM_INDEX_OFFSET].address;
3429
+ const seeds = await unpackSeeds(meta.addressConfig, previous, instructionData, rpc);
3430
+ const [pda] = await getProgramDerivedAddress14({ programAddress: programId, seeds });
3431
+ return { address: pda, role };
3432
+ }
3433
+ async function resolveTransferHookAccounts(rpc, args) {
3434
+ if (args.transferHookAccounts?.length) return args.transferHookAccounts;
3435
+ if (args.tokenProgram !== TOKEN_2022_PROGRAM_ADDRESS) return [];
3436
+ const { data } = await fetchMint(rpc, args.mint);
3437
+ const extensions = data.extensions.__option === "Some" ? data.extensions.value : [];
3438
+ const hook = extensions.find((extension) => extension.__kind === "TransferHook");
3439
+ if (!hook || hook.programId === DEFAULT_ADDRESS) return [];
3440
+ const hookProgram = hook.programId;
3441
+ const [validationPda] = await getProgramDerivedAddress14({
3442
+ programAddress: hookProgram,
3443
+ seeds: [EXTRA_ACCOUNT_METAS_SEED, addressEncoder.encode(args.mint)]
3444
+ });
3445
+ const trailing = [
3446
+ { address: hookProgram, role: AccountRole.READONLY },
3447
+ { address: validationPda, role: AccountRole.READONLY }
3448
+ ];
3449
+ const validationAccount = await fetchEncodedAccount7(rpc, validationPda);
3450
+ if (!validationAccount.exists) return trailing;
3451
+ const instructionData = executeInstructionData(args.amount);
3452
+ const previous = [
3453
+ { address: args.source, role: AccountRole.READONLY },
3454
+ { address: args.mint, role: AccountRole.READONLY },
3455
+ { address: args.destination, role: AccountRole.READONLY },
3456
+ { address: args.authority, role: AccountRole.READONLY },
3457
+ { address: validationPda, role: AccountRole.READONLY }
3458
+ ];
3459
+ for (const meta of readMetas(validationAccount.data)) {
3460
+ const resolved = await resolveMeta(meta, previous, instructionData, hookProgram, rpc);
3461
+ previous.push(resolved);
3462
+ trailing.push(resolved);
3463
+ }
3464
+ return trailing;
3465
+ }
3466
+
2758
3467
  // src/validators.ts
2759
3468
  var textEncoder = new TextEncoder();
2760
3469
  var ValidationError = class extends Error {
@@ -2766,6 +3475,10 @@ var ValidationError = class extends Error {
2766
3475
  function assertPositive(value, name) {
2767
3476
  if (BigInt(value) <= 0n) throw new ValidationError(`${name} must be greater than zero`);
2768
3477
  }
3478
+ function assertSafeU64(value, name) {
3479
+ if (typeof value === "number" && !Number.isSafeInteger(value))
3480
+ throw new ValidationError(`${name} must be a bigint or a safe integer (numbers above 2^53-1 lose precision)`);
3481
+ }
2769
3482
  function assertMetadataUri(metadataUri) {
2770
3483
  if (textEncoder.encode(metadataUri).length > METADATA_URI_LEN)
2771
3484
  throw new ValidationError(`metadataUri exceeds ${METADATA_URI_LEN} bytes`);
@@ -2789,6 +3502,10 @@ function padPlanPullers(addresses) {
2789
3502
  function pdaConfig(programAddress) {
2790
3503
  return programAddress ? { programAddress } : {};
2791
3504
  }
3505
+ async function eventAccounts(programAddress) {
3506
+ const [eventAuthority] = await findEventAuthorityPda(pdaConfig(programAddress));
3507
+ return { eventAuthority, selfProgram: programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS };
3508
+ }
2792
3509
  function withTrailing(instruction, trailing) {
2793
3510
  if (trailing.length === 0) return instruction;
2794
3511
  const accounts = [
@@ -2802,7 +3519,7 @@ function appendPayer(instruction, payer) {
2802
3519
  return withTrailing(instruction, [
2803
3520
  {
2804
3521
  address: payer.address,
2805
- role: AccountRole.WRITABLE_SIGNER,
3522
+ role: AccountRole2.WRITABLE_SIGNER,
2806
3523
  signer: payer
2807
3524
  }
2808
3525
  ]);
@@ -2831,7 +3548,32 @@ async function getCloseSubscriptionAuthorityOverlayInstructionAsync(input) {
2831
3548
  pdaConfig(input.programAddress)
2832
3549
  );
2833
3550
  if (input.receiver) {
2834
- ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole.WRITABLE }]);
3551
+ ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole2.WRITABLE }]);
3552
+ }
3553
+ return ix;
3554
+ }
3555
+ async function getRevokeSubscriptionAuthorityOverlayInstructionAsync(input) {
3556
+ const [userAta] = await findAssociatedTokenPda({
3557
+ mint: input.tokenMint,
3558
+ owner: input.user.address,
3559
+ tokenProgram: input.tokenProgram
3560
+ });
3561
+ const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
3562
+ { tokenMint: input.tokenMint, user: input.user.address },
3563
+ pdaConfig(input.programAddress)
3564
+ );
3565
+ let ix = getRevokeSubscriptionAuthorityInstruction(
3566
+ {
3567
+ subscriptionAuthority,
3568
+ tokenMint: input.tokenMint,
3569
+ tokenProgram: input.tokenProgram,
3570
+ user: input.user,
3571
+ userAta
3572
+ },
3573
+ pdaConfig(input.programAddress)
3574
+ );
3575
+ if (input.receiver) {
3576
+ ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole2.WRITABLE }]);
2835
3577
  }
2836
3578
  return ix;
2837
3579
  }
@@ -2925,14 +3667,14 @@ function getRevokeDelegationOverlayInstruction(input) {
2925
3667
  pdaConfig(input.programAddress)
2926
3668
  );
2927
3669
  if (input.receiver) {
2928
- ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole.WRITABLE }]);
3670
+ ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole2.WRITABLE }]);
2929
3671
  }
2930
3672
  return ix;
2931
3673
  }
2932
3674
  function getRevokeSubscriptionOverlayInstruction(input) {
2933
- const trailing = [{ address: input.planPda, role: AccountRole.READONLY }];
3675
+ const trailing = [{ address: input.planPda, role: AccountRole2.READONLY }];
2934
3676
  if (input.receiver) {
2935
- trailing.push({ address: input.receiver, role: AccountRole.WRITABLE });
3677
+ trailing.push({ address: input.receiver, role: AccountRole2.WRITABLE });
2936
3678
  }
2937
3679
  return withTrailing(
2938
3680
  getRevokeDelegationInstruction(
@@ -2951,22 +3693,26 @@ async function getTransferDelegationOverlayInstructionAsync(input, getInstructio
2951
3693
  { tokenMint: input.tokenMint, user: input.delegator },
2952
3694
  pdaConfig(input.programAddress)
2953
3695
  );
2954
- return getInstruction(
2955
- {
2956
- delegatee: input.delegatee,
2957
- delegationPda: input.delegationPda,
2958
- delegatorAta: input.delegatorAta,
2959
- receiverAta: input.receiverAta,
2960
- subscriptionAuthority,
2961
- tokenMint: input.tokenMint,
2962
- tokenProgram: input.tokenProgram,
2963
- transferData: {
2964
- amount: input.amount,
2965
- delegator: input.delegator,
2966
- mint: input.tokenMint
2967
- }
2968
- },
2969
- pdaConfig(input.programAddress)
3696
+ return withTrailing(
3697
+ getInstruction(
3698
+ {
3699
+ ...await eventAccounts(input.programAddress),
3700
+ delegatee: input.delegatee,
3701
+ delegationPda: input.delegationPda,
3702
+ delegatorAta: input.delegatorAta,
3703
+ receiverAta: input.receiverAta,
3704
+ subscriptionAuthority,
3705
+ tokenMint: input.tokenMint,
3706
+ tokenProgram: input.tokenProgram,
3707
+ transferData: {
3708
+ amount: input.amount,
3709
+ delegator: input.delegator,
3710
+ mint: input.tokenMint
3711
+ }
3712
+ },
3713
+ pdaConfig(input.programAddress)
3714
+ ),
3715
+ input.transferHookAccounts ?? []
2970
3716
  );
2971
3717
  }
2972
3718
  function getTransferFixedOverlayInstructionAsync(input) {
@@ -2986,28 +3732,33 @@ async function getTransferSubscriptionOverlayInstructionAsync(input) {
2986
3732
  owner: input.delegator,
2987
3733
  tokenProgram: input.tokenProgram
2988
3734
  });
2989
- return getTransferSubscriptionInstruction(
2990
- {
2991
- caller: input.caller,
2992
- delegatorAta,
2993
- planPda: input.planPda,
2994
- receiverAta: input.receiverAta,
2995
- subscriptionAuthority,
2996
- subscriptionPda: input.subscriptionPda,
2997
- tokenMint: input.tokenMint,
2998
- tokenProgram: input.tokenProgram,
2999
- transferData: {
3000
- amount: input.amount,
3001
- delegator: input.delegator,
3002
- mint: input.tokenMint
3003
- }
3004
- },
3005
- pdaConfig(input.programAddress)
3735
+ return withTrailing(
3736
+ getTransferSubscriptionInstruction(
3737
+ {
3738
+ ...await eventAccounts(input.programAddress),
3739
+ caller: input.caller,
3740
+ delegatorAta,
3741
+ planPda: input.planPda,
3742
+ receiverAta: input.receiverAta,
3743
+ subscriptionAuthority,
3744
+ subscriptionPda: input.subscriptionPda,
3745
+ tokenMint: input.tokenMint,
3746
+ tokenProgram: input.tokenProgram,
3747
+ transferData: {
3748
+ amount: input.amount,
3749
+ delegator: input.delegator,
3750
+ mint: input.tokenMint
3751
+ }
3752
+ },
3753
+ pdaConfig(input.programAddress)
3754
+ ),
3755
+ input.transferHookAccounts ?? []
3006
3756
  );
3007
3757
  }
3008
3758
  async function getCreatePlanOverlayInstructionAsync(input) {
3009
3759
  assertPositive(input.amount, "amount");
3010
3760
  assertPositive(input.periodHours, "periodHours");
3761
+ assertSafeU64(input.planId, "planId");
3011
3762
  assertMetadataUri(input.metadataUri);
3012
3763
  const destinations = padPlanDestinations(input.destinations);
3013
3764
  const pullers = padPlanPullers(input.pullers);
@@ -3038,11 +3789,12 @@ async function getCreatePlanOverlayInstructionAsync(input) {
3038
3789
  pdaConfig(input.programAddress)
3039
3790
  );
3040
3791
  }
3041
- function getUpdatePlanOverlayInstruction(input) {
3792
+ async function getUpdatePlanOverlayInstruction(input) {
3042
3793
  assertMetadataUri(input.metadataUri);
3043
- const pullers = padPlanPullers(input.pullers ?? []);
3794
+ const pullers = padPlanPullers(input.pullers);
3044
3795
  return getUpdatePlanInstruction(
3045
3796
  {
3797
+ ...await eventAccounts(input.programAddress),
3046
3798
  owner: input.owner,
3047
3799
  planPda: input.planPda,
3048
3800
  updatePlanData: {
@@ -3064,6 +3816,7 @@ async function getSubscribeOverlayInstructionAsync(input) {
3064
3816
  "getSubscribeOverlayInstructionAsync requires expectedAmount, expectedPeriodHours, expectedCreatedAt, and expectedSubscriptionAuthorityInitId. Use the plugin client `subscriptions.instructions.subscribe(...)` to auto-fetch from the live plan and authority."
3065
3817
  );
3066
3818
  }
3819
+ assertSafeU64(input.planId, "planId");
3067
3820
  const [planPda, planBump] = await findPlanPda(
3068
3821
  { owner: input.merchant, planId: input.planId },
3069
3822
  pdaConfig(input.programAddress)
@@ -3075,6 +3828,7 @@ async function getSubscribeOverlayInstructionAsync(input) {
3075
3828
  return appendPayer(
3076
3829
  await getSubscribeInstructionAsync(
3077
3830
  {
3831
+ ...await eventAccounts(input.programAddress),
3078
3832
  merchant: input.merchant,
3079
3833
  planPda,
3080
3834
  subscribeData: {
@@ -3094,9 +3848,10 @@ async function getSubscribeOverlayInstructionAsync(input) {
3094
3848
  input.payer
3095
3849
  );
3096
3850
  }
3097
- function getCancelSubscriptionOverlayInstructionAsync(input) {
3098
- return getCancelSubscriptionInstructionAsync(
3851
+ async function getCancelSubscriptionOverlayInstructionAsync(input) {
3852
+ return await getCancelSubscriptionInstructionAsync(
3099
3853
  {
3854
+ ...await eventAccounts(input.programAddress),
3100
3855
  planPda: input.planPda,
3101
3856
  subscriber: input.subscriber,
3102
3857
  subscriptionPda: input.subscriptionPda
@@ -3104,11 +3859,17 @@ function getCancelSubscriptionOverlayInstructionAsync(input) {
3104
3859
  pdaConfig(input.programAddress)
3105
3860
  );
3106
3861
  }
3107
- function getResumeSubscriptionOverlayInstructionAsync(input) {
3108
- return getResumeSubscriptionInstructionAsync(
3862
+ async function getResumeSubscriptionOverlayInstructionAsync(input) {
3863
+ const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
3864
+ { tokenMint: input.tokenMint, user: input.subscriber.address },
3865
+ pdaConfig(input.programAddress)
3866
+ );
3867
+ return await getResumeSubscriptionInstructionAsync(
3109
3868
  {
3869
+ ...await eventAccounts(input.programAddress),
3110
3870
  planPda: input.planPda,
3111
3871
  subscriber: input.subscriber,
3872
+ subscriptionAuthority,
3112
3873
  subscriptionPda: input.subscriptionPda
3113
3874
  },
3114
3875
  pdaConfig(input.programAddress)
@@ -3153,6 +3914,21 @@ function subscriptionsProgram2() {
3153
3914
  }
3154
3915
  return subscriptionAuthority.data.initId;
3155
3916
  };
3917
+ const resolveDelegationHookAccounts = async (input) => {
3918
+ const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
3919
+ { tokenMint: input.tokenMint, user: input.delegator },
3920
+ pdaConfig(input.programAddress)
3921
+ );
3922
+ return await resolveTransferHookAccounts(c.rpc, {
3923
+ amount: input.amount,
3924
+ authority: subscriptionAuthority,
3925
+ destination: input.receiverAta,
3926
+ mint: input.tokenMint,
3927
+ source: input.delegatorAta,
3928
+ tokenProgram: input.tokenProgram,
3929
+ transferHookAccounts: input.transferHookAccounts
3930
+ });
3931
+ };
3156
3932
  const instructions = {
3157
3933
  cancelSubscription: (input) => addSelfPlanAndSendFunctions2(
3158
3934
  client,
@@ -3247,10 +4023,18 @@ function subscriptionsProgram2() {
3247
4023
  authority: input.authority ?? client.identity
3248
4024
  })
3249
4025
  ),
4026
+ revokeSubscriptionAuthority: (input) => addSelfPlanAndSendFunctions2(
4027
+ client,
4028
+ getRevokeSubscriptionAuthorityOverlayInstructionAsync({
4029
+ ...input,
4030
+ user: input.user ?? client.identity
4031
+ })
4032
+ ),
3250
4033
  subscribe: (input) => addSelfPlanAndSendFunctions2(
3251
4034
  client,
3252
4035
  (async () => {
3253
4036
  const subscriber = input.subscriber ?? client.identity;
4037
+ assertSafeU64(input.planId, "planId");
3254
4038
  let {
3255
4039
  expectedAmount,
3256
4040
  expectedCreatedAt,
@@ -3296,24 +4080,47 @@ function subscriptionsProgram2() {
3296
4080
  ),
3297
4081
  transferFixed: (input) => addSelfPlanAndSendFunctions2(
3298
4082
  client,
3299
- getTransferFixedOverlayInstructionAsync({
4083
+ (async () => await getTransferFixedOverlayInstructionAsync({
3300
4084
  ...input,
3301
- delegatee: input.delegatee ?? client.identity
3302
- })
4085
+ delegatee: input.delegatee ?? client.identity,
4086
+ transferHookAccounts: await resolveDelegationHookAccounts(input)
4087
+ }))()
3303
4088
  ),
3304
4089
  transferRecurring: (input) => addSelfPlanAndSendFunctions2(
3305
4090
  client,
3306
- getTransferRecurringOverlayInstructionAsync({
4091
+ (async () => await getTransferRecurringOverlayInstructionAsync({
3307
4092
  ...input,
3308
- delegatee: input.delegatee ?? client.identity
3309
- })
4093
+ delegatee: input.delegatee ?? client.identity,
4094
+ transferHookAccounts: await resolveDelegationHookAccounts(input)
4095
+ }))()
3310
4096
  ),
3311
4097
  transferSubscription: (input) => addSelfPlanAndSendFunctions2(
3312
4098
  client,
3313
- getTransferSubscriptionOverlayInstructionAsync({
3314
- ...input,
3315
- caller: input.caller ?? client.identity
3316
- })
4099
+ (async () => {
4100
+ const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
4101
+ { tokenMint: input.tokenMint, user: input.delegator },
4102
+ pdaConfig(input.programAddress)
4103
+ );
4104
+ const [delegatorAta] = await findAssociatedTokenPda({
4105
+ mint: input.tokenMint,
4106
+ owner: input.delegator,
4107
+ tokenProgram: input.tokenProgram
4108
+ });
4109
+ const transferHookAccounts = await resolveTransferHookAccounts(c.rpc, {
4110
+ amount: input.amount,
4111
+ authority: subscriptionAuthority,
4112
+ destination: input.receiverAta,
4113
+ mint: input.tokenMint,
4114
+ source: delegatorAta,
4115
+ tokenProgram: input.tokenProgram,
4116
+ transferHookAccounts: input.transferHookAccounts
4117
+ });
4118
+ return await getTransferSubscriptionOverlayInstructionAsync({
4119
+ ...input,
4120
+ caller: input.caller ?? client.identity,
4121
+ transferHookAccounts
4122
+ });
4123
+ })()
3317
4124
  ),
3318
4125
  updatePlan: (input) => addSelfPlanAndSendFunctions2(
3319
4126
  client,
@@ -3358,7 +4165,10 @@ export {
3358
4165
  PROGRAM_ID,
3359
4166
  PlanStatus,
3360
4167
  RESUME_SUBSCRIPTION_DISCRIMINATOR,
4168
+ REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR,
4169
+ REVOKE_ABANDONED_SUBSCRIPTION_DISCRIMINATOR,
3361
4170
  REVOKE_DELEGATION_DISCRIMINATOR,
4171
+ REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR,
3362
4172
  SUBSCRIBE_DISCRIMINATOR,
3363
4173
  SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE,
3364
4174
  SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED,
@@ -3393,6 +4203,7 @@ export {
3393
4203
  SUBSCRIPTIONS_ERROR__INVALID_PERIOD_LENGTH,
3394
4204
  SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA,
3395
4205
  SUBSCRIPTIONS_ERROR__INVALID_PLAN_STATUS,
4206
+ SUBSCRIPTIONS_ERROR__INVALID_SELF_PROGRAM,
3396
4207
  SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_AUTHORITY_PDA,
3397
4208
  SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_PDA,
3398
4209
  SUBSCRIPTIONS_ERROR__INVALID_TOKEN2022_MINT_ACCOUNT_DATA,
@@ -3416,12 +4227,14 @@ export {
3416
4227
  SUBSCRIPTIONS_ERROR__PERIOD_NOT_ELAPSED,
3417
4228
  SUBSCRIPTIONS_ERROR__PLAN_ALREADY_EXISTS,
3418
4229
  SUBSCRIPTIONS_ERROR__PLAN_CLOSED,
4230
+ SUBSCRIPTIONS_ERROR__PLAN_END_TS_CANNOT_EXTEND,
3419
4231
  SUBSCRIPTIONS_ERROR__PLAN_EXPIRED,
3420
4232
  SUBSCRIPTIONS_ERROR__PLAN_IMMUTABLE_AFTER_SUNSET,
3421
4233
  SUBSCRIPTIONS_ERROR__PLAN_NOT_EXPIRED,
3422
4234
  SUBSCRIPTIONS_ERROR__PLAN_SUNSET,
3423
4235
  SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH,
3424
4236
  SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO,
4237
+ SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY,
3425
4238
  SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY,
3426
4239
  SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST,
3427
4240
  SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY,
@@ -3430,6 +4243,7 @@ export {
3430
4243
  SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED,
3431
4244
  SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH,
3432
4245
  SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS,
4246
+ SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS,
3433
4247
  SUBSCRIPTIONS_ERROR__UNAUTHORIZED,
3434
4248
  SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION,
3435
4249
  SUBSCRIPTIONS_PROGRAM_ADDRESS,
@@ -3582,12 +4396,29 @@ export {
3582
4396
  getResumeSubscriptionInstructionDataDecoder,
3583
4397
  getResumeSubscriptionInstructionDataEncoder,
3584
4398
  getResumeSubscriptionOverlayInstructionAsync,
4399
+ getRevokeAbandonedDelegationDiscriminatorBytes,
4400
+ getRevokeAbandonedDelegationInstruction,
4401
+ getRevokeAbandonedDelegationInstructionDataCodec,
4402
+ getRevokeAbandonedDelegationInstructionDataDecoder,
4403
+ getRevokeAbandonedDelegationInstructionDataEncoder,
4404
+ getRevokeAbandonedSubscriptionDiscriminatorBytes,
4405
+ getRevokeAbandonedSubscriptionInstruction,
4406
+ getRevokeAbandonedSubscriptionInstructionDataCodec,
4407
+ getRevokeAbandonedSubscriptionInstructionDataDecoder,
4408
+ getRevokeAbandonedSubscriptionInstructionDataEncoder,
3585
4409
  getRevokeDelegationDiscriminatorBytes,
3586
4410
  getRevokeDelegationInstruction,
3587
4411
  getRevokeDelegationInstructionDataCodec,
3588
4412
  getRevokeDelegationInstructionDataDecoder,
3589
4413
  getRevokeDelegationInstructionDataEncoder,
3590
4414
  getRevokeDelegationOverlayInstruction,
4415
+ getRevokeSubscriptionAuthorityDiscriminatorBytes,
4416
+ getRevokeSubscriptionAuthorityInstruction,
4417
+ getRevokeSubscriptionAuthorityInstructionAsync,
4418
+ getRevokeSubscriptionAuthorityInstructionDataCodec,
4419
+ getRevokeSubscriptionAuthorityInstructionDataDecoder,
4420
+ getRevokeSubscriptionAuthorityInstructionDataEncoder,
4421
+ getRevokeSubscriptionAuthorityOverlayInstructionAsync,
3591
4422
  getRevokeSubscriptionOverlayInstruction,
3592
4423
  getSubscribeDataCodec,
3593
4424
  getSubscribeDataDecoder,
@@ -3611,18 +4442,21 @@ export {
3611
4442
  getTransferDataEncoder,
3612
4443
  getTransferFixedDiscriminatorBytes,
3613
4444
  getTransferFixedInstruction,
4445
+ getTransferFixedInstructionAsync,
3614
4446
  getTransferFixedInstructionDataCodec,
3615
4447
  getTransferFixedInstructionDataDecoder,
3616
4448
  getTransferFixedInstructionDataEncoder,
3617
4449
  getTransferFixedOverlayInstructionAsync,
3618
4450
  getTransferRecurringDiscriminatorBytes,
3619
4451
  getTransferRecurringInstruction,
4452
+ getTransferRecurringInstructionAsync,
3620
4453
  getTransferRecurringInstructionDataCodec,
3621
4454
  getTransferRecurringInstructionDataDecoder,
3622
4455
  getTransferRecurringInstructionDataEncoder,
3623
4456
  getTransferRecurringOverlayInstructionAsync,
3624
4457
  getTransferSubscriptionDiscriminatorBytes,
3625
4458
  getTransferSubscriptionInstruction,
4459
+ getTransferSubscriptionInstructionAsync,
3626
4460
  getTransferSubscriptionInstructionDataCodec,
3627
4461
  getTransferSubscriptionInstructionDataDecoder,
3628
4462
  getTransferSubscriptionInstructionDataEncoder,
@@ -3632,6 +4466,7 @@ export {
3632
4466
  getUpdatePlanDataEncoder,
3633
4467
  getUpdatePlanDiscriminatorBytes,
3634
4468
  getUpdatePlanInstruction,
4469
+ getUpdatePlanInstructionAsync,
3635
4470
  getUpdatePlanInstructionDataCodec,
3636
4471
  getUpdatePlanInstructionDataDecoder,
3637
4472
  getUpdatePlanInstructionDataEncoder,
@@ -3646,13 +4481,17 @@ export {
3646
4481
  parseDeletePlanInstruction,
3647
4482
  parseInitSubscriptionAuthorityInstruction,
3648
4483
  parseResumeSubscriptionInstruction,
4484
+ parseRevokeAbandonedDelegationInstruction,
4485
+ parseRevokeAbandonedSubscriptionInstruction,
3649
4486
  parseRevokeDelegationInstruction,
4487
+ parseRevokeSubscriptionAuthorityInstruction,
3650
4488
  parseSubscribeInstruction,
3651
4489
  parseSubscriptionsInstruction,
3652
4490
  parseTransferFixedInstruction,
3653
4491
  parseTransferRecurringInstruction,
3654
4492
  parseTransferSubscriptionInstruction,
3655
4493
  parseUpdatePlanInstruction,
4494
+ resolveTransferHookAccounts,
3656
4495
  subscriptionsProgram2 as subscriptionsProgram,
3657
4496
  toEncodedAccount
3658
4497
  };