@lightprotocol/compressed-token 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser/index.cjs +25 -120
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +25 -120
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/es/browser/index.js +26 -121
- package/dist/es/browser/index.js.map +1 -1
- package/dist/types/index.d.ts +23 -127
- package/package.json +2 -2
package/dist/es/browser/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { getIndexOrAdd,
|
|
1
|
+
import { getIndexOrAdd, bn, padOutputStateMerkleTrees, useWallet, confirmConfig, defaultStaticAccountsStruct, toArray, LightSystemProgram, defaultTestStateTreeAccounts, sumUpLamports, validateSufficientBalance, validateSameOwner, dedupeSigner, buildAndSignTx, sendAndConfirmTx } from '@lightprotocol/stateless.js';
|
|
2
2
|
import { PublicKey, TransactionInstruction, SystemProgram, Transaction, sendAndConfirmTransaction, Keypair, Connection, ComputeBudgetProgram } from '@solana/web3.js';
|
|
3
3
|
import { AnchorProvider, setProvider, Program } from '@coral-xyz/anchor';
|
|
4
4
|
|
|
5
5
|
const IDL = {
|
|
6
|
-
version: '0.4.
|
|
6
|
+
version: '0.4.1',
|
|
7
7
|
name: 'light_compressed_token',
|
|
8
8
|
instructions: [
|
|
9
9
|
{
|
|
10
|
-
name: '
|
|
10
|
+
name: 'createTokenPool',
|
|
11
11
|
docs: [
|
|
12
12
|
'This instruction expects a mint account to be created in a separate',
|
|
13
13
|
'token program instruction with token authority as mint authority. This',
|
|
@@ -879,12 +879,6 @@ const IDL = {
|
|
|
879
879
|
option: 'u8',
|
|
880
880
|
},
|
|
881
881
|
},
|
|
882
|
-
{
|
|
883
|
-
name: 'isNative',
|
|
884
|
-
type: {
|
|
885
|
-
option: 'u64',
|
|
886
|
-
},
|
|
887
|
-
},
|
|
888
882
|
{
|
|
889
883
|
name: 'merkleContext',
|
|
890
884
|
type: {
|
|
@@ -895,6 +889,12 @@ const IDL = {
|
|
|
895
889
|
name: 'rootIndex',
|
|
896
890
|
type: 'u16',
|
|
897
891
|
},
|
|
892
|
+
{
|
|
893
|
+
name: 'lamports',
|
|
894
|
+
type: {
|
|
895
|
+
option: 'u64',
|
|
896
|
+
},
|
|
897
|
+
},
|
|
898
898
|
],
|
|
899
899
|
},
|
|
900
900
|
},
|
|
@@ -1345,18 +1345,6 @@ const IDL = {
|
|
|
1345
1345
|
defined: 'AccountState',
|
|
1346
1346
|
},
|
|
1347
1347
|
},
|
|
1348
|
-
{
|
|
1349
|
-
name: 'isNative',
|
|
1350
|
-
docs: [
|
|
1351
|
-
'If is_some, this is a native token, and the value logs the rent-exempt',
|
|
1352
|
-
'reserve. An Account is required to be rent-exempt, so the value is',
|
|
1353
|
-
'used by the Processor to ensure that wrapped SOL accounts do not',
|
|
1354
|
-
'drop below this threshold.',
|
|
1355
|
-
],
|
|
1356
|
-
type: {
|
|
1357
|
-
option: 'u64',
|
|
1358
|
-
},
|
|
1359
|
-
},
|
|
1360
1348
|
],
|
|
1361
1349
|
},
|
|
1362
1350
|
},
|
|
@@ -1364,108 +1352,23 @@ const IDL = {
|
|
|
1364
1352
|
errors: [
|
|
1365
1353
|
{
|
|
1366
1354
|
code: 6000,
|
|
1367
|
-
name: '
|
|
1368
|
-
msg: '
|
|
1355
|
+
name: 'SignerCheckFailed',
|
|
1356
|
+
msg: 'Signer check failed',
|
|
1369
1357
|
},
|
|
1370
1358
|
{
|
|
1371
1359
|
code: 6001,
|
|
1372
|
-
name: '
|
|
1373
|
-
msg: '
|
|
1360
|
+
name: 'CreateTransferInstructionFailed',
|
|
1361
|
+
msg: 'Create transfer instruction failed',
|
|
1374
1362
|
},
|
|
1375
1363
|
{
|
|
1376
1364
|
code: 6002,
|
|
1377
|
-
name: '
|
|
1378
|
-
msg: '
|
|
1365
|
+
name: 'AccountNotFound',
|
|
1366
|
+
msg: 'Account not found',
|
|
1379
1367
|
},
|
|
1380
1368
|
{
|
|
1381
1369
|
code: 6003,
|
|
1382
|
-
name: '
|
|
1383
|
-
msg: '
|
|
1384
|
-
},
|
|
1385
|
-
{
|
|
1386
|
-
code: 6004,
|
|
1387
|
-
name: 'ComputeCompressSumFailed',
|
|
1388
|
-
msg: 'ComputeCompressSumFailed',
|
|
1389
|
-
},
|
|
1390
|
-
{
|
|
1391
|
-
code: 6005,
|
|
1392
|
-
name: 'ComputeDecompressSumFailed',
|
|
1393
|
-
msg: 'ComputeDecompressSumFailed',
|
|
1394
|
-
},
|
|
1395
|
-
{
|
|
1396
|
-
code: 6006,
|
|
1397
|
-
name: 'SumCheckFailed',
|
|
1398
|
-
msg: 'SumCheckFailed',
|
|
1399
|
-
},
|
|
1400
|
-
{
|
|
1401
|
-
code: 6007,
|
|
1402
|
-
name: 'DecompressRecipientUndefinedForDecompress',
|
|
1403
|
-
msg: 'DecompressRecipientUndefinedForDecompress',
|
|
1404
|
-
},
|
|
1405
|
-
{
|
|
1406
|
-
code: 6008,
|
|
1407
|
-
name: 'CompressedPdaUndefinedForDecompress',
|
|
1408
|
-
msg: 'CompressedPdaUndefinedForDecompress',
|
|
1409
|
-
},
|
|
1410
|
-
{
|
|
1411
|
-
code: 6009,
|
|
1412
|
-
name: 'DeCompressAmountUndefinedForDecompress',
|
|
1413
|
-
msg: 'DeCompressAmountUndefinedForDecompress',
|
|
1414
|
-
},
|
|
1415
|
-
{
|
|
1416
|
-
code: 6010,
|
|
1417
|
-
name: 'CompressedPdaUndefinedForCompress',
|
|
1418
|
-
msg: 'CompressedPdaUndefinedForCompress',
|
|
1419
|
-
},
|
|
1420
|
-
{
|
|
1421
|
-
code: 6011,
|
|
1422
|
-
name: 'DeCompressAmountUndefinedForCompress',
|
|
1423
|
-
msg: 'DeCompressAmountUndefinedForCompress',
|
|
1424
|
-
},
|
|
1425
|
-
{
|
|
1426
|
-
code: 6012,
|
|
1427
|
-
name: 'DelegateUndefined',
|
|
1428
|
-
msg: 'DelegateUndefined while delegated amount is defined',
|
|
1429
|
-
},
|
|
1430
|
-
{
|
|
1431
|
-
code: 6013,
|
|
1432
|
-
name: 'DelegateSignerCheckFailed',
|
|
1433
|
-
msg: 'DelegateSignerCheckFailed',
|
|
1434
|
-
},
|
|
1435
|
-
{
|
|
1436
|
-
code: 6014,
|
|
1437
|
-
name: 'SplTokenSupplyMismatch',
|
|
1438
|
-
msg: 'SplTokenSupplyMismatch',
|
|
1439
|
-
},
|
|
1440
|
-
{
|
|
1441
|
-
code: 6015,
|
|
1442
|
-
name: 'HeapMemoryCheckFailed',
|
|
1443
|
-
msg: 'HeapMemoryCheckFailed',
|
|
1444
|
-
},
|
|
1445
|
-
{
|
|
1446
|
-
code: 6016,
|
|
1447
|
-
name: 'InstructionNotCallable',
|
|
1448
|
-
msg: 'The instruction is not callable',
|
|
1449
|
-
},
|
|
1450
|
-
{
|
|
1451
|
-
code: 6017,
|
|
1452
|
-
name: 'ArithmeticUnderflow',
|
|
1453
|
-
msg: 'ArithmeticUnderflow',
|
|
1454
|
-
},
|
|
1455
|
-
{
|
|
1456
|
-
code: 6018,
|
|
1457
|
-
name: 'InvalidDelegate',
|
|
1458
|
-
msg: 'InvalidDelegate',
|
|
1459
|
-
},
|
|
1460
|
-
{
|
|
1461
|
-
code: 6019,
|
|
1462
|
-
name: 'HashToFieldError',
|
|
1463
|
-
msg: 'HashToFieldError',
|
|
1464
|
-
},
|
|
1465
|
-
{
|
|
1466
|
-
code: 6020,
|
|
1467
|
-
name: 'InvalidMint',
|
|
1468
|
-
msg: 'InvalidMint',
|
|
1370
|
+
name: 'SerializationError',
|
|
1371
|
+
msg: 'Serialization error',
|
|
1469
1372
|
},
|
|
1470
1373
|
],
|
|
1471
1374
|
};
|
|
@@ -1492,13 +1395,15 @@ function packCompressedTokenAccounts(params) {
|
|
|
1492
1395
|
packedInputTokenData.push({
|
|
1493
1396
|
amount: account.parsed.amount,
|
|
1494
1397
|
delegateIndex,
|
|
1495
|
-
isNative: account.parsed.isNative,
|
|
1496
1398
|
merkleContext: {
|
|
1497
1399
|
merkleTreePubkeyIndex,
|
|
1498
1400
|
nullifierQueuePubkeyIndex,
|
|
1499
1401
|
leafIndex: account.compressedAccount.leafIndex,
|
|
1500
1402
|
},
|
|
1501
1403
|
rootIndex: rootIndices[index],
|
|
1404
|
+
lamports: account.compressedAccount.lamports.eq(bn(0))
|
|
1405
|
+
? null
|
|
1406
|
+
: account.compressedAccount.lamports,
|
|
1502
1407
|
});
|
|
1503
1408
|
});
|
|
1504
1409
|
/// pack output state trees
|
|
@@ -6541,7 +6446,7 @@ class CompressedTokenProgram {
|
|
|
6541
6446
|
space: MINT_SIZE,
|
|
6542
6447
|
});
|
|
6543
6448
|
const initializeMintInstruction = createInitializeMint2Instruction(mint, params.decimals, authority, params.freezeAuthority, TOKEN_PROGRAM_ID);
|
|
6544
|
-
const ix = await this.
|
|
6449
|
+
const ix = await this.createTokenPool({
|
|
6545
6450
|
feePayer,
|
|
6546
6451
|
mint,
|
|
6547
6452
|
});
|
|
@@ -6551,11 +6456,11 @@ class CompressedTokenProgram {
|
|
|
6551
6456
|
* Enable compression for an existing SPL mint, creating an omnibus account.
|
|
6552
6457
|
* For new mints, use `CompressedTokenProgram.createMint`.
|
|
6553
6458
|
*/
|
|
6554
|
-
static async
|
|
6459
|
+
static async createTokenPool(params) {
|
|
6555
6460
|
const { mint, feePayer } = params;
|
|
6556
6461
|
const tokenPoolPda = this.deriveTokenPoolPda(mint);
|
|
6557
6462
|
const ix = await this.program.methods
|
|
6558
|
-
.
|
|
6463
|
+
.createTokenPool()
|
|
6559
6464
|
.accounts({
|
|
6560
6465
|
mint,
|
|
6561
6466
|
feePayer,
|
|
@@ -7027,8 +6932,8 @@ async function mintTo(rpc, payer, mint, destination, authority, amount, merkleTr
|
|
|
7027
6932
|
*
|
|
7028
6933
|
* @return transaction signature
|
|
7029
6934
|
*/
|
|
7030
|
-
async function
|
|
7031
|
-
const ix = await CompressedTokenProgram.
|
|
6935
|
+
async function createTokenPool(rpc, payer, mintAddress, confirmOptions) {
|
|
6936
|
+
const ix = await CompressedTokenProgram.createTokenPool({
|
|
7032
6937
|
feePayer: payer.publicKey,
|
|
7033
6938
|
mint: mintAddress,
|
|
7034
6939
|
});
|
|
@@ -7038,5 +6943,5 @@ async function registerMint(rpc, payer, mintAddress, confirmOptions) {
|
|
|
7038
6943
|
return txId;
|
|
7039
6944
|
}
|
|
7040
6945
|
|
|
7041
|
-
export { CPI_AUTHORITY_SEED, CompressedTokenProgram, IDL, POOL_SEED, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, approveAndMintTo, compress, createDecompressOutputState, createMint, createTransferOutputState, decompress, mintTo, packCompressedTokenAccounts, parseTokenData,
|
|
6946
|
+
export { CPI_AUTHORITY_SEED, CompressedTokenProgram, IDL, POOL_SEED, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, approveAndMintTo, compress, createDecompressOutputState, createMint, createTokenPool, createTransferOutputState, decompress, mintTo, packCompressedTokenAccounts, parseTokenData, selectMinCompressedTokenAccountsForTransfer, sumUpTokenAmount, transfer, validateSameTokenOwner };
|
|
7042
6947
|
//# sourceMappingURL=index.js.map
|