@lightprotocol/compressed-token 0.1.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.
@@ -0,0 +1,1270 @@
1
+ import { ParsedTokenAccount, InputTokenDataWithContext as InputTokenDataWithContext$1, CompressedProof, TokenTransferOutputData as TokenTransferOutputData$1, Rpc } from '@lightprotocol/stateless.js';
2
+ import { PublicKey, AccountMeta, TransactionInstruction, Signer, ConfirmOptions, TransactionSignature, Keypair } from '@solana/web3.js';
3
+ import { BN, Program } from '@coral-xyz/anchor';
4
+
5
+ type LightCompressedToken = {
6
+ version: '0.3.0';
7
+ name: 'light_compressed_token';
8
+ constants: [
9
+ {
10
+ name: 'PROGRAM_ID';
11
+ type: 'string';
12
+ value: '"9sixVEthz2kMSKfeApZXHwuboT6DZuT6crAYJTciUCqE"';
13
+ }
14
+ ];
15
+ instructions: [
16
+ {
17
+ name: 'createMint';
18
+ docs: [
19
+ 'This instruction expects a mint account to be created in a separate token program instruction',
20
+ 'with token authority as mint authority.',
21
+ 'This instruction creates a token pool account for that mint owned by token authority.'
22
+ ];
23
+ accounts: [
24
+ {
25
+ name: 'feePayer';
26
+ isMut: true;
27
+ isSigner: true;
28
+ },
29
+ {
30
+ name: 'authority';
31
+ isMut: true;
32
+ isSigner: true;
33
+ },
34
+ {
35
+ name: 'tokenPoolPda';
36
+ isMut: true;
37
+ isSigner: false;
38
+ },
39
+ {
40
+ name: 'systemProgram';
41
+ isMut: false;
42
+ isSigner: false;
43
+ },
44
+ {
45
+ name: 'mint';
46
+ isMut: true;
47
+ isSigner: false;
48
+ },
49
+ {
50
+ name: 'mintAuthorityPda';
51
+ isMut: true;
52
+ isSigner: false;
53
+ },
54
+ {
55
+ name: 'tokenProgram';
56
+ isMut: false;
57
+ isSigner: false;
58
+ },
59
+ {
60
+ name: 'cpiAuthorityPda';
61
+ isMut: false;
62
+ isSigner: false;
63
+ }
64
+ ];
65
+ args: [];
66
+ },
67
+ {
68
+ name: 'mintTo';
69
+ accounts: [
70
+ {
71
+ name: 'feePayer';
72
+ isMut: true;
73
+ isSigner: true;
74
+ },
75
+ {
76
+ name: 'authority';
77
+ isMut: true;
78
+ isSigner: true;
79
+ },
80
+ {
81
+ name: 'mintAuthorityPda';
82
+ isMut: true;
83
+ isSigner: false;
84
+ },
85
+ {
86
+ name: 'mint';
87
+ isMut: true;
88
+ isSigner: false;
89
+ },
90
+ {
91
+ name: 'tokenPoolPda';
92
+ isMut: true;
93
+ isSigner: false;
94
+ },
95
+ {
96
+ name: 'tokenProgram';
97
+ isMut: false;
98
+ isSigner: false;
99
+ },
100
+ {
101
+ name: 'compressedPdaProgram';
102
+ isMut: false;
103
+ isSigner: false;
104
+ },
105
+ {
106
+ name: 'registeredProgramPda';
107
+ isMut: true;
108
+ isSigner: false;
109
+ },
110
+ {
111
+ name: 'noopProgram';
112
+ isMut: false;
113
+ isSigner: false;
114
+ },
115
+ {
116
+ name: 'accountCompressionAuthority';
117
+ isMut: true;
118
+ isSigner: false;
119
+ },
120
+ {
121
+ name: 'accountCompressionProgram';
122
+ isMut: false;
123
+ isSigner: false;
124
+ },
125
+ {
126
+ name: 'merkleTree';
127
+ isMut: true;
128
+ isSigner: false;
129
+ },
130
+ {
131
+ name: 'selfProgram';
132
+ isMut: false;
133
+ isSigner: false;
134
+ }
135
+ ];
136
+ args: [
137
+ {
138
+ name: 'publicKeys';
139
+ type: {
140
+ vec: 'publicKey';
141
+ };
142
+ },
143
+ {
144
+ name: 'amounts';
145
+ type: {
146
+ vec: 'u64';
147
+ };
148
+ }
149
+ ];
150
+ },
151
+ {
152
+ name: 'transfer';
153
+ accounts: [
154
+ {
155
+ name: 'feePayer';
156
+ isMut: false;
157
+ isSigner: true;
158
+ },
159
+ {
160
+ name: 'authority';
161
+ isMut: false;
162
+ isSigner: true;
163
+ },
164
+ {
165
+ name: 'cpiAuthorityPda';
166
+ isMut: false;
167
+ isSigner: false;
168
+ },
169
+ {
170
+ name: 'compressedPdaProgram';
171
+ isMut: false;
172
+ isSigner: false;
173
+ },
174
+ {
175
+ name: 'registeredProgramPda';
176
+ isMut: false;
177
+ isSigner: false;
178
+ },
179
+ {
180
+ name: 'noopProgram';
181
+ isMut: false;
182
+ isSigner: false;
183
+ },
184
+ {
185
+ name: 'accountCompressionAuthority';
186
+ isMut: false;
187
+ isSigner: false;
188
+ },
189
+ {
190
+ name: 'accountCompressionProgram';
191
+ isMut: false;
192
+ isSigner: false;
193
+ },
194
+ {
195
+ name: 'selfProgram';
196
+ isMut: false;
197
+ isSigner: false;
198
+ },
199
+ {
200
+ name: 'tokenPoolPda';
201
+ isMut: true;
202
+ isSigner: false;
203
+ isOptional: true;
204
+ },
205
+ {
206
+ name: 'decompressTokenAccount';
207
+ isMut: true;
208
+ isSigner: false;
209
+ isOptional: true;
210
+ },
211
+ {
212
+ name: 'tokenProgram';
213
+ isMut: false;
214
+ isSigner: false;
215
+ isOptional: true;
216
+ }
217
+ ];
218
+ args: [
219
+ {
220
+ name: 'inputs';
221
+ type: 'bytes';
222
+ },
223
+ {
224
+ name: 'cpiContext';
225
+ type: {
226
+ option: {
227
+ defined: 'CompressedCpiContext';
228
+ };
229
+ };
230
+ }
231
+ ];
232
+ }
233
+ ];
234
+ types: [
235
+ {
236
+ name: 'CompressedAccountWithMerkleContext';
237
+ type: {
238
+ kind: 'struct';
239
+ fields: [
240
+ {
241
+ name: 'compressedAccount';
242
+ type: {
243
+ defined: 'CompressedAccount';
244
+ };
245
+ },
246
+ {
247
+ name: 'merkleTreePubkeyIndex';
248
+ type: 'u8';
249
+ },
250
+ {
251
+ name: 'nullifierQueuePubkeyIndex';
252
+ type: 'u8';
253
+ },
254
+ {
255
+ name: 'leafIndex';
256
+ type: 'u32';
257
+ }
258
+ ];
259
+ };
260
+ },
261
+ {
262
+ name: 'MerkleContext';
263
+ type: {
264
+ kind: 'struct';
265
+ fields: [
266
+ {
267
+ name: 'merkleTreePubkey';
268
+ type: 'publicKey';
269
+ },
270
+ {
271
+ name: 'nullifierQueuePubkey';
272
+ type: 'publicKey';
273
+ },
274
+ {
275
+ name: 'leafIndex';
276
+ type: 'u32';
277
+ }
278
+ ];
279
+ };
280
+ },
281
+ {
282
+ name: 'PackedMerkleContext';
283
+ type: {
284
+ kind: 'struct';
285
+ fields: [
286
+ {
287
+ name: 'merkleTreePubkeyIndex';
288
+ type: 'u8';
289
+ },
290
+ {
291
+ name: 'nullifierQueuePubkeyIndex';
292
+ type: 'u8';
293
+ },
294
+ {
295
+ name: 'leafIndex';
296
+ type: 'u32';
297
+ }
298
+ ];
299
+ };
300
+ },
301
+ {
302
+ name: 'CompressedAccount';
303
+ type: {
304
+ kind: 'struct';
305
+ fields: [
306
+ {
307
+ name: 'owner';
308
+ type: 'publicKey';
309
+ },
310
+ {
311
+ name: 'lamports';
312
+ type: 'u64';
313
+ },
314
+ {
315
+ name: 'address';
316
+ type: {
317
+ option: {
318
+ array: ['u8', 32];
319
+ };
320
+ };
321
+ },
322
+ {
323
+ name: 'data';
324
+ type: {
325
+ option: {
326
+ defined: 'CompressedAccountData';
327
+ };
328
+ };
329
+ }
330
+ ];
331
+ };
332
+ },
333
+ {
334
+ name: 'CompressedAccountData';
335
+ type: {
336
+ kind: 'struct';
337
+ fields: [
338
+ {
339
+ name: 'discriminator';
340
+ type: {
341
+ array: ['u8', 8];
342
+ };
343
+ },
344
+ {
345
+ name: 'data';
346
+ type: 'bytes';
347
+ },
348
+ {
349
+ name: 'dataHash';
350
+ type: {
351
+ array: ['u8', 32];
352
+ };
353
+ }
354
+ ];
355
+ };
356
+ },
357
+ {
358
+ name: 'CompressedCpiContext';
359
+ docs: ['To spend multiple compressed'];
360
+ type: {
361
+ kind: 'struct';
362
+ fields: [
363
+ {
364
+ name: 'cpiSignatureAccountIndex';
365
+ docs: [
366
+ 'index of the output state Merkle tree that will be used to store cpi signatures',
367
+ 'The transaction will fail if this index is not consistent in your transaction.'
368
+ ];
369
+ type: 'u8';
370
+ },
371
+ {
372
+ name: 'execute';
373
+ docs: [
374
+ 'The final cpi of your program needs to set execute to true.',
375
+ 'Execute compressed transaction will verify the proof and execute the transaction if this is true.',
376
+ 'If this is false the transaction will be stored in the cpi signature account.'
377
+ ];
378
+ type: 'bool';
379
+ }
380
+ ];
381
+ };
382
+ },
383
+ {
384
+ name: 'PublicTransactionEvent';
385
+ type: {
386
+ kind: 'struct';
387
+ fields: [
388
+ {
389
+ name: 'inputCompressedAccountHashes';
390
+ type: {
391
+ vec: {
392
+ array: ['u8', 32];
393
+ };
394
+ };
395
+ },
396
+ {
397
+ name: 'outputCompressedAccountHashes';
398
+ type: {
399
+ vec: {
400
+ array: ['u8', 32];
401
+ };
402
+ };
403
+ },
404
+ {
405
+ name: 'inputCompressedAccounts';
406
+ type: {
407
+ vec: {
408
+ defined: 'CompressedAccountWithMerkleContext';
409
+ };
410
+ };
411
+ },
412
+ {
413
+ name: 'outputCompressedAccounts';
414
+ type: {
415
+ vec: {
416
+ defined: 'CompressedAccount';
417
+ };
418
+ };
419
+ },
420
+ {
421
+ name: 'outputStateMerkleTreeAccountIndices';
422
+ type: 'bytes';
423
+ },
424
+ {
425
+ name: 'outputLeafIndices';
426
+ type: {
427
+ vec: 'u32';
428
+ };
429
+ },
430
+ {
431
+ name: 'relayFee';
432
+ type: {
433
+ option: 'u64';
434
+ };
435
+ },
436
+ {
437
+ name: 'isCompress';
438
+ type: 'bool';
439
+ },
440
+ {
441
+ name: 'compressionLamports';
442
+ type: {
443
+ option: 'u64';
444
+ };
445
+ },
446
+ {
447
+ name: 'pubkeyArray';
448
+ type: {
449
+ vec: 'publicKey';
450
+ };
451
+ },
452
+ {
453
+ name: 'message';
454
+ type: {
455
+ option: 'bytes';
456
+ };
457
+ }
458
+ ];
459
+ };
460
+ },
461
+ {
462
+ name: 'InstructionDataTransfer';
463
+ type: {
464
+ kind: 'struct';
465
+ fields: [
466
+ {
467
+ name: 'proof';
468
+ type: {
469
+ option: {
470
+ defined: 'CompressedProof';
471
+ };
472
+ };
473
+ },
474
+ {
475
+ name: 'newAddressParams';
476
+ type: {
477
+ vec: {
478
+ defined: 'NewAddressParamsPacked';
479
+ };
480
+ };
481
+ },
482
+ {
483
+ name: 'inputRootIndices';
484
+ type: {
485
+ vec: 'u16';
486
+ };
487
+ },
488
+ {
489
+ name: 'inputCompressedAccountsWithMerkleContext';
490
+ type: {
491
+ vec: {
492
+ defined: 'CompressedAccountWithMerkleContext';
493
+ };
494
+ };
495
+ },
496
+ {
497
+ name: 'outputCompressedAccounts';
498
+ type: {
499
+ vec: {
500
+ defined: 'CompressedAccount';
501
+ };
502
+ };
503
+ },
504
+ {
505
+ name: 'outputStateMerkleTreeAccountIndices';
506
+ docs: [
507
+ 'The indices of the accounts in the output state merkle tree.'
508
+ ];
509
+ type: 'bytes';
510
+ },
511
+ {
512
+ name: 'relayFee';
513
+ type: {
514
+ option: 'u64';
515
+ };
516
+ },
517
+ {
518
+ name: 'compressionLamports';
519
+ type: {
520
+ option: 'u64';
521
+ };
522
+ },
523
+ {
524
+ name: 'isCompress';
525
+ type: 'bool';
526
+ },
527
+ {
528
+ name: 'signerSeeds';
529
+ type: {
530
+ option: {
531
+ vec: 'bytes';
532
+ };
533
+ };
534
+ }
535
+ ];
536
+ };
537
+ },
538
+ {
539
+ name: 'NewAddressParamsPacked';
540
+ type: {
541
+ kind: 'struct';
542
+ fields: [
543
+ {
544
+ name: 'seed';
545
+ type: {
546
+ array: ['u8', 32];
547
+ };
548
+ },
549
+ {
550
+ name: 'addressQueueAccountIndex';
551
+ type: 'u8';
552
+ },
553
+ {
554
+ name: 'addressMerkleTreeAccountIndex';
555
+ type: 'u8';
556
+ },
557
+ {
558
+ name: 'addressMerkleTreeRootIndex';
559
+ type: 'u16';
560
+ }
561
+ ];
562
+ };
563
+ },
564
+ {
565
+ name: 'NewAddressParams';
566
+ type: {
567
+ kind: 'struct';
568
+ fields: [
569
+ {
570
+ name: 'seed';
571
+ type: {
572
+ array: ['u8', 32];
573
+ };
574
+ },
575
+ {
576
+ name: 'addressQueuePubkey';
577
+ type: 'publicKey';
578
+ },
579
+ {
580
+ name: 'addressMerkleTreePubkey';
581
+ type: 'publicKey';
582
+ },
583
+ {
584
+ name: 'addressMerkleTreeRootIndex';
585
+ type: 'u16';
586
+ }
587
+ ];
588
+ };
589
+ },
590
+ {
591
+ name: 'CompressedProof';
592
+ type: {
593
+ kind: 'struct';
594
+ fields: [
595
+ {
596
+ name: 'a';
597
+ type: {
598
+ array: ['u8', 32];
599
+ };
600
+ },
601
+ {
602
+ name: 'b';
603
+ type: {
604
+ array: ['u8', 64];
605
+ };
606
+ },
607
+ {
608
+ name: 'c';
609
+ type: {
610
+ array: ['u8', 32];
611
+ };
612
+ }
613
+ ];
614
+ };
615
+ },
616
+ {
617
+ name: 'InputTokenDataWithContext';
618
+ type: {
619
+ kind: 'struct';
620
+ fields: [
621
+ {
622
+ name: 'amount';
623
+ type: 'u64';
624
+ },
625
+ {
626
+ name: 'delegateIndex';
627
+ type: {
628
+ option: 'u8';
629
+ };
630
+ },
631
+ {
632
+ name: 'delegatedAmount';
633
+ type: {
634
+ option: 'u64';
635
+ };
636
+ },
637
+ {
638
+ name: 'isNative';
639
+ type: {
640
+ option: 'u64';
641
+ };
642
+ },
643
+ {
644
+ name: 'merkleTreePubkeyIndex';
645
+ type: 'u8';
646
+ },
647
+ {
648
+ name: 'nullifierQueuePubkeyIndex';
649
+ type: 'u8';
650
+ },
651
+ {
652
+ name: 'leafIndex';
653
+ type: 'u32';
654
+ }
655
+ ];
656
+ };
657
+ },
658
+ {
659
+ name: 'CompressedTokenInstructionDataTransfer';
660
+ type: {
661
+ kind: 'struct';
662
+ fields: [
663
+ {
664
+ name: 'proof';
665
+ type: {
666
+ option: {
667
+ defined: 'CompressedProof';
668
+ };
669
+ };
670
+ },
671
+ {
672
+ name: 'rootIndices';
673
+ type: {
674
+ vec: 'u16';
675
+ };
676
+ },
677
+ {
678
+ name: 'mint';
679
+ type: 'publicKey';
680
+ },
681
+ {
682
+ name: 'signerIsDelegate';
683
+ type: 'bool';
684
+ },
685
+ {
686
+ name: 'inputTokenDataWithContext';
687
+ type: {
688
+ vec: {
689
+ defined: 'InputTokenDataWithContext';
690
+ };
691
+ };
692
+ },
693
+ {
694
+ name: 'outputCompressedAccounts';
695
+ type: {
696
+ vec: {
697
+ defined: 'TokenTransferOutputData';
698
+ };
699
+ };
700
+ },
701
+ {
702
+ name: 'outputStateMerkleTreeAccountIndices';
703
+ type: 'bytes';
704
+ },
705
+ {
706
+ name: 'isCompress';
707
+ type: 'bool';
708
+ },
709
+ {
710
+ name: 'compressionAmount';
711
+ type: {
712
+ option: 'u64';
713
+ };
714
+ }
715
+ ];
716
+ };
717
+ },
718
+ {
719
+ name: 'TokenTransferOutputData';
720
+ type: {
721
+ kind: 'struct';
722
+ fields: [
723
+ {
724
+ name: 'owner';
725
+ type: 'publicKey';
726
+ },
727
+ {
728
+ name: 'amount';
729
+ type: 'u64';
730
+ },
731
+ {
732
+ name: 'lamports';
733
+ type: {
734
+ option: 'u64';
735
+ };
736
+ }
737
+ ];
738
+ };
739
+ },
740
+ {
741
+ name: 'TokenData';
742
+ type: {
743
+ kind: 'struct';
744
+ fields: [
745
+ {
746
+ name: 'mint';
747
+ docs: ['The mint associated with this account'];
748
+ type: 'publicKey';
749
+ },
750
+ {
751
+ name: 'owner';
752
+ docs: ['The owner of this account.'];
753
+ type: 'publicKey';
754
+ },
755
+ {
756
+ name: 'amount';
757
+ docs: ['The amount of tokens this account holds.'];
758
+ type: 'u64';
759
+ },
760
+ {
761
+ name: 'delegate';
762
+ docs: [
763
+ 'If `delegate` is `Some` then `delegated_amount` represents',
764
+ 'the amount authorized by the delegate'
765
+ ];
766
+ type: {
767
+ option: 'publicKey';
768
+ };
769
+ },
770
+ {
771
+ name: 'state';
772
+ docs: ["The account's state"];
773
+ type: {
774
+ defined: 'AccountState';
775
+ };
776
+ },
777
+ {
778
+ name: 'isNative';
779
+ docs: [
780
+ 'If is_some, this is a native token, and the value logs the rent-exempt',
781
+ 'reserve. An Account is required to be rent-exempt, so the value is',
782
+ 'used by the Processor to ensure that wrapped SOL accounts do not',
783
+ 'drop below this threshold.'
784
+ ];
785
+ type: {
786
+ option: 'u64';
787
+ };
788
+ },
789
+ {
790
+ name: 'delegatedAmount';
791
+ docs: ['The amount delegated'];
792
+ type: 'u64';
793
+ }
794
+ ];
795
+ };
796
+ },
797
+ {
798
+ name: 'TokenDataClient';
799
+ type: {
800
+ kind: 'struct';
801
+ fields: [
802
+ {
803
+ name: 'mint';
804
+ docs: ['The mint associated with this account'];
805
+ type: 'publicKey';
806
+ },
807
+ {
808
+ name: 'owner';
809
+ docs: ['The owner of this account.'];
810
+ type: 'publicKey';
811
+ },
812
+ {
813
+ name: 'amount';
814
+ docs: ['The amount of tokens this account holds.'];
815
+ type: 'u64';
816
+ },
817
+ {
818
+ name: 'delegate';
819
+ docs: [
820
+ 'If `delegate` is `Some` then `delegated_amount` represents',
821
+ 'the amount authorized by the delegate'
822
+ ];
823
+ type: {
824
+ option: 'publicKey';
825
+ };
826
+ },
827
+ {
828
+ name: 'state';
829
+ docs: ["The account's state"];
830
+ type: 'u8';
831
+ },
832
+ {
833
+ name: 'isNative';
834
+ docs: [
835
+ 'If is_some, this is a native token, and the value logs the rent-exempt',
836
+ 'reserve. An Account is required to be rent-exempt, so the value is',
837
+ 'used by the Processor to ensure that wrapped SOL accounts do not',
838
+ 'drop below this threshold.'
839
+ ];
840
+ type: {
841
+ option: 'u64';
842
+ };
843
+ },
844
+ {
845
+ name: 'delegatedAmount';
846
+ docs: ['The amount delegated'];
847
+ type: 'u64';
848
+ }
849
+ ];
850
+ };
851
+ },
852
+ {
853
+ name: 'AccountState';
854
+ type: {
855
+ kind: 'enum';
856
+ variants: [
857
+ {
858
+ name: 'Uninitialized';
859
+ },
860
+ {
861
+ name: 'Initialized';
862
+ },
863
+ {
864
+ name: 'Frozen';
865
+ }
866
+ ];
867
+ };
868
+ },
869
+ {
870
+ name: 'ErrorCode';
871
+ type: {
872
+ kind: 'enum';
873
+ variants: [
874
+ {
875
+ name: 'PublicKeyAmountMissmatch';
876
+ },
877
+ {
878
+ name: 'MissingNewAuthorityPda';
879
+ },
880
+ {
881
+ name: 'SignerCheckFailed';
882
+ },
883
+ {
884
+ name: 'MintCheckFailed';
885
+ },
886
+ {
887
+ name: 'ComputeInputSumFailed';
888
+ },
889
+ {
890
+ name: 'ComputeOutputSumFailed';
891
+ },
892
+ {
893
+ name: 'ComputeCompressSumFailed';
894
+ },
895
+ {
896
+ name: 'ComputeDecompressSumFailed';
897
+ },
898
+ {
899
+ name: 'SumCheckFailed';
900
+ },
901
+ {
902
+ name: 'DecompressRecipientUndefinedForDecompress';
903
+ },
904
+ {
905
+ name: 'CompressedPdaUndefinedForDecompress';
906
+ },
907
+ {
908
+ name: 'DeCompressAmountUndefinedForDecompress';
909
+ },
910
+ {
911
+ name: 'CompressedPdaUndefinedForCompress';
912
+ },
913
+ {
914
+ name: 'DeCompressAmountUndefinedForCompress';
915
+ },
916
+ {
917
+ name: 'DelegateUndefined';
918
+ }
919
+ ];
920
+ };
921
+ }
922
+ ];
923
+ errors: [
924
+ {
925
+ code: 6000;
926
+ name: 'SignerCheckFailed';
927
+ msg: 'Signer check failed';
928
+ },
929
+ {
930
+ code: 6001;
931
+ name: 'CreateTransferInstructionFailed';
932
+ msg: 'Create transfer instruction failed';
933
+ }
934
+ ];
935
+ };
936
+ declare const IDL: LightCompressedToken;
937
+
938
+ type PackCompressedTokenAccountsParams = {
939
+ /** Input state to be consumed */
940
+ inputCompressedTokenAccounts: ParsedTokenAccount[];
941
+ /** Length of output compressed accounts */
942
+ outputCompressedAccountsLength: number;
943
+ /**
944
+ * State trees that the output should be inserted into. Defaults to the 0th
945
+ * state tree of the input state. Gets padded to the length of
946
+ * outputCompressedAccounts.
947
+ */
948
+ outputStateTrees?: PublicKey[] | PublicKey;
949
+ /** Optional remaining accounts to append to */
950
+ remainingAccounts?: PublicKey[];
951
+ };
952
+ /**
953
+ * Packs Compressed Token Accounts.
954
+ */
955
+ declare function packCompressedTokenAccounts(params: PackCompressedTokenAccountsParams): {
956
+ inputTokenDataWithContext: InputTokenDataWithContext$1[];
957
+ outputStateMerkleTreeIndices: number[];
958
+ remainingAccountMetas: AccountMeta[];
959
+ };
960
+
961
+ declare const POOL_SEED: Buffer;
962
+ declare const CPI_AUTHORITY_SEED: Buffer;
963
+ declare const MINT_AUTHORITY_SEED: Uint8Array;
964
+ declare const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;
965
+
966
+ type CompressParams = {
967
+ /**
968
+ * The payer of the transaction.
969
+ */
970
+ payer: PublicKey;
971
+ /**
972
+ * owner of the *uncompressed* token account.
973
+ */
974
+ owner: PublicKey;
975
+ /**
976
+ * source (associated) token account address.
977
+ */
978
+ source: PublicKey;
979
+ /**
980
+ * owner of the compressed token account.
981
+ */
982
+ toAddress: PublicKey;
983
+ /**
984
+ * Mint address of the token to compress.
985
+ */
986
+ mint: PublicKey;
987
+ /**
988
+ * amount of tokens to compress.
989
+ */
990
+ amount: number | BN;
991
+ /**
992
+ * The state tree that the tx output should be inserted into.
993
+ */
994
+ outputStateTree: PublicKey;
995
+ };
996
+ type DecompressParams = {
997
+ /**
998
+ * The payer of the transaction.
999
+ */
1000
+ payer: PublicKey;
1001
+ /**
1002
+ * input state to be consumed
1003
+ */
1004
+ inputCompressedTokenAccounts: ParsedTokenAccount[];
1005
+ /**
1006
+ * address of **uncompressed** destination token account.
1007
+ */
1008
+ toAddress: PublicKey;
1009
+ /**
1010
+ * amount of tokens to decompress.
1011
+ */
1012
+ amount: number | BN;
1013
+ /**
1014
+ * The state tree that the change tx output should be inserted into.
1015
+ */
1016
+ outputStateTree: PublicKey;
1017
+ /**
1018
+ * The recent state root indices of the input state. The expiry is tied to
1019
+ * the proof.
1020
+ */
1021
+ recentInputStateRootIndices: number[];
1022
+ /**
1023
+ * The recent validity proof for state inclusion of the input state. It
1024
+ * expires after n slots.
1025
+ */
1026
+ recentValidityProof: CompressedProof;
1027
+ };
1028
+ type TransferParams = {
1029
+ /**
1030
+ * The payer of the transaction
1031
+ */
1032
+ payer: PublicKey;
1033
+ /**
1034
+ * The input state to be consumed
1035
+ */
1036
+ inputCompressedTokenAccounts: ParsedTokenAccount[];
1037
+ /**
1038
+ * Recipient address
1039
+ */
1040
+ toAddress: PublicKey;
1041
+ /**
1042
+ * Amount of tokens to transfer
1043
+ */
1044
+ amount: BN | number;
1045
+ /**
1046
+ * The recent state root indices of the input state. The expiry is tied to
1047
+ * the proof.
1048
+
1049
+ */
1050
+ recentInputStateRootIndices: number[];
1051
+ /**
1052
+ * The recent validity proof for state inclusion of the input state. It
1053
+ * expires after n slots.
1054
+ */
1055
+ recentValidityProof: CompressedProof;
1056
+ /**
1057
+ * The state trees that the tx output should be inserted into. This can be a
1058
+ * single PublicKey or an array of PublicKey. Defaults to the 0th state tree
1059
+ * of input state.
1060
+ */
1061
+ outputStateTrees?: PublicKey[] | PublicKey;
1062
+ };
1063
+ /** Create Mint account for compressed Tokens */
1064
+ type CreateMintParams = {
1065
+ /** Tx feepayer */
1066
+ feePayer: PublicKey;
1067
+ /** Mint authority */
1068
+ authority: PublicKey;
1069
+ /** Mint public key */
1070
+ mint: PublicKey;
1071
+ /** Mint decimals */
1072
+ decimals: number;
1073
+ /** Optional: freeze authority */
1074
+ freezeAuthority: PublicKey | null;
1075
+ /** lamport amount for mint account rent exemption */
1076
+ rentExemptBalance: number;
1077
+ };
1078
+ /**
1079
+ * Create compressed token accounts
1080
+ */
1081
+ type MintToParams = {
1082
+ /** Tx feepayer */
1083
+ feePayer: PublicKey;
1084
+ /** Mint authority */
1085
+ authority: PublicKey;
1086
+ /** Mint public key */
1087
+ mint: PublicKey;
1088
+ /** The Solana Public Keys to mint to. Accepts batches */
1089
+ toPubkey: PublicKey[] | PublicKey;
1090
+ /** The amount of compressed tokens to mint. Accepts batches */
1091
+ amount: BN | BN[] | number | number[];
1092
+ /** Public key of the state tree to mint into. */
1093
+ merkleTree: PublicKey;
1094
+ };
1095
+ declare const sumUpTokenAmount: (accounts: ParsedTokenAccount[]) => BN;
1096
+ declare const validateSameTokenOwner: (accounts: ParsedTokenAccount[]) => void;
1097
+ declare const parseInputTokenData: (inputCompressedTokenAccounts: ParsedTokenAccount[]) => {
1098
+ mint: PublicKey;
1099
+ currentOwner: PublicKey;
1100
+ delegate: PublicKey | null;
1101
+ };
1102
+ declare function createTransferOutputState(inputCompressedTokenAccounts: ParsedTokenAccount[], toAddress: PublicKey, amount: number | BN): TokenTransferOutputData$1[];
1103
+ declare function createDecompressOutputState(inputCompressedTokenAccounts: ParsedTokenAccount[], amount: number | BN): TokenTransferOutputData$1[];
1104
+ declare class CompressedTokenProgram {
1105
+ /**
1106
+ * @internal
1107
+ */
1108
+ constructor();
1109
+ /**
1110
+ * Public key that identifies the CompressedPda program
1111
+ */
1112
+ static programId: PublicKey;
1113
+ private static _program;
1114
+ static get program(): Program<LightCompressedToken>;
1115
+ /**
1116
+ * Initializes the program statically if not already initialized.
1117
+ */
1118
+ private static initializeProgram;
1119
+ /** @internal */
1120
+ static deriveMintAuthorityPda: (authority: PublicKey, mint: PublicKey) => PublicKey;
1121
+ /** @internal */
1122
+ static deriveTokenPoolPda(mint: PublicKey): PublicKey;
1123
+ /** @internal */
1124
+ static get deriveCpiAuthorityPda(): PublicKey;
1125
+ static createMint(params: CreateMintParams): Promise<TransactionInstruction[]>;
1126
+ static mintTo(params: MintToParams): Promise<TransactionInstruction>;
1127
+ static transfer(params: TransferParams): Promise<TransactionInstruction[]>;
1128
+ static compress(params: CompressParams): Promise<TransactionInstruction[]>;
1129
+ static decompress(params: DecompressParams): Promise<TransactionInstruction[]>;
1130
+ }
1131
+
1132
+ type TokenTransferOutputData = {
1133
+ owner: PublicKey;
1134
+ amount: BN;
1135
+ lamports: BN | null;
1136
+ };
1137
+ type InputTokenDataWithContext = {
1138
+ amount: BN;
1139
+ delegateIndex: number | null;
1140
+ delegatedAmount: BN | null;
1141
+ isNative: BN | null;
1142
+ merkleTreePubkeyIndex: number;
1143
+ nullifierQueuePubkeyIndex: number;
1144
+ leafIndex: number;
1145
+ };
1146
+ type CompressedTokenInstructionDataTransfer = {
1147
+ proof: CompressedProof | null;
1148
+ rootIndices: number[];
1149
+ mint: PublicKey;
1150
+ signerIsDelegate: boolean;
1151
+ inputTokenDataWithContext: InputTokenDataWithContext[];
1152
+ outputCompressedAccounts: TokenTransferOutputData[];
1153
+ outputStateMerkleTreeAccountIndices: Buffer;
1154
+ };
1155
+ type TokenData = {
1156
+ mint: PublicKey;
1157
+ owner: PublicKey;
1158
+ amount: BN;
1159
+ delegate: PublicKey | null;
1160
+ state: number;
1161
+ isNative: BN | null;
1162
+ delegatedAmount: BN;
1163
+ };
1164
+
1165
+ /**
1166
+ * Compress SPL tokens
1167
+ *
1168
+ * @param rpc Rpc connection to use
1169
+ * @param payer Payer of the transaction fees
1170
+ * @param mint Mint of the compressed token
1171
+ * @param amount Number of tokens to transfer
1172
+ * @param owner Owner of the compressed tokens.
1173
+ * @param sourceTokenAccount Source (associated) token account
1174
+ * @param toAddress Destination address of the recipient
1175
+ * @param merkleTree State tree account that the compressed tokens
1176
+ * should be inserted into. Defaults to a default
1177
+ * state tree account.
1178
+ * @param confirmOptions Options for confirming the transaction
1179
+ *
1180
+ *
1181
+ * @return Signature of the confirmed transaction
1182
+ */
1183
+ declare function compress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, sourceTokenAccount: PublicKey, toAddress: PublicKey, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
1184
+
1185
+ /**
1186
+ * Decompress compressed tokens
1187
+ *
1188
+ * @param rpc Rpc to use
1189
+ * @param payer Payer of the transaction fees
1190
+ * @param mint Mint of the compressed token
1191
+ * @param amount Number of tokens to transfer
1192
+ * @param owner Owner of the compressed tokens
1193
+ * @param toAddress Destination **uncompressed** (associated) token account
1194
+ * address.
1195
+ * @param merkleTree State tree account that any change compressed tokens should be
1196
+ * inserted into. Defaults to a default state tree
1197
+ * account.
1198
+ * @param confirmOptions Options for confirming the transaction
1199
+ *
1200
+ *
1201
+ * @return Signature of the confirmed transaction
1202
+ */
1203
+ declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
1204
+
1205
+ /**
1206
+ * Create and initialize a new compressed token mint
1207
+ *
1208
+ * @param rpc RPC to use
1209
+ * @param payer Payer of the transaction and initialization fees
1210
+ * @param mintAuthority Account or multisig that will control minting. Is signer.
1211
+ * @param decimals Location of the decimal place
1212
+ * @param keypair Optional keypair, defaulting to a new random one
1213
+ * @param confirmOptions Options for confirming the transaction
1214
+ *
1215
+ * @return Address of the new mint and the transaction signature
1216
+ */
1217
+ declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: Signer, decimals: number, keypair?: Keypair, confirmOptions?: ConfirmOptions): Promise<{
1218
+ mint: PublicKey;
1219
+ transactionSignature: TransactionSignature;
1220
+ }>;
1221
+
1222
+ /**
1223
+ * Mint compressed tokens to a solana address
1224
+ *
1225
+ * @param rpc Rpc to use
1226
+ * @param payer Payer of the transaction fees
1227
+ * @param mint Mint for the account
1228
+ * @param destination Address of the account to mint to
1229
+ * @param authority Minting authority
1230
+ * @param amount Amount to mint
1231
+ * @param merkleTree State tree account that the compressed tokens should be
1232
+ * part of. Defaults to the default state tree account.
1233
+ * @param confirmOptions Options for confirming the transaction
1234
+ *
1235
+ * @return Signature of the confirmed transaction
1236
+ */
1237
+ declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey, authority: Signer, amount: number | BN, merkleTree?: PublicKey, // DEFAULT IF NOT PROVIDED
1238
+ confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
1239
+
1240
+ /**
1241
+ * Transfer compressed tokens from one owner to another
1242
+ *
1243
+ * @param rpc Rpc to use
1244
+ * @param payer Payer of the transaction fees
1245
+ * @param mint Mint of the compressed token
1246
+ * @param amount Number of tokens to transfer
1247
+ * @param owner Owner of the compressed tokens
1248
+ * @param toAddress Destination address of the recipient
1249
+ * @param merkleTree State tree account that the compressed tokens should be
1250
+ * inserted into. Defaults to the default state tree account.
1251
+ * @param confirmOptions Options for confirming the transaction
1252
+ *
1253
+ *
1254
+ * @return Signature of the confirmed transaction
1255
+ */
1256
+ declare function transfer(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
1257
+ /**
1258
+ * Selects the minimal number of compressed token accounts for a transfer.
1259
+ *
1260
+ * 1. Sorts the accounts by amount in descending order
1261
+ * 2. Accumulates the amount until it is greater than or equal to the transfer
1262
+ * amount
1263
+ */
1264
+ declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN): [
1265
+ selectedAccounts: ParsedTokenAccount[],
1266
+ total: BN,
1267
+ totalLamports: BN | null
1268
+ ];
1269
+
1270
+ export { CPI_AUTHORITY_SEED, type CompressedTokenInstructionDataTransfer, CompressedTokenProgram, type CreateMintParams, IDL, type InputTokenDataWithContext, type LightCompressedToken, MINT_AUTHORITY_SEED, type MintToParams, POOL_SEED, type PackCompressedTokenAccountsParams, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, type TokenData, type TokenTransferOutputData, type TransferParams, compress, createDecompressOutputState, createMint, createTransferOutputState, decompress, mintTo, packCompressedTokenAccounts, parseInputTokenData, selectMinCompressedTokenAccountsForTransfer, sumUpTokenAmount, transfer, validateSameTokenOwner };