@lightprotocol/compressed-token 0.3.0 → 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/cjs/node/index.cjs
CHANGED
|
@@ -6,11 +6,11 @@ var anchor = require('@coral-xyz/anchor');
|
|
|
6
6
|
var require$$0 = require('buffer');
|
|
7
7
|
|
|
8
8
|
const IDL = {
|
|
9
|
-
version: '0.4.
|
|
9
|
+
version: '0.4.1',
|
|
10
10
|
name: 'light_compressed_token',
|
|
11
11
|
instructions: [
|
|
12
12
|
{
|
|
13
|
-
name: '
|
|
13
|
+
name: 'createTokenPool',
|
|
14
14
|
docs: [
|
|
15
15
|
'This instruction expects a mint account to be created in a separate',
|
|
16
16
|
'token program instruction with token authority as mint authority. This',
|
|
@@ -882,12 +882,6 @@ const IDL = {
|
|
|
882
882
|
option: 'u8',
|
|
883
883
|
},
|
|
884
884
|
},
|
|
885
|
-
{
|
|
886
|
-
name: 'isNative',
|
|
887
|
-
type: {
|
|
888
|
-
option: 'u64',
|
|
889
|
-
},
|
|
890
|
-
},
|
|
891
885
|
{
|
|
892
886
|
name: 'merkleContext',
|
|
893
887
|
type: {
|
|
@@ -898,6 +892,12 @@ const IDL = {
|
|
|
898
892
|
name: 'rootIndex',
|
|
899
893
|
type: 'u16',
|
|
900
894
|
},
|
|
895
|
+
{
|
|
896
|
+
name: 'lamports',
|
|
897
|
+
type: {
|
|
898
|
+
option: 'u64',
|
|
899
|
+
},
|
|
900
|
+
},
|
|
901
901
|
],
|
|
902
902
|
},
|
|
903
903
|
},
|
|
@@ -1348,18 +1348,6 @@ const IDL = {
|
|
|
1348
1348
|
defined: 'AccountState',
|
|
1349
1349
|
},
|
|
1350
1350
|
},
|
|
1351
|
-
{
|
|
1352
|
-
name: 'isNative',
|
|
1353
|
-
docs: [
|
|
1354
|
-
'If is_some, this is a native token, and the value logs the rent-exempt',
|
|
1355
|
-
'reserve. An Account is required to be rent-exempt, so the value is',
|
|
1356
|
-
'used by the Processor to ensure that wrapped SOL accounts do not',
|
|
1357
|
-
'drop below this threshold.',
|
|
1358
|
-
],
|
|
1359
|
-
type: {
|
|
1360
|
-
option: 'u64',
|
|
1361
|
-
},
|
|
1362
|
-
},
|
|
1363
1351
|
],
|
|
1364
1352
|
},
|
|
1365
1353
|
},
|
|
@@ -1367,108 +1355,23 @@ const IDL = {
|
|
|
1367
1355
|
errors: [
|
|
1368
1356
|
{
|
|
1369
1357
|
code: 6000,
|
|
1370
|
-
name: '
|
|
1371
|
-
msg: '
|
|
1358
|
+
name: 'SignerCheckFailed',
|
|
1359
|
+
msg: 'Signer check failed',
|
|
1372
1360
|
},
|
|
1373
1361
|
{
|
|
1374
1362
|
code: 6001,
|
|
1375
|
-
name: '
|
|
1376
|
-
msg: '
|
|
1363
|
+
name: 'CreateTransferInstructionFailed',
|
|
1364
|
+
msg: 'Create transfer instruction failed',
|
|
1377
1365
|
},
|
|
1378
1366
|
{
|
|
1379
1367
|
code: 6002,
|
|
1380
|
-
name: '
|
|
1381
|
-
msg: '
|
|
1368
|
+
name: 'AccountNotFound',
|
|
1369
|
+
msg: 'Account not found',
|
|
1382
1370
|
},
|
|
1383
1371
|
{
|
|
1384
1372
|
code: 6003,
|
|
1385
|
-
name: '
|
|
1386
|
-
msg: '
|
|
1387
|
-
},
|
|
1388
|
-
{
|
|
1389
|
-
code: 6004,
|
|
1390
|
-
name: 'ComputeCompressSumFailed',
|
|
1391
|
-
msg: 'ComputeCompressSumFailed',
|
|
1392
|
-
},
|
|
1393
|
-
{
|
|
1394
|
-
code: 6005,
|
|
1395
|
-
name: 'ComputeDecompressSumFailed',
|
|
1396
|
-
msg: 'ComputeDecompressSumFailed',
|
|
1397
|
-
},
|
|
1398
|
-
{
|
|
1399
|
-
code: 6006,
|
|
1400
|
-
name: 'SumCheckFailed',
|
|
1401
|
-
msg: 'SumCheckFailed',
|
|
1402
|
-
},
|
|
1403
|
-
{
|
|
1404
|
-
code: 6007,
|
|
1405
|
-
name: 'DecompressRecipientUndefinedForDecompress',
|
|
1406
|
-
msg: 'DecompressRecipientUndefinedForDecompress',
|
|
1407
|
-
},
|
|
1408
|
-
{
|
|
1409
|
-
code: 6008,
|
|
1410
|
-
name: 'CompressedPdaUndefinedForDecompress',
|
|
1411
|
-
msg: 'CompressedPdaUndefinedForDecompress',
|
|
1412
|
-
},
|
|
1413
|
-
{
|
|
1414
|
-
code: 6009,
|
|
1415
|
-
name: 'DeCompressAmountUndefinedForDecompress',
|
|
1416
|
-
msg: 'DeCompressAmountUndefinedForDecompress',
|
|
1417
|
-
},
|
|
1418
|
-
{
|
|
1419
|
-
code: 6010,
|
|
1420
|
-
name: 'CompressedPdaUndefinedForCompress',
|
|
1421
|
-
msg: 'CompressedPdaUndefinedForCompress',
|
|
1422
|
-
},
|
|
1423
|
-
{
|
|
1424
|
-
code: 6011,
|
|
1425
|
-
name: 'DeCompressAmountUndefinedForCompress',
|
|
1426
|
-
msg: 'DeCompressAmountUndefinedForCompress',
|
|
1427
|
-
},
|
|
1428
|
-
{
|
|
1429
|
-
code: 6012,
|
|
1430
|
-
name: 'DelegateUndefined',
|
|
1431
|
-
msg: 'DelegateUndefined while delegated amount is defined',
|
|
1432
|
-
},
|
|
1433
|
-
{
|
|
1434
|
-
code: 6013,
|
|
1435
|
-
name: 'DelegateSignerCheckFailed',
|
|
1436
|
-
msg: 'DelegateSignerCheckFailed',
|
|
1437
|
-
},
|
|
1438
|
-
{
|
|
1439
|
-
code: 6014,
|
|
1440
|
-
name: 'SplTokenSupplyMismatch',
|
|
1441
|
-
msg: 'SplTokenSupplyMismatch',
|
|
1442
|
-
},
|
|
1443
|
-
{
|
|
1444
|
-
code: 6015,
|
|
1445
|
-
name: 'HeapMemoryCheckFailed',
|
|
1446
|
-
msg: 'HeapMemoryCheckFailed',
|
|
1447
|
-
},
|
|
1448
|
-
{
|
|
1449
|
-
code: 6016,
|
|
1450
|
-
name: 'InstructionNotCallable',
|
|
1451
|
-
msg: 'The instruction is not callable',
|
|
1452
|
-
},
|
|
1453
|
-
{
|
|
1454
|
-
code: 6017,
|
|
1455
|
-
name: 'ArithmeticUnderflow',
|
|
1456
|
-
msg: 'ArithmeticUnderflow',
|
|
1457
|
-
},
|
|
1458
|
-
{
|
|
1459
|
-
code: 6018,
|
|
1460
|
-
name: 'InvalidDelegate',
|
|
1461
|
-
msg: 'InvalidDelegate',
|
|
1462
|
-
},
|
|
1463
|
-
{
|
|
1464
|
-
code: 6019,
|
|
1465
|
-
name: 'HashToFieldError',
|
|
1466
|
-
msg: 'HashToFieldError',
|
|
1467
|
-
},
|
|
1468
|
-
{
|
|
1469
|
-
code: 6020,
|
|
1470
|
-
name: 'InvalidMint',
|
|
1471
|
-
msg: 'InvalidMint',
|
|
1373
|
+
name: 'SerializationError',
|
|
1374
|
+
msg: 'Serialization error',
|
|
1472
1375
|
},
|
|
1473
1376
|
],
|
|
1474
1377
|
};
|
|
@@ -1495,13 +1398,15 @@ function packCompressedTokenAccounts(params) {
|
|
|
1495
1398
|
packedInputTokenData.push({
|
|
1496
1399
|
amount: account.parsed.amount,
|
|
1497
1400
|
delegateIndex,
|
|
1498
|
-
isNative: account.parsed.isNative,
|
|
1499
1401
|
merkleContext: {
|
|
1500
1402
|
merkleTreePubkeyIndex,
|
|
1501
1403
|
nullifierQueuePubkeyIndex,
|
|
1502
1404
|
leafIndex: account.compressedAccount.leafIndex,
|
|
1503
1405
|
},
|
|
1504
1406
|
rootIndex: rootIndices[index],
|
|
1407
|
+
lamports: account.compressedAccount.lamports.eq(stateless_js.bn(0))
|
|
1408
|
+
? null
|
|
1409
|
+
: account.compressedAccount.lamports,
|
|
1505
1410
|
});
|
|
1506
1411
|
});
|
|
1507
1412
|
/// pack output state trees
|
|
@@ -4516,7 +4421,7 @@ class CompressedTokenProgram {
|
|
|
4516
4421
|
space: MINT_SIZE,
|
|
4517
4422
|
});
|
|
4518
4423
|
const initializeMintInstruction = createInitializeMint2Instruction(mint, params.decimals, authority, params.freezeAuthority, TOKEN_PROGRAM_ID);
|
|
4519
|
-
const ix = await this.
|
|
4424
|
+
const ix = await this.createTokenPool({
|
|
4520
4425
|
feePayer,
|
|
4521
4426
|
mint,
|
|
4522
4427
|
});
|
|
@@ -4526,11 +4431,11 @@ class CompressedTokenProgram {
|
|
|
4526
4431
|
* Enable compression for an existing SPL mint, creating an omnibus account.
|
|
4527
4432
|
* For new mints, use `CompressedTokenProgram.createMint`.
|
|
4528
4433
|
*/
|
|
4529
|
-
static async
|
|
4434
|
+
static async createTokenPool(params) {
|
|
4530
4435
|
const { mint, feePayer } = params;
|
|
4531
4436
|
const tokenPoolPda = this.deriveTokenPoolPda(mint);
|
|
4532
4437
|
const ix = await this.program.methods
|
|
4533
|
-
.
|
|
4438
|
+
.createTokenPool()
|
|
4534
4439
|
.accounts({
|
|
4535
4440
|
mint,
|
|
4536
4441
|
feePayer,
|
|
@@ -5007,8 +4912,8 @@ async function mintTo(rpc, payer, mint, destination, authority, amount, merkleTr
|
|
|
5007
4912
|
*
|
|
5008
4913
|
* @return transaction signature
|
|
5009
4914
|
*/
|
|
5010
|
-
async function
|
|
5011
|
-
const ix = await CompressedTokenProgram.
|
|
4915
|
+
async function createTokenPool(rpc, payer, mintAddress, confirmOptions) {
|
|
4916
|
+
const ix = await CompressedTokenProgram.createTokenPool({
|
|
5012
4917
|
feePayer: payer.publicKey,
|
|
5013
4918
|
mint: mintAddress,
|
|
5014
4919
|
});
|
|
@@ -5027,12 +4932,12 @@ exports.approveAndMintTo = approveAndMintTo;
|
|
|
5027
4932
|
exports.compress = compress;
|
|
5028
4933
|
exports.createDecompressOutputState = createDecompressOutputState;
|
|
5029
4934
|
exports.createMint = createMint;
|
|
4935
|
+
exports.createTokenPool = createTokenPool;
|
|
5030
4936
|
exports.createTransferOutputState = createTransferOutputState;
|
|
5031
4937
|
exports.decompress = decompress;
|
|
5032
4938
|
exports.mintTo = mintTo;
|
|
5033
4939
|
exports.packCompressedTokenAccounts = packCompressedTokenAccounts;
|
|
5034
4940
|
exports.parseTokenData = parseTokenData;
|
|
5035
|
-
exports.registerMint = registerMint;
|
|
5036
4941
|
exports.selectMinCompressedTokenAccountsForTransfer = selectMinCompressedTokenAccountsForTransfer;
|
|
5037
4942
|
exports.sumUpTokenAmount = sumUpTokenAmount;
|
|
5038
4943
|
exports.transfer = transfer;
|