@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
package/dist/cjs/node/index.cjs
CHANGED
|
@@ -12,16 +12,17 @@ const IDL = {
|
|
|
12
12
|
{
|
|
13
13
|
name: 'createTokenPool',
|
|
14
14
|
docs: [
|
|
15
|
-
'This instruction
|
|
16
|
-
'token
|
|
17
|
-
'
|
|
18
|
-
'
|
|
15
|
+
'This instruction creates a token pool for a given mint. Every spl mint',
|
|
16
|
+
'can have one token pool. When a token is compressed the tokens are',
|
|
17
|
+
'transferrred to the token pool, and their compressed equivalent is',
|
|
18
|
+
'minted into a Merkle tree.',
|
|
19
19
|
],
|
|
20
20
|
accounts: [
|
|
21
21
|
{
|
|
22
22
|
name: 'feePayer',
|
|
23
23
|
isMut: true,
|
|
24
24
|
isSigner: true,
|
|
25
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
25
26
|
},
|
|
26
27
|
{
|
|
27
28
|
name: 'tokenPoolPda',
|
|
@@ -57,13 +58,17 @@ const IDL = {
|
|
|
57
58
|
'Mints tokens from an spl token mint to a list of compressed accounts.',
|
|
58
59
|
'Minted tokens are transferred to a pool account owned by the compressed',
|
|
59
60
|
'token program. The instruction creates one compressed output account for',
|
|
60
|
-
'every amount and pubkey input pair
|
|
61
|
+
'every amount and pubkey input pair. A constant amount of lamports can be',
|
|
62
|
+
'transferred to each output account to enable. A use case to add lamports',
|
|
63
|
+
'to a compressed token account is to prevent spam. This is the only way',
|
|
64
|
+
'to add lamports to a compressed token account.',
|
|
61
65
|
],
|
|
62
66
|
accounts: [
|
|
63
67
|
{
|
|
64
68
|
name: 'feePayer',
|
|
65
69
|
isMut: true,
|
|
66
70
|
isSigner: true,
|
|
71
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
67
72
|
},
|
|
68
73
|
{
|
|
69
74
|
name: 'authority',
|
|
@@ -84,6 +89,9 @@ const IDL = {
|
|
|
84
89
|
name: 'tokenPoolPda',
|
|
85
90
|
isMut: true,
|
|
86
91
|
isSigner: false,
|
|
92
|
+
docs: [
|
|
93
|
+
'account to a token account of a different mint will fail',
|
|
94
|
+
],
|
|
87
95
|
},
|
|
88
96
|
{
|
|
89
97
|
name: 'tokenProgram',
|
|
@@ -104,6 +112,7 @@ const IDL = {
|
|
|
104
112
|
name: 'noopProgram',
|
|
105
113
|
isMut: false,
|
|
106
114
|
isSigner: false,
|
|
115
|
+
docs: ['programs'],
|
|
107
116
|
},
|
|
108
117
|
{
|
|
109
118
|
name: 'accountCompressionAuthority',
|
|
@@ -130,6 +139,12 @@ const IDL = {
|
|
|
130
139
|
isMut: false,
|
|
131
140
|
isSigner: false,
|
|
132
141
|
},
|
|
142
|
+
{
|
|
143
|
+
name: 'solPoolPda',
|
|
144
|
+
isMut: true,
|
|
145
|
+
isSigner: false,
|
|
146
|
+
isOptional: true,
|
|
147
|
+
},
|
|
133
148
|
],
|
|
134
149
|
args: [
|
|
135
150
|
{
|
|
@@ -144,20 +159,42 @@ const IDL = {
|
|
|
144
159
|
vec: 'u64',
|
|
145
160
|
},
|
|
146
161
|
},
|
|
162
|
+
{
|
|
163
|
+
name: 'lamports',
|
|
164
|
+
type: {
|
|
165
|
+
option: 'u64',
|
|
166
|
+
},
|
|
167
|
+
},
|
|
147
168
|
],
|
|
148
169
|
},
|
|
149
170
|
{
|
|
150
171
|
name: 'transfer',
|
|
172
|
+
docs: [
|
|
173
|
+
'Transfers compressed tokens from one account to another. All accounts',
|
|
174
|
+
'must be of the same mint. Additional spl tokens can be compressed or',
|
|
175
|
+
'decompressed. In one transaction only compression or decompression is',
|
|
176
|
+
'possible. Lamports can be transferred alongside tokens. If output token',
|
|
177
|
+
'accounts specify less lamports than inputs the remaining lamports are',
|
|
178
|
+
'transferred to an output compressed account. Signer must be owner or',
|
|
179
|
+
'delegate. If a delegated token account is transferred the delegate is',
|
|
180
|
+
'not preserved.',
|
|
181
|
+
],
|
|
151
182
|
accounts: [
|
|
152
183
|
{
|
|
153
184
|
name: 'feePayer',
|
|
154
185
|
isMut: true,
|
|
155
186
|
isSigner: true,
|
|
187
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
156
188
|
},
|
|
157
189
|
{
|
|
158
190
|
name: 'authority',
|
|
159
191
|
isMut: false,
|
|
160
192
|
isSigner: true,
|
|
193
|
+
docs: [
|
|
194
|
+
'Authority is verified through proof since both owner and delegate',
|
|
195
|
+
'are included in the token data hash, which is a public input to the',
|
|
196
|
+
'validity proof.',
|
|
197
|
+
],
|
|
161
198
|
},
|
|
162
199
|
{
|
|
163
200
|
name: 'cpiAuthorityPda',
|
|
@@ -193,6 +230,10 @@ const IDL = {
|
|
|
193
230
|
name: 'selfProgram',
|
|
194
231
|
isMut: false,
|
|
195
232
|
isSigner: false,
|
|
233
|
+
docs: [
|
|
234
|
+
'(different program) checked in light system program to derive',
|
|
235
|
+
'cpi_authority_pda and check that this program is the signer of the cpi.',
|
|
236
|
+
],
|
|
196
237
|
},
|
|
197
238
|
{
|
|
198
239
|
name: 'tokenPoolPda',
|
|
@@ -227,16 +268,30 @@ const IDL = {
|
|
|
227
268
|
},
|
|
228
269
|
{
|
|
229
270
|
name: 'approve',
|
|
271
|
+
docs: [
|
|
272
|
+
'Delegates an amount to a delegate. A compressed token account is either',
|
|
273
|
+
'completely delegated or not. Prior delegates are not preserved. Cannot',
|
|
274
|
+
'be called by a delegate.',
|
|
275
|
+
'The instruction creates two output accounts:',
|
|
276
|
+
'1. one account with delegated amount',
|
|
277
|
+
'2. one account with remaining(change) amount',
|
|
278
|
+
],
|
|
230
279
|
accounts: [
|
|
231
280
|
{
|
|
232
281
|
name: 'feePayer',
|
|
233
282
|
isMut: true,
|
|
234
283
|
isSigner: true,
|
|
284
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
235
285
|
},
|
|
236
286
|
{
|
|
237
287
|
name: 'authority',
|
|
238
288
|
isMut: false,
|
|
239
289
|
isSigner: true,
|
|
290
|
+
docs: [
|
|
291
|
+
'Authority is verified through proof since both owner and delegate',
|
|
292
|
+
'are included in the token data hash, which is a public input to the',
|
|
293
|
+
'validity proof.',
|
|
294
|
+
],
|
|
240
295
|
},
|
|
241
296
|
{
|
|
242
297
|
name: 'cpiAuthorityPda',
|
|
@@ -272,6 +327,10 @@ const IDL = {
|
|
|
272
327
|
name: 'selfProgram',
|
|
273
328
|
isMut: false,
|
|
274
329
|
isSigner: false,
|
|
330
|
+
docs: [
|
|
331
|
+
'(different program) checked in light system program to derive',
|
|
332
|
+
'cpi_authority_pda and check that this program is the signer of the cpi.',
|
|
333
|
+
],
|
|
275
334
|
},
|
|
276
335
|
{
|
|
277
336
|
name: 'systemProgram',
|
|
@@ -288,16 +347,26 @@ const IDL = {
|
|
|
288
347
|
},
|
|
289
348
|
{
|
|
290
349
|
name: 'revoke',
|
|
350
|
+
docs: [
|
|
351
|
+
'Revokes a delegation. The instruction merges all inputs into one output',
|
|
352
|
+
'account. Cannot be called by a delegate. Delegates are not preserved.',
|
|
353
|
+
],
|
|
291
354
|
accounts: [
|
|
292
355
|
{
|
|
293
356
|
name: 'feePayer',
|
|
294
357
|
isMut: true,
|
|
295
358
|
isSigner: true,
|
|
359
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
296
360
|
},
|
|
297
361
|
{
|
|
298
362
|
name: 'authority',
|
|
299
363
|
isMut: false,
|
|
300
364
|
isSigner: true,
|
|
365
|
+
docs: [
|
|
366
|
+
'Authority is verified through proof since both owner and delegate',
|
|
367
|
+
'are included in the token data hash, which is a public input to the',
|
|
368
|
+
'validity proof.',
|
|
369
|
+
],
|
|
301
370
|
},
|
|
302
371
|
{
|
|
303
372
|
name: 'cpiAuthorityPda',
|
|
@@ -333,6 +402,10 @@ const IDL = {
|
|
|
333
402
|
name: 'selfProgram',
|
|
334
403
|
isMut: false,
|
|
335
404
|
isSigner: false,
|
|
405
|
+
docs: [
|
|
406
|
+
'(different program) checked in light system program to derive',
|
|
407
|
+
'cpi_authority_pda and check that this program is the signer of the cpi.',
|
|
408
|
+
],
|
|
336
409
|
},
|
|
337
410
|
{
|
|
338
411
|
name: 'systemProgram',
|
|
@@ -349,11 +422,16 @@ const IDL = {
|
|
|
349
422
|
},
|
|
350
423
|
{
|
|
351
424
|
name: 'freeze',
|
|
425
|
+
docs: [
|
|
426
|
+
'Freezes compressed token accounts. Inputs must not be frozen. Creates as',
|
|
427
|
+
'many outputs as inputs. Balances and delegates are preserved.',
|
|
428
|
+
],
|
|
352
429
|
accounts: [
|
|
353
430
|
{
|
|
354
431
|
name: 'feePayer',
|
|
355
432
|
isMut: true,
|
|
356
433
|
isSigner: true,
|
|
434
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
357
435
|
},
|
|
358
436
|
{
|
|
359
437
|
name: 'authority',
|
|
@@ -394,6 +472,10 @@ const IDL = {
|
|
|
394
472
|
name: 'selfProgram',
|
|
395
473
|
isMut: false,
|
|
396
474
|
isSigner: false,
|
|
475
|
+
docs: [
|
|
476
|
+
'(different program) checked in light system program to derive',
|
|
477
|
+
'cpi_authority_pda and check that this program is the signer of the cpi.',
|
|
478
|
+
],
|
|
397
479
|
},
|
|
398
480
|
{
|
|
399
481
|
name: 'systemProgram',
|
|
@@ -415,11 +497,16 @@ const IDL = {
|
|
|
415
497
|
},
|
|
416
498
|
{
|
|
417
499
|
name: 'thaw',
|
|
500
|
+
docs: [
|
|
501
|
+
'Thaws frozen compressed token accounts. Inputs must be frozen. Creates',
|
|
502
|
+
'as many outputs as inputs. Balances and delegates are preserved.',
|
|
503
|
+
],
|
|
418
504
|
accounts: [
|
|
419
505
|
{
|
|
420
506
|
name: 'feePayer',
|
|
421
507
|
isMut: true,
|
|
422
508
|
isSigner: true,
|
|
509
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
423
510
|
},
|
|
424
511
|
{
|
|
425
512
|
name: 'authority',
|
|
@@ -460,6 +547,10 @@ const IDL = {
|
|
|
460
547
|
name: 'selfProgram',
|
|
461
548
|
isMut: false,
|
|
462
549
|
isSigner: false,
|
|
550
|
+
docs: [
|
|
551
|
+
'(different program) checked in light system program to derive',
|
|
552
|
+
'cpi_authority_pda and check that this program is the signer of the cpi.',
|
|
553
|
+
],
|
|
463
554
|
},
|
|
464
555
|
{
|
|
465
556
|
name: 'systemProgram',
|
|
@@ -481,22 +572,48 @@ const IDL = {
|
|
|
481
572
|
},
|
|
482
573
|
{
|
|
483
574
|
name: 'burn',
|
|
575
|
+
docs: [
|
|
576
|
+
'Burns compressed tokens and spl tokens from the pool account. Delegates',
|
|
577
|
+
'can burn tokens. The output compressed token account remains delegated.',
|
|
578
|
+
'Creates one output compressed token account.',
|
|
579
|
+
],
|
|
484
580
|
accounts: [
|
|
485
581
|
{
|
|
486
582
|
name: 'feePayer',
|
|
487
583
|
isMut: true,
|
|
488
584
|
isSigner: true,
|
|
585
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
489
586
|
},
|
|
490
587
|
{
|
|
491
588
|
name: 'authority',
|
|
492
589
|
isMut: false,
|
|
493
590
|
isSigner: true,
|
|
591
|
+
docs: [
|
|
592
|
+
'Authority is verified through proof since both owner and delegate',
|
|
593
|
+
'are included in the token data hash, which is a public input to the',
|
|
594
|
+
'validity proof.',
|
|
595
|
+
],
|
|
494
596
|
},
|
|
495
597
|
{
|
|
496
598
|
name: 'cpiAuthorityPda',
|
|
497
599
|
isMut: false,
|
|
498
600
|
isSigner: false,
|
|
499
601
|
},
|
|
602
|
+
{
|
|
603
|
+
name: 'mint',
|
|
604
|
+
isMut: true,
|
|
605
|
+
isSigner: false,
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
name: 'tokenPoolPda',
|
|
609
|
+
isMut: true,
|
|
610
|
+
isSigner: false,
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
name: 'tokenProgram',
|
|
614
|
+
isMut: false,
|
|
615
|
+
isSigner: false,
|
|
616
|
+
},
|
|
500
617
|
{
|
|
501
618
|
name: 'lightSystemProgram',
|
|
502
619
|
isMut: false,
|
|
@@ -552,11 +669,17 @@ const IDL = {
|
|
|
552
669
|
name: 'feePayer',
|
|
553
670
|
isMut: true,
|
|
554
671
|
isSigner: true,
|
|
672
|
+
docs: ['UNCHECKED: only pays fees.'],
|
|
555
673
|
},
|
|
556
674
|
{
|
|
557
675
|
name: 'authority',
|
|
558
676
|
isMut: false,
|
|
559
677
|
isSigner: true,
|
|
678
|
+
docs: [
|
|
679
|
+
'Authority is verified through proof since both owner and delegate',
|
|
680
|
+
'are included in the token data hash, which is a public input to the',
|
|
681
|
+
'validity proof.',
|
|
682
|
+
],
|
|
560
683
|
},
|
|
561
684
|
{
|
|
562
685
|
name: 'cpiAuthorityPda',
|
|
@@ -592,6 +715,10 @@ const IDL = {
|
|
|
592
715
|
name: 'selfProgram',
|
|
593
716
|
isMut: false,
|
|
594
717
|
isSigner: false,
|
|
718
|
+
docs: [
|
|
719
|
+
'(different program) checked in light system program to derive',
|
|
720
|
+
'cpi_authority_pda and check that this program is the signer of the cpi.',
|
|
721
|
+
],
|
|
595
722
|
},
|
|
596
723
|
{
|
|
597
724
|
name: 'tokenPoolPda',
|
|
@@ -633,24 +760,6 @@ const IDL = {
|
|
|
633
760
|
],
|
|
634
761
|
},
|
|
635
762
|
],
|
|
636
|
-
accounts: [
|
|
637
|
-
{
|
|
638
|
-
name: 'RegisteredProgram',
|
|
639
|
-
type: {
|
|
640
|
-
kind: 'struct',
|
|
641
|
-
fields: [
|
|
642
|
-
{
|
|
643
|
-
name: 'registeredProgramId',
|
|
644
|
-
type: 'publicKey',
|
|
645
|
-
},
|
|
646
|
-
{
|
|
647
|
-
name: 'groupAuthorityPda',
|
|
648
|
-
type: 'publicKey',
|
|
649
|
-
},
|
|
650
|
-
],
|
|
651
|
-
},
|
|
652
|
-
},
|
|
653
|
-
],
|
|
654
763
|
types: [
|
|
655
764
|
{
|
|
656
765
|
name: 'AccessMetadata',
|
|
@@ -665,7 +774,7 @@ const IDL = {
|
|
|
665
774
|
{
|
|
666
775
|
name: 'programOwner',
|
|
667
776
|
docs: [
|
|
668
|
-
'
|
|
777
|
+
'Program owner of the Merkle tree. This will be used for program owned Merkle trees.',
|
|
669
778
|
],
|
|
670
779
|
type: 'publicKey',
|
|
671
780
|
},
|
|
@@ -819,9 +928,9 @@ const IDL = {
|
|
|
819
928
|
{
|
|
820
929
|
name: 'delegatedTransfer',
|
|
821
930
|
docs: [
|
|
822
|
-
'
|
|
931
|
+
'Is required if the signer is delegate,',
|
|
932
|
+
'-> delegate is authority account,',
|
|
823
933
|
'owner = Some(owner) is the owner of the token account.',
|
|
824
|
-
'Is set if the signer is delegate',
|
|
825
934
|
],
|
|
826
935
|
type: {
|
|
827
936
|
option: {
|
|
@@ -863,11 +972,20 @@ const IDL = {
|
|
|
863
972
|
},
|
|
864
973
|
},
|
|
865
974
|
},
|
|
975
|
+
{
|
|
976
|
+
name: 'lamportsChangeAccountMerkleTreeIndex',
|
|
977
|
+
type: {
|
|
978
|
+
option: 'u8',
|
|
979
|
+
},
|
|
980
|
+
},
|
|
866
981
|
],
|
|
867
982
|
},
|
|
868
983
|
},
|
|
869
984
|
{
|
|
870
985
|
name: 'DelegatedTransfer',
|
|
986
|
+
docs: [
|
|
987
|
+
'Struct to provide the owner when the delegate is signer of the transaction.',
|
|
988
|
+
],
|
|
871
989
|
type: {
|
|
872
990
|
kind: 'struct',
|
|
873
991
|
fields: [
|
|
@@ -877,7 +995,15 @@ const IDL = {
|
|
|
877
995
|
},
|
|
878
996
|
{
|
|
879
997
|
name: 'delegateChangeAccountIndex',
|
|
880
|
-
|
|
998
|
+
docs: [
|
|
999
|
+
'Index of change compressed account in output compressed accounts. In',
|
|
1000
|
+
"case that the delegate didn't spend the complete delegated compressed",
|
|
1001
|
+
'account balance the change compressed account will be delegated to her',
|
|
1002
|
+
'as well.',
|
|
1003
|
+
],
|
|
1004
|
+
type: {
|
|
1005
|
+
option: 'u8',
|
|
1006
|
+
},
|
|
881
1007
|
},
|
|
882
1008
|
],
|
|
883
1009
|
},
|
|
@@ -913,6 +1039,15 @@ const IDL = {
|
|
|
913
1039
|
option: 'u64',
|
|
914
1040
|
},
|
|
915
1041
|
},
|
|
1042
|
+
{
|
|
1043
|
+
name: 'tlv',
|
|
1044
|
+
docs: [
|
|
1045
|
+
'Placeholder for TokenExtension tlv data (unimplemented)',
|
|
1046
|
+
],
|
|
1047
|
+
type: {
|
|
1048
|
+
option: 'bytes',
|
|
1049
|
+
},
|
|
1050
|
+
},
|
|
916
1051
|
],
|
|
917
1052
|
},
|
|
918
1053
|
},
|
|
@@ -1174,6 +1309,18 @@ const IDL = {
|
|
|
1174
1309
|
name: 'leafIndex',
|
|
1175
1310
|
type: 'u32',
|
|
1176
1311
|
},
|
|
1312
|
+
{
|
|
1313
|
+
name: 'queueIndex',
|
|
1314
|
+
docs: [
|
|
1315
|
+
'Index of leaf in queue. Placeholder of batched Merkle tree updates',
|
|
1316
|
+
'currently unimplemented.',
|
|
1317
|
+
],
|
|
1318
|
+
type: {
|
|
1319
|
+
option: {
|
|
1320
|
+
defined: 'QueueIndex',
|
|
1321
|
+
},
|
|
1322
|
+
},
|
|
1323
|
+
},
|
|
1177
1324
|
],
|
|
1178
1325
|
},
|
|
1179
1326
|
},
|
|
@@ -1200,6 +1347,15 @@ const IDL = {
|
|
|
1200
1347
|
name: 'merkleTreeIndex',
|
|
1201
1348
|
type: 'u8',
|
|
1202
1349
|
},
|
|
1350
|
+
{
|
|
1351
|
+
name: 'tlv',
|
|
1352
|
+
docs: [
|
|
1353
|
+
'Placeholder for TokenExtension tlv data (unimplemented)',
|
|
1354
|
+
],
|
|
1355
|
+
type: {
|
|
1356
|
+
option: 'bytes',
|
|
1357
|
+
},
|
|
1358
|
+
},
|
|
1203
1359
|
],
|
|
1204
1360
|
},
|
|
1205
1361
|
},
|
|
@@ -1277,6 +1433,24 @@ const IDL = {
|
|
|
1277
1433
|
],
|
|
1278
1434
|
},
|
|
1279
1435
|
},
|
|
1436
|
+
{
|
|
1437
|
+
name: 'QueueIndex',
|
|
1438
|
+
type: {
|
|
1439
|
+
kind: 'struct',
|
|
1440
|
+
fields: [
|
|
1441
|
+
{
|
|
1442
|
+
name: 'queueId',
|
|
1443
|
+
docs: ['Id of queue in queue account.'],
|
|
1444
|
+
type: 'u8',
|
|
1445
|
+
},
|
|
1446
|
+
{
|
|
1447
|
+
name: 'index',
|
|
1448
|
+
docs: ['Index of compressed account hash in queue.'],
|
|
1449
|
+
type: 'u16',
|
|
1450
|
+
},
|
|
1451
|
+
],
|
|
1452
|
+
},
|
|
1453
|
+
},
|
|
1280
1454
|
{
|
|
1281
1455
|
name: 'RolloverMetadata',
|
|
1282
1456
|
type: {
|
|
@@ -1363,6 +1537,15 @@ const IDL = {
|
|
|
1363
1537
|
defined: 'AccountState',
|
|
1364
1538
|
},
|
|
1365
1539
|
},
|
|
1540
|
+
{
|
|
1541
|
+
name: 'tlv',
|
|
1542
|
+
docs: [
|
|
1543
|
+
'Placeholder for TokenExtension tlv data (unimplemented)',
|
|
1544
|
+
],
|
|
1545
|
+
type: {
|
|
1546
|
+
option: 'bytes',
|
|
1547
|
+
},
|
|
1548
|
+
},
|
|
1366
1549
|
],
|
|
1367
1550
|
},
|
|
1368
1551
|
},
|
|
@@ -1417,11 +1600,13 @@ function packCompressedTokenAccounts(params) {
|
|
|
1417
1600
|
merkleTreePubkeyIndex,
|
|
1418
1601
|
nullifierQueuePubkeyIndex,
|
|
1419
1602
|
leafIndex: account.compressedAccount.leafIndex,
|
|
1603
|
+
queueIndex: null,
|
|
1420
1604
|
},
|
|
1421
1605
|
rootIndex: rootIndices[index],
|
|
1422
1606
|
lamports: account.compressedAccount.lamports.eq(stateless_js.bn(0))
|
|
1423
1607
|
? null
|
|
1424
1608
|
: account.compressedAccount.lamports,
|
|
1609
|
+
tlv: null,
|
|
1425
1610
|
});
|
|
1426
1611
|
});
|
|
1427
1612
|
/// pack output state trees
|
|
@@ -1437,6 +1622,7 @@ function packCompressedTokenAccounts(params) {
|
|
|
1437
1622
|
? null
|
|
1438
1623
|
: tokenTransferOutputs[index].lamports,
|
|
1439
1624
|
merkleTreeIndex,
|
|
1625
|
+
tlv: null,
|
|
1440
1626
|
});
|
|
1441
1627
|
});
|
|
1442
1628
|
// to meta
|
|
@@ -3985,33 +4171,6 @@ function addSigners(keys, ownerOrAuthority, multiSigners) {
|
|
|
3985
4171
|
return keys;
|
|
3986
4172
|
}
|
|
3987
4173
|
|
|
3988
|
-
/** TODO: docs */
|
|
3989
|
-
const approveInstructionData = struct([u8('instruction'), u64('amount')]);
|
|
3990
|
-
/**
|
|
3991
|
-
* Construct an Approve instruction
|
|
3992
|
-
*
|
|
3993
|
-
* @param account Account to set the delegate for
|
|
3994
|
-
* @param delegate Account authorized to transfer tokens from the account
|
|
3995
|
-
* @param owner Owner of the account
|
|
3996
|
-
* @param amount Maximum number of tokens the delegate may transfer
|
|
3997
|
-
* @param multiSigners Signing accounts if `owner` is a multisig
|
|
3998
|
-
* @param programId SPL Token program account
|
|
3999
|
-
*
|
|
4000
|
-
* @return Instruction to add to a transaction
|
|
4001
|
-
*/
|
|
4002
|
-
function createApproveInstruction(account, delegate, owner, amount, multiSigners = [], programId = TOKEN_PROGRAM_ID) {
|
|
4003
|
-
const keys = addSigners([
|
|
4004
|
-
{ pubkey: account, isSigner: false, isWritable: true },
|
|
4005
|
-
{ pubkey: delegate, isSigner: false, isWritable: false },
|
|
4006
|
-
], owner, multiSigners);
|
|
4007
|
-
const data = Buffer.alloc(approveInstructionData.span);
|
|
4008
|
-
approveInstructionData.encode({
|
|
4009
|
-
instruction: TokenInstruction.Approve,
|
|
4010
|
-
amount: BigInt(amount),
|
|
4011
|
-
}, data);
|
|
4012
|
-
return new web3_js.TransactionInstruction({ keys, programId, data });
|
|
4013
|
-
}
|
|
4014
|
-
|
|
4015
4174
|
var AccountType;
|
|
4016
4175
|
(function (AccountType) {
|
|
4017
4176
|
AccountType[AccountType["Uninitialized"] = 0] = "Uninitialized";
|
|
@@ -4335,6 +4494,7 @@ function createTransferOutputState(inputCompressedTokenAccounts, toAddress, amou
|
|
|
4335
4494
|
owner: toAddress,
|
|
4336
4495
|
amount,
|
|
4337
4496
|
lamports: inputLamports,
|
|
4497
|
+
tlv: null,
|
|
4338
4498
|
},
|
|
4339
4499
|
];
|
|
4340
4500
|
}
|
|
@@ -4346,11 +4506,13 @@ function createTransferOutputState(inputCompressedTokenAccounts, toAddress, amou
|
|
|
4346
4506
|
owner: inputCompressedTokenAccounts[0].parsed.owner,
|
|
4347
4507
|
amount: changeAmount,
|
|
4348
4508
|
lamports: inputLamports,
|
|
4509
|
+
tlv: null,
|
|
4349
4510
|
},
|
|
4350
4511
|
{
|
|
4351
4512
|
owner: toAddress,
|
|
4352
4513
|
amount,
|
|
4353
4514
|
lamports: stateless_js.bn(0),
|
|
4515
|
+
tlv: null,
|
|
4354
4516
|
},
|
|
4355
4517
|
];
|
|
4356
4518
|
return outputCompressedAccounts;
|
|
@@ -4379,6 +4541,7 @@ function createDecompressOutputState(inputCompressedTokenAccounts, amount) {
|
|
|
4379
4541
|
owner: inputCompressedTokenAccounts[0].parsed.owner,
|
|
4380
4542
|
amount: changeAmount,
|
|
4381
4543
|
lamports: inputLamports,
|
|
4544
|
+
tlv: null,
|
|
4382
4545
|
},
|
|
4383
4546
|
];
|
|
4384
4547
|
return tokenTransferOutputs;
|
|
@@ -4472,7 +4635,7 @@ class CompressedTokenProgram {
|
|
|
4472
4635
|
const amounts = stateless_js.toArray(amount).map(amount => stateless_js.bn(amount));
|
|
4473
4636
|
const toPubkeys = stateless_js.toArray(toPubkey);
|
|
4474
4637
|
const instruction = await this.program.methods
|
|
4475
|
-
.mintTo(toPubkeys, amounts)
|
|
4638
|
+
.mintTo(toPubkeys, amounts, null)
|
|
4476
4639
|
.accounts({
|
|
4477
4640
|
feePayer,
|
|
4478
4641
|
authority,
|
|
@@ -4487,6 +4650,7 @@ class CompressedTokenProgram {
|
|
|
4487
4650
|
accountCompressionProgram: systemKeys.accountCompressionProgram,
|
|
4488
4651
|
merkleTree: merkleTree !== null && merkleTree !== void 0 ? merkleTree : stateless_js.defaultTestStateTreeAccounts().merkleTree,
|
|
4489
4652
|
selfProgram: this.programId,
|
|
4653
|
+
solPoolPda: null,
|
|
4490
4654
|
})
|
|
4491
4655
|
.instruction();
|
|
4492
4656
|
return instruction;
|
|
@@ -4501,7 +4665,7 @@ class CompressedTokenProgram {
|
|
|
4501
4665
|
/// 1. Mint to existing ATA of mintAuthority.
|
|
4502
4666
|
const splMintToInstruction = createMintToInstruction(mint, authorityTokenAccount, authority, amount);
|
|
4503
4667
|
/// 2. Compress from mint authority ATA to recipient compressed account
|
|
4504
|
-
const
|
|
4668
|
+
const compressInstruction = await this.compress({
|
|
4505
4669
|
payer: feePayer,
|
|
4506
4670
|
owner: authority,
|
|
4507
4671
|
source: authorityTokenAccount,
|
|
@@ -4510,7 +4674,7 @@ class CompressedTokenProgram {
|
|
|
4510
4674
|
amount: params.amount,
|
|
4511
4675
|
outputStateTree: merkleTree,
|
|
4512
4676
|
});
|
|
4513
|
-
return [splMintToInstruction,
|
|
4677
|
+
return [splMintToInstruction, compressInstruction];
|
|
4514
4678
|
}
|
|
4515
4679
|
/**
|
|
4516
4680
|
* Construct transfer instruction for compressed tokens
|
|
@@ -4534,6 +4698,7 @@ class CompressedTokenProgram {
|
|
|
4534
4698
|
compressOrDecompressAmount: null,
|
|
4535
4699
|
isCompress: false,
|
|
4536
4700
|
cpiContext: null,
|
|
4701
|
+
lamportsChangeAccountMerkleTreeIndex: null,
|
|
4537
4702
|
};
|
|
4538
4703
|
const encodedData = this.program.coder.types.encode('CompressedTokenInstructionDataTransfer', data);
|
|
4539
4704
|
const { accountCompressionAuthority, noopProgram, registeredProgramPda, accountCompressionProgram, } = stateless_js.defaultStaticAccountsStruct();
|
|
@@ -4558,8 +4723,8 @@ class CompressedTokenProgram {
|
|
|
4558
4723
|
return instruction;
|
|
4559
4724
|
}
|
|
4560
4725
|
/**
|
|
4561
|
-
* Construct
|
|
4562
|
-
* @returns
|
|
4726
|
+
* Construct compress instruction
|
|
4727
|
+
* @returns compressInstruction
|
|
4563
4728
|
*/
|
|
4564
4729
|
static async compress(params) {
|
|
4565
4730
|
const { payer, owner, source, toAddress, mint, outputStateTree } = params;
|
|
@@ -4569,6 +4734,7 @@ class CompressedTokenProgram {
|
|
|
4569
4734
|
owner: toAddress,
|
|
4570
4735
|
amount,
|
|
4571
4736
|
lamports: stateless_js.bn(0),
|
|
4737
|
+
tlv: null,
|
|
4572
4738
|
},
|
|
4573
4739
|
];
|
|
4574
4740
|
const { inputTokenDataWithContext, packedOutputTokenData, remainingAccountMetas, } = packCompressedTokenAccounts({
|
|
@@ -4586,10 +4752,10 @@ class CompressedTokenProgram {
|
|
|
4586
4752
|
compressOrDecompressAmount: amount,
|
|
4587
4753
|
isCompress: true,
|
|
4588
4754
|
cpiContext: null,
|
|
4755
|
+
lamportsChangeAccountMerkleTreeIndex: null,
|
|
4589
4756
|
};
|
|
4590
4757
|
const encodedData = this.program.coder.types.encode('CompressedTokenInstructionDataTransfer', data);
|
|
4591
4758
|
const { accountCompressionAuthority, noopProgram, registeredProgramPda, accountCompressionProgram, } = stateless_js.defaultStaticAccountsStruct();
|
|
4592
|
-
const approveInstruction = createApproveInstruction(source, this.deriveCpiAuthorityPda, owner, BigInt(amount.toString()));
|
|
4593
4759
|
const instruction = await this.program.methods
|
|
4594
4760
|
.transfer(encodedData)
|
|
4595
4761
|
.accounts({
|
|
@@ -4608,7 +4774,7 @@ class CompressedTokenProgram {
|
|
|
4608
4774
|
})
|
|
4609
4775
|
.remainingAccounts(remainingAccountMetas)
|
|
4610
4776
|
.instruction();
|
|
4611
|
-
return
|
|
4777
|
+
return instruction;
|
|
4612
4778
|
}
|
|
4613
4779
|
/**
|
|
4614
4780
|
* Construct decompress instruction
|
|
@@ -4634,6 +4800,7 @@ class CompressedTokenProgram {
|
|
|
4634
4800
|
compressOrDecompressAmount: amount,
|
|
4635
4801
|
isCompress: false,
|
|
4636
4802
|
cpiContext: null,
|
|
4803
|
+
lamportsChangeAccountMerkleTreeIndex: null,
|
|
4637
4804
|
};
|
|
4638
4805
|
const encodedData = this.program.coder.types.encode('CompressedTokenInstructionDataTransfer', data);
|
|
4639
4806
|
const { accountCompressionAuthority, noopProgram, registeredProgramPda, accountCompressionProgram, } = stateless_js.defaultStaticAccountsStruct();
|
|
@@ -4720,7 +4887,7 @@ async function approveAndMintTo(rpc, payer, mint, destination, authority, amount
|
|
|
4720
4887
|
*/
|
|
4721
4888
|
async function compress(rpc, payer, mint, amount, owner, sourceTokenAccount, toAddress, merkleTree, confirmOptions) {
|
|
4722
4889
|
amount = stateless_js.bn(amount);
|
|
4723
|
-
const
|
|
4890
|
+
const compressIx = await CompressedTokenProgram.compress({
|
|
4724
4891
|
payer: payer.publicKey,
|
|
4725
4892
|
owner: owner.publicKey,
|
|
4726
4893
|
source: sourceTokenAccount,
|
|
@@ -4735,7 +4902,6 @@ async function compress(rpc, payer, mint, amount, owner, sourceTokenAccount, toA
|
|
|
4735
4902
|
web3_js.ComputeBudgetProgram.setComputeUnitLimit({
|
|
4736
4903
|
units: 1000000,
|
|
4737
4904
|
}),
|
|
4738
|
-
approveIx,
|
|
4739
4905
|
compressIx,
|
|
4740
4906
|
], payer, blockhashCtx.blockhash, additionalSigners);
|
|
4741
4907
|
const txId = await stateless_js.sendAndConfirmTx(rpc, signedTx, confirmOptions, blockhashCtx);
|