@lightprotocol/compressed-token 0.1.2 → 0.2.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.
@@ -3,7 +3,7 @@ import { PublicKey, AccountMeta, TransactionInstruction, Signer, ConfirmOptions,
3
3
  import { BN, Program } from '@coral-xyz/anchor';
4
4
 
5
5
  type LightCompressedToken = {
6
- version: '0.3.0';
6
+ version: '0.3.1';
7
7
  name: 'light_compressed_token';
8
8
  constants: [
9
9
  {
@@ -16,9 +16,10 @@ type LightCompressedToken = {
16
16
  {
17
17
  name: 'createMint';
18
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.'
19
+ 'This instruction expects a mint account to be created in a separate',
20
+ 'token program instruction with token authority as mint authority. This',
21
+ 'instruction creates a token pool account for that mint owned by token',
22
+ 'authority.'
22
23
  ];
23
24
  accounts: [
24
25
  {
@@ -98,7 +99,7 @@ type LightCompressedToken = {
98
99
  isSigner: false;
99
100
  },
100
101
  {
101
- name: 'compressedPdaProgram';
102
+ name: 'lightSystemProgram';
102
103
  isMut: false;
103
104
  isSigner: false;
104
105
  },
@@ -131,6 +132,11 @@ type LightCompressedToken = {
131
132
  name: 'selfProgram';
132
133
  isMut: false;
133
134
  isSigner: false;
135
+ },
136
+ {
137
+ name: 'systemProgram';
138
+ isMut: false;
139
+ isSigner: false;
134
140
  }
135
141
  ];
136
142
  args: [
@@ -145,6 +151,10 @@ type LightCompressedToken = {
145
151
  type: {
146
152
  vec: 'u64';
147
153
  };
154
+ },
155
+ {
156
+ name: 'bump';
157
+ type: 'u8';
148
158
  }
149
159
  ];
150
160
  },
@@ -153,7 +163,7 @@ type LightCompressedToken = {
153
163
  accounts: [
154
164
  {
155
165
  name: 'feePayer';
156
- isMut: false;
166
+ isMut: true;
157
167
  isSigner: true;
158
168
  },
159
169
  {
@@ -167,7 +177,7 @@ type LightCompressedToken = {
167
177
  isSigner: false;
168
178
  },
169
179
  {
170
- name: 'compressedPdaProgram';
180
+ name: 'lightSystemProgram';
171
181
  isMut: false;
172
182
  isSigner: false;
173
183
  },
@@ -213,140 +223,162 @@ type LightCompressedToken = {
213
223
  isMut: false;
214
224
  isSigner: false;
215
225
  isOptional: true;
226
+ },
227
+ {
228
+ name: 'systemProgram';
229
+ isMut: false;
230
+ isSigner: false;
216
231
  }
217
232
  ];
218
233
  args: [
219
234
  {
220
235
  name: 'inputs';
221
236
  type: 'bytes';
222
- },
223
- {
224
- name: 'cpiContext';
225
- type: {
226
- option: {
227
- defined: 'CompressedCpiContext';
228
- };
229
- };
230
237
  }
231
238
  ];
232
239
  }
233
240
  ];
234
241
  types: [
235
242
  {
236
- name: 'CompressedAccountWithMerkleContext';
243
+ name: 'InstructionDataInvoke';
237
244
  type: {
238
245
  kind: 'struct';
239
246
  fields: [
240
247
  {
241
- name: 'compressedAccount';
248
+ name: 'proof';
242
249
  type: {
243
- defined: 'CompressedAccount';
250
+ option: {
251
+ defined: 'CompressedProof';
252
+ };
244
253
  };
245
254
  },
246
255
  {
247
- name: 'merkleTreePubkeyIndex';
248
- type: 'u8';
256
+ name: 'inputRootIndices';
257
+ type: {
258
+ vec: 'u16';
259
+ };
249
260
  },
250
261
  {
251
- name: 'nullifierQueuePubkeyIndex';
252
- type: 'u8';
262
+ name: 'inputCompressedAccountsWithMerkleContext';
263
+ type: {
264
+ vec: {
265
+ defined: 'PackedCompressedAccountWithMerkleContext';
266
+ };
267
+ };
253
268
  },
254
269
  {
255
- name: 'leafIndex';
256
- type: 'u32';
257
- }
258
- ];
259
- };
260
- },
261
- {
262
- name: 'MerkleContext';
263
- type: {
264
- kind: 'struct';
265
- fields: [
270
+ name: 'outputCompressedAccounts';
271
+ type: {
272
+ vec: {
273
+ defined: 'CompressedAccount';
274
+ };
275
+ };
276
+ },
266
277
  {
267
- name: 'merkleTreePubkey';
268
- type: 'publicKey';
278
+ name: 'outputStateMerkleTreeAccountIndices';
279
+ docs: [
280
+ 'The indices of the accounts in the output state merkle tree.'
281
+ ];
282
+ type: 'bytes';
269
283
  },
270
284
  {
271
- name: 'nullifierQueuePubkey';
272
- type: 'publicKey';
285
+ name: 'relayFee';
286
+ type: {
287
+ option: 'u64';
288
+ };
273
289
  },
274
290
  {
275
- name: 'leafIndex';
276
- type: 'u32';
291
+ name: 'newAddressParams';
292
+ type: {
293
+ vec: {
294
+ defined: 'NewAddressParamsPacked';
295
+ };
296
+ };
297
+ },
298
+ {
299
+ name: 'compressionLamports';
300
+ type: {
301
+ option: 'u64';
302
+ };
303
+ },
304
+ {
305
+ name: 'isCompress';
306
+ type: 'bool';
277
307
  }
278
308
  ];
279
309
  };
280
310
  },
281
311
  {
282
- name: 'PackedMerkleContext';
312
+ name: 'NewAddressParamsPacked';
283
313
  type: {
284
314
  kind: 'struct';
285
315
  fields: [
286
316
  {
287
- name: 'merkleTreePubkeyIndex';
317
+ name: 'seed';
318
+ type: {
319
+ array: ['u8', 32];
320
+ };
321
+ },
322
+ {
323
+ name: 'addressQueueAccountIndex';
288
324
  type: 'u8';
289
325
  },
290
326
  {
291
- name: 'nullifierQueuePubkeyIndex';
327
+ name: 'addressMerkleTreeAccountIndex';
292
328
  type: 'u8';
293
329
  },
294
330
  {
295
- name: 'leafIndex';
296
- type: 'u32';
331
+ name: 'addressMerkleTreeRootIndex';
332
+ type: 'u16';
297
333
  }
298
334
  ];
299
335
  };
300
336
  },
301
337
  {
302
- name: 'CompressedAccount';
338
+ name: 'NewAddressParams';
303
339
  type: {
304
340
  kind: 'struct';
305
341
  fields: [
306
342
  {
307
- name: 'owner';
308
- type: 'publicKey';
343
+ name: 'seed';
344
+ type: {
345
+ array: ['u8', 32];
346
+ };
309
347
  },
310
348
  {
311
- name: 'lamports';
312
- type: 'u64';
349
+ name: 'addressQueuePubkey';
350
+ type: 'publicKey';
313
351
  },
314
352
  {
315
- name: 'address';
316
- type: {
317
- option: {
318
- array: ['u8', 32];
319
- };
320
- };
353
+ name: 'addressMerkleTreePubkey';
354
+ type: 'publicKey';
321
355
  },
322
356
  {
323
- name: 'data';
324
- type: {
325
- option: {
326
- defined: 'CompressedAccountData';
327
- };
328
- };
357
+ name: 'addressMerkleTreeRootIndex';
358
+ type: 'u16';
329
359
  }
330
360
  ];
331
361
  };
332
362
  },
333
363
  {
334
- name: 'CompressedAccountData';
364
+ name: 'CompressedProof';
335
365
  type: {
336
366
  kind: 'struct';
337
367
  fields: [
338
368
  {
339
- name: 'discriminator';
369
+ name: 'a';
340
370
  type: {
341
- array: ['u8', 8];
371
+ array: ['u8', 32];
342
372
  };
343
373
  },
344
374
  {
345
- name: 'data';
346
- type: 'bytes';
375
+ name: 'b';
376
+ type: {
377
+ array: ['u8', 64];
378
+ };
347
379
  },
348
380
  {
349
- name: 'dataHash';
381
+ name: 'c';
350
382
  type: {
351
383
  array: ['u8', 32];
352
384
  };
@@ -355,57 +387,37 @@ type LightCompressedToken = {
355
387
  };
356
388
  },
357
389
  {
358
- name: 'CompressedCpiContext';
359
- docs: ['To spend multiple compressed'];
390
+ name: 'InstructionDataInvokeCpi';
360
391
  type: {
361
392
  kind: 'struct';
362
393
  fields: [
363
394
  {
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';
395
+ name: 'proof';
396
+ type: {
397
+ option: {
398
+ defined: 'CompressedProof';
399
+ };
400
+ };
370
401
  },
371
402
  {
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';
403
+ name: 'newAddressParams';
390
404
  type: {
391
405
  vec: {
392
- array: ['u8', 32];
406
+ defined: 'NewAddressParamsPacked';
393
407
  };
394
408
  };
395
409
  },
396
410
  {
397
- name: 'outputCompressedAccountHashes';
411
+ name: 'inputRootIndices';
398
412
  type: {
399
- vec: {
400
- array: ['u8', 32];
401
- };
413
+ vec: 'u16';
402
414
  };
403
415
  },
404
416
  {
405
- name: 'inputCompressedAccounts';
417
+ name: 'inputCompressedAccountsWithMerkleContext';
406
418
  type: {
407
419
  vec: {
408
- defined: 'CompressedAccountWithMerkleContext';
420
+ defined: 'PackedCompressedAccountWithMerkleContext';
409
421
  };
410
422
  };
411
423
  },
@@ -419,16 +431,19 @@ type LightCompressedToken = {
419
431
  },
420
432
  {
421
433
  name: 'outputStateMerkleTreeAccountIndices';
434
+ docs: [
435
+ 'The indices of the accounts in the output state merkle tree.'
436
+ ];
422
437
  type: 'bytes';
423
438
  },
424
439
  {
425
- name: 'outputLeafIndices';
440
+ name: 'relayFee';
426
441
  type: {
427
- vec: 'u32';
442
+ option: 'u64';
428
443
  };
429
444
  },
430
445
  {
431
- name: 'relayFee';
446
+ name: 'compressionLamports';
432
447
  type: {
433
448
  option: 'u64';
434
449
  };
@@ -438,177 +453,240 @@ type LightCompressedToken = {
438
453
  type: 'bool';
439
454
  },
440
455
  {
441
- name: 'compressionLamports';
456
+ name: 'signerSeeds';
442
457
  type: {
443
- option: 'u64';
458
+ vec: 'bytes';
444
459
  };
445
460
  },
446
461
  {
447
- name: 'pubkeyArray';
462
+ name: 'cpiContext';
448
463
  type: {
449
- vec: 'publicKey';
464
+ option: {
465
+ defined: 'CompressedCpiContext';
466
+ };
467
+ };
468
+ }
469
+ ];
470
+ };
471
+ },
472
+ {
473
+ name: 'PackedCompressedAccountWithMerkleContext';
474
+ type: {
475
+ kind: 'struct';
476
+ fields: [
477
+ {
478
+ name: 'compressedAccount';
479
+ type: {
480
+ defined: 'CompressedAccount';
450
481
  };
451
482
  },
452
483
  {
453
- name: 'message';
484
+ name: 'merkleContext';
454
485
  type: {
455
- option: 'bytes';
486
+ defined: 'PackedMerkleContext';
456
487
  };
457
488
  }
458
489
  ];
459
490
  };
460
491
  },
461
492
  {
462
- name: 'InstructionDataTransfer';
493
+ name: 'CompressedAccountWithMerkleContext';
463
494
  type: {
464
495
  kind: 'struct';
465
496
  fields: [
466
497
  {
467
- name: 'proof';
498
+ name: 'compressedAccount';
468
499
  type: {
469
- option: {
470
- defined: 'CompressedProof';
471
- };
500
+ defined: 'CompressedAccount';
472
501
  };
473
502
  },
474
503
  {
475
- name: 'newAddressParams';
504
+ name: 'merkleContext';
476
505
  type: {
477
- vec: {
478
- defined: 'NewAddressParamsPacked';
479
- };
506
+ defined: 'MerkleContext';
480
507
  };
508
+ }
509
+ ];
510
+ };
511
+ },
512
+ {
513
+ name: 'MerkleContext';
514
+ type: {
515
+ kind: 'struct';
516
+ fields: [
517
+ {
518
+ name: 'merkleTreePubkey';
519
+ type: 'publicKey';
481
520
  },
482
521
  {
483
- name: 'inputRootIndices';
484
- type: {
485
- vec: 'u16';
486
- };
522
+ name: 'nullifierQueuePubkey';
523
+ type: 'publicKey';
487
524
  },
488
525
  {
489
- name: 'inputCompressedAccountsWithMerkleContext';
490
- type: {
491
- vec: {
492
- defined: 'CompressedAccountWithMerkleContext';
493
- };
494
- };
526
+ name: 'leafIndex';
527
+ type: 'u32';
528
+ }
529
+ ];
530
+ };
531
+ },
532
+ {
533
+ name: 'PackedMerkleContext';
534
+ type: {
535
+ kind: 'struct';
536
+ fields: [
537
+ {
538
+ name: 'merkleTreePubkeyIndex';
539
+ type: 'u8';
495
540
  },
496
541
  {
497
- name: 'outputCompressedAccounts';
498
- type: {
499
- vec: {
500
- defined: 'CompressedAccount';
501
- };
502
- };
542
+ name: 'nullifierQueuePubkeyIndex';
543
+ type: 'u8';
503
544
  },
504
545
  {
505
- name: 'outputStateMerkleTreeAccountIndices';
506
- docs: [
507
- 'The indices of the accounts in the output state merkle tree.'
508
- ];
509
- type: 'bytes';
546
+ name: 'leafIndex';
547
+ type: 'u32';
548
+ }
549
+ ];
550
+ };
551
+ },
552
+ {
553
+ name: 'CompressedAccount';
554
+ type: {
555
+ kind: 'struct';
556
+ fields: [
557
+ {
558
+ name: 'owner';
559
+ type: 'publicKey';
510
560
  },
511
561
  {
512
- name: 'relayFee';
562
+ name: 'lamports';
563
+ type: 'u64';
564
+ },
565
+ {
566
+ name: 'address';
513
567
  type: {
514
- option: 'u64';
568
+ option: {
569
+ array: ['u8', 32];
570
+ };
515
571
  };
516
572
  },
517
573
  {
518
- name: 'compressionLamports';
574
+ name: 'data';
519
575
  type: {
520
- option: 'u64';
576
+ option: {
577
+ defined: 'CompressedAccountData';
578
+ };
579
+ };
580
+ }
581
+ ];
582
+ };
583
+ },
584
+ {
585
+ name: 'CompressedAccountData';
586
+ type: {
587
+ kind: 'struct';
588
+ fields: [
589
+ {
590
+ name: 'discriminator';
591
+ type: {
592
+ array: ['u8', 8];
521
593
  };
522
594
  },
523
595
  {
524
- name: 'isCompress';
525
- type: 'bool';
596
+ name: 'data';
597
+ type: 'bytes';
526
598
  },
527
599
  {
528
- name: 'signerSeeds';
600
+ name: 'dataHash';
529
601
  type: {
530
- option: {
531
- vec: 'bytes';
532
- };
602
+ array: ['u8', 32];
533
603
  };
534
604
  }
535
605
  ];
536
606
  };
537
607
  },
538
608
  {
539
- name: 'NewAddressParamsPacked';
609
+ name: 'PublicTransactionEvent';
540
610
  type: {
541
611
  kind: 'struct';
542
612
  fields: [
543
613
  {
544
- name: 'seed';
614
+ name: 'inputCompressedAccountHashes';
545
615
  type: {
546
- array: ['u8', 32];
616
+ vec: {
617
+ array: ['u8', 32];
618
+ };
619
+ };
620
+ },
621
+ {
622
+ name: 'outputCompressedAccountHashes';
623
+ type: {
624
+ vec: {
625
+ array: ['u8', 32];
626
+ };
627
+ };
628
+ },
629
+ {
630
+ name: 'outputCompressedAccounts';
631
+ type: {
632
+ vec: {
633
+ defined: 'CompressedAccount';
634
+ };
635
+ };
636
+ },
637
+ {
638
+ name: 'outputStateMerkleTreeAccountIndices';
639
+ type: 'bytes';
640
+ },
641
+ {
642
+ name: 'outputLeafIndices';
643
+ type: {
644
+ vec: 'u32';
547
645
  };
548
646
  },
549
647
  {
550
- name: 'addressQueueAccountIndex';
551
- type: 'u8';
648
+ name: 'relayFee';
649
+ type: {
650
+ option: 'u64';
651
+ };
552
652
  },
553
653
  {
554
- name: 'addressMerkleTreeAccountIndex';
555
- type: 'u8';
654
+ name: 'isCompress';
655
+ type: 'bool';
556
656
  },
557
657
  {
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';
658
+ name: 'compressionLamports';
571
659
  type: {
572
- array: ['u8', 32];
660
+ option: 'u64';
573
661
  };
574
662
  },
575
663
  {
576
- name: 'addressQueuePubkey';
577
- type: 'publicKey';
578
- },
579
- {
580
- name: 'addressMerkleTreePubkey';
581
- type: 'publicKey';
664
+ name: 'pubkeyArray';
665
+ type: {
666
+ vec: 'publicKey';
667
+ };
582
668
  },
583
669
  {
584
- name: 'addressMerkleTreeRootIndex';
585
- type: 'u16';
670
+ name: 'message';
671
+ type: {
672
+ option: 'bytes';
673
+ };
586
674
  }
587
675
  ];
588
676
  };
589
677
  },
590
678
  {
591
- name: 'CompressedProof';
679
+ name: 'CompressedCpiContext';
592
680
  type: {
593
681
  kind: 'struct';
594
682
  fields: [
595
683
  {
596
- name: 'a';
597
- type: {
598
- array: ['u8', 32];
599
- };
600
- },
601
- {
602
- name: 'b';
603
- type: {
604
- array: ['u8', 64];
605
- };
684
+ name: 'setContext';
685
+ type: 'bool';
606
686
  },
607
687
  {
608
- name: 'c';
609
- type: {
610
- array: ['u8', 32];
611
- };
688
+ name: 'cpiContextAccountIndex';
689
+ type: 'u8';
612
690
  }
613
691
  ];
614
692
  };
@@ -641,16 +719,10 @@ type LightCompressedToken = {
641
719
  };
642
720
  },
643
721
  {
644
- name: 'merkleTreePubkeyIndex';
645
- type: 'u8';
646
- },
647
- {
648
- name: 'nullifierQueuePubkeyIndex';
649
- type: 'u8';
650
- },
651
- {
652
- name: 'leafIndex';
653
- type: 'u32';
722
+ name: 'merkleContext';
723
+ type: {
724
+ defined: 'PackedMerkleContext';
725
+ };
654
726
  }
655
727
  ];
656
728
  };
@@ -711,6 +783,14 @@ type LightCompressedToken = {
711
783
  type: {
712
784
  option: 'u64';
713
785
  };
786
+ },
787
+ {
788
+ name: 'cpiContext';
789
+ type: {
790
+ option: {
791
+ defined: 'CompressedCpiContext';
792
+ };
793
+ };
714
794
  }
715
795
  ];
716
796
  };
@@ -794,69 +874,11 @@ type LightCompressedToken = {
794
874
  ];
795
875
  };
796
876
  },
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
877
  {
853
878
  name: 'AccountState';
854
879
  type: {
855
880
  kind: 'enum';
856
881
  variants: [
857
- {
858
- name: 'Uninitialized';
859
- },
860
882
  {
861
883
  name: 'Initialized';
862
884
  },
@@ -1060,7 +1082,9 @@ type TransferParams = {
1060
1082
  */
1061
1083
  outputStateTrees?: PublicKey[] | PublicKey;
1062
1084
  };
1063
- /** Create Mint account for compressed Tokens */
1085
+ /**
1086
+ * Create Mint account for compressed Tokens
1087
+ */
1064
1088
  type CreateMintParams = {
1065
1089
  /** Tx feepayer */
1066
1090
  feePayer: PublicKey;
@@ -1092,14 +1116,69 @@ type MintToParams = {
1092
1116
  /** Public key of the state tree to mint into. */
1093
1117
  merkleTree: PublicKey;
1094
1118
  };
1119
+ /**
1120
+ * Register an existing SPL mint account to the compressed token program
1121
+ * Creates an omnibus account for the mint
1122
+ */
1123
+ type RegisterMintParams = {
1124
+ /** Tx feepayer */
1125
+ feePayer: PublicKey;
1126
+ /** Mint authority */
1127
+ authority: PublicKey;
1128
+ /** Mint public key */
1129
+ mint: PublicKey;
1130
+ };
1131
+ /**
1132
+ * Mint from existing SPL mint to compressed token accounts
1133
+ */
1134
+ type ApproveAndMintToParams = {
1135
+ /** Tx feepayer */
1136
+ feePayer: PublicKey;
1137
+ /** Mint authority */
1138
+ authority: PublicKey;
1139
+ /** Mint authority (associated) token account */
1140
+ authorityTokenAccount: PublicKey;
1141
+ /** Mint public key */
1142
+ mint: PublicKey;
1143
+ /** The Solana Public Key to mint to. */
1144
+ toPubkey: PublicKey;
1145
+ /** The amount of compressed tokens to mint. */
1146
+ amount: BN | number;
1147
+ /** Public key of the state tree to mint into. */
1148
+ merkleTree: PublicKey;
1149
+ };
1150
+ /**
1151
+ * Sum up the token amounts of the compressed token accounts
1152
+ */
1095
1153
  declare const sumUpTokenAmount: (accounts: ParsedTokenAccount[]) => BN;
1154
+ /**
1155
+ * Validate that all the compressed token accounts are owned by the same owner.
1156
+ */
1096
1157
  declare const validateSameTokenOwner: (accounts: ParsedTokenAccount[]) => void;
1097
- declare const parseInputTokenData: (inputCompressedTokenAccounts: ParsedTokenAccount[]) => {
1158
+ /**
1159
+ * Parse compressed token accounts to get the mint, current owner and delegate.
1160
+ */
1161
+ declare const parseTokenData: (compressedTokenAccounts: ParsedTokenAccount[]) => {
1098
1162
  mint: PublicKey;
1099
1163
  currentOwner: PublicKey;
1100
1164
  delegate: PublicKey | null;
1101
1165
  };
1166
+ /**
1167
+ * Create the output state for a transfer transaction.
1168
+ * @param inputCompressedTokenAccounts Input state
1169
+ * @param toAddress Recipient address
1170
+ * @param amount Amount of tokens to transfer
1171
+ * @returns Output token data for the transfer
1172
+ * instruction
1173
+ */
1102
1174
  declare function createTransferOutputState(inputCompressedTokenAccounts: ParsedTokenAccount[], toAddress: PublicKey, amount: number | BN): TokenTransferOutputData$1[];
1175
+ /**
1176
+ * Create the output state for a compress transaction.
1177
+ * @param inputCompressedTokenAccounts Input state
1178
+ * @param amount Amount of tokens to compress
1179
+ * @returns Output token data for the compress
1180
+ * instruction
1181
+ */
1103
1182
  declare function createDecompressOutputState(inputCompressedTokenAccounts: ParsedTokenAccount[], amount: number | BN): TokenTransferOutputData$1[];
1104
1183
  declare class CompressedTokenProgram {
1105
1184
  /**
@@ -1111,57 +1190,178 @@ declare class CompressedTokenProgram {
1111
1190
  */
1112
1191
  static programId: PublicKey;
1113
1192
  private static _program;
1193
+ /** @internal */
1114
1194
  static get program(): Program<LightCompressedToken>;
1115
1195
  /**
1196
+ * @internal
1116
1197
  * Initializes the program statically if not already initialized.
1117
1198
  */
1118
1199
  private static initializeProgram;
1119
1200
  /** @internal */
1120
- static deriveMintAuthorityPda: (authority: PublicKey, mint: PublicKey) => PublicKey;
1201
+ static deriveMintAuthorityPda: (authority: PublicKey, mint: PublicKey) => [PublicKey, number];
1121
1202
  /** @internal */
1122
1203
  static deriveTokenPoolPda(mint: PublicKey): PublicKey;
1123
1204
  /** @internal */
1124
1205
  static get deriveCpiAuthorityPda(): PublicKey;
1206
+ /**
1207
+ * Construct createMint instruction for compressed tokens
1208
+ */
1125
1209
  static createMint(params: CreateMintParams): Promise<TransactionInstruction[]>;
1210
+ /**
1211
+ * Enable compression for an existing SPL mint, creating an omnibus account.
1212
+ * For new mints, use `CompressedTokenProgram.createMint`.
1213
+ */
1214
+ static registerMint(params: RegisterMintParams): Promise<TransactionInstruction[]>;
1215
+ /**
1216
+ * Construct mintTo instruction for compressed tokens
1217
+ */
1126
1218
  static mintTo(params: MintToParams): Promise<TransactionInstruction>;
1127
- static transfer(params: TransferParams): Promise<TransactionInstruction[]>;
1219
+ /**
1220
+ * Mint tokens from registed SPL mint account to a compressed account
1221
+ */
1222
+ static approveAndMintTo(params: ApproveAndMintToParams): Promise<TransactionInstruction[]>;
1223
+ /**
1224
+ * Construct transfer instruction for compressed tokens
1225
+ */
1226
+ static transfer(params: TransferParams): Promise<TransactionInstruction>;
1227
+ /**
1228
+ * Construct approve and compress instructions
1229
+ * @returns [approveInstruction, compressInstruction]
1230
+ */
1128
1231
  static compress(params: CompressParams): Promise<TransactionInstruction[]>;
1129
- static decompress(params: DecompressParams): Promise<TransactionInstruction[]>;
1232
+ /**
1233
+ * Construct decompress instruction
1234
+ */
1235
+ static decompress(params: DecompressParams): Promise<TransactionInstruction>;
1130
1236
  }
1131
1237
 
1132
1238
  type TokenTransferOutputData = {
1239
+ /**
1240
+ * The owner of the output token account
1241
+ */
1133
1242
  owner: PublicKey;
1243
+ /**
1244
+ * The amount of tokens of the output token account
1245
+ */
1134
1246
  amount: BN;
1247
+ /**
1248
+ * lamports associated with the output token account
1249
+ */
1135
1250
  lamports: BN | null;
1136
1251
  };
1137
1252
  type InputTokenDataWithContext = {
1253
+ /**
1254
+ * The amount of tokens to transfer
1255
+ */
1138
1256
  amount: BN;
1257
+ /**
1258
+ * Optional: The index of the delegate in remaining accounts
1259
+ */
1139
1260
  delegateIndex: number | null;
1261
+ /**
1262
+ * Optional: The amount of delegated tokens
1263
+ */
1140
1264
  delegatedAmount: BN | null;
1265
+ /**
1266
+ * Optional: Whether the token is native (wSOL)
1267
+ */
1141
1268
  isNative: BN | null;
1269
+ /**
1270
+ * The index of the merkle tree address in remaining accounts
1271
+ */
1142
1272
  merkleTreePubkeyIndex: number;
1273
+ /**
1274
+ * The index of the nullifier queue address in remaining accounts
1275
+ */
1143
1276
  nullifierQueuePubkeyIndex: number;
1277
+ /**
1278
+ * The index of the leaf in the merkle tree
1279
+ */
1144
1280
  leafIndex: number;
1145
1281
  };
1146
- type CompressedTokenInstructionDataTransfer = {
1282
+ type CompressedTokenInstructionDataInvoke = {
1283
+ /**
1284
+ * Validity proof
1285
+ */
1147
1286
  proof: CompressedProof | null;
1287
+ /**
1288
+ * The root indices of the transfer
1289
+ */
1148
1290
  rootIndices: number[];
1291
+ /**
1292
+ * The mint of the transfer
1293
+ */
1149
1294
  mint: PublicKey;
1295
+ /**
1296
+ * Whether the signer is a delegate
1297
+ */
1150
1298
  signerIsDelegate: boolean;
1299
+ /**
1300
+ * Input token data with packed merkle context
1301
+ */
1151
1302
  inputTokenDataWithContext: InputTokenDataWithContext[];
1303
+ /**
1304
+ * Data of the output token accounts
1305
+ */
1152
1306
  outputCompressedAccounts: TokenTransferOutputData[];
1307
+ /**
1308
+ * The indices of the output state merkle tree accounts in 'remaining
1309
+ * accounts'
1310
+ */
1153
1311
  outputStateMerkleTreeAccountIndices: Buffer;
1154
1312
  };
1155
1313
  type TokenData = {
1314
+ /**
1315
+ * The mint associated with this account
1316
+ */
1156
1317
  mint: PublicKey;
1318
+ /**
1319
+ * The owner of this account
1320
+ */
1157
1321
  owner: PublicKey;
1322
+ /**
1323
+ * The amount of tokens this account holds
1324
+ */
1158
1325
  amount: BN;
1326
+ /**
1327
+ * If `delegate` is `Some` then `delegated_amount` represents the amount
1328
+ * authorized by the delegate
1329
+ */
1159
1330
  delegate: PublicKey | null;
1331
+ /**
1332
+ * The account's state
1333
+ */
1160
1334
  state: number;
1335
+ /**
1336
+ * If is_some, this is a native token, and the value logs the rent-exempt
1337
+ * reserve. An Account is required to be rent-exempt, so the value is used
1338
+ * by the Processor to ensure that wrapped SOL accounts do not drop below
1339
+ * this threshold.
1340
+ */
1161
1341
  isNative: BN | null;
1342
+ /**
1343
+ * The amount delegated
1344
+ */
1162
1345
  delegatedAmount: BN;
1163
1346
  };
1164
1347
 
1348
+ /**
1349
+ * Mint compressed tokens to a solana address from an external mint authority
1350
+ *
1351
+ * @param rpc Rpc to use
1352
+ * @param payer Payer of the transaction fees
1353
+ * @param mint Mint for the account
1354
+ * @param destination Address of the account to mint to
1355
+ * @param authority Minting authority
1356
+ * @param amount Amount to mint
1357
+ * @param merkleTree State tree account that the compressed tokens should be
1358
+ * part of. Defaults to the default state tree account.
1359
+ * @param confirmOptions Options for confirming the transaction
1360
+ *
1361
+ * @return Signature of the confirmed transaction
1362
+ */
1363
+ declare function approveAndMintTo(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey, authority: Signer, amount: number | BN, merkleTree?: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
1364
+
1165
1365
  /**
1166
1366
  * Compress SPL tokens
1167
1367
  *
@@ -1237,6 +1437,19 @@ declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: Signer, deci
1237
1437
  declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey, authority: Signer, amount: number | BN, merkleTree?: PublicKey, // DEFAULT IF NOT PROVIDED
1238
1438
  confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
1239
1439
 
1440
+ /**
1441
+ * Register an existing mint with the CompressedToken program
1442
+ *
1443
+ * @param rpc RPC to use
1444
+ * @param payer Payer of the transaction and initialization fees
1445
+ * @param mintAuthority Account or multisig that will control minting. Is signer.
1446
+ * @param mintAddress Address of the existing mint
1447
+ * @param confirmOptions Options for confirming the transaction
1448
+ *
1449
+ * @return transaction signature
1450
+ */
1451
+ declare function registerMint(rpc: Rpc, payer: Signer, mintAuthority: Signer, mintAddress: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
1452
+
1240
1453
  /**
1241
1454
  * Transfer compressed tokens from one owner to another
1242
1455
  *
@@ -1267,4 +1480,4 @@ declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTok
1267
1480
  totalLamports: BN | null
1268
1481
  ];
1269
1482
 
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 };
1483
+ export { type ApproveAndMintToParams, CPI_AUTHORITY_SEED, type CompressedTokenInstructionDataInvoke, CompressedTokenProgram, type CreateMintParams, IDL, type InputTokenDataWithContext, type LightCompressedToken, MINT_AUTHORITY_SEED, type MintToParams, POOL_SEED, type PackCompressedTokenAccountsParams, type RegisterMintParams, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, type TokenData, type TokenTransferOutputData, type TransferParams, approveAndMintTo, compress, createDecompressOutputState, createMint, createTransferOutputState, decompress, mintTo, packCompressedTokenAccounts, parseTokenData, registerMint, selectMinCompressedTokenAccountsForTransfer, sumUpTokenAmount, transfer, validateSameTokenOwner };