@lightprotocol/compressed-token 0.20.2 → 0.20.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.
@@ -732,18 +732,6 @@ declare function createTokenPool(rpc: Rpc, payer: Signer, mint: PublicKey, confi
732
732
  * @return Signature of the confirmed transaction
733
733
  */
734
734
  declare function transfer(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
735
- /**
736
- * Selects the minimal number of compressed token accounts for a transfer.
737
- *
738
- * 1. Sorts the accounts by amount in descending order
739
- * 2. Accumulates the amount until it is greater than or equal to the transfer
740
- * amount
741
- */
742
- declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN): [
743
- selectedAccounts: ParsedTokenAccount[],
744
- total: BN,
745
- totalLamports: BN | null
746
- ];
747
735
 
748
736
  /**
749
737
  * Create a lookup table for the token program's default accounts
@@ -2572,4 +2560,57 @@ type LightCompressedToken = {
2572
2560
  };
2573
2561
  declare const IDL: LightCompressedToken;
2574
2562
 
2575
- export { type ApproveAndMintToParams, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type CompressedCpiContext, type CompressedTokenInstructionDataTransfer, CompressedTokenInstructionDataTransferLayout, CompressedTokenProgram, CpiContextLayout, type CreateMintParams, type CreateTokenProgramLookupTableParams, type DecompressParams, type DelegatedTransfer, DelegatedTransferLayout, IDL, type InputTokenDataWithContext, type LightCompressedToken, MINT_TO_DISCRIMINATOR, type MergeTokenAccountsParams, type MintToInstructionData, type MintToParams, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedTokenTransferOutputData, type RegisterMintParams, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, TRANSFER_DISCRIMINATOR, type TokenData, type TokenTransferOutputData, type TransferParams, type approveAccountsLayoutParams, approveAndMintTo, compress, compressSplTokenAccount, compressSplTokenAccountInstructionDataLayout, createDecompressOutputState, createMint, createTokenPool, createTokenPoolAccountsLayout, type createTokenPoolAccountsLayoutParams, createTokenProgramLookupTable, createTransferOutputState, decodeCompressSplTokenAccountInstructionData, decodeMintToInstructionData, decodeTransferInstructionData, decompress, encodeCompressSplTokenAccountInstructionData, encodeMintToInstructionData, encodeTransferInstructionData, type freezeAccountsLayoutParams, mergeTokenAccounts, mintTo, mintToAccountsLayout, type mintToAccountsLayoutParams, mintToLayout, packCompressedTokenAccounts, parseTokenData, type revokeAccountsLayoutParams, selectMinCompressedTokenAccountsForTransfer, sumUpTokenAmount, type thawAccountsLayoutParams, transfer, transferAccountsLayout, type transferAccountsLayoutParams, validateSameTokenOwner };
2563
+ declare const ERROR_NO_ACCOUNTS_FOUND = "Could not find accounts to select for transfer.";
2564
+ /**
2565
+ * Selects the minimal number of compressed token accounts for a transfer.
2566
+ *
2567
+ * 1. Sorts accounts by amount (descending)
2568
+ * 2. Accumulates amount until it meets or exceeds transfer amount
2569
+ */
2570
+ declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
2571
+ selectedAccounts: ParsedTokenAccount[],
2572
+ total: BN,
2573
+ totalLamports: BN | null,
2574
+ maxPossibleAmount: BN
2575
+ ];
2576
+ /**
2577
+ * Selects the minimal number of compressed token accounts for a transfer idempotently.
2578
+ *
2579
+ * 1. Sorts accounts by amount (descending)
2580
+ * 2. Accumulates amount until it meets or exceeds transfer amount
2581
+ */
2582
+ declare function selectMinCompressedTokenAccountsForTransferIdempotent(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
2583
+ selectedAccounts: ParsedTokenAccount[],
2584
+ total: BN,
2585
+ totalLamports: BN | null,
2586
+ maxPossibleAmount: BN
2587
+ ];
2588
+ /**
2589
+ * Selects compressed token accounts for a transfer, ensuring one extra account
2590
+ * if possible, up to maxInputs.
2591
+ *
2592
+ * 1. Sorts accounts by amount (desc)
2593
+ * 2. Selects accounts until transfer amount is met or cap is reached
2594
+ */
2595
+ declare function selectSmartCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
2596
+ selectedAccounts: ParsedTokenAccount[],
2597
+ total: BN,
2598
+ totalLamports: BN | null,
2599
+ maxPossibleAmount: BN
2600
+ ];
2601
+ /**
2602
+ * Idempotently selects compressed token accounts for a transfer. Picks one more
2603
+ * account than needed, up to maxInputs, with the extra being the smallest.
2604
+ *
2605
+ * 1. Sorts accounts by amount (desc)
2606
+ * 2. Selects accounts until transfer amount is met, then adds the smallest
2607
+ * extra account if possible
2608
+ */
2609
+ declare function selectSmartCompressedTokenAccountsForTransferIdempotent(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
2610
+ selectedAccounts: ParsedTokenAccount[],
2611
+ total: BN,
2612
+ totalLamports: BN | null,
2613
+ maxPossibleAmount: BN
2614
+ ];
2615
+
2616
+ export { type ApproveAndMintToParams, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type CompressedCpiContext, type CompressedTokenInstructionDataTransfer, CompressedTokenInstructionDataTransferLayout, CompressedTokenProgram, CpiContextLayout, type CreateMintParams, type CreateTokenProgramLookupTableParams, type DecompressParams, type DelegatedTransfer, DelegatedTransferLayout, ERROR_NO_ACCOUNTS_FOUND, IDL, type InputTokenDataWithContext, type LightCompressedToken, MINT_TO_DISCRIMINATOR, type MergeTokenAccountsParams, type MintToInstructionData, type MintToParams, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedTokenTransferOutputData, type RegisterMintParams, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, TRANSFER_DISCRIMINATOR, type TokenData, type TokenTransferOutputData, type TransferParams, type approveAccountsLayoutParams, approveAndMintTo, compress, compressSplTokenAccount, compressSplTokenAccountInstructionDataLayout, createDecompressOutputState, createMint, createTokenPool, createTokenPoolAccountsLayout, type createTokenPoolAccountsLayoutParams, createTokenProgramLookupTable, createTransferOutputState, decodeCompressSplTokenAccountInstructionData, decodeMintToInstructionData, decodeTransferInstructionData, decompress, encodeCompressSplTokenAccountInstructionData, encodeMintToInstructionData, encodeTransferInstructionData, type freezeAccountsLayoutParams, mergeTokenAccounts, mintTo, mintToAccountsLayout, type mintToAccountsLayoutParams, mintToLayout, packCompressedTokenAccounts, parseTokenData, type revokeAccountsLayoutParams, selectMinCompressedTokenAccountsForTransfer, selectMinCompressedTokenAccountsForTransferIdempotent, selectSmartCompressedTokenAccountsForTransfer, selectSmartCompressedTokenAccountsForTransferIdempotent, sumUpTokenAmount, type thawAccountsLayoutParams, transfer, transferAccountsLayout, type transferAccountsLayoutParams, validateSameTokenOwner };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightprotocol/compressed-token",
3
- "version": "0.20.2",
3
+ "version": "0.20.4",
4
4
  "description": "JS client to interact with the compressed-token program",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/node/index.cjs",
