@solana/subscriptions 0.3.0 → 0.4.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.cjs +602 -189
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +165 -6
- package/dist/index.d.ts +165 -6
- package/dist/index.js +585 -167
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
package/dist/index.js
CHANGED
|
@@ -862,10 +862,10 @@ import {
|
|
|
862
862
|
assertIsInstructionWithAccounts,
|
|
863
863
|
containsBytes,
|
|
864
864
|
extendClient,
|
|
865
|
-
getU8Encoder as
|
|
865
|
+
getU8Encoder as getU8Encoder22,
|
|
866
866
|
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
|
|
867
867
|
SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
|
|
868
|
-
SolanaError as
|
|
868
|
+
SolanaError as SolanaError17
|
|
869
869
|
} from "@solana/kit";
|
|
870
870
|
import {
|
|
871
871
|
addSelfFetchFunctions,
|
|
@@ -1639,7 +1639,7 @@ function parseResumeSubscriptionInstruction(instruction) {
|
|
|
1639
1639
|
};
|
|
1640
1640
|
}
|
|
1641
1641
|
|
|
1642
|
-
// src/generated/instructions/
|
|
1642
|
+
// src/generated/instructions/revokeAbandonedDelegation.ts
|
|
1643
1643
|
import {
|
|
1644
1644
|
combineCodec as combineCodec25,
|
|
1645
1645
|
getStructDecoder as getStructDecoder23,
|
|
@@ -1651,21 +1651,95 @@ import {
|
|
|
1651
1651
|
transformEncoder as transformEncoder9
|
|
1652
1652
|
} from "@solana/kit";
|
|
1653
1653
|
import { getAccountMetaFactory as getAccountMetaFactory9 } from "@solana/program-client-core";
|
|
1654
|
+
var REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR = 15;
|
|
1655
|
+
function getRevokeAbandonedDelegationDiscriminatorBytes() {
|
|
1656
|
+
return getU8Encoder14().encode(REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR);
|
|
1657
|
+
}
|
|
1658
|
+
function getRevokeAbandonedDelegationInstructionDataEncoder() {
|
|
1659
|
+
return transformEncoder9(getStructEncoder23([["discriminator", getU8Encoder14()]]), (value) => ({
|
|
1660
|
+
...value,
|
|
1661
|
+
discriminator: REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR
|
|
1662
|
+
}));
|
|
1663
|
+
}
|
|
1664
|
+
function getRevokeAbandonedDelegationInstructionDataDecoder() {
|
|
1665
|
+
return getStructDecoder23([["discriminator", getU8Decoder14()]]);
|
|
1666
|
+
}
|
|
1667
|
+
function getRevokeAbandonedDelegationInstructionDataCodec() {
|
|
1668
|
+
return combineCodec25(
|
|
1669
|
+
getRevokeAbandonedDelegationInstructionDataEncoder(),
|
|
1670
|
+
getRevokeAbandonedDelegationInstructionDataDecoder()
|
|
1671
|
+
);
|
|
1672
|
+
}
|
|
1673
|
+
function getRevokeAbandonedDelegationInstruction(input, config) {
|
|
1674
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1675
|
+
const originalAccounts = {
|
|
1676
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
1677
|
+
delegationAccount: { value: input.delegationAccount ?? null, isWritable: true },
|
|
1678
|
+
subscriptionAuthority: { value: input.subscriptionAuthority ?? null, isWritable: false }
|
|
1679
|
+
};
|
|
1680
|
+
const accounts = originalAccounts;
|
|
1681
|
+
const getAccountMeta = getAccountMetaFactory9(programAddress, "programId");
|
|
1682
|
+
return Object.freeze({
|
|
1683
|
+
accounts: [
|
|
1684
|
+
getAccountMeta("payer", accounts.payer),
|
|
1685
|
+
getAccountMeta("delegationAccount", accounts.delegationAccount),
|
|
1686
|
+
getAccountMeta("subscriptionAuthority", accounts.subscriptionAuthority)
|
|
1687
|
+
],
|
|
1688
|
+
data: getRevokeAbandonedDelegationInstructionDataEncoder().encode({}),
|
|
1689
|
+
programAddress
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
function parseRevokeAbandonedDelegationInstruction(instruction) {
|
|
1693
|
+
if (instruction.accounts.length < 3) {
|
|
1694
|
+
throw new SolanaError9(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS9, {
|
|
1695
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1696
|
+
expectedAccountMetas: 3
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1699
|
+
let accountIndex = 0;
|
|
1700
|
+
const getNextAccount = () => {
|
|
1701
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1702
|
+
accountIndex += 1;
|
|
1703
|
+
return accountMeta;
|
|
1704
|
+
};
|
|
1705
|
+
return {
|
|
1706
|
+
programAddress: instruction.programAddress,
|
|
1707
|
+
accounts: {
|
|
1708
|
+
payer: getNextAccount(),
|
|
1709
|
+
delegationAccount: getNextAccount(),
|
|
1710
|
+
subscriptionAuthority: getNextAccount()
|
|
1711
|
+
},
|
|
1712
|
+
data: getRevokeAbandonedDelegationInstructionDataDecoder().decode(instruction.data)
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
// src/generated/instructions/revokeDelegation.ts
|
|
1717
|
+
import {
|
|
1718
|
+
combineCodec as combineCodec26,
|
|
1719
|
+
getStructDecoder as getStructDecoder24,
|
|
1720
|
+
getStructEncoder as getStructEncoder24,
|
|
1721
|
+
getU8Decoder as getU8Decoder15,
|
|
1722
|
+
getU8Encoder as getU8Encoder15,
|
|
1723
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS10,
|
|
1724
|
+
SolanaError as SolanaError10,
|
|
1725
|
+
transformEncoder as transformEncoder10
|
|
1726
|
+
} from "@solana/kit";
|
|
1727
|
+
import { getAccountMetaFactory as getAccountMetaFactory10 } from "@solana/program-client-core";
|
|
1654
1728
|
var REVOKE_DELEGATION_DISCRIMINATOR = 3;
|
|
1655
1729
|
function getRevokeDelegationDiscriminatorBytes() {
|
|
1656
|
-
return
|
|
1730
|
+
return getU8Encoder15().encode(REVOKE_DELEGATION_DISCRIMINATOR);
|
|
1657
1731
|
}
|
|
1658
1732
|
function getRevokeDelegationInstructionDataEncoder() {
|
|
1659
|
-
return
|
|
1733
|
+
return transformEncoder10(getStructEncoder24([["discriminator", getU8Encoder15()]]), (value) => ({
|
|
1660
1734
|
...value,
|
|
1661
1735
|
discriminator: REVOKE_DELEGATION_DISCRIMINATOR
|
|
1662
1736
|
}));
|
|
1663
1737
|
}
|
|
1664
1738
|
function getRevokeDelegationInstructionDataDecoder() {
|
|
1665
|
-
return
|
|
1739
|
+
return getStructDecoder24([["discriminator", getU8Decoder15()]]);
|
|
1666
1740
|
}
|
|
1667
1741
|
function getRevokeDelegationInstructionDataCodec() {
|
|
1668
|
-
return
|
|
1742
|
+
return combineCodec26(getRevokeDelegationInstructionDataEncoder(), getRevokeDelegationInstructionDataDecoder());
|
|
1669
1743
|
}
|
|
1670
1744
|
function getRevokeDelegationInstruction(input, config) {
|
|
1671
1745
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -1674,7 +1748,7 @@ function getRevokeDelegationInstruction(input, config) {
|
|
|
1674
1748
|
delegationAccount: { value: input.delegationAccount ?? null, isWritable: true }
|
|
1675
1749
|
};
|
|
1676
1750
|
const accounts = originalAccounts;
|
|
1677
|
-
const getAccountMeta =
|
|
1751
|
+
const getAccountMeta = getAccountMetaFactory10(programAddress, "programId");
|
|
1678
1752
|
return Object.freeze({
|
|
1679
1753
|
accounts: [
|
|
1680
1754
|
getAccountMeta("authority", accounts.authority),
|
|
@@ -1686,7 +1760,7 @@ function getRevokeDelegationInstruction(input, config) {
|
|
|
1686
1760
|
}
|
|
1687
1761
|
function parseRevokeDelegationInstruction(instruction) {
|
|
1688
1762
|
if (instruction.accounts.length < 2) {
|
|
1689
|
-
throw new
|
|
1763
|
+
throw new SolanaError10(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS10, {
|
|
1690
1764
|
actualAccountMetas: instruction.accounts.length,
|
|
1691
1765
|
expectedAccountMetas: 2
|
|
1692
1766
|
});
|
|
@@ -1704,42 +1778,119 @@ function parseRevokeDelegationInstruction(instruction) {
|
|
|
1704
1778
|
};
|
|
1705
1779
|
}
|
|
1706
1780
|
|
|
1781
|
+
// src/generated/instructions/revokeSubscriptionAuthority.ts
|
|
1782
|
+
import {
|
|
1783
|
+
combineCodec as combineCodec27,
|
|
1784
|
+
getStructDecoder as getStructDecoder25,
|
|
1785
|
+
getStructEncoder as getStructEncoder25,
|
|
1786
|
+
getU8Decoder as getU8Decoder16,
|
|
1787
|
+
getU8Encoder as getU8Encoder16,
|
|
1788
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS11,
|
|
1789
|
+
SolanaError as SolanaError11,
|
|
1790
|
+
transformEncoder as transformEncoder11
|
|
1791
|
+
} from "@solana/kit";
|
|
1792
|
+
import { getAccountMetaFactory as getAccountMetaFactory11 } from "@solana/program-client-core";
|
|
1793
|
+
var REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR = 14;
|
|
1794
|
+
function getRevokeSubscriptionAuthorityDiscriminatorBytes() {
|
|
1795
|
+
return getU8Encoder16().encode(REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR);
|
|
1796
|
+
}
|
|
1797
|
+
function getRevokeSubscriptionAuthorityInstructionDataEncoder() {
|
|
1798
|
+
return transformEncoder11(getStructEncoder25([["discriminator", getU8Encoder16()]]), (value) => ({
|
|
1799
|
+
...value,
|
|
1800
|
+
discriminator: REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR
|
|
1801
|
+
}));
|
|
1802
|
+
}
|
|
1803
|
+
function getRevokeSubscriptionAuthorityInstructionDataDecoder() {
|
|
1804
|
+
return getStructDecoder25([["discriminator", getU8Decoder16()]]);
|
|
1805
|
+
}
|
|
1806
|
+
function getRevokeSubscriptionAuthorityInstructionDataCodec() {
|
|
1807
|
+
return combineCodec27(
|
|
1808
|
+
getRevokeSubscriptionAuthorityInstructionDataEncoder(),
|
|
1809
|
+
getRevokeSubscriptionAuthorityInstructionDataDecoder()
|
|
1810
|
+
);
|
|
1811
|
+
}
|
|
1812
|
+
function getRevokeSubscriptionAuthorityInstruction(input, config) {
|
|
1813
|
+
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
1814
|
+
const originalAccounts = {
|
|
1815
|
+
user: { value: input.user ?? null, isWritable: false },
|
|
1816
|
+
userAta: { value: input.userAta ?? null, isWritable: true },
|
|
1817
|
+
tokenMint: { value: input.tokenMint ?? null, isWritable: false },
|
|
1818
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }
|
|
1819
|
+
};
|
|
1820
|
+
const accounts = originalAccounts;
|
|
1821
|
+
const getAccountMeta = getAccountMetaFactory11(programAddress, "programId");
|
|
1822
|
+
return Object.freeze({
|
|
1823
|
+
accounts: [
|
|
1824
|
+
getAccountMeta("user", accounts.user),
|
|
1825
|
+
getAccountMeta("userAta", accounts.userAta),
|
|
1826
|
+
getAccountMeta("tokenMint", accounts.tokenMint),
|
|
1827
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram)
|
|
1828
|
+
],
|
|
1829
|
+
data: getRevokeSubscriptionAuthorityInstructionDataEncoder().encode({}),
|
|
1830
|
+
programAddress
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
function parseRevokeSubscriptionAuthorityInstruction(instruction) {
|
|
1834
|
+
if (instruction.accounts.length < 4) {
|
|
1835
|
+
throw new SolanaError11(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS11, {
|
|
1836
|
+
actualAccountMetas: instruction.accounts.length,
|
|
1837
|
+
expectedAccountMetas: 4
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
let accountIndex = 0;
|
|
1841
|
+
const getNextAccount = () => {
|
|
1842
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1843
|
+
accountIndex += 1;
|
|
1844
|
+
return accountMeta;
|
|
1845
|
+
};
|
|
1846
|
+
return {
|
|
1847
|
+
programAddress: instruction.programAddress,
|
|
1848
|
+
accounts: {
|
|
1849
|
+
user: getNextAccount(),
|
|
1850
|
+
userAta: getNextAccount(),
|
|
1851
|
+
tokenMint: getNextAccount(),
|
|
1852
|
+
tokenProgram: getNextAccount()
|
|
1853
|
+
},
|
|
1854
|
+
data: getRevokeSubscriptionAuthorityInstructionDataDecoder().decode(instruction.data)
|
|
1855
|
+
};
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1707
1858
|
// src/generated/instructions/subscribe.ts
|
|
1708
1859
|
import {
|
|
1709
|
-
combineCodec as
|
|
1710
|
-
getStructDecoder as
|
|
1711
|
-
getStructEncoder as
|
|
1712
|
-
getU8Decoder as
|
|
1713
|
-
getU8Encoder as
|
|
1714
|
-
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as
|
|
1715
|
-
SolanaError as
|
|
1716
|
-
transformEncoder as
|
|
1860
|
+
combineCodec as combineCodec28,
|
|
1861
|
+
getStructDecoder as getStructDecoder26,
|
|
1862
|
+
getStructEncoder as getStructEncoder26,
|
|
1863
|
+
getU8Decoder as getU8Decoder17,
|
|
1864
|
+
getU8Encoder as getU8Encoder17,
|
|
1865
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS12,
|
|
1866
|
+
SolanaError as SolanaError12,
|
|
1867
|
+
transformEncoder as transformEncoder12
|
|
1717
1868
|
} from "@solana/kit";
|
|
1718
1869
|
import {
|
|
1719
|
-
getAccountMetaFactory as
|
|
1870
|
+
getAccountMetaFactory as getAccountMetaFactory12,
|
|
1720
1871
|
getAddressFromResolvedInstructionAccount as getAddressFromResolvedInstructionAccount4
|
|
1721
1872
|
} from "@solana/program-client-core";
|
|
1722
1873
|
var SUBSCRIBE_DISCRIMINATOR = 11;
|
|
1723
1874
|
function getSubscribeDiscriminatorBytes() {
|
|
1724
|
-
return
|
|
1875
|
+
return getU8Encoder17().encode(SUBSCRIBE_DISCRIMINATOR);
|
|
1725
1876
|
}
|
|
1726
1877
|
function getSubscribeInstructionDataEncoder() {
|
|
1727
|
-
return
|
|
1728
|
-
|
|
1729
|
-
["discriminator",
|
|
1878
|
+
return transformEncoder12(
|
|
1879
|
+
getStructEncoder26([
|
|
1880
|
+
["discriminator", getU8Encoder17()],
|
|
1730
1881
|
["subscribeData", getSubscribeDataEncoder()]
|
|
1731
1882
|
]),
|
|
1732
1883
|
(value) => ({ ...value, discriminator: SUBSCRIBE_DISCRIMINATOR })
|
|
1733
1884
|
);
|
|
1734
1885
|
}
|
|
1735
1886
|
function getSubscribeInstructionDataDecoder() {
|
|
1736
|
-
return
|
|
1737
|
-
["discriminator",
|
|
1887
|
+
return getStructDecoder26([
|
|
1888
|
+
["discriminator", getU8Decoder17()],
|
|
1738
1889
|
["subscribeData", getSubscribeDataDecoder()]
|
|
1739
1890
|
]);
|
|
1740
1891
|
}
|
|
1741
1892
|
function getSubscribeInstructionDataCodec() {
|
|
1742
|
-
return
|
|
1893
|
+
return combineCodec28(getSubscribeInstructionDataEncoder(), getSubscribeInstructionDataDecoder());
|
|
1743
1894
|
}
|
|
1744
1895
|
async function getSubscribeInstructionAsync(input, config) {
|
|
1745
1896
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -1770,7 +1921,7 @@ async function getSubscribeInstructionAsync(input, config) {
|
|
|
1770
1921
|
if (!accounts.selfProgram.value) {
|
|
1771
1922
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1772
1923
|
}
|
|
1773
|
-
const getAccountMeta =
|
|
1924
|
+
const getAccountMeta = getAccountMetaFactory12(programAddress, "programId");
|
|
1774
1925
|
return Object.freeze({
|
|
1775
1926
|
accounts: [
|
|
1776
1927
|
getAccountMeta("subscriber", accounts.subscriber),
|
|
@@ -1809,7 +1960,7 @@ function getSubscribeInstruction(input, config) {
|
|
|
1809
1960
|
if (!accounts.selfProgram.value) {
|
|
1810
1961
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1811
1962
|
}
|
|
1812
|
-
const getAccountMeta =
|
|
1963
|
+
const getAccountMeta = getAccountMetaFactory12(programAddress, "programId");
|
|
1813
1964
|
return Object.freeze({
|
|
1814
1965
|
accounts: [
|
|
1815
1966
|
getAccountMeta("subscriber", accounts.subscriber),
|
|
@@ -1827,7 +1978,7 @@ function getSubscribeInstruction(input, config) {
|
|
|
1827
1978
|
}
|
|
1828
1979
|
function parseSubscribeInstruction(instruction) {
|
|
1829
1980
|
if (instruction.accounts.length < 8) {
|
|
1830
|
-
throw new
|
|
1981
|
+
throw new SolanaError12(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS12, {
|
|
1831
1982
|
actualAccountMetas: instruction.accounts.length,
|
|
1832
1983
|
expectedAccountMetas: 8
|
|
1833
1984
|
});
|
|
@@ -1856,37 +2007,37 @@ function parseSubscribeInstruction(instruction) {
|
|
|
1856
2007
|
|
|
1857
2008
|
// src/generated/instructions/transferFixed.ts
|
|
1858
2009
|
import {
|
|
1859
|
-
combineCodec as
|
|
1860
|
-
getStructDecoder as
|
|
1861
|
-
getStructEncoder as
|
|
1862
|
-
getU8Decoder as
|
|
1863
|
-
getU8Encoder as
|
|
1864
|
-
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as
|
|
1865
|
-
SolanaError as
|
|
1866
|
-
transformEncoder as
|
|
2010
|
+
combineCodec as combineCodec29,
|
|
2011
|
+
getStructDecoder as getStructDecoder27,
|
|
2012
|
+
getStructEncoder as getStructEncoder27,
|
|
2013
|
+
getU8Decoder as getU8Decoder18,
|
|
2014
|
+
getU8Encoder as getU8Encoder18,
|
|
2015
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS13,
|
|
2016
|
+
SolanaError as SolanaError13,
|
|
2017
|
+
transformEncoder as transformEncoder13
|
|
1867
2018
|
} from "@solana/kit";
|
|
1868
|
-
import { getAccountMetaFactory as
|
|
2019
|
+
import { getAccountMetaFactory as getAccountMetaFactory13 } from "@solana/program-client-core";
|
|
1869
2020
|
var TRANSFER_FIXED_DISCRIMINATOR = 4;
|
|
1870
2021
|
function getTransferFixedDiscriminatorBytes() {
|
|
1871
|
-
return
|
|
2022
|
+
return getU8Encoder18().encode(TRANSFER_FIXED_DISCRIMINATOR);
|
|
1872
2023
|
}
|
|
1873
2024
|
function getTransferFixedInstructionDataEncoder() {
|
|
1874
|
-
return
|
|
1875
|
-
|
|
1876
|
-
["discriminator",
|
|
2025
|
+
return transformEncoder13(
|
|
2026
|
+
getStructEncoder27([
|
|
2027
|
+
["discriminator", getU8Encoder18()],
|
|
1877
2028
|
["transferData", getTransferDataEncoder()]
|
|
1878
2029
|
]),
|
|
1879
2030
|
(value) => ({ ...value, discriminator: TRANSFER_FIXED_DISCRIMINATOR })
|
|
1880
2031
|
);
|
|
1881
2032
|
}
|
|
1882
2033
|
function getTransferFixedInstructionDataDecoder() {
|
|
1883
|
-
return
|
|
1884
|
-
["discriminator",
|
|
2034
|
+
return getStructDecoder27([
|
|
2035
|
+
["discriminator", getU8Decoder18()],
|
|
1885
2036
|
["transferData", getTransferDataDecoder()]
|
|
1886
2037
|
]);
|
|
1887
2038
|
}
|
|
1888
2039
|
function getTransferFixedInstructionDataCodec() {
|
|
1889
|
-
return
|
|
2040
|
+
return combineCodec29(getTransferFixedInstructionDataEncoder(), getTransferFixedInstructionDataDecoder());
|
|
1890
2041
|
}
|
|
1891
2042
|
function getTransferFixedInstruction(input, config) {
|
|
1892
2043
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -1909,7 +2060,7 @@ function getTransferFixedInstruction(input, config) {
|
|
|
1909
2060
|
if (!accounts.selfProgram.value) {
|
|
1910
2061
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
1911
2062
|
}
|
|
1912
|
-
const getAccountMeta =
|
|
2063
|
+
const getAccountMeta = getAccountMetaFactory13(programAddress, "programId");
|
|
1913
2064
|
return Object.freeze({
|
|
1914
2065
|
accounts: [
|
|
1915
2066
|
getAccountMeta("delegationPda", accounts.delegationPda),
|
|
@@ -1928,7 +2079,7 @@ function getTransferFixedInstruction(input, config) {
|
|
|
1928
2079
|
}
|
|
1929
2080
|
function parseTransferFixedInstruction(instruction) {
|
|
1930
2081
|
if (instruction.accounts.length < 9) {
|
|
1931
|
-
throw new
|
|
2082
|
+
throw new SolanaError13(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS13, {
|
|
1932
2083
|
actualAccountMetas: instruction.accounts.length,
|
|
1933
2084
|
expectedAccountMetas: 9
|
|
1934
2085
|
});
|
|
@@ -1958,37 +2109,37 @@ function parseTransferFixedInstruction(instruction) {
|
|
|
1958
2109
|
|
|
1959
2110
|
// src/generated/instructions/transferRecurring.ts
|
|
1960
2111
|
import {
|
|
1961
|
-
combineCodec as
|
|
1962
|
-
getStructDecoder as
|
|
1963
|
-
getStructEncoder as
|
|
1964
|
-
getU8Decoder as
|
|
1965
|
-
getU8Encoder as
|
|
1966
|
-
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as
|
|
1967
|
-
SolanaError as
|
|
1968
|
-
transformEncoder as
|
|
2112
|
+
combineCodec as combineCodec30,
|
|
2113
|
+
getStructDecoder as getStructDecoder28,
|
|
2114
|
+
getStructEncoder as getStructEncoder28,
|
|
2115
|
+
getU8Decoder as getU8Decoder19,
|
|
2116
|
+
getU8Encoder as getU8Encoder19,
|
|
2117
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS14,
|
|
2118
|
+
SolanaError as SolanaError14,
|
|
2119
|
+
transformEncoder as transformEncoder14
|
|
1969
2120
|
} from "@solana/kit";
|
|
1970
|
-
import { getAccountMetaFactory as
|
|
2121
|
+
import { getAccountMetaFactory as getAccountMetaFactory14 } from "@solana/program-client-core";
|
|
1971
2122
|
var TRANSFER_RECURRING_DISCRIMINATOR = 5;
|
|
1972
2123
|
function getTransferRecurringDiscriminatorBytes() {
|
|
1973
|
-
return
|
|
2124
|
+
return getU8Encoder19().encode(TRANSFER_RECURRING_DISCRIMINATOR);
|
|
1974
2125
|
}
|
|
1975
2126
|
function getTransferRecurringInstructionDataEncoder() {
|
|
1976
|
-
return
|
|
1977
|
-
|
|
1978
|
-
["discriminator",
|
|
2127
|
+
return transformEncoder14(
|
|
2128
|
+
getStructEncoder28([
|
|
2129
|
+
["discriminator", getU8Encoder19()],
|
|
1979
2130
|
["transferData", getTransferDataEncoder()]
|
|
1980
2131
|
]),
|
|
1981
2132
|
(value) => ({ ...value, discriminator: TRANSFER_RECURRING_DISCRIMINATOR })
|
|
1982
2133
|
);
|
|
1983
2134
|
}
|
|
1984
2135
|
function getTransferRecurringInstructionDataDecoder() {
|
|
1985
|
-
return
|
|
1986
|
-
["discriminator",
|
|
2136
|
+
return getStructDecoder28([
|
|
2137
|
+
["discriminator", getU8Decoder19()],
|
|
1987
2138
|
["transferData", getTransferDataDecoder()]
|
|
1988
2139
|
]);
|
|
1989
2140
|
}
|
|
1990
2141
|
function getTransferRecurringInstructionDataCodec() {
|
|
1991
|
-
return
|
|
2142
|
+
return combineCodec30(getTransferRecurringInstructionDataEncoder(), getTransferRecurringInstructionDataDecoder());
|
|
1992
2143
|
}
|
|
1993
2144
|
function getTransferRecurringInstruction(input, config) {
|
|
1994
2145
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -2011,7 +2162,7 @@ function getTransferRecurringInstruction(input, config) {
|
|
|
2011
2162
|
if (!accounts.selfProgram.value) {
|
|
2012
2163
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
2013
2164
|
}
|
|
2014
|
-
const getAccountMeta =
|
|
2165
|
+
const getAccountMeta = getAccountMetaFactory14(programAddress, "programId");
|
|
2015
2166
|
return Object.freeze({
|
|
2016
2167
|
accounts: [
|
|
2017
2168
|
getAccountMeta("delegationPda", accounts.delegationPda),
|
|
@@ -2030,7 +2181,7 @@ function getTransferRecurringInstruction(input, config) {
|
|
|
2030
2181
|
}
|
|
2031
2182
|
function parseTransferRecurringInstruction(instruction) {
|
|
2032
2183
|
if (instruction.accounts.length < 9) {
|
|
2033
|
-
throw new
|
|
2184
|
+
throw new SolanaError14(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS14, {
|
|
2034
2185
|
actualAccountMetas: instruction.accounts.length,
|
|
2035
2186
|
expectedAccountMetas: 9
|
|
2036
2187
|
});
|
|
@@ -2060,37 +2211,37 @@ function parseTransferRecurringInstruction(instruction) {
|
|
|
2060
2211
|
|
|
2061
2212
|
// src/generated/instructions/transferSubscription.ts
|
|
2062
2213
|
import {
|
|
2063
|
-
combineCodec as
|
|
2064
|
-
getStructDecoder as
|
|
2065
|
-
getStructEncoder as
|
|
2066
|
-
getU8Decoder as
|
|
2067
|
-
getU8Encoder as
|
|
2068
|
-
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as
|
|
2069
|
-
SolanaError as
|
|
2070
|
-
transformEncoder as
|
|
2214
|
+
combineCodec as combineCodec31,
|
|
2215
|
+
getStructDecoder as getStructDecoder29,
|
|
2216
|
+
getStructEncoder as getStructEncoder29,
|
|
2217
|
+
getU8Decoder as getU8Decoder20,
|
|
2218
|
+
getU8Encoder as getU8Encoder20,
|
|
2219
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS15,
|
|
2220
|
+
SolanaError as SolanaError15,
|
|
2221
|
+
transformEncoder as transformEncoder15
|
|
2071
2222
|
} from "@solana/kit";
|
|
2072
|
-
import { getAccountMetaFactory as
|
|
2223
|
+
import { getAccountMetaFactory as getAccountMetaFactory15 } from "@solana/program-client-core";
|
|
2073
2224
|
var TRANSFER_SUBSCRIPTION_DISCRIMINATOR = 10;
|
|
2074
2225
|
function getTransferSubscriptionDiscriminatorBytes() {
|
|
2075
|
-
return
|
|
2226
|
+
return getU8Encoder20().encode(TRANSFER_SUBSCRIPTION_DISCRIMINATOR);
|
|
2076
2227
|
}
|
|
2077
2228
|
function getTransferSubscriptionInstructionDataEncoder() {
|
|
2078
|
-
return
|
|
2079
|
-
|
|
2080
|
-
["discriminator",
|
|
2229
|
+
return transformEncoder15(
|
|
2230
|
+
getStructEncoder29([
|
|
2231
|
+
["discriminator", getU8Encoder20()],
|
|
2081
2232
|
["transferData", getTransferDataEncoder()]
|
|
2082
2233
|
]),
|
|
2083
2234
|
(value) => ({ ...value, discriminator: TRANSFER_SUBSCRIPTION_DISCRIMINATOR })
|
|
2084
2235
|
);
|
|
2085
2236
|
}
|
|
2086
2237
|
function getTransferSubscriptionInstructionDataDecoder() {
|
|
2087
|
-
return
|
|
2088
|
-
["discriminator",
|
|
2238
|
+
return getStructDecoder29([
|
|
2239
|
+
["discriminator", getU8Decoder20()],
|
|
2089
2240
|
["transferData", getTransferDataDecoder()]
|
|
2090
2241
|
]);
|
|
2091
2242
|
}
|
|
2092
2243
|
function getTransferSubscriptionInstructionDataCodec() {
|
|
2093
|
-
return
|
|
2244
|
+
return combineCodec31(
|
|
2094
2245
|
getTransferSubscriptionInstructionDataEncoder(),
|
|
2095
2246
|
getTransferSubscriptionInstructionDataDecoder()
|
|
2096
2247
|
);
|
|
@@ -2117,7 +2268,7 @@ function getTransferSubscriptionInstruction(input, config) {
|
|
|
2117
2268
|
if (!accounts.selfProgram.value) {
|
|
2118
2269
|
accounts.selfProgram.value = "De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";
|
|
2119
2270
|
}
|
|
2120
|
-
const getAccountMeta =
|
|
2271
|
+
const getAccountMeta = getAccountMetaFactory15(programAddress, "programId");
|
|
2121
2272
|
return Object.freeze({
|
|
2122
2273
|
accounts: [
|
|
2123
2274
|
getAccountMeta("subscriptionPda", accounts.subscriptionPda),
|
|
@@ -2137,7 +2288,7 @@ function getTransferSubscriptionInstruction(input, config) {
|
|
|
2137
2288
|
}
|
|
2138
2289
|
function parseTransferSubscriptionInstruction(instruction) {
|
|
2139
2290
|
if (instruction.accounts.length < 10) {
|
|
2140
|
-
throw new
|
|
2291
|
+
throw new SolanaError15(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS15, {
|
|
2141
2292
|
actualAccountMetas: instruction.accounts.length,
|
|
2142
2293
|
expectedAccountMetas: 10
|
|
2143
2294
|
});
|
|
@@ -2168,37 +2319,37 @@ function parseTransferSubscriptionInstruction(instruction) {
|
|
|
2168
2319
|
|
|
2169
2320
|
// src/generated/instructions/updatePlan.ts
|
|
2170
2321
|
import {
|
|
2171
|
-
combineCodec as
|
|
2172
|
-
getStructDecoder as
|
|
2173
|
-
getStructEncoder as
|
|
2174
|
-
getU8Decoder as
|
|
2175
|
-
getU8Encoder as
|
|
2176
|
-
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as
|
|
2177
|
-
SolanaError as
|
|
2178
|
-
transformEncoder as
|
|
2322
|
+
combineCodec as combineCodec32,
|
|
2323
|
+
getStructDecoder as getStructDecoder30,
|
|
2324
|
+
getStructEncoder as getStructEncoder30,
|
|
2325
|
+
getU8Decoder as getU8Decoder21,
|
|
2326
|
+
getU8Encoder as getU8Encoder21,
|
|
2327
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS as SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS16,
|
|
2328
|
+
SolanaError as SolanaError16,
|
|
2329
|
+
transformEncoder as transformEncoder16
|
|
2179
2330
|
} from "@solana/kit";
|
|
2180
|
-
import { getAccountMetaFactory as
|
|
2331
|
+
import { getAccountMetaFactory as getAccountMetaFactory16 } from "@solana/program-client-core";
|
|
2181
2332
|
var UPDATE_PLAN_DISCRIMINATOR = 8;
|
|
2182
2333
|
function getUpdatePlanDiscriminatorBytes() {
|
|
2183
|
-
return
|
|
2334
|
+
return getU8Encoder21().encode(UPDATE_PLAN_DISCRIMINATOR);
|
|
2184
2335
|
}
|
|
2185
2336
|
function getUpdatePlanInstructionDataEncoder() {
|
|
2186
|
-
return
|
|
2187
|
-
|
|
2188
|
-
["discriminator",
|
|
2337
|
+
return transformEncoder16(
|
|
2338
|
+
getStructEncoder30([
|
|
2339
|
+
["discriminator", getU8Encoder21()],
|
|
2189
2340
|
["updatePlanData", getUpdatePlanDataEncoder()]
|
|
2190
2341
|
]),
|
|
2191
2342
|
(value) => ({ ...value, discriminator: UPDATE_PLAN_DISCRIMINATOR })
|
|
2192
2343
|
);
|
|
2193
2344
|
}
|
|
2194
2345
|
function getUpdatePlanInstructionDataDecoder() {
|
|
2195
|
-
return
|
|
2196
|
-
["discriminator",
|
|
2346
|
+
return getStructDecoder30([
|
|
2347
|
+
["discriminator", getU8Decoder21()],
|
|
2197
2348
|
["updatePlanData", getUpdatePlanDataDecoder()]
|
|
2198
2349
|
]);
|
|
2199
2350
|
}
|
|
2200
2351
|
function getUpdatePlanInstructionDataCodec() {
|
|
2201
|
-
return
|
|
2352
|
+
return combineCodec32(getUpdatePlanInstructionDataEncoder(), getUpdatePlanInstructionDataDecoder());
|
|
2202
2353
|
}
|
|
2203
2354
|
function getUpdatePlanInstruction(input, config) {
|
|
2204
2355
|
const programAddress = config?.programAddress ?? SUBSCRIPTIONS_PROGRAM_ADDRESS;
|
|
@@ -2208,7 +2359,7 @@ function getUpdatePlanInstruction(input, config) {
|
|
|
2208
2359
|
};
|
|
2209
2360
|
const accounts = originalAccounts;
|
|
2210
2361
|
const args = { ...input };
|
|
2211
|
-
const getAccountMeta =
|
|
2362
|
+
const getAccountMeta = getAccountMetaFactory16(programAddress, "programId");
|
|
2212
2363
|
return Object.freeze({
|
|
2213
2364
|
accounts: [getAccountMeta("owner", accounts.owner), getAccountMeta("planPda", accounts.planPda)],
|
|
2214
2365
|
data: getUpdatePlanInstructionDataEncoder().encode(args),
|
|
@@ -2217,7 +2368,7 @@ function getUpdatePlanInstruction(input, config) {
|
|
|
2217
2368
|
}
|
|
2218
2369
|
function parseUpdatePlanInstruction(instruction) {
|
|
2219
2370
|
if (instruction.accounts.length < 2) {
|
|
2220
|
-
throw new
|
|
2371
|
+
throw new SolanaError16(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS16, {
|
|
2221
2372
|
actualAccountMetas: instruction.accounts.length,
|
|
2222
2373
|
expectedAccountMetas: 2
|
|
2223
2374
|
});
|
|
@@ -2261,53 +2412,61 @@ var SubscriptionsInstruction = /* @__PURE__ */ ((SubscriptionsInstruction2) => {
|
|
|
2261
2412
|
SubscriptionsInstruction2[SubscriptionsInstruction2["Subscribe"] = 11] = "Subscribe";
|
|
2262
2413
|
SubscriptionsInstruction2[SubscriptionsInstruction2["CancelSubscription"] = 12] = "CancelSubscription";
|
|
2263
2414
|
SubscriptionsInstruction2[SubscriptionsInstruction2["ResumeSubscription"] = 13] = "ResumeSubscription";
|
|
2415
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeSubscriptionAuthority"] = 14] = "RevokeSubscriptionAuthority";
|
|
2416
|
+
SubscriptionsInstruction2[SubscriptionsInstruction2["RevokeAbandonedDelegation"] = 15] = "RevokeAbandonedDelegation";
|
|
2264
2417
|
return SubscriptionsInstruction2;
|
|
2265
2418
|
})(SubscriptionsInstruction || {});
|
|
2266
2419
|
function identifySubscriptionsInstruction(instruction) {
|
|
2267
2420
|
const data = "data" in instruction ? instruction.data : instruction;
|
|
2268
|
-
if (containsBytes(data,
|
|
2421
|
+
if (containsBytes(data, getU8Encoder22().encode(0), 0)) {
|
|
2269
2422
|
return 0 /* InitSubscriptionAuthority */;
|
|
2270
2423
|
}
|
|
2271
|
-
if (containsBytes(data,
|
|
2424
|
+
if (containsBytes(data, getU8Encoder22().encode(1), 0)) {
|
|
2272
2425
|
return 1 /* CreateFixedDelegation */;
|
|
2273
2426
|
}
|
|
2274
|
-
if (containsBytes(data,
|
|
2427
|
+
if (containsBytes(data, getU8Encoder22().encode(2), 0)) {
|
|
2275
2428
|
return 2 /* CreateRecurringDelegation */;
|
|
2276
2429
|
}
|
|
2277
|
-
if (containsBytes(data,
|
|
2430
|
+
if (containsBytes(data, getU8Encoder22().encode(3), 0)) {
|
|
2278
2431
|
return 3 /* RevokeDelegation */;
|
|
2279
2432
|
}
|
|
2280
|
-
if (containsBytes(data,
|
|
2433
|
+
if (containsBytes(data, getU8Encoder22().encode(4), 0)) {
|
|
2281
2434
|
return 4 /* TransferFixed */;
|
|
2282
2435
|
}
|
|
2283
|
-
if (containsBytes(data,
|
|
2436
|
+
if (containsBytes(data, getU8Encoder22().encode(5), 0)) {
|
|
2284
2437
|
return 5 /* TransferRecurring */;
|
|
2285
2438
|
}
|
|
2286
|
-
if (containsBytes(data,
|
|
2439
|
+
if (containsBytes(data, getU8Encoder22().encode(6), 0)) {
|
|
2287
2440
|
return 6 /* CloseSubscriptionAuthority */;
|
|
2288
2441
|
}
|
|
2289
|
-
if (containsBytes(data,
|
|
2442
|
+
if (containsBytes(data, getU8Encoder22().encode(7), 0)) {
|
|
2290
2443
|
return 7 /* CreatePlan */;
|
|
2291
2444
|
}
|
|
2292
|
-
if (containsBytes(data,
|
|
2445
|
+
if (containsBytes(data, getU8Encoder22().encode(8), 0)) {
|
|
2293
2446
|
return 8 /* UpdatePlan */;
|
|
2294
2447
|
}
|
|
2295
|
-
if (containsBytes(data,
|
|
2448
|
+
if (containsBytes(data, getU8Encoder22().encode(9), 0)) {
|
|
2296
2449
|
return 9 /* DeletePlan */;
|
|
2297
2450
|
}
|
|
2298
|
-
if (containsBytes(data,
|
|
2451
|
+
if (containsBytes(data, getU8Encoder22().encode(10), 0)) {
|
|
2299
2452
|
return 10 /* TransferSubscription */;
|
|
2300
2453
|
}
|
|
2301
|
-
if (containsBytes(data,
|
|
2454
|
+
if (containsBytes(data, getU8Encoder22().encode(11), 0)) {
|
|
2302
2455
|
return 11 /* Subscribe */;
|
|
2303
2456
|
}
|
|
2304
|
-
if (containsBytes(data,
|
|
2457
|
+
if (containsBytes(data, getU8Encoder22().encode(12), 0)) {
|
|
2305
2458
|
return 12 /* CancelSubscription */;
|
|
2306
2459
|
}
|
|
2307
|
-
if (containsBytes(data,
|
|
2460
|
+
if (containsBytes(data, getU8Encoder22().encode(13), 0)) {
|
|
2308
2461
|
return 13 /* ResumeSubscription */;
|
|
2309
2462
|
}
|
|
2310
|
-
|
|
2463
|
+
if (containsBytes(data, getU8Encoder22().encode(14), 0)) {
|
|
2464
|
+
return 14 /* RevokeSubscriptionAuthority */;
|
|
2465
|
+
}
|
|
2466
|
+
if (containsBytes(data, getU8Encoder22().encode(15), 0)) {
|
|
2467
|
+
return 15 /* RevokeAbandonedDelegation */;
|
|
2468
|
+
}
|
|
2469
|
+
throw new SolanaError17(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
|
|
2311
2470
|
instructionData: data,
|
|
2312
2471
|
programName: "subscriptions"
|
|
2313
2472
|
});
|
|
@@ -2401,8 +2560,22 @@ function parseSubscriptionsInstruction(instruction) {
|
|
|
2401
2560
|
...parseResumeSubscriptionInstruction(instruction)
|
|
2402
2561
|
};
|
|
2403
2562
|
}
|
|
2563
|
+
case 14 /* RevokeSubscriptionAuthority */: {
|
|
2564
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2565
|
+
return {
|
|
2566
|
+
instructionType: 14 /* RevokeSubscriptionAuthority */,
|
|
2567
|
+
...parseRevokeSubscriptionAuthorityInstruction(instruction)
|
|
2568
|
+
};
|
|
2569
|
+
}
|
|
2570
|
+
case 15 /* RevokeAbandonedDelegation */: {
|
|
2571
|
+
assertIsInstructionWithAccounts(instruction);
|
|
2572
|
+
return {
|
|
2573
|
+
instructionType: 15 /* RevokeAbandonedDelegation */,
|
|
2574
|
+
...parseRevokeAbandonedDelegationInstruction(instruction)
|
|
2575
|
+
};
|
|
2576
|
+
}
|
|
2404
2577
|
default:
|
|
2405
|
-
throw new
|
|
2578
|
+
throw new SolanaError17(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
|
|
2406
2579
|
instructionType,
|
|
2407
2580
|
programName: "subscriptions"
|
|
2408
2581
|
});
|
|
@@ -2434,7 +2607,9 @@ function subscriptionsProgram() {
|
|
|
2434
2607
|
transferSubscription: (input) => addSelfPlanAndSendFunctions(client, getTransferSubscriptionInstruction(input)),
|
|
2435
2608
|
subscribe: (input) => addSelfPlanAndSendFunctions(client, getSubscribeInstructionAsync(input)),
|
|
2436
2609
|
cancelSubscription: (input) => addSelfPlanAndSendFunctions(client, getCancelSubscriptionInstructionAsync(input)),
|
|
2437
|
-
resumeSubscription: (input) => addSelfPlanAndSendFunctions(client, getResumeSubscriptionInstructionAsync(input))
|
|
2610
|
+
resumeSubscription: (input) => addSelfPlanAndSendFunctions(client, getResumeSubscriptionInstructionAsync(input)),
|
|
2611
|
+
revokeSubscriptionAuthority: (input) => addSelfPlanAndSendFunctions(client, getRevokeSubscriptionAuthorityInstruction(input)),
|
|
2612
|
+
revokeAbandonedDelegation: (input) => addSelfPlanAndSendFunctions(client, getRevokeAbandonedDelegationInstruction(input))
|
|
2438
2613
|
},
|
|
2439
2614
|
pdas: {
|
|
2440
2615
|
fixedDelegation: findFixedDelegationPda,
|
|
@@ -2487,6 +2662,8 @@ var SUBSCRIPTIONS_ERROR__DELEGATION_VERSION_MISMATCH = 133;
|
|
|
2487
2662
|
var SUBSCRIPTIONS_ERROR__MIGRATION_REQUIRED = 134;
|
|
2488
2663
|
var SUBSCRIPTIONS_ERROR__DELEGATION_ALREADY_EXISTS = 135;
|
|
2489
2664
|
var SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY = 136;
|
|
2665
|
+
var SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS = 137;
|
|
2666
|
+
var SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_VALIDATION_ACCOUNT_MISSING = 138;
|
|
2490
2667
|
var SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_LIMIT = 300;
|
|
2491
2668
|
var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_EXPIRY_IN_PAST = 301;
|
|
2492
2669
|
var SUBSCRIPTIONS_ERROR__FIXED_DELEGATION_AMOUNT_ZERO = 302;
|
|
@@ -2498,6 +2675,7 @@ var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST = 404;
|
|
|
2498
2675
|
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY = 405;
|
|
2499
2676
|
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO = 406;
|
|
2500
2677
|
var SUBSCRIPTIONS_ERROR__DELEGATION_NOT_STARTED = 407;
|
|
2678
|
+
var SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY = 408;
|
|
2501
2679
|
var SUBSCRIPTIONS_ERROR__PLAN_SUNSET = 500;
|
|
2502
2680
|
var SUBSCRIPTIONS_ERROR__PLAN_EXPIRED = 501;
|
|
2503
2681
|
var SUBSCRIPTIONS_ERROR__INVALID_PLAN_PDA = 502;
|
|
@@ -2587,6 +2765,7 @@ if (process.env["NODE_ENV"] !== "production") {
|
|
|
2587
2765
|
[SUBSCRIPTIONS_ERROR__PLAN_SUNSET]: `Plan is in sunset status`,
|
|
2588
2766
|
[SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH]: `Subscription plan terms do not match the current plan`,
|
|
2589
2767
|
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO]: `zero amount specified`,
|
|
2768
|
+
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY]: `start_ts of 0 (start on landing) requires a non-zero expiry`,
|
|
2590
2769
|
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY]: `start time specified is greater than expiry`,
|
|
2591
2770
|
[SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST]: `Past start time specified`,
|
|
2592
2771
|
[SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY]: `Delegation init_id does not match current SubscriptionAuthority`,
|
|
@@ -2595,6 +2774,8 @@ if (process.env["NODE_ENV"] !== "production") {
|
|
|
2595
2774
|
[SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED]: `Subscription is not cancelled`,
|
|
2596
2775
|
[SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH]: `Subscription does not belong to this plan`,
|
|
2597
2776
|
[SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS]: `Sunset requires a non-zero end timestamp`,
|
|
2777
|
+
[SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS]: `Too many transfer hook accounts provided`,
|
|
2778
|
+
[SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_VALIDATION_ACCOUNT_MISSING]: `Transfer hook validation account missing from provided accounts`,
|
|
2598
2779
|
[SUBSCRIPTIONS_ERROR__UNAUTHORIZED]: `Caller not authorized for this action`,
|
|
2599
2780
|
[SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION]: `Destination not in plan whitelist`
|
|
2600
2781
|
};
|
|
@@ -2749,12 +2930,156 @@ async function fetchSubscriptionsForUser(rpc, user, programAddress) {
|
|
|
2749
2930
|
|
|
2750
2931
|
// src/plugin.ts
|
|
2751
2932
|
import {
|
|
2752
|
-
AccountRole,
|
|
2933
|
+
AccountRole as AccountRole2,
|
|
2753
2934
|
pipe
|
|
2754
2935
|
} from "@solana/kit";
|
|
2755
2936
|
import { addSelfPlanAndSendFunctions as addSelfPlanAndSendFunctions2 } from "@solana/program-client-core";
|
|
2756
2937
|
import { findAssociatedTokenPda } from "@solana-program/token";
|
|
2757
2938
|
|
|
2939
|
+
// src/transfer-hook.ts
|
|
2940
|
+
import {
|
|
2941
|
+
AccountRole,
|
|
2942
|
+
fetchEncodedAccount as fetchEncodedAccount7,
|
|
2943
|
+
getAddressDecoder as getAddressDecoder10,
|
|
2944
|
+
getAddressEncoder as getAddressEncoder15,
|
|
2945
|
+
getProgramDerivedAddress as getProgramDerivedAddress7
|
|
2946
|
+
} from "@solana/kit";
|
|
2947
|
+
import { fetchMint, TOKEN_2022_PROGRAM_ADDRESS } from "@solana-program/token-2022";
|
|
2948
|
+
var DEFAULT_ADDRESS = "11111111111111111111111111111111";
|
|
2949
|
+
var EXTRA_ACCOUNT_METAS_SEED = "extra-account-metas";
|
|
2950
|
+
var TLV_HEADER_LEN = 12;
|
|
2951
|
+
var POD_SLICE_COUNT_LEN = 4;
|
|
2952
|
+
var EXTRA_ACCOUNT_META_LEN = 35;
|
|
2953
|
+
var PUBKEY_LEN = 32;
|
|
2954
|
+
var PDA_PROGRAM_INDEX_OFFSET = 1 << 7;
|
|
2955
|
+
var EXECUTE_DISCRIMINATOR = Uint8Array.from([105, 37, 101, 197, 75, 251, 102, 26]);
|
|
2956
|
+
var addressDecoder = getAddressDecoder10();
|
|
2957
|
+
var addressEncoder = getAddressEncoder15();
|
|
2958
|
+
function roleFor(isSigner, isWritable) {
|
|
2959
|
+
if (isSigner && isWritable) return AccountRole.WRITABLE_SIGNER;
|
|
2960
|
+
if (isSigner) return AccountRole.READONLY_SIGNER;
|
|
2961
|
+
if (isWritable) return AccountRole.WRITABLE;
|
|
2962
|
+
return AccountRole.READONLY;
|
|
2963
|
+
}
|
|
2964
|
+
async function fetchData(rpc, address) {
|
|
2965
|
+
const account = await fetchEncodedAccount7(rpc, address);
|
|
2966
|
+
if (!account.exists) throw new Error("transfer hook: referenced account not found");
|
|
2967
|
+
return account.data;
|
|
2968
|
+
}
|
|
2969
|
+
function executeInstructionData(amount) {
|
|
2970
|
+
const data = new Uint8Array(EXECUTE_DISCRIMINATOR.length + 8);
|
|
2971
|
+
data.set(EXECUTE_DISCRIMINATOR, 0);
|
|
2972
|
+
new DataView(data.buffer).setBigUint64(EXECUTE_DISCRIMINATOR.length, BigInt(amount), true);
|
|
2973
|
+
return data;
|
|
2974
|
+
}
|
|
2975
|
+
function readMetas(data) {
|
|
2976
|
+
if (data.length < TLV_HEADER_LEN || !EXECUTE_DISCRIMINATOR.every((byte, i) => data[i] === byte)) {
|
|
2977
|
+
return [];
|
|
2978
|
+
}
|
|
2979
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
2980
|
+
const count = view.getUint32(TLV_HEADER_LEN, true);
|
|
2981
|
+
const metas = [];
|
|
2982
|
+
let offset = TLV_HEADER_LEN + POD_SLICE_COUNT_LEN;
|
|
2983
|
+
for (let n = 0; n < count && offset + EXTRA_ACCOUNT_META_LEN <= data.length; n++) {
|
|
2984
|
+
metas.push({
|
|
2985
|
+
addressConfig: data.subarray(offset + 1, offset + 33),
|
|
2986
|
+
discriminator: data[offset],
|
|
2987
|
+
isSigner: data[offset + 33] === 1,
|
|
2988
|
+
isWritable: data[offset + 34] === 1
|
|
2989
|
+
});
|
|
2990
|
+
offset += EXTRA_ACCOUNT_META_LEN;
|
|
2991
|
+
}
|
|
2992
|
+
return metas;
|
|
2993
|
+
}
|
|
2994
|
+
async function unpackSeeds(config, previous, instructionData, rpc) {
|
|
2995
|
+
const seeds = [];
|
|
2996
|
+
let i = 0;
|
|
2997
|
+
while (i < 32) {
|
|
2998
|
+
const discriminator = config[i];
|
|
2999
|
+
const rest = config.subarray(i + 1);
|
|
3000
|
+
if (discriminator === 0) break;
|
|
3001
|
+
if (discriminator === 1) {
|
|
3002
|
+
const length = rest[0];
|
|
3003
|
+
seeds.push(rest.subarray(1, 1 + length));
|
|
3004
|
+
i += 2 + length;
|
|
3005
|
+
} else if (discriminator === 2) {
|
|
3006
|
+
const [index, length] = [rest[0], rest[1]];
|
|
3007
|
+
seeds.push(instructionData.subarray(index, index + length));
|
|
3008
|
+
i += 3;
|
|
3009
|
+
} else if (discriminator === 3) {
|
|
3010
|
+
seeds.push(addressEncoder.encode(previous[rest[0]].address));
|
|
3011
|
+
i += 2;
|
|
3012
|
+
} else if (discriminator === 4) {
|
|
3013
|
+
const [accountIndex, dataIndex, length] = [rest[0], rest[1], rest[2]];
|
|
3014
|
+
const data = await fetchData(rpc, previous[accountIndex].address);
|
|
3015
|
+
seeds.push(data.subarray(dataIndex, dataIndex + length));
|
|
3016
|
+
i += 4;
|
|
3017
|
+
} else {
|
|
3018
|
+
throw new Error("transfer hook: invalid seed");
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
return seeds;
|
|
3022
|
+
}
|
|
3023
|
+
async function unpackPubkeyData(config, previous, instructionData, rpc) {
|
|
3024
|
+
const rest = config.subarray(1);
|
|
3025
|
+
if (config[0] === 1) {
|
|
3026
|
+
const offset = rest[0];
|
|
3027
|
+
return addressDecoder.decode(instructionData.subarray(offset, offset + PUBKEY_LEN));
|
|
3028
|
+
}
|
|
3029
|
+
if (config[0] === 2) {
|
|
3030
|
+
const [accountIndex, offset] = [rest[0], rest[1]];
|
|
3031
|
+
const data = await fetchData(rpc, previous[accountIndex].address);
|
|
3032
|
+
return addressDecoder.decode(data.subarray(offset, offset + PUBKEY_LEN));
|
|
3033
|
+
}
|
|
3034
|
+
throw new Error("transfer hook: invalid pubkey data");
|
|
3035
|
+
}
|
|
3036
|
+
async function resolveMeta(meta, previous, instructionData, hookProgram, rpc) {
|
|
3037
|
+
const role = roleFor(meta.isSigner, meta.isWritable);
|
|
3038
|
+
if (meta.discriminator === 0) {
|
|
3039
|
+
return { address: addressDecoder.decode(meta.addressConfig), role };
|
|
3040
|
+
}
|
|
3041
|
+
if (meta.discriminator === 2) {
|
|
3042
|
+
return { address: await unpackPubkeyData(meta.addressConfig, previous, instructionData, rpc), role };
|
|
3043
|
+
}
|
|
3044
|
+
const programId = meta.discriminator === 1 ? hookProgram : previous[meta.discriminator - PDA_PROGRAM_INDEX_OFFSET].address;
|
|
3045
|
+
const seeds = await unpackSeeds(meta.addressConfig, previous, instructionData, rpc);
|
|
3046
|
+
const [pda] = await getProgramDerivedAddress7({ programAddress: programId, seeds });
|
|
3047
|
+
return { address: pda, role };
|
|
3048
|
+
}
|
|
3049
|
+
async function resolveTransferHookAccounts(rpc, args) {
|
|
3050
|
+
if (args.transferHookAccounts?.length) return args.transferHookAccounts;
|
|
3051
|
+
if (args.tokenProgram !== TOKEN_2022_PROGRAM_ADDRESS) return [];
|
|
3052
|
+
const { data } = await fetchMint(rpc, args.mint);
|
|
3053
|
+
const extensions = data.extensions.__option === "Some" ? data.extensions.value : [];
|
|
3054
|
+
const hook = extensions.find((extension) => extension.__kind === "TransferHook");
|
|
3055
|
+
if (!hook || hook.programId === DEFAULT_ADDRESS) return [];
|
|
3056
|
+
const hookProgram = hook.programId;
|
|
3057
|
+
const [validationPda] = await getProgramDerivedAddress7({
|
|
3058
|
+
programAddress: hookProgram,
|
|
3059
|
+
seeds: [EXTRA_ACCOUNT_METAS_SEED, addressEncoder.encode(args.mint)]
|
|
3060
|
+
});
|
|
3061
|
+
const trailing = [
|
|
3062
|
+
{ address: hookProgram, role: AccountRole.READONLY },
|
|
3063
|
+
{ address: validationPda, role: AccountRole.READONLY }
|
|
3064
|
+
];
|
|
3065
|
+
const validationAccount = await fetchEncodedAccount7(rpc, validationPda);
|
|
3066
|
+
if (!validationAccount.exists) return trailing;
|
|
3067
|
+
const instructionData = executeInstructionData(args.amount);
|
|
3068
|
+
const previous = [
|
|
3069
|
+
{ address: args.source, role: AccountRole.READONLY },
|
|
3070
|
+
{ address: args.mint, role: AccountRole.READONLY },
|
|
3071
|
+
{ address: args.destination, role: AccountRole.READONLY },
|
|
3072
|
+
{ address: args.authority, role: AccountRole.READONLY },
|
|
3073
|
+
{ address: validationPda, role: AccountRole.READONLY }
|
|
3074
|
+
];
|
|
3075
|
+
for (const meta of readMetas(validationAccount.data)) {
|
|
3076
|
+
const resolved = await resolveMeta(meta, previous, instructionData, hookProgram, rpc);
|
|
3077
|
+
previous.push(resolved);
|
|
3078
|
+
trailing.push(resolved);
|
|
3079
|
+
}
|
|
3080
|
+
return trailing;
|
|
3081
|
+
}
|
|
3082
|
+
|
|
2758
3083
|
// src/validators.ts
|
|
2759
3084
|
var textEncoder = new TextEncoder();
|
|
2760
3085
|
var ValidationError = class extends Error {
|
|
@@ -2766,6 +3091,10 @@ var ValidationError = class extends Error {
|
|
|
2766
3091
|
function assertPositive(value, name) {
|
|
2767
3092
|
if (BigInt(value) <= 0n) throw new ValidationError(`${name} must be greater than zero`);
|
|
2768
3093
|
}
|
|
3094
|
+
function assertSafeU64(value, name) {
|
|
3095
|
+
if (typeof value === "number" && !Number.isSafeInteger(value))
|
|
3096
|
+
throw new ValidationError(`${name} must be a bigint or a safe integer (numbers above 2^53-1 lose precision)`);
|
|
3097
|
+
}
|
|
2769
3098
|
function assertMetadataUri(metadataUri) {
|
|
2770
3099
|
if (textEncoder.encode(metadataUri).length > METADATA_URI_LEN)
|
|
2771
3100
|
throw new ValidationError(`metadataUri exceeds ${METADATA_URI_LEN} bytes`);
|
|
@@ -2802,7 +3131,7 @@ function appendPayer(instruction, payer) {
|
|
|
2802
3131
|
return withTrailing(instruction, [
|
|
2803
3132
|
{
|
|
2804
3133
|
address: payer.address,
|
|
2805
|
-
role:
|
|
3134
|
+
role: AccountRole2.WRITABLE_SIGNER,
|
|
2806
3135
|
signer: payer
|
|
2807
3136
|
}
|
|
2808
3137
|
]);
|
|
@@ -2831,10 +3160,26 @@ async function getCloseSubscriptionAuthorityOverlayInstructionAsync(input) {
|
|
|
2831
3160
|
pdaConfig(input.programAddress)
|
|
2832
3161
|
);
|
|
2833
3162
|
if (input.receiver) {
|
|
2834
|
-
ix = withTrailing(ix, [{ address: input.receiver, role:
|
|
3163
|
+
ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole2.WRITABLE }]);
|
|
2835
3164
|
}
|
|
2836
3165
|
return ix;
|
|
2837
3166
|
}
|
|
3167
|
+
async function getRevokeSubscriptionAuthorityOverlayInstructionAsync(input) {
|
|
3168
|
+
const [userAta] = await findAssociatedTokenPda({
|
|
3169
|
+
mint: input.tokenMint,
|
|
3170
|
+
owner: input.user.address,
|
|
3171
|
+
tokenProgram: input.tokenProgram
|
|
3172
|
+
});
|
|
3173
|
+
return getRevokeSubscriptionAuthorityInstruction(
|
|
3174
|
+
{
|
|
3175
|
+
tokenMint: input.tokenMint,
|
|
3176
|
+
tokenProgram: input.tokenProgram,
|
|
3177
|
+
user: input.user,
|
|
3178
|
+
userAta
|
|
3179
|
+
},
|
|
3180
|
+
pdaConfig(input.programAddress)
|
|
3181
|
+
);
|
|
3182
|
+
}
|
|
2838
3183
|
async function getCreateFixedDelegationOverlayInstructionAsync(input) {
|
|
2839
3184
|
assertPositive(input.amount, "amount");
|
|
2840
3185
|
if (input.expectedSubscriptionAuthorityInitId === void 0) {
|
|
@@ -2925,14 +3270,14 @@ function getRevokeDelegationOverlayInstruction(input) {
|
|
|
2925
3270
|
pdaConfig(input.programAddress)
|
|
2926
3271
|
);
|
|
2927
3272
|
if (input.receiver) {
|
|
2928
|
-
ix = withTrailing(ix, [{ address: input.receiver, role:
|
|
3273
|
+
ix = withTrailing(ix, [{ address: input.receiver, role: AccountRole2.WRITABLE }]);
|
|
2929
3274
|
}
|
|
2930
3275
|
return ix;
|
|
2931
3276
|
}
|
|
2932
3277
|
function getRevokeSubscriptionOverlayInstruction(input) {
|
|
2933
|
-
const trailing = [{ address: input.planPda, role:
|
|
3278
|
+
const trailing = [{ address: input.planPda, role: AccountRole2.READONLY }];
|
|
2934
3279
|
if (input.receiver) {
|
|
2935
|
-
trailing.push({ address: input.receiver, role:
|
|
3280
|
+
trailing.push({ address: input.receiver, role: AccountRole2.WRITABLE });
|
|
2936
3281
|
}
|
|
2937
3282
|
return withTrailing(
|
|
2938
3283
|
getRevokeDelegationInstruction(
|
|
@@ -2951,22 +3296,25 @@ async function getTransferDelegationOverlayInstructionAsync(input, getInstructio
|
|
|
2951
3296
|
{ tokenMint: input.tokenMint, user: input.delegator },
|
|
2952
3297
|
pdaConfig(input.programAddress)
|
|
2953
3298
|
);
|
|
2954
|
-
return
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
3299
|
+
return withTrailing(
|
|
3300
|
+
getInstruction(
|
|
3301
|
+
{
|
|
3302
|
+
delegatee: input.delegatee,
|
|
3303
|
+
delegationPda: input.delegationPda,
|
|
3304
|
+
delegatorAta: input.delegatorAta,
|
|
3305
|
+
receiverAta: input.receiverAta,
|
|
3306
|
+
subscriptionAuthority,
|
|
3307
|
+
tokenMint: input.tokenMint,
|
|
3308
|
+
tokenProgram: input.tokenProgram,
|
|
3309
|
+
transferData: {
|
|
3310
|
+
amount: input.amount,
|
|
3311
|
+
delegator: input.delegator,
|
|
3312
|
+
mint: input.tokenMint
|
|
3313
|
+
}
|
|
3314
|
+
},
|
|
3315
|
+
pdaConfig(input.programAddress)
|
|
3316
|
+
),
|
|
3317
|
+
input.transferHookAccounts ?? []
|
|
2970
3318
|
);
|
|
2971
3319
|
}
|
|
2972
3320
|
function getTransferFixedOverlayInstructionAsync(input) {
|
|
@@ -2986,28 +3334,32 @@ async function getTransferSubscriptionOverlayInstructionAsync(input) {
|
|
|
2986
3334
|
owner: input.delegator,
|
|
2987
3335
|
tokenProgram: input.tokenProgram
|
|
2988
3336
|
});
|
|
2989
|
-
return
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3337
|
+
return withTrailing(
|
|
3338
|
+
getTransferSubscriptionInstruction(
|
|
3339
|
+
{
|
|
3340
|
+
caller: input.caller,
|
|
3341
|
+
delegatorAta,
|
|
3342
|
+
planPda: input.planPda,
|
|
3343
|
+
receiverAta: input.receiverAta,
|
|
3344
|
+
subscriptionAuthority,
|
|
3345
|
+
subscriptionPda: input.subscriptionPda,
|
|
3346
|
+
tokenMint: input.tokenMint,
|
|
3347
|
+
tokenProgram: input.tokenProgram,
|
|
3348
|
+
transferData: {
|
|
3349
|
+
amount: input.amount,
|
|
3350
|
+
delegator: input.delegator,
|
|
3351
|
+
mint: input.tokenMint
|
|
3352
|
+
}
|
|
3353
|
+
},
|
|
3354
|
+
pdaConfig(input.programAddress)
|
|
3355
|
+
),
|
|
3356
|
+
input.transferHookAccounts ?? []
|
|
3006
3357
|
);
|
|
3007
3358
|
}
|
|
3008
3359
|
async function getCreatePlanOverlayInstructionAsync(input) {
|
|
3009
3360
|
assertPositive(input.amount, "amount");
|
|
3010
3361
|
assertPositive(input.periodHours, "periodHours");
|
|
3362
|
+
assertSafeU64(input.planId, "planId");
|
|
3011
3363
|
assertMetadataUri(input.metadataUri);
|
|
3012
3364
|
const destinations = padPlanDestinations(input.destinations);
|
|
3013
3365
|
const pullers = padPlanPullers(input.pullers);
|
|
@@ -3040,7 +3392,7 @@ async function getCreatePlanOverlayInstructionAsync(input) {
|
|
|
3040
3392
|
}
|
|
3041
3393
|
function getUpdatePlanOverlayInstruction(input) {
|
|
3042
3394
|
assertMetadataUri(input.metadataUri);
|
|
3043
|
-
const pullers = padPlanPullers(input.pullers
|
|
3395
|
+
const pullers = padPlanPullers(input.pullers);
|
|
3044
3396
|
return getUpdatePlanInstruction(
|
|
3045
3397
|
{
|
|
3046
3398
|
owner: input.owner,
|
|
@@ -3064,6 +3416,7 @@ async function getSubscribeOverlayInstructionAsync(input) {
|
|
|
3064
3416
|
"getSubscribeOverlayInstructionAsync requires expectedAmount, expectedPeriodHours, expectedCreatedAt, and expectedSubscriptionAuthorityInitId. Use the plugin client `subscriptions.instructions.subscribe(...)` to auto-fetch from the live plan and authority."
|
|
3065
3417
|
);
|
|
3066
3418
|
}
|
|
3419
|
+
assertSafeU64(input.planId, "planId");
|
|
3067
3420
|
const [planPda, planBump] = await findPlanPda(
|
|
3068
3421
|
{ owner: input.merchant, planId: input.planId },
|
|
3069
3422
|
pdaConfig(input.programAddress)
|
|
@@ -3153,6 +3506,21 @@ function subscriptionsProgram2() {
|
|
|
3153
3506
|
}
|
|
3154
3507
|
return subscriptionAuthority.data.initId;
|
|
3155
3508
|
};
|
|
3509
|
+
const resolveDelegationHookAccounts = async (input) => {
|
|
3510
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
3511
|
+
{ tokenMint: input.tokenMint, user: input.delegator },
|
|
3512
|
+
pdaConfig(input.programAddress)
|
|
3513
|
+
);
|
|
3514
|
+
return await resolveTransferHookAccounts(c.rpc, {
|
|
3515
|
+
amount: input.amount,
|
|
3516
|
+
authority: subscriptionAuthority,
|
|
3517
|
+
destination: input.receiverAta,
|
|
3518
|
+
mint: input.tokenMint,
|
|
3519
|
+
source: input.delegatorAta,
|
|
3520
|
+
tokenProgram: input.tokenProgram,
|
|
3521
|
+
transferHookAccounts: input.transferHookAccounts
|
|
3522
|
+
});
|
|
3523
|
+
};
|
|
3156
3524
|
const instructions = {
|
|
3157
3525
|
cancelSubscription: (input) => addSelfPlanAndSendFunctions2(
|
|
3158
3526
|
client,
|
|
@@ -3247,10 +3615,18 @@ function subscriptionsProgram2() {
|
|
|
3247
3615
|
authority: input.authority ?? client.identity
|
|
3248
3616
|
})
|
|
3249
3617
|
),
|
|
3618
|
+
revokeSubscriptionAuthority: (input) => addSelfPlanAndSendFunctions2(
|
|
3619
|
+
client,
|
|
3620
|
+
getRevokeSubscriptionAuthorityOverlayInstructionAsync({
|
|
3621
|
+
...input,
|
|
3622
|
+
user: input.user ?? client.identity
|
|
3623
|
+
})
|
|
3624
|
+
),
|
|
3250
3625
|
subscribe: (input) => addSelfPlanAndSendFunctions2(
|
|
3251
3626
|
client,
|
|
3252
3627
|
(async () => {
|
|
3253
3628
|
const subscriber = input.subscriber ?? client.identity;
|
|
3629
|
+
assertSafeU64(input.planId, "planId");
|
|
3254
3630
|
let {
|
|
3255
3631
|
expectedAmount,
|
|
3256
3632
|
expectedCreatedAt,
|
|
@@ -3296,24 +3672,47 @@ function subscriptionsProgram2() {
|
|
|
3296
3672
|
),
|
|
3297
3673
|
transferFixed: (input) => addSelfPlanAndSendFunctions2(
|
|
3298
3674
|
client,
|
|
3299
|
-
getTransferFixedOverlayInstructionAsync({
|
|
3675
|
+
(async () => await getTransferFixedOverlayInstructionAsync({
|
|
3300
3676
|
...input,
|
|
3301
|
-
delegatee: input.delegatee ?? client.identity
|
|
3302
|
-
|
|
3677
|
+
delegatee: input.delegatee ?? client.identity,
|
|
3678
|
+
transferHookAccounts: await resolveDelegationHookAccounts(input)
|
|
3679
|
+
}))()
|
|
3303
3680
|
),
|
|
3304
3681
|
transferRecurring: (input) => addSelfPlanAndSendFunctions2(
|
|
3305
3682
|
client,
|
|
3306
|
-
getTransferRecurringOverlayInstructionAsync({
|
|
3683
|
+
(async () => await getTransferRecurringOverlayInstructionAsync({
|
|
3307
3684
|
...input,
|
|
3308
|
-
delegatee: input.delegatee ?? client.identity
|
|
3309
|
-
|
|
3685
|
+
delegatee: input.delegatee ?? client.identity,
|
|
3686
|
+
transferHookAccounts: await resolveDelegationHookAccounts(input)
|
|
3687
|
+
}))()
|
|
3310
3688
|
),
|
|
3311
3689
|
transferSubscription: (input) => addSelfPlanAndSendFunctions2(
|
|
3312
3690
|
client,
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3691
|
+
(async () => {
|
|
3692
|
+
const [subscriptionAuthority] = await findSubscriptionAuthorityPda(
|
|
3693
|
+
{ tokenMint: input.tokenMint, user: input.delegator },
|
|
3694
|
+
pdaConfig(input.programAddress)
|
|
3695
|
+
);
|
|
3696
|
+
const [delegatorAta] = await findAssociatedTokenPda({
|
|
3697
|
+
mint: input.tokenMint,
|
|
3698
|
+
owner: input.delegator,
|
|
3699
|
+
tokenProgram: input.tokenProgram
|
|
3700
|
+
});
|
|
3701
|
+
const transferHookAccounts = await resolveTransferHookAccounts(c.rpc, {
|
|
3702
|
+
amount: input.amount,
|
|
3703
|
+
authority: subscriptionAuthority,
|
|
3704
|
+
destination: input.receiverAta,
|
|
3705
|
+
mint: input.tokenMint,
|
|
3706
|
+
source: delegatorAta,
|
|
3707
|
+
tokenProgram: input.tokenProgram,
|
|
3708
|
+
transferHookAccounts: input.transferHookAccounts
|
|
3709
|
+
});
|
|
3710
|
+
return await getTransferSubscriptionOverlayInstructionAsync({
|
|
3711
|
+
...input,
|
|
3712
|
+
caller: input.caller ?? client.identity,
|
|
3713
|
+
transferHookAccounts
|
|
3714
|
+
});
|
|
3715
|
+
})()
|
|
3317
3716
|
),
|
|
3318
3717
|
updatePlan: (input) => addSelfPlanAndSendFunctions2(
|
|
3319
3718
|
client,
|
|
@@ -3358,7 +3757,9 @@ export {
|
|
|
3358
3757
|
PROGRAM_ID,
|
|
3359
3758
|
PlanStatus,
|
|
3360
3759
|
RESUME_SUBSCRIPTION_DISCRIMINATOR,
|
|
3760
|
+
REVOKE_ABANDONED_DELEGATION_DISCRIMINATOR,
|
|
3361
3761
|
REVOKE_DELEGATION_DISCRIMINATOR,
|
|
3762
|
+
REVOKE_SUBSCRIPTION_AUTHORITY_DISCRIMINATOR,
|
|
3362
3763
|
SUBSCRIBE_DISCRIMINATOR,
|
|
3363
3764
|
SUBSCRIPTIONS_ERROR__ACCOUNT_NOT_WRITABLE,
|
|
3364
3765
|
SUBSCRIPTIONS_ERROR__ALREADY_SUBSCRIBED,
|
|
@@ -3422,6 +3823,7 @@ export {
|
|
|
3422
3823
|
SUBSCRIPTIONS_ERROR__PLAN_SUNSET,
|
|
3423
3824
|
SUBSCRIPTIONS_ERROR__PLAN_TERMS_MISMATCH,
|
|
3424
3825
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_AMOUNT_ZERO,
|
|
3826
|
+
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_ON_LANDING_REQUIRES_EXPIRY,
|
|
3425
3827
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_GREATER_THAN_EXPIRY,
|
|
3426
3828
|
SUBSCRIPTIONS_ERROR__RECURRING_DELEGATION_START_TIME_IN_PAST,
|
|
3427
3829
|
SUBSCRIPTIONS_ERROR__STALE_SUBSCRIPTION_AUTHORITY,
|
|
@@ -3430,6 +3832,8 @@ export {
|
|
|
3430
3832
|
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_NOT_CANCELLED,
|
|
3431
3833
|
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_PLAN_MISMATCH,
|
|
3432
3834
|
SUBSCRIPTIONS_ERROR__SUNSET_REQUIRES_END_TS,
|
|
3835
|
+
SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_TOO_MANY_ACCOUNTS,
|
|
3836
|
+
SUBSCRIPTIONS_ERROR__TRANSFER_HOOK_VALIDATION_ACCOUNT_MISSING,
|
|
3433
3837
|
SUBSCRIPTIONS_ERROR__UNAUTHORIZED,
|
|
3434
3838
|
SUBSCRIPTIONS_ERROR__UNAUTHORIZED_DESTINATION,
|
|
3435
3839
|
SUBSCRIPTIONS_PROGRAM_ADDRESS,
|
|
@@ -3582,12 +3986,23 @@ export {
|
|
|
3582
3986
|
getResumeSubscriptionInstructionDataDecoder,
|
|
3583
3987
|
getResumeSubscriptionInstructionDataEncoder,
|
|
3584
3988
|
getResumeSubscriptionOverlayInstructionAsync,
|
|
3989
|
+
getRevokeAbandonedDelegationDiscriminatorBytes,
|
|
3990
|
+
getRevokeAbandonedDelegationInstruction,
|
|
3991
|
+
getRevokeAbandonedDelegationInstructionDataCodec,
|
|
3992
|
+
getRevokeAbandonedDelegationInstructionDataDecoder,
|
|
3993
|
+
getRevokeAbandonedDelegationInstructionDataEncoder,
|
|
3585
3994
|
getRevokeDelegationDiscriminatorBytes,
|
|
3586
3995
|
getRevokeDelegationInstruction,
|
|
3587
3996
|
getRevokeDelegationInstructionDataCodec,
|
|
3588
3997
|
getRevokeDelegationInstructionDataDecoder,
|
|
3589
3998
|
getRevokeDelegationInstructionDataEncoder,
|
|
3590
3999
|
getRevokeDelegationOverlayInstruction,
|
|
4000
|
+
getRevokeSubscriptionAuthorityDiscriminatorBytes,
|
|
4001
|
+
getRevokeSubscriptionAuthorityInstruction,
|
|
4002
|
+
getRevokeSubscriptionAuthorityInstructionDataCodec,
|
|
4003
|
+
getRevokeSubscriptionAuthorityInstructionDataDecoder,
|
|
4004
|
+
getRevokeSubscriptionAuthorityInstructionDataEncoder,
|
|
4005
|
+
getRevokeSubscriptionAuthorityOverlayInstructionAsync,
|
|
3591
4006
|
getRevokeSubscriptionOverlayInstruction,
|
|
3592
4007
|
getSubscribeDataCodec,
|
|
3593
4008
|
getSubscribeDataDecoder,
|
|
@@ -3646,13 +4061,16 @@ export {
|
|
|
3646
4061
|
parseDeletePlanInstruction,
|
|
3647
4062
|
parseInitSubscriptionAuthorityInstruction,
|
|
3648
4063
|
parseResumeSubscriptionInstruction,
|
|
4064
|
+
parseRevokeAbandonedDelegationInstruction,
|
|
3649
4065
|
parseRevokeDelegationInstruction,
|
|
4066
|
+
parseRevokeSubscriptionAuthorityInstruction,
|
|
3650
4067
|
parseSubscribeInstruction,
|
|
3651
4068
|
parseSubscriptionsInstruction,
|
|
3652
4069
|
parseTransferFixedInstruction,
|
|
3653
4070
|
parseTransferRecurringInstruction,
|
|
3654
4071
|
parseTransferSubscriptionInstruction,
|
|
3655
4072
|
parseUpdatePlanInstruction,
|
|
4073
|
+
resolveTransferHookAccounts,
|
|
3656
4074
|
subscriptionsProgram2 as subscriptionsProgram,
|
|
3657
4075
|
toEncodedAccount
|
|
3658
4076
|
};
|