@lightprotocol/compressed-token 0.15.4 → 0.17.0

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,5 +1,5 @@
1
1
  import { CompressedProof, ParsedTokenAccount, TokenTransferOutputData as TokenTransferOutputData$1, InputTokenDataWithContext as InputTokenDataWithContext$1, Rpc } from '@lightprotocol/stateless.js';
2
- import { PublicKey, AccountMeta, TransactionInstruction, Signer, ConfirmOptions, TransactionSignature, Keypair } from '@solana/web3.js';
2
+ import { PublicKey, AccountMeta, TransactionInstruction, Connection, Signer, ConfirmOptions, TransactionSignature, Keypair } from '@solana/web3.js';
3
3
  import { BN, Program } from '@coral-xyz/anchor';
4
4
 
5
5
  type LightCompressedToken = {
@@ -86,9 +86,6 @@ type LightCompressedToken = {
86
86
  name: 'tokenPoolPda';
87
87
  isMut: true;
88
88
  isSigner: false;
89
- docs: [
90
- 'account to a token account of a different mint will fail'
91
- ];
92
89
  },
93
90
  {
94
91
  name: 'tokenProgram';
@@ -166,6 +163,11 @@ type LightCompressedToken = {
166
163
  },
167
164
  {
168
165
  name: 'compressSplTokenAccount';
166
+ docs: [
167
+ 'Compresses the balance of an spl token account sub an optional remaining',
168
+ 'amount. This instruction does not close the spl token account. To close',
169
+ 'the account bundle a close spl account instruction in your transaction.'
170
+ ];
169
171
  accounts: [
170
172
  {
171
173
  name: 'feePayer';
@@ -1653,23 +1655,141 @@ type LightCompressedToken = {
1653
1655
  errors: [
1654
1656
  {
1655
1657
  code: 6000;
1656
- name: 'SignerCheckFailed';
1657
- msg: 'Signer check failed';
1658
+ name: 'PublicKeyAmountMissmatch';
1659
+ msg: 'public keys and amounts must be of same length';
1658
1660
  },
1659
1661
  {
1660
1662
  code: 6001;
1661
- name: 'CreateTransferInstructionFailed';
1662
- msg: 'Create transfer instruction failed';
1663
+ name: 'ComputeInputSumFailed';
1664
+ msg: 'ComputeInputSumFailed';
1663
1665
  },
1664
1666
  {
1665
1667
  code: 6002;
1666
- name: 'AccountNotFound';
1667
- msg: 'Account not found';
1668
+ name: 'ComputeOutputSumFailed';
1669
+ msg: 'ComputeOutputSumFailed';
1668
1670
  },
1669
1671
  {
1670
1672
  code: 6003;
1671
- name: 'SerializationError';
1672
- msg: 'Serialization error';
1673
+ name: 'ComputeCompressSumFailed';
1674
+ msg: 'ComputeCompressSumFailed';
1675
+ },
1676
+ {
1677
+ code: 6004;
1678
+ name: 'ComputeDecompressSumFailed';
1679
+ msg: 'ComputeDecompressSumFailed';
1680
+ },
1681
+ {
1682
+ code: 6005;
1683
+ name: 'SumCheckFailed';
1684
+ msg: 'SumCheckFailed';
1685
+ },
1686
+ {
1687
+ code: 6006;
1688
+ name: 'DecompressRecipientUndefinedForDecompress';
1689
+ msg: 'DecompressRecipientUndefinedForDecompress';
1690
+ },
1691
+ {
1692
+ code: 6007;
1693
+ name: 'CompressedPdaUndefinedForDecompress';
1694
+ msg: 'CompressedPdaUndefinedForDecompress';
1695
+ },
1696
+ {
1697
+ code: 6008;
1698
+ name: 'DeCompressAmountUndefinedForDecompress';
1699
+ msg: 'DeCompressAmountUndefinedForDecompress';
1700
+ },
1701
+ {
1702
+ code: 6009;
1703
+ name: 'CompressedPdaUndefinedForCompress';
1704
+ msg: 'CompressedPdaUndefinedForCompress';
1705
+ },
1706
+ {
1707
+ code: 6010;
1708
+ name: 'DeCompressAmountUndefinedForCompress';
1709
+ msg: 'DeCompressAmountUndefinedForCompress';
1710
+ },
1711
+ {
1712
+ code: 6011;
1713
+ name: 'DelegateSignerCheckFailed';
1714
+ msg: 'DelegateSignerCheckFailed';
1715
+ },
1716
+ {
1717
+ code: 6012;
1718
+ name: 'MintTooLarge';
1719
+ msg: 'Minted amount greater than u64::MAX';
1720
+ },
1721
+ {
1722
+ code: 6013;
1723
+ name: 'SplTokenSupplyMismatch';
1724
+ msg: 'SplTokenSupplyMismatch';
1725
+ },
1726
+ {
1727
+ code: 6014;
1728
+ name: 'HeapMemoryCheckFailed';
1729
+ msg: 'HeapMemoryCheckFailed';
1730
+ },
1731
+ {
1732
+ code: 6015;
1733
+ name: 'InstructionNotCallable';
1734
+ msg: 'The instruction is not callable';
1735
+ },
1736
+ {
1737
+ code: 6016;
1738
+ name: 'ArithmeticUnderflow';
1739
+ msg: 'ArithmeticUnderflow';
1740
+ },
1741
+ {
1742
+ code: 6017;
1743
+ name: 'HashToFieldError';
1744
+ msg: 'HashToFieldError';
1745
+ },
1746
+ {
1747
+ code: 6018;
1748
+ name: 'InvalidAuthorityMint';
1749
+ msg: 'Expected the authority to be also a mint authority';
1750
+ },
1751
+ {
1752
+ code: 6019;
1753
+ name: 'InvalidFreezeAuthority';
1754
+ msg: 'Provided authority is not the freeze authority';
1755
+ },
1756
+ {
1757
+ code: 6020;
1758
+ name: 'InvalidDelegateIndex';
1759
+ },
1760
+ {
1761
+ code: 6021;
1762
+ name: 'TokenPoolPdaUndefined';
1763
+ },
1764
+ {
1765
+ code: 6022;
1766
+ name: 'IsTokenPoolPda';
1767
+ msg: 'Compress or decompress recipient is the same account as the token pool pda.';
1768
+ },
1769
+ {
1770
+ code: 6023;
1771
+ name: 'InvalidTokenPoolPda';
1772
+ },
1773
+ {
1774
+ code: 6024;
1775
+ name: 'NoInputTokenAccountsProvided';
1776
+ },
1777
+ {
1778
+ code: 6025;
1779
+ name: 'NoInputsProvided';
1780
+ },
1781
+ {
1782
+ code: 6026;
1783
+ name: 'MintHasNoFreezeAuthority';
1784
+ },
1785
+ {
1786
+ code: 6027;
1787
+ name: 'MintWithInvalidExtension';
1788
+ },
1789
+ {
1790
+ code: 6028;
1791
+ name: 'InsufficientTokenAccountBalance';
1792
+ msg: 'The token account balance is less than the remaining amount.';
1673
1793
  }
1674
1794
  ];
1675
1795
  };
@@ -1871,6 +1991,10 @@ type CompressParams = {
1871
1991
  * public state tree if unspecified.
1872
1992
  */
1873
1993
  outputStateTree?: PublicKey;
1994
+ /**
1995
+ * Optional: The token program ID. Default: SPL Token Program ID
1996
+ */
1997
+ tokenProgramId?: PublicKey;
1874
1998
  };
1875
1999
  type CompressSplTokenAccountParams = {
1876
2000
  /**
@@ -1897,6 +2021,10 @@ type CompressSplTokenAccountParams = {
1897
2021
  * The state tree that the compressed token account should be inserted into.
1898
2022
  */
1899
2023
  outputStateTree: PublicKey;
2024
+ /**
2025
+ * Optional: The token program ID. Default: SPL Token Program ID
2026
+ */
2027
+ tokenProgramId?: PublicKey;
1900
2028
  };
1901
2029
  type DecompressParams = {
1902
2030
  /**
@@ -1930,6 +2058,10 @@ type DecompressParams = {
1930
2058
  * Defaults to a public state tree if unspecified.
1931
2059
  */
1932
2060
  outputStateTree?: PublicKey;
2061
+ /**
2062
+ * Optional: The token program ID. Default: SPL Token Program ID
2063
+ */
2064
+ tokenProgramId?: PublicKey;
1933
2065
  };
1934
2066
  type TransferParams = {
1935
2067
  /**
@@ -1994,6 +2126,14 @@ type CreateMintParams = {
1994
2126
  * lamport amount for mint account rent exemption
1995
2127
  */
1996
2128
  rentExemptBalance: number;
2129
+ /**
2130
+ * Optional: The token program ID. Default: SPL Token Program ID
2131
+ */
2132
+ tokenProgramId?: PublicKey;
2133
+ /**
2134
+ * Optional: Mint size to use, defaults to MINT_SIZE
2135
+ */
2136
+ mintSize?: number;
1997
2137
  };
1998
2138
  /**
1999
2139
  * Parameters for merging compressed token accounts
@@ -2057,6 +2197,10 @@ type MintToParams = {
2057
2197
  * tree if unspecified.
2058
2198
  */
2059
2199
  merkleTree?: PublicKey;
2200
+ /**
2201
+ * Optional: The token program ID. Default: SPL Token Program ID
2202
+ */
2203
+ tokenProgramId?: PublicKey;
2060
2204
  };
2061
2205
  /**
2062
2206
  * Register an existing SPL mint account to the compressed token program
@@ -2067,6 +2211,10 @@ type RegisterMintParams = {
2067
2211
  feePayer: PublicKey;
2068
2212
  /** Mint public key */
2069
2213
  mint: PublicKey;
2214
+ /**
2215
+ * Optional: The token program ID. Default: SPL Token Program ID
2216
+ */
2217
+ tokenProgramId?: PublicKey;
2070
2218
  };
2071
2219
  /**
2072
2220
  * Mint from existing SPL mint to compressed token accounts
@@ -2101,6 +2249,10 @@ type ApproveAndMintToParams = {
2101
2249
  * tree if unspecified.
2102
2250
  */
2103
2251
  merkleTree?: PublicKey;
2252
+ /**
2253
+ * Optional: The token program ID. Default: SPL Token Program ID
2254
+ */
2255
+ tokenProgramId?: PublicKey;
2104
2256
  };
2105
2257
  type CreateTokenProgramLookupTableParams = {
2106
2258
  /**
@@ -2199,7 +2351,7 @@ declare class CompressedTokenProgram {
2199
2351
  */
2200
2352
  static mintTo(params: MintToParams): Promise<TransactionInstruction>;
2201
2353
  /**
2202
- * Mint tokens from registed SPL mint account to a compressed account
2354
+ * Mint tokens from registered SPL mint account to a compressed account
2203
2355
  */
2204
2356
  static approveAndMintTo(params: ApproveAndMintToParams): Promise<TransactionInstruction[]>;
2205
2357
  /**
@@ -2224,6 +2376,7 @@ declare class CompressedTokenProgram {
2224
2376
  static decompress(params: DecompressParams): Promise<TransactionInstruction>;
2225
2377
  static mergeTokenAccounts(params: MergeTokenAccountsParams): Promise<TransactionInstruction[]>;
2226
2378
  static compressSplTokenAccount(params: CompressSplTokenAccountParams): Promise<TransactionInstruction>;
2379
+ static get_mint_program_id(mint: PublicKey, connection: Connection): Promise<PublicKey | undefined>;
2227
2380
  }
2228
2381
 
2229
2382
  /**
@@ -2241,7 +2394,7 @@ declare class CompressedTokenProgram {
2241
2394
  *
2242
2395
  * @return Signature of the confirmed transaction
2243
2396
  */
2244
- declare function approveAndMintTo(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey, authority: Signer, amount: number | BN, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
2397
+ declare function approveAndMintTo(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey, authority: Signer, amount: number | BN, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
2245
2398
 
2246
2399
  /**
2247
2400
  * Compress SPL tokens
@@ -2261,7 +2414,7 @@ declare function approveAndMintTo(rpc: Rpc, payer: Signer, mint: PublicKey, dest
2261
2414
  *
2262
2415
  * @return Signature of the confirmed transaction
2263
2416
  */
2264
- declare function compress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN | number[] | BN[], owner: Signer, sourceTokenAccount: PublicKey, toAddress: PublicKey | Array<PublicKey>, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
2417
+ declare function compress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN | number[] | BN[], owner: Signer, sourceTokenAccount: PublicKey, toAddress: PublicKey | Array<PublicKey>, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
2265
2418
 
2266
2419
  /**
2267
2420
  * Decompress compressed tokens
@@ -2281,7 +2434,7 @@ declare function compress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: numb
2281
2434
  *
2282
2435
  * @return Signature of the confirmed transaction
2283
2436
  */
2284
- declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
2437
+ declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
2285
2438
 
2286
2439
  /**
2287
2440
  * Create and initialize a new compressed token mint
@@ -2292,10 +2445,11 @@ declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: nu
2292
2445
  * @param decimals Location of the decimal place
2293
2446
  * @param keypair Optional keypair, defaulting to a new random one
2294
2447
  * @param confirmOptions Options for confirming the transaction
2448
+ * @param isToken22 Whether to create a Token 2022 mint. Defaults to false.
2295
2449
  *
2296
2450
  * @return Address of the new mint and the transaction signature
2297
2451
  */
2298
- declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: PublicKey, decimals: number, keypair?: Keypair, confirmOptions?: ConfirmOptions): Promise<{
2452
+ declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: PublicKey, decimals: number, keypair?: Keypair, confirmOptions?: ConfirmOptions, isToken22?: boolean): Promise<{
2299
2453
  mint: PublicKey;
2300
2454
  transactionSignature: TransactionSignature;
2301
2455
  }>;
@@ -2317,7 +2471,7 @@ declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: PublicKey, d
2317
2471
  *
2318
2472
  * @return Signature of the confirmed transaction
2319
2473
  */
2320
- declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey | PublicKey[], authority: Signer, amount: number | BN | number[] | BN[], merkleTree?: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
2474
+ declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey | PublicKey[], authority: Signer, amount: number | BN | number[] | BN[], merkleTree?: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
2321
2475
 
2322
2476
  /**
2323
2477
  * Merge multiple compressed token accounts for a given mint into a single
@@ -2345,7 +2499,7 @@ declare function mergeTokenAccounts(rpc: Rpc, payer: Signer, mint: PublicKey, ow
2345
2499
  *
2346
2500
  * @return transaction signature
2347
2501
  */
2348
- declare function createTokenPool(rpc: Rpc, payer: Signer, mintAddress: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
2502
+ declare function createTokenPool(rpc: Rpc, payer: Signer, mint: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
2349
2503
 
2350
2504
  /**
2351
2505
  * Transfer compressed tokens from one owner to another
@@ -2410,6 +2564,6 @@ declare function createTokenProgramLookupTable(rpc: Rpc, payer: Signer, authorit
2410
2564
  *
2411
2565
  * @return Signature of the confirmed transaction
2412
2566
  */
2413
- declare function compressSplTokenAccount(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, tokenAccount: PublicKey, outputStateTree: PublicKey, remainingAmount?: BN, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
2567
+ declare function compressSplTokenAccount(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, tokenAccount: PublicKey, outputStateTree: PublicKey, remainingAmount?: BN, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
2414
2568
 
2415
2569
  export { type ApproveAndMintToParams, CPI_AUTHORITY_SEED, type CompressParams, type CompressSplTokenAccountParams, type CompressedTokenInstructionDataInvoke, CompressedTokenProgram, type CreateMintParams, type CreateTokenProgramLookupTableParams, type DecompressParams, IDL, type InputTokenDataWithContext, type LightCompressedToken, type MergeTokenAccountsParams, type MintToParams, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedTokenTransferOutputData, type RegisterMintParams, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, type TokenData, type TokenTransferOutputData, type TransferParams, approveAndMintTo, compress, compressSplTokenAccount, createDecompressOutputState, createMint, createTokenPool, createTokenProgramLookupTable, createTransferOutputState, decompress, mergeTokenAccounts, mintTo, packCompressedTokenAccounts, parseTokenData, selectMinCompressedTokenAccountsForTransfer, sumUpTokenAmount, transfer, validateSameTokenOwner };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightprotocol/compressed-token",
3
- "version": "0.15.4",
3
+ "version": "0.17.0",
4
4
  "description": "JS client to interact with the compressed-token program",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/node/index.cjs",
@@ -36,14 +36,14 @@
36
36
  ],
37
37
  "license": "Apache-2.0",
38
38
  "peerDependencies": {
39
- "@lightprotocol/stateless.js": "0.15.4"
39
+ "@lightprotocol/stateless.js": "0.17.0"
40
40
  },
41
41
  "dependencies": {
42
42
  "@coral-xyz/anchor": "0.29.0",
43
- "@solana/web3.js": "^1.95.3",
44
- "@solana/spl-token": "^0.4.8",
45
- "buffer": "^6.0.3",
46
- "tweetnacl": "^1.0.3"
43
+ "@solana/web3.js": "1.95.3",
44
+ "@solana/spl-token": "0.4.8",
45
+ "buffer": "6.0.3",
46
+ "tweetnacl": "1.0.3"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@esbuild-plugins/node-globals-polyfill": "^0.2.3",