@lightprotocol/compressed-token 0.23.0-beta.3 → 0.23.0-beta.4

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.
@@ -1,2 +1,285 @@
1
- import{TransactionInstruction as c,ComputeBudgetProgram as l}from"@solana/web3.js";import{CTOKEN_PROGRAM_ID as k,assertBetaEnabled as C,dedupeSigner as D,buildAndSignTx as g,sendAndConfirmTx as E}from"@lightprotocol/stateless.js";import{bu as ea,bv as ta,bw as sa,br as oa,am as na,C as ra,l as ca,g as ia,c as ua,k as pa,E as da,bx as Ia,by as Ta}from"../types-Z2gqWJ9V.js";export{aS as ADD_TOKEN_POOL_DISCRIMINATOR,aQ as APPROVE_DISCRIMINATOR,an as Action,aN as BATCH_COMPRESS_DISCRIMINATOR,bA as COMPRESSED_MINT_SEED,aP as COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,aJ as CPI_AUTHORITY_SEED,aL as CREATE_TOKEN_POOL_DISCRIMINATOR,bf as CompressedTokenInstructionDataApproveLayout,bg as CompressedTokenInstructionDataRevokeLayout,aX as CompressedTokenInstructionDataTransferLayout,aW as CpiContextLayout,aT as DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR,aV as DelegatedTransferLayout,aw as ERROR_MIXED_TREE_TYPES,av as ERROR_NO_ACCOUNTS_FOUND,a0 as ExtensionType,aU as IDL,aM as MINT_TO_DISCRIMINATOR,aI as POOL_SEED,aR as REVOKE_DISCRIMINATOR,aK as SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,aO as TRANSFER_DISCRIMINATOR,aH as TokenDataVersion,a9 as addSplInterfaces,b8 as addTokenPoolAccountsLayout,aa as addTokenPools,a2 as approve,bb as approveAccountsLayout,a3 as approveAndMintTo,aZ as batchCompressLayout,d as calculateCompressibleLoadComputeUnits,aG as checkMint,al as checkSplInterfaceInfo,ar as checkTokenPoolInfo,a4 as compress,a5 as compressSplTokenAccount,a_ as compressSplTokenAccountInstructionDataLayout,W as convertTokenDataToAccount,i as createAssociatedCTokenAccountIdempotentInstruction,h as createAssociatedCTokenAccountInstruction,j as createAssociatedTokenAccountInterfaceInstruction,A as createAtaInterface,B as createAtaInterfaceIdempotent,m as createAtaInterfaceIdempotentInstruction,y as createCTokenTransferInstruction,w as createDecompressInterfaceInstruction,bq as createDecompressOutputState,a as createLoadAccountsParams,b as createLoadAtaInstructionsFromInterface,a6 as createMint,e as createMintInstruction,z as createMintInterface,o as createMintToCompressedInstruction,n as createMintToInstruction,p as createMintToInterfaceInstruction,u as createRemoveMetadataKeyInstruction,a7 as createSplInterface,f as createTokenMetadata,a8 as createTokenPool,b7 as createTokenPoolAccountsLayout,ab as createTokenProgramLookupTable,x as createTransferInterfaceInstruction,bp as createTransferOutputState,r as createUpdateFreezeAuthorityInstruction,t as createUpdateMetadataAuthorityInstruction,s as createUpdateMetadataFieldInstruction,q as createUpdateMintAuthorityInstruction,v as createWrapInstruction,bi as decodeApproveInstructionData,b2 as decodeBatchCompressInstructionData,b4 as decodeCompressSplTokenAccountInstructionData,b0 as decodeMintToInstructionData,bk as decodeRevokeInstructionData,Z as decodeTokenMetadata,b6 as decodeTransferInstructionData,ac as decompress,ai as decompressDelegated,F as decompressInterface,bz as deriveCMintAddress,ak as deriveSplInterfaceInfo,aq as deriveTokenPoolInfo,X as deserializeMint,bh as encodeApproveInstructionData,b1 as encodeBatchCompressInstructionData,b3 as encodeCompressSplTokenAccountInstructionData,a$ as encodeMintToInstructionData,bj as encodeRevokeInstructionData,_ as encodeTokenMetadata,b5 as encodeTransferInstructionData,$ as extractTokenMetadata,bB as findMintAddress,bd as freezeAccountsLayout,S as getAccountInterface,bD as getAssociatedCTokenAddress,bC as getAssociatedCTokenAddressAndBump,P as getMintInterface,as as getTokenPoolInfos,ax as groupAccountsByTreeType,bs as isSingleSplInterfaceInfo,bt as isSingleTokenPoolInfo,ad as mergeTokenAccounts,ae as mintTo,b9 as mintToAccountsLayout,H as mintToCToken,I as mintToCompressed,J as mintToInterface,aY as mintToLayout,aF as packCompressedTokenAccounts,U as parseCTokenCold,T as parseCTokenHot,bo as parseMaybeDelegatedTransfer,bn as parseTokenData,O as removeMetadataKey,af as revoke,bc as revokeAccountsLayout,ay as selectAccountsByPreferredTreeType,aA as selectMinCompressedTokenAccountsForDecompression,aB as selectMinCompressedTokenAccountsForTransfer,aC as selectMinCompressedTokenAccountsForTransferOrPartial,aD as selectSmartCompressedTokenAccountsForTransfer,aE as selectSmartCompressedTokenAccountsForTransferOrPartial,ao as selectSplInterfaceInfo,ap as selectSplInterfaceInfosForDecompression,az as selectTokenAccountsForApprove,at as selectTokenPoolInfo,au as selectTokenPoolInfosForDecompression,Y as serializeMint,bl as sumUpTokenAmount,be as thawAccountsLayout,V as toAccountInfo,a1 as toOffChainMetadataJson,aj as toTokenPoolInfo,ag as transfer,ba as transferAccountsLayout,ah as transferDelegated,R as unpackMintData,Q as unpackMintInterface,L as updateFreezeAuthority,N as updateMetadataAuthority,M as updateMetadataField,K as updateMintAuthority,bm as validateSameTokenOwner,G as wrap}from"../types-Z2gqWJ9V.js";import{getMint as la}from"@solana/spl-token";export{AccountState}from"@solana/spl-token";import"@coral-xyz/borsh";function Aa(a,e,t,s,o,n,r,i=t){const u=[ea(o,0,2,1,6),ta(o,0,3,4,n.poolIndex,n.bump,r)],p=sa({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:0,maxTopUp:0,cpiContext:null,compressions:u,proof:null,inTokenData:[],outTokenData:[],inLamports:null,outLamports:null,inTlv:null,outTlv:null}),d=[{pubkey:oa.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:i,isSigner:1,isWritable:1},{pubkey:s,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:0},{pubkey:a,isSigner:0,isWritable:1},{pubkey:e,isSigner:0,isWritable:1},{pubkey:n.splInterfacePda,isSigner:0,isWritable:1},{pubkey:n.tokenProgram,isSigner:0,isWritable:0},{pubkey:k,isSigner:0,isWritable:0}];return new c({programId:oa.programId,keys:d,data:p})}async function fa(a,e,t,s,o,n,r,c){C();let i=r;if(!i&&(i=(await na(a,o)).find((a=>a.isInitialized)),!i))throw new Error(`No initialized SPL interface found for mint: ${o.toBase58()}. Please create an SPL interface via createSplInterface().`);if(!await a.getAccountInfo(t))throw new Error(`Destination account does not exist: ${t.toBase58()}. Create it first using getOrCreateAssociatedTokenAccount or createAssociatedTokenAccountIdempotentInstruction.`);const u=ra(o,s.publicKey);await ca(a,u,s,o,e,c);const p=await a.getAccountInfo(u);if(!p)throw new Error("No c-token ATA found after loading");const d=p.data.readBigUInt64LE(64);if(d===BigInt(0))throw new Error("No c-token balance to unwrap");const I=n?BigInt(n.toString()):d;if(I>d)throw new Error(`Insufficient c-token balance. Requested: ${I}, Available: ${d}`);const T=await la(a,o,void 0,i.tokenProgram),A=Aa(u,t,s.publicKey,o,I,i,T.decimals,e.publicKey),{blockhash:f}=await a.getLatestBlockhash(),k=D(e,[s]),m=g([l.setComputeUnitLimit({units:2e5}),A],e,f,k);return await E(a,m,c)}async function ka(a,e,t,s,o,n){return ia(a,e,t,s,o,n,1)}function ma(a,e,t=0,s=k,o){if(!s.equals(k))throw new Error("Please derive the unified ATA from the c-token program; balances across SPL, T22, and c-token are unified under the canonical c-token ATA.");return ra(a,e,t,s,o)}async function Ca(a,e,t,s,o,n){return ua(a,e,t,s,o,n,1)}async function Sa(a,e,t,s,o,n,r){o??=t;const c=await ca(a,e,t,s,o,n,r,1);if(null===c&&!await a.getAccountInfo(e)){const r=pa(o.publicKey,e,t.publicKey,s,k),{blockhash:c}=await a.getLatestBlockhash(),i=g([l.setComputeUnitLimit({units:3e4}),r],o,c,o.publicKey.equals(t.publicKey)?[]:[t]);return E(a,i,n)}return c}async function ya(a,e,t,s,o,n,r,c=k,i,u){return da(a,e,t,s,o,n,r,c,i,u,1)}async function Ma(a,e,t,s,o=0,n,r){return Ia(a,e,t,s,o,n,r,k,Ta(k),1)}export{oa as CompressedTokenProgram,pa as createAssociatedTokenAccountInterfaceIdempotentInstruction,Ca as createLoadAtaInstructions,Aa as createUnwrapInstruction,ma as getAssociatedTokenAddressInterface,ka as getAtaInterface,Ma as getOrCreateAtaInterface,na as getSplInterfaceInfos,Sa as loadAta,ya as transferInterface,fa as unwrap};
1
+ import {
2
+ TransactionInstruction as c,
3
+ ComputeBudgetProgram as l,
4
+ } from '@solana/web3.js';
5
+ import {
6
+ CTOKEN_PROGRAM_ID as k,
7
+ assertBetaEnabled as C,
8
+ dedupeSigner as D,
9
+ buildAndSignTx as g,
10
+ sendAndConfirmTx as E,
11
+ } from '@lightprotocol/stateless.js';
12
+ import {
13
+ bu as ea,
14
+ bv as ta,
15
+ bw as sa,
16
+ br as oa,
17
+ am as na,
18
+ C as ra,
19
+ l as ca,
20
+ g as ia,
21
+ c as ua,
22
+ k as pa,
23
+ E as da,
24
+ bx as Ia,
25
+ by as Ta,
26
+ } from '../types-pblNXos5.js';
27
+ export {
28
+ aS as ADD_TOKEN_POOL_DISCRIMINATOR,
29
+ aQ as APPROVE_DISCRIMINATOR,
30
+ an as Action,
31
+ aN as BATCH_COMPRESS_DISCRIMINATOR,
32
+ bA as COMPRESSED_MINT_SEED,
33
+ aP as COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,
34
+ aJ as CPI_AUTHORITY_SEED,
35
+ aL as CREATE_TOKEN_POOL_DISCRIMINATOR,
36
+ bf as CompressedTokenInstructionDataApproveLayout,
37
+ bg as CompressedTokenInstructionDataRevokeLayout,
38
+ aX as CompressedTokenInstructionDataTransferLayout,
39
+ aW as CpiContextLayout,
40
+ aT as DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR,
41
+ aV as DelegatedTransferLayout,
42
+ aw as ERROR_MIXED_TREE_TYPES,
43
+ av as ERROR_NO_ACCOUNTS_FOUND,
44
+ a0 as ExtensionType,
45
+ aU as IDL,
46
+ aM as MINT_TO_DISCRIMINATOR,
47
+ aI as POOL_SEED,
48
+ aR as REVOKE_DISCRIMINATOR,
49
+ aK as SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,
50
+ aO as TRANSFER_DISCRIMINATOR,
51
+ aH as TokenDataVersion,
52
+ a9 as addSplInterfaces,
53
+ b8 as addTokenPoolAccountsLayout,
54
+ aa as addTokenPools,
55
+ a2 as approve,
56
+ bb as approveAccountsLayout,
57
+ a3 as approveAndMintTo,
58
+ aZ as batchCompressLayout,
59
+ d as calculateCompressibleLoadComputeUnits,
60
+ aG as checkMint,
61
+ al as checkSplInterfaceInfo,
62
+ ar as checkTokenPoolInfo,
63
+ a4 as compress,
64
+ a5 as compressSplTokenAccount,
65
+ a_ as compressSplTokenAccountInstructionDataLayout,
66
+ W as convertTokenDataToAccount,
67
+ i as createAssociatedCTokenAccountIdempotentInstruction,
68
+ h as createAssociatedCTokenAccountInstruction,
69
+ j as createAssociatedTokenAccountInterfaceInstruction,
70
+ A as createAtaInterface,
71
+ B as createAtaInterfaceIdempotent,
72
+ m as createAtaInterfaceIdempotentInstruction,
73
+ y as createCTokenTransferInstruction,
74
+ w as createDecompressInterfaceInstruction,
75
+ bq as createDecompressOutputState,
76
+ a as createLoadAccountsParams,
77
+ b as createLoadAtaInstructionsFromInterface,
78
+ a6 as createMint,
79
+ e as createMintInstruction,
80
+ z as createMintInterface,
81
+ o as createMintToCompressedInstruction,
82
+ n as createMintToInstruction,
83
+ p as createMintToInterfaceInstruction,
84
+ u as createRemoveMetadataKeyInstruction,
85
+ a7 as createSplInterface,
86
+ f as createTokenMetadata,
87
+ a8 as createTokenPool,
88
+ b7 as createTokenPoolAccountsLayout,
89
+ ab as createTokenProgramLookupTable,
90
+ x as createTransferInterfaceInstruction,
91
+ bp as createTransferOutputState,
92
+ r as createUpdateFreezeAuthorityInstruction,
93
+ t as createUpdateMetadataAuthorityInstruction,
94
+ s as createUpdateMetadataFieldInstruction,
95
+ q as createUpdateMintAuthorityInstruction,
96
+ v as createWrapInstruction,
97
+ bi as decodeApproveInstructionData,
98
+ b2 as decodeBatchCompressInstructionData,
99
+ b4 as decodeCompressSplTokenAccountInstructionData,
100
+ b0 as decodeMintToInstructionData,
101
+ bk as decodeRevokeInstructionData,
102
+ Z as decodeTokenMetadata,
103
+ b6 as decodeTransferInstructionData,
104
+ ac as decompress,
105
+ ai as decompressDelegated,
106
+ F as decompressInterface,
107
+ bz as deriveCMintAddress,
108
+ ak as deriveSplInterfaceInfo,
109
+ aq as deriveTokenPoolInfo,
110
+ X as deserializeMint,
111
+ bh as encodeApproveInstructionData,
112
+ b1 as encodeBatchCompressInstructionData,
113
+ b3 as encodeCompressSplTokenAccountInstructionData,
114
+ a$ as encodeMintToInstructionData,
115
+ bj as encodeRevokeInstructionData,
116
+ _ as encodeTokenMetadata,
117
+ b5 as encodeTransferInstructionData,
118
+ $ as extractTokenMetadata,
119
+ bB as findMintAddress,
120
+ bd as freezeAccountsLayout,
121
+ S as getAccountInterface,
122
+ bD as getAssociatedCTokenAddress,
123
+ bC as getAssociatedCTokenAddressAndBump,
124
+ P as getMintInterface,
125
+ as as getTokenPoolInfos,
126
+ ax as groupAccountsByTreeType,
127
+ bs as isSingleSplInterfaceInfo,
128
+ bt as isSingleTokenPoolInfo,
129
+ ad as mergeTokenAccounts,
130
+ ae as mintTo,
131
+ b9 as mintToAccountsLayout,
132
+ H as mintToCToken,
133
+ I as mintToCompressed,
134
+ J as mintToInterface,
135
+ aY as mintToLayout,
136
+ aF as packCompressedTokenAccounts,
137
+ U as parseCTokenCold,
138
+ T as parseCTokenHot,
139
+ bo as parseMaybeDelegatedTransfer,
140
+ bn as parseTokenData,
141
+ O as removeMetadataKey,
142
+ af as revoke,
143
+ bc as revokeAccountsLayout,
144
+ ay as selectAccountsByPreferredTreeType,
145
+ aA as selectMinCompressedTokenAccountsForDecompression,
146
+ aB as selectMinCompressedTokenAccountsForTransfer,
147
+ aC as selectMinCompressedTokenAccountsForTransferOrPartial,
148
+ aD as selectSmartCompressedTokenAccountsForTransfer,
149
+ aE as selectSmartCompressedTokenAccountsForTransferOrPartial,
150
+ ao as selectSplInterfaceInfo,
151
+ ap as selectSplInterfaceInfosForDecompression,
152
+ az as selectTokenAccountsForApprove,
153
+ at as selectTokenPoolInfo,
154
+ au as selectTokenPoolInfosForDecompression,
155
+ Y as serializeMint,
156
+ bl as sumUpTokenAmount,
157
+ be as thawAccountsLayout,
158
+ V as toAccountInfo,
159
+ a1 as toOffChainMetadataJson,
160
+ aj as toTokenPoolInfo,
161
+ ag as transfer,
162
+ ba as transferAccountsLayout,
163
+ ah as transferDelegated,
164
+ R as unpackMintData,
165
+ Q as unpackMintInterface,
166
+ L as updateFreezeAuthority,
167
+ N as updateMetadataAuthority,
168
+ M as updateMetadataField,
169
+ K as updateMintAuthority,
170
+ bm as validateSameTokenOwner,
171
+ G as wrap,
172
+ } from '../types-pblNXos5.js';
173
+ import { getMint as la } from '@solana/spl-token';
174
+ export { AccountState } from '@solana/spl-token';
175
+ import '@coral-xyz/borsh';
176
+ function Aa(a, e, t, s, o, n, r, i = t) {
177
+ const u = [ea(o, 0, 2, 1, 6), ta(o, 0, 3, 4, n.poolIndex, n.bump, r)],
178
+ p = sa({
179
+ withTransactionHash: 0,
180
+ withLamportsChangeAccountMerkleTreeIndex: 0,
181
+ lamportsChangeAccountMerkleTreeIndex: 0,
182
+ lamportsChangeAccountOwnerIndex: 0,
183
+ outputQueue: 0,
184
+ maxTopUp: 0,
185
+ cpiContext: null,
186
+ compressions: u,
187
+ proof: null,
188
+ inTokenData: [],
189
+ outTokenData: [],
190
+ inLamports: null,
191
+ outLamports: null,
192
+ inTlv: null,
193
+ outTlv: null,
194
+ }),
195
+ d = [
196
+ { pubkey: oa.deriveCpiAuthorityPda, isSigner: 0, isWritable: 0 },
197
+ { pubkey: i, isSigner: 1, isWritable: 1 },
198
+ { pubkey: s, isSigner: 0, isWritable: 0 },
199
+ { pubkey: t, isSigner: 1, isWritable: 0 },
200
+ { pubkey: a, isSigner: 0, isWritable: 1 },
201
+ { pubkey: e, isSigner: 0, isWritable: 1 },
202
+ { pubkey: n.splInterfacePda, isSigner: 0, isWritable: 1 },
203
+ { pubkey: n.tokenProgram, isSigner: 0, isWritable: 0 },
204
+ { pubkey: k, isSigner: 0, isWritable: 0 },
205
+ ];
206
+ return new c({ programId: oa.programId, keys: d, data: p });
207
+ }
208
+ async function fa(a, e, t, s, o, n, r, c) {
209
+ C();
210
+ let i = r;
211
+ if (!i && ((i = (await na(a, o)).find(a => a.isInitialized)), !i))
212
+ throw new Error(
213
+ `No initialized SPL interface found for mint: ${o.toBase58()}. Please create an SPL interface via createSplInterface().`,
214
+ );
215
+ if (!(await a.getAccountInfo(t)))
216
+ throw new Error(
217
+ `Destination account does not exist: ${t.toBase58()}. Create it first using getOrCreateAssociatedTokenAccount or createAssociatedTokenAccountIdempotentInstruction.`,
218
+ );
219
+ const u = ra(o, s.publicKey);
220
+ await ca(a, u, s, o, e, c);
221
+ const p = await a.getAccountInfo(u);
222
+ if (!p) throw new Error('No c-token ATA found after loading');
223
+ const d = p.data.readBigUInt64LE(64);
224
+ if (d === BigInt(0)) throw new Error('No c-token balance to unwrap');
225
+ const I = n ? BigInt(n.toString()) : d;
226
+ if (I > d)
227
+ throw new Error(
228
+ `Insufficient c-token balance. Requested: ${I}, Available: ${d}`,
229
+ );
230
+ const T = await la(a, o, void 0, i.tokenProgram),
231
+ A = Aa(u, t, s.publicKey, o, I, i, T.decimals, e.publicKey),
232
+ { blockhash: f } = await a.getLatestBlockhash(),
233
+ k = D(e, [s]),
234
+ m = g([l.setComputeUnitLimit({ units: 2e5 }), A], e, f, k);
235
+ return await E(a, m, c);
236
+ }
237
+ async function ka(a, e, t, s, o, n) {
238
+ return ia(a, e, t, s, o, n, 1);
239
+ }
240
+ function ma(a, e, t = 0, s = k, o) {
241
+ if (!s.equals(k))
242
+ throw new Error(
243
+ 'Please derive the unified ATA from the c-token program; balances across SPL, T22, and c-token are unified under the canonical c-token ATA.',
244
+ );
245
+ return ra(a, e, t, s, o);
246
+ }
247
+ async function Ca(a, e, t, s, o, n) {
248
+ return ua(a, e, t, s, o, n, 1);
249
+ }
250
+ async function Sa(a, e, t, s, o, n, r) {
251
+ o ??= t;
252
+ const c = await ca(a, e, t, s, o, n, r, 1);
253
+ if (null === c && !(await a.getAccountInfo(e))) {
254
+ const r = pa(o.publicKey, e, t.publicKey, s, k),
255
+ { blockhash: c } = await a.getLatestBlockhash(),
256
+ i = g(
257
+ [l.setComputeUnitLimit({ units: 3e4 }), r],
258
+ o,
259
+ c,
260
+ o.publicKey.equals(t.publicKey) ? [] : [t],
261
+ );
262
+ return E(a, i, n);
263
+ }
264
+ return c;
265
+ }
266
+ async function ya(a, e, t, s, o, n, r, c = k, i, u) {
267
+ return da(a, e, t, s, o, n, r, c, i, u, 1);
268
+ }
269
+ async function Ma(a, e, t, s, o = 0, n, r) {
270
+ return Ia(a, e, t, s, o, n, r, k, Ta(k), 1);
271
+ }
272
+ export {
273
+ oa as CompressedTokenProgram,
274
+ pa as createAssociatedTokenAccountInterfaceIdempotentInstruction,
275
+ Ca as createLoadAtaInstructions,
276
+ Aa as createUnwrapInstruction,
277
+ ma as getAssociatedTokenAddressInterface,
278
+ ka as getAtaInterface,
279
+ Ma as getOrCreateAtaInterface,
280
+ na as getSplInterfaceInfos,
281
+ Sa as loadAta,
282
+ ya as transferInterface,
283
+ fa as unwrap,
284
+ };
2
285
  //# sourceMappingURL=index.js.map