@lightprotocol/compressed-token 0.3.4 → 0.4.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.
- package/dist/cjs/browser/index.cjs +229 -63
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +229 -63
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/es/browser/index.js +230 -64
- package/dist/es/browser/index.js.map +1 -1
- package/dist/types/index.d.ts +234 -31
- package/package.json +5 -5
|
@@ -11,16 +11,17 @@ const IDL = {
|
|
|
11
11
|
{
|
|
12
12
|
name: 'createTokenPool',
|
|
13
13
|
docs: [
|
|
14
|
-
'This instruction
|
|
15
|
-
'token
|
|
16
|
-
'
|
|
17
|
-
'
|
|
14
|
+
'This instruction creates a token pool for a given mint. Every spl mint',
|
|
15
|
+
'can have one token pool. When a token is compressed the tokens are',
|
|
16
|
+
'transferrred to the token pool, and their compressed equivalent is',
|
|
17
|
+
'minted into a Merkle tree.',
|
|
18
18
|
],
|
|
19
19
|
accounts: [
|
|
20
20
|
{
|
|
21
21
|
name: 'feePayer',
|
|
22
22
|
isMut: true,
|
|
23
23
|
isSigner: true,
|
|
24
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
24
25
|
},
|
|
25
26
|
{
|
|
26
27
|
name: 'tokenPoolPda',
|
|
@@ -56,13 +57,17 @@ const IDL = {
|
|
|
56
57
|
'Mints tokens from an spl token mint to a list of compressed accounts.',
|
|
57
58
|
'Minted tokens are transferred to a pool account owned by the compressed',
|
|
58
59
|
'token program. The instruction creates one compressed output account for',
|
|
59
|
-
'every amount and pubkey input pair
|
|
60
|
+
'every amount and pubkey input pair. A constant amount of lamports can be',
|
|
61
|
+
'transferred to each output account to enable. A use case to add lamports',
|
|
62
|
+
'to a compressed token account is to prevent spam. This is the only way',
|
|
63
|
+
'to add lamports to a compressed token account.',
|
|
60
64
|
],
|
|
61
65
|
accounts: [
|
|
62
66
|
{
|
|
63
67
|
name: 'feePayer',
|
|
64
68
|
isMut: true,
|
|
65
69
|
isSigner: true,
|
|
70
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
66
71
|
},
|
|
67
72
|
{
|
|
68
73
|
name: 'authority',
|
|
@@ -83,6 +88,9 @@ const IDL = {
|
|
|
83
88
|
name: 'tokenPoolPda',
|
|
84
89
|
isMut: true,
|
|
85
90
|
isSigner: false,
|
|
91
|
+
docs: [
|
|
92
|
+
'account to a token account of a different mint will fail',
|
|
93
|
+
],
|
|
86
94
|
},
|
|
87
95
|
{
|
|
88
96
|
name: 'tokenProgram',
|
|
@@ -103,6 +111,7 @@ const IDL = {
|
|
|
103
111
|
name: 'noopProgram',
|
|
104
112
|
isMut: false,
|
|
105
113
|
isSigner: false,
|
|
114
|
+
docs: ['programs'],
|
|
106
115
|
},
|
|
107
116
|
{
|
|
108
117
|
name: 'accountCompressionAuthority',
|
|
@@ -129,6 +138,12 @@ const IDL = {
|
|
|
129
138
|
isMut: false,
|
|
130
139
|
isSigner: false,
|
|
131
140
|
},
|
|
141
|
+
{
|
|
142
|
+
name: 'solPoolPda',
|
|
143
|
+
isMut: true,
|
|
144
|
+
isSigner: false,
|
|
145
|
+
isOptional: true,
|
|
146
|
+
},
|
|
132
147
|
],
|
|
133
148
|
args: [
|
|
134
149
|
{
|
|
@@ -143,20 +158,42 @@ const IDL = {
|
|
|
143
158
|
vec: 'u64',
|
|
144
159
|
},
|
|
145
160
|
},
|
|
161
|
+
{
|
|
162
|
+
name: 'lamports',
|
|
163
|
+
type: {
|
|
164
|
+
option: 'u64',
|
|
165
|
+
},
|
|
166
|
+
},
|
|
146
167
|
],
|
|
147
168
|
},
|
|
148
169
|
{
|
|
149
170
|
name: 'transfer',
|
|
171
|
+
docs: [
|
|
172
|
+
'Transfers compressed tokens from one account to another. All accounts',
|
|
173
|
+
'must be of the same mint. Additional spl tokens can be compressed or',
|
|
174
|
+
'decompressed. In one transaction only compression or decompression is',
|
|
175
|
+
'possible. Lamports can be transferred alongside tokens. If output token',
|
|
176
|
+
'accounts specify less lamports than inputs the remaining lamports are',
|
|
177
|
+
'transferred to an output compressed account. Signer must be owner or',
|
|
178
|
+
'delegate. If a delegated token account is transferred the delegate is',
|
|
179
|
+
'not preserved.',
|
|
180
|
+
],
|
|
150
181
|
accounts: [
|
|
151
182
|
{
|
|
152
183
|
name: 'feePayer',
|
|
153
184
|
isMut: true,
|
|
154
185
|
isSigner: true,
|
|
186
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
155
187
|
},
|
|
156
188
|
{
|
|
157
189
|
name: 'authority',
|
|
158
190
|
isMut: false,
|
|
159
191
|
isSigner: true,
|
|
192
|
+
docs: [
|
|
193
|
+
'Authority is verified through proof since both owner and delegate',
|
|
194
|
+
'are included in the token data hash, which is a public input to the',
|
|
195
|
+
'validity proof.',
|
|
196
|
+
],
|
|
160
197
|
},
|
|
161
198
|
{
|
|
162
199
|
name: 'cpiAuthorityPda',
|
|
@@ -192,6 +229,10 @@ const IDL = {
|
|
|
192
229
|
name: 'selfProgram',
|
|
193
230
|
isMut: false,
|
|
194
231
|
isSigner: false,
|
|
232
|
+
docs: [
|
|
233
|
+
'(different program) checked in light system program to derive',
|
|
234
|
+
'cpi_authority_pda and check that this program is the signer of the cpi.',
|
|
235
|
+
],
|
|
195
236
|
},
|
|
196
237
|
{
|
|
197
238
|
name: 'tokenPoolPda',
|
|
@@ -226,16 +267,30 @@ const IDL = {
|
|
|
226
267
|
},
|
|
227
268
|
{
|
|
228
269
|
name: 'approve',
|
|
270
|
+
docs: [
|
|
271
|
+
'Delegates an amount to a delegate. A compressed token account is either',
|
|
272
|
+
'completely delegated or not. Prior delegates are not preserved. Cannot',
|
|
273
|
+
'be called by a delegate.',
|
|
274
|
+
'The instruction creates two output accounts:',
|
|
275
|
+
'1. one account with delegated amount',
|
|
276
|
+
'2. one account with remaining(change) amount',
|
|
277
|
+
],
|
|
229
278
|
accounts: [
|
|
230
279
|
{
|
|
231
280
|
name: 'feePayer',
|
|
232
281
|
isMut: true,
|
|
233
282
|
isSigner: true,
|
|
283
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
234
284
|
},
|
|
235
285
|
{
|
|
236
286
|
name: 'authority',
|
|
237
287
|
isMut: false,
|
|
238
288
|
isSigner: true,
|
|
289
|
+
docs: [
|
|
290
|
+
'Authority is verified through proof since both owner and delegate',
|
|
291
|
+
'are included in the token data hash, which is a public input to the',
|
|
292
|
+
'validity proof.',
|
|
293
|
+
],
|
|
239
294
|
},
|
|
240
295
|
{
|
|
241
296
|
name: 'cpiAuthorityPda',
|
|
@@ -271,6 +326,10 @@ const IDL = {
|
|
|
271
326
|
name: 'selfProgram',
|
|
272
327
|
isMut: false,
|
|
273
328
|
isSigner: false,
|
|
329
|
+
docs: [
|
|
330
|
+
'(different program) checked in light system program to derive',
|
|
331
|
+
'cpi_authority_pda and check that this program is the signer of the cpi.',
|
|
332
|
+
],
|
|
274
333
|
},
|
|
275
334
|
{
|
|
276
335
|
name: 'systemProgram',
|
|
@@ -287,16 +346,26 @@ const IDL = {
|
|
|
287
346
|
},
|
|
288
347
|
{
|
|
289
348
|
name: 'revoke',
|
|
349
|
+
docs: [
|
|
350
|
+
'Revokes a delegation. The instruction merges all inputs into one output',
|
|
351
|
+
'account. Cannot be called by a delegate. Delegates are not preserved.',
|
|
352
|
+
],
|
|
290
353
|
accounts: [
|
|
291
354
|
{
|
|
292
355
|
name: 'feePayer',
|
|
293
356
|
isMut: true,
|
|
294
357
|
isSigner: true,
|
|
358
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
295
359
|
},
|
|
296
360
|
{
|
|
297
361
|
name: 'authority',
|
|
298
362
|
isMut: false,
|
|
299
363
|
isSigner: true,
|
|
364
|
+
docs: [
|
|
365
|
+
'Authority is verified through proof since both owner and delegate',
|
|
366
|
+
'are included in the token data hash, which is a public input to the',
|
|
367
|
+
'validity proof.',
|
|
368
|
+
],
|
|
300
369
|
},
|
|
301
370
|
{
|
|
302
371
|
name: 'cpiAuthorityPda',
|
|
@@ -332,6 +401,10 @@ const IDL = {
|
|
|
332
401
|
name: 'selfProgram',
|
|
333
402
|
isMut: false,
|
|
334
403
|
isSigner: false,
|
|
404
|
+
docs: [
|
|
405
|
+
'(different program) checked in light system program to derive',
|
|
406
|
+
'cpi_authority_pda and check that this program is the signer of the cpi.',
|
|
407
|
+
],
|
|
335
408
|
},
|
|
336
409
|
{
|
|
337
410
|
name: 'systemProgram',
|
|
@@ -348,11 +421,16 @@ const IDL = {
|
|
|
348
421
|
},
|
|
349
422
|
{
|
|
350
423
|
name: 'freeze',
|
|
424
|
+
docs: [
|
|
425
|
+
'Freezes compressed token accounts. Inputs must not be frozen. Creates as',
|
|
426
|
+
'many outputs as inputs. Balances and delegates are preserved.',
|
|
427
|
+
],
|
|
351
428
|
accounts: [
|
|
352
429
|
{
|
|
353
430
|
name: 'feePayer',
|
|
354
431
|
isMut: true,
|
|
355
432
|
isSigner: true,
|
|
433
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
356
434
|
},
|
|
357
435
|
{
|
|
358
436
|
name: 'authority',
|
|
@@ -393,6 +471,10 @@ const IDL = {
|
|
|
393
471
|
name: 'selfProgram',
|
|
394
472
|
isMut: false,
|
|
395
473
|
isSigner: false,
|
|
474
|
+
docs: [
|
|
475
|
+
'(different program) checked in light system program to derive',
|
|
476
|
+
'cpi_authority_pda and check that this program is the signer of the cpi.',
|
|
477
|
+
],
|
|
396
478
|
},
|
|
397
479
|
{
|
|
398
480
|
name: 'systemProgram',
|
|
@@ -414,11 +496,16 @@ const IDL = {
|
|
|
414
496
|
},
|
|
415
497
|
{
|
|
416
498
|
name: 'thaw',
|
|
499
|
+
docs: [
|
|
500
|
+
'Thaws frozen compressed token accounts. Inputs must be frozen. Creates',
|
|
501
|
+
'as many outputs as inputs. Balances and delegates are preserved.',
|
|
502
|
+
],
|
|
417
503
|
accounts: [
|
|
418
504
|
{
|
|
419
505
|
name: 'feePayer',
|
|
420
506
|
isMut: true,
|
|
421
507
|
isSigner: true,
|
|
508
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
422
509
|
},
|
|
423
510
|
{
|
|
424
511
|
name: 'authority',
|
|
@@ -459,6 +546,10 @@ const IDL = {
|
|
|
459
546
|
name: 'selfProgram',
|
|
460
547
|
isMut: false,
|
|
461
548
|
isSigner: false,
|
|
549
|
+
docs: [
|
|
550
|
+
'(different program) checked in light system program to derive',
|
|
551
|
+
'cpi_authority_pda and check that this program is the signer of the cpi.',
|
|
552
|
+
],
|
|
462
553
|
},
|
|
463
554
|
{
|
|
464
555
|
name: 'systemProgram',
|
|
@@ -480,22 +571,48 @@ const IDL = {
|
|
|
480
571
|
},
|
|
481
572
|
{
|
|
482
573
|
name: 'burn',
|
|
574
|
+
docs: [
|
|
575
|
+
'Burns compressed tokens and spl tokens from the pool account. Delegates',
|
|
576
|
+
'can burn tokens. The output compressed token account remains delegated.',
|
|
577
|
+
'Creates one output compressed token account.',
|
|
578
|
+
],
|
|
483
579
|
accounts: [
|
|
484
580
|
{
|
|
485
581
|
name: 'feePayer',
|
|
486
582
|
isMut: true,
|
|
487
583
|
isSigner: true,
|
|
584
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
488
585
|
},
|
|
489
586
|
{
|
|
490
587
|
name: 'authority',
|
|
491
588
|
isMut: false,
|
|
492
589
|
isSigner: true,
|
|
590
|
+
docs: [
|
|
591
|
+
'Authority is verified through proof since both owner and delegate',
|
|
592
|
+
'are included in the token data hash, which is a public input to the',
|
|
593
|
+
'validity proof.',
|
|
594
|
+
],
|
|
493
595
|
},
|
|
494
596
|
{
|
|
495
597
|
name: 'cpiAuthorityPda',
|
|
496
598
|
isMut: false,
|
|
497
599
|
isSigner: false,
|
|
498
600
|
},
|
|
601
|
+
{
|
|
602
|
+
name: 'mint',
|
|
603
|
+
isMut: true,
|
|
604
|
+
isSigner: false,
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
name: 'tokenPoolPda',
|
|
608
|
+
isMut: true,
|
|
609
|
+
isSigner: false,
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
name: 'tokenProgram',
|
|
613
|
+
isMut: false,
|
|
614
|
+
isSigner: false,
|
|
615
|
+
},
|
|
499
616
|
{
|
|
500
617
|
name: 'lightSystemProgram',
|
|
501
618
|
isMut: false,
|
|
@@ -551,11 +668,17 @@ const IDL = {
|
|
|
551
668
|
name: 'feePayer',
|
|
552
669
|
isMut: true,
|
|
553
670
|
isSigner: true,
|
|
671
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
554
672
|
},
|
|
555
673
|
{
|
|
556
674
|
name: 'authority',
|
|
557
675
|
isMut: false,
|
|
558
676
|
isSigner: true,
|
|
677
|
+
docs: [
|
|
678
|
+
'Authority is verified through proof since both owner and delegate',
|
|
679
|
+
'are included in the token data hash, which is a public input to the',
|
|
680
|
+
'validity proof.',
|
|
681
|
+
],
|
|
559
682
|
},
|
|
560
683
|
{
|
|
561
684
|
name: 'cpiAuthorityPda',
|
|
@@ -591,6 +714,10 @@ const IDL = {
|
|
|
591
714
|
name: 'selfProgram',
|
|
592
715
|
isMut: false,
|
|
593
716
|
isSigner: false,
|
|
717
|
+
docs: [
|
|
718
|
+
'(different program) checked in light system program to derive',
|
|
719
|
+
'cpi_authority_pda and check that this program is the signer of the cpi.',
|
|
720
|
+
],
|
|
594
721
|
},
|
|
595
722
|
{
|
|
596
723
|
name: 'tokenPoolPda',
|
|
@@ -632,24 +759,6 @@ const IDL = {
|
|
|
632
759
|
],
|
|
633
760
|
},
|
|
634
761
|
],
|
|
635
|
-
accounts: [
|
|
636
|
-
{
|
|
637
|
-
name: 'RegisteredProgram',
|
|
638
|
-
type: {
|
|
639
|
-
kind: 'struct',
|
|
640
|
-
fields: [
|
|
641
|
-
{
|
|
642
|
-
name: 'registeredProgramId',
|
|
643
|
-
type: 'publicKey',
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
name: 'groupAuthorityPda',
|
|
647
|
-
type: 'publicKey',
|
|
648
|
-
},
|
|
649
|
-
],
|
|
650
|
-
},
|
|
651
|
-
},
|
|
652
|
-
],
|
|
653
762
|
types: [
|
|
654
763
|
{
|
|
655
764
|
name: 'AccessMetadata',
|
|
@@ -664,7 +773,7 @@ const IDL = {
|
|
|
664
773
|
{
|
|
665
774
|
name: 'programOwner',
|
|
666
775
|
docs: [
|
|
667
|
-
'
|
|
776
|
+
'Program owner of the Merkle tree. This will be used for program owned Merkle trees.',
|
|
668
777
|
],
|
|
669
778
|
type: 'publicKey',
|
|
670
779
|
},
|
|
@@ -818,9 +927,9 @@ const IDL = {
|
|
|
818
927
|
{
|
|
819
928
|
name: 'delegatedTransfer',
|
|
820
929
|
docs: [
|
|
821
|
-
'
|
|
930
|
+
'Is required if the signer is delegate,',
|
|
931
|
+
'-> delegate is authority account,',
|
|
822
932
|
'owner = Some(owner) is the owner of the token account.',
|
|
823
|
-
'Is set if the signer is delegate',
|
|
824
933
|
],
|
|
825
934
|
type: {
|
|
826
935
|
option: {
|
|
@@ -862,11 +971,20 @@ const IDL = {
|
|
|
862
971
|
},
|
|
863
972
|
},
|
|
864
973
|
},
|
|
974
|
+
{
|
|
975
|
+
name: 'lamportsChangeAccountMerkleTreeIndex',
|
|
976
|
+
type: {
|
|
977
|
+
option: 'u8',
|
|
978
|
+
},
|
|
979
|
+
},
|
|
865
980
|
],
|
|
866
981
|
},
|
|
867
982
|
},
|
|
868
983
|
{
|
|
869
984
|
name: 'DelegatedTransfer',
|
|
985
|
+
docs: [
|
|
986
|
+
'Struct to provide the owner when the delegate is signer of the transaction.',
|
|
987
|
+
],
|
|
870
988
|
type: {
|
|
871
989
|
kind: 'struct',
|
|
872
990
|
fields: [
|
|
@@ -876,7 +994,15 @@ const IDL = {
|
|
|
876
994
|
},
|
|
877
995
|
{
|
|
878
996
|
name: 'delegateChangeAccountIndex',
|
|
879
|
-
|
|
997
|
+
docs: [
|
|
998
|
+
'Index of change compressed account in output compressed accounts. In',
|
|
999
|
+
"case that the delegate didn't spend the complete delegated compressed",
|
|
1000
|
+
'account balance the change compressed account will be delegated to her',
|
|
1001
|
+
'as well.',
|
|
1002
|
+
],
|
|
1003
|
+
type: {
|
|
1004
|
+
option: 'u8',
|
|
1005
|
+
},
|
|
880
1006
|
},
|
|
881
1007
|
],
|
|
882
1008
|
},
|
|
@@ -912,6 +1038,15 @@ const IDL = {
|
|
|
912
1038
|
option: 'u64',
|
|
913
1039
|
},
|
|
914
1040
|
},
|
|
1041
|
+
{
|
|
1042
|
+
name: 'tlv',
|
|
1043
|
+
docs: [
|
|
1044
|
+
'Placeholder for TokenExtension tlv data (unimplemented)',
|
|
1045
|
+
],
|
|
1046
|
+
type: {
|
|
1047
|
+
option: 'bytes',
|
|
1048
|
+
},
|
|
1049
|
+
},
|
|
915
1050
|
],
|
|
916
1051
|
},
|
|
917
1052
|
},
|
|
@@ -1173,6 +1308,18 @@ const IDL = {
|
|
|
1173
1308
|
name: 'leafIndex',
|
|
1174
1309
|
type: 'u32',
|
|
1175
1310
|
},
|
|
1311
|
+
{
|
|
1312
|
+
name: 'queueIndex',
|
|
1313
|
+
docs: [
|
|
1314
|
+
'Index of leaf in queue. Placeholder of batched Merkle tree updates',
|
|
1315
|
+
'currently unimplemented.',
|
|
1316
|
+
],
|
|
1317
|
+
type: {
|
|
1318
|
+
option: {
|
|
1319
|
+
defined: 'QueueIndex',
|
|
1320
|
+
},
|
|
1321
|
+
},
|
|
1322
|
+
},
|
|
1176
1323
|
],
|
|
1177
1324
|
},
|
|
1178
1325
|
},
|
|
@@ -1199,6 +1346,15 @@ const IDL = {
|
|
|
1199
1346
|
name: 'merkleTreeIndex',
|
|
1200
1347
|
type: 'u8',
|
|
1201
1348
|
},
|
|
1349
|
+
{
|
|
1350
|
+
name: 'tlv',
|
|
1351
|
+
docs: [
|
|
1352
|
+
'Placeholder for TokenExtension tlv data (unimplemented)',
|
|
1353
|
+
],
|
|
1354
|
+
type: {
|
|
1355
|
+
option: 'bytes',
|
|
1356
|
+
},
|
|
1357
|
+
},
|
|
1202
1358
|
],
|
|
1203
1359
|
},
|
|
1204
1360
|
},
|
|
@@ -1276,6 +1432,24 @@ const IDL = {
|
|
|
1276
1432
|
],
|
|
1277
1433
|
},
|
|
1278
1434
|
},
|
|
1435
|
+
{
|
|
1436
|
+
name: 'QueueIndex',
|
|
1437
|
+
type: {
|
|
1438
|
+
kind: 'struct',
|
|
1439
|
+
fields: [
|
|
1440
|
+
{
|
|
1441
|
+
name: 'queueId',
|
|
1442
|
+
docs: ['Id of queue in queue account.'],
|
|
1443
|
+
type: 'u8',
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
name: 'index',
|
|
1447
|
+
docs: ['Index of compressed account hash in queue.'],
|
|
1448
|
+
type: 'u16',
|
|
1449
|
+
},
|
|
1450
|
+
],
|
|
1451
|
+
},
|
|
1452
|
+
},
|
|
1279
1453
|
{
|
|
1280
1454
|
name: 'RolloverMetadata',
|
|
1281
1455
|
type: {
|
|
@@ -1362,6 +1536,15 @@ const IDL = {
|
|
|
1362
1536
|
defined: 'AccountState',
|
|
1363
1537
|
},
|
|
1364
1538
|
},
|
|
1539
|
+
{
|
|
1540
|
+
name: 'tlv',
|
|
1541
|
+
docs: [
|
|
1542
|
+
'Placeholder for TokenExtension tlv data (unimplemented)',
|
|
1543
|
+
],
|
|
1544
|
+
type: {
|
|
1545
|
+
option: 'bytes',
|
|
1546
|
+
},
|
|
1547
|
+
},
|
|
1365
1548
|
],
|
|
1366
1549
|
},
|
|
1367
1550
|
},
|
|
@@ -1416,11 +1599,13 @@ function packCompressedTokenAccounts(params) {
|
|
|
1416
1599
|
merkleTreePubkeyIndex,
|
|
1417
1600
|
nullifierQueuePubkeyIndex,
|
|
1418
1601
|
leafIndex: account.compressedAccount.leafIndex,
|
|
1602
|
+
queueIndex: null,
|
|
1419
1603
|
},
|
|
1420
1604
|
rootIndex: rootIndices[index],
|
|
1421
1605
|
lamports: account.compressedAccount.lamports.eq(stateless_js.bn(0))
|
|
1422
1606
|
? null
|
|
1423
1607
|
: account.compressedAccount.lamports,
|
|
1608
|
+
tlv: null,
|
|
1424
1609
|
});
|
|
1425
1610
|
});
|
|
1426
1611
|
/// pack output state trees
|
|
@@ -1436,6 +1621,7 @@ function packCompressedTokenAccounts(params) {
|
|
|
1436
1621
|
? null
|
|
1437
1622
|
: tokenTransferOutputs[index].lamports,
|
|
1438
1623
|
merkleTreeIndex,
|
|
1624
|
+
tlv: null,
|
|
1439
1625
|
});
|
|
1440
1626
|
});
|
|
1441
1627
|
// to meta
|
|
@@ -6008,33 +6194,6 @@ function addSigners(keys, ownerOrAuthority, multiSigners) {
|
|
|
6008
6194
|
return keys;
|
|
6009
6195
|
}
|
|
6010
6196
|
|
|
6011
|
-
/** TODO: docs */
|
|
6012
|
-
const approveInstructionData = struct([u8('instruction'), u64('amount')]);
|
|
6013
|
-
/**
|
|
6014
|
-
* Construct an Approve instruction
|
|
6015
|
-
*
|
|
6016
|
-
* @param account Account to set the delegate for
|
|
6017
|
-
* @param delegate Account authorized to transfer tokens from the account
|
|
6018
|
-
* @param owner Owner of the account
|
|
6019
|
-
* @param amount Maximum number of tokens the delegate may transfer
|
|
6020
|
-
* @param multiSigners Signing accounts if `owner` is a multisig
|
|
6021
|
-
* @param programId SPL Token program account
|
|
6022
|
-
*
|
|
6023
|
-
* @return Instruction to add to a transaction
|
|
6024
|
-
*/
|
|
6025
|
-
function createApproveInstruction(account, delegate, owner, amount, multiSigners = [], programId = TOKEN_PROGRAM_ID) {
|
|
6026
|
-
const keys = addSigners([
|
|
6027
|
-
{ pubkey: account, isSigner: false, isWritable: true },
|
|
6028
|
-
{ pubkey: delegate, isSigner: false, isWritable: false },
|
|
6029
|
-
], owner, multiSigners);
|
|
6030
|
-
const data = Buffer.alloc(approveInstructionData.span);
|
|
6031
|
-
approveInstructionData.encode({
|
|
6032
|
-
instruction: TokenInstruction.Approve,
|
|
6033
|
-
amount: BigInt(amount),
|
|
6034
|
-
}, data);
|
|
6035
|
-
return new web3_js.TransactionInstruction({ keys, programId, data });
|
|
6036
|
-
}
|
|
6037
|
-
|
|
6038
6197
|
var AccountType;
|
|
6039
6198
|
(function (AccountType) {
|
|
6040
6199
|
AccountType[AccountType["Uninitialized"] = 0] = "Uninitialized";
|
|
@@ -6358,6 +6517,7 @@ function createTransferOutputState(inputCompressedTokenAccounts, toAddress, amou
|
|
|
6358
6517
|
owner: toAddress,
|
|
6359
6518
|
amount,
|
|
6360
6519
|
lamports: inputLamports,
|
|
6520
|
+
tlv: null,
|
|
6361
6521
|
},
|
|
6362
6522
|
];
|
|
6363
6523
|
}
|
|
@@ -6369,11 +6529,13 @@ function createTransferOutputState(inputCompressedTokenAccounts, toAddress, amou
|
|
|
6369
6529
|
owner: inputCompressedTokenAccounts[0].parsed.owner,
|
|
6370
6530
|
amount: changeAmount,
|
|
6371
6531
|
lamports: inputLamports,
|
|
6532
|
+
tlv: null,
|
|
6372
6533
|
},
|
|
6373
6534
|
{
|
|
6374
6535
|
owner: toAddress,
|
|
6375
6536
|
amount,
|
|
6376
6537
|
lamports: stateless_js.bn(0),
|
|
6538
|
+
tlv: null,
|
|
6377
6539
|
},
|
|
6378
6540
|
];
|
|
6379
6541
|
return outputCompressedAccounts;
|
|
@@ -6402,6 +6564,7 @@ function createDecompressOutputState(inputCompressedTokenAccounts, amount) {
|
|
|
6402
6564
|
owner: inputCompressedTokenAccounts[0].parsed.owner,
|
|
6403
6565
|
amount: changeAmount,
|
|
6404
6566
|
lamports: inputLamports,
|
|
6567
|
+
tlv: null,
|
|
6405
6568
|
},
|
|
6406
6569
|
];
|
|
6407
6570
|
return tokenTransferOutputs;
|
|
@@ -6495,7 +6658,7 @@ class CompressedTokenProgram {
|
|
|
6495
6658
|
const amounts = stateless_js.toArray(amount).map(amount => stateless_js.bn(amount));
|
|
6496
6659
|
const toPubkeys = stateless_js.toArray(toPubkey);
|
|
6497
6660
|
const instruction = await this.program.methods
|
|
6498
|
-
.mintTo(toPubkeys, amounts)
|
|
6661
|
+
.mintTo(toPubkeys, amounts, null)
|
|
6499
6662
|
.accounts({
|
|
6500
6663
|
feePayer,
|
|
6501
6664
|
authority,
|
|
@@ -6510,6 +6673,7 @@ class CompressedTokenProgram {
|
|
|
6510
6673
|
accountCompressionProgram: systemKeys.accountCompressionProgram,
|
|
6511
6674
|
merkleTree: merkleTree !== null && merkleTree !== void 0 ? merkleTree : stateless_js.defaultTestStateTreeAccounts().merkleTree,
|
|
6512
6675
|
selfProgram: this.programId,
|
|
6676
|
+
solPoolPda: null,
|
|
6513
6677
|
})
|
|
6514
6678
|
.instruction();
|
|
6515
6679
|
return instruction;
|
|
@@ -6524,7 +6688,7 @@ class CompressedTokenProgram {
|
|
|
6524
6688
|
/// 1. Mint to existing ATA of mintAuthority.
|
|
6525
6689
|
const splMintToInstruction = createMintToInstruction(mint, authorityTokenAccount, authority, amount);
|
|
6526
6690
|
/// 2. Compress from mint authority ATA to recipient compressed account
|
|
6527
|
-
const
|
|
6691
|
+
const compressInstruction = await this.compress({
|
|
6528
6692
|
payer: feePayer,
|
|
6529
6693
|
owner: authority,
|
|
6530
6694
|
source: authorityTokenAccount,
|
|
@@ -6533,7 +6697,7 @@ class CompressedTokenProgram {
|
|
|
6533
6697
|
amount: params.amount,
|
|
6534
6698
|
outputStateTree: merkleTree,
|
|
6535
6699
|
});
|
|
6536
|
-
return [splMintToInstruction,
|
|
6700
|
+
return [splMintToInstruction, compressInstruction];
|
|
6537
6701
|
}
|
|
6538
6702
|
/**
|
|
6539
6703
|
* Construct transfer instruction for compressed tokens
|
|
@@ -6557,6 +6721,7 @@ class CompressedTokenProgram {
|
|
|
6557
6721
|
compressOrDecompressAmount: null,
|
|
6558
6722
|
isCompress: false,
|
|
6559
6723
|
cpiContext: null,
|
|
6724
|
+
lamportsChangeAccountMerkleTreeIndex: null,
|
|
6560
6725
|
};
|
|
6561
6726
|
const encodedData = this.program.coder.types.encode('CompressedTokenInstructionDataTransfer', data);
|
|
6562
6727
|
const { accountCompressionAuthority, noopProgram, registeredProgramPda, accountCompressionProgram, } = stateless_js.defaultStaticAccountsStruct();
|
|
@@ -6581,8 +6746,8 @@ class CompressedTokenProgram {
|
|
|
6581
6746
|
return instruction;
|
|
6582
6747
|
}
|
|
6583
6748
|
/**
|
|
6584
|
-
* Construct
|
|
6585
|
-
* @returns
|
|
6749
|
+
* Construct compress instruction
|
|
6750
|
+
* @returns compressInstruction
|
|
6586
6751
|
*/
|
|
6587
6752
|
static async compress(params) {
|
|
6588
6753
|
const { payer, owner, source, toAddress, mint, outputStateTree } = params;
|
|
@@ -6592,6 +6757,7 @@ class CompressedTokenProgram {
|
|
|
6592
6757
|
owner: toAddress,
|
|
6593
6758
|
amount,
|
|
6594
6759
|
lamports: stateless_js.bn(0),
|
|
6760
|
+
tlv: null,
|
|
6595
6761
|
},
|
|
6596
6762
|
];
|
|
6597
6763
|
const { inputTokenDataWithContext, packedOutputTokenData, remainingAccountMetas, } = packCompressedTokenAccounts({
|
|
@@ -6609,10 +6775,10 @@ class CompressedTokenProgram {
|
|
|
6609
6775
|
compressOrDecompressAmount: amount,
|
|
6610
6776
|
isCompress: true,
|
|
6611
6777
|
cpiContext: null,
|
|
6778
|
+
lamportsChangeAccountMerkleTreeIndex: null,
|
|
6612
6779
|
};
|
|
6613
6780
|
const encodedData = this.program.coder.types.encode('CompressedTokenInstructionDataTransfer', data);
|
|
6614
6781
|
const { accountCompressionAuthority, noopProgram, registeredProgramPda, accountCompressionProgram, } = stateless_js.defaultStaticAccountsStruct();
|
|
6615
|
-
const approveInstruction = createApproveInstruction(source, this.deriveCpiAuthorityPda, owner, BigInt(amount.toString()));
|
|
6616
6782
|
const instruction = await this.program.methods
|
|
6617
6783
|
.transfer(encodedData)
|
|
6618
6784
|
.accounts({
|
|
@@ -6631,7 +6797,7 @@ class CompressedTokenProgram {
|
|
|
6631
6797
|
})
|
|
6632
6798
|
.remainingAccounts(remainingAccountMetas)
|
|
6633
6799
|
.instruction();
|
|
6634
|
-
return
|
|
6800
|
+
return instruction;
|
|
6635
6801
|
}
|
|
6636
6802
|
/**
|
|
6637
6803
|
* Construct decompress instruction
|
|
@@ -6657,6 +6823,7 @@ class CompressedTokenProgram {
|
|
|
6657
6823
|
compressOrDecompressAmount: amount,
|
|
6658
6824
|
isCompress: false,
|
|
6659
6825
|
cpiContext: null,
|
|
6826
|
+
lamportsChangeAccountMerkleTreeIndex: null,
|
|
6660
6827
|
};
|
|
6661
6828
|
const encodedData = this.program.coder.types.encode('CompressedTokenInstructionDataTransfer', data);
|
|
6662
6829
|
const { accountCompressionAuthority, noopProgram, registeredProgramPda, accountCompressionProgram, } = stateless_js.defaultStaticAccountsStruct();
|
|
@@ -6743,7 +6910,7 @@ async function approveAndMintTo(rpc, payer, mint, destination, authority, amount
|
|
|
6743
6910
|
*/
|
|
6744
6911
|
async function compress(rpc, payer, mint, amount, owner, sourceTokenAccount, toAddress, merkleTree, confirmOptions) {
|
|
6745
6912
|
amount = stateless_js.bn(amount);
|
|
6746
|
-
const
|
|
6913
|
+
const compressIx = await CompressedTokenProgram.compress({
|
|
6747
6914
|
payer: payer.publicKey,
|
|
6748
6915
|
owner: owner.publicKey,
|
|
6749
6916
|
source: sourceTokenAccount,
|
|
@@ -6758,7 +6925,6 @@ async function compress(rpc, payer, mint, amount, owner, sourceTokenAccount, toA
|
|
|
6758
6925
|
web3_js.ComputeBudgetProgram.setComputeUnitLimit({
|
|
6759
6926
|
units: 1000000,
|
|
6760
6927
|
}),
|
|
6761
|
-
approveIx,
|
|
6762
6928
|
compressIx,
|
|
6763
6929
|
], payer, blockhashCtx.blockhash, additionalSigners);
|
|
6764
6930
|
const txId = await stateless_js.sendAndConfirmTx(rpc, signedTx, confirmOptions, blockhashCtx);
|