@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.
- package/dist/cjs/browser/index.cjs +218 -1
- package/dist/cjs/browser/types-qZMOMIxa.cjs +11351 -0
- package/dist/cjs/browser/types-qZMOMIxa.cjs.map +1 -0
- package/dist/cjs/browser/unified/index.cjs +379 -1
- package/dist/cjs/node/index.cjs +219 -1
- package/dist/cjs/node/types-BsKbElnz.cjs +10113 -0
- package/dist/cjs/node/types-BsKbElnz.cjs.map +1 -0
- package/dist/cjs/node/unified/index.cjs +380 -1
- package/dist/es/browser/index.js +166 -1
- package/dist/es/browser/types-pblNXos5.js +10454 -0
- package/dist/es/browser/types-pblNXos5.js.map +1 -0
- package/dist/es/browser/unified/index.js +284 -1
- package/dist/types/index.d.ts +1271 -262
- package/dist/types/unified/index.d.ts +1307 -267
- package/package.json +2 -2
- package/dist/cjs/browser/types-BYVvBJS4.cjs +0 -2
- package/dist/cjs/browser/types-BYVvBJS4.cjs.map +0 -1
- package/dist/cjs/node/types-C6bFjLLI.cjs +0 -2
- package/dist/cjs/node/types-C6bFjLLI.cjs.map +0 -1
- package/dist/es/browser/types-Z2gqWJ9V.js +0 -2
- package/dist/es/browser/types-Z2gqWJ9V.js.map +0 -1
|
@@ -1,2 +1,285 @@
|
|
|
1
|
-
import
|
|
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
|