@@ -31,7 +31,7 @@
31
31
  "peerDependencies": {
32
32
  "@solana/spl-token": ">=0.3.9",
33
33
  "@solana/web3.js": ">=1.73.5",
34
- "@lightprotocol/stateless.js": "0.20.2"
34
+ "@lightprotocol/stateless.js": "0.20.4"
35
35
  },
36
36
  "dependencies": {
37
37
  "@coral-xyz/borsh": "^0.29.0",
@@ -102,6 +102,7 @@
102
102
  "test-validator": "./../../cli/test_bin/run test-validator --prover-run-mode rpc",
103
103
  "test:e2e:create-mint": "pnpm test-validator && NODE_OPTIONS='--trace-deprecation' vitest run tests/e2e/create-mint.test.ts --reporter=verbose",
104
104
  "test:e2e:layout": "vitest run tests/e2e/layout.test.ts --reporter=verbose",
105
+ "test:e2e:select-accounts": "vitest run tests/e2e/select-accounts.test.ts --reporter=verbose",
105
106
  "test:e2e:create-token-pool": "pnpm test-validator && vitest run tests/e2e/create-token-pool.test.ts",
106
107
  "test:e2e:mint-to": "pnpm test-validator && vitest run tests/e2e/mint-to.test.ts --reporter=verbose",
107
108
  "test:e2e:approve-and-mint-to": "pnpm test-validator && vitest run tests/e2e/approve-and-mint-to.test.ts --reporter=verbose",
@@ -112,7 +113,7 @@
112
113
  "test:e2e:decompress": "pnpm test-validator && vitest run tests/e2e/decompress.test.ts --reporter=verbose",
113
114
  "test:e2e:rpc-token-interop": "pnpm test-validator && vitest run tests/e2e/rpc-token-interop.test.ts --reporter=verbose",
114
115
  "test:e2e:rpc-multi-trees": "pnpm test-validator && vitest run tests/e2e/rpc-multi-trees.test.ts --reporter=verbose",
115
- "test:e2e:all": "pnpm test-validator && vitest run tests/e2e/create-mint.test.ts && vitest run tests/e2e/mint-to.test.ts && vitest run tests/e2e/transfer.test.ts && vitest run tests/e2e/compress.test.ts && vitest run tests/e2e/compress-spl-token-account.test.ts && vitest run tests/e2e/decompress.test.ts && vitest run tests/e2e/create-token-pool.test.ts && vitest run tests/e2e/approve-and-mint-to.test.ts && vitest run tests/e2e/rpc-token-interop.test.ts && vitest run tests/e2e/rpc-multi-trees.test.ts && vitest run tests/e2e/layout.test.ts",
116
+ "test:e2e:all": "pnpm test-validator && vitest run tests/e2e/create-mint.test.ts && vitest run tests/e2e/mint-to.test.ts && vitest run tests/e2e/transfer.test.ts && vitest run tests/e2e/compress.test.ts && vitest run tests/e2e/compress-spl-token-account.test.ts && vitest run tests/e2e/decompress.test.ts && vitest run tests/e2e/create-token-pool.test.ts && vitest run tests/e2e/approve-and-mint-to.test.ts && vitest run tests/e2e/rpc-token-interop.test.ts && vitest run tests/e2e/rpc-multi-trees.test.ts && vitest run tests/e2e/layout.test.ts && vitest run tests/e2e/select-accounts.test.ts",
116
117
  "pull-idl": "../../scripts/push-compressed-token-idl.sh",
117
118
  "build": "rimraf dist && pnpm build:bundle",
118
119
  "build:bundle": "rollup -c